2023-05-22 18:58:05 +02:00
|
|
|
window.AFRAME.registerComponent('xrf-get', {
|
|
|
|
|
schema: {
|
|
|
|
|
name: {type: 'string'},
|
|
|
|
|
clone: {type: 'boolean', default:false}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
init: function () {
|
|
|
|
|
|
|
|
|
|
var el = this.el;
|
|
|
|
|
var meshname = this.data.name || this.data;
|
|
|
|
|
|
|
|
|
|
this.el.addEventListener('update', (evt) => {
|
|
|
|
|
|
2023-10-11 13:46:38 +02:00
|
|
|
setTimeout( () => {
|
|
|
|
|
|
|
|
|
|
if( !this.mesh && this.el.className == "ray" ){
|
|
|
|
|
let scene = AFRAME.XRF.scene
|
|
|
|
|
let mesh = this.mesh = scene.getObjectByName(meshname);
|
|
|
|
|
if (!mesh){
|
|
|
|
|
console.error("mesh with name '"+meshname+"' not found in model")
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// convert to worldcoordinates
|
2023-10-19 16:48:12 +02:00
|
|
|
// mesh.getWorldPosition(mesh.position)
|
|
|
|
|
// mesh.getWorldScale(mesh.scale)
|
|
|
|
|
// mesh.getWorldQuaternion(mesh.quaternion)
|
2023-10-11 13:46:38 +02:00
|
|
|
mesh.isXRF = true // mark for deletion by xrf
|
2023-10-19 16:48:12 +02:00
|
|
|
this.el.object3D.add = (a) => a // dummy
|
2023-10-11 13:46:38 +02:00
|
|
|
this.el.setObject3D('mesh',mesh)
|
|
|
|
|
// normalize position
|
|
|
|
|
//this.el.object3D.position.copy( mesh.position )
|
|
|
|
|
//mesh.position.fromArray([0,0,0])
|
|
|
|
|
if( !this.el.id ) this.el.setAttribute("id",`xrf-${mesh.name}`)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},500)
|
2023-05-22 18:58:05 +02:00
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
2023-10-11 13:46:38 +02:00
|
|
|
this.el.emit("update")
|
2023-05-22 18:58:05 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|