mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-24 09:26:43 +01:00
'tesselation' type fix
This commit is contained in:
parent
a596b22a78
commit
bf2d6386c9
8 changed files with 17 additions and 17 deletions
|
|
@ -20,9 +20,9 @@ export function readBrep(data: BREPData) {
|
|||
bb.face();
|
||||
let nonDirect = faceData.surface.direct === false; // left handed coordinate system for planes
|
||||
let inverted = faceData.inverted !== nonDirect;
|
||||
bb._face.data.tesselation = {
|
||||
bb._face.data.tessellation = {
|
||||
format: 'verbose',
|
||||
data: normalizeTesselationData(faceData.tess, inverted, faceData.surface.TYPE === 'PLANE' ? faceData.surface.normal : undefined)
|
||||
data: normalizetessellationData(faceData.tess, inverted, faceData.surface.TYPE === 'PLANE' ? faceData.surface.normal : undefined)
|
||||
};
|
||||
bb._face.data.productionInfo = faceData.productionInfo;
|
||||
if (faceData.ref !== undefined) {
|
||||
|
|
@ -37,7 +37,7 @@ export function readBrep(data: BREPData) {
|
|||
let a = vf.getData(edgeData.inverted ? edgeData.b : edgeData.a);
|
||||
let b = vf.getData(edgeData.inverted ? edgeData.a : edgeData.b);
|
||||
bb.edge(a, b, () => readCurve(edgeData.curve), edgeData.inverted, edgeData.edgeRef);
|
||||
bb.lastHalfEdge.edge.data.tesselation = edgeData.tess;
|
||||
bb.lastHalfEdge.edge.data.tessellation = edgeData.tess;
|
||||
//todo: data should provide full externals object
|
||||
bb.lastHalfEdge.edge.data.externals = {
|
||||
ptr: edgeData.ptr
|
||||
|
|
@ -73,7 +73,7 @@ function readSurface(s, inverted, face) {
|
|||
|
||||
let tr = plane.get2DTransformation();
|
||||
for (let he of face.outerLoop.halfEdges) {
|
||||
let tess = he.edge.data.tesselation ? he.edge.data.tesselation : he.edge.curve.tessellateToData();
|
||||
let tess = he.edge.data.tessellation ? he.edge.data.tessellation : he.edge.curve.tessellateToData();
|
||||
tess.forEach(p => bBox.checkData(tr.apply3(p)));
|
||||
}
|
||||
bBox.expand(10);
|
||||
|
|
@ -96,7 +96,7 @@ function readCurve(curve) {
|
|||
}
|
||||
}
|
||||
|
||||
export function normalizeTesselationData(tessellation, inverted, surfaceNormal) {
|
||||
export function normalizetessellationData(tessellation, inverted, surfaceNormal) {
|
||||
let tess = [];
|
||||
for (let i = 0; i < tessellation.length; ++i) {
|
||||
let [tr, normales] = tessellation[i];
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ declare module './face' {
|
|||
data: {
|
||||
id: string,
|
||||
productionInfo: ProductionInfo,
|
||||
tesselation: {
|
||||
tessellation: {
|
||||
format: string,
|
||||
data: any;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import {ORIGIN} from "math/vector";
|
|||
|
||||
export default class ScalableLine extends Mesh {
|
||||
|
||||
constructor(tesselation, width, color, opacity, smooth, ambient) {
|
||||
super(createGeometry(tesselation, smooth), createMaterial(color, opacity, ambient));
|
||||
constructor(tessellation, width, color, opacity, smooth, ambient) {
|
||||
super(createGeometry(tessellation, smooth), createMaterial(color, opacity, ambient));
|
||||
this.width = width;
|
||||
this.morphTargetInfluences = [0];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export class EdgeView extends CurveBasedView {
|
|||
|
||||
constructor(edge) {
|
||||
let brepEdge = edge.brepEdge;
|
||||
let tess = brepEdge.data.tesselation ? brepEdge.data.tesselation : brepEdge.curve.tessellateToData();
|
||||
let tess = brepEdge.data.tessellation ? brepEdge.data.tessellation : brepEdge.curve.tessellateToData();
|
||||
super(edge, tess, 2, 3, 0x2B3856, 0xd1726c);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ export class FaceView extends SketchingView {
|
|||
this.geometry = geometry;
|
||||
this.meshFaces = [];
|
||||
let off = geometry.faces.length;
|
||||
if (face.brepFace.data.tesselation) {
|
||||
tessDataToGeom(face.brepFace.data.tesselation.data, geometry)
|
||||
if (face.brepFace.data.tessellation) {
|
||||
tessDataToGeom(face.brepFace.data.tessellation.data, geometry)
|
||||
} else {
|
||||
brepFaceToGeom(face, geometry);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ export class BREPSceneSolid extends SceneSolid {
|
|||
const sceneFace = new BREPSceneFace(brepFace, this);
|
||||
this.sceneFaces.push(sceneFace);
|
||||
let off = geom.faces.length;
|
||||
if (brepFace.data.tesselation) {
|
||||
tessDataToGeom(brepFace.data.tesselation.data, geom)
|
||||
if (brepFace.data.tessellation) {
|
||||
tessDataToGeom(brepFace.data.tessellation.data, geom)
|
||||
} else {
|
||||
brepFaceToGeom(brepFace, geom);
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ export class BREPSceneSolid extends SceneSolid {
|
|||
materialParams.transparent = true;
|
||||
materialParams.opacity = opacity;
|
||||
}
|
||||
let tess = edge.data.tesselation ? edge.data.tesselation : edge.curve.tessellateToData();
|
||||
let tess = edge.data.tessellation ? edge.data.tessellation : edge.curve.tessellateToData();
|
||||
let base = null;
|
||||
for (let i = 1; i < tess.length; i++) {
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,6 @@ function begincallback(type) {
|
|||
}
|
||||
}
|
||||
function errorcallback(errno) {
|
||||
console.log('tesselation error');
|
||||
console.log('tessellation error');
|
||||
console.log('error number: ' + errno);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ function errorcallback(errno) {
|
|||
|
||||
export function Triangulate(contours, normal) {
|
||||
const tessy = initTesselator();
|
||||
// libtess will take 3d verts and flatten to a plane for tesselation
|
||||
// since only doing 2d tesselation here, provide z=1 normal to skip
|
||||
// libtess will take 3d verts and flatten to a plane for tessellation
|
||||
// since only doing 2d tessellation here, provide z=1 normal to skip
|
||||
// iterating over verts only to get the same answer.
|
||||
// comment out to test normal-generation code
|
||||
//tessy.gluTessNormal(0, 0, 1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue