Moved grabbing to base controller class.
This commit is contained in:
parent
745aed33af
commit
160138b3f4
@ -1,4 +1,4 @@
|
||||
import {AbstractMesh, Scene, Vector3, WebXRInputSource} from "@babylonjs/core";
|
||||
import {AbstractMesh, Scene, Vector3, WebXRControllerComponent, WebXRInputSource} from "@babylonjs/core";
|
||||
|
||||
export class Base {
|
||||
static stickVector = Vector3.Zero();
|
||||
@ -23,9 +23,22 @@ export class Base {
|
||||
}
|
||||
});
|
||||
}
|
||||
this.initGrip(init.components['xr-standard-squeeze']);
|
||||
});
|
||||
}
|
||||
public mesh() {
|
||||
return this.controller.grip;
|
||||
|
||||
private initGrip(grip: WebXRControllerComponent) {
|
||||
grip.onButtonStateChangedObservable.add((value) => {
|
||||
if (value.value > .5) {
|
||||
if (this.currentMesh) {
|
||||
this.currentMesh.setParent(this.controller.pointer);
|
||||
}
|
||||
} else {
|
||||
if (this.currentMesh) {
|
||||
this.currentMesh.setParent(null);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -21,7 +21,7 @@ export class Right extends Base {
|
||||
this.initBButton(init.components['b-button']);
|
||||
this.initAButton(init.components['a-button']);
|
||||
this.initThumbstick(init.components['xr-standard-thumbstick']);
|
||||
this.initGrip(init.components['xr-standard-squeeze']);
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
@ -115,20 +115,7 @@ export class Right extends Base {
|
||||
}
|
||||
|
||||
|
||||
private initGrip(grip: WebXRControllerComponent) {
|
||||
grip.onButtonStateChangedObservable.add((value) => {
|
||||
if (value.value > .5) {
|
||||
if (this.currentMesh) {
|
||||
this.currentMesh.setParent(this.controller.pointer);
|
||||
}
|
||||
} else {
|
||||
if (this.currentMesh) {
|
||||
this.currentMesh.setParent(null);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
public setBMenu(menu: Bmenu) {
|
||||
this.bmenu = menu;
|
||||
this.bmenu.setController(this.controller);
|
||||
|
||||
@ -2,5 +2,6 @@ export enum BmenuState {
|
||||
NONE,
|
||||
ADDING, // Adding a new entity
|
||||
DROPPING, // Dropping an entity
|
||||
REMOVING, // Removing an entity
|
||||
|
||||
}
|
||||
@ -1,10 +1,4 @@
|
||||
import {
|
||||
AbstractMesh,
|
||||
Scene,
|
||||
Vector3,
|
||||
WebXRExperienceHelper,
|
||||
WebXRInputSource
|
||||
} from "@babylonjs/core";
|
||||
import {AbstractMesh, Scene, Vector3, WebXRExperienceHelper, WebXRInputSource} from "@babylonjs/core";
|
||||
import {GUI3DManager, NearMenu, TouchHolographicButton} from "@babylonjs/gui";
|
||||
import {DiagramManager} from "../diagram/diagramManager";
|
||||
import {BmenuState} from "./MenuState";
|
||||
@ -79,6 +73,7 @@ export class Bmenu {
|
||||
panel.addButton(this.makeButton("Add Sphere", "addSphere"));
|
||||
panel.addButton(this.makeButton("Add Cylinder", "addCylinder"));
|
||||
panel.addButton(this.makeButton("Add Text", "addText"));
|
||||
panel.addButton(this.makeButton("Remove", "remove"));
|
||||
panel.addButton(this.makeButton("Done Adding", "doneAdding"));
|
||||
this.manager.controlScaling = .5;
|
||||
|
||||
@ -119,7 +114,9 @@ export class Bmenu {
|
||||
break;
|
||||
case "doneAdding":
|
||||
this.state = BmenuState.NONE;
|
||||
|
||||
break;
|
||||
case "remove":
|
||||
this.state = BmenuState.REMOVING;
|
||||
break;
|
||||
default:
|
||||
console.log("Unknown button");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user