main: minor bugfix

This commit is contained in:
Leon van Kammen 2024-10-08 17:11:14 +02:00
parent a54ff56a8d
commit 4d68b50ede
3 changed files with 5 additions and 7 deletions

1
index.glb Symbolic link
View File

@ -0,0 +1 @@
example/assets/index.glb

1
other.glb Symbolic link
View File

@ -0,0 +1 @@
example/assets/other.glb

View File

@ -2,19 +2,15 @@ xrf.frag.pos = function(v, opts){
let { frag, mesh, model, camera, scene, renderer, THREE} = opts let { frag, mesh, model, camera, scene, renderer, THREE} = opts
let pos = v let pos = v
console.dir(pos)
// spec: indirect coordinate using objectname: https://xrfragment.org/#navigating%203D // spec: indirect coordinate using objectname: https://xrfragment.org/#navigating%203D
if( pos.x == undefined ){ if( pos.x == undefined ){
let obj = scene.getObjectByName(v.string) let obj = scene.getObjectByName(v.string)
if( !obj ) return if( !obj ) return console.warn("#pos="+v.string+" not found")
pos = obj.position.clone()
obj.getWorldPosition(pos)
camera.position.copy(pos)
obj.attach(camera)
camera.position.set(0,0,0) camera.position.set(0,0,0)
obj.attach(camera)
let c = camera.getCam().rotation let c = camera.getCam().rotation
c.set( c.x, obj.rotation.y, c.z ) c.set( c.x, obj.rotation.y, c.z )
obj.updateMatrixWorld(); // Update parents world matrix obj.updateMatrixWorld(); // Update parents world matrix
}else{ }else{