Added clickMenu cleanup when multiple clicks.
This commit is contained in:
parent
d0b08b72e2
commit
1a3e9b879e
@ -217,6 +217,9 @@ export class Base {
|
|||||||
this.diagramManager.diagramMenuManager.connect(mesh);
|
this.diagramManager.diagramMenuManager.connect(mesh);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if (this.clickMenu) {
|
||||||
|
this.clickMenu.dispose();
|
||||||
|
}
|
||||||
this.clickMenu = this.diagramManager.diagramMenuManager.createClickMenu(mesh, this.xrInputSource);
|
this.clickMenu = this.diagramManager.diagramMenuManager.createClickMenu(mesh, this.xrInputSource);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -5,13 +5,13 @@ const POINTER_UP = "pointerup";
|
|||||||
|
|
||||||
export class ClickMenu {
|
export class ClickMenu {
|
||||||
private readonly _mesh: AbstractMesh;
|
private readonly _mesh: AbstractMesh;
|
||||||
private readonly transform: TransformNode;
|
private readonly _transformNode: TransformNode;
|
||||||
public onClickMenuObservable: Observable<ActionEvent> = new Observable<ActionEvent>();
|
public onClickMenuObservable: Observable<ActionEvent> = new Observable<ActionEvent>();
|
||||||
|
|
||||||
constructor(mesh: AbstractMesh) {
|
constructor(mesh: AbstractMesh) {
|
||||||
this._mesh = mesh;
|
this._mesh = mesh;
|
||||||
const scene = mesh.getScene();
|
const scene = mesh.getScene();
|
||||||
this.transform = new TransformNode("transform", scene);
|
this._transformNode = new TransformNode("transform", scene);
|
||||||
let x = -.54 / 2;
|
let x = -.54 / 2;
|
||||||
|
|
||||||
this.makeNewButton("Remove", "remove", scene, x += .11)
|
this.makeNewButton("Remove", "remove", scene, x += .11)
|
||||||
@ -55,29 +55,29 @@ export class ClickMenu {
|
|||||||
}, -1, false, this, false);
|
}, -1, false, this, false);
|
||||||
|
|
||||||
const platform = scene.getMeshByName("platform");
|
const platform = scene.getMeshByName("platform");
|
||||||
this.transform.parent = scene.activeCamera;
|
this._transformNode.parent = scene.activeCamera;
|
||||||
this.transform.position.z = .7;
|
this._transformNode.position.z = .7;
|
||||||
this.transform.position.y = -.1;
|
this._transformNode.position.y = -.1;
|
||||||
this.transform.setParent(platform);
|
this._transformNode.setParent(platform);
|
||||||
this.transform.rotation.z = 0;
|
this._transformNode.rotation.z = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get mesh(): AbstractMesh {
|
public get mesh(): AbstractMesh {
|
||||||
return this._mesh;
|
return this._mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public dispose() {
|
||||||
|
this._transformNode.dispose(false, true);
|
||||||
|
}
|
||||||
|
|
||||||
private makeNewButton(name: string, id: string, scene: Scene, x: number): HtmlButton {
|
private makeNewButton(name: string, id: string, scene: Scene, x: number): HtmlButton {
|
||||||
const button = new HtmlButton(name, id, scene, null, {html: null, image: {width: 268, height: 268}});
|
const button = new HtmlButton(name, id, scene, null, {html: null, image: {width: 268, height: 268}});
|
||||||
const transform = button.transform;
|
const transform = button.transform;
|
||||||
transform.parent = this.transform;
|
transform.parent = this._transformNode;
|
||||||
transform.rotation.y = Math.PI;
|
transform.rotation.y = Math.PI;
|
||||||
transform.position.x = x;
|
transform.position.x = x;
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
private dispose() {
|
|
||||||
this.transform.dispose(false, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUp(event: ActionEvent): boolean {
|
function isUp(event: ActionEvent): boolean {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user