diff --git a/src/controllers/base.ts b/src/controllers/base.ts index 71142c4..1d20094 100644 --- a/src/controllers/base.ts +++ b/src/controllers/base.ts @@ -1,6 +1,5 @@ import { AbstractMesh, - Mesh, PhysicsMotionType, Scene, TransformNode, @@ -144,12 +143,8 @@ export class Base { mesh && mesh.setParent(this.xrInputSource.motionController.rootMesh); this.grabbedMesh = mesh; } else { - if (mesh?.parent?.parent?.metadata?.grabbable) { - if (mesh?.parent?.parent?.parent) { - mesh = (mesh?.parent?.parent?.parent as Mesh); - this.grabbedMesh = mesh; - player = true; - } + if (mesh?.metadata?.grabbable) { + this.grabbedMesh = mesh; } else { return; } diff --git a/src/react/functions/uploadImage.ts b/src/react/functions/uploadImage.ts index bc87f01..3d369b3 100644 --- a/src/react/functions/uploadImage.ts +++ b/src/react/functions/uploadImage.ts @@ -1,6 +1,10 @@ const uploadImage = async (evt) => { const file = (evt.target as HTMLInputElement).files[0]; + if (!file) { + console.log('no file selected'); + return; + } const formData = new FormData(); formData.append('file', file); //formData.append('requireSignedURLs', 'true'); diff --git a/src/react/webApp.tsx b/src/react/webApp.tsx index 838dba5..df6b873 100644 --- a/src/react/webApp.tsx +++ b/src/react/webApp.tsx @@ -115,7 +115,10 @@ function Menu() { function handleDiagramListClick(evt: React.MouseEvent) { evt.preventDefault(); - switch (evt.target.id) { + if (!evt.currentTarget.id) { + return; + } + switch (evt.currentTarget.id) { case 'imageUploadLink': const input = document.createElement('input'); input.type = 'file'; @@ -133,9 +136,7 @@ function Menu() { return (
- -
) diff --git a/src/vrApp.ts b/src/vrApp.ts index bc956cc..010b17c 100644 --- a/src/vrApp.ts +++ b/src/vrApp.ts @@ -57,6 +57,35 @@ export class VrApp { */ addSceneInspector(); + + /* + SceneLoader.ImportMesh(null,'https://models.deepdiagram.com/', 'Chair_textured_mesh_lowpoly_glb.glb', scene, (meshes) => { + const transform = new Mesh('chair', scene); + for(const mesh of meshes){ + mesh.parent= transform; + } + let {min, max} = transform.getHierarchyBoundingVectors(true); + const parentMesh = MeshBuilder.CreateBox('boundingBox', {width: max.x - min.x, height: max.y - min.y, depth: max.z - min.z}, scene); + for(const mesh of meshes){ + mesh.parent= parentMesh; + + } + transform.dispose(); + //parentMesh.setBoundingInfo(new BoundingInfo(min, max)); + parentMesh.showBoundingBox = true; + parentMesh.scaling = new Vector3(.2,.2,.2); + //mesh.metadata = {grabbable: true}; + parentMesh.position.y = .5; + parentMesh.position.z = 0; + parentMesh.metadata = {grabbable: true}; + const material = new StandardMaterial('chairMaterial', scene); + material.alpha = 0; + parentMesh.material = material; + parentMesh.showBoundingBox = true; + }); + + */ + const el = document.querySelector('#download'); if (el) { el.addEventListener('click', () => {