Skip to content

Created Drag Mode (previously god mode) #1145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 26, 2025
Merged
2 changes: 2 additions & 0 deletions fission/src/Synthesis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import ContextMenu from "./ui/components/ContextMenu.tsx"
import GlobalUIComponent from "./ui/components/GlobalUIComponent.tsx"
import InitialConfigPanel from "./ui/panels/configuring/initial-config/InitialConfigPanel.tsx"
import WPILibConnectionStatus from "./ui/components/WPILibConnectionStatus.tsx"
import DragModeIndicator from "./ui/components/DragModeIndicator.tsx"
import AutoTestPanel from "./ui/panels/simulation/AutoTestPanel.tsx"
import TouchControls from "./ui/components/TouchControls.tsx"
import GraphicsSettings from "./ui/panels/GraphicsSettingsPanel.tsx"
Expand Down Expand Up @@ -195,6 +196,7 @@ function Synthesis() {
<ProgressNotifications key={"progress-notifications"} />
<ToastContainer key={"toast-container"} />
<WPILibConnectionStatus />
<DragModeIndicator />

{!consentPopupDisable ? (
<AnalyticsConsent onClose={onDisableConsent} onConsent={onConsent} />
Expand Down
8 changes: 8 additions & 0 deletions fission/src/systems/World.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import SceneRenderer from "./scene/SceneRenderer"
import SimulationSystem from "./simulation/SimulationSystem"
import InputSystem from "./input/InputSystem"
import AnalyticsSystem, { AccumTimes } from "./analytics/AnalyticsSystem"
import DragModeSystem from "./scene/DragModeSystem"

class World {
private static _isAlive: boolean = false
Expand All @@ -16,6 +17,7 @@ class World {
private static _simulationSystem: SimulationSystem
private static _inputSystem: InputSystem
private static _analyticsSystem: AnalyticsSystem | undefined = undefined
private static _dragModeSystem: DragModeSystem

private static _accumTimes: AccumTimes = {
frames: 0,
Expand Down Expand Up @@ -49,6 +51,9 @@ class World {
public static get AnalyticsSystem() {
return World._analyticsSystem
}
public static get DragModeSystem() {
return World._dragModeSystem
}

public static resetAccumTimes() {
this._accumTimes = {
Expand All @@ -71,6 +76,7 @@ class World {
World._physicsSystem = new PhysicsSystem()
World._simulationSystem = new SimulationSystem()
World._inputSystem = new InputSystem()
World._dragModeSystem = new DragModeSystem()
try {
World._analyticsSystem = new AnalyticsSystem()
} catch (_) {
Expand All @@ -87,6 +93,7 @@ class World {
World._sceneRenderer.Destroy()
World._simulationSystem.Destroy()
World._inputSystem.Destroy()
World._dragModeSystem.Destroy()

World._analyticsSystem?.Destroy()
}
Expand All @@ -101,6 +108,7 @@ class World {
this._accumTimes.physicsTime += this.time(() => World._physicsSystem.Update(this._currentDeltaT))
this._accumTimes.inputTime += this.time(() => World._inputSystem.Update(this._currentDeltaT))
this._accumTimes.sceneTime += this.time(() => World._sceneRenderer.Update(this._currentDeltaT))
World._dragModeSystem.Update(this._currentDeltaT)
})

World._analyticsSystem?.Update(this._currentDeltaT)
Expand Down
35 changes: 1 addition & 34 deletions fission/src/systems/physics/PhysicsSystem.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
JoltRVec3_JoltVec3,
JoltVec3_JoltRVec3,
JoltVec3_ThreeVector3,
MirabufFloatArr_JoltFloat3,
MirabufFloatArr_JoltVec3,
MirabufVector3_JoltRVec3,
Expand Down Expand Up @@ -46,7 +45,7 @@ const RobotLayers: number[] = [
3, 4, 5, 6, 7, 8, 9,
]

// Layer for ghost object in god mode, interacts with nothing
// Layer for ghost objects used in constraint systems, interacts with nothing
const LAYER_GHOST = 10

// Please update this accordingly.
Expand Down Expand Up @@ -1306,38 +1305,6 @@ class PhysicsSystem extends WorldSystem {
return body
}

/**
* Creates a ghost object and a distance constraint that connects it to the given body
* The ghost body is part of the LAYER_GHOST which doesn't interact with any other layer
* The caller is responsible for cleaning up the ghost body and the constraint
*
* @param id The id of the body to be attatched to and moved
* @returns The ghost body and the constraint
*/

public CreateGodModeBody(id: Jolt.BodyID, anchorPoint: Jolt.Vec3): [Jolt.Body, Jolt.Constraint] {
const body = this.GetBody(id)
const ghostBody = this.CreateBox(
new THREE.Vector3(0.05, 0.05, 0.05),
undefined,
JoltVec3_ThreeVector3(anchorPoint),
undefined
)

const ghostBodyId = ghostBody.GetID()
this._joltBodyInterface.SetObjectLayer(ghostBodyId, LAYER_GHOST)
this._joltBodyInterface.AddBody(ghostBodyId, JOLT.EActivation_Activate)
this._bodies.push(ghostBodyId)

const constraintSettings = new JOLT.PointConstraintSettings()
constraintSettings.mPoint1 = constraintSettings.mPoint2 = JoltVec3_JoltRVec3(anchorPoint)
const constraint = constraintSettings.Create(ghostBody, body)
this._joltPhysSystem.AddConstraint(constraint)
this._constraints.push(constraint)

return [ghostBody, constraint]
}

public CreateSensor(shapeSettings: Jolt.ShapeSettings): Jolt.BodyID | undefined {
const shape = shapeSettings.Create()
if (shape.HasError()) {
Expand Down
14 changes: 13 additions & 1 deletion fission/src/systems/scene/CameraControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export abstract class CameraControls {
public abstract dispose(): void
}

interface SphericalCoords {
export interface SphericalCoords {
theta: number
phi: number
r: number
Expand Down Expand Up @@ -112,6 +112,18 @@ export class CustomOrbitControls extends CameraControls {
return this._focusProvider
}

public get coords(): SphericalCoords {
return this._coords
}

public get focus(): THREE.Matrix4 {
return this._focus
}

public set focus(matrix: THREE.Matrix4) {
this._focus.copy(matrix)
}

public constructor(mainCamera: THREE.Camera, interactionHandler: ScreenInteractionHandler) {
super("Orbit")

Expand Down
Loading
Loading