From 7da6efaee85032122fd67afc2602aad0ffc2d5a8 Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Wed, 12 Jun 2024 14:59:49 +0000 Subject: [PATCH] feat/model-viewer: work in progress [might break] --- example/model-viewer/index.html | 91 +++++++++++++++++++++++ example/three/sandbox/index.html | 11 ++- src/3rd/js/three/xrf/src/non-euclidian.js | 2 +- 3 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 example/model-viewer/index.html diff --git a/example/model-viewer/index.html b/example/model-viewer/index.html new file mode 100644 index 0000000..a5674e9 --- /dev/null +++ b/example/model-viewer/index.html @@ -0,0 +1,91 @@ + + + + <model-viewer> template + + + + + + + + + + < + > + + + + + + + + diff --git a/example/three/sandbox/index.html b/example/three/sandbox/index.html index 09de641..75724ce 100644 --- a/example/three/sandbox/index.html +++ b/example/three/sandbox/index.html @@ -42,7 +42,6 @@ import { XRControllerModelFactory } from 'three/addons/webxr/XRControllerModelFactory.js'; import { OculusHandModel } from 'three/addons/webxr/OculusHandModel.js'; import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; - import { GUI } from 'three/addons/libs/lil-gui.module.min.js'; import Stats from 'three/addons/libs/stats.module.js'; window.$ = (s) => document.querySelector(s) @@ -165,16 +164,19 @@ const handModel1 = new OculusHandModel( hand1 ); hand1.add( handModel1 ); cameraRig.add( hand1 ); + console.dir(hand1) const controllerGrip2 = renderer.xr.getControllerGrip( 1 ); controllerGrip2.add( controllerModelFactory.createControllerModel( controllerGrip2 ) ); cameraRig.add( controllerGrip2 ); + console.dir(hand1) // hand2 const hand2 = renderer.xr.getHand( 1 ); const handModel2 = new OculusHandModel( hand2 ); hand2.add( handModel2 ); cameraRig.add( hand2 ); + console.dir(hand2) // Add stats.js stats = new Stats(); @@ -190,9 +192,6 @@ statsMesh.scale.setScalar( 2.5 ); vrbutton.addEventListener('click', () => { - // show gui inside VR scene - gui.domElement.style.visibility = 'hidden'; - XRF.interactive.add( mesh ); XRF.interactive.add( statsMesh ); }) @@ -219,8 +218,8 @@ let fileLoaders = loadFile({ - ".gltf": (file) => file.arrayBuffer().then( (data) => XRF.navigator.to(file.name,null,XRF.loaders.gltf,data) ), - ".glb": (file) => file.arrayBuffer().then( (data) => XRF.navigator.to(file.name,null, XRF.loaders.gltf,data) ) + ".gltf": (file) => file.arrayBuffer().then( (data) => xrf.navigator.to(file.name,null, (new xrf.loaders.gltf()), data) ), + ".glb": (file) => file.arrayBuffer().then( (data) => xrf.navigator.to(file.name,null, (new xrf.loaders.gltf()), data) ) }) $("input[type=submit]").addEventListener("click", fileLoaders ) diff --git a/src/3rd/js/three/xrf/src/non-euclidian.js b/src/3rd/js/three/xrf/src/non-euclidian.js index a3e5b7e..3afb9ab 100644 --- a/src/3rd/js/three/xrf/src/non-euclidian.js +++ b/src/3rd/js/three/xrf/src/non-euclidian.js @@ -120,7 +120,7 @@ xrf.portalNonEuclidian = function(opts){ if( mesh.userData.XRF.href ){ raycaster.far = 0.35 raycaster.set(cameraPosition, cameraDirection ) - intersects = raycaster.intersectObjects([mesh], false) + let intersects = raycaster.intersectObjects([mesh], false) if (intersects.length > 0 && !mesh.portal.teleporting ){ mesh.portal.teleporting = true mesh.userData.XRF.href.exec({nocommit:true})