如果我希望旋转后所有圆柱体的高度都是固定值,我将如何计算原始高度

If I want all cylinders' height to be a fixed value after rotation, how would I calculate the original height?

本文关键字:高度 何计算 原始 计算 旋转 我希望 圆柱体 如果      更新时间:2023-09-26

我是WebGL和Three.js的新手。如果我希望旋转后所有气缸的高度都是固定值,我将如何计算原始高度?

这就是我想要的:我有几个圆柱体,

我把每个圆柱体的原点作为底部的中心,圆柱体通过球体连接,圆柱体将根据参数旋转 x、y 和 z。圆柱体高度为 30,但旋转后 y 轴高度小于 30。如果我想旋转后 y 轴的高度仍然是 30,我该怎么办?我需要在旋转前重新计算气缸高度,我可以得到一些关于如何做到这一点的建议吗?非常感谢您的任何帮助。 有人可以帮忙吗? :)

var cyliderHeight = 30;
var cylinderGeometry = new THREE.CylinderGeometry( topRadius, botRadius, cyliderHeight, 16 );
cylinderGeometry.applyMatrix( new THREE.Matrix4().makeTranslation( 0, cyliderHeight/2, 0 ) );
var cylinder = new THREE.Mesh( cylinderGeometry, material );
cylinder.position.set( positionX, positionY, positionZ);    
group.add( cylinder );                              
cylinder.rotation.x = NaturalIncrease  / 100000;
cylinder.rotation.y = year * 4 / 10000;
cylinder.rotation.z = NetOverseasMigration  / 100000;
var sphere = new THREE.Mesh( new THREE.SphereGeometry(topRadius, 20, 20), material );
var point = new THREE.Vector3( 0, cyliderHeight, 0 );
point.applyEuler( cylinder.rotation );
sphere.position.set( point.x + positionX, point.y + positionY, point.z + positionZ );

围绕 y 轴的旋转无关紧要。您可以分两个不同的步骤考虑旋转的另外两个组成部分,并应用伸长率两次。