优化:EntityRef在被缩放的情况下提供正确的包围盒

pull/2047/head
ChenX 2 years ago
parent aba8d13a22
commit 1f2b186d81

@ -60,12 +60,26 @@ export class EntityRef extends Entity
return new Vector3(1, 1, 1); return new Vector3(1, 1, 1);
} }
get BoundingBox()
{
return this.BoundingBoxInOCS.applyMatrix4(this.OCSNoClone);
}
get BoundingBoxInOCS() get BoundingBoxInOCS()
{ {
let size = this.ScaleSize.x ? this.ScaleSize : this._Size; let box = new Box3Ext(
return new Box3Ext( this._Size.clone().multiplyScalar(-0.5).add(this._Center),
size.clone().multiplyScalar(-0.5).add(this._Center), this._Size.clone().multiplyScalar(0.5).add(this._Center));
size.clone().multiplyScalar(0.5).add(this._Center));
if (this._ScaleSize.x)
{
box.applyMatrix4(new Matrix4().makeScale(
this._ScaleSize.x / this._Size.x,
this._ScaleSize.y / this._Size.y,
this._ScaleSize.z / this._Size.z,
));
}
return box;
} }
CloneDrawObject(from: this) CloneDrawObject(from: this)

Loading…
Cancel
Save