修正:csg计算

pull/706/MERGE
ChenX 5 years ago
parent f70ec3dc6c
commit ab296731c4

@ -1,4 +1,5 @@
import { Matrix4 } from "three";
import { equaln, equalv3 } from "../../../Geometry/GeUtils";
import { getTag } from "../constants";
import { IsMirror } from "./IsMirrot";
import { Vector3D } from "./Vector3";
@ -29,9 +30,9 @@ export class Plane
return this.tag;
}
equals(plane: Plane)
coplanarTo(plane: Plane)
{
return this.normal.equals(plane.normal) && this.w === plane.w;
return equalv3(this.normal, plane.normal, 1e-4) && equaln(this.w, plane.w, 1e-4);
}
transform(matrix4x4: Matrix4)

@ -129,7 +129,7 @@ export class Polygon
let planeNormal = plane.normal;
let vertices = this.vertices;
let numVertices = vertices.length;
if (this.plane.equals(plane))
if (this.plane.coplanarTo(plane))
{
result.type = Type.CoplanarFront;
}

@ -7,7 +7,7 @@ export function reTesselate(csg: CSG): CSG
{
if (csg.isRetesselated) return csg;
let polygonsPerPlane: { [key: number]: Polygon[] } = {};
let polygonsPerPlane: { [key: number]: Polygon[]; } = {};
let isCanonicalized = csg.isCanonicalized;
let fuzzyfactory = new FuzzyCSGFactory();

Loading…
Cancel
Save