【发布时间】:2021-04-13 12:24:32
【问题描述】:
我在后端使用 three.js lib 来计算 AABB(轴对齐边界框)。
getAABB: function (position, scale, orientation) {
const cube = new Mesh(new BoxGeometry(0, 0, 0));
cube.position.set(...position);
cube.scale.set(...scale);
cube.rotation.set(...orientation);
const bb = new Box3().setFromObject(cube);
const { min, max } = bb;
return {
x: {
min: min.x,
max: max.x,
},
y: {
min: min.y,
max: max.y,
},
z: {
min: min.z,
max: max.z,
}
};
}
对于三个@0.118,结果看起来不错:
{
x: { min: 0.5391231359521602, max: 3.46087686404784 },
y: { min: 0.32046946879189564, max: 3.6795305312081044 },
z: { min: 0.4349899537033477, max: 3.5650100462966523 },
}
但是一旦我更新到three@0.119,它就会开始返回错误的结果:
{
x: { min: 2, max: 2 },
y: { min: 2, max: 2 },
z: { min: 2, max: 2 },
}
在此示例中,您可以看到 0.119 https://jsfiddle.net/yura_syedin/zwm3jkdL/ 的错误结果
这是 0.118 https://jsfiddle.net/yura_syedin/5801pLaw/34/ 的正确结果
【问题讨论】:
标签: three.js bounding-box aabb