topotopo 0.2.0 → 0.4.0
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/NOTICE +30 -0
- package/README.md +54 -16
- package/dist/cli.js +95 -14
- package/dist/core/analysis.d.ts +5 -1
- package/dist/core/analysis.js +8 -3
- package/dist/core/bake.d.ts +2 -5
- package/dist/core/bake.js +12 -25
- package/dist/core/bevel.js +165 -97
- package/dist/core/geometry.js +1 -1
- package/dist/core/imageops.d.ts +6 -0
- package/dist/core/imageops.js +51 -0
- package/dist/core/materials.d.ts +4 -0
- package/dist/core/materials.js +11 -0
- package/dist/core/packed.js +11 -0
- package/dist/core/particles.d.ts +1 -1
- package/dist/core/particles.js +1 -1
- package/dist/core/rbd.js +13 -1
- package/dist/core/scatter.d.ts +1 -1
- package/dist/core/scatter.js +1 -1
- package/dist/core/scene.d.ts +20 -0
- package/dist/core/scene.js +71 -0
- package/dist/core/snippet-lib.d.ts +1 -1
- package/dist/core/snippet-lib.js +1 -1
- package/dist/core/solidify.d.ts +38 -0
- package/dist/core/solidify.js +356 -0
- package/dist/core/tangents.d.ts +52 -0
- package/dist/core/tangents.js +214 -0
- package/dist/core/texcoord.d.ts +4 -0
- package/dist/core/texcoord.js +14 -0
- package/dist/core/topology.d.ts +22 -0
- package/dist/core/topology.js +70 -7
- package/dist/core/traceimage.d.ts +7 -0
- package/dist/core/traceimage.js +221 -0
- package/dist/core/tritri.d.ts +5 -0
- package/dist/core/tritri.js +120 -0
- package/dist/core/uv.d.ts +13 -0
- package/dist/core/uv.js +3 -3
- package/dist/core/uvreport.d.ts +66 -0
- package/dist/core/uvreport.js +308 -0
- package/dist/core/xatlas.js +32 -2
- package/dist/gallery/app/gallery.css +100 -0
- package/dist/gallery/app/gallery.js +80 -0
- package/dist/gallery/bake.d.ts +34 -0
- package/dist/gallery/bake.js +144 -0
- package/dist/gallery/cli.d.ts +4 -0
- package/dist/gallery/cli.js +157 -0
- package/dist/gallery/library.d.ts +124 -0
- package/dist/gallery/library.js +366 -0
- package/dist/gallery/pages.d.ts +94 -0
- package/dist/gallery/pages.js +148 -0
- package/dist/gallery/server.d.ts +21 -0
- package/dist/gallery/server.js +391 -0
- package/dist/graph/engine.js +14 -0
- package/dist/graph/types.d.ts +17 -0
- package/dist/host/artifacts.d.ts +21 -0
- package/dist/host/artifacts.js +58 -0
- package/dist/host/export-targets.d.ts +33 -0
- package/dist/host/export-targets.js +84 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/inspect.d.ts +6 -1
- package/dist/inspect.js +13 -1
- package/dist/io/common.d.ts +8 -0
- package/dist/io/gltf.js +236 -19
- package/dist/io/targets.d.ts +31 -0
- package/dist/io/targets.js +75 -0
- package/dist/mcp/docs.d.ts +1 -1
- package/dist/mcp/docs.js +73 -6
- package/dist/mcp/library.d.ts +12 -0
- package/dist/mcp/library.js +159 -0
- package/dist/mcp/server.js +29 -12
- package/dist/mcp/tools.d.ts +1 -1
- package/dist/mcp/tools.js +102 -43
- package/dist/nodes/bake.js +56 -36
- package/dist/nodes/bevel.js +4 -3
- package/dist/nodes/code.js +33 -7
- package/dist/nodes/curves.js +7 -0
- package/dist/nodes/generate.js +1 -1
- package/dist/nodes/imageops.d.ts +1 -0
- package/dist/nodes/imageops.js +206 -0
- package/dist/nodes/index.d.ts +3 -0
- package/dist/nodes/index.js +3 -0
- package/dist/nodes/material.js +3 -0
- package/dist/nodes/measure.js +3 -2
- package/dist/nodes/rbd.js +1 -1
- package/dist/nodes/scene.d.ts +1 -0
- package/dist/nodes/scene.js +53 -0
- package/dist/nodes/solidify.d.ts +1 -0
- package/dist/nodes/solidify.js +52 -0
- package/dist/nodes/transform.js +5 -1
- package/dist/nodes/util.d.ts +1 -1
- package/dist/nodes/wasmcall.js +1 -1
- package/dist/render/options.js +1 -1
- package/dist/render/pbr.d.ts +28 -0
- package/dist/render/pbr.js +378 -0
- package/dist/render/preview.d.ts +58 -0
- package/dist/render/preview.js +24 -0
- package/dist/render/raster.d.ts +12 -2
- package/dist/render/raster.js +98 -11
- package/dist/render/texview.d.ts +1 -1
- package/dist/render/texview.js +7 -2
- package/dist/viewer/app/camera.js +27 -7
- package/dist/viewer/app/embed.js +80 -0
- package/dist/viewer/app/export-popover.js +68 -0
- package/dist/viewer/app/grid.js +1 -1
- package/dist/viewer/app/guides.js +1 -1
- package/dist/viewer/app/image-view.js +114 -0
- package/dist/viewer/app/keymap.js +15 -3
- package/dist/viewer/app/layers.js +24 -5
- package/dist/viewer/app/main.js +71 -15
- package/dist/viewer/app/markers.js +1 -1
- package/dist/viewer/app/outliner.js +56 -15
- package/dist/viewer/app/outputs.css +73 -0
- package/dist/viewer/app/outputs.js +240 -0
- package/dist/viewer/app/props.js +1 -1
- package/dist/viewer/app/scene.js +6 -2
- package/dist/viewer/app/select.js +14 -3
- package/dist/viewer/app/selection.js +1 -1
- package/dist/viewer/app/status.js +20 -0
- package/dist/viewer/app/style.css +2 -1
- package/dist/viewer/app/units.js +1 -1
- package/dist/viewer/app/vars.js +1 -1
- package/dist/viewer/index.html +20 -6
- package/dist/viewer/outputs.d.ts +54 -0
- package/dist/viewer/outputs.js +436 -0
- package/dist/viewer/server.d.ts +19 -2
- package/dist/viewer/server.js +77 -9
- package/dist/workspace.d.ts +21 -2
- package/dist/workspace.js +124 -4
- package/kernels/pkg/README.md +21 -28
- package/kernels/pkg-simd/README.md +21 -28
- package/package.json +11 -4
package/dist/mcp/tools.js
CHANGED
|
@@ -8,11 +8,13 @@ import { didYouMean } from '../graph/params.js';
|
|
|
8
8
|
import { migrateGraph } from '../graph/migrate.js';
|
|
9
9
|
import { catalogText, nodeDoc, TOPICS, topicList, INSTRUCTIONS } from './docs.js';
|
|
10
10
|
import { summarize, inspect } from '../inspect.js';
|
|
11
|
-
import {
|
|
11
|
+
import { renderGeometryAsync } from '../render/raster.js';
|
|
12
12
|
import { renderArgs } from '../render/options.js';
|
|
13
13
|
import { encodePNG } from '../render/png.js';
|
|
14
14
|
import { EXPORT_FORMATS, exportFormatFromPath } from '../io/export.js';
|
|
15
|
-
import {
|
|
15
|
+
import { publishedOutputs } from '../io/targets.js';
|
|
16
|
+
import { ArtifactStore } from '../host/artifacts.js';
|
|
17
|
+
import { prepareTarget, serializeExport, writeExportFiles, writeTargets } from '../host/export-targets.js';
|
|
16
18
|
import { evalGroup } from '../core/groups.js';
|
|
17
19
|
import { Geometry } from '../core/geometry.js';
|
|
18
20
|
import { verifyTools } from './verify.js';
|
|
@@ -55,8 +57,9 @@ function reportText(name, r, extraNotes = []) {
|
|
|
55
57
|
const FRAME_PROP = {
|
|
56
58
|
frame: { type: 'number', description: 'frame to cook at (default 1; frame 1 = time 0, 24 fps). Only time-dependent nodes (solver, @Frame wrangles, "=frame" params) change between frames.' },
|
|
57
59
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
/** Render to a PNG content block; shading "pbr" reads texture files through the host. */
|
|
61
|
+
async function pngContent(g, o, host) {
|
|
62
|
+
const r = await renderGeometryAsync(g, o, (t) => host.readFile(t));
|
|
60
63
|
const png = encodePNG(r.rgba, r.width, r.height, (d) => zlib.deflateSync(d, { level: 6 }));
|
|
61
64
|
return { img: { type: 'image', data: Buffer.from(png).toString('base64'), mimeType: 'image/png' }, notes: r.notes, png };
|
|
62
65
|
}
|
|
@@ -65,30 +68,19 @@ function pngContent(g, o) {
|
|
|
65
68
|
* Landscape bundle, or the single file of other formats). Textures are read through the host; USD texture paths are
|
|
66
69
|
* written relative to the output file. Returns the report text.
|
|
67
70
|
*/
|
|
68
|
-
export async function writeExport(geo, format, p, a, host) {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
texturePath: (t) => {
|
|
79
|
-
const abs = host.resolvePath(t);
|
|
80
|
-
return /^[a-z][a-z0-9+.-]*:\/\//i.test(abs) ? abs : path.relative(outDir, abs).split(path.sep).join('/');
|
|
81
|
-
},
|
|
82
|
-
warn: (m) => warnings.push(m),
|
|
83
|
-
});
|
|
84
|
-
for (const f of res.files) {
|
|
85
|
-
fs.mkdirSync(path.dirname(f.path), { recursive: true });
|
|
86
|
-
fs.writeFileSync(f.path, f.bytes);
|
|
87
|
-
}
|
|
88
|
-
const total = res.files.reduce((s, f) => s + f.bytes.byteLength, 0);
|
|
71
|
+
export async function writeExport(geo, format, p, a, host, record) {
|
|
72
|
+
const res = await serializeExport(geo, format, p, a, host);
|
|
73
|
+
writeExportFiles(res.files);
|
|
74
|
+
if (res.files.length)
|
|
75
|
+
record?.(res.files.map((f) => f.path));
|
|
76
|
+
return exportReport(res.files, res.outDir, format, res.summary, res.warnings);
|
|
77
|
+
}
|
|
78
|
+
/** "wrote <file or N files in dir> (format, KB): summary", then any warnings. */
|
|
79
|
+
function exportReport(files, outDir, format, summary, warnings) {
|
|
80
|
+
const total = files.reduce((s, f) => s + f.bytes.byteLength, 0);
|
|
89
81
|
const rel = (f) => path.relative(outDir, f).split(path.sep).join('/');
|
|
90
|
-
const list =
|
|
91
|
-
return `wrote ${list} (${format}, ${(total / 1024).toFixed(1)} KB): ${
|
|
82
|
+
const list = files.length === 1 ? files[0].path : `${files.length} files in ${outDir}: ${files.slice(0, 12).map((f) => rel(f.path)).join(', ')}${files.length > 12 ? ', …' : ''}`;
|
|
83
|
+
return `wrote ${list} (${format}, ${(total / 1024).toFixed(1)} KB): ${summary}${warnings.length ? '\nwarnings:\n ' + warnings.join('\n ') : ''}`;
|
|
92
84
|
}
|
|
93
85
|
function renderOpts(a, g, label) {
|
|
94
86
|
const ro = renderArgs(a); // views (presets, persp@az, section), overlays, shading, labels … (src/render/options.ts)
|
|
@@ -137,7 +129,8 @@ const RENDER_PROPS = {
|
|
|
137
129
|
label_pieces: { type: 'boolean', description: 'number connected pieces (#0, #1, … in connectivity order)' },
|
|
138
130
|
label_attrib: { type: 'string', description: 'label each distinct value of a string/int attribute (e.g. "name") on its elements; colours match color_by' },
|
|
139
131
|
legend: { type: 'boolean', description: 'legend for color_by (gradient bar with min/max, or categorical swatches) and highlight' },
|
|
140
|
-
shading: { type: 'string', enum: ['default', 'flat', 'matcap', 'ao'], description: 'flat: facets (ignores N); matcap: clay that reads form; ao: screen-space ambient occlusion darkens creases and cavities' },
|
|
132
|
+
shading: { type: 'string', enum: ['default', 'flat', 'matcap', 'ao', 'pbr'], description: 'flat: facets (ignores N); matcap: clay that reads form; ao: screen-space ambient occlusion darkens creases and cavities; pbr: the exported metallic-roughness material (base colour, normal, orm/roughness maps, emissive, unlit) under a fixed studio light rig, deterministic' },
|
|
133
|
+
exposure: { type: 'number', description: 'shading "pbr": exposure in stops (default 0)' },
|
|
141
134
|
ao_radius: { type: 'number', description: 'shading "ao": sample radius in pixels (default 10)' },
|
|
142
135
|
look_at: { type: 'array', items: { type: 'number' }, description: 'look-at point [x,y,z] (same as target)' },
|
|
143
136
|
ortho_scale: { type: 'number', description: 'ortho/section views: world width across a view (default: fit the bbox)' },
|
|
@@ -148,13 +141,20 @@ const RENDER_PROPS = {
|
|
|
148
141
|
texture: { type: 'string', description: 'adds the "texture" view and picks what it shows: an image name, "image/layer", or a material name (its maps as a labelled strip); "" = every image. A geometry holding only images renders as the texture view by default' },
|
|
149
142
|
};
|
|
150
143
|
export function makeTools(ws, opts = {}) {
|
|
144
|
+
// One file per graph node, overwritten by each render: agents render after most edits, so a new file per render
|
|
145
|
+
// would pile up in exports/renders (save_to keeps a copy elsewhere).
|
|
146
|
+
const renderDestination = (name, node) => path.join(ws.exportDir, 'renders', `${name}-${node}`.replace(/[^A-Za-z0-9_.-]/g, '_') + '.png');
|
|
151
147
|
const engine = ws.engine;
|
|
152
148
|
/** The text (+ optional render) of a cook report. */
|
|
153
|
-
const reportResult = (name, r, a, extraNotes = []) => {
|
|
149
|
+
const reportResult = async (name, r, a, extraNotes = []) => {
|
|
154
150
|
const content = [{ type: 'text', text: reportText(name, r, extraNotes) }];
|
|
155
151
|
if (r.geo && a.render) {
|
|
156
152
|
const ro = renderOpts(typeof a.render === 'object' ? a.render : {}, r.geo, `${name}/${r.target}${atFrame(r)}`);
|
|
157
|
-
const { img, notes } = pngContent(r.geo, ro);
|
|
153
|
+
const { img, notes, png } = await pngContent(r.geo, ro, engine.host);
|
|
154
|
+
const renderPath = renderDestination(name, r.target);
|
|
155
|
+
fs.mkdirSync(path.dirname(renderPath), { recursive: true });
|
|
156
|
+
fs.writeFileSync(renderPath, png);
|
|
157
|
+
new ArtifactStore(ws.exportDir).record([renderPath], { graph: name, node: r.target, format: 'png' });
|
|
158
158
|
content.push(img);
|
|
159
159
|
if (notes.length)
|
|
160
160
|
content.push({ type: 'text', text: 'render: ' + notes.join('; ') });
|
|
@@ -175,6 +175,35 @@ export function makeTools(ws, opts = {}) {
|
|
|
175
175
|
throw new Error(reportText(name, r));
|
|
176
176
|
return { r, name, geo: r.geo };
|
|
177
177
|
};
|
|
178
|
+
/** export without a path: the graph's targets (the default output's, a named one's, or all), inside exports/ */
|
|
179
|
+
const exportTargets = async (a) => {
|
|
180
|
+
const name = a.graph ?? a.name ?? 'main', spec = ws.getGraph(name);
|
|
181
|
+
const published = publishedOutputs(name, spec, engine.findOutput(spec).name);
|
|
182
|
+
const hint = (o) => `edit {ops:[{op:"export"${o === undefined ? '' : `, output:"${o}"`}, export:"glb"}]}`;
|
|
183
|
+
let chosen = published;
|
|
184
|
+
if (!a.all) {
|
|
185
|
+
const p = a.output === undefined ? published[0] : published.find((x) => x.output === a.output);
|
|
186
|
+
if (!p)
|
|
187
|
+
return text(`graph "${name}" publishes no output "${a.output}" (outputs: ${published.slice(1).map((x) => x.output).join(', ') || 'none'})`, true);
|
|
188
|
+
if (!p.target)
|
|
189
|
+
return text(`${a.output === undefined ? 'the default output' : `output "${a.output}"`} of "${name}" has no export target: set one with ${hint(a.output)}, or pass path`, true);
|
|
190
|
+
chosen = [p];
|
|
191
|
+
}
|
|
192
|
+
const targets = chosen.filter((p) => p.target);
|
|
193
|
+
if (!targets.length)
|
|
194
|
+
return text(`no output of "${name}" has an export target: set one with ${hint(undefined)}, or pass path`, true);
|
|
195
|
+
const prepared = [];
|
|
196
|
+
for (const p of targets) {
|
|
197
|
+
const r = await ws.cook(name, p.node, a.frame);
|
|
198
|
+
if (!r.ok || !r.geo)
|
|
199
|
+
return text(reportText(name, r), true);
|
|
200
|
+
prepared.push(await prepareTarget(r.geo, name, p, ws.exportDir, engine.host));
|
|
201
|
+
}
|
|
202
|
+
writeTargets(prepared, ws.exportDir);
|
|
203
|
+
const skipped = chosen.filter((p) => !p.target).map((p) => p.label);
|
|
204
|
+
return text(prepared.map((p) => exportReport(p.files, ws.exportDir, p.target.format, `${p.label}: ${p.summary}`, p.warnings)).join('\n')
|
|
205
|
+
+ (skipped.length ? `\nno export target (skipped): ${skipped.join(', ')}` : ''));
|
|
206
|
+
};
|
|
178
207
|
const tools = [
|
|
179
208
|
{
|
|
180
209
|
name: 'catalog',
|
|
@@ -228,7 +257,7 @@ export function makeTools(ws, opts = {}) {
|
|
|
228
257
|
type: 'object',
|
|
229
258
|
required: ['graph'],
|
|
230
259
|
properties: {
|
|
231
|
-
graph: { type: 'object', description: '{"nodes": {name: {"type", "in", "params"}}, "output": name, "vars": {...}, "params": {var: {"type", "desc", "min", "max", "options", "label", "step"}}}' },
|
|
260
|
+
graph: { type: 'object', description: '{"nodes": {name: {"type", "in", "params"}}, "output": name, "outputs": {id: {"node": name, "label": "Published result", "export": "glb"}}, "export": "glb", "vars": {...}, "params": {var: {"type", "desc", "min", "max", "options", "label", "step"}}}. Publish intended deliverables in outputs; output remains the default. "export" (on the graph for the default output, or on a named output) is where it exports: a format, or {format, path?, ...export options}, written inside exports/ by the viewer\'s Export buttons and export {output} / {all:true}.' },
|
|
232
261
|
name: { type: 'string', description: 'graph name (default "main")' },
|
|
233
262
|
mode: { type: 'string', enum: ['replace', 'merge'] },
|
|
234
263
|
dry_run: { type: 'boolean' },
|
|
@@ -259,7 +288,7 @@ export function makeTools(ws, opts = {}) {
|
|
|
259
288
|
},
|
|
260
289
|
{
|
|
261
290
|
name: 'edit',
|
|
262
|
-
description: 'Incrementally edit a graph, then re-cook (only affected nodes recompute). ops: {op:"set",node,params} (null removes a param) · {op:"add",node,type,in,params} · {op:"insert",node,type,params,after} (splice after a node) · {op:"remove",node} (rewires consumers) · {op:"connect",node,in:[...]} or {op:"connect",node,input:1,from:"x"} · {op:"rename",node,to} · {op:"replace",node,type?,params?,in?} · {op:"output",node} · {op:"vars",vars:{k:v}} · {op:"bypass",node,value}.',
|
|
291
|
+
description: 'Incrementally edit a graph, then re-cook (only affected nodes recompute). ops: {op:"set",node,params} (null removes a param) · {op:"add",node,type,in,params} · {op:"insert",node,type,params,after} (splice after a node) · {op:"remove",node} (rewires consumers) · {op:"connect",node,in:[...]} or {op:"connect",node,input:1,from:"x"} · {op:"rename",node,to} · {op:"replace",node,type?,params?,in?} · {op:"output",node} · {op:"vars",vars:{k:v}} · {op:"bypass",node,value} · {op:"export",output?,export} (the export target of a named output, or of the default output without "output": a format "glb" or {format, path?, ...export options}; null removes it).',
|
|
263
292
|
inputSchema: {
|
|
264
293
|
type: 'object',
|
|
265
294
|
required: ['ops'],
|
|
@@ -286,13 +315,16 @@ export function makeTools(ws, opts = {}) {
|
|
|
286
315
|
},
|
|
287
316
|
{
|
|
288
317
|
name: 'inspect',
|
|
289
|
-
description: 'Inspect any node\'s output as text: summary; detail "attributes" (min/max/mean, unique strings), "topology" (watertight/manifold, pieces, volume, area, genus), "elements" (list values for a range), or "
|
|
318
|
+
description: 'Inspect any node\'s output as text: summary; detail "attributes" (min/max/mean, unique strings), "topology" (watertight/manifold, pieces, volume, area, genus, render/export triangle health), "elements" (list values for a range), "all", or "uv" (exact uv overlaps with triangle pairs and areas, collapsed / non-finite / out-of-tile triangles, charts, utilization, per-piece texel density with resolution; json:true appends the machine-readable report).',
|
|
290
319
|
inputSchema: {
|
|
291
320
|
type: 'object',
|
|
292
321
|
properties: {
|
|
293
322
|
graph: { type: 'string', description: 'graph name (default "main")' },
|
|
294
323
|
node: { type: 'string', description: 'node to inspect (default: graph output)' },
|
|
295
|
-
detail: { type: 'string', enum: ['summary', 'attributes', 'topology', 'elements', 'all'] },
|
|
324
|
+
detail: { type: 'string', enum: ['summary', 'attributes', 'topology', 'elements', 'all', 'uv'] },
|
|
325
|
+
uv_attrib: { type: 'string', description: 'detail "uv": the uv attribute (default "uv")' },
|
|
326
|
+
resolution: { description: 'detail "uv": texture size in texels for texel density, n or [width, height]', anyOf: [{ type: 'number' }, { type: 'array', items: { type: 'number' } }] },
|
|
327
|
+
json: { type: 'boolean', description: 'detail "uv": append the report as JSON' },
|
|
296
328
|
class: { type: 'string', enum: ['point', 'prim', 'vertex', 'detail', 'edge'], description: 'element class; "edge" lists unique edges (point pair, length, polygon count, dihedral angle, edge groups)' },
|
|
297
329
|
attribs: { type: 'array', items: { type: 'string' } },
|
|
298
330
|
start: { type: 'number' }, count: { type: 'number' },
|
|
@@ -305,7 +337,7 @@ export function makeTools(ws, opts = {}) {
|
|
|
305
337
|
const node = r.target;
|
|
306
338
|
const res = r.results.get(node);
|
|
307
339
|
const head = `${name}/${node}${atFrame(r)}${res ? ` (${res.cached ? 'cached' : res.ms.toFixed(0) + ' ms'})` : ''}`;
|
|
308
|
-
return text(head + '\n' + inspect(geo, { detail: a.detail, cls: a.class, attribs: a.attribs, start: a.start, count: a.count, group: a.group }));
|
|
340
|
+
return text(head + '\n' + inspect(geo, { detail: a.detail, cls: a.class, attribs: a.attribs, start: a.start, count: a.count, group: a.group, uvAttrib: a.uv_attrib, uvResolution: a.resolution, json: a.json }));
|
|
309
341
|
},
|
|
310
342
|
},
|
|
311
343
|
{
|
|
@@ -322,13 +354,14 @@ export function makeTools(ws, opts = {}) {
|
|
|
322
354
|
},
|
|
323
355
|
run: async (a) => {
|
|
324
356
|
const { geo, name, r } = await resolveNodeGeo(a);
|
|
325
|
-
const { img, notes, png } = pngContent(geo, renderOpts(a, geo, `${name}/${r.target}${atFrame(r)}`));
|
|
357
|
+
const { img, notes, png } = await pngContent(geo, renderOpts(a, geo, `${name}/${r.target}${atFrame(r)}`), engine.host);
|
|
326
358
|
const content = [img];
|
|
327
359
|
const info = [];
|
|
328
|
-
|
|
329
|
-
const p = path.resolve(ws.dir, a.save_to);
|
|
360
|
+
{
|
|
361
|
+
const p = a.save_to ? path.resolve(ws.dir, a.save_to) : renderDestination(name, r.target);
|
|
330
362
|
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
331
363
|
fs.writeFileSync(p, png);
|
|
364
|
+
new ArtifactStore(ws.exportDir).record([p], { graph: name, node: r.target, format: 'png' });
|
|
332
365
|
info.push(`saved ${p}`);
|
|
333
366
|
}
|
|
334
367
|
if (notes.length)
|
|
@@ -343,10 +376,11 @@ export function makeTools(ws, opts = {}) {
|
|
|
343
376
|
description: 'Write a node\'s output to a file: .glb/.gltf (glTF via gltf-transform: materials + texture maps, vertex colours, uv, custom attributes, EXT_mesh_gpu_instancing with per-instance attributes, meshopt compression; best for Unreal/Blender/web), .obj, .usda (PointInstancer with per-instance primvars, UsdPreviewSurface materials), .ply, .stl, .geo (Houdini JSON geometry, every attribute and group, packed prims as PackedGeometry), .csv (point stream; pcg:true for Unreal PCG columns; packed instances = one row per instance + Mesh column + .meshes.json sidecar + one GLB per source), .points.json, .json (lossless topotopo). Relative paths go into the workspace. help {topic:"export"} for details. Heightfields: png16 (.png, 16-bit Unreal Landscape heightmap) or r16 (.r16/.raw) plus a .json sidecar with the height range and the Unreal scale/location, mask_png (8-bit weight layers; param layers), unreal_landscape (a directory: heightmap, every layer, manifest with the exact Landscape import settings, objects.glb and the instance stream). Textures: glb/gltf embed the image textures of materials (texture_to_material) as PNG, usda writes them to <name>_textures/ next to the file, format textures writes every image as <path>/<image>.png (layers: extra layers, or ["*"]).',
|
|
344
377
|
inputSchema: {
|
|
345
378
|
type: 'object',
|
|
346
|
-
required: ['path'],
|
|
347
379
|
properties: {
|
|
348
380
|
graph: { type: 'string', description: 'graph name (default "main")' }, node: { type: 'string', description: 'node to look at (default: the graph output)' },
|
|
349
|
-
path: { type: 'string', description: 'e.g. "exports/rock.glb", "exports/trees.csv", "exports/pts.points.json", "exports/terrain.png" (heightmap), "exports/level" (unreal_landscape: a directory), "exports/maps" (textures: a directory)' },
|
|
381
|
+
path: { type: 'string', description: 'e.g. "exports/rock.glb", "exports/trees.csv", "exports/pts.points.json", "exports/terrain.png" (heightmap), "exports/level" (unreal_landscape: a directory), "exports/maps" (textures: a directory). Without path: the graph\'s export targets (output / all), written inside exports/' },
|
|
382
|
+
output: { type: 'string', description: 'without path: export this named output (graph.outputs) to its target; omitted = the default output (graph.export)' },
|
|
383
|
+
all: { type: 'boolean', description: 'without path: export every output of the graph that has an export target' },
|
|
350
384
|
format: { type: 'string', enum: EXPORT_FORMATS, description: 'default: from the extension (.points.json = pointsjson)' },
|
|
351
385
|
layer: { type: 'string', description: 'heightmaps: layer to write (png16/r16 default "height", mask_png default "mask")' },
|
|
352
386
|
layers: { type: 'array', items: { type: 'string' }, description: 'mask_png: layers to write, one PNG each (name_<layer>.png); textures: extra image layers to write as <image>_<layer>.png ("*" = all)' },
|
|
@@ -361,6 +395,7 @@ export function makeTools(ws, opts = {}) {
|
|
|
361
395
|
materials: { type: 'boolean', description: 'glTF: write materials from the prim "material" attribute + table (default true)' },
|
|
362
396
|
compress: { type: 'string', enum: ['none', 'meshopt', 'draco'], description: 'glTF: meshopt = EXT_meshopt_compression + quantization; draco needs the optional draco3dgltf package' },
|
|
363
397
|
quantize: { type: 'boolean', description: 'glTF: KHR_mesh_quantization (smaller, lossy) without compression' },
|
|
398
|
+
tangents: { type: 'string', enum: ['auto', 'preserve', 'none'], description: 'glTF TANGENT: auto (default) = MikkTSpace for normal-mapped materials, a valid supplied "tangent" attribute elsewhere; preserve = the supplied attribute wherever it exists (malformed = error); none = never' },
|
|
364
399
|
attributes: { type: 'array', items: { type: 'string' }, description: 'csv / points.json: point attributes to write (default all)' },
|
|
365
400
|
pcg: { type: 'boolean', description: 'csv: Unreal PCG columns (Position/Rotation/Scale/Density/Color/Seed) in Unreal space (Z-up, left-handed, cm)' },
|
|
366
401
|
pcg_struct: { type: 'boolean', description: 'csv with pcg: Unreal struct-text cells ("(X=…,Y=…,Z=…)") for DataTable import with a row struct' },
|
|
@@ -372,13 +407,15 @@ export function makeTools(ws, opts = {}) {
|
|
|
372
407
|
},
|
|
373
408
|
},
|
|
374
409
|
run: async (a) => {
|
|
410
|
+
if (a.path === undefined)
|
|
411
|
+
return exportTargets(a);
|
|
375
412
|
const { geo, name, r } = await resolveNodeGeo(a);
|
|
376
413
|
const p = path.resolve(ws.dir, a.path);
|
|
377
414
|
const fmt0 = String(a.format ?? exportFormatFromPath(p)).toLowerCase();
|
|
378
415
|
const ext = ({ png: 'png16', raw: 'r16' }[fmt0] ?? fmt0);
|
|
379
416
|
if (!EXPORT_FORMATS.includes(ext))
|
|
380
417
|
throw new Error(`unknown format "${ext}"; use ${EXPORT_FORMATS.map((f) => (f === 'pointsjson' ? '.points.json' : '.' + f)).join(' ')}`);
|
|
381
|
-
const report = await writeExport(geo, ext, p, a, engine.host);
|
|
418
|
+
const report = await writeExport(geo, ext, p, a, engine.host, (files) => new ArtifactStore(ws.exportDir).record(files, { graph: name, node: r.target, format: ext }));
|
|
382
419
|
return text(`${report}\n(from ${name}/${r.target}${atFrame(r)}: ${geo.numPoints} points, ${geo.numPrims} prims)`);
|
|
383
420
|
},
|
|
384
421
|
},
|
|
@@ -501,10 +538,32 @@ export function makeTools(ws, opts = {}) {
|
|
|
501
538
|
if (opts.onPreview) {
|
|
502
539
|
tools.push({
|
|
503
540
|
name: 'preview',
|
|
504
|
-
description: 'Start (or get the URL of) the live
|
|
541
|
+
description: 'Start (or get the URL of) the live viewer for humans: an editor viewport of the workspace (graph menu, an outliner with the graph\'s nodes, single and quad views, the graph\'s params as Controls, input layers and guides) that updates after every build/edit. Returns the URL to open in a browser.',
|
|
505
542
|
inputSchema: { type: 'object', properties: {} },
|
|
506
|
-
run: async () => text(`live preview: ${await opts.onPreview()} (updates automatically on every build/edit; click
|
|
543
|
+
run: async () => text(`live preview: ${await opts.onPreview()} (updates automatically on every build/edit; click a node in the outliner to see its result)`),
|
|
507
544
|
});
|
|
508
545
|
}
|
|
546
|
+
// A person can add files to inputs/ at any time (the viewer's Add input, a drop, the folder). The first answer says
|
|
547
|
+
// what is there, later answers what is new or changed since the last one; the inputs tool's own answer counts.
|
|
548
|
+
let heard = null;
|
|
549
|
+
const inputsNote = (tool) => {
|
|
550
|
+
const files = ws.listInputs(), now = new Map(files.map((f) => [f.path, `${f.size}:${f.mtime}`]));
|
|
551
|
+
const first = heard === null, fresh = files.filter((f) => heard?.get(f.path) !== now.get(f.path));
|
|
552
|
+
heard = now;
|
|
553
|
+
if (tool === 'inputs' || !fresh.length)
|
|
554
|
+
return '';
|
|
555
|
+
const shown = fresh.slice(0, 8).map((f) => `inputs/${f.path} (${f.kind}, ${(f.size / 1024).toFixed(0)} KB)`).join(', ') + (fresh.length > 8 ? `, and ${fresh.length - 8} more` : '');
|
|
556
|
+
return `${first ? `inputs/ holds ${files.length} file(s) from the person` : 'new or changed in inputs/ since your last call'}: ${shown}. inputs {action:"describe", path} tells what one holds.`;
|
|
557
|
+
};
|
|
558
|
+
for (const t of tools) {
|
|
559
|
+
const run = t.run;
|
|
560
|
+
t.run = async (args) => {
|
|
561
|
+
const result = await run(args);
|
|
562
|
+
const note = inputsNote(t.name);
|
|
563
|
+
if (note)
|
|
564
|
+
result.content.push({ type: 'text', text: note });
|
|
565
|
+
return result;
|
|
566
|
+
};
|
|
567
|
+
}
|
|
509
568
|
return tools;
|
|
510
569
|
}
|
package/dist/nodes/bake.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Image, MAIN_LAYER } from '../core/image.js';
|
|
2
|
-
import { averagedVertexNormals, bakeSamples, curvatureEdges, dilate, edgeGrid, idColor, interpolate, normalize3, resolve,
|
|
2
|
+
import { averagedVertexNormals, bakeSamples, curvatureEdges, dilate, edgeGrid, idColor, interpolate, interpolateCorners, normalize3, resolve, uvIslands, vertexPositions, vertexValues, } from '../core/bake.js';
|
|
3
|
+
import { cornerTangents, loadMikkTSpace, mikkTSpaceReady, shadingFrame } from '../core/tangents.js';
|
|
3
4
|
import { RayScene, bboxDiagonal } from '../core/analysis.js';
|
|
4
5
|
import { pointNormals, resolveVertexNormals, triangulate } from '../core/topology.js';
|
|
5
6
|
import { defineNode } from '../graph/registry.js';
|
|
@@ -134,12 +135,28 @@ function rayDirs(b) {
|
|
|
134
135
|
normalize3(R);
|
|
135
136
|
return R;
|
|
136
137
|
}
|
|
137
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Point normals of a mesh: its point N when present, else area-weighted face normals. Points whose N is zero or not
|
|
140
|
+
* finite take the computed normal: a merge of parts with and without N fills the missing ones with zeros, which would
|
|
141
|
+
* bake as grey.
|
|
142
|
+
*/
|
|
138
143
|
function pointNormalsOf(g) {
|
|
139
144
|
const a = g.points.get('N');
|
|
140
|
-
if (a
|
|
141
|
-
return
|
|
142
|
-
|
|
145
|
+
if (!a || a.type !== 'float' || a.size !== 3)
|
|
146
|
+
return pointNormals(g);
|
|
147
|
+
const N = a.data;
|
|
148
|
+
let out = null, computed = null;
|
|
149
|
+
for (let i = 0; i < N.length; i += 3) {
|
|
150
|
+
const l = Math.hypot(N[i], N[i + 1], N[i + 2]);
|
|
151
|
+
if (l > 1e-12 && Number.isFinite(l))
|
|
152
|
+
continue;
|
|
153
|
+
out ??= N.slice();
|
|
154
|
+
computed ??= pointNormals(g);
|
|
155
|
+
out[i] = computed[i];
|
|
156
|
+
out[i + 1] = computed[i + 1];
|
|
157
|
+
out[i + 2] = computed[i + 2];
|
|
158
|
+
}
|
|
159
|
+
return out ?? N;
|
|
143
160
|
}
|
|
144
161
|
/** andThen() for a callback that may itself return a promise (a cook result); keeps synchronous runs synchronous. */
|
|
145
162
|
const chain = (x, f) => (x instanceof Promise ? x.then(f) : f(x));
|
|
@@ -382,9 +399,11 @@ defineBake({
|
|
|
382
399
|
type: 'bake_normal',
|
|
383
400
|
summary: 'Bake a tangent-space normal map from a high-res mesh (input 1) onto the uv of the low mesh: OpenGL or DirectX.',
|
|
384
401
|
description: 'Substance Painter / Marmoset "Normal". ' + BAKE_DOC + 'For each texel a ray from cage above the low surface along -N finds ' +
|
|
385
|
-
'the high-res surface (within cage below); its interpolated normal is written in the low mesh\'s tangent
|
|
386
|
-
'
|
|
387
|
-
'
|
|
402
|
+
'the high-res surface (within cage below); its interpolated normal is written in the low mesh\'s MikkTSpace tangent ' +
|
|
403
|
+
'frame as 0.5 + 0.5 n: the frame glTF export writes as TANGENT and Blender, Unreal and Unity compute, so the map ' +
|
|
404
|
+
'decodes the same everywhere (N interpolated and normalised, T the interpolated MikkTSpace tangent made ' +
|
|
405
|
+
'perpendicular to N, B = w · N × T). Misses and a missing input 1 give the flat (0.5, 0.5, 1). glTF and Blender ' +
|
|
406
|
+
'read OpenGL; Unreal DirectX (or flip green on import).',
|
|
388
407
|
aliases: ['normal_bake', 'bake_tangent_normal', 'bake_normal_map'],
|
|
389
408
|
params: {
|
|
390
409
|
...BAKE_PARAMS('normal'),
|
|
@@ -415,36 +434,37 @@ defineBake({
|
|
|
415
434
|
ctx.warn(`${ctx.type}: no high-res mesh on input 1: the map is flat (0.5, 0.5, 1)`);
|
|
416
435
|
return finish(b, out, 4, [0.5, 0.5, 1, 1]);
|
|
417
436
|
}
|
|
418
|
-
const tan = triangleTangents(b.g, b.uv, b.tris);
|
|
419
437
|
const dx = p.format === 'directx' ? -1 : 1;
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
if (!(tl > 1e-12))
|
|
433
|
-
continue;
|
|
434
|
-
tx /= tl;
|
|
435
|
-
ty /= tl;
|
|
436
|
-
tz /= tl;
|
|
437
|
-
const sg = tan.sign[t];
|
|
438
|
-
const bx = (ny * tz - nz * ty) * sg, by = (nz * tx - nx * tz) * sg, bz = (nx * ty - ny * tx) * sg;
|
|
439
|
-
const hx = h.N[i * 3], hy = h.N[i * 3 + 1], hz = h.N[i * 3 + 2];
|
|
440
|
-
const u = hx * tx + hy * ty + hz * tz, v = hx * bx + hy * by + hz * bz, w = hx * nx + hy * ny + hz * nz;
|
|
441
|
-
const l = Math.hypot(u, v, w) || 1;
|
|
442
|
-
out[i * 4] = 0.5 + (0.5 * u) / l;
|
|
443
|
-
out[i * 4 + 1] = 0.5 + (0.5 * v * dx) / l;
|
|
444
|
-
out[i * 4 + 2] = 0.5 + (0.5 * w) / l;
|
|
438
|
+
const bakeWith = () => {
|
|
439
|
+
// the same vertex normals (cusp 60°) and uv the exporter writes, so the frame matches the exported TANGENT
|
|
440
|
+
const { tangents, diag } = cornerTangents(b.g, b.tris, resolveVertexNormals(b.g, 60), b.uv);
|
|
441
|
+
if (diag.uvDegenerate || diag.uvNonFinite)
|
|
442
|
+
ctx.warn(`${ctx.type}: ${diag.uvDegenerate + diag.uvNonFinite} of ${diag.triangles} triangles have collapsed or non-finite uvs: no tangent frame there (flat texels)`);
|
|
443
|
+
const T = interpolateCorners(b.s, tangents, 4), f = new Float64Array(9);
|
|
444
|
+
const collapsed = new Uint8Array(diag.triangles);
|
|
445
|
+
for (let t = 0; t < diag.triangles; t++) {
|
|
446
|
+
const u0 = b.uv[b.tris[t * 3] * 2], v0 = b.uv[b.tris[t * 3] * 2 + 1];
|
|
447
|
+
const du1 = b.uv[b.tris[t * 3 + 1] * 2] - u0, dv1 = b.uv[b.tris[t * 3 + 1] * 2 + 1] - v0, du2 = b.uv[b.tris[t * 3 + 2] * 2] - u0, dv2 = b.uv[b.tris[t * 3 + 2] * 2 + 1] - v0;
|
|
448
|
+
if (!(Math.abs(du1 * dv2 - du2 * dv1) > 0))
|
|
449
|
+
collapsed[t] = 1;
|
|
445
450
|
}
|
|
446
|
-
return
|
|
447
|
-
|
|
451
|
+
return andThen(onHigh(b, high), (h) => {
|
|
452
|
+
for (let i = 0; i < n; i++) {
|
|
453
|
+
if (!(h.D[i] === h.D[i]) || collapsed[b.s.tri[i]])
|
|
454
|
+
continue;
|
|
455
|
+
if (!shadingFrame(b.N[i * 3], b.N[i * 3 + 1], b.N[i * 3 + 2], T[i * 4], T[i * 4 + 1], T[i * 4 + 2], T[i * 4 + 3], f))
|
|
456
|
+
continue;
|
|
457
|
+
const hx = h.N[i * 3], hy = h.N[i * 3 + 1], hz = h.N[i * 3 + 2];
|
|
458
|
+
const u = hx * f[0] + hy * f[1] + hz * f[2], v = hx * f[3] + hy * f[4] + hz * f[5], w = hx * f[6] + hy * f[7] + hz * f[8];
|
|
459
|
+
const l = Math.hypot(u, v, w) || 1;
|
|
460
|
+
out[i * 4] = 0.5 + (0.5 * u) / l;
|
|
461
|
+
out[i * 4 + 1] = 0.5 + (0.5 * v * dx) / l;
|
|
462
|
+
out[i * 4 + 2] = 0.5 + (0.5 * w) / l;
|
|
463
|
+
}
|
|
464
|
+
return finish(b, out, 4, [0.5, 0.5, 1, 1]);
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
return mikkTSpaceReady() ? bakeWith() : loadMikkTSpace().then(bakeWith);
|
|
448
468
|
},
|
|
449
469
|
});
|
|
450
470
|
defineBake({
|
package/dist/nodes/bevel.js
CHANGED
|
@@ -11,8 +11,9 @@ defineNode({
|
|
|
11
11
|
'for a chamfer (triangle at a box corner), rings of quads for round bevels (a sphere octant at a box corner). A ' +
|
|
12
12
|
'bevelled edge ending at an unbevelled point slides its offset along the neighbouring edges and ends flush; two ' +
|
|
13
13
|
'bevelled edges meeting at a point with one other edge (a cylinder rim) are mitred. Boundary and non-manifold edges ' +
|
|
14
|
-
'are skipped with a warning (chamfering open-mesh boundary edges is out of scope). clamp
|
|
15
|
-
'
|
|
14
|
+
'are skipped with a warning (chamfering open-mesh boundary edges is out of scope). clamp shrinks the offsets only ' +
|
|
15
|
+
'around edges that would cross (huge offsets stay clean; one short edge does not flatten every bevel), and leaves an ' +
|
|
16
|
+
'edge sharp when a zero-length neighbour leaves no room. Point mode truncates the selected points: ' +
|
|
16
17
|
'every edge at the point is cut at "offset", the corner becomes a polygon, or a dome of "divisions" rings. Faces keep ' +
|
|
17
18
|
'their attributes (uv is interpolated inside each face), strips take prim attributes from the larger neighbouring face, ' +
|
|
18
19
|
'corner patches from the first face around the point; N is recomputed if present. Select edges with patterns: ' +
|
|
@@ -29,7 +30,7 @@ defineNode({
|
|
|
29
30
|
mode: { type: 'enum', options: ['edges', 'points'], default: 'edges', desc: 'bevel edges, or truncate points', aliases: ['bevel_type', 'class'] },
|
|
30
31
|
offset: { type: 'float', default: 0.1, min: 0, desc: 'distance from the edge across each adjacent face (points mode: along each edge)', aliases: ['distance', 'width', 'radius', 'size', 'amount'] },
|
|
31
32
|
offset_mode: { type: 'enum', options: ['distance', 'fraction'], default: 'distance', desc: 'distance = offset in scene units; fraction = offset x the shortest edge at the edge\'s points (stays proportional on small faces)', aliases: ['distance_mode', 'offsetmode'] },
|
|
32
|
-
clamp: { type: 'bool', default: true, desc: '
|
|
33
|
+
clamp: { type: 'bool', default: true, desc: 'shrink the offsets where bevels would cross their neighbours, only at the edges involved (Houdini Clamp Offset, applied locally); warns when it does', aliases: ['clamp_offset', 'clamp_overlap'] },
|
|
33
34
|
divisions: { type: 'int', default: 0, min: 0, max: 64, desc: '0 = flat chamfer (one strip of quads per edge); n = round profile with n+1 strips', aliases: ['segments', 'divs', 'subdivisions'] },
|
|
34
35
|
shape: { type: 'float', default: 0, min: -1, max: 1, desc: 'profile convexity for round bevels: 0 = circular arc, 1 = bulges out to a nearly square corner, -0.5 = straight, -1 = concave cove', aliases: ['profile_shape', 'convexity', 'profile'] },
|
|
35
36
|
},
|
package/dist/nodes/code.js
CHANGED
|
@@ -83,8 +83,9 @@ defineNode({
|
|
|
83
83
|
function scriptLib(ctx, wake, run) {
|
|
84
84
|
const engine = ctx.engine;
|
|
85
85
|
// compiled in the script realm: a synchronous node's result resolves a realm promise, so `await lib.run(...)`
|
|
86
|
-
// continues inside the same time-limited call;
|
|
87
|
-
|
|
86
|
+
// continues inside the same time-limited call; an async node hands back its outcome (see run below), which the
|
|
87
|
+
// realm awaits and turns back into the node's value or error
|
|
88
|
+
const realmAsync = engine.host.compile('(function(f){ return async function run(...a) { const r = f(...a); if (r && r.libRunOutcome) { const o = await r.libRunOutcome; if (o.failed) throw o.error; return o.value; } return r; }; })');
|
|
88
89
|
return {
|
|
89
90
|
Geometry, GeoBuilder, math, topology, random,
|
|
90
91
|
noise: { makeNoise, fractal, makeCurl },
|
|
@@ -134,10 +135,35 @@ function scriptLib(ctx, wake, run) {
|
|
|
134
135
|
node: `${ctx.node}/${type}`, type: def.type, p: rp.values, inputs,
|
|
135
136
|
input: (i) => inputs[i] ?? new Geometry(), hasInput: (i) => !!inputs[i], inputSigs: inputs.map(() => 'script'),
|
|
136
137
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
// The script's time limit can stop it anywhere, also between starting an async node and listening to it: that
|
|
139
|
+
// node's promise would then reject later with nobody listening, which ends the process (MCP server included).
|
|
140
|
+
// So an async node's promise is awaited right inside `outcome`, with no call in between that the limit could
|
|
141
|
+
// stop, and `outcome` never rejects. A synchronous node returns (or throws) here, as before.
|
|
142
|
+
let started, thrownNow = null;
|
|
143
|
+
const isAsync = () => !!started && typeof started.then === 'function';
|
|
144
|
+
const outcome = (async () => {
|
|
145
|
+
try {
|
|
146
|
+
started = def.cook(sub);
|
|
147
|
+
// property reads only from here to the await: a function call is where the limit could stop the script
|
|
148
|
+
if (!started || typeof started.then !== 'function')
|
|
149
|
+
return null;
|
|
150
|
+
return { value: await started };
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
if (!isAsync()) {
|
|
154
|
+
thrownNow = { error };
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
return { failed: true, error };
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
if (isAsync())
|
|
161
|
+
wake();
|
|
162
|
+
}
|
|
163
|
+
})();
|
|
164
|
+
if (thrownNow)
|
|
165
|
+
throw thrownNow.error;
|
|
166
|
+
return isAsync() ? { libRunOutcome: outcome } : started;
|
|
141
167
|
}),
|
|
142
168
|
warn: (m) => ctx.warn(String(m)),
|
|
143
169
|
};
|
|
@@ -203,7 +229,7 @@ defineNode({
|
|
|
203
229
|
run.stopped = true;
|
|
204
230
|
}
|
|
205
231
|
// what the script returned is user code too: `instanceof` (and Object.getPrototypeOf) run a Proxy's
|
|
206
|
-
// getPrototypeOf trap here, outside the time limit, so only the engine's brand check looks at it
|
|
232
|
+
// getPrototypeOf trap here, outside the time limit, so only the engine's brand check looks at it
|
|
207
233
|
const bad = notGeometry(res);
|
|
208
234
|
if (bad)
|
|
209
235
|
throw new NodeError(`script must return a Geometry (got ${bad})`, 'return geo, a geometry from lib.run, or one built with lib.GeoBuilder / new lib.Geometry()');
|
package/dist/nodes/curves.js
CHANGED
|
@@ -271,6 +271,13 @@ defineNode({
|
|
|
271
271
|
const a = ((a0 + (90 * k) / s) * Math.PI) / 180;
|
|
272
272
|
pts2.push([cx + r * Math.cos(a), cy + r * Math.sin(a)]);
|
|
273
273
|
}
|
|
274
|
+
// a radius of half the width or depth makes neighbouring arcs meet: keep their shared end point once
|
|
275
|
+
const eps = 1e-9 * Math.max(hw, hd);
|
|
276
|
+
for (let i = pts2.length - 1; i >= 0 && pts2.length > 3; i--) {
|
|
277
|
+
const q = pts2[(i + 1) % pts2.length];
|
|
278
|
+
if (Math.abs(pts2[i][0] - q[0]) <= eps && Math.abs(pts2[i][1] - q[1]) <= eps)
|
|
279
|
+
pts2.splice(i, 1);
|
|
280
|
+
}
|
|
274
281
|
break;
|
|
275
282
|
}
|
|
276
283
|
case 'ngon':
|
package/dist/nodes/generate.js
CHANGED
|
@@ -463,7 +463,7 @@ defineNode({
|
|
|
463
463
|
example: { type: 'point_grid', params: { counts: [10, 1, 10], size: [9, 0, 9], jitter: 0.3, seed: 1 } },
|
|
464
464
|
cook: ({ p }) => {
|
|
465
465
|
const [cx, cy, cz] = p.counts;
|
|
466
|
-
// each count has a max, but not their product (
|
|
466
|
+
// each count has a max, but not their product (a huge grid ran the process out of heap)
|
|
467
467
|
if (cx * cy * cz > MAX_GRID_POINTS)
|
|
468
468
|
throw new NodeError(`point_grid: counts [${cx}, ${cy}, ${cz}] give ${(cx * cy * cz).toLocaleString('en-US')} points, more than ${MAX_GRID_POINTS.toLocaleString('en-US')}`, 'lower the counts, or scatter points instead');
|
|
469
469
|
const r = rng(p.seed);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|