topotopo 0.3.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 +35 -14
- package/dist/cli.js +28 -10
- 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/host/export-targets.js +1 -1
- 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.js +1 -1
- package/dist/mcp/docs.d.ts +1 -1
- package/dist/mcp/docs.js +58 -4
- 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.js +16 -10
- package/dist/nodes/bake.js +56 -36
- package/dist/nodes/bevel.js +4 -3
- package/dist/nodes/code.js +1 -1
- 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 +1 -1
- package/dist/viewer/app/embed.js +80 -0
- package/dist/viewer/app/grid.js +1 -1
- package/dist/viewer/app/guides.js +1 -1
- package/dist/viewer/app/keymap.js +1 -1
- package/dist/viewer/app/layers.js +1 -1
- package/dist/viewer/app/main.js +1 -1
- package/dist/viewer/app/markers.js +1 -1
- package/dist/viewer/app/outliner.js +1 -1
- package/dist/viewer/app/props.js +1 -1
- package/dist/viewer/app/scene.js +6 -2
- package/dist/viewer/app/select.js +1 -1
- package/dist/viewer/app/selection.js +1 -1
- package/dist/viewer/app/status.js +1 -1
- package/dist/viewer/app/style.css +1 -1
- package/dist/viewer/app/units.js +1 -1
- package/dist/viewer/app/vars.js +1 -1
- package/dist/viewer/index.html +1 -1
- package/dist/viewer/server.d.ts +14 -2
- package/dist/viewer/server.js +30 -10
- package/dist/workspace.d.ts +13 -0
- package/dist/workspace.js +87 -1
- package/kernels/pkg/README.md +21 -28
- package/kernels/pkg-simd/README.md +21 -28
- package/package.json +9 -3
package/dist/workspace.js
CHANGED
|
@@ -9,7 +9,7 @@ import path from 'node:path';
|
|
|
9
9
|
import { Engine, wiringOf } from './graph/engine.js';
|
|
10
10
|
import { didYouMean, renameExprRefs } from './graph/params.js';
|
|
11
11
|
import { migrateGraph } from './graph/migrate.js';
|
|
12
|
-
const NAME_RE = /^[A-Za-z_][\w.-]*$/;
|
|
12
|
+
export const NAME_RE = /^[A-Za-z_][\w.-]*$/;
|
|
13
13
|
const GEOMETRY_EXTS = new Set(['obj', 'stl', 'ply', 'glb', 'gltf', 'geo', 'bgeo', 'blend', 'csv', 'json', 'points.json']);
|
|
14
14
|
const IMAGE_EXTS = new Set(['png', 'jpg', 'jpeg', 'webp']);
|
|
15
15
|
/** Lower-case extension of a file name without the dot; ".points.json" is one extension, dot-files have none. */
|
|
@@ -394,4 +394,90 @@ export class Workspace {
|
|
|
394
394
|
this.lastReport.set(name, r);
|
|
395
395
|
return r;
|
|
396
396
|
}
|
|
397
|
+
watchers = [];
|
|
398
|
+
watchTimers = new Map();
|
|
399
|
+
/**
|
|
400
|
+
* Follow what other processes write into graphs/ and assets/ (a second Workspace on the same folder: the gallery's
|
|
401
|
+
* editor next to an MCP server, or a person editing the JSON). A graph file whose content differs from the stored
|
|
402
|
+
* graph replaces it and notifies the listeners; a removed file removes the graph. Our own writes read back equal, so
|
|
403
|
+
* they change nothing. An asset whose content changed is registered again and every graph is notified (any may use
|
|
404
|
+
* it); a removed asset stays registered until the next load(). Two writers to one graph: the last write wins.
|
|
405
|
+
*/
|
|
406
|
+
watch() {
|
|
407
|
+
if (this.watchers.length)
|
|
408
|
+
return;
|
|
409
|
+
const on = (dir, apply) => {
|
|
410
|
+
try {
|
|
411
|
+
const w = fs.watch(dir, (_ev, f) => {
|
|
412
|
+
const rel = f ? String(f) : '';
|
|
413
|
+
// Windows names a removed folder by its absolute path: stop rather than follow a folder that is gone
|
|
414
|
+
if (path.isAbsolute(rel)) {
|
|
415
|
+
w.close();
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (!rel.endsWith('.json') || rel.includes(path.sep) || rel.startsWith('.'))
|
|
419
|
+
return;
|
|
420
|
+
const name = rel.slice(0, -'.json'.length), key = dir + '|' + name;
|
|
421
|
+
clearTimeout(this.watchTimers.get(key));
|
|
422
|
+
// persist() is not atomic: let the writer finish, and read again if the JSON is still half written
|
|
423
|
+
let tries = 0;
|
|
424
|
+
const run = () => {
|
|
425
|
+
this.watchTimers.delete(key);
|
|
426
|
+
try {
|
|
427
|
+
apply(name, path.join(dir, rel));
|
|
428
|
+
}
|
|
429
|
+
catch (e) {
|
|
430
|
+
if (e instanceof SyntaxError && ++tries < 5)
|
|
431
|
+
this.watchTimers.set(key, setTimeout(run, 100).unref());
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
this.watchTimers.set(key, setTimeout(run, 150).unref());
|
|
435
|
+
});
|
|
436
|
+
w.on('error', () => w.close());
|
|
437
|
+
w.unref();
|
|
438
|
+
this.watchers.push(w);
|
|
439
|
+
}
|
|
440
|
+
catch { /* no folder: nothing to follow */ }
|
|
441
|
+
};
|
|
442
|
+
on(this.graphDir, (name, file) => {
|
|
443
|
+
if (!NAME_RE.test(name))
|
|
444
|
+
return;
|
|
445
|
+
if (!fs.existsSync(file)) {
|
|
446
|
+
if (this.graphs.delete(name)) {
|
|
447
|
+
this.lastReport.delete(name);
|
|
448
|
+
this.bump(name);
|
|
449
|
+
}
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const spec = migrateGraph(JSON.parse(fs.readFileSync(file, 'utf8')));
|
|
453
|
+
const cur = this.graphs.get(name);
|
|
454
|
+
if (cur && JSON.stringify(cur) === JSON.stringify(spec))
|
|
455
|
+
return;
|
|
456
|
+
this.graphs.set(name, spec);
|
|
457
|
+
this.lastReport.delete(name);
|
|
458
|
+
this.bump(name);
|
|
459
|
+
});
|
|
460
|
+
on(this.assetDir, (name, file) => {
|
|
461
|
+
if (!fs.existsSync(file))
|
|
462
|
+
return;
|
|
463
|
+
const spec = migrateGraph(JSON.parse(fs.readFileSync(file, 'utf8')));
|
|
464
|
+
const before = this.engine.assets.get(name)?.hash;
|
|
465
|
+
this.engine.registerAsset(name, spec);
|
|
466
|
+
if (this.engine.assets.get(name)?.hash === before)
|
|
467
|
+
return;
|
|
468
|
+
for (const g of this.graphs.keys()) {
|
|
469
|
+
this.lastReport.delete(g);
|
|
470
|
+
this.bump(g);
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
/** Stop following the folders (watch()). */
|
|
475
|
+
unwatch() {
|
|
476
|
+
for (const w of this.watchers)
|
|
477
|
+
w.close();
|
|
478
|
+
for (const t of this.watchTimers.values())
|
|
479
|
+
clearTimeout(t);
|
|
480
|
+
this.watchers = [];
|
|
481
|
+
this.watchTimers.clear();
|
|
482
|
+
}
|
|
397
483
|
}
|
package/kernels/pkg/README.md
CHANGED
|
@@ -6,7 +6,7 @@ SIMD and scalar WebAssembly builds; normal TopoTopo users do not install Rust.
|
|
|
6
6
|
The loader feature-detects simd128 and defaults to SIMD, with scalar fallback.
|
|
7
7
|
See [BUILD.md](https://github.com/topotopo-dev/topotopo/blob/main/kernels/BUILD.md).
|
|
8
8
|
|
|
9
|
-
## Scatter selection
|
|
9
|
+
## Scatter selection
|
|
10
10
|
|
|
11
11
|
`scatter_eliminate(positions, scale, target_count, r_max)` and
|
|
12
12
|
`scatter_min_distance(positions, order, radius, limit, groups, group_cap)` expose
|
|
@@ -62,7 +62,7 @@ positive minimum distances whose squares underflow to zero, and
|
|
|
62
62
|
excessive pair lists return errors. Minimum-distance grid coordinates are limited
|
|
63
63
|
to the exact integer range `abs(position / radius) <= 2^52 - 4`, so hostile tiny
|
|
64
64
|
radii cannot produce overflowing or nonadvancing cell loops. No dependencies were
|
|
65
|
-
added.
|
|
65
|
+
added.
|
|
66
66
|
|
|
67
67
|
`scatter_relax` accepts f64 positions, per-point spacing, triangle indices and
|
|
68
68
|
barycentrics, plus the existing `TriSurface.arrays()` buffers (`T`, `nodes`, `child`,
|
|
@@ -87,8 +87,8 @@ with at least three started pool slots, or 500k with two; uniform elimination fr
|
|
|
87
87
|
500k candidates with at least four, or 250k with at least eight; and projected
|
|
88
88
|
relaxation from 50k kept points with at least three. Minimum-distance rejection
|
|
89
89
|
uses WASM. Cold/disabled pools and stages below a pool threshold use WASM;
|
|
90
|
-
counts beyond kernel budgets use JS.
|
|
91
|
-
|
|
90
|
+
counts beyond kernel budgets use JS. The measured crossover is machine-specific.
|
|
91
|
+
Sampling and attribute
|
|
92
92
|
interpolation remain in TS; heightfield_scatter retains its TS integration.
|
|
93
93
|
`cargo bench --manifest-path kernels/Cargo.toml --features profile --bench scatter`
|
|
94
94
|
prints native KD/search/heap/grid/projection stage timings. `bench/bench.ts` measures
|
|
@@ -105,10 +105,10 @@ initializes WASM once per worker on its first such job;
|
|
|
105
105
|
the full-stage registry entry rejects split ranges, and an unavailable pool falls
|
|
106
106
|
back to the loaded main-thread kernel.
|
|
107
107
|
The pool threshold override can force this path for parity tests. The conservative
|
|
108
|
-
default
|
|
109
|
-
|
|
108
|
+
default keeps a 1M placement cutoff; a 500k measurement did not support lowering
|
|
109
|
+
it.
|
|
110
110
|
|
|
111
|
-
## Heightfield erosion
|
|
111
|
+
## Heightfield erosion
|
|
112
112
|
|
|
113
113
|
`src/wasm/kernels.ts` exposes `erode_droplet`, `erode_pipe`, `thermal_erode`, and
|
|
114
114
|
`flow_accumulation`. Heights and optional hardness/freeze/rain maps are flat row-major
|
|
@@ -191,9 +191,7 @@ use f64x2 SIMD while preserving scalar arithmetic and active thermal transfer
|
|
|
191
191
|
order. Row bounds are validated
|
|
192
192
|
before the small unchecked stencil/scatter loops; ordinary pipe and droplet work
|
|
193
193
|
buffers are allocated before iteration. Filled routing allocates its flood and
|
|
194
|
-
drainage buffers when refreshed.
|
|
195
|
-
rejected experiments and remaining limits in
|
|
196
|
-
[BENCH.md](https://github.com/topotopo-dev/topotopo/blob/main/kernels/BENCH.md).
|
|
194
|
+
drainage buffers when refreshed.
|
|
197
195
|
|
|
198
196
|
`flow_accumulation` offers D8 and triangular-facet D-infinity routing. Accumulation
|
|
199
197
|
includes each sample's own cell area. Stable height/index ordering fixes the sum
|
|
@@ -221,10 +219,9 @@ Scalar/SIMD corpus parity compares every returned byte, with no floating toleran
|
|
|
221
219
|
golden and pool tests exercise the default SIMD path. `TOPOTOPO_WASM=scalar|simd`
|
|
222
220
|
selects an explicit path before import. No dependencies were added; existing crate
|
|
223
221
|
licences below still apply.
|
|
224
|
-
See
|
|
225
|
-
`examples/renders/erosion_models.png` for the four-model comparison.
|
|
222
|
+
See `examples/renders/erosion_models.png` for the four-model comparison.
|
|
226
223
|
|
|
227
|
-
## Depression filling and lakes
|
|
224
|
+
## Depression filling and lakes
|
|
228
225
|
|
|
229
226
|
The loader API is `fill_sinks(height, width, heightCount, options?, mask?)`, with
|
|
230
227
|
`Float32Array` height/mask buffers and options `epsilon`, `maxDepth` and
|
|
@@ -303,9 +300,7 @@ filled and deeper lakes retained on the right. Both use the same contributing-ar
|
|
|
303
300
|
colour scale; lake surfaces are blue. Its `filled` node is the terrain result;
|
|
304
301
|
`water_surface` raises only the display mesh by `lake`, keeping water and terrain
|
|
305
302
|
separate in the actual heightfield. Run `node test/showcase.ts drainage` and inspect
|
|
306
|
-
`examples/renders/drainage.png`.
|
|
307
|
-
[BENCH.md](https://github.com/topotopo-dev/topotopo/blob/main/kernels/BENCH.md)
|
|
308
|
-
for the measured timings, backend parity and remaining limits.
|
|
303
|
+
`examples/renders/drainage.png`.
|
|
309
304
|
|
|
310
305
|
## API and geometry
|
|
311
306
|
|
|
@@ -396,7 +391,7 @@ has not been established by an exhaustive platform matrix.
|
|
|
396
391
|
Current limits are explicit:
|
|
397
392
|
|
|
398
393
|
- At most 4096 contour vertices. Event search and incidence rebuilding are deliberately
|
|
399
|
-
exhaustive (roughly cubic time on typical inputs);
|
|
394
|
+
exhaustive (roughly cubic time on typical inputs); correctness comes first.
|
|
400
395
|
- Adjacent exactly collinear edges with **different** speeds/pitches are rejected with
|
|
401
396
|
an actionable error. Equal-speed collinear points are supported and keep provenance.
|
|
402
397
|
- Touching/intersecting contours, nested holes, duplicate points, zero-area rings, all
|
|
@@ -413,7 +408,7 @@ Current limits are explicit:
|
|
|
413
408
|
the weights and then convert the returned times accordingly. Ordinary roof pitches
|
|
414
409
|
and the explicit 90-degree gable are covered by tests; pitches extremely close to
|
|
415
410
|
zero or 90 degrees can encounter the same limit.
|
|
416
|
-
- The Rust isotropic remesher and point kernels are not included;
|
|
411
|
+
- The Rust isotropic remesher and point kernels are not included; quad remeshing and erosion are separate kernels.
|
|
417
412
|
|
|
418
413
|
## Tests
|
|
419
414
|
|
|
@@ -461,9 +456,9 @@ dependency is used. `earcutr` is only used for flat cap triangulation, not skele
|
|
|
461
456
|
|
|
462
457
|
`unicode-ident` is a compiler-only transitive dependency; its Unicode-3.0 data-table
|
|
463
458
|
licence is permitted by the repository's build-time licence rule. Its identifier
|
|
464
|
-
tables are not linked into the shipped WASM.
|
|
459
|
+
tables are not linked into the shipped WASM. The SDF, remeshing and erosion kernels add no dependencies.
|
|
465
460
|
|
|
466
|
-
## Field-aligned quad remeshing
|
|
461
|
+
## Field-aligned quad remeshing
|
|
467
462
|
|
|
468
463
|
```js
|
|
469
464
|
const mesh = remesh_quad(positions, tris, {
|
|
@@ -548,15 +543,14 @@ also capped at two million triangles. Self-intersecting inputs are not repaired.
|
|
|
548
543
|
Face counts remain approximate, especially with locked borders or dense geometric
|
|
549
544
|
constraints. Local cleanup and bounded integer correction do not establish global
|
|
550
545
|
integrability or intersection freedom on arbitrary surfaces. Scalar/SIMD parity is
|
|
551
|
-
tested on the regression corpus, not an exhaustive operating-system/compiler matrix.
|
|
552
|
-
acceptance, scalar/SIMD comparisons and remaining limits are in [BENCH.md](https://github.com/topotopo-dev/topotopo/blob/main/kernels/BENCH.md).
|
|
546
|
+
tested on the regression corpus, not an exhaustive operating-system/compiler matrix.
|
|
553
547
|
|
|
554
548
|
Run `node test/remeshquad.ts`, `node bench/remeshquad.ts` and
|
|
555
549
|
`cargo bench --manifest-path kernels/Cargo.toml --bench remesh_quad`.
|
|
556
550
|
Inspect `examples/renders/quad_remesh.png`: gray inputs and colored results for a
|
|
557
551
|
noisy sphere, bevelled box, shelf rock and capped tube, with every polygon edge visible.
|
|
558
552
|
|
|
559
|
-
## Sampled SDF grids
|
|
553
|
+
## Sampled SDF grids
|
|
560
554
|
|
|
561
555
|
The original skeleton API is unchanged. Additional generated WASM exports are:
|
|
562
556
|
|
|
@@ -628,9 +622,9 @@ Ambiguous topology and unsafe sharp fits trigger local conservative patches. Sha
|
|
|
628
622
|
face connectors make the transition conforming, without unmatched edges or T-junctions.
|
|
629
623
|
These guards detect risky local configurations, not every possible geometric
|
|
630
624
|
self-intersection. Runtime validation checks oriented edge incidence; the test corpus
|
|
631
|
-
also checks vertex links and proper nonadjacent triangle crossings.
|
|
632
|
-
|
|
633
|
-
The explicit `conservative=true` path retains the
|
|
625
|
+
also checks vertex links and proper nonadjacent triangle crossings. Union junctions
|
|
626
|
+
remain less accurate (about 0.4 voxel).
|
|
627
|
+
The explicit `conservative=true` path retains the original minmod gradients and
|
|
634
628
|
cell-local fans byte-for-byte. Signed negative zero at iso zero retains inside sign.
|
|
635
629
|
Unclamped QEF fits are accepted only when they stay in their cells; otherwise the
|
|
636
630
|
caller gets a clear enable-clamping error. The construction follows the uniform
|
|
@@ -673,5 +667,4 @@ existing `remesh` node and its `remesh_voxel` alias retain their old behavior.
|
|
|
673
667
|
Run `node test/sdfgrid.ts` for Node integration, `node bench/sdfgrid.ts` for the 256³
|
|
674
668
|
box benchmark, and inspect `examples/renders/voxel_remesh.png` (sharp left, smooth
|
|
675
669
|
middle, dilate/erode/blur right). Existing goldens and render hashes are checked
|
|
676
|
-
separately from the new example.
|
|
677
|
-
[BENCH.md](https://github.com/topotopo-dev/topotopo/blob/main/kernels/BENCH.md).
|
|
670
|
+
separately from the new example.
|
|
@@ -6,7 +6,7 @@ SIMD and scalar WebAssembly builds; normal TopoTopo users do not install Rust.
|
|
|
6
6
|
The loader feature-detects simd128 and defaults to SIMD, with scalar fallback.
|
|
7
7
|
See [BUILD.md](https://github.com/topotopo-dev/topotopo/blob/main/kernels/BUILD.md).
|
|
8
8
|
|
|
9
|
-
## Scatter selection
|
|
9
|
+
## Scatter selection
|
|
10
10
|
|
|
11
11
|
`scatter_eliminate(positions, scale, target_count, r_max)` and
|
|
12
12
|
`scatter_min_distance(positions, order, radius, limit, groups, group_cap)` expose
|
|
@@ -62,7 +62,7 @@ positive minimum distances whose squares underflow to zero, and
|
|
|
62
62
|
excessive pair lists return errors. Minimum-distance grid coordinates are limited
|
|
63
63
|
to the exact integer range `abs(position / radius) <= 2^52 - 4`, so hostile tiny
|
|
64
64
|
radii cannot produce overflowing or nonadvancing cell loops. No dependencies were
|
|
65
|
-
added.
|
|
65
|
+
added.
|
|
66
66
|
|
|
67
67
|
`scatter_relax` accepts f64 positions, per-point spacing, triangle indices and
|
|
68
68
|
barycentrics, plus the existing `TriSurface.arrays()` buffers (`T`, `nodes`, `child`,
|
|
@@ -87,8 +87,8 @@ with at least three started pool slots, or 500k with two; uniform elimination fr
|
|
|
87
87
|
500k candidates with at least four, or 250k with at least eight; and projected
|
|
88
88
|
relaxation from 50k kept points with at least three. Minimum-distance rejection
|
|
89
89
|
uses WASM. Cold/disabled pools and stages below a pool threshold use WASM;
|
|
90
|
-
counts beyond kernel budgets use JS.
|
|
91
|
-
|
|
90
|
+
counts beyond kernel budgets use JS. The measured crossover is machine-specific.
|
|
91
|
+
Sampling and attribute
|
|
92
92
|
interpolation remain in TS; heightfield_scatter retains its TS integration.
|
|
93
93
|
`cargo bench --manifest-path kernels/Cargo.toml --features profile --bench scatter`
|
|
94
94
|
prints native KD/search/heap/grid/projection stage timings. `bench/bench.ts` measures
|
|
@@ -105,10 +105,10 @@ initializes WASM once per worker on its first such job;
|
|
|
105
105
|
the full-stage registry entry rejects split ranges, and an unavailable pool falls
|
|
106
106
|
back to the loaded main-thread kernel.
|
|
107
107
|
The pool threshold override can force this path for parity tests. The conservative
|
|
108
|
-
default
|
|
109
|
-
|
|
108
|
+
default keeps a 1M placement cutoff; a 500k measurement did not support lowering
|
|
109
|
+
it.
|
|
110
110
|
|
|
111
|
-
## Heightfield erosion
|
|
111
|
+
## Heightfield erosion
|
|
112
112
|
|
|
113
113
|
`src/wasm/kernels.ts` exposes `erode_droplet`, `erode_pipe`, `thermal_erode`, and
|
|
114
114
|
`flow_accumulation`. Heights and optional hardness/freeze/rain maps are flat row-major
|
|
@@ -191,9 +191,7 @@ use f64x2 SIMD while preserving scalar arithmetic and active thermal transfer
|
|
|
191
191
|
order. Row bounds are validated
|
|
192
192
|
before the small unchecked stencil/scatter loops; ordinary pipe and droplet work
|
|
193
193
|
buffers are allocated before iteration. Filled routing allocates its flood and
|
|
194
|
-
drainage buffers when refreshed.
|
|
195
|
-
rejected experiments and remaining limits in
|
|
196
|
-
[BENCH.md](https://github.com/topotopo-dev/topotopo/blob/main/kernels/BENCH.md).
|
|
194
|
+
drainage buffers when refreshed.
|
|
197
195
|
|
|
198
196
|
`flow_accumulation` offers D8 and triangular-facet D-infinity routing. Accumulation
|
|
199
197
|
includes each sample's own cell area. Stable height/index ordering fixes the sum
|
|
@@ -221,10 +219,9 @@ Scalar/SIMD corpus parity compares every returned byte, with no floating toleran
|
|
|
221
219
|
golden and pool tests exercise the default SIMD path. `TOPOTOPO_WASM=scalar|simd`
|
|
222
220
|
selects an explicit path before import. No dependencies were added; existing crate
|
|
223
221
|
licences below still apply.
|
|
224
|
-
See
|
|
225
|
-
`examples/renders/erosion_models.png` for the four-model comparison.
|
|
222
|
+
See `examples/renders/erosion_models.png` for the four-model comparison.
|
|
226
223
|
|
|
227
|
-
## Depression filling and lakes
|
|
224
|
+
## Depression filling and lakes
|
|
228
225
|
|
|
229
226
|
The loader API is `fill_sinks(height, width, heightCount, options?, mask?)`, with
|
|
230
227
|
`Float32Array` height/mask buffers and options `epsilon`, `maxDepth` and
|
|
@@ -303,9 +300,7 @@ filled and deeper lakes retained on the right. Both use the same contributing-ar
|
|
|
303
300
|
colour scale; lake surfaces are blue. Its `filled` node is the terrain result;
|
|
304
301
|
`water_surface` raises only the display mesh by `lake`, keeping water and terrain
|
|
305
302
|
separate in the actual heightfield. Run `node test/showcase.ts drainage` and inspect
|
|
306
|
-
`examples/renders/drainage.png`.
|
|
307
|
-
[BENCH.md](https://github.com/topotopo-dev/topotopo/blob/main/kernels/BENCH.md)
|
|
308
|
-
for the measured timings, backend parity and remaining limits.
|
|
303
|
+
`examples/renders/drainage.png`.
|
|
309
304
|
|
|
310
305
|
## API and geometry
|
|
311
306
|
|
|
@@ -396,7 +391,7 @@ has not been established by an exhaustive platform matrix.
|
|
|
396
391
|
Current limits are explicit:
|
|
397
392
|
|
|
398
393
|
- At most 4096 contour vertices. Event search and incidence rebuilding are deliberately
|
|
399
|
-
exhaustive (roughly cubic time on typical inputs);
|
|
394
|
+
exhaustive (roughly cubic time on typical inputs); correctness comes first.
|
|
400
395
|
- Adjacent exactly collinear edges with **different** speeds/pitches are rejected with
|
|
401
396
|
an actionable error. Equal-speed collinear points are supported and keep provenance.
|
|
402
397
|
- Touching/intersecting contours, nested holes, duplicate points, zero-area rings, all
|
|
@@ -413,7 +408,7 @@ Current limits are explicit:
|
|
|
413
408
|
the weights and then convert the returned times accordingly. Ordinary roof pitches
|
|
414
409
|
and the explicit 90-degree gable are covered by tests; pitches extremely close to
|
|
415
410
|
zero or 90 degrees can encounter the same limit.
|
|
416
|
-
- The Rust isotropic remesher and point kernels are not included;
|
|
411
|
+
- The Rust isotropic remesher and point kernels are not included; quad remeshing and erosion are separate kernels.
|
|
417
412
|
|
|
418
413
|
## Tests
|
|
419
414
|
|
|
@@ -461,9 +456,9 @@ dependency is used. `earcutr` is only used for flat cap triangulation, not skele
|
|
|
461
456
|
|
|
462
457
|
`unicode-ident` is a compiler-only transitive dependency; its Unicode-3.0 data-table
|
|
463
458
|
licence is permitted by the repository's build-time licence rule. Its identifier
|
|
464
|
-
tables are not linked into the shipped WASM.
|
|
459
|
+
tables are not linked into the shipped WASM. The SDF, remeshing and erosion kernels add no dependencies.
|
|
465
460
|
|
|
466
|
-
## Field-aligned quad remeshing
|
|
461
|
+
## Field-aligned quad remeshing
|
|
467
462
|
|
|
468
463
|
```js
|
|
469
464
|
const mesh = remesh_quad(positions, tris, {
|
|
@@ -548,15 +543,14 @@ also capped at two million triangles. Self-intersecting inputs are not repaired.
|
|
|
548
543
|
Face counts remain approximate, especially with locked borders or dense geometric
|
|
549
544
|
constraints. Local cleanup and bounded integer correction do not establish global
|
|
550
545
|
integrability or intersection freedom on arbitrary surfaces. Scalar/SIMD parity is
|
|
551
|
-
tested on the regression corpus, not an exhaustive operating-system/compiler matrix.
|
|
552
|
-
acceptance, scalar/SIMD comparisons and remaining limits are in [BENCH.md](https://github.com/topotopo-dev/topotopo/blob/main/kernels/BENCH.md).
|
|
546
|
+
tested on the regression corpus, not an exhaustive operating-system/compiler matrix.
|
|
553
547
|
|
|
554
548
|
Run `node test/remeshquad.ts`, `node bench/remeshquad.ts` and
|
|
555
549
|
`cargo bench --manifest-path kernels/Cargo.toml --bench remesh_quad`.
|
|
556
550
|
Inspect `examples/renders/quad_remesh.png`: gray inputs and colored results for a
|
|
557
551
|
noisy sphere, bevelled box, shelf rock and capped tube, with every polygon edge visible.
|
|
558
552
|
|
|
559
|
-
## Sampled SDF grids
|
|
553
|
+
## Sampled SDF grids
|
|
560
554
|
|
|
561
555
|
The original skeleton API is unchanged. Additional generated WASM exports are:
|
|
562
556
|
|
|
@@ -628,9 +622,9 @@ Ambiguous topology and unsafe sharp fits trigger local conservative patches. Sha
|
|
|
628
622
|
face connectors make the transition conforming, without unmatched edges or T-junctions.
|
|
629
623
|
These guards detect risky local configurations, not every possible geometric
|
|
630
624
|
self-intersection. Runtime validation checks oriented edge incidence; the test corpus
|
|
631
|
-
also checks vertex links and proper nonadjacent triangle crossings.
|
|
632
|
-
|
|
633
|
-
The explicit `conservative=true` path retains the
|
|
625
|
+
also checks vertex links and proper nonadjacent triangle crossings. Union junctions
|
|
626
|
+
remain less accurate (about 0.4 voxel).
|
|
627
|
+
The explicit `conservative=true` path retains the original minmod gradients and
|
|
634
628
|
cell-local fans byte-for-byte. Signed negative zero at iso zero retains inside sign.
|
|
635
629
|
Unclamped QEF fits are accepted only when they stay in their cells; otherwise the
|
|
636
630
|
caller gets a clear enable-clamping error. The construction follows the uniform
|
|
@@ -673,5 +667,4 @@ existing `remesh` node and its `remesh_voxel` alias retain their old behavior.
|
|
|
673
667
|
Run `node test/sdfgrid.ts` for Node integration, `node bench/sdfgrid.ts` for the 256³
|
|
674
668
|
box benchmark, and inspect `examples/renders/voxel_remesh.png` (sharp left, smooth
|
|
675
669
|
middle, dilate/erode/blur right). Existing goldens and render hashes are checked
|
|
676
|
-
separately from the new example.
|
|
677
|
-
[BENCH.md](https://github.com/topotopo-dev/topotopo/blob/main/kernels/BENCH.md).
|
|
670
|
+
separately from the new example.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "topotopo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "An open-source procedural geometry engine: node graphs in JSON, cooked headless and deterministic, exported to Unreal, Blender and Houdini. Built for LLM agents through MCP, and for people through the CLI.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"mcp": "node src/mcp/server.ts",
|
|
39
39
|
"preview": "node scripts/preview.ts --examples",
|
|
40
40
|
"cook": "node src/cli.ts",
|
|
41
|
-
"test": "node test/smoke.ts && node test/golden.ts && node test/property.ts && node test/fuzz.ts && node test/docs.ts && node test/portability.ts && node test/examples.ts && node scripts/gen-notice.ts --check && node test/io.ts && node test/import.ts && node test/interop.ts && node test/mcp.ts && node test/engine.ts && node test/viewer.ts && node test/viewer-logic.ts && node test/topology.ts && node test/deform.ts && node test/cloth.ts && node test/arrays.ts && node test/bugs.ts && node test/uv.ts && node test/polyedit.ts && node test/bevel.ts && node test/measure.ts && node test/render.ts && node test/packed.ts && node test/heightfield.ts && node test/remesh.ts && node test/pcg.ts && node test/scatterkernel.ts && node test/splines.ts && node test/shelf.ts && node test/textures.ts && node test/pool.ts && node test/kernelsloader.ts && node test/kernels.ts && node test/sdfgrid.ts && node test/remeshquad.ts && node test/erosionkernel.ts && node test/erosionsimd.ts && node test/particles.ts && node test/rbd.ts && node test/limits.ts && node test/viewer-outputs.ts",
|
|
41
|
+
"test": "node test/smoke.ts && node test/golden.ts && node test/property.ts && node test/fuzz.ts && node test/docs.ts && node test/portability.ts && node test/examples.ts && node scripts/gen-notice.ts --check && node test/io.ts && node test/import.ts && node test/interop.ts && node test/mcp.ts && node test/engine.ts && node test/viewer.ts && node test/viewer-logic.ts && node test/topology.ts && node test/deform.ts && node test/cloth.ts && node test/arrays.ts && node test/bugs.ts && node test/uv.ts && node test/polyedit.ts && node test/bevel.ts && node test/measure.ts && node test/render.ts && node test/packed.ts && node test/heightfield.ts && node test/remesh.ts && node test/pcg.ts && node test/scatterkernel.ts && node test/splines.ts && node test/shelf.ts && node test/textures.ts && node test/imageops.ts && node test/pool.ts && node test/kernelsloader.ts && node test/kernels.ts && node test/sdfgrid.ts && node test/remeshquad.ts && node test/erosionkernel.ts && node test/erosionsimd.ts && node test/particles.ts && node test/rbd.ts && node test/limits.ts && node test/viewer-outputs.ts && node test/library.ts && node test/gallery.ts && node test/tangents.ts && node test/pbr.ts && node test/sockets.ts && node test/uvreport.ts && node test/solidify.ts",
|
|
42
42
|
"test:limits": "node test/limits.ts",
|
|
43
43
|
"kernels:build": "node scripts/kernels-build.ts",
|
|
44
44
|
"test:kernels": "node test/scatterkernel.ts && node test/kernelsloader.ts && node test/kernels.ts && node test/sdfgrid.ts && node test/remeshquad.ts && node test/erosionkernel.ts && node test/erosionsimd.ts",
|
|
@@ -48,13 +48,18 @@
|
|
|
48
48
|
"test:pool": "node test/pool.ts --golden",
|
|
49
49
|
"test:particles": "node test/particles.ts",
|
|
50
50
|
"test:splines": "node test/splines.ts",
|
|
51
|
-
"test:uv": "node test/uv.ts",
|
|
51
|
+
"test:uv": "node test/uv.ts && node test/uvreport.ts",
|
|
52
|
+
"test:tangents": "node test/tangents.ts",
|
|
53
|
+
"test:sockets": "node test/sockets.ts",
|
|
54
|
+
"test:solidify": "node test/solidify.ts",
|
|
52
55
|
"test:render": "node test/render.ts",
|
|
56
|
+
"test:pbr": "node test/pbr.ts",
|
|
53
57
|
"test:remesh": "node test/remesh.ts",
|
|
54
58
|
"test:pcg": "node test/pcg.ts",
|
|
55
59
|
"test:cloth": "node test/cloth.ts",
|
|
56
60
|
"test:shelf": "node test/shelf.ts",
|
|
57
61
|
"test:textures": "node test/textures.ts",
|
|
62
|
+
"test:imageops": "node test/imageops.ts",
|
|
58
63
|
"test:smoke": "node test/smoke.ts",
|
|
59
64
|
"test:golden": "node test/golden.ts",
|
|
60
65
|
"test:update": "node test/golden.ts --update",
|
|
@@ -63,6 +68,7 @@
|
|
|
63
68
|
"test:portability": "node test/portability.ts",
|
|
64
69
|
"test:examples": "node test/examples.ts",
|
|
65
70
|
"test:interop": "node test/interop.ts",
|
|
71
|
+
"test:gallery": "node test/library.ts && node test/gallery.ts",
|
|
66
72
|
"test:viewer": "node test/viewer.ts && node test/viewer-logic.ts && node test/viewer-outputs.ts",
|
|
67
73
|
"showcase": "node test/showcase.ts",
|
|
68
74
|
"export:demo": "node scripts/export-demo.ts",
|