Skip to content

Commit

Permalink
Delete Assembly Hot Fix (#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
HunterBarclay authored Jul 16, 2024
2 parents 99f8ecc + 0f5454b commit 8d208bc
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions fission/src/mirabuf/MirabufSceneObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class MirabufSceneObject extends SceneObject {
private _physicsLayerReserve: LayerReserve | undefined

private _transformGizmos: TransformGizmos | undefined
private _deleteGizmoOnEscape: boolean = true

private _intakePreferences: IntakePreferences | undefined
private _ejectorPreferences: EjectorPreferences | undefined
Expand Down Expand Up @@ -160,16 +159,11 @@ class MirabufSceneObject extends SceneObject {
if (this._transformGizmos) {
if (InputSystem.isKeyPressed("Enter")) {
// confirming placement of the mirabuf object
this._transformGizmos.RemoveGizmos()
this.EnablePhysics()
this._transformGizmos = undefined
this.DisableTransformControls()
return
} else if (InputSystem.isKeyPressed("Escape") && this._deleteGizmoOnEscape) {
} else if (InputSystem.isKeyPressed("Escape")) {
// cancelling the creation of the mirabuf scene object
this._transformGizmos.RemoveGizmos()
World.SceneRenderer.RemoveSceneObject(this.id)
this._transformGizmos = undefined
this._deleteGizmoOnEscape = false
return
}

Expand Down Expand Up @@ -222,6 +216,7 @@ class MirabufSceneObject extends SceneObject {
World.PhysicsSystem.RemoveBodyAssocation(bodyId)
})

this.DisableTransformControls()
World.SimulationSystem.UnregisterMechanism(this._mechanism)
World.PhysicsSystem.DestroyMechanism(this._mechanism)
this._mirabufInstance.Dispose(World.SceneRenderer.scene)
Expand Down Expand Up @@ -313,7 +308,12 @@ class MirabufSceneObject extends SceneObject {
return true
}

/**
* Changes the mode of the mirabuf object from being interacted with to being placed.
*/
public EnableTransformControls(): void {
if (this._transformGizmos) return

this._transformGizmos = new TransformGizmos(
new THREE.Mesh(
new THREE.SphereGeometry(3.0),
Expand All @@ -326,6 +326,16 @@ class MirabufSceneObject extends SceneObject {
this.DisablePhysics()
}

/**
* Changes the mode of the mirabuf object from being placed to being interacted with.
*/
public DisableTransformControls(): void {
if (!this._transformGizmos) return
this._transformGizmos?.RemoveGizmos()
this._transformGizmos = undefined
this.EnablePhysics()
}

private getPreferences(): void {
this._intakePreferences = PreferencesSystem.getRobotPreferences(this.assemblyName)?.intake
this._ejectorPreferences = PreferencesSystem.getRobotPreferences(this.assemblyName)?.ejector
Expand Down

0 comments on commit 8d208bc

Please sign in to comment.