Hello folks,
I didn’ t want to create a thread for this issue but I can’t solve it. I don’t understand why I am not able to rotate the cloned meshes. In playground it works just fine but in my code it doesn’t.
My model consists of several identical wood beams which are build up to a box. I created a function to clone these wood beams dynamically if the size of the box changes. To achieve a more realistic appearance I try to rotate the wood beams randomly around the own axis. Unfortunately rotation isn’t working at all. Nothing happens.
function adjustWidth(type, desiredSize) {
if (desiredSize >= min && desiredSize <= max) {
const preAdjustBeams_2Length = getObjectSize(Beams_2).x
const currentParentSize = getObjectSize(parent).x
const Beams_1Scaling = Beams_1.absoluteScaling.x
if (desiredSize !== Math.round(currentParentSize)) {
const beam = type === "length" ? Scene3d.c.lengthBeamBase : Scene3d.c.widthBeamBase
const currentBeamLength = getObjectSize(beam).x
const currentBeamCount = Math.floor(currentParentSize / currentBeamLength)
var nextBeamCount = currentBeamCount + 1
const desiredBeamLength = 45
const desiredBeamCount = Math.ceil(desiredSize / desiredBeamLength)
for (nextBeamCount; nextBeamCount < desiredBeamCount + 1; nextBeamCount++) {
Beams_4.map(Beam => {
const beamClone = Beam.clone()
beamClone.position.x -= currentBeamLength * (nextBeamCount - 1) / Beams_1Scaling
beamClone.rotation.x = Math.PI/2 * Math.round(Math.random() * 4)
return true
})
}
const lengthBeams_1Length = getObjectSize(Beams_1).x
Beams_1.scaling.x = (desiredSize - beamWidth) / lengthBeams_1Length * Beams_1Scaling
Beams_2.scaling.x = (desiredSize - beamWidth) / lengthBeams_1Length * Beams_1Scaling
Scene3d.c.lengthBeams_3.map(Beam => {
Beam.position.x -= getObjectSize(Beams_2).x - preAdjustBeams_2Length
return true
})
const bottomLength = getObjectSize(bottom).x
bottom.scaling.x = (desiredSize / bottomLength) * bottom.absoluteScaling.x
}
}
}
if you have any idea how I can solve this, I would appreciate it very much.
Thank you!