From 8375e5f1b597bf0b7c2c1fceff0bc02f5574f611 Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Mon, 28 Oct 2024 12:25:14 +0000 Subject: [PATCH] better auto-position window --- com/window.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/com/window.js b/com/window.js index b15e7f4..07ddeda 100644 --- a/com/window.js +++ b/com/window.js @@ -70,7 +70,7 @@ AFRAME.registerComponent('window', { if( els.length < 2 ) return let current = els[ els.length-1 ] 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 :) - object.position.x = lastNeighbor.position.x + ((neighbours-1) * margin) - object.position.y = lastNeighbor.position.y - object.position.z = lastNeighbor.position.z - //object.rotation.y += THREE.MathUtils.degToRad( (neighbours-1) * degree); + object.position.x = lastNeighbor.position.x + margin + object.position.y = lastNeighbor.position.y - margin + object.position.z = lastNeighbor.position.z + margin }