修复:实体对象包围盒错误导致的一键布局错误

pull/1892/MERGE
ChenX 2 years ago
parent 22bb664a2d
commit a9c586a65e

@ -1,9 +1,9 @@
import { Face3, Geometry, Matrix4, Mesh, MeshNormalMaterial, Object3D, ShapeUtils, Vector2, Vector3 } from "three";
import { Box3, Face3, Geometry, Matrix4, Mesh, MeshNormalMaterial, Object3D, ShapeUtils, Vector2, Vector3 } from "three";
import { ColorMaterial } from "../../Common/ColorPalette";
import { Object3DRemoveAll } from "../../Common/Dispose";
import { clamp, FixIndex } from "../../Common/Utils";
import { ObjectSnapMode } from "../../Editor/ObjectSnapMode";
import { angle, AsVector2, equaln, equalv3, ZeroVec, YAxis, isParallelTo } from "../../Geometry/GeUtils";
import { angle, AsVector2, equaln, equalv3, isParallelTo, YAxis, ZeroVec } from "../../Geometry/GeUtils";
import { Matrix2 } from "../../Geometry/Matrix2";
import { Orbit } from "../../Geometry/Orbit";
import { RenderType } from "../../GraphicsSystem/RenderType";
@ -147,6 +147,22 @@ export class RevolveSolid extends Entity
private _MeshGeometry: Geometry;
get BoundingBox()
{
let geom = this.MeshGeometry;
if (!geom)
{
console.error("RevolveSolid无法建模");
return new Box3;
}
if (!geom.boundingBox)
geom.computeBoundingBox();
return geom.boundingBox.clone().applyMatrix4(this._Matrix);
}
private _CacheContourPoints: Vector2[];//轮廓2D点
private _CacheContourPoints3D: Vector3[];//轮廓3D点

@ -1,4 +1,4 @@
import { BoxBufferGeometry, BufferGeometry, Float32BufferAttribute, InstancedInterleavedBuffer, InterleavedBufferAttribute, Line as TLine, Line3, LineSegments, Matrix3, Matrix4, Mesh, Object3D, Vector3 } from "three";
import { Box3, BoxBufferGeometry, BufferGeometry, Float32BufferAttribute, InstancedInterleavedBuffer, InterleavedBufferAttribute, Line as TLine, Line3, LineSegments, Matrix3, Matrix4, Mesh, Object3D, Vector3 } from "three";
import { Line2 } from "three/examples/jsm/lines/Line2";
import { LineGeometry } from "three/examples/jsm/lines/LineGeometry";
import { ColorMaterial } from '../../Common/ColorPalette';
@ -284,13 +284,23 @@ export class SweepSolid extends Entity
mesh.material = this.MeshMaterial;
}
}
get BoundingBox()
{
if (!this.MeshGeometry.boundingBox)
this.MeshGeometry.computeBoundingBox();
let geom = this.MeshGeometry;
if (!geom)
{
console.error("SweepSolid无法建模");
return new Box3;
}
if (!geom.boundingBox)
geom.computeBoundingBox();
return this.MeshGeometry.boundingBox.clone().applyMatrix4(this._Matrix);
return geom.boundingBox.clone().applyMatrix4(this._Matrix);
}
get OBB(): OBB
{
let box = this.BoundingBox;

Loading…
Cancel
Save