wip: rotate

This commit is contained in:
Leon van Kammen 2023-11-28 13:27:53 +01:00
parent 99ea791adb
commit 76d6478504
4 changed files with 19 additions and 16 deletions

View File

@ -31,8 +31,8 @@
<canvas id="qrcode" style="display:none" width="300" height="300"></canvas>
<a-scene renderer="colorManagement: true; highRefreshRate:true" light="defaultLightsEnabled: false">
<a-entity id="player" wasd-controls look-controls>
<a-entity camera="fov:90" position="0 1.6 0" id="camera"></a-entity>
<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 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>

Binary file not shown.

View File

@ -64,15 +64,14 @@ window.AFRAME.registerComponent('xrf', {
// in order to set the rotation programmatically
// we need to disable look-controls
xrf.rot = (xrf,v,opts) => {
let {frag,renderer} = opts;
if( frag.q ) return // camera was not targeted for rotation
let look = document.querySelector('[look-controls]')
if( look ) look.removeAttribute("look-controls")
// *TODO* make look-controls compatible, because simply
// adding the look-controls will revert to the old rotation (cached somehow?)
//setTimeout( () => look.setAttribute("look-controls",""), 100 )
}
//xrf.rot = (xrf,v,opts) => {
// let {frag,renderer} = opts;
// //let look = document.querySelector('[look-controls]')
// //if( look ) look.removeAttribute("look-controls")
// // *TODO* make look-controls compatible, because simply
// // adding the look-controls will revert to the old rotation (cached somehow?)
// //setTimeout( () => look.setAttribute("look-controls",""), 100 )
//}
// convert href's to a-entity's so AFRAME
// raycaster can find & execute it

View File

@ -38,7 +38,7 @@ xrf.portalNonEuclidian = function(opts){
let stencilObject = scene
if( opts.srcFrag.target ){
stencilObject = scene.getObjectByName( opts.srcFrag.target.key )
// scan if object is child of portal (then project lens)
// spec: if src-object is child of portal (then portal is lens, and should include all children )
mesh.traverse( (n) => n.name == opts.srcFrag.target.key && (stencilObject = n) && (mesh.portal.isLens = true) )
}
if( !stencilObject ) return console.warn(`no objects were found (src:${mesh.userData.src}) for (portal)object name '${mesh.name}'`)
@ -69,6 +69,10 @@ xrf.portalNonEuclidian = function(opts){
setTimeout( (mesh) => {
if( mesh.material ) mesh.material = mesh.material.clone() // clone, so we can individually highlight meshes
}, 0, mesh )
// spec: increase height of portal(object) floor so it won't get rendererd under the current floor
mesh.portal.posWorld.y +=0.1
return this
}
@ -90,6 +94,10 @@ xrf.portalNonEuclidian = function(opts){
let cameraDirection = mesh.portal.cameraDirection
let cameraPosition = mesh.portal.cameraPosition
let raycaster = mesh.portal.raycaster
let cam = xrf.camera.getCam ? xrf.camera.getCam() : camera
cam.getWorldPosition(cameraPosition)
if( cameraPosition.distanceTo(newPos) > 20.0 ) return // dont render far portals
cam.getWorldDirection(cameraDirection)
// init
if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = true
@ -105,9 +113,6 @@ xrf.portalNonEuclidian = function(opts){
// trigger href upon camera collide
if( mesh.userData.XRF.href ){
raycaster.far = 0.35
let cam = xrf.camera.getCam ? xrf.camera.getCam() : camera
cam.getWorldPosition(cameraPosition)
cam.getWorldDirection(cameraDirection)
raycaster.set(cameraPosition, cameraDirection )
intersects = raycaster.intersectObjects([mesh], false)
if (intersects.length > 0 && !mesh.portal.teleporting ){
@ -126,7 +131,6 @@ xrf.portalNonEuclidian = function(opts){
.portalNonEuclidian
.setMaterial(mesh)
.getWorldPosition(mesh.portal.posWorld)
mesh.portal.posWorld.y +=0.2
this
.setupListeners()