适当使用三js box3()。getsize()方法是什么?
stackoverflow 等人似乎都同意正确使用 Box3() getSize()
方法如下:
const geometry = new THREE.BoxGeometry( 10, 10, 10 );
const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );
let cubeBoundingBox = new THREE.Box3().setFromObject( cube );
let boxSize = cubeBoundingBox.getSize();
console.log("BoxSize: " + boxSize);
然而事实似乎并非如此。请参阅此示例中的错误: https://jsfiddle.net/8L5dczmf/3/
我可以请参阅 Three.js 文档 getSize()
实际上应该这样使用...除非我正在阅读 .getSize ( target : Vector3 ) : Vector3
错误地。那么上面小提琴中的代码有什么问题呢?
Everywhere on stackoverflow et al seem to agree that the proper use of the Box3() getSize()
method is as follows:
const geometry = new THREE.BoxGeometry( 10, 10, 10 );
const material = new THREE.MeshBasicMaterial( {color: 0x00ff00} );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );
let cubeBoundingBox = new THREE.Box3().setFromObject( cube );
let boxSize = cubeBoundingBox.getSize();
console.log("BoxSize: " + boxSize);
However this doesn't seem to be the case. See the error in this example: https://jsfiddle.net/8L5dczmf/3/
I can see in the three.js documentation that getSize()
is in fact supposed to be used this way... unless I'm reading .getSize ( target : Vector3 ) : Vector3
incorrectly. What is wrong with the code in the fiddle above then?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
您需要传入一个向量,结果将写入其中:
这里的目的是您可以 池化您的
Vector3
对象,并以低廉的成本重复使用它们,而不会产生大量垃圾供 GC 清理。You're expected to pass in a vector into which the result will be written:
The intention here is that you can pool your
Vector3
objects, and re-use them cheaply without making tons of garbage for the GC to clean up.