This commit is contained in:
Leon van Kammen 2023-10-19 16:48:12 +02:00
parent ee3d430261
commit 39463736e1
9 changed files with 3516 additions and 2906 deletions

File diff suppressed because one or more lines are too long

BIN
example/assets/podcast.mp3 Normal file

Binary file not shown.

BIN
example/assets/test.mp3 Normal file

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -67,6 +67,21 @@ window.AFRAME.registerComponent('xrf', {
}
xrf.addEventListener('interactionReady', AFRAME.XRF.clickableMeshToEntity )
// xrf.addEventListener('interactionReady', () => {
// let raycasters = [ ...document.querySelectorAll('[raycaster]') ]
// raycasters.map( (rc) => {
// rc = rc.components['raycaster']
// rc.refreshObjects = () => {
// rc.objects = xrf.interactive.objects.map( (o) => ({ ...o, el:{} }) ) // AFRAME raycaster requires 'el' property
// console.log("refreshing")
// rc.dirty = false
// }
// rc.dirty = true
// rc.refreshObjects()
// })
// })
// cleanup xrf-get objects when resetting scene
xrf.reset = ((reset) => () => {
reset()

View File

@ -21,10 +21,11 @@ window.AFRAME.registerComponent('xrf-get', {
return;
}
// convert to worldcoordinates
mesh.getWorldPosition(mesh.position)
mesh.getWorldScale(mesh.scale)
mesh.getWorldQuaternion(mesh.quaternion)
// mesh.getWorldPosition(mesh.position)
// mesh.getWorldScale(mesh.scale)
// mesh.getWorldQuaternion(mesh.quaternion)
mesh.isXRF = true // mark for deletion by xrf
this.el.object3D.add = (a) => a // dummy
this.el.setObject3D('mesh',mesh)
// normalize position
//this.el.object3D.position.copy( mesh.position )

View File

@ -131,9 +131,9 @@ xrf.InteractiveGroup = function(THREE,renderer,camera){
}
add(obj){
Group.prototype.add.call( this, obj )
this.objects = ([]).concat( this.children )
add(obj, unparent){
if( unparent ) Group.prototype.add.call( this, obj )
this.objects.push(obj)
}
}

View File

@ -131,12 +131,12 @@ xrf.frag.href = function(v, opts){
// lazy add mesh (because we're inside a recursive traverse)
setTimeout( (mesh) => {
mesh.getWorldPosition(world.pos)
mesh.getWorldScale(world.scale)
mesh.getWorldQuaternion(world.quat);
mesh.position.copy(world.pos)
mesh.scale.copy(world.scale)
mesh.setRotationFromQuaternion(world.quat);
//mesh.getWorldPosition(world.pos)
//mesh.getWorldScale(world.scale)
//mesh.getWorldQuaternion(world.quat);
//mesh.position.copy(world.pos)
//mesh.scale.copy(world.scale)
//mesh.setRotationFromQuaternion(world.quat);
xrf.interactive.add(mesh)
xrf.emit('interactionReady', {mesh,xrf:v,clickHandler: mesh.userData.XRF.href.exec })
}, 0, mesh )