@danielsimonjr/sciengjs 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES.md +9 -5
- package/assets/licenses/MIT-three.txt +21 -0
- package/assets/three.BufferGeometryUtils.js +1523 -0
- package/assets/three.GLTFLoader.js +5006 -0
- package/assets/three.OrbitControls.js +1985 -0
- package/assets/three.SkeletonUtils.js +496 -0
- package/assets/three.core.js +61162 -0
- package/assets/three.module.js +19537 -0
- package/dist/browser/pinned.d.ts +23 -0
- package/dist/browser/pinned.js +18 -0
- package/dist/browser/pinned.js.map +1 -1
- package/dist/browser/render.d.ts +6 -0
- package/dist/browser/render.js +10 -1
- package/dist/browser/render.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mesh/backend-glb.d.ts +25 -0
- package/dist/mesh/backend-glb.js +74 -0
- package/dist/mesh/backend-glb.js.map +1 -0
- package/dist/mesh/backend-html.d.ts +6 -0
- package/dist/mesh/backend-html.js +12 -0
- package/dist/mesh/backend-html.js.map +1 -0
- package/dist/mesh/backend-png.d.ts +6 -0
- package/dist/mesh/backend-png.js +35 -0
- package/dist/mesh/backend-png.js.map +1 -0
- package/dist/mesh/glb.d.ts +9 -0
- package/dist/mesh/glb.js +163 -0
- package/dist/mesh/glb.js.map +1 -0
- package/dist/mesh/index.d.ts +5 -0
- package/dist/mesh/index.js +5 -0
- package/dist/mesh/index.js.map +1 -0
- package/dist/mesh/pinned-three.d.ts +6 -0
- package/dist/mesh/pinned-three.js +21 -0
- package/dist/mesh/pinned-three.js.map +1 -0
- package/dist/mesh/read.d.ts +27 -0
- package/dist/mesh/read.js +56 -0
- package/dist/mesh/read.js.map +1 -0
- package/dist/mesh/viewer-script.d.ts +6 -0
- package/dist/mesh/viewer-script.js +207 -0
- package/dist/mesh/viewer-script.js.map +1 -0
- package/dist/mesh/viewer.d.ts +14 -0
- package/dist/mesh/viewer.js +39 -0
- package/dist/mesh/viewer.js.map +1 -0
- package/dist/registry.js +9 -0
- package/dist/registry.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { THREE_MODULES } from "../browser/pinned.js";
|
|
3
|
+
import { readAsset } from "../assets.js";
|
|
4
|
+
import { RenderError } from "../errors.js";
|
|
5
|
+
/**
|
|
6
|
+
* Reads the pinned Three.js files from the assets folder and checks the SHA-256 of each. A missing file rejects with
|
|
7
|
+
* E_STAGE_MISSING. A file with other bytes rejects with E_INTEGRITY, so a changed copy never runs in a page.
|
|
8
|
+
*/
|
|
9
|
+
export function pinnedThree(assetsUrl) {
|
|
10
|
+
const map = new Map();
|
|
11
|
+
for (const m of THREE_MODULES) {
|
|
12
|
+
const bytes = readAsset(assetsUrl, m.file);
|
|
13
|
+
const hash = createHash("sha256").update(bytes).digest("hex");
|
|
14
|
+
if (hash !== m.sha256) {
|
|
15
|
+
throw new RenderError("E_INTEGRITY", `${m.file} has the SHA-256 ${hash}, not the pinned ${m.sha256}`);
|
|
16
|
+
}
|
|
17
|
+
map.set(m.url, { bytes, mime: m.mime });
|
|
18
|
+
}
|
|
19
|
+
return map;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=pinned-three.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pinned-three.js","sourceRoot":"","sources":["../../src/mesh/pinned-three.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC3C,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9D,IAAI,IAAI,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;YACtB,MAAM,IAAI,WAAW,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,IAAI,oBAAoB,IAAI,oBAAoB,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QACxG,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** The CAD input formats that occt-import-js reads. */
|
|
2
|
+
export type CadFormat = "step" | "iges" | "brep";
|
|
3
|
+
/** The linear units that the STEP and IGES readers accept. The default is millimeter. */
|
|
4
|
+
export type LinearUnit = "millimeter" | "meter";
|
|
5
|
+
/** One face of a mesh. The triangles first to last (inclusive) belong to the face. */
|
|
6
|
+
export interface CadFace {
|
|
7
|
+
first: number;
|
|
8
|
+
last: number;
|
|
9
|
+
/** The RGB colour in the range 0 to 1, or null when the face has no colour. */
|
|
10
|
+
color: [number, number, number] | null;
|
|
11
|
+
}
|
|
12
|
+
/** One mesh of a CAD file, as flat arrays. */
|
|
13
|
+
export interface CadMesh {
|
|
14
|
+
name: string;
|
|
15
|
+
/** Vertex positions, three values per vertex. */
|
|
16
|
+
positions: Float32Array;
|
|
17
|
+
/** Vertex normals, three values per vertex, or undefined when the reader gives none. */
|
|
18
|
+
normals: Float32Array | undefined;
|
|
19
|
+
/** Triangle vertex indices, three per triangle. */
|
|
20
|
+
indices: Uint32Array;
|
|
21
|
+
faces: CadFace[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reads a STEP, IGES or BREP file to meshes. The linear unit applies to STEP and IGES only.
|
|
25
|
+
* A file that the reader does not accept rejects with E_INPUT.
|
|
26
|
+
*/
|
|
27
|
+
export declare function readCad(format: CadFormat, bytes: Uint8Array, linearUnit?: LinearUnit): Promise<CadMesh[]>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { RenderError } from "../errors.js";
|
|
2
|
+
/** The name of each reader function, by input format. */
|
|
3
|
+
const READER = {
|
|
4
|
+
step: "ReadStepFile",
|
|
5
|
+
iges: "ReadIgesFile",
|
|
6
|
+
brep: "ReadBrepFile",
|
|
7
|
+
};
|
|
8
|
+
/** The one WASM module of this process. It loads once and is shared by every read. */
|
|
9
|
+
let occtPromise;
|
|
10
|
+
/** Loads the WASM module once. A failed load clears the cache so that a later read tries again. */
|
|
11
|
+
function loadOcct() {
|
|
12
|
+
if (occtPromise === undefined) {
|
|
13
|
+
const started = import("occt-import-js").then((mod) => mod.default({ print: () => { }, printErr: () => { } }));
|
|
14
|
+
occtPromise = started;
|
|
15
|
+
started.catch(() => {
|
|
16
|
+
if (occtPromise === started)
|
|
17
|
+
occtPromise = undefined;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return occtPromise;
|
|
21
|
+
}
|
|
22
|
+
/** Converts one mesh of the reader to flat typed arrays. */
|
|
23
|
+
function toCadMesh(mesh) {
|
|
24
|
+
return {
|
|
25
|
+
name: mesh.name,
|
|
26
|
+
positions: Float32Array.from(mesh.attributes.position.array),
|
|
27
|
+
normals: mesh.attributes.normal === undefined ? undefined : Float32Array.from(mesh.attributes.normal.array),
|
|
28
|
+
indices: Uint32Array.from(mesh.index.array),
|
|
29
|
+
faces: mesh.brep_faces.map((f) => ({
|
|
30
|
+
first: f.first,
|
|
31
|
+
last: f.last,
|
|
32
|
+
color: f.color === null ? null : [f.color[0], f.color[1], f.color[2]],
|
|
33
|
+
})),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reads a STEP, IGES or BREP file to meshes. The linear unit applies to STEP and IGES only.
|
|
38
|
+
* A file that the reader does not accept rejects with E_INPUT.
|
|
39
|
+
*/
|
|
40
|
+
export async function readCad(format, bytes, linearUnit = "millimeter") {
|
|
41
|
+
const occt = await loadOcct();
|
|
42
|
+
const read = occt[READER[format]];
|
|
43
|
+
const params = format === "brep" ? null : { linearUnit };
|
|
44
|
+
let result;
|
|
45
|
+
try {
|
|
46
|
+
result = read(bytes, params);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw new RenderError("E_INPUT", `the ${format} reader failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
50
|
+
}
|
|
51
|
+
if (!result.success) {
|
|
52
|
+
throw new RenderError("E_INPUT", `the ${format} reader did not accept the file`);
|
|
53
|
+
}
|
|
54
|
+
return result.meshes.map(toCadMesh);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../src/mesh/read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAiD3C,yDAAyD;AACzD,MAAM,MAAM,GAAkC;IAC5C,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,cAAc;CACrB,CAAC;AAEF,sFAAsF;AACtF,IAAI,WAAsC,CAAC;AAE3C,mGAAmG;AACnG,SAAS,QAAQ;IACf,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAC3C,CAAC,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;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,MAAiB,EAAE,KAAiB,EAAE,UAAU,GAAe,YAAY;IACvG,MAAM,IAAI,GAAG,MAAM,QAAQ,EAAE,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAuD,CAAC;IACxF,MAAM,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;IACzD,IAAI,MAAkB,CAAC;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,WAAW,CAAC,SAAS,EAAE,OAAO,MAAM,mBAAmB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC7H,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,WAAW,CAAC,SAAS,EAAE,OAAO,MAAM,iCAAiC,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The module script of the viewer page. The page builder replaces three markers before it writes the page:
|
|
3
|
+
* the two import addresses, the glb text and the flag that shows the panel. The script reports its result in
|
|
4
|
+
* window.__sciengDone, so the browser stage waits for the first drawn frame.
|
|
5
|
+
*/
|
|
6
|
+
export declare const VIEWER_SCRIPT = "\nimport * as THREE from \"three\";\nimport { OrbitControls } from \"@@ORBIT@@\";\nimport { GLTFLoader } from \"@@GLTF@@\";\n\nconst GLB_BASE64 = \"@@GLB@@\";\nconst SHOW_CONTROLS = @@CONTROLS@@;\nconst AXIS_KEYS = [\"x\", \"y\", \"z\"];\n\nfunction fail(err) {\n window.__sciengDone = { ok: false, internal: true, message: String((err && err.message) || err) };\n}\n\ntry {\n const renderer = new THREE.WebGLRenderer({ antialias: true });\n renderer.setSize(window.innerWidth, window.innerHeight);\n renderer.setPixelRatio(window.devicePixelRatio || 1);\n renderer.domElement.style.display = \"block\";\n document.body.appendChild(renderer.domElement);\n\n const scene = new THREE.Scene();\n scene.background = new THREE.Color(0xf2f4f7);\n scene.add(new THREE.HemisphereLight(0xffffff, 0x8d939b, 1.2));\n const keyLight = new THREE.DirectionalLight(0xffffff, 2.0);\n keyLight.position.set(1.0, 2.0, 1.5);\n scene.add(keyLight);\n const fillLight = new THREE.DirectionalLight(0xffffff, 0.7);\n fillLight.position.set(-1.5, 0.8, -1.2);\n scene.add(fillLight);\n\n const camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1000);\n camera.position.set(3.0, 2.0, 4.0);\n\n // The controls fire the change event inside update, so render must not call update.\n function render() {\n renderer.render(scene, camera);\n }\n\n const controls = new OrbitControls(camera, renderer.domElement);\n controls.enableDamping = false;\n controls.addEventListener(\"change\", render);\n\n window.addEventListener(\"resize\", function () {\n camera.aspect = window.innerWidth / window.innerHeight;\n camera.updateProjectionMatrix();\n renderer.setSize(window.innerWidth, window.innerHeight);\n render();\n });\n\n // The plane keeps the part of the model with a coordinate below its value.\n const sectionPlanes = [\n new THREE.Plane(new THREE.Vector3(-1, 0, 0), 0),\n new THREE.Plane(new THREE.Vector3(0, -1, 0), 0),\n new THREE.Plane(new THREE.Vector3(0, 0, -1), 0)\n ];\n const sectionEnabled = [false, false, false];\n const sectionFraction = [0.5, 0.5, 0.5];\n let modelBox = null;\n const parts = [];\n\n function setSection(axis, enabled, fraction) {\n if (!modelBox) return;\n const axisIndex = axis | 0;\n if (axisIndex < 0 || axisIndex > 2) return;\n sectionEnabled[axisIndex] = !!enabled;\n if (fraction !== undefined && fraction !== null) {\n const parsed = Number(fraction);\n if (isFinite(parsed)) sectionFraction[axisIndex] = parsed;\n }\n const axisMin = modelBox.min[AXIS_KEYS[axisIndex]];\n const axisMax = modelBox.max[AXIS_KEYS[axisIndex]];\n sectionPlanes[axisIndex].constant = axisMin + sectionFraction[axisIndex] * (axisMax - axisMin);\n const activePlanes = [];\n for (let k = 0; k < 3; k++) {\n if (sectionEnabled[k]) activePlanes.push(sectionPlanes[k]);\n }\n renderer.clippingPlanes = activePlanes;\n }\n\n function setExplode(f) {\n const amount = Number(f);\n if (!isFinite(amount)) return;\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n part.object.position.copy(part.base).addScaledVector(part.dir, amount * 1.5);\n }\n }\n\n function buildControlsPanel() {\n const panel = document.createElement(\"div\");\n panel.id = \"sciengjs-controls\";\n panel.style.cssText =\n \"position:fixed;top:10px;left:10px;padding:10px;background:#fff;color:#222;font:12px system-ui,Arial,sans-serif;\" +\n \"border-radius:6px;box-shadow:0 1px 4px rgba(0,0,0,.25);z-index:1000\";\n\n function range(value) {\n const input = document.createElement(\"input\");\n input.type = \"range\";\n input.min = \"0\";\n input.max = \"1\";\n input.step = \"0.01\";\n input.value = value;\n input.style.width = \"140px\";\n return input;\n }\n\n const explodeRow = document.createElement(\"div\");\n const explodeLabel = document.createElement(\"label\");\n explodeLabel.textContent = \"Exploded \";\n const explodeInput = range(\"0\");\n explodeInput.id = \"sciengjs-explode\";\n explodeInput.addEventListener(\"input\", function () {\n setExplode(parseFloat(explodeInput.value));\n render();\n });\n explodeLabel.appendChild(explodeInput);\n explodeRow.appendChild(explodeLabel);\n panel.appendChild(explodeRow);\n\n const axisNames = [\"X\", \"Y\", \"Z\"];\n for (let i = 0; i < axisNames.length; i++) {\n const row = document.createElement(\"div\");\n const label = document.createElement(\"label\");\n const checkbox = document.createElement(\"input\");\n checkbox.type = \"checkbox\";\n checkbox.id = \"sciengjs-section-\" + axisNames[i].toLowerCase();\n label.appendChild(checkbox);\n label.appendChild(document.createTextNode(\" Section \" + axisNames[i] + \" \"));\n const slider = range(\"0.5\");\n const update = function () {\n setSection(i, checkbox.checked, parseFloat(slider.value));\n render();\n };\n checkbox.addEventListener(\"change\", update);\n slider.addEventListener(\"input\", update);\n row.appendChild(label);\n row.appendChild(slider);\n panel.appendChild(row);\n }\n document.body.appendChild(panel);\n }\n\n window.__sciengViewer = { setExplode, setSection, render, scene, camera, renderer };\n\n const binary = atob(GLB_BASE64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n\n new GLTFLoader().parse(\n bytes.buffer,\n \"\",\n function (gltf) {\n try {\n const model = gltf.scene;\n model.traverse(function (object) {\n if (!object.isMesh) return;\n if (!object.geometry.attributes.normal) object.geometry.computeVertexNormals();\n const materials = Array.isArray(object.material) ? object.material : [object.material];\n for (const material of materials) material.side = THREE.DoubleSide;\n });\n scene.add(model);\n model.updateMatrixWorld(true);\n\n const box = new THREE.Box3().setFromObject(model);\n const centre = box.getCenter(new THREE.Vector3());\n const boxSize = box.getSize(new THREE.Vector3());\n let size = Math.max(boxSize.x, boxSize.y, boxSize.z);\n if (!isFinite(size) || size <= 0) size = 1;\n modelBox = box;\n\n camera.position.set(centre.x + 0.95 * size, centre.y + 0.7 * size, centre.z + 0.95 * size);\n camera.near = size / 1000;\n camera.far = size * 100;\n camera.updateProjectionMatrix();\n controls.target.copy(centre);\n camera.lookAt(centre);\n controls.update();\n\n for (const child of model.children) {\n const dir = new THREE.Vector3(0, 0, 0);\n const childBox = new THREE.Box3().setFromObject(child);\n if (!childBox.isEmpty()) {\n dir.copy(childBox.getCenter(new THREE.Vector3())).sub(centre);\n if (dir.length() < 1e-9) dir.set(0, 0, 0);\n }\n parts.push({ object: child, base: child.position.clone(), dir: dir });\n }\n\n if (SHOW_CONTROLS) buildControlsPanel();\n render();\n window.__sciengDone = { ok: true, svg: \"\" };\n } catch (err) {\n fail(err);\n }\n },\n fail\n );\n} catch (err) {\n fail(err);\n}\n";
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The module script of the viewer page. The page builder replaces three markers before it writes the page:
|
|
3
|
+
* the two import addresses, the glb text and the flag that shows the panel. The script reports its result in
|
|
4
|
+
* window.__sciengDone, so the browser stage waits for the first drawn frame.
|
|
5
|
+
*/
|
|
6
|
+
export const VIEWER_SCRIPT = `
|
|
7
|
+
import * as THREE from "three";
|
|
8
|
+
import { OrbitControls } from "@@ORBIT@@";
|
|
9
|
+
import { GLTFLoader } from "@@GLTF@@";
|
|
10
|
+
|
|
11
|
+
const GLB_BASE64 = "@@GLB@@";
|
|
12
|
+
const SHOW_CONTROLS = @@CONTROLS@@;
|
|
13
|
+
const AXIS_KEYS = ["x", "y", "z"];
|
|
14
|
+
|
|
15
|
+
function fail(err) {
|
|
16
|
+
window.__sciengDone = { ok: false, internal: true, message: String((err && err.message) || err) };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
|
21
|
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
|
22
|
+
renderer.setPixelRatio(window.devicePixelRatio || 1);
|
|
23
|
+
renderer.domElement.style.display = "block";
|
|
24
|
+
document.body.appendChild(renderer.domElement);
|
|
25
|
+
|
|
26
|
+
const scene = new THREE.Scene();
|
|
27
|
+
scene.background = new THREE.Color(0xf2f4f7);
|
|
28
|
+
scene.add(new THREE.HemisphereLight(0xffffff, 0x8d939b, 1.2));
|
|
29
|
+
const keyLight = new THREE.DirectionalLight(0xffffff, 2.0);
|
|
30
|
+
keyLight.position.set(1.0, 2.0, 1.5);
|
|
31
|
+
scene.add(keyLight);
|
|
32
|
+
const fillLight = new THREE.DirectionalLight(0xffffff, 0.7);
|
|
33
|
+
fillLight.position.set(-1.5, 0.8, -1.2);
|
|
34
|
+
scene.add(fillLight);
|
|
35
|
+
|
|
36
|
+
const camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1000);
|
|
37
|
+
camera.position.set(3.0, 2.0, 4.0);
|
|
38
|
+
|
|
39
|
+
// The controls fire the change event inside update, so render must not call update.
|
|
40
|
+
function render() {
|
|
41
|
+
renderer.render(scene, camera);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const controls = new OrbitControls(camera, renderer.domElement);
|
|
45
|
+
controls.enableDamping = false;
|
|
46
|
+
controls.addEventListener("change", render);
|
|
47
|
+
|
|
48
|
+
window.addEventListener("resize", function () {
|
|
49
|
+
camera.aspect = window.innerWidth / window.innerHeight;
|
|
50
|
+
camera.updateProjectionMatrix();
|
|
51
|
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
|
52
|
+
render();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// The plane keeps the part of the model with a coordinate below its value.
|
|
56
|
+
const sectionPlanes = [
|
|
57
|
+
new THREE.Plane(new THREE.Vector3(-1, 0, 0), 0),
|
|
58
|
+
new THREE.Plane(new THREE.Vector3(0, -1, 0), 0),
|
|
59
|
+
new THREE.Plane(new THREE.Vector3(0, 0, -1), 0)
|
|
60
|
+
];
|
|
61
|
+
const sectionEnabled = [false, false, false];
|
|
62
|
+
const sectionFraction = [0.5, 0.5, 0.5];
|
|
63
|
+
let modelBox = null;
|
|
64
|
+
const parts = [];
|
|
65
|
+
|
|
66
|
+
function setSection(axis, enabled, fraction) {
|
|
67
|
+
if (!modelBox) return;
|
|
68
|
+
const axisIndex = axis | 0;
|
|
69
|
+
if (axisIndex < 0 || axisIndex > 2) return;
|
|
70
|
+
sectionEnabled[axisIndex] = !!enabled;
|
|
71
|
+
if (fraction !== undefined && fraction !== null) {
|
|
72
|
+
const parsed = Number(fraction);
|
|
73
|
+
if (isFinite(parsed)) sectionFraction[axisIndex] = parsed;
|
|
74
|
+
}
|
|
75
|
+
const axisMin = modelBox.min[AXIS_KEYS[axisIndex]];
|
|
76
|
+
const axisMax = modelBox.max[AXIS_KEYS[axisIndex]];
|
|
77
|
+
sectionPlanes[axisIndex].constant = axisMin + sectionFraction[axisIndex] * (axisMax - axisMin);
|
|
78
|
+
const activePlanes = [];
|
|
79
|
+
for (let k = 0; k < 3; k++) {
|
|
80
|
+
if (sectionEnabled[k]) activePlanes.push(sectionPlanes[k]);
|
|
81
|
+
}
|
|
82
|
+
renderer.clippingPlanes = activePlanes;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function setExplode(f) {
|
|
86
|
+
const amount = Number(f);
|
|
87
|
+
if (!isFinite(amount)) return;
|
|
88
|
+
for (let i = 0; i < parts.length; i++) {
|
|
89
|
+
const part = parts[i];
|
|
90
|
+
part.object.position.copy(part.base).addScaledVector(part.dir, amount * 1.5);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function buildControlsPanel() {
|
|
95
|
+
const panel = document.createElement("div");
|
|
96
|
+
panel.id = "sciengjs-controls";
|
|
97
|
+
panel.style.cssText =
|
|
98
|
+
"position:fixed;top:10px;left:10px;padding:10px;background:#fff;color:#222;font:12px system-ui,Arial,sans-serif;" +
|
|
99
|
+
"border-radius:6px;box-shadow:0 1px 4px rgba(0,0,0,.25);z-index:1000";
|
|
100
|
+
|
|
101
|
+
function range(value) {
|
|
102
|
+
const input = document.createElement("input");
|
|
103
|
+
input.type = "range";
|
|
104
|
+
input.min = "0";
|
|
105
|
+
input.max = "1";
|
|
106
|
+
input.step = "0.01";
|
|
107
|
+
input.value = value;
|
|
108
|
+
input.style.width = "140px";
|
|
109
|
+
return input;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const explodeRow = document.createElement("div");
|
|
113
|
+
const explodeLabel = document.createElement("label");
|
|
114
|
+
explodeLabel.textContent = "Exploded ";
|
|
115
|
+
const explodeInput = range("0");
|
|
116
|
+
explodeInput.id = "sciengjs-explode";
|
|
117
|
+
explodeInput.addEventListener("input", function () {
|
|
118
|
+
setExplode(parseFloat(explodeInput.value));
|
|
119
|
+
render();
|
|
120
|
+
});
|
|
121
|
+
explodeLabel.appendChild(explodeInput);
|
|
122
|
+
explodeRow.appendChild(explodeLabel);
|
|
123
|
+
panel.appendChild(explodeRow);
|
|
124
|
+
|
|
125
|
+
const axisNames = ["X", "Y", "Z"];
|
|
126
|
+
for (let i = 0; i < axisNames.length; i++) {
|
|
127
|
+
const row = document.createElement("div");
|
|
128
|
+
const label = document.createElement("label");
|
|
129
|
+
const checkbox = document.createElement("input");
|
|
130
|
+
checkbox.type = "checkbox";
|
|
131
|
+
checkbox.id = "sciengjs-section-" + axisNames[i].toLowerCase();
|
|
132
|
+
label.appendChild(checkbox);
|
|
133
|
+
label.appendChild(document.createTextNode(" Section " + axisNames[i] + " "));
|
|
134
|
+
const slider = range("0.5");
|
|
135
|
+
const update = function () {
|
|
136
|
+
setSection(i, checkbox.checked, parseFloat(slider.value));
|
|
137
|
+
render();
|
|
138
|
+
};
|
|
139
|
+
checkbox.addEventListener("change", update);
|
|
140
|
+
slider.addEventListener("input", update);
|
|
141
|
+
row.appendChild(label);
|
|
142
|
+
row.appendChild(slider);
|
|
143
|
+
panel.appendChild(row);
|
|
144
|
+
}
|
|
145
|
+
document.body.appendChild(panel);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
window.__sciengViewer = { setExplode, setSection, render, scene, camera, renderer };
|
|
149
|
+
|
|
150
|
+
const binary = atob(GLB_BASE64);
|
|
151
|
+
const bytes = new Uint8Array(binary.length);
|
|
152
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
153
|
+
|
|
154
|
+
new GLTFLoader().parse(
|
|
155
|
+
bytes.buffer,
|
|
156
|
+
"",
|
|
157
|
+
function (gltf) {
|
|
158
|
+
try {
|
|
159
|
+
const model = gltf.scene;
|
|
160
|
+
model.traverse(function (object) {
|
|
161
|
+
if (!object.isMesh) return;
|
|
162
|
+
if (!object.geometry.attributes.normal) object.geometry.computeVertexNormals();
|
|
163
|
+
const materials = Array.isArray(object.material) ? object.material : [object.material];
|
|
164
|
+
for (const material of materials) material.side = THREE.DoubleSide;
|
|
165
|
+
});
|
|
166
|
+
scene.add(model);
|
|
167
|
+
model.updateMatrixWorld(true);
|
|
168
|
+
|
|
169
|
+
const box = new THREE.Box3().setFromObject(model);
|
|
170
|
+
const centre = box.getCenter(new THREE.Vector3());
|
|
171
|
+
const boxSize = box.getSize(new THREE.Vector3());
|
|
172
|
+
let size = Math.max(boxSize.x, boxSize.y, boxSize.z);
|
|
173
|
+
if (!isFinite(size) || size <= 0) size = 1;
|
|
174
|
+
modelBox = box;
|
|
175
|
+
|
|
176
|
+
camera.position.set(centre.x + 0.95 * size, centre.y + 0.7 * size, centre.z + 0.95 * size);
|
|
177
|
+
camera.near = size / 1000;
|
|
178
|
+
camera.far = size * 100;
|
|
179
|
+
camera.updateProjectionMatrix();
|
|
180
|
+
controls.target.copy(centre);
|
|
181
|
+
camera.lookAt(centre);
|
|
182
|
+
controls.update();
|
|
183
|
+
|
|
184
|
+
for (const child of model.children) {
|
|
185
|
+
const dir = new THREE.Vector3(0, 0, 0);
|
|
186
|
+
const childBox = new THREE.Box3().setFromObject(child);
|
|
187
|
+
if (!childBox.isEmpty()) {
|
|
188
|
+
dir.copy(childBox.getCenter(new THREE.Vector3())).sub(centre);
|
|
189
|
+
if (dir.length() < 1e-9) dir.set(0, 0, 0);
|
|
190
|
+
}
|
|
191
|
+
parts.push({ object: child, base: child.position.clone(), dir: dir });
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (SHOW_CONTROLS) buildControlsPanel();
|
|
195
|
+
render();
|
|
196
|
+
window.__sciengDone = { ok: true, svg: "" };
|
|
197
|
+
} catch (err) {
|
|
198
|
+
fail(err);
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
fail
|
|
202
|
+
);
|
|
203
|
+
} catch (err) {
|
|
204
|
+
fail(err);
|
|
205
|
+
}
|
|
206
|
+
`;
|
|
207
|
+
//# sourceMappingURL=viewer-script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewer-script.js","sourceRoot":"","sources":["../../src/mesh/viewer-script.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwM5B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The options of a viewer page. */
|
|
2
|
+
export interface ViewerOptions {
|
|
3
|
+
/** The page title. */
|
|
4
|
+
title?: string;
|
|
5
|
+
/** True shows the panel with the section and exploded view controls. A png render hides the panel. */
|
|
6
|
+
controls?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A page that views one glTF binary. The page embeds the glb as base64 text and loads the pinned Three.js modules
|
|
10
|
+
* from their exact URLs. An import map maps the name three to the pinned URL and holds the integrity value of every
|
|
11
|
+
* module. A modulepreload link with the same integrity value starts each download. The page draws one frame and then
|
|
12
|
+
* sets window.__sciengDone, so the browser stage knows when to take the screenshot.
|
|
13
|
+
*/
|
|
14
|
+
export declare function viewerPageHtml(glb: Uint8Array, options?: ViewerOptions): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { THREE_MAIN_URL, THREE_MODULES } from "../browser/pinned.js";
|
|
2
|
+
import { VIEWER_SCRIPT } from "./viewer-script.js";
|
|
3
|
+
const PAGE_STYLE = "html,body{margin:0;height:100%;overflow:hidden;background:#f2f4f7}";
|
|
4
|
+
/** Escapes text for an HTML element body. */
|
|
5
|
+
function escapeHtmlText(text) {
|
|
6
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
7
|
+
}
|
|
8
|
+
/** The pinned module with a path inside the three package. */
|
|
9
|
+
function moduleOf(path) {
|
|
10
|
+
const found = THREE_MODULES.find((m) => m.path === path);
|
|
11
|
+
if (found === undefined)
|
|
12
|
+
throw new Error(`the pinned module ${path} is missing`);
|
|
13
|
+
return found;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A page that views one glTF binary. The page embeds the glb as base64 text and loads the pinned Three.js modules
|
|
17
|
+
* from their exact URLs. An import map maps the name three to the pinned URL and holds the integrity value of every
|
|
18
|
+
* module. A modulepreload link with the same integrity value starts each download. The page draws one frame and then
|
|
19
|
+
* sets window.__sciengDone, so the browser stage knows when to take the screenshot.
|
|
20
|
+
*/
|
|
21
|
+
export function viewerPageHtml(glb, options = {}) {
|
|
22
|
+
const orbit = moduleOf("examples/jsm/controls/OrbitControls.js");
|
|
23
|
+
const loader = moduleOf("examples/jsm/loaders/GLTFLoader.js");
|
|
24
|
+
const integrity = {};
|
|
25
|
+
for (const m of THREE_MODULES)
|
|
26
|
+
integrity[m.url] = m.sri;
|
|
27
|
+
const importMap = JSON.stringify({ imports: { three: THREE_MAIN_URL }, integrity }).replace(/</g, "\u003c");
|
|
28
|
+
const preload = THREE_MODULES.map((m) => `<link rel="modulepreload" href="${m.url}" integrity="${m.sri}" crossorigin="anonymous">`).join("");
|
|
29
|
+
const script = VIEWER_SCRIPT.replace("@@ORBIT@@", orbit.url)
|
|
30
|
+
.replace("@@GLTF@@", loader.url)
|
|
31
|
+
.replace("@@GLB@@", Buffer.from(glb).toString("base64"))
|
|
32
|
+
.replace("@@CONTROLS@@", options.controls === false ? "false" : "true");
|
|
33
|
+
return ('<!DOCTYPE html><html><head><meta charset="utf-8">' +
|
|
34
|
+
'<meta name="viewport" content="width=device-width, initial-scale=1">' +
|
|
35
|
+
`<title>${escapeHtmlText(options.title ?? "model")}</title><style>${PAGE_STYLE}</style>` +
|
|
36
|
+
`<script type="importmap">${importMap}</script>${preload}</head><body>` +
|
|
37
|
+
`<script type="module">${script}</script></body></html>`);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=viewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../src/mesh/viewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAUnD,MAAM,UAAU,GAAG,oEAAoE,CAAC;AAExF,6CAA6C;AAC7C,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC;AAED,8DAA8D;AAC9D,SAAS,QAAQ,CAAC,IAAY;IAC5B,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACzD,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,aAAa,CAAC,CAAC;IACjF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAAe,EAAE,OAAO,GAAkB,EAAE;IACzE,MAAM,KAAK,GAAG,QAAQ,CAAC,wCAAwC,CAAC,CAAC;IACjE,MAAM,MAAM,GAAG,QAAQ,CAAC,oCAAoC,CAAC,CAAC;IAC9D,MAAM,SAAS,GAA2B,EAAE,CAAC;IAC7C,KAAK,MAAM,CAAC,IAAI,aAAa;QAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;IACxD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC5G,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAC/B,CAAC,CAAC,EAAE,EAAE,CAAC,mCAAmC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,GAAG,4BAA4B,CACjG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACX,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC;SACzD,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,CAAC;SAC/B,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SACvD,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC1E,OAAO,CACL,mDAAmD;QACnD,sEAAsE;QACtE,UAAU,cAAc,CAAC,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,kBAAkB,UAAU,UAAU;QACxF,4BAA4B,SAAS,YAAY,OAAO,eAAe;QACvE,yBAAyB,MAAM,yBAAyB,CACzD,CAAC;AACJ,CAAC"}
|
package/dist/registry.js
CHANGED
|
@@ -22,6 +22,15 @@ export const DEFAULT_REGISTRY = {
|
|
|
22
22
|
"html:png": { backend: "browser/chromium", moduleUrl: backendUrl("browser/backend-png") },
|
|
23
23
|
"html:pdf": { backend: "browser/chromium", moduleUrl: backendUrl("browser/backend-pdf") },
|
|
24
24
|
"html:md": { backend: "html/md", moduleUrl: backendUrl("html/backend-md") },
|
|
25
|
+
"step:glb": { backend: "mesh/occt+glb", moduleUrl: backendUrl("mesh/backend-glb") },
|
|
26
|
+
"iges:glb": { backend: "mesh/occt+glb", moduleUrl: backendUrl("mesh/backend-glb") },
|
|
27
|
+
"brep:glb": { backend: "mesh/occt+glb", moduleUrl: backendUrl("mesh/backend-glb") },
|
|
28
|
+
"step:html": { backend: "mesh/occt+viewer", moduleUrl: backendUrl("mesh/backend-html") },
|
|
29
|
+
"iges:html": { backend: "mesh/occt+viewer", moduleUrl: backendUrl("mesh/backend-html") },
|
|
30
|
+
"brep:html": { backend: "mesh/occt+viewer", moduleUrl: backendUrl("mesh/backend-html") },
|
|
31
|
+
"step:png": { backend: "mesh/occt+viewer+browser/chromium", moduleUrl: backendUrl("mesh/backend-png") },
|
|
32
|
+
"iges:png": { backend: "mesh/occt+viewer+browser/chromium", moduleUrl: backendUrl("mesh/backend-png") },
|
|
33
|
+
"brep:png": { backend: "mesh/occt+viewer+browser/chromium", moduleUrl: backendUrl("mesh/backend-png") },
|
|
25
34
|
};
|
|
26
35
|
/** Builds the registry key of a pair. */
|
|
27
36
|
export function registryKey(type, format) {
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAazC,iHAAiH;AACjH,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,OAAO,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,SAAS,EAAE,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED,kCAAkC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAa;IACxC,SAAS,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,CAAC,mBAAmB,CAAC,EAAE;IAC/E,SAAS,EAAE,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AAE,EAAE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,CAAC,mBAAmB,CAAC,EAAE;IACxF,UAAU,EAAE,EAAE,OAAO,EAAE,mCAAmC,EAAE,SAAS,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAAE;IACvG,UAAU,EAAE,EAAE,OAAO,EAAE,mCAAmC,EAAE,SAAS,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAAE;IACvG,UAAU,EAAE,EAAE,OAAO,EAAE,mCAAmC,EAAE,SAAS,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAAE;CACxG,CAAC;AAEF,yCAAyC;AACzC,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,MAAc;IACtD,OAAO,GAAG,IAAI,IAAI,MAAM,EAAE,CAAC;AAC7B,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ENGINE_VERSION = "0.
|
|
1
|
+
export declare const ENGINE_VERSION = "0.7.1";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/sciengjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A local rendering engine for science and engineering diagrams, documents and models",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,6 +41,10 @@
|
|
|
41
41
|
"types": "./dist/html/index.d.ts",
|
|
42
42
|
"default": "./dist/html/index.js"
|
|
43
43
|
},
|
|
44
|
+
"./mesh": {
|
|
45
|
+
"types": "./dist/mesh/index.d.ts",
|
|
46
|
+
"default": "./dist/mesh/index.js"
|
|
47
|
+
},
|
|
44
48
|
"./package.json": "./package.json"
|
|
45
49
|
},
|
|
46
50
|
"files": [
|
|
@@ -56,7 +60,7 @@
|
|
|
56
60
|
"test": "bun test",
|
|
57
61
|
"smoke": "node test/smoke/smoke.mjs",
|
|
58
62
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
59
|
-
"test:node": "node --test test/node/worker.node.mjs test/node/eval-render.node.mjs test/node/worker-execargv.node.mjs test/node/math.node.mjs"
|
|
63
|
+
"test:node": "node --test test/node/worker.node.mjs test/node/eval-render.node.mjs test/node/worker-execargv.node.mjs test/node/math.node.mjs test/node/mesh.node.mjs"
|
|
60
64
|
},
|
|
61
65
|
"keywords": [
|
|
62
66
|
"graphviz",
|
|
@@ -84,12 +88,14 @@
|
|
|
84
88
|
"@types/node": "^22",
|
|
85
89
|
"mermaid": "11.17.2",
|
|
86
90
|
"plotly.js-dist-min": "4.2.0",
|
|
91
|
+
"three": "0.187.0",
|
|
87
92
|
"typescript": "^7.0.2"
|
|
88
93
|
},
|
|
89
94
|
"dependencies": {
|
|
90
95
|
"@mathjax/src": "4.1.3",
|
|
91
96
|
"@resvg/resvg-wasm": "2.6.2",
|
|
92
97
|
"@viz-js/viz": "3.31.0",
|
|
98
|
+
"occt-import-js": "0.0.23",
|
|
93
99
|
"parse5": "8.1.0"
|
|
94
100
|
}
|
|
95
101
|
}
|