Fixed left controller typo.

This commit is contained in:
Michael Mainguy 2024-05-02 05:49:14 -05:00
parent d864c2e562
commit 08569de94d
5 changed files with 32 additions and 18 deletions

View File

@ -251,7 +251,7 @@ export class Base {
this.clickMenu = null; this.clickMenu = null;
} }
} else { } else {
this.clickMenu = this.diagramManager.diagramMenuManager.createClickMenu(mesh, this.xrInputSource.grip); this.clickMenu = this.diagramManager.diagramMenuManager.createClickMenu(mesh, this.xrInputSource);
} }
} else { } else {

View File

@ -1,4 +1,4 @@
import {AbstractMesh, ActionManager, InstancedMesh, Mesh, Observable, Scene, TransformNode} from "@babylonjs/core"; import {AbstractMesh, ActionManager, InstancedMesh, Mesh, Observable, Scene, WebXRInputSource} from "@babylonjs/core";
import {DiagramEntity, DiagramEvent, DiagramEventType} from "./types/diagramEntity"; import {DiagramEntity, DiagramEvent, DiagramEventType} from "./types/diagramEntity";
import log from "loglevel"; import log from "loglevel";
import {Controllers} from "../controllers/controllers"; import {Controllers} from "../controllers/controllers";
@ -74,7 +74,7 @@ export class DiagramManager {
return this._diagramMenuManager; return this._diagramMenuManager;
} }
public createClickMenu(mesh: AbstractMesh, grip: TransformNode): ClickMenu { public createClickMenu(mesh: AbstractMesh, grip: WebXRInputSource): ClickMenu {
return this._diagramMenuManager.createClickMenu(mesh, grip); return this._diagramMenuManager.createClickMenu(mesh, grip);
} }
private notifyAll(event: DiagramEvent) { private notifyAll(event: DiagramEvent) {

View File

@ -1,5 +1,5 @@
import {DiagramEvent, DiagramEventType} from "./types/diagramEntity"; import {DiagramEvent, DiagramEventType} from "./types/diagramEntity";
import {AbstractMesh, ActionEvent, Observable, Scene, TransformNode, Vector3} from "@babylonjs/core"; import {AbstractMesh, ActionEvent, Observable, Scene, Vector3, WebXRInputSource} from "@babylonjs/core";
import {InputTextView} from "../information/inputTextView"; import {InputTextView} from "../information/inputTextView";
import {toDiagramEntity} from "./functions/toDiagramEntity"; import {toDiagramEntity} from "./functions/toDiagramEntity";
import {DefaultScene} from "../defaultScene"; import {DefaultScene} from "../defaultScene";
@ -79,8 +79,8 @@ export class DiagramMenuManager {
this._inputTextView.show(mesh); this._inputTextView.show(mesh);
} }
public createClickMenu(mesh: AbstractMesh, grip: TransformNode): ClickMenu { public createClickMenu(mesh: AbstractMesh, input: WebXRInputSource): ClickMenu {
const clickMenu = new ClickMenu(mesh, grip, this._notifier); const clickMenu = new ClickMenu(mesh, input, this._notifier);
clickMenu.onClickMenuObservable.add((evt: ActionEvent) => { clickMenu.onClickMenuObservable.add((evt: ActionEvent) => {
console.log(evt); console.log(evt);
switch (evt.source.id) { switch (evt.source.id) {

View File

@ -1,4 +1,4 @@
import {AbstractMesh, ActionEvent, Observable, Scene, TransformNode, Vector3} from "@babylonjs/core"; import {AbstractMesh, ActionEvent, Observable, Scene, TransformNode, Vector3, WebXRInputSource} from "@babylonjs/core";
import {DiagramEvent, DiagramEventType} from "../diagram/types/diagramEntity"; import {DiagramEvent, DiagramEventType} from "../diagram/types/diagramEntity";
import {toDiagramEntity} from "../diagram/functions/toDiagramEntity"; import {toDiagramEntity} from "../diagram/functions/toDiagramEntity";
import {DiagramConnection} from "../diagram/diagramConnection"; import {DiagramConnection} from "../diagram/diagramConnection";
@ -15,7 +15,8 @@ export class ClickMenu {
public onClickMenuObservable: Observable<ActionEvent> = new Observable<ActionEvent>(); public onClickMenuObservable: Observable<ActionEvent> = new Observable<ActionEvent>();
private _diagramEventObservable: Observable<DiagramEvent>; private _diagramEventObservable: Observable<DiagramEvent>;
constructor(mesh: AbstractMesh, grip: TransformNode, diagramEventObservable: Observable<DiagramEvent>) { constructor(mesh: AbstractMesh, input: WebXRInputSource, diagramEventObservable: Observable<DiagramEvent>) {
const grip = input.grip;
this._mesh = mesh; this._mesh = mesh;
this._diagramEventObservable = diagramEventObservable; this._diagramEventObservable = diagramEventObservable;
//this.diagramManager = diagramManager; //this.diagramManager = diagramManager;
@ -63,9 +64,22 @@ export class ClickMenu {
}, -1, false, this, false); }, -1, false, this, false);
this.transform.position = mesh.absolutePosition.clone(); const meshPos = mesh.absolutePosition.clone();
this.transform.position.y = mesh.getBoundingInfo().boundingBox.maximumWorld.y + .1; const camPos = scene.activeCamera.globalPosition.clone();
this.transform.billboardMode = TransformNode.BILLBOARDMODE_Y; const direction = meshPos.subtract(camPos).normalize();
//const {min, max} = mesh.getHierarchyBoundingVectors(true);
this.transform.position = camPos.add(direction.scale(.8));
this.transform.lookAt(meshPos);
this.transform.position.y = this.transform.position.y - .2;
//this.transform.billboardMode = TransformNode.BILLBOARDMODE_Y;
const platform = scene.getMeshByName("platform");
this.transform.setParent(platform);
} }
private makeNewButton(name: string, id: string, scene: Scene, x: number): HtmlButton { private makeNewButton(name: string, id: string, scene: Scene, x: number): HtmlButton {

View File

@ -76,11 +76,11 @@ export class VrApp {
*/ */
/* /*
const chair = new GaussianSplattingMesh('chair', null, scene); const chair = new GaussianSplattingMesh('chair', null, scene);
const m = await chair.loadFileAsync('https://models.deepdiagram.com/drill1.ply'); const m = await chair.loadFileAsync('https://models.deepdiagram.com/house.ply');
chair.position.y = 1.6; chair.position.y = 1.6;
chair.rotation.y = Math.PI; chair.rotation.y = Math.PI;
chair.scaling = chair.scaling.scale(3); chair.scaling = chair.scaling.scale(1);
chair.showBoundingBox = true; chair.showBoundingBox = true;
*/ */