topotopo 0.3.0 → 0.5.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 +40 -10
- package/README.md +475 -111
- package/dist/cli.js +328 -133
- package/dist/config.d.ts +48 -0
- package/dist/config.js +170 -0
- package/dist/core/analysis.d.ts +5 -1
- package/dist/core/analysis.js +8 -3
- package/dist/core/bake.d.ts +16 -8
- package/dist/core/bake.js +165 -29
- package/dist/core/bevel.d.ts +3 -1
- package/dist/core/bevel.js +238 -97
- package/dist/core/decimate.d.ts +65 -0
- package/dist/core/decimate.js +409 -3
- package/dist/core/erosion.d.ts +37 -0
- package/dist/core/erosion.js +41 -1
- package/dist/core/geometry.d.ts +5 -1
- package/dist/core/geometry.js +204 -4
- package/dist/core/heightfield.d.ts +27 -4
- package/dist/core/heightfield.js +54 -16
- package/dist/core/imageops.d.ts +6 -0
- package/dist/core/imageops.js +51 -0
- package/dist/core/intrinsics.d.ts +7 -0
- package/dist/core/intrinsics.js +94 -0
- package/dist/core/manifold.d.ts +12 -1
- package/dist/core/manifold.js +78 -6
- package/dist/core/materials.d.ts +11 -0
- package/dist/core/materials.js +56 -0
- package/dist/core/noise.d.ts +9 -0
- package/dist/core/noise.js +10 -1
- 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/polymerge.d.ts +21 -0
- package/dist/core/polymerge.js +327 -0
- package/dist/core/rbd.js +13 -1
- package/dist/core/repair.d.ts +2 -0
- package/dist/core/repair.js +2 -0
- package/dist/core/report.d.ts +70 -0
- package/dist/core/report.js +275 -0
- 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 +72 -0
- package/dist/core/sha256.d.ts +4 -0
- package/dist/core/sha256.js +69 -0
- package/dist/core/shapes.d.ts +3 -0
- package/dist/core/shapes.js +34 -0
- package/dist/core/snippet-lib.d.ts +15 -2
- package/dist/core/snippet-lib.js +40 -14
- package/dist/core/solidify.d.ts +38 -0
- package/dist/core/solidify.js +356 -0
- package/dist/core/tangents.d.ts +54 -0
- package/dist/core/tangents.js +218 -0
- package/dist/core/texcoord.d.ts +4 -0
- package/dist/core/texcoord.js +14 -0
- package/dist/core/texnoise.d.ts +6 -1
- package/dist/core/texnoise.js +6 -2
- package/dist/core/texsdf.d.ts +131 -0
- package/dist/core/texsdf.js +637 -0
- package/dist/core/texture.d.ts +163 -9
- package/dist/core/texture.js +844 -20
- package/dist/core/topology.d.ts +32 -0
- package/dist/core/topology.js +238 -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/unwrap.d.ts +72 -0
- package/dist/core/unwrap.js +800 -0
- package/dist/core/usercode.d.ts +27 -0
- package/dist/core/usercode.js +87 -0
- package/dist/core/uv.d.ts +15 -16
- package/dist/core/uv.js +36 -189
- package/dist/core/uvislands.d.ts +62 -0
- package/dist/core/uvislands.js +574 -0
- package/dist/core/uvoverlap.d.ts +58 -0
- package/dist/core/uvoverlap.js +220 -0
- package/dist/core/uvpack.d.ts +64 -0
- package/dist/core/uvpack.js +628 -0
- package/dist/core/uvreport.d.ts +127 -0
- package/dist/core/uvreport.js +372 -0
- package/dist/core/wrangle.d.ts +6 -1
- package/dist/core/wrangle.js +27 -16
- package/dist/core/xatlas.d.ts +16 -1
- package/dist/core/xatlas.js +95 -61
- package/dist/engines.d.ts +63 -0
- package/dist/engines.js +180 -0
- package/dist/explain.d.ts +4 -3
- package/dist/explain.js +129 -12
- package/dist/graph/engine.d.ts +92 -29
- package/dist/graph/engine.js +298 -148
- package/dist/graph/expr.d.ts +6 -3
- package/dist/graph/expr.js +18 -8
- package/dist/graph/outputs.d.ts +23 -0
- package/dist/graph/outputs.js +41 -0
- package/dist/graph/packages.d.ts +72 -0
- package/dist/graph/packages.js +261 -0
- package/dist/graph/parallel.d.ts +3 -1
- package/dist/graph/parallel.js +4 -1
- package/dist/graph/params.d.ts +6 -0
- package/dist/graph/params.js +34 -7
- package/dist/graph/scope.d.ts +55 -0
- package/dist/graph/scope.js +14 -0
- package/dist/graph/types.d.ts +75 -12
- package/dist/graph/types.js +4 -2
- package/dist/graph/vars.d.ts +16 -0
- package/dist/graph/vars.js +80 -0
- package/dist/host/artifacts.d.ts +10 -1
- package/dist/host/artifacts.js +37 -6
- package/dist/host/cook.d.ts +241 -0
- package/dist/host/cook.js +844 -0
- package/dist/host/export-targets.d.ts +42 -5
- package/dist/host/export-targets.js +72 -13
- package/dist/host/godot-commands.d.ts +4 -0
- package/dist/host/godot-commands.js +21 -0
- package/dist/host/godot.d.ts +183 -0
- package/dist/host/godot.js +916 -0
- package/dist/host/node.d.ts +12 -7
- package/dist/host/node.js +27 -9
- package/dist/host/pool.js +51 -2
- package/dist/host/sidecars.d.ts +8 -0
- package/dist/host/sidecars.js +50 -0
- package/dist/host/types.d.ts +19 -6
- package/dist/host/version.d.ts +1 -0
- package/dist/host/version.js +3 -0
- package/dist/host/worker.js +5 -2
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -2
- package/dist/inspect.d.ts +84 -1
- package/dist/inspect.js +271 -24
- package/dist/io/common.d.ts +33 -5
- package/dist/io/export.js +2 -1
- package/dist/io/files.d.ts +23 -4
- package/dist/io/files.js +60 -8
- package/dist/io/gltf.js +355 -51
- package/dist/io/heightmap.d.ts +3 -0
- package/dist/io/heightmap.js +1 -0
- package/dist/io/import.js +10 -0
- package/dist/io/inspect-scene.d.ts +55 -0
- package/dist/io/inspect-scene.js +155 -0
- package/dist/io/kinds.d.ts +81 -0
- package/dist/io/kinds.js +163 -0
- package/dist/io/points.d.ts +2 -1
- package/dist/io/points.js +3 -1
- package/dist/io/sidecars.d.ts +24 -0
- package/dist/io/sidecars.js +57 -0
- package/dist/io/source.d.ts +65 -0
- package/dist/io/source.js +112 -0
- package/dist/io/targets.d.ts +47 -3
- package/dist/io/targets.js +149 -14
- package/dist/io/textures.js +21 -1
- package/dist/io/unreal.js +5 -1
- package/dist/mcp/docs.d.ts +10 -1
- package/dist/mcp/docs.js +816 -119
- package/dist/mcp/inputs.d.ts +12 -5
- package/dist/mcp/inputs.js +50 -13
- package/dist/mcp/server.js +70 -24
- package/dist/mcp/tools.d.ts +14 -7
- package/dist/mcp/tools.js +207 -108
- package/dist/mcp/verify.d.ts +2 -2
- package/dist/mcp/verify.js +1 -1
- package/dist/mcp/workspace.d.ts +15 -0
- package/dist/mcp/workspace.js +349 -0
- package/dist/nodes/attributes.js +198 -1
- package/dist/nodes/bake.js +207 -83
- package/dist/nodes/beam.d.ts +1 -0
- package/dist/nodes/beam.js +201 -0
- package/dist/nodes/bevel.js +54 -5
- package/dist/nodes/cloth.js +2 -0
- package/dist/nodes/code.js +22 -10
- package/dist/nodes/curves.js +440 -93
- package/dist/nodes/flow.js +53 -33
- package/dist/nodes/generate.js +13 -39
- package/dist/nodes/heightfield.js +248 -77
- package/dist/nodes/imageops.d.ts +1 -0
- package/dist/nodes/imageops.js +203 -0
- package/dist/nodes/index.d.ts +4 -0
- package/dist/nodes/index.js +4 -0
- package/dist/nodes/material.js +91 -23
- package/dist/nodes/measure.js +45 -18
- package/dist/nodes/particles.js +2 -0
- package/dist/nodes/pcg.js +6 -5
- package/dist/nodes/procedural.js +4 -3
- package/dist/nodes/rbd.js +1 -1
- package/dist/nodes/remesh.js +71 -15
- package/dist/nodes/scene.d.ts +1 -0
- package/dist/nodes/scene.js +55 -0
- package/dist/nodes/sdf.js +10 -5
- package/dist/nodes/solid.js +20 -5
- package/dist/nodes/solidify.d.ts +1 -0
- package/dist/nodes/solidify.js +52 -0
- package/dist/nodes/splines.d.ts +15 -1
- package/dist/nodes/splines.js +112 -105
- package/dist/nodes/texture.d.ts +21 -6
- package/dist/nodes/texture.js +1318 -185
- package/dist/nodes/topology.d.ts +7 -0
- package/dist/nodes/topology.js +133 -6
- package/dist/nodes/transform.js +11 -3
- package/dist/nodes/util.d.ts +1 -1
- package/dist/nodes/uv.js +192 -174
- package/dist/nodes/wasmcall.js +6 -2
- package/dist/open.d.ts +19 -0
- package/dist/open.js +12 -0
- package/dist/package.d.ts +288 -0
- package/dist/package.js +772 -0
- package/dist/packages/check.d.ts +32 -0
- package/dist/packages/check.js +169 -0
- package/dist/packages/commands.d.ts +57 -0
- package/dist/packages/commands.js +537 -0
- package/dist/packages/registry.d.ts +796 -0
- package/dist/packages/registry.js +2998 -0
- package/dist/packages/update.d.ts +124 -0
- package/dist/packages/update.js +476 -0
- package/dist/render/options.d.ts +2 -0
- package/dist/render/options.js +44 -5
- package/dist/render/pbr.d.ts +28 -0
- package/dist/render/pbr.js +378 -0
- package/dist/render/preview.d.ts +69 -0
- package/dist/render/preview.js +26 -0
- package/dist/render/raster.d.ts +78 -7
- package/dist/render/raster.js +600 -145
- package/dist/render/texview.d.ts +7 -1
- package/dist/render/texview.js +34 -2
- package/dist/scan.d.ts +61 -0
- package/dist/scan.js +228 -0
- package/dist/session.d.ts +311 -0
- package/dist/session.js +849 -0
- package/dist/viewer/app/api.js +48 -6
- package/dist/viewer/app/camera.js +1 -1
- package/dist/viewer/app/cooking.js +78 -0
- package/dist/viewer/app/embed.js +100 -0
- package/dist/viewer/app/export-popover.js +118 -16
- package/dist/viewer/app/grid.js +6 -2
- package/dist/viewer/app/guides.js +123 -1
- package/dist/viewer/app/keymap.js +7 -4
- package/dist/viewer/app/layers.js +5 -5
- package/dist/viewer/app/main.js +186 -53
- package/dist/viewer/app/markers.js +61 -1
- package/dist/viewer/app/outliner.js +72 -27
- package/dist/viewer/app/output-info.js +45 -0
- package/dist/viewer/app/outputs.css +147 -8
- package/dist/viewer/app/outputs.js +168 -54
- package/dist/viewer/app/packages.js +614 -0
- package/dist/viewer/app/props.js +177 -53
- package/dist/viewer/app/scene.js +35 -6
- package/dist/viewer/app/select.js +5 -4
- package/dist/viewer/app/selection.js +1 -1
- package/dist/viewer/app/status.js +12 -15
- package/dist/viewer/app/style.css +66 -8
- package/dist/viewer/app/units.js +1 -1
- package/dist/viewer/app/vars.js +48 -1
- package/dist/viewer/app/welcome.js +72 -0
- package/dist/viewer/graph-file.d.ts +62 -0
- package/dist/viewer/graph-file.js +175 -0
- package/dist/viewer/index.html +24 -11
- package/dist/viewer/json-edit.d.ts +13 -0
- package/dist/viewer/json-edit.js +274 -0
- package/dist/viewer/outputs.d.ts +49 -5
- package/dist/viewer/outputs.js +264 -56
- package/dist/viewer/packages.d.ts +121 -0
- package/dist/viewer/packages.js +584 -0
- package/dist/viewer/server.d.ts +24 -7
- package/dist/viewer/server.js +289 -31
- package/dist/web/app/web.css +419 -0
- package/dist/web/app/web.js +188 -0
- package/dist/web/bake.d.ts +34 -0
- package/dist/web/bake.js +153 -0
- package/dist/web/folder-page.d.ts +101 -0
- package/dist/web/folder-page.js +146 -0
- package/dist/web/folders.d.ts +280 -0
- package/dist/web/folders.js +970 -0
- package/dist/web/library.d.ts +91 -0
- package/dist/web/library.js +228 -0
- package/dist/web/markdown.d.ts +45 -0
- package/dist/web/markdown.js +677 -0
- package/dist/web/pages.d.ts +258 -0
- package/dist/web/pages.js +301 -0
- package/dist/web/server.d.ts +24 -0
- package/dist/web/server.js +1068 -0
- package/dist/workspace.d.ts +88 -105
- package/dist/workspace.js +359 -375
- package/integrations/godot/addons/topotopo/LICENSE +202 -0
- package/integrations/godot/addons/topotopo/README.md +57 -0
- package/integrations/godot/addons/topotopo/context_menu.gd +43 -0
- package/integrations/godot/addons/topotopo/dock.gd +266 -0
- package/integrations/godot/addons/topotopo/dock.tscn +72 -0
- package/integrations/godot/addons/topotopo/export_filter.gd +72 -0
- package/integrations/godot/addons/topotopo/gltf_instancing.gd +131 -0
- package/integrations/godot/addons/topotopo/icons/topotopo.svg +1 -0
- package/integrations/godot/addons/topotopo/inspector.gd +38 -0
- package/integrations/godot/addons/topotopo/instances_post_import.gd +111 -0
- package/integrations/godot/addons/topotopo/package.gd +23 -0
- package/integrations/godot/addons/topotopo/package_importer.gd +187 -0
- package/integrations/godot/addons/topotopo/plugin.cfg +7 -0
- package/integrations/godot/addons/topotopo/plugin.gd +970 -0
- package/integrations/godot/addons/topotopo/record.gd +435 -0
- package/integrations/godot/addons/topotopo/runner.gd +458 -0
- package/integrations/godot/addons/topotopo/tools/check.gd +42 -0
- package/integrations/godot/addons/topotopo/watcher.gd +199 -0
- package/kernels/pkg/README.md +23 -29
- package/kernels/pkg-simd/README.md +23 -29
- package/library/architecture/versions/1.0/architecture.topo +12 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/arch.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/beam_truss.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/brick_wall.json +8 -8
- package/{shelf → library/architecture/versions/1.0/graphs}/door_frame.json +3 -3
- package/{shelf → library/architecture/versions/1.0/graphs}/hex_grid_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/house.json +8 -8
- package/library/architecture/versions/1.0/graphs/lineup.json +42 -0
- package/{shelf → library/architecture/versions/1.0/graphs}/pillar.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/railing.json +5 -5
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_gable.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_hip.json +2 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/roof_skeleton.json +2 -1
- package/{shelf → library/architecture/versions/1.0/graphs}/scaffold.json +4 -4
- package/{shelf → library/architecture/versions/1.0/graphs}/spiral_stairs.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/stairs.json +6 -6
- package/{shelf → library/architecture/versions/1.0/graphs}/tile_floor.json +3 -2
- package/{shelf → library/architecture/versions/1.0/graphs}/wall_segment.json +10 -10
- package/{shelf → library/architecture/versions/1.0/graphs}/window_frame.json +2 -2
- package/library/architecture/versions/1.0/version.json +1119 -0
- package/{shelf → library/nature/versions/1.0/graphs}/bush.json +2 -2
- package/{shelf → library/nature/versions/1.0/graphs}/cliff_block.json +4 -3
- package/{shelf → library/nature/versions/1.0/graphs}/forest_patch.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/grass_clumps.json +2 -2
- package/library/nature/versions/1.0/graphs/lineup.json +24 -0
- package/{shelf → library/nature/versions/1.0/graphs}/log.json +6 -6
- package/{shelf → library/nature/versions/1.0/graphs}/rock.json +5 -4
- package/{shelf → library/nature/versions/1.0/graphs}/scatter_rocks.json +5 -5
- package/{shelf → library/nature/versions/1.0/graphs}/tree_lowpoly.json +3 -2
- package/library/nature/versions/1.0/nature.topo +12 -0
- package/library/nature/versions/1.0/version.json +534 -0
- package/{shelf → library/props/versions/1.0/graphs}/barrel.json +5 -4
- package/{shelf → library/props/versions/1.0/graphs}/crate.json +3 -3
- package/library/props/versions/1.0/graphs/lineup.json +18 -0
- package/{shelf → library/props/versions/1.0/graphs}/pallet.json +4 -3
- package/{shelf → library/props/versions/1.0/graphs}/pipe_run.json +3 -3
- package/{shelf → library/props/versions/1.0/graphs}/sandbag_wall.json +5 -5
- package/library/props/versions/1.0/props.topo +12 -0
- package/library/props/versions/1.0/version.json +336 -0
- package/{shelf → library/street/versions/1.0/graphs}/bench.json +5 -5
- package/{shelf → library/street/versions/1.0/graphs}/bollard.json +2 -1
- package/{shelf → library/street/versions/1.0/graphs}/cable.json +4 -4
- package/{shelf → library/street/versions/1.0/graphs}/fence.json +7 -7
- package/{shelf → library/street/versions/1.0/graphs}/lamp_post.json +2 -2
- package/library/street/versions/1.0/graphs/lineup.json +22 -0
- package/{shelf → library/street/versions/1.0/graphs}/road_strip.json +2 -2
- package/{shelf → library/street/versions/1.0/graphs}/sign_post.json +1 -1
- package/library/street/versions/1.0/street.topo +12 -0
- package/library/street/versions/1.0/version.json +421 -0
- package/package.json +23 -8
- package/dist/graph/migrate.d.ts +0 -23
- package/dist/graph/migrate.js +0 -58
- package/shelf/index.json +0 -190
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
let mod = null;
|
|
10
|
+
let loading = null;
|
|
11
|
+
/** Load (once) and initialise the MikkTSpace WebAssembly module. */
|
|
12
|
+
export async function loadMikkTSpace() {
|
|
13
|
+
if (mod)
|
|
14
|
+
return;
|
|
15
|
+
if (!loading) {
|
|
16
|
+
loading = (async () => {
|
|
17
|
+
const spec = 'three/examples/jsm/libs/mikktspace.module.js';
|
|
18
|
+
const m = await import(__rewriteRelativeImportExtension(spec));
|
|
19
|
+
await m.ready;
|
|
20
|
+
return m;
|
|
21
|
+
})();
|
|
22
|
+
loading.catch(() => { loading = null; });
|
|
23
|
+
}
|
|
24
|
+
mod = await loading;
|
|
25
|
+
}
|
|
26
|
+
/** True once loadMikkTSpace() has finished. */
|
|
27
|
+
export const mikkTSpaceReady = () => mod !== null;
|
|
28
|
+
/** uv triangles whose doubled area is below this fraction of their squared edge lengths are collapsed. */
|
|
29
|
+
const UV_DEGENERATE = 1e-9;
|
|
30
|
+
/**
|
|
31
|
+
* MikkTSpace tangents for a triangle soup: pos and nrm 9 floats per triangle, uv 6 (TopoTopo convention). Returns 12
|
|
32
|
+
* floats per triangle: xyz unit tangent and w = ±1 (bitangent = w · cross(N, T)). Throws when the module is not
|
|
33
|
+
* loaded.
|
|
34
|
+
*/
|
|
35
|
+
export function mikkTangents(pos, nrm, uv) {
|
|
36
|
+
if (!mod)
|
|
37
|
+
throw new Error('MikkTSpace is not loaded: await loadMikkTSpace() first (exportGLB, renderPBR and bake_normal do)');
|
|
38
|
+
const nt = Math.floor(pos.length / 9);
|
|
39
|
+
const diag = { triangles: nt, uvNonFinite: 0, uvDegenerate: 0, fallbackCorners: 0, firstBad: -1 };
|
|
40
|
+
const bad = new Uint8Array(nt);
|
|
41
|
+
const P = Float32Array.from(pos), N = Float32Array.from(nrm), T = Float32Array.from(uv);
|
|
42
|
+
for (let t = 0; t < nt; t++) {
|
|
43
|
+
let finite = true;
|
|
44
|
+
for (let k = 0; k < 6; k++)
|
|
45
|
+
if (!Number.isFinite(T[t * 6 + k])) {
|
|
46
|
+
finite = false;
|
|
47
|
+
T[t * 6 + k] = 0;
|
|
48
|
+
}
|
|
49
|
+
if (!finite) {
|
|
50
|
+
diag.uvNonFinite++;
|
|
51
|
+
bad[t] = 1;
|
|
52
|
+
if (diag.firstBad < 0)
|
|
53
|
+
diag.firstBad = t;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const u0 = T[t * 6], v0 = T[t * 6 + 1], du1 = T[t * 6 + 2] - u0, dv1 = T[t * 6 + 3] - v0, du2 = T[t * 6 + 4] - u0, dv2 = T[t * 6 + 5] - v0;
|
|
57
|
+
const e2 = du1 * du1 + dv1 * dv1 + du2 * du2 + dv2 * dv2 + (du2 - du1) ** 2 + (dv2 - dv1) ** 2;
|
|
58
|
+
if (!(Math.abs(du1 * dv2 - du2 * dv1) > UV_DEGENERATE * e2)) {
|
|
59
|
+
diag.uvDegenerate++;
|
|
60
|
+
bad[t] = 1;
|
|
61
|
+
if (diag.firstBad < 0)
|
|
62
|
+
diag.firstBad = t;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
for (let i = 0; i < N.length; i += 3) {
|
|
66
|
+
const l = Math.hypot(N[i], N[i + 1], N[i + 2]);
|
|
67
|
+
if (l > 0 && Number.isFinite(l)) {
|
|
68
|
+
N[i] /= l;
|
|
69
|
+
N[i + 1] /= l;
|
|
70
|
+
N[i + 2] /= l;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
N[i] = 0;
|
|
74
|
+
N[i + 1] = 0;
|
|
75
|
+
N[i + 2] = 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const out = nt ? mod.generateTangents(P, N, T) : new Float32Array(0);
|
|
79
|
+
for (let t = 0; t < nt; t++)
|
|
80
|
+
for (let k = 0; k < 3; k++) {
|
|
81
|
+
const c = t * 3 + k, o = c * 4, n = c * 3;
|
|
82
|
+
let x = out[o], y = out[o + 1], z = out[o + 2];
|
|
83
|
+
const nx = N[n], ny = N[n + 1], nz = N[n + 2];
|
|
84
|
+
// keep it exactly perpendicular to the (normalised, float) normal the consumer will see
|
|
85
|
+
const d = x * nx + y * ny + z * nz;
|
|
86
|
+
x -= nx * d;
|
|
87
|
+
y -= ny * d;
|
|
88
|
+
z -= nz * d;
|
|
89
|
+
const l = Math.hypot(x, y, z), w = out[o + 3];
|
|
90
|
+
if (!bad[t] && l > 1e-6 && Number.isFinite(l) && (w === 1 || w === -1)) {
|
|
91
|
+
out[o] = x / l;
|
|
92
|
+
out[o + 1] = y / l;
|
|
93
|
+
out[o + 2] = z / l;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
diag.fallbackCorners++;
|
|
97
|
+
// the world axis least aligned with N, made perpendicular to it
|
|
98
|
+
const ax = Math.abs(nx), ay = Math.abs(ny), az = Math.abs(nz);
|
|
99
|
+
const a = ax <= ay && ax <= az ? [1, 0, 0] : ay <= az ? [0, 1, 0] : [0, 0, 1];
|
|
100
|
+
const e = a[0] * nx + a[1] * ny + a[2] * nz;
|
|
101
|
+
const fx = a[0] - nx * e, fy = a[1] - ny * e, fz = a[2] - nz * e, fl = Math.hypot(fx, fy, fz);
|
|
102
|
+
out[o] = fx / fl;
|
|
103
|
+
out[o + 1] = fy / fl;
|
|
104
|
+
out[o + 2] = fz / fl;
|
|
105
|
+
out[o + 3] = 1;
|
|
106
|
+
}
|
|
107
|
+
return { tangents: out, diag };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* MikkTSpace tangents for the triangles `tris` (vertex indices, as topology.triangulate returns them) of g, with the
|
|
111
|
+
* per-vertex normals N (3 per vertex, e.g. resolveVertexNormals) and per-vertex uv (2 per vertex, TopoTopo
|
|
112
|
+
* convention). 12 floats per triangle, in g's space.
|
|
113
|
+
*/
|
|
114
|
+
export function cornerTangents(g, tris, N, uv) {
|
|
115
|
+
const nc = tris.length, P = g.P, vp = g.vertexPoint;
|
|
116
|
+
const pos = new Float32Array(nc * 3), nrm = new Float32Array(nc * 3), tex = new Float32Array(nc * 2);
|
|
117
|
+
for (let c = 0; c < nc; c++) {
|
|
118
|
+
const v = tris[c], p = vp[v] * 3;
|
|
119
|
+
pos[c * 3] = P[p];
|
|
120
|
+
pos[c * 3 + 1] = P[p + 1];
|
|
121
|
+
pos[c * 3 + 2] = P[p + 2];
|
|
122
|
+
nrm[c * 3] = N[v * 3];
|
|
123
|
+
nrm[c * 3 + 1] = N[v * 3 + 1];
|
|
124
|
+
nrm[c * 3 + 2] = N[v * 3 + 2];
|
|
125
|
+
tex[c * 2] = uv[v * 2];
|
|
126
|
+
tex[c * 2 + 1] = uv[v * 2 + 1];
|
|
127
|
+
}
|
|
128
|
+
return mikkTangents(pos, nrm, tex);
|
|
129
|
+
}
|
|
130
|
+
/** Per-vertex uv (2 per vertex) of a vertex or point attribute, or null when g has no such float attribute. */
|
|
131
|
+
export function vertexUV(g, name = 'uv') {
|
|
132
|
+
const f = g.findAttrib(name, ['vertex', 'point']);
|
|
133
|
+
if (!f || f.attr.type !== 'float' || f.attr.isArray)
|
|
134
|
+
return null;
|
|
135
|
+
const a = f.attr, d = a.data, s = a.size;
|
|
136
|
+
const out = new Float64Array(g.numVertices * 2);
|
|
137
|
+
for (let v = 0; v < g.numVertices; v++) {
|
|
138
|
+
const i = (f.cls === 'vertex' ? v : g.vertexPoint[v]) * s;
|
|
139
|
+
out[v * 2] = d[i];
|
|
140
|
+
out[v * 2 + 1] = s > 1 ? d[i + 1] : 0;
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The orthonormal shading frame at a surface sample, as bake_normal writes and the PBR preview reads it: N normalised,
|
|
146
|
+
* T = the interpolated tangent made perpendicular to N and normalised, B = w · cross(N, T) with w the sign of the
|
|
147
|
+
* interpolated handedness. Fills out[0..8] with T, B, N; returns false (out untouched) when T is parallel to N.
|
|
148
|
+
*/
|
|
149
|
+
export function shadingFrame(nx, ny, nz, tx, ty, tz, w, out) {
|
|
150
|
+
const nl = Math.hypot(nx, ny, nz);
|
|
151
|
+
if (!(nl > 0))
|
|
152
|
+
return false;
|
|
153
|
+
nx /= nl;
|
|
154
|
+
ny /= nl;
|
|
155
|
+
nz /= nl;
|
|
156
|
+
const d = tx * nx + ty * ny + tz * nz;
|
|
157
|
+
tx -= nx * d;
|
|
158
|
+
ty -= ny * d;
|
|
159
|
+
tz -= nz * d;
|
|
160
|
+
const tl = Math.hypot(tx, ty, tz);
|
|
161
|
+
if (!(tl > 1e-12))
|
|
162
|
+
return false;
|
|
163
|
+
tx /= tl;
|
|
164
|
+
ty /= tl;
|
|
165
|
+
tz /= tl;
|
|
166
|
+
const sg = w < 0 ? -1 : 1;
|
|
167
|
+
out[0] = tx;
|
|
168
|
+
out[1] = ty;
|
|
169
|
+
out[2] = tz;
|
|
170
|
+
out[3] = (ny * tz - nz * ty) * sg;
|
|
171
|
+
out[4] = (nz * tx - nx * tz) * sg;
|
|
172
|
+
out[5] = (nx * ty - ny * tx) * sg;
|
|
173
|
+
out[6] = nx;
|
|
174
|
+
out[7] = ny;
|
|
175
|
+
out[8] = nz;
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
/** The standard tangent attribute: float, 4 components (xyz unit tangent, w = ±1 handedness), point or vertex class. */
|
|
179
|
+
export const TANGENT_ATTRIB = 'tangent';
|
|
180
|
+
/**
|
|
181
|
+
* Check a supplied tangent attribute: every element finite, |xyz| within 1e-3 of 1, w exactly ±1. Returns null when
|
|
182
|
+
* valid, else a description of the first problem (element class, index and value).
|
|
183
|
+
*/
|
|
184
|
+
export function tangentProblem(g) {
|
|
185
|
+
const f = g.findAttrib(TANGENT_ATTRIB, ['vertex', 'point']);
|
|
186
|
+
if (!f)
|
|
187
|
+
return null;
|
|
188
|
+
const a = f.attr;
|
|
189
|
+
if (a.type !== 'float' || a.isArray || a.size !== 4)
|
|
190
|
+
return `"${TANGENT_ATTRIB}" is ${a.isArray ? 'an array' : `${a.type}[${a.size}]`}, not float[4]`;
|
|
191
|
+
const d = a.data, n = f.cls === 'vertex' ? g.numVertices : g.numPoints;
|
|
192
|
+
for (let i = 0; i < n; i++) {
|
|
193
|
+
const x = d[i * 4], y = d[i * 4 + 1], z = d[i * 4 + 2], w = d[i * 4 + 3];
|
|
194
|
+
const l = Math.hypot(x, y, z);
|
|
195
|
+
if (!Number.isFinite(l) || Math.abs(l - 1) > 1e-3 || (w !== 1 && w !== -1))
|
|
196
|
+
return `${f.cls} ${i} has tangent (${[x, y, z, w].map((q) => +q.toPrecision(4)).join(', ')}): xyz must be unit length and w ±1`;
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Transform tangent vectors in place by the 3×3 linear part L (column-major, 9 numbers): xyz → normalize(L · xyz),
|
|
202
|
+
* w → w · sign(det L) (a mirror flips the bitangent relative to cross(N, T)). sel limits the elements.
|
|
203
|
+
*/
|
|
204
|
+
export function transformTangents(d, count, L, sel) {
|
|
205
|
+
const det = L[0] * (L[4] * L[8] - L[7] * L[5]) - L[3] * (L[1] * L[8] - L[7] * L[2]) + L[6] * (L[1] * L[5] - L[4] * L[2]);
|
|
206
|
+
const s = det < 0 ? -1 : 1;
|
|
207
|
+
for (let i = 0; i < count; i++) {
|
|
208
|
+
if (sel && !sel(i))
|
|
209
|
+
continue;
|
|
210
|
+
const x = d[i * 4], y = d[i * 4 + 1], z = d[i * 4 + 2];
|
|
211
|
+
const tx = L[0] * x + L[3] * y + L[6] * z, ty = L[1] * x + L[4] * y + L[7] * z, tz = L[2] * x + L[5] * y + L[8] * z;
|
|
212
|
+
const l = Math.hypot(tx, ty, tz) || 1;
|
|
213
|
+
d[i * 4] = tx / l;
|
|
214
|
+
d[i * 4 + 1] = ty / l;
|
|
215
|
+
d[i * 4 + 2] = tz / l;
|
|
216
|
+
d[i * 4 + 3] *= s;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** TopoTopo v ↔ glTF v (the mapping is its own inverse). */
|
|
2
|
+
export declare const gltfV: (v: number) => number;
|
|
3
|
+
/** Continuous image row coordinate (0 = top edge of row 0, h = bottom edge of the last row) of TopoTopo v. */
|
|
4
|
+
export declare const imageRowOfV: (v: number, h: number) => number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Texture coordinate conventions, in one place.
|
|
2
|
+
//
|
|
3
|
+
// TopoTopo (like Houdini and OpenGL): v points up. uv (0, 0) is the bottom-left of an image and (0, 1) its top-left;
|
|
4
|
+
// image row 0 (the first row in memory and in a PNG) is the top, at v = 1.
|
|
5
|
+
// glTF TEXCOORD_n: v points down. (0, 0) is the top-left of the image, so glTF v = 1 - TopoTopo v.
|
|
6
|
+
//
|
|
7
|
+
// Tangent space follows from this. TopoTopo's tangent is dP/du and its bitangent dP/dv points towards image "up",
|
|
8
|
+
// which is the green-up (OpenGL) normal map convention glTF uses. MikkTSpace fed TopoTopo uvs therefore returns the
|
|
9
|
+
// handedness glTF expects (bitangent = w · cross(N, T)) without the sign flip a v-down caller (three.js reading glTF
|
|
10
|
+
// uvs) applies.
|
|
11
|
+
/** TopoTopo v ↔ glTF v (the mapping is its own inverse). */
|
|
12
|
+
export const gltfV = (v) => 1 - v;
|
|
13
|
+
/** Continuous image row coordinate (0 = top edge of row 0, h = bottom edge of the last row) of TopoTopo v. */
|
|
14
|
+
export const imageRowOfV = (v, h) => (1 - v) * h;
|
package/dist/core/texnoise.d.ts
CHANGED
|
@@ -3,13 +3,18 @@ export type Noise2 = (x: number, y: number) => number;
|
|
|
3
3
|
export declare function perlin2(seed: number, px?: number, py?: number): Noise2;
|
|
4
4
|
/** Value noise in [-1, 1], periodic with period (px, py) cells when > 0. */
|
|
5
5
|
export declare function value2(seed: number, px?: number, py?: number): Noise2;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Result of a cellular query: distances to the nearest and second nearest feature point, the nearest cell's hash and
|
|
8
|
+
* (wrapped) lattice cell, and the offset (ex, ey) from the sample to the nearest feature point.
|
|
9
|
+
*/
|
|
7
10
|
export interface CellHit {
|
|
8
11
|
f1: number;
|
|
9
12
|
f2: number;
|
|
10
13
|
id: number;
|
|
11
14
|
cx: number;
|
|
12
15
|
cy: number;
|
|
16
|
+
ex: number;
|
|
17
|
+
ey: number;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* Cellular (Worley) noise: one feature point per lattice cell, jittered by `jitter` (0 = regular grid, 1 = anywhere in
|
package/dist/core/texnoise.js
CHANGED
|
@@ -52,7 +52,7 @@ export function cellular2(seed, px = 0, py = 0, jitter = 1, metric = 0) {
|
|
|
52
52
|
const j = Math.max(0, Math.min(1, jitter));
|
|
53
53
|
return (x, y, out) => {
|
|
54
54
|
const xf = Math.floor(x), yf = Math.floor(y);
|
|
55
|
-
let f1 = Infinity, f2 = Infinity, id = 0, bx = 0, by = 0;
|
|
55
|
+
let f1 = Infinity, f2 = Infinity, id = 0, bx = 0, by = 0, oex = 0, oey = 0;
|
|
56
56
|
for (let dy = -1; dy <= 1; dy++)
|
|
57
57
|
for (let dx = -1; dx <= 1; dx++) {
|
|
58
58
|
const cx = xf + dx, cy = yf + dy;
|
|
@@ -67,6 +67,8 @@ export function cellular2(seed, px = 0, py = 0, jitter = 1, metric = 0) {
|
|
|
67
67
|
id = h;
|
|
68
68
|
bx = wrap(cx, px);
|
|
69
69
|
by = wrap(cy, py);
|
|
70
|
+
oex = ex;
|
|
71
|
+
oey = ey;
|
|
70
72
|
}
|
|
71
73
|
else if (d < f2)
|
|
72
74
|
f2 = d;
|
|
@@ -76,6 +78,8 @@ export function cellular2(seed, px = 0, py = 0, jitter = 1, metric = 0) {
|
|
|
76
78
|
out.id = id;
|
|
77
79
|
out.cx = bx;
|
|
78
80
|
out.cy = by;
|
|
81
|
+
out.ex = oex;
|
|
82
|
+
out.ey = oey;
|
|
79
83
|
return out;
|
|
80
84
|
};
|
|
81
85
|
}
|
|
@@ -225,7 +229,7 @@ export function texNoise(o) {
|
|
|
225
229
|
}
|
|
226
230
|
else if (o.noise === 'worley') {
|
|
227
231
|
const c = cellular2(seed, px, py, o.jitter ?? 1);
|
|
228
|
-
const hit = { f1: 0, f2: 0, id: 0, cx: 0, cy: 0 };
|
|
232
|
+
const hit = { f1: 0, f2: 0, id: 0, cx: 0, cy: 0, ex: 0, ey: 0 };
|
|
229
233
|
fns.push((u, v) => Math.min(1, c(u * fx + ox, v * fy + oy, hit).f1 / 0.85) * 2 - 1);
|
|
230
234
|
}
|
|
231
235
|
else {
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exact Euclidean distance transform of the sites (non-zero entries): d2 = squared distance in pixels to the nearest
|
|
3
|
+
* site, nearest = its index (-1 when there is none). With wrap the image is periodic: each 1D pass runs over three
|
|
4
|
+
* copies of its row or column and keeps the middle one, so the distance is to the nearest periodic copy of a site.
|
|
5
|
+
*/
|
|
6
|
+
export declare function edt(sites: ArrayLike<number>, w: number, h: number, wrap: boolean): {
|
|
7
|
+
d2: Float64Array;
|
|
8
|
+
nearest: Int32Array;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Signed distance in pixels (negative inside, where value ≥ threshold) to the iso-line value = threshold of a grey
|
|
12
|
+
* layer. The line crosses each pair of 4-neighbours on opposite sides at the linearly interpolated point (exact for
|
|
13
|
+
* the one-pixel ramps of antialiased edges and for wider soft ramps); every pixel takes the distance to the nearest
|
|
14
|
+
* crossing, found around the nearest crossing pixel of an exact distance transform. Sub-pixel accurate, so a field
|
|
15
|
+
* measured in metres is the same at any resolution. Without any crossing every pixel is ±(width + height).
|
|
16
|
+
*/
|
|
17
|
+
export declare function signedDistance(a: Float32Array, w: number, h: number, threshold: number, wrap: boolean): Float32Array;
|
|
18
|
+
/** Re-measure an SDF in metres (after booleans or offsets that leave it inexact): the distance to its zero line again. */
|
|
19
|
+
export declare function redistance(d: Float32Array, w: number, h: number, texel: number, wrap: boolean): Float32Array;
|
|
20
|
+
export declare const SDF_SHAPES: string[];
|
|
21
|
+
export interface SdfShapeOptions {
|
|
22
|
+
shape: string;
|
|
23
|
+
/** disc, polygon and star: (outer) radius in metres */
|
|
24
|
+
radius: number;
|
|
25
|
+
/** box: full width and height; capsule: length and thickness; cross: arm length and thickness (metres) */
|
|
26
|
+
extent: [number, number];
|
|
27
|
+
sides: number;
|
|
28
|
+
/** star: inner radius / outer radius */
|
|
29
|
+
inner: number;
|
|
30
|
+
/** box, polygon and cross: corner rounding radius (metres) */
|
|
31
|
+
corner: number;
|
|
32
|
+
/** degrees, counter-clockwise */
|
|
33
|
+
rotation: number;
|
|
34
|
+
/** centre of the shape in each tile's uv (0.5, 0.5 = the middle) */
|
|
35
|
+
center: [number, number];
|
|
36
|
+
/** repeats along u and v */
|
|
37
|
+
tile: [number, number];
|
|
38
|
+
/** metres the image width covers */
|
|
39
|
+
size: number;
|
|
40
|
+
/** the grid of shapes repeats past the borders (distances measured across them) */
|
|
41
|
+
wrap: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The cells around a pixel that its shape can reach, along x and y (the shape's bound over a cell, and one more):
|
|
45
|
+
* every pixel measures (2kx + 1) × (2ky + 1) instances.
|
|
46
|
+
*/
|
|
47
|
+
export declare function shapeReach(o: SdfShapeOptions, w: number, h: number): {
|
|
48
|
+
kx: number;
|
|
49
|
+
ky: number;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Signed distance in metres to a shape, or a tile[0] × tile[1] grid of them, on a w × h image whose width covers
|
|
53
|
+
* `size` metres (y up, the image height covers size · h / w). Each pixel takes the nearest instance among the cells
|
|
54
|
+
* around it (as many as the shape's size reaches), so repeats that overlap their cells union correctly; with wrap
|
|
55
|
+
* the grid continues past the borders and the field tiles.
|
|
56
|
+
*/
|
|
57
|
+
export declare function sdfShape(o: SdfShapeOptions, w: number, h: number): Float32Array;
|
|
58
|
+
export declare const SDF_OPS: string[];
|
|
59
|
+
/**
|
|
60
|
+
* An operation on an SDF in metres:
|
|
61
|
+
* offset grow by amount (negative shrinks): d - amount
|
|
62
|
+
* round round the convex corners by amount: shrink, re-measure, grow back
|
|
63
|
+
* fillet round the concave corners by amount: grow, re-measure, shrink back
|
|
64
|
+
* stroke a band amount wide centred on the outline: |d| - amount / 2
|
|
65
|
+
* invert inside out: -d
|
|
66
|
+
* redistance the distance to the zero line measured again (after smooth booleans or a morph)
|
|
67
|
+
*/
|
|
68
|
+
export declare function sdfOp(d: Float32Array, w: number, h: number, mode: string, amount: number, texel: number, wrap: boolean): Float32Array;
|
|
69
|
+
export declare const SDF_BOOLEANS: string[];
|
|
70
|
+
/** Combine two SDFs (same size, metres): union, subtract (a minus b), intersect, xor, or morph (a → b by t); k = blend width. */
|
|
71
|
+
export declare function sdfBoolean(a: Float32Array, b: Float32Array, mode: string, k: number, t: number): Float32Array;
|
|
72
|
+
export declare const BEVEL_PROFILES: string[];
|
|
73
|
+
/** A bevel profile: t = 0 at the outline … 1 at the full bevel width → height 0 … 1. */
|
|
74
|
+
export declare function profileFn(name: string, ramp?: (t: number) => number): (t: number) => number;
|
|
75
|
+
export declare const SDF_RENDER: string[];
|
|
76
|
+
/**
|
|
77
|
+
* A grey image from an SDF in metres:
|
|
78
|
+
* fill 1 inside, 0 outside; the edge is antialiased over a texel, or a smooth ramp `softness` metres wide
|
|
79
|
+
* outline a line `width` metres wide centred on the outline (softness as for fill)
|
|
80
|
+
* bevel 0 at the outline rising through the profile to 1 at `width` metres inside
|
|
81
|
+
* distance the field encoded for export: 0.5 on the outline, 1 at `width` metres inside, 0 at `width` outside
|
|
82
|
+
*/
|
|
83
|
+
export declare function sdfToMask(d: Float32Array, mode: string, width: number, softness: number, texel: number, profile: (t: number) => number): Float32Array;
|
|
84
|
+
export declare const EDGE_MODES: string[];
|
|
85
|
+
/**
|
|
86
|
+
* A line along an outline from its SDF in metres, `width` metres wide: outline = centred on it, inner = just inside,
|
|
87
|
+
* outer = just outside. roundness 0 = a flat band antialiased over a texel, 1 = a rounded ridge (a quarter circle up
|
|
88
|
+
* from each side of the band, a height for tex_normal_from_height).
|
|
89
|
+
*/
|
|
90
|
+
export declare function edgeBand(d: Float32Array, mode: string, width: number, roundness: number, texel: number): Float32Array;
|
|
91
|
+
/**
|
|
92
|
+
* A bevel height from an SDF in metres: distance > 0 bevels inward (0 on the outline, 1 at `distance` inside),
|
|
93
|
+
* distance < 0 outward (1 inside, falling to 0 at |distance| outside).
|
|
94
|
+
*/
|
|
95
|
+
export declare function bevelHeight(d: Float32Array, distance: number, profile: (t: number) => number, texel: number): Float32Array;
|
|
96
|
+
/**
|
|
97
|
+
* Values of src (ch 1 or 4) carried out from the inside pixels to every pixel within maxPx pixels (each takes the
|
|
98
|
+
* value of its nearest inside pixel; inside pixels keep their own); farther pixels are 0.
|
|
99
|
+
*/
|
|
100
|
+
export declare function propagate(src: Float32Array, ch: number, inside: Uint8Array, w: number, h: number, maxPx: number, wrap: boolean): Float32Array;
|
|
101
|
+
export declare const FLOOD_OUTPUTS: string[];
|
|
102
|
+
export interface FloodOptions {
|
|
103
|
+
threshold: number;
|
|
104
|
+
/** 4 or 8 */
|
|
105
|
+
connectivity: number;
|
|
106
|
+
output: string;
|
|
107
|
+
/** gradient: direction in degrees (0 = along +u) and random spread ± degrees per tile */
|
|
108
|
+
angle: number;
|
|
109
|
+
angleRandom: number;
|
|
110
|
+
seed: number;
|
|
111
|
+
wrap: boolean;
|
|
112
|
+
/** metres per pixel (bbox_size) */
|
|
113
|
+
texel: number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Flood fill: the tiles of a mask (connected pixels with value ≥ threshold; with wrap a tile crossing a border is one
|
|
117
|
+
* tile) and a value per tile in C:
|
|
118
|
+
* random a random grey 0..1 color a random RGB colour (alpha 1 on the tiles, 0 in the gaps)
|
|
119
|
+
* gradient 0 → 1 across the tile along angle (± angleRandom per tile)
|
|
120
|
+
* bbox_size the longer side of the tile's bounding box in metres
|
|
121
|
+
* position the tile's centre as (u, v, 0, 1)
|
|
122
|
+
* id = the random grey of each tile (0 in the gaps). Random values hash the tile's centre (area-weighted with the
|
|
123
|
+
* antialiased edge pixels, snapped to a 1/128 grid of the image whose cells are centred where the centres of regular
|
|
124
|
+
* patterns fall), so they do not depend on the resolution or on the order tiles are found in.
|
|
125
|
+
*/
|
|
126
|
+
export declare function floodFill(a: Float32Array, w: number, h: number, o: FloodOptions): {
|
|
127
|
+
C: Float32Array;
|
|
128
|
+
ch: 1 | 4;
|
|
129
|
+
id: Float32Array;
|
|
130
|
+
tiles: number;
|
|
131
|
+
};
|