mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-22 05:37:55 +01:00
remove normals
This commit is contained in:
parent
ead6be081f
commit
fd6e5cebbd
@ -1,15 +1,15 @@
|
|||||||
import { angle, subtract, distanceTo, normal } from './vector2.js';
|
import { angle, subtract, distanceTo } from './vector2.js';
|
||||||
|
|
||||||
const graphs = new WeakMap();
|
const graphs = new WeakMap();
|
||||||
export default function comb(polygons, start, end) {
|
export default function comb(polygons, start, end) {
|
||||||
if (!graphs.has(polygons)) graphs.set(polygons, createGraph(polygons));
|
if (!graphs.has(polygons)) graphs.set(polygons, createGraph(polygons));
|
||||||
let { edges, graph, points, normals } = graphs.get(polygons);
|
let { edges, graph, points } = graphs.get(polygons);
|
||||||
|
|
||||||
points = [...points, start, end];
|
points = [...points, start, end];
|
||||||
graph = [...graph];
|
graph = [...graph];
|
||||||
|
|
||||||
const startNode = createNode(graph, points, edges, normals, start);
|
const startNode = createNode(graph, points, edges, start);
|
||||||
const endNode = createNode(graph, points, edges, normals, end);
|
const endNode = createNode(graph, points, edges, end);
|
||||||
|
|
||||||
let result;
|
let result;
|
||||||
if (graph[startNode].some(node => node.to === endNode)) {
|
if (graph[startNode].some(node => node.to === endNode)) {
|
||||||
@ -31,7 +31,6 @@ function createGraph(polygons) {
|
|||||||
const edges = [];
|
const edges = [];
|
||||||
const nextPoints = new WeakMap();
|
const nextPoints = new WeakMap();
|
||||||
const previousPoints = new WeakMap();
|
const previousPoints = new WeakMap();
|
||||||
const normals = new WeakMap();
|
|
||||||
for (let i = 0; i < polygons.length; i ++) {
|
for (let i = 0; i < polygons.length; i ++) {
|
||||||
const polygon = polygons[i];
|
const polygon = polygons[i];
|
||||||
for (let j = 0; j < polygon.length; j ++) {
|
for (let j = 0; j < polygon.length; j ++) {
|
||||||
@ -43,8 +42,6 @@ function createGraph(polygons) {
|
|||||||
edges.push([point, nextPoint]);
|
edges.push([point, nextPoint]);
|
||||||
nextPoints.set(point, nextPoint);
|
nextPoints.set(point, nextPoint);
|
||||||
previousPoints.set(point, previousPoint);
|
previousPoints.set(point, previousPoint);
|
||||||
|
|
||||||
normals.set(point, normal(subtract(nextPoint, point)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,10 +65,10 @@ function createGraph(polygons) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { graph, edges, points, normals };
|
return { graph, edges, points };
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNode(graph, points, edges, normals, point) {
|
function createNode(graph, points, edges, point) {
|
||||||
const node = [];
|
const node = [];
|
||||||
const to = graph.length;
|
const to = graph.length;
|
||||||
graph.push(node);
|
graph.push(node);
|
||||||
|
Loading…
Reference in New Issue
Block a user