Three.js - 使用 scale.set() 缩放模型或增加模型大小? [英] Three.js - Scale model with scale.set() or increase model size?
问题描述
在 Three.js(或其他 3d 渲染器)中缩放 3d 模型的最佳实践是什么?
What is the best practise for scaling 3d models in Three.js (or other 3d renderers)?
这是我刚刚遇到的一个例子:
Here is an example I just faced:
我加载了一个模型,发现模型太小了.然后我使用 mesh.scale.set(2,2,2);
缩放网格,它是完美的尺寸.
I load a model in and realise the size of the model is too small. I then scale the mesh using mesh.scale.set(2,2,2);
and it is perfect size.
在这种情况下我应该采取什么措施,我是让它保持这样的缩放比例(以编程方式缩放),还是返回到我的 3d 建模软件并将模型的大小加倍?
What action should I take in this scenario, do I leave it scaled like that (programatically scaled) or do I go back to my 3d modelling software and double the size of the model?
谢谢
推荐答案
这不是最佳实践
的问题,而是优化
的问题.如果您的网格总是被缩放,最好在建模软件中进行缩放.那个简单的语句 mesh.scale.set(2,2,2);
是一个矩阵乘法,需要在渲染的每一帧上发生.现在也许您的场景中没有太多几何体,在这种情况下您并不关心.但正如我所说,这是一个优化问题.如果您的场景有 1000 个或 1000000 个这样的网格会怎样.矩阵乘法需要对每个网格进行.尽可能优化.
It is not a matter of best practice
but rather of optimization
. If your mesh will always be scaled, it is better if you do the scaling in your modeling software. That simple statement mesh.scale.set(2,2,2);
is a matrix multiplication that needs to happen on each frame rendered. Now maybe your scene does not have much geometry in it in which case you don't care. But as I said it is a matter of optimization. What if your scene had 1000 such meshes or 1000000. That matrix multiplication would need to happen for each one of them. Optimize whenever you can.
这篇关于Three.js - 使用 scale.set() 缩放模型或增加模型大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!