improved collisions for floor

This commit is contained in:
Leon van Kammen 2023-11-29 19:39:31 +01:00
parent 1291763409
commit e38eea1859
3 changed files with 15 additions and 10 deletions

View File

@ -33,17 +33,16 @@
<a-scene renderer="colorManagement: true; highRefreshRate:true" light="defaultLightsEnabled: false">
<a-entity id="player">
<a-entity camera="fov:90" position="0 1.6 0" wasd-controls look-controls id="camera"></a-entity>
<a-entity id="left-hand" laser-controls="hand: left" raycaster="objects:.ray" blink-controls="cameraRig:#player; teleportOrigin: #camera; collisionEntities: #floor">
<a-entity id="left-hand" laser-controls="hand: left" raycaster="objects:.ray" blink-controls="cameraRig:#player; teleportOrigin: #camera; collisionEntities: .floor">
<a-entity rotation="-35 0 0" position="0 0.1 0" id="navigator">
<a-entity id="back" xrf-button="label: <; width:0.05; action: history.back()" position="-0.025 0 0" class="ray"></a-entity>
<a-entity id="next" xrf-button="label: >; width:0.05; action: history.forward()" position=" 0.025 0 0" class="ray"></a-entity>
</a-entity>
</a-entity>
<a-entity id="right-hand" laser-controls="hand: right" raycaster="objects:.ray" blink-controls="cameraRig:#player; teleportOrigin: #camera; collisionEntities: #floor"></a-entity>
<a-entity id="right-hand" laser-controls="hand: right" raycaster="objects:.ray" blink-controls="cameraRig:#player; teleportOrigin: #camera; collisionEntities: .floor"></a-entity>
</a-entity>
<a-entity id="home" xrf="index.glb"></a-entity>
<a-plane id="floor" position="0 0 0" rotation="-90 0 0" width="1000" height="1000" material="visible:false"></a-plane>
</a-scene>
<script>

View File

@ -33,9 +33,15 @@ window.AFRAME.registerComponent('xrf', {
// *TODO* this does not really belong here perhaps
let blinkControls = document.querySelector('[blink-controls]')
if( blinkControls ){
blinkControls = blinkControls.components['blink-controls']
blinkControls.defaultCollisionMeshes = xrf.getCollisionMeshes()
blinkControls.update()
let els = xrf.getCollisionMeshes()
els.map( (mesh) => {
mesh.material.visible = false
let el = document.createElement("a-entity")
el.setAttribute("xrf-get", `name: ${mesh.name};reparent:true` )
el.setAttribute("class","floor ray")
$('a-scene').appendChild(el)
})
blinkControls = blinkControls.components['blink-controls'].queryCollisionEntities()
}
})

View File

@ -14,7 +14,7 @@ window.AFRAME.registerComponent('xrf-get', {
setTimeout( () => {
if( !this.mesh && this.el.className == "ray" ){
if( !this.mesh && this.el.className.match(/ray/) ){
let scene = AFRAME.XRF.scene
let mesh = this.mesh = scene.getObjectByName(meshname);
if (!mesh){
@ -41,12 +41,12 @@ window.AFRAME.registerComponent('xrf-get', {
}
this.el.setObject3D('mesh',mesh)
if( !this.el.id ) this.el.setAttribute("id",`xrf-${mesh.name}`)
}
},500)
}else console.warn("xrf-get ignore: "+JSON.stringify(this.data))
}, evt && evt.timeout ? evt.timeout: 500)
})
this.el.emit("update")
this.el.emit("update",{timeout:0})
}