2023-05-12 22:06:21 +02:00
|
|
|
xrf.frag.pos = function(v, opts){
|
2023-05-09 17:42:29 +02:00
|
|
|
let { frag, mesh, model, camera, scene, renderer, THREE} = opts
|
2023-11-24 17:32:53 +01:00
|
|
|
|
2024-01-24 18:11:37 +00:00
|
|
|
let pos = v
|
2023-11-24 17:32:53 +01:00
|
|
|
|
|
|
|
|
// spec: indirect coordinate using objectname: https://xrfragment.org/#navigating%203D
|
2024-01-24 18:11:37 +00:00
|
|
|
if( pos.x == undefined ){
|
2023-11-24 17:32:53 +01:00
|
|
|
let obj = scene.getObjectByName(v.string)
|
|
|
|
|
if( !obj ) return
|
2024-01-24 18:11:37 +00:00
|
|
|
pos = obj.position.clone()
|
2023-11-24 17:32:53 +01:00
|
|
|
obj.getWorldPosition(pos)
|
|
|
|
|
camera.position.copy(pos)
|
|
|
|
|
}else{
|
|
|
|
|
// spec: direct coordinate: https://xrfragment.org/#navigating%203D
|
2024-01-24 18:11:37 +00:00
|
|
|
camera.position.x = pos.x
|
|
|
|
|
camera.position.y = pos.y
|
|
|
|
|
camera.position.z = pos.z
|
2023-11-24 17:32:53 +01:00
|
|
|
}
|
2024-01-24 18:11:37 +00:00
|
|
|
|
|
|
|
|
xrf.frag.pos.last = pos // remember
|
|
|
|
|
|
2023-12-12 18:09:30 +01:00
|
|
|
camera.updateMatrixWorld()
|
2023-05-04 21:28:12 +02:00
|
|
|
}
|