Skip to content

Commit

Permalink
Ripping out old near interaction code. Buttons no longer react proper…
Browse files Browse the repository at this point in the history
…ly to variable press depths
  • Loading branch information
rickfromwork committed Jun 24, 2021
1 parent 4e4a3b2 commit 1fcd24d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 52 deletions.
36 changes: 6 additions & 30 deletions gui/src/3D/gui3DManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IDisposable, Scene } from "babylonjs/scene";

import { Container3D } from "./controls/container3D";
import { Control3D } from "./controls/control3D";
import { TouchButton3D } from "./controls/touchButton3D";
//import { TouchButton3D } from "./controls/touchButton3D";

/**
* Class used to manage 3D user interface
Expand All @@ -24,9 +24,9 @@ export class GUI3DManager implements IDisposable {
private _rootContainer: Container3D;
private _pointerObserver: Nullable<Observer<PointerInfo>>;
private _pointerOutObserver: Nullable<Observer<number>>;
private _touchableButtons = new Set<TouchButton3D>();
private _touchIds = new Map<string, number>();
private static _touchIdCounter = 300;
// private _touchableButtons = new Set<TouchButton3D>();
// private _touchIds = new Map<string, number>();
// private static _touchIdCounter = 300;
/** @hidden */
public _lastPickedControl: Control3D;
/** @hidden */
Expand Down Expand Up @@ -165,7 +165,7 @@ export class GUI3DManager implements IDisposable {

return true;
}

/*
private _processTouchControls = () => {
let utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
if (utilityLayerScene) {
Expand Down Expand Up @@ -202,7 +202,7 @@ export class GUI3DManager implements IDisposable {
});
});
}
};
};*/

/**
* Gets the root container
Expand All @@ -227,16 +227,6 @@ export class GUI3DManager implements IDisposable {
*/
public addControl(control: Control3D): GUI3DManager {
this._rootContainer.addControl(control);

let utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
if (utilityLayerScene && control instanceof TouchButton3D) {
if (this._touchableButtons.size == 0) {
utilityLayerScene.registerBeforeRender(this._processTouchControls);
}

this._touchableButtons.add(control as TouchButton3D);
}

return this;
}

Expand All @@ -247,16 +237,6 @@ export class GUI3DManager implements IDisposable {
*/
public removeControl(control: Control3D): GUI3DManager {
this._rootContainer.removeControl(control);

let utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
if (utilityLayerScene && control instanceof TouchButton3D) {
this._touchableButtons.delete(control);

if (this._touchableButtons.size == 0) {
utilityLayerScene.unregisterBeforeRender(this._processTouchControls);
}
}

return this;
}

Expand Down Expand Up @@ -297,10 +277,6 @@ export class GUI3DManager implements IDisposable {
let utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;

if (utilityLayerScene) {
if (this._touchableButtons.size != 0) {
utilityLayerScene.unregisterBeforeRender(this._processTouchControls);
}

if (this._pointerObserver) {
utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
this._pointerObserver = null;
Expand Down
22 changes: 0 additions & 22 deletions src/XR/features/WebXRHandTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { Engine } from "../../Engines/engine";
import { Tools } from "../../Misc/tools";
import { Axis } from "../../Maths/math.axis";
import { TransformNode } from "../../Meshes/transformNode";
import { Tags } from "../../Misc/tags";
import { Bone } from "../../Bones/bone";

declare const XRHand: XRHand;
Expand Down Expand Up @@ -95,10 +94,6 @@ export interface IWebXRHandTrackingOptions {
right: string[];
left: string[];
};
/**
* The utilityLayer scene that contains the 3D UI elements. Passing this in turns on near interactions with the index finger tip
*/
sceneForNearInteraction?: Scene;
};
}

Expand Down Expand Up @@ -258,7 +253,6 @@ export class WebXRHand implements IDisposable {
* @param _handMesh an optional hand mesh. if not provided, ours will be used
* @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
* @param disableDefaultHandMesh should the default mesh creation be disabled
* @param _nearInteractionMesh as optional mesh used for near interaction collision checking
* @param _leftHandedMeshes are the hand meshes left-handed-system meshes
*/
constructor(
Expand All @@ -269,7 +263,6 @@ export class WebXRHand implements IDisposable {
private _handMesh?: AbstractMesh,
private _rigMapping?: string[],
disableDefaultHandMesh?: boolean,
private _nearInteractionMesh?: Nullable<AbstractMesh>,
private _leftHandedMeshes?: boolean
) {
this.handPartsDefinition = this.generateHandPartsDefinition();
Expand Down Expand Up @@ -395,12 +388,6 @@ export class WebXRHand implements IDisposable {
}
}
});

// Update the invisible fingertip collidable
if (this._nearInteractionMesh && this.trackedMeshes.has("index-finger-tip")) {
const indexTipPose = this.trackedMeshes.get("index-finger-tip")!.position;
this._nearInteractionMesh.position.set(indexTipPose.x, indexTipPose.y, indexTipPose.z);
}
}

/**
Expand All @@ -417,7 +404,6 @@ export class WebXRHand implements IDisposable {
*/
public dispose() {
this.trackedMeshes.forEach((mesh) => mesh.dispose(true)); // spare anything which might have been parented to one
this._nearInteractionMesh?.dispose();
this.onHandMeshReadyObservable.clear();
// dispose the hand mesh, if it is the default one
if (this._defaultHandMesh && this._handMesh) {
Expand Down Expand Up @@ -683,13 +669,6 @@ export class WebXRHandTracking extends WebXRAbstractFeature {
trackedMeshes.set(handJointReferenceArray[i], newInstance);
}

let touchMesh: Nullable<AbstractMesh> = null;
if (this.options.jointMeshes?.sceneForNearInteraction) {
touchMesh = SphereBuilder.CreateSphere(`${xrController.uniqueId}-handJoint-indexCollidable`, {}, this.options.jointMeshes.sceneForNearInteraction);
touchMesh.isVisible = false;
Tags.AddTagsTo(touchMesh, "touchEnabled");
}

const handedness = xrController.inputSource.handedness === "right" ? "right" : "left";
const handMesh = this.options.jointMeshes?.handMeshes && this.options.jointMeshes?.handMeshes[handedness];
const rigMapping = this.options.jointMeshes?.rigMapping && this.options.jointMeshes?.rigMapping[handedness];
Expand All @@ -699,7 +678,6 @@ export class WebXRHandTracking extends WebXRAbstractFeature {
handMesh,
rigMapping,
this.options.jointMeshes?.disableDefaultHandMesh,
touchMesh,
this.options.jointMeshes?.leftHandedSystemMeshes
);

Expand Down

0 comments on commit 1fcd24d

Please sign in to comment.