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
package/dist/core/xatlas.d.ts
CHANGED
|
@@ -40,6 +40,22 @@ export interface XatlasResult {
|
|
|
40
40
|
chartCount: number;
|
|
41
41
|
utilization: number[];
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* xatlas charts of a set of triangles (vertex triples into g). A corner's input vertex is keyOf(v) (its point, or a
|
|
45
|
+
* seam-split key); triangles of different group(t) never share a chart. The triangles are scaled on their own to a
|
|
46
|
+
* bounding-box diagonal of XATLAS_SIZE, so a small part of a large model is charted as finely as it would be alone.
|
|
47
|
+
* Returns the chart per triangle (-1: xatlas dropped it, e.g. no area) and the uv per triangle corner in xatlas texel
|
|
48
|
+
* space: each chart's shape (where xatlas placed it is not used).
|
|
49
|
+
*/
|
|
50
|
+
export declare function xatlasCharts(X: any, g: Geometry, tris: ArrayLike<number>, o: {
|
|
51
|
+
keyOf: (v: number) => number;
|
|
52
|
+
group?: ((t: number) => number) | null;
|
|
53
|
+
chart: XatlasChartOptions;
|
|
54
|
+
}): {
|
|
55
|
+
triChart: Int32Array;
|
|
56
|
+
cornerUV: Float64Array;
|
|
57
|
+
chartCount: number;
|
|
58
|
+
};
|
|
43
59
|
/**
|
|
44
60
|
* Run xatlas on the closed polygons of g (prims outside primMask are skipped). Input vertices are the
|
|
45
61
|
* geometry points, or per-vertex keys (`vertexKey[v]`, e.g. split along seams); `faceGroup[prim]`
|
|
@@ -49,5 +65,4 @@ export declare function runXatlas(X: any, g: Geometry, chart: XatlasChartOptions
|
|
|
49
65
|
vertexKey?: Int32Array | null;
|
|
50
66
|
faceGroup?: Int32Array | null;
|
|
51
67
|
primMask?: ArrayLike<number> | null;
|
|
52
|
-
unmirror?: boolean;
|
|
53
68
|
}): XatlasResult;
|
package/dist/core/xatlas.js
CHANGED
|
@@ -11,6 +11,86 @@ export async function loadXatlas() {
|
|
|
11
11
|
}
|
|
12
12
|
return modPromise;
|
|
13
13
|
}
|
|
14
|
+
/** Bounding-box diagonal small inputs are scaled up to before xatlas sees them (world units). */
|
|
15
|
+
const XATLAS_SIZE = 100;
|
|
16
|
+
/** The factor that brings a position list's bounding-box diagonal up to XATLAS_SIZE (1 when it is already larger). */
|
|
17
|
+
function xatlasScale(pos) {
|
|
18
|
+
const lo = [Infinity, Infinity, Infinity], hi = [-Infinity, -Infinity, -Infinity];
|
|
19
|
+
for (let i = 0; i < pos.length; i++) {
|
|
20
|
+
const a = i % 3;
|
|
21
|
+
if (pos[i] < lo[a])
|
|
22
|
+
lo[a] = pos[i];
|
|
23
|
+
if (pos[i] > hi[a])
|
|
24
|
+
hi[a] = pos[i];
|
|
25
|
+
}
|
|
26
|
+
const d = Math.hypot(hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]);
|
|
27
|
+
return d > 0 && d < XATLAS_SIZE ? XATLAS_SIZE / d : 1;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* xatlas charts of a set of triangles (vertex triples into g). A corner's input vertex is keyOf(v) (its point, or a
|
|
31
|
+
* seam-split key); triangles of different group(t) never share a chart. The triangles are scaled on their own to a
|
|
32
|
+
* bounding-box diagonal of XATLAS_SIZE, so a small part of a large model is charted as finely as it would be alone.
|
|
33
|
+
* Returns the chart per triangle (-1: xatlas dropped it, e.g. no area) and the uv per triangle corner in xatlas texel
|
|
34
|
+
* space: each chart's shape (where xatlas placed it is not used).
|
|
35
|
+
*/
|
|
36
|
+
export function xatlasCharts(X, g, tris, o) {
|
|
37
|
+
const nt = Math.floor(tris.length / 3), P = g.P;
|
|
38
|
+
const remap = new Map(), pos = [], idx = new Uint32Array(nt * 3);
|
|
39
|
+
for (let i = 0; i < nt * 3; i++) {
|
|
40
|
+
const v = tris[i], key = o.keyOf(v);
|
|
41
|
+
let x = remap.get(key);
|
|
42
|
+
if (x === undefined) {
|
|
43
|
+
x = pos.length / 3;
|
|
44
|
+
remap.set(key, x);
|
|
45
|
+
const pt = g.vertexPoint[v];
|
|
46
|
+
pos.push(P[pt * 3], P[pt * 3 + 1], P[pt * 3 + 2]);
|
|
47
|
+
}
|
|
48
|
+
idx[i] = x;
|
|
49
|
+
}
|
|
50
|
+
const res = { triChart: new Int32Array(nt).fill(-1), cornerUV: new Float64Array(nt * 6), chartCount: 0 };
|
|
51
|
+
if (!nt)
|
|
52
|
+
return res;
|
|
53
|
+
let chart = o.chart;
|
|
54
|
+
const k = xatlasScale(pos);
|
|
55
|
+
if (k !== 1) {
|
|
56
|
+
for (let i = 0; i < pos.length; i++)
|
|
57
|
+
pos[i] *= k;
|
|
58
|
+
chart = { ...chart };
|
|
59
|
+
if (chart.maxChartArea)
|
|
60
|
+
chart.maxChartArea *= k * k;
|
|
61
|
+
if (chart.maxBoundaryLength)
|
|
62
|
+
chart.maxBoundaryLength *= k;
|
|
63
|
+
}
|
|
64
|
+
const atlas = X.createAtlas();
|
|
65
|
+
try {
|
|
66
|
+
const decl = { positions: Float32Array.from(pos), indices: idx };
|
|
67
|
+
if (o.group)
|
|
68
|
+
decl.faceMaterialData = Uint32Array.from({ length: nt }, (_, t) => Math.max(0, o.group(t)));
|
|
69
|
+
const err = atlas.addMesh(decl);
|
|
70
|
+
if (err !== 0)
|
|
71
|
+
throw new Error(`xatlas addMesh failed: ${X.addMeshErrorString ? X.addMeshErrorString(err) : err}`);
|
|
72
|
+
atlas.computeCharts(chart);
|
|
73
|
+
// xatlas writes uv only when it packs; the placement is thrown away, so the atlas is as small as keeps the shapes
|
|
74
|
+
// precise (its cost grows with its area)
|
|
75
|
+
atlas.packCharts({ resolution: Math.max(64, Math.min(1024, Math.round(Math.sqrt(nt) * 8))), padding: 0, rotateCharts: false, rotateChartsToAxis: false, blockAlign: true });
|
|
76
|
+
const m = atlas.getMesh(0);
|
|
77
|
+
res.chartCount = m.chartCount;
|
|
78
|
+
const out = m.indices;
|
|
79
|
+
const verts = m.vertices;
|
|
80
|
+
for (let i = 0; i < out.length && i < nt * 3; i++) {
|
|
81
|
+
const ov = verts[out[i]];
|
|
82
|
+
res.cornerUV[i * 2] = ov.uv[0];
|
|
83
|
+
res.cornerUV[i * 2 + 1] = ov.uv[1];
|
|
84
|
+
const t = (i / 3) | 0;
|
|
85
|
+
if (ov.chartIndex >= 0 && res.triChart[t] < 0)
|
|
86
|
+
res.triChart[t] = ov.chartIndex;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
atlas.destroy();
|
|
91
|
+
}
|
|
92
|
+
return res;
|
|
93
|
+
}
|
|
14
94
|
/**
|
|
15
95
|
* Run xatlas on the closed polygons of g (prims outside primMask are skipped). Input vertices are the
|
|
16
96
|
* geometry points, or per-vertex keys (`vertexKey[v]`, e.g. split along seams); `faceGroup[prim]`
|
|
@@ -42,6 +122,21 @@ export function runXatlas(X, g, chart, pack, opts = {}) {
|
|
|
42
122
|
};
|
|
43
123
|
if (!nt)
|
|
44
124
|
return result;
|
|
125
|
+
// xatlas compares positions and areas against absolute epsilons (about 1e-4 and 1.2e-7), so on a model a few
|
|
126
|
+
// centimetres across it welds bevel corners and drops small faces as degenerate. Scale small inputs up to a
|
|
127
|
+
// bounding-box diagonal of XATLAS_SIZE; the world-unit options scale with them, so the result is unchanged.
|
|
128
|
+
const k = xatlasScale(pos);
|
|
129
|
+
if (k !== 1) {
|
|
130
|
+
for (let i = 0; i < pos.length; i++)
|
|
131
|
+
pos[i] *= k;
|
|
132
|
+
chart = { ...chart };
|
|
133
|
+
if (chart.maxChartArea)
|
|
134
|
+
chart.maxChartArea *= k * k;
|
|
135
|
+
if (chart.maxBoundaryLength)
|
|
136
|
+
chart.maxBoundaryLength *= k;
|
|
137
|
+
if (pack?.texelsPerUnit)
|
|
138
|
+
pack = { ...pack, texelsPerUnit: pack.texelsPerUnit / k };
|
|
139
|
+
}
|
|
45
140
|
const atlas = X.createAtlas();
|
|
46
141
|
try {
|
|
47
142
|
const decl = { positions: Float32Array.from(pos), indices: idx };
|
|
@@ -71,70 +166,9 @@ export function runXatlas(X, g, chart, pack, opts = {}) {
|
|
|
71
166
|
result.triAtlas[t] = ov.atlasIndex;
|
|
72
167
|
}
|
|
73
168
|
}
|
|
74
|
-
if (opts.unmirror && pack)
|
|
75
|
-
unmirrorAndRepack(X, result, out, verts.length, pack);
|
|
76
169
|
}
|
|
77
170
|
finally {
|
|
78
171
|
atlas.destroy();
|
|
79
172
|
}
|
|
80
173
|
return result;
|
|
81
174
|
}
|
|
82
|
-
/**
|
|
83
|
-
* xatlas charts come out in either orientation (its texel space is y-down and LSCM/planar charts are not
|
|
84
|
-
* winding-aware). Mirror the charts whose uv winding disagrees with the polygon winding, then repack all
|
|
85
|
-
* charts with xatlas's UV-mesh packer so the packing stays tight and overlap-free.
|
|
86
|
-
*/
|
|
87
|
-
function unmirrorAndRepack(X, r, out, nOut, pack) {
|
|
88
|
-
const nt = r.triChart.length;
|
|
89
|
-
const signed = new Map();
|
|
90
|
-
for (let t = 0; t < nt; t++) {
|
|
91
|
-
const c = r.triChart[t];
|
|
92
|
-
if (c < 0)
|
|
93
|
-
continue;
|
|
94
|
-
const u = r.cornerUV, i = t * 6;
|
|
95
|
-
const a = (u[i + 2] - u[i]) * (u[i + 5] - u[i + 1]) - (u[i + 3] - u[i + 1]) * (u[i + 4] - u[i]);
|
|
96
|
-
signed.set(c, (signed.get(c) ?? 0) + a);
|
|
97
|
-
}
|
|
98
|
-
let mirrored = 0;
|
|
99
|
-
for (const [, a] of signed)
|
|
100
|
-
if (a < 0)
|
|
101
|
-
mirrored++;
|
|
102
|
-
if (!mirrored)
|
|
103
|
-
return;
|
|
104
|
-
const uvs = new Float32Array(nOut * 2);
|
|
105
|
-
for (let i = 0; i < out.length; i++) {
|
|
106
|
-
const c = r.triChart[(i / 3) | 0];
|
|
107
|
-
const flip = c >= 0 && signed.get(c) < 0;
|
|
108
|
-
uvs[out[i] * 2] = flip ? -r.cornerUV[i * 2] : r.cornerUV[i * 2];
|
|
109
|
-
uvs[out[i] * 2 + 1] = r.cornerUV[i * 2 + 1];
|
|
110
|
-
}
|
|
111
|
-
const b = X.createAtlas();
|
|
112
|
-
try {
|
|
113
|
-
const err = b.addUvMesh({ uvs, indices: out, faceMaterialData: Uint32Array.from(r.triChart, (c) => c + 1) });
|
|
114
|
-
if (err !== 0)
|
|
115
|
-
return;
|
|
116
|
-
b.computeCharts();
|
|
117
|
-
b.packCharts(pack);
|
|
118
|
-
const m = b.getMesh(0);
|
|
119
|
-
const o2 = m.indices;
|
|
120
|
-
const v2 = m.vertices;
|
|
121
|
-
if (o2.length !== out.length)
|
|
122
|
-
return;
|
|
123
|
-
for (let i = 0; i < o2.length; i++) {
|
|
124
|
-
const ov = v2[o2[i]];
|
|
125
|
-
r.cornerUV[i * 2] = ov.uv[0];
|
|
126
|
-
r.cornerUV[i * 2 + 1] = ov.uv[1];
|
|
127
|
-
if (i % 3 === 0)
|
|
128
|
-
r.triAtlas[i / 3] = ov.atlasIndex;
|
|
129
|
-
}
|
|
130
|
-
r.width = b.width;
|
|
131
|
-
r.height = b.height;
|
|
132
|
-
r.atlasCount = b.atlasCount;
|
|
133
|
-
r.utilization = [];
|
|
134
|
-
for (let a = 0; a < b.atlasCount; a++)
|
|
135
|
-
r.utilization.push(b.getUtilization(a));
|
|
136
|
-
}
|
|
137
|
-
finally {
|
|
138
|
-
b.destroy();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type EngineType = 'godot' | 'unreal';
|
|
2
|
+
/** The game engine a workspace builds with: its project file, written from the workspace ("game/project.godot", "../Game.uproject"). */
|
|
3
|
+
export interface EngineLink {
|
|
4
|
+
type: EngineType;
|
|
5
|
+
project: string;
|
|
6
|
+
}
|
|
7
|
+
/** The engine type a project file's name says, or null. */
|
|
8
|
+
export declare const engineTypeOf: (file: string) => EngineType | null;
|
|
9
|
+
/**
|
|
10
|
+
* Files an engine writes beside the files it imports, which never count as TopoTopo's: Godot's *.import, *.uid and
|
|
11
|
+
* *.translation, Unreal's *.uasset, and TopoTopo's own .gdignore. Versions, their hashes, input listings, bake keys and
|
|
12
|
+
* the viewer's saved outputs leave them out, so a package inside an engine project publishes what it would elsewhere.
|
|
13
|
+
*/
|
|
14
|
+
export declare const isEngineFile: (name: string) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The nearest engine project at or above a folder: project.godot in the folder or above it, a *.uproject the same;
|
|
17
|
+
* null when there is none. A folder holding both answers Godot's (the one a workspace there sees first).
|
|
18
|
+
*/
|
|
19
|
+
export declare function engineAbove(dir: string): {
|
|
20
|
+
file: string;
|
|
21
|
+
type: EngineType;
|
|
22
|
+
} | null;
|
|
23
|
+
/** The engine projects below a folder (project.godot, *.uproject), nearest first, at most 4 levels down; paths from `dir`. */
|
|
24
|
+
export declare function findEngines(dir: string): EngineLink[];
|
|
25
|
+
/**
|
|
26
|
+
* The engine project a workspace at `dir` builds with when none is named: the nearest at or above it (the workspace
|
|
27
|
+
* inside the engine's content folder), else the nearest below it; `found` says how many there were below, when that
|
|
28
|
+
* is where it came from.
|
|
29
|
+
*/
|
|
30
|
+
export declare function detectEngine(dir: string): {
|
|
31
|
+
link: EngineLink;
|
|
32
|
+
below: EngineLink[];
|
|
33
|
+
} | null;
|
|
34
|
+
/**
|
|
35
|
+
* Whether Unreal sees a folder of its project: Unreal imports only what lies under the project's Content/ folder or a
|
|
36
|
+
* plugin's (Plugins/…/Content/). `uproject`: the project file.
|
|
37
|
+
*/
|
|
38
|
+
export declare function unrealSees(folder: string, uproject: string): boolean;
|
|
39
|
+
/** The Godot project a folder lies in: the folder holding the nearest project.godot at or above it; null for none. */
|
|
40
|
+
export declare function godotProjectOf(dir: string): string | null;
|
|
41
|
+
/** TopoTopo's working folders of a package, which are not game content: Godot imports none of them (a .gdignore in each). */
|
|
42
|
+
export declare const GODOT_IGNORED: string[];
|
|
43
|
+
/** With the import addon, cooked outputs replace these working folders as Godot's source assets. */
|
|
44
|
+
export declare const GODOT_PLUGIN_IGNORED: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Inside a Godot project (project.godot at or above the package), keep Godot's importer out of a package's working
|
|
47
|
+
* folders: an empty .gdignore in each of versions/, packages/ and inputs/ that is there, and in the folders of `make`
|
|
48
|
+
* (made when they are not there yet), so the file is in place before the first version or copy lands. Nothing outside a
|
|
49
|
+
* Godot project. With the TopoTopo addon installed, also hide the package's graphs/, assets/ and exports/ as they
|
|
50
|
+
* appear (for example when the viewer opens after setup). Returns the files it added (none when they were all there).
|
|
51
|
+
*/
|
|
52
|
+
export declare function godotIgnore(pkgDir: string, make?: string[]): string[];
|
|
53
|
+
/** The .gdignore files a package inside a Godot project lacks in the working folders it has (godotIgnore adds them); none outside one. */
|
|
54
|
+
export declare function godotIgnoreMissing(pkgDir: string): string[];
|
|
55
|
+
/** What a Godot export preset should exclude so that it ships none of TopoTopo's files. */
|
|
56
|
+
export declare const GODOT_EXCLUDES: string[];
|
|
57
|
+
/**
|
|
58
|
+
* The export presets of a Godot project (export_presets.cfg in `projectDir`) that would ship TopoTopo's files: one that
|
|
59
|
+
* exports every resource (export_filter="all_resources", or "exclude": all but the files checked) or includes *.json or
|
|
60
|
+
* *.txt files, with the exclude_filter entries it lacks. Nothing is edited. One line each; none when the file is missing
|
|
61
|
+
* or every preset excludes them.
|
|
62
|
+
*/
|
|
63
|
+
export declare function godotPresetReport(projectDir: string): string[];
|
package/dist/engines.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// Game engine projects (Godot, Unreal) as TopoTopo meets them: finding the project a workspace builds with (the nearest
|
|
2
|
+
// one at or above the workspace, else one below it), whether Unreal sees a workspace (under the project's Content/ or a
|
|
3
|
+
// plugin's), the files engines write beside TopoTopo's (never TopoTopo's: left out of versions, hashes, listings and
|
|
4
|
+
// bake keys), the .gdignore files that keep TopoTopo's working folders out of Godot's importer, and the Godot export
|
|
5
|
+
// presets that would ship TopoTopo's files.
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
const ENGINE_FILES = [[/^project\.godot$/, 'godot'], [/\.uproject$/i, 'unreal']];
|
|
9
|
+
/** The engine type a project file's name says, or null. */
|
|
10
|
+
export const engineTypeOf = (file) => ENGINE_FILES.find(([re]) => re.test(path.basename(file)))?.[1] ?? null;
|
|
11
|
+
/** Folders an engine search below a folder never enters (besides dot folders). */
|
|
12
|
+
const SKIP_BELOW = new Set(['node_modules', 'binaries', 'intermediate', 'saved', 'deriveddatacache', 'versions', 'packages', 'topotopo-packages']);
|
|
13
|
+
/**
|
|
14
|
+
* Files an engine writes beside the files it imports, which never count as TopoTopo's: Godot's *.import, *.uid and
|
|
15
|
+
* *.translation, Unreal's *.uasset, and TopoTopo's own .gdignore. Versions, their hashes, input listings, bake keys and
|
|
16
|
+
* the viewer's saved outputs leave them out, so a package inside an engine project publishes what it would elsewhere.
|
|
17
|
+
*/
|
|
18
|
+
export const isEngineFile = (name) => name === '.gdignore' || /\.(import|uid|translation|uasset)$/i.test(name);
|
|
19
|
+
const rel = (from, to) => path.relative(path.resolve(from), path.resolve(to)).split(path.sep).join('/') || '.';
|
|
20
|
+
/** The engine project files directly in a folder. */
|
|
21
|
+
function projectsIn(dir) {
|
|
22
|
+
try {
|
|
23
|
+
return fs.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && engineTypeOf(e.name)).map((e) => e.name).sort();
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The nearest engine project at or above a folder: project.godot in the folder or above it, a *.uproject the same;
|
|
31
|
+
* null when there is none. A folder holding both answers Godot's (the one a workspace there sees first).
|
|
32
|
+
*/
|
|
33
|
+
export function engineAbove(dir) {
|
|
34
|
+
for (let d = path.resolve(dir);;) {
|
|
35
|
+
const found = projectsIn(d).sort((a, b) => (engineTypeOf(a) === 'godot' ? -1 : engineTypeOf(b) === 'godot' ? 1 : 0));
|
|
36
|
+
if (found.length)
|
|
37
|
+
return { file: path.join(d, found[0]), type: engineTypeOf(found[0]) };
|
|
38
|
+
const up = path.dirname(d);
|
|
39
|
+
if (up === d)
|
|
40
|
+
return null;
|
|
41
|
+
d = up;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** The engine projects below a folder (project.godot, *.uproject), nearest first, at most 4 levels down; paths from `dir`. */
|
|
45
|
+
export function findEngines(dir) {
|
|
46
|
+
const out = [];
|
|
47
|
+
const walk = (d, depth) => {
|
|
48
|
+
let entries;
|
|
49
|
+
try {
|
|
50
|
+
entries = fs.readdirSync(d, { withFileTypes: true });
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
for (const e of entries) {
|
|
56
|
+
const type = e.isFile() ? engineTypeOf(e.name) : null;
|
|
57
|
+
if (type)
|
|
58
|
+
out.push({ link: { type, project: rel(dir, path.join(d, e.name)) }, depth });
|
|
59
|
+
}
|
|
60
|
+
if (depth >= 4)
|
|
61
|
+
return;
|
|
62
|
+
for (const e of entries)
|
|
63
|
+
if (e.isDirectory() && !e.name.startsWith('.') && !SKIP_BELOW.has(e.name.toLowerCase()))
|
|
64
|
+
walk(path.join(d, e.name), depth + 1);
|
|
65
|
+
};
|
|
66
|
+
walk(path.resolve(dir), 0);
|
|
67
|
+
return out.sort((a, b) => a.depth - b.depth || (a.link.project < b.link.project ? -1 : 1)).map((x) => x.link);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The engine project a workspace at `dir` builds with when none is named: the nearest at or above it (the workspace
|
|
71
|
+
* inside the engine's content folder), else the nearest below it; `found` says how many there were below, when that
|
|
72
|
+
* is where it came from.
|
|
73
|
+
*/
|
|
74
|
+
export function detectEngine(dir) {
|
|
75
|
+
const above = engineAbove(dir);
|
|
76
|
+
if (above)
|
|
77
|
+
return { link: { type: above.type, project: rel(dir, above.file) }, below: [] };
|
|
78
|
+
const below = findEngines(dir);
|
|
79
|
+
return below.length ? { link: below[0], below } : null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Whether Unreal sees a folder of its project: Unreal imports only what lies under the project's Content/ folder or a
|
|
83
|
+
* plugin's (Plugins/…/Content/). `uproject`: the project file.
|
|
84
|
+
*/
|
|
85
|
+
export function unrealSees(folder, uproject) {
|
|
86
|
+
const r = path.relative(path.dirname(path.resolve(uproject)), path.resolve(folder));
|
|
87
|
+
if (!r || r.startsWith('..') || path.isAbsolute(r))
|
|
88
|
+
return false;
|
|
89
|
+
const parts = r.split(path.sep).map((s) => s.toLowerCase());
|
|
90
|
+
if (parts[0] === 'content')
|
|
91
|
+
return true;
|
|
92
|
+
return parts[0] === 'plugins' && parts.indexOf('content') > 1;
|
|
93
|
+
}
|
|
94
|
+
/** The Godot project a folder lies in: the folder holding the nearest project.godot at or above it; null for none. */
|
|
95
|
+
export function godotProjectOf(dir) {
|
|
96
|
+
for (let d = path.resolve(dir);;) {
|
|
97
|
+
if (fs.statSync(path.join(d, 'project.godot'), { throwIfNoEntry: false })?.isFile())
|
|
98
|
+
return d;
|
|
99
|
+
const up = path.dirname(d);
|
|
100
|
+
if (up === d)
|
|
101
|
+
return null;
|
|
102
|
+
d = up;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/** TopoTopo's working folders of a package, which are not game content: Godot imports none of them (a .gdignore in each). */
|
|
106
|
+
export const GODOT_IGNORED = ['versions', 'packages', 'inputs'];
|
|
107
|
+
/** With the import addon, cooked outputs replace these working folders as Godot's source assets. */
|
|
108
|
+
export const GODOT_PLUGIN_IGNORED = ['graphs', 'assets', 'inputs', 'exports', 'versions', 'packages'];
|
|
109
|
+
function godotIgnoredFolders(pkgDir) {
|
|
110
|
+
const project = godotProjectOf(pkgDir);
|
|
111
|
+
if (!project)
|
|
112
|
+
return [];
|
|
113
|
+
// A package at the project root is unsupported by the addon: never hide the game's assets/ there.
|
|
114
|
+
return path.resolve(pkgDir) !== project && fs.statSync(path.join(project, 'addons', 'topotopo', 'plugin.cfg'), { throwIfNoEntry: false })?.isFile()
|
|
115
|
+
? GODOT_PLUGIN_IGNORED : GODOT_IGNORED;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Inside a Godot project (project.godot at or above the package), keep Godot's importer out of a package's working
|
|
119
|
+
* folders: an empty .gdignore in each of versions/, packages/ and inputs/ that is there, and in the folders of `make`
|
|
120
|
+
* (made when they are not there yet), so the file is in place before the first version or copy lands. Nothing outside a
|
|
121
|
+
* Godot project. With the TopoTopo addon installed, also hide the package's graphs/, assets/ and exports/ as they
|
|
122
|
+
* appear (for example when the viewer opens after setup). Returns the files it added (none when they were all there).
|
|
123
|
+
*/
|
|
124
|
+
export function godotIgnore(pkgDir, make = []) {
|
|
125
|
+
const added = [];
|
|
126
|
+
for (const d of godotIgnoredFolders(pkgDir)) {
|
|
127
|
+
const folder = path.join(pkgDir, d), f = path.join(folder, '.gdignore');
|
|
128
|
+
if (fs.existsSync(f) || (!make.includes(d) && !fs.statSync(folder, { throwIfNoEntry: false })?.isDirectory()))
|
|
129
|
+
continue;
|
|
130
|
+
try {
|
|
131
|
+
fs.mkdirSync(folder, { recursive: true });
|
|
132
|
+
fs.writeFileSync(f, '');
|
|
133
|
+
added.push(f);
|
|
134
|
+
}
|
|
135
|
+
catch { /* Godot imports them: harmless */ }
|
|
136
|
+
}
|
|
137
|
+
return added;
|
|
138
|
+
}
|
|
139
|
+
/** The .gdignore files a package inside a Godot project lacks in the working folders it has (godotIgnore adds them); none outside one. */
|
|
140
|
+
export function godotIgnoreMissing(pkgDir) {
|
|
141
|
+
return godotIgnoredFolders(pkgDir).filter((d) => fs.statSync(path.join(pkgDir, d), { throwIfNoEntry: false })?.isDirectory()).map((d) => path.join(pkgDir, d, '.gdignore')).filter((f) => !fs.existsSync(f));
|
|
142
|
+
}
|
|
143
|
+
/** What a Godot export preset should exclude so that it ships none of TopoTopo's files. */
|
|
144
|
+
export const GODOT_EXCLUDES = ['*/attachments/*', '*/graphs/*', '*/inputs/*', '*.topo', '*/exports/*.source.json', '*/exports/.outputs.json'];
|
|
145
|
+
/**
|
|
146
|
+
* The export presets of a Godot project (export_presets.cfg in `projectDir`) that would ship TopoTopo's files: one that
|
|
147
|
+
* exports every resource (export_filter="all_resources", or "exclude": all but the files checked) or includes *.json or
|
|
148
|
+
* *.txt files, with the exclude_filter entries it lacks. Nothing is edited. One line each; none when the file is missing
|
|
149
|
+
* or every preset excludes them.
|
|
150
|
+
*/
|
|
151
|
+
export function godotPresetReport(projectDir) {
|
|
152
|
+
let text;
|
|
153
|
+
try {
|
|
154
|
+
text = fs.readFileSync(path.join(projectDir, 'export_presets.cfg'), 'utf8');
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
const out = [];
|
|
160
|
+
// [preset.N] sections; their keys are key="value" lines
|
|
161
|
+
for (const block of text.split(/^\[preset\.\d+\]\s*$/m).slice(1)) {
|
|
162
|
+
const body = block.split(/^\[/m)[0];
|
|
163
|
+
const key = (k) => new RegExp(`^${k}\\s*=\\s*"((?:[^"\\\\]|\\\\.)*)"`, 'm').exec(body)?.[1] ?? '';
|
|
164
|
+
const name = key('name') || '(unnamed)', filter = key('export_filter'), include = key('include_filter'), exclude = key('exclude_filter');
|
|
165
|
+
const includes = include.split(',').map((s) => s.trim()).filter(Boolean);
|
|
166
|
+
// "all_resources": every resource; "exclude": every resource but the files checked in the dialog
|
|
167
|
+
const every = filter === 'all_resources' || filter === 'exclude';
|
|
168
|
+
const ships = every || includes.some((p) => /\*\.(json|txt)$/i.test(p) || p === '*' || p === '*.*');
|
|
169
|
+
if (!ships)
|
|
170
|
+
continue;
|
|
171
|
+
const have = new Set(exclude.split(',').map((s) => s.trim()).filter(Boolean));
|
|
172
|
+
const missing = GODOT_EXCLUDES.filter((e) => !have.has(e));
|
|
173
|
+
if (!missing.length)
|
|
174
|
+
continue;
|
|
175
|
+
const why = filter === 'all_resources' ? 'exports every resource' : filter === 'exclude' ? 'exports every resource but the files it leaves out'
|
|
176
|
+
: `includes ${includes.filter((p) => /\*\.(json|txt)$/i.test(p) || p === '*' || p === '*.*').join(', ')}`;
|
|
177
|
+
out.push(`export preset "${name}" ${why}, so it would ship TopoTopo's files: add to its exclude_filter (Project > Export > Resources > Filters to exclude) ${missing.join(', ')}`);
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
package/dist/explain.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface DiffResult {
|
|
|
10
10
|
mean: number;
|
|
11
11
|
identical: boolean;
|
|
12
12
|
}
|
|
13
|
-
/** What changed from a to b: counts, bbox, topology, attribute schema, groups, sampled Hausdorff and mean distance. */
|
|
13
|
+
/** What changed from a to b: counts, bbox, topology, attribute schema, groups, volumes, sampled Hausdorff and mean distance. */
|
|
14
14
|
export declare function diffGeometry(a: Geometry, b: Geometry, labels?: [string, string], samples?: number): DiffResult;
|
|
15
15
|
/** Colours of the diff overlay. */
|
|
16
16
|
export declare const DIFF_COLORS: {
|
|
@@ -19,7 +19,8 @@ export declare const DIFF_COLORS: {
|
|
|
19
19
|
a: number[];
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
|
-
* One geometry for the renderer: b
|
|
23
|
-
*
|
|
22
|
+
* One geometry for the renderer: b (grey where it lies on a, blue where it moved or is new), and in orange the polygons
|
|
23
|
+
* of a that do not lie on b. Those that do are left out, b's grey stands for both there: two coincident surfaces mix
|
|
24
|
+
* their colours in the renderer. So grey = unchanged, blue = only b, orange = only a.
|
|
24
25
|
*/
|
|
25
26
|
export declare function diffOverlay(a: Geometry, b: Geometry): Geometry;
|