简体   繁体   English

3D模型相同尺度的3D模型

[英]3D Model Same Scale at Three JS

I'm adding more than one .OBJ file (3D Model) to my Three.js scene via Input File, and I want to make them the same size. 我通过输入文件向我的Three.js场景添加了多个.OBJ文件(3D模型),我想让它们大小相同。

The problem is that this 3D models come each one in different sizes, some of them being huge and the other ones being very small. 问题是这个3D模型每个都有不同的尺寸,其中一些是巨大的,另一些是非常小的。

Does anybody know a way of making all the 3D Models the same size? 有人知道让所有3D模型大小相同的方法吗?

Thank You!!! 谢谢!!!

You have to modify the Object3D scale property. 您必须修改Object3D scale属性。 You can scale independently X, Y and Z, so you can set them up to half of its size setting this scale like this: 您可以独立缩放X,Y和Z,因此您可以将它们设置为其大小的一半,设置此比例如下:

yorDownloadedObject.scale = new THREE.Vector3(0.5, 0.5, 0.5);

or double its size like this: 或者它的大小加倍:

yorDownloadedObject.scale = new THREE.Vector3(2, 2, 2);

But if the sizes are too different you may want to scale up or down depending their actual size... 但如果尺寸太大,您可能需要根据实际尺寸放大或缩小......

To know their original size, before scaling, get their bounding box using the Object3D.Geometry property method named computeBoundingBox (or computeBoundingSphere). 要在缩放之前知道它们的原始大小,请使用名为computeBoundingBox (或computeBoundingSphere)的Object3D.Geometry属性方法获取其边界框

Afterwards scale up or down up to your desired size depending on the Geometry.boundingBox property using Cross-multiplication . 然后根据使用交叉乘法的Geometry.boundingBox属性向上或向下放大到所需的大小。

Another recommendation is that you get the models resized and do not touch anything. 另一个建议是,您可以调整模型大小,不要碰任何东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM