简体   繁体   中英

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.

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.

Does anybody know a way of making all the 3D Models the same size?

Thank You!!!

You have to modify the Object3D scale property. You can scale independently X, Y and Z, so you can set them up to half of its size setting this scale like this:

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).

Afterwards scale up or down up to your desired size depending on the Geometry.boundingBox property using Cross-multiplication .

Another recommendation is that you get the models resized and do not touch anything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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