xrfragment-haxe/src/3rd/js/three/xrf/pos.js

20 lines
582 B
JavaScript
Raw Normal View History

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