Cleaned up menus and local environment.

This commit is contained in:
Michael Mainguy 2023-12-11 15:15:17 -06:00
parent 7d5ef80b5b
commit 410a88099e
4 changed files with 15 additions and 16 deletions

View File

@ -167,14 +167,13 @@ export class Base {
} }
private toolboxHandleWasGrabbed(mesh: AbstractMesh): boolean { private toolboxHandleWasGrabbed(mesh: AbstractMesh): boolean {
if (isDiagramEntity(mesh) if (isDiagramEntity(mesh)) {
&& mesh?.metadata?.handle == true) {
this.grabbedMesh = null; this.grabbedMesh = null;
this.previousParentId = null; this.previousParentId = null;
mesh.setParent(null); mesh.setParent(null);
return true;
} else {
return false; return false;
} else {
return (mesh?.metadata?.handle == true);
} }
} }
private drop() { private drop() {

View File

@ -39,10 +39,9 @@ export function diagramEventHandler(event: DiagramEvent,
switch (event.type) { switch (event.type) {
case DiagramEventType.RESET: case DiagramEventType.RESET:
scene.getNodes().forEach((node) => {
scene.getNodes().forEach((m) => { if (node?.metadata?.template && !node?.metadata?.tool) {
if (m?.metadata?.template && !m?.metadata?.tool) { node.dispose();
m.dispose();
} }
}); });
break; break;

View File

@ -16,12 +16,9 @@ export class DiagramListingMenu extends AbstractMenu {
constructor(scene: Scene, xr: WebXRDefaultExperience, controllers: Controllers, diagramManager: DiagramManager) { constructor(scene: Scene, xr: WebXRDefaultExperience, controllers: Controllers, diagramManager: DiagramManager) {
super(scene, xr, controllers); super(scene, xr, controllers);
this.diagramManager = diagramManager; this.diagramManager = diagramManager;
this.buildMenu(); this.buildMenu();
this.controllers.controllerObserver.add((event) => { this.controllers.controllerObserver.add((event) => {
if (event.type == ControllerEventType.B_BUTTON) { if (event.type == ControllerEventType.B_BUTTON) {
this.toggle(); this.toggle();
} }
}); });
@ -47,6 +44,8 @@ export class DiagramListingMenu extends AbstractMenu {
height: .5 height: .5
}, this.scene); }, this.scene);
this.mesh = configPlane; this.mesh = configPlane;
this.createHandle(this.mesh);
this.mesh.position = new Vector3(0, .32, 0);
const configTexture = AdvancedDynamicTexture.CreateForMesh(configPlane, 2048, 1024); const configTexture = AdvancedDynamicTexture.CreateForMesh(configPlane, 2048, 1024);
configTexture.background = "white"; configTexture.background = "white";
@ -55,8 +54,7 @@ export class DiagramListingMenu extends AbstractMenu {
this.panel = new StackPanel('diagramListingStack'); this.panel = new StackPanel('diagramListingStack');
scrollViewer.addControl(this.panel); scrollViewer.addControl(this.panel);
this.createHandle(configPlane); //configPlane.position.y = .5;
configPlane.position.y = .5;
setMenuPosition(this.handle.mesh, this.scene, new Vector3(0, .4, 0)); setMenuPosition(this.handle.mesh, this.scene, new Vector3(0, .4, 0));
this.mesh.isVisible = false; this.mesh.isVisible = false;
(this.mesh.parent as AbstractMesh).isVisible = false; (this.mesh.parent as AbstractMesh).isVisible = false;

View File

@ -48,15 +48,18 @@ export class CustomEnvironment {
sound.play() sound.play()
}, 2000, sounds.background); }, 2000, sounds.background);
const effects: Array<Sound> = sounds.backgroundEffects; const effects: Array<Sound> = sounds.backgroundEffects;
window.setInterval((sounds: Array<Sound>) => { window.setInterval((sounds: Array<Sound>) => {
if (Math.random() < .5) { if (Math.random() < .5) {
return; return;
} }
const MAX_DISTANCE = 40;
const sound = Math.floor(Math.random() * sounds.length); const sound = Math.floor(Math.random() * sounds.length);
const x = Math.floor(Math.random() * 20) - 10; const x = (Math.random() * MAX_DISTANCE) - (MAX_DISTANCE / 2);
const z = Math.floor(Math.random() * 20) - 10; const y = Math.random() * (MAX_DISTANCE / 2);
const z = (Math.random() * MAX_DISTANCE) - (MAX_DISTANCE / 2);
const position = new Vector3(x, 0, z); const position = new Vector3(x, y, z);
if (sounds[sound].isPlaying) { if (sounds[sound].isPlaying) {
} else { } else {