better auto-position window
/ mirror_to_github (push) Successful in 18s Details
/ test (push) Successful in 3s Details

This commit is contained in:
Leon van Kammen 2024-10-28 12:25:14 +00:00
parent 5aeb860aef
commit 8375e5f1b5
1 changed files with 5 additions and 6 deletions

View File

@ -70,7 +70,7 @@ AFRAME.registerComponent('window', {
if( els.length < 2 ) return if( els.length < 2 ) return
let current = els[ els.length-1 ] let current = els[ els.length-1 ]
let last = els[ els.length-2 ] let last = els[ els.length-2 ]
AFRAME.utils.positionObjectNextToNeighbor( current.object3D , last.object3D, els.length ) AFRAME.utils.positionObjectNextToNeighbor( current.object3D , last.object3D, 0.02 )
} }
}, },
@ -79,11 +79,10 @@ AFRAME.registerComponent('window', {
} }
}) })
AFRAME.utils.positionObjectNextToNeighbor = function positionObjectNextToNeighbor(object, lastNeighbor = null, neighbours, margin = 0.45, degree = 20) { AFRAME.utils.positionObjectNextToNeighbor = function positionObjectNextToNeighbor(object, lastNeighbor = null, margin ){
// *FIXME* this could be more sophisticated :) // *FIXME* this could be more sophisticated :)
object.position.x = lastNeighbor.position.x + ((neighbours-1) * margin) object.position.x = lastNeighbor.position.x + margin
object.position.y = lastNeighbor.position.y object.position.y = lastNeighbor.position.y - margin
object.position.z = lastNeighbor.position.z object.position.z = lastNeighbor.position.z + margin
//object.rotation.y += THREE.MathUtils.degToRad( (neighbours-1) * degree);
} }