more fdm slicing work
This commit is contained in:
parent
6e172fe40f
commit
c1ee342dbb
9 changed files with 45 additions and 52 deletions
1
app.js
1
app.js
|
|
@ -937,6 +937,7 @@ function cookieValue(cookie,key) {
|
||||||
function rewriteHtmlVersion(req, res, next) {
|
function rewriteHtmlVersion(req, res, next) {
|
||||||
if ([
|
if ([
|
||||||
"/v2/kiri/",
|
"/v2/kiri/",
|
||||||
|
"/v2/lib/kiri-run/minion.js",
|
||||||
"/v2/lib/kiri-run/worker.js"
|
"/v2/lib/kiri-run/worker.js"
|
||||||
].indexOf(req.app.path) >= 0) {
|
].indexOf(req.app.path) >= 0) {
|
||||||
addCorsHeaders(req, res);
|
addCorsHeaders(req, res);
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,12 @@ import { base, config, util } from './base.js';
|
||||||
import { ClipperLib } from '../ext/clip2.esm.js';
|
import { ClipperLib } from '../ext/clip2.esm.js';
|
||||||
import { newBounds } from './bounds.js';
|
import { newBounds } from './bounds.js';
|
||||||
import { newPoint, pointFromClipper } from './point.js';
|
import { newPoint, pointFromClipper } from './point.js';
|
||||||
import { polygons } from './polygons.js';
|
import { polygons as POLY } from './polygons.js';
|
||||||
import { earcut } from '../geo/base.js';
|
import { earcut } from '../geo/base.js';
|
||||||
|
|
||||||
const { Vector3 } = THREE;
|
const { Vector3 } = THREE;
|
||||||
|
|
||||||
const POLY = polygons,
|
let XAXIS = new Vector3(1,0,0),
|
||||||
XAXIS = new Vector3(1,0,0),
|
|
||||||
DEG2RAD = Math.PI / 180,
|
DEG2RAD = Math.PI / 180,
|
||||||
Clipper = ClipperLib.Clipper,
|
Clipper = ClipperLib.Clipper,
|
||||||
ClipType = ClipperLib.ClipType,
|
ClipType = ClipperLib.ClipType,
|
||||||
|
|
@ -2381,5 +2380,3 @@ export function fromClipperPath(path, z) {
|
||||||
export function newPolygon(points) {
|
export function newPolygon(points) {
|
||||||
return new Polygon(points);
|
return new Polygon(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { polygons };
|
|
||||||
|
|
@ -10,7 +10,6 @@ import { newOrderedLine } from './line.js';
|
||||||
import { newPolygon } from '../geo/polygon.js';
|
import { newPolygon } from '../geo/polygon.js';
|
||||||
import { polygons } from '../geo/polygons.js';
|
import { polygons } from '../geo/polygons.js';
|
||||||
import { newPoint } from '../geo/point.js';
|
import { newPoint } from '../geo/point.js';
|
||||||
import { util } from '../mesh/util.js';
|
|
||||||
import { config } from '../geo/base.js';
|
import { config } from '../geo/base.js';
|
||||||
|
|
||||||
function dval(v, dv) {
|
function dval(v, dv) {
|
||||||
|
|
@ -409,7 +408,6 @@ export async function sliceZ(z, points, options = {}) {
|
||||||
|
|
||||||
// look for driver-specific slice post-processor
|
// look for driver-specific slice post-processor
|
||||||
if (options.post) {
|
if (options.post) {
|
||||||
console.log({ options });
|
|
||||||
let fn = slicer.slicePost[options.post];
|
let fn = slicer.slicePost[options.post];
|
||||||
if (fn) fn(rval, options);
|
if (fn) fn(rval, options);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
import { base } from '../../geo/base.js';
|
import { base } from '../../geo/base.js';
|
||||||
import { polygons as POLY, fillArea } from '../../geo/polygons.js';
|
import { polygons as POLY, fillArea } from '../../geo/polygons.js';
|
||||||
import { getRangeParameters } from './driver.js';
|
import { getRangeParameters } from './driver.js';
|
||||||
|
import { slicer } from '../../geo/slicer.js';
|
||||||
|
|
||||||
|
slicer.slicePost.FDM = slicePost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* may run in minion or worker context. do not create objects
|
* may run in minion or worker context. do not create objects
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,20 @@
|
||||||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
|
|
||||||
// Base dependencies
|
import "../ext/clip2.js";
|
||||||
import { polygons } from '../../geo/base.js';
|
import "../ext/earcut.js";
|
||||||
|
import '../add/array.js';
|
||||||
|
import '../add/class.js';
|
||||||
|
import '../add/three.js';
|
||||||
|
|
||||||
// Kiri dependencies
|
import { base } from '../geo/base.js';
|
||||||
import { codec } from '../../kiri/index.js';
|
import { newPoint } from '../geo/point.js';
|
||||||
|
import { polygons as POLY } from '../geo/polygons.js';
|
||||||
|
import { sliceZ } from '../geo/slicer.js';
|
||||||
|
import { codec } from '../kiri/codec.js';
|
||||||
|
import { broker } from '../moto/broker.js';
|
||||||
|
import { doTopShells } from '../kiri-mode/fdm/post.js';
|
||||||
|
import { wasm_ctrl } from '../geo/wasm.js';
|
||||||
|
|
||||||
// Moto dependencies
|
|
||||||
import { broker } from '../../moto/broker.js';
|
|
||||||
|
|
||||||
// Note: This module also depends on:
|
|
||||||
// - moto.license (for licensing functionality)
|
|
||||||
// - geo.slicer (for slicing functionality)
|
|
||||||
// - geo.wasm (for WebAssembly functionality)
|
|
||||||
// - kiri-mode.fdm.post (for FDM post processing)
|
|
||||||
// - kiri-mode.cam.topo (for CAM topo functionality)
|
|
||||||
// - kiri-mode.cam.topo4 (for CAM topo4 functionality)
|
|
||||||
// - kiri-mode.cam.slicer (for CAM slicing)
|
|
||||||
// - ext.clip2 (for clipping operations)
|
|
||||||
// - Various kiri API functions injected via root
|
|
||||||
|
|
||||||
const POLY = polygons;
|
|
||||||
const clib = self.ClipperLib;
|
const clib = self.ClipperLib;
|
||||||
const ctyp = clib.ClipType;
|
const ctyp = clib.ClipType;
|
||||||
const ptyp = clib.PolyType;
|
const ptyp = clib.PolyType;
|
||||||
|
|
@ -75,7 +69,7 @@ const funcs = self.minion = {
|
||||||
topShells: (data, seq) => {
|
topShells: (data, seq) => {
|
||||||
let top = codec.decode(data.top, {full: true});
|
let top = codec.decode(data.top, {full: true});
|
||||||
let {z, count, offset1, offsetN, fillOffset, opt} = data;
|
let {z, count, offset1, offsetN, fillOffset, opt} = data;
|
||||||
kiri.driver.FDM.doTopShells(z, top, count, offset1, offsetN, fillOffset, opt);
|
doTopShells(z, top, count, offset1, offsetN, fillOffset, opt);
|
||||||
let state = { zeros: [] };
|
let state = { zeros: [] };
|
||||||
reply({ seq, top: codec.encode(top, {full: true}) }, state.zeros);
|
reply({ seq, top: codec.encode(top, {full: true}) }, state.zeros);
|
||||||
},
|
},
|
||||||
|
|
@ -122,14 +116,15 @@ const funcs = self.minion = {
|
||||||
},
|
},
|
||||||
|
|
||||||
sliceZ: (data, seq) => {
|
sliceZ: (data, seq) => {
|
||||||
|
console.log('minion.sliceZ', { data, seq });
|
||||||
let { z, points, options } = data;
|
let { z, points, options } = data;
|
||||||
let i = 0, p = 0, realp = new Array(points.length / 3);
|
let i = 0, p = 0, realp = new Array(points.length / 3);
|
||||||
while (i < points.length) {
|
while (i < points.length) {
|
||||||
realp[p++] = base.newPoint(points[i++], points[i++], points[i++]).round(3);
|
realp[p++] = newPoint(points[i++], points[i++], points[i++]).round(3);
|
||||||
}
|
}
|
||||||
let state = { zero: [] };
|
let state = { zero: [] };
|
||||||
let output = [];
|
let output = [];
|
||||||
base.sliceZ(z, realp, {
|
sliceZ(z, realp, {
|
||||||
...options,
|
...options,
|
||||||
each(out) { output.push(out) }
|
each(out) { output.push(out) }
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
|
@ -159,9 +154,9 @@ const funcs = self.minion = {
|
||||||
|
|
||||||
wasm: data => {
|
wasm: data => {
|
||||||
if (data.enable) {
|
if (data.enable) {
|
||||||
base.wasm_ctrl.enable();
|
wasm_ctrl.enable();
|
||||||
} else {
|
} else {
|
||||||
base.wasm_ctrl.disable();
|
wasm_ctrl.disable();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -170,18 +165,4 @@ const funcs = self.minion = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
moto.broker.publish("minion.started", { funcs, cache, reply, log });
|
broker.publish("minion.started", { funcs, cache, reply, log });
|
||||||
|
|
||||||
// Future exports for src/kiri-run/minion.js when unwrapped from gapp.register()
|
|
||||||
|
|
||||||
// Utility functions
|
|
||||||
export { reply, log };
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
export { POLY, clib, ctyp, ptyp, cfil };
|
|
||||||
|
|
||||||
// Global variables
|
|
||||||
export { cache, name };
|
|
||||||
|
|
||||||
// Default export - the main minion functionality
|
|
||||||
export default funcs;
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,16 @@ const minwork = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let i=0; i < concurrent; i++) {
|
for (let i=0; i < concurrent; i++) {
|
||||||
let minion = new Worker(`/v2/lib/kiri-run/minion.js`);
|
let minion = new Worker(`/v2/lib/kiri-run/minion.js`, { type: 'module' });
|
||||||
|
minion.onerror = (error) => {
|
||||||
|
console.log({ MINION_ERROR: error });
|
||||||
|
error.preventDefault();
|
||||||
|
};
|
||||||
|
minion.onmessageerror = (error) => {
|
||||||
|
console.log({ MINION_MESSAGE_ERROR: error });
|
||||||
|
error.preventDefault();
|
||||||
|
};
|
||||||
|
console.log({ minion });
|
||||||
minion.onmessage = minhandler;
|
minion.onmessage = minhandler;
|
||||||
minion.postMessage({ cmd: "label", name: `#${i}` });
|
minion.postMessage({ cmd: "label", name: `#${i}` });
|
||||||
minions.push(minion);
|
minions.push(minion);
|
||||||
|
|
@ -173,6 +182,7 @@ const minwork = {
|
||||||
},
|
},
|
||||||
|
|
||||||
sliceZ(z, points, options) {
|
sliceZ(z, points, options) {
|
||||||
|
console.log('minwork.sliceZ', { z, points, options });
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (concurrent < 2) {
|
if (concurrent < 2) {
|
||||||
reject("concurrent slice unavaiable");
|
reject("concurrent slice unavaiable");
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,12 @@ export const client = {
|
||||||
} else {
|
} else {
|
||||||
let worker = new Worker(`/v2/lib/kiri-run/worker.js`, { type: 'module' });
|
let worker = new Worker(`/v2/lib/kiri-run/worker.js`, { type: 'module' });
|
||||||
worker.onerror = (error) => {
|
worker.onerror = (error) => {
|
||||||
console.log({ worker_error: error });
|
console.log({ WORKER_ERROR: error });
|
||||||
error.preventDefault();
|
error.preventDefault();
|
||||||
};
|
};
|
||||||
worker.onmessageerror = (error) => {
|
worker.onmessageerror = (error) => {
|
||||||
console.log({ worker_message_error: error });
|
console.log({ WORKER_MESSAGE_ERROR: error });
|
||||||
|
error.preventDefault();
|
||||||
};
|
};
|
||||||
console.log({ worker });
|
console.log({ worker });
|
||||||
return worker;
|
return worker;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ import { client as motoClient } from '../moto/client.js';
|
||||||
import { api as meshApi } from './api.js';
|
import { api as meshApi } from './api.js';
|
||||||
import { object as meshObject } from './object.js';
|
import { object as meshObject } from './object.js';
|
||||||
import { model as meshModel } from './model.js';
|
import { model as meshModel } from './model.js';
|
||||||
import { newPolygon, polygons } from '../geo/polygon.js';
|
import { newPolygon } from '../geo/polygon.js';
|
||||||
|
import { polygons } from '../geo/polygons.js';
|
||||||
import { space } from '../moto/space.js';
|
import { space } from '../moto/space.js';
|
||||||
import { util } from './util.js';
|
import { util } from './util.js';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
<link href="manifest.json" rel="manifest">
|
<link href="manifest.json" rel="manifest">
|
||||||
<link href="../font/css/all.min.css" rel="stylesheet">
|
<link href="../font/css/all.min.css" rel="stylesheet">
|
||||||
<!-- <script type="module" src="/v2/lib/kiri-run/worker.js"></script> -->
|
<!-- <script type="module" src="/v2/lib/kiri-run/worker.js"></script> -->
|
||||||
|
<!-- <script type="module" src="/v2/lib/kiri-run/minion.js"></script> -->
|
||||||
<script src="../lib/ext/earcut.js" type="module"></script>
|
<script src="../lib/ext/earcut.js" type="module"></script>
|
||||||
<script src="../lib/ext/tween.js"></script>
|
<script src="../lib/ext/tween.js"></script>
|
||||||
<script src="../font/js/all.min.js" crossorigin="anonymous" defer></script>
|
<script src="../font/js/all.min.js" crossorigin="anonymous" defer></script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue