topotopo 0.5.2 → 0.5.3
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/dist/cli.js +40 -17
- package/dist/core/manifold.d.ts +11 -2
- package/dist/core/manifold.js +7 -4
- package/dist/core/materials.d.ts +3 -2
- package/dist/core/materials.js +3 -2
- package/dist/core/tangents.d.ts +2 -0
- package/dist/core/tangents.js +26 -3
- package/dist/core/texture.d.ts +1 -1
- package/dist/core/texture.js +12 -3
- package/dist/core/topology.d.ts +5 -1
- package/dist/core/topology.js +35 -4
- package/dist/io/gltf.js +8 -7
- package/dist/io/source.d.ts +2 -0
- package/dist/io/source.js +10 -1
- package/dist/mcp/docs.js +35 -8
- package/dist/mcp/tools.js +35 -10
- package/dist/nodes/attributes.js +12 -3
- package/dist/nodes/curves.js +7 -7
- package/dist/nodes/material.js +3 -3
- package/dist/nodes/solid.js +42 -15
- package/dist/nodes/texture.js +16 -9
- package/dist/nodes/topology.js +3 -2
- package/dist/packages/registry.d.ts +21 -8
- package/dist/packages/registry.js +57 -24
- package/dist/render/options.js +9 -1
- package/dist/render/pbr.d.ts +22 -2
- package/dist/render/pbr.js +113 -38
- package/dist/render/preview.d.ts +2 -0
- package/dist/render/raster.d.ts +13 -1
- package/dist/render/raster.js +108 -19
- package/dist/session.d.ts +20 -5
- package/dist/session.js +5 -3
- package/integrations/godot/addons/topotopo/plugin.cfg +1 -1
- package/package.json +1 -1
package/dist/mcp/tools.js
CHANGED
|
@@ -19,6 +19,7 @@ import { packageAt, packagesUsed } from '../graph/packages.js';
|
|
|
19
19
|
import { ArtifactStore } from '../host/artifacts.js';
|
|
20
20
|
import { prepareTarget, serializeExport, writeExportFiles, writeTargets } from '../host/export-targets.js';
|
|
21
21
|
import { TOPOTOPO_VERSION } from '../host/version.js';
|
|
22
|
+
import { program } from '../package.js';
|
|
22
23
|
import { evalGroup } from '../core/groups.js';
|
|
23
24
|
import { Geometry } from '../core/geometry.js';
|
|
24
25
|
import { verifyTools } from './verify.js';
|
|
@@ -153,6 +154,8 @@ const RENDER_PROPS = {
|
|
|
153
154
|
legend: { type: 'boolean', description: 'legend for color_by (gradient bar with min/max, or categorical swatches) and highlight' },
|
|
154
155
|
shading: { type: 'string', enum: ['default', 'flat', 'matcap', 'ao', 'pbr'], description: 'flat: facets (ignores N); matcap: clay that reads form; ao: screen-space ambient occlusion darkens creases and cavities; pbr: the exported metallic-roughness material (base colour, normal, orm/roughness maps, emissive, unlit) under a fixed studio light rig, deterministic' },
|
|
155
156
|
exposure: { type: 'number', description: 'shading "pbr": exposure in stops (default 0)' },
|
|
157
|
+
grey: { type: 'boolean', description: 'value check: shading "pbr" (implied) with every base colour a neutral 18% grey under the studio rig at its luminance (no hue anywhere); base colour maps and Cd give no colour, roughness/metallic/normal/orm maps, alpha and emissive still apply' },
|
|
158
|
+
cd: { type: 'string', enum: ['auto', 'ignore', 'multiply'], description: 'shading "pbr": vertex colour Cd. auto (default, as glTF export): a named material\'s base colour (factor or map) wins and Cd colours only prims without a material; ignore: Cd never shown; multiply: Cd also tints a named material\'s base colour (vertex paint)' },
|
|
156
159
|
ao_radius: { type: 'number', description: 'shading "ao": sample radius in pixels (default 10)' },
|
|
157
160
|
look_at: { type: 'array', items: { type: 'number' }, description: 'look-at point [x, y, z] in world metres (x right, y up, z towards the front; default the bbox centre): the view centres on it and still fits the bounds; with zoom > 1 it zooms into that point' },
|
|
158
161
|
bounds: { type: 'array', items: { type: 'array', items: { type: 'number' } }, description: 'world-space [[x0, y0, z0], [x1, y1, z1]] (min then max, metres, Y up): every 3D view frames these bounds instead of the box of the geometry, so renders of different geometries share one camera (timelapse frames, turntable azimuths)' },
|
|
@@ -211,22 +214,43 @@ export function makeTools(ws, opts = {}) {
|
|
|
211
214
|
ws.bump(name);
|
|
212
215
|
return reportResult(name, r, a, extraNotes);
|
|
213
216
|
};
|
|
217
|
+
/**
|
|
218
|
+
* export {follow}: the packages whose working folders the export uses (each followed this session), checked; an
|
|
219
|
+
* export that would cook a followed package with no published version in use from published copies is refused.
|
|
220
|
+
*/
|
|
221
|
+
const exportFollow = (a, spec) => {
|
|
222
|
+
const follow = a.follow === undefined ? [] : (Array.isArray(a.follow) ? a.follow : [a.follow]).map(String);
|
|
223
|
+
const followed = new Set((ws.packages?.following?.() ?? []).map((f) => f.package));
|
|
224
|
+
for (const p of follow) {
|
|
225
|
+
if (!followed.has(p))
|
|
226
|
+
throw new Error(`follow: this session does not follow ${p}: workspace {action:"follow", package:"${p}", on:true} follows its working folder (renders show it too), then export {follow:["${p}"]} exports from it`);
|
|
227
|
+
}
|
|
228
|
+
const missing = ws.packages?.unpublished?.(spec, follow) ?? [];
|
|
229
|
+
if (missing.length) {
|
|
230
|
+
throw new Error(`export: ${missing.map((u) => u.package).join(', ')} ${missing.length === 1 ? 'has' : 'have'} no published version in use (this session shows ${missing.length === 1 ? 'its working folder' : 'their working folders'}, for looking): `
|
|
231
|
+
+ `${missing.map((u) => `publish ${u.package} (${program()} publish ${u.dir} --note "...") or pass follow:["${u.package}"] to export from its working folder`).join('; ')}; nothing was written`);
|
|
232
|
+
}
|
|
233
|
+
return follow;
|
|
234
|
+
};
|
|
214
235
|
const resolveNodeGeo = async (a, forExport = false) => {
|
|
215
236
|
const name = a.graph ?? a.name ?? 'main'; // `name` is what build/edit call it; accept both
|
|
216
237
|
const g = ws.getGraph(name);
|
|
217
238
|
const target = a.node || undefined;
|
|
218
|
-
// an export uses the published copies of the packages the session shows live (following is for looking)
|
|
219
|
-
|
|
239
|
+
// an export uses the published copies of the packages the session shows live (following is for looking), but
|
|
240
|
+
// the working folders of those export {follow} names
|
|
241
|
+
const follow = forExport ? exportFollow(a, g) : [];
|
|
242
|
+
const scope = forExport && ws.packages?.publishedNote?.(g, follow) ? ws.packages.published?.(follow) : null;
|
|
220
243
|
const r = await engine.cook(g, { target, frame: a.frame, ...(scope ? { scope } : {}) });
|
|
221
244
|
if (!r.ok || !r.geo)
|
|
222
245
|
throw new Error(reportText(name, r));
|
|
223
|
-
return { r, name, geo: r.geo, scope };
|
|
246
|
+
return { r, name, geo: r.geo, scope, follow };
|
|
224
247
|
};
|
|
225
|
-
/** What an export of a graph made while following says (the published versions it used), on a line of its own. */
|
|
226
|
-
const publishedLine = (spec) => { const n = ws.packages?.publishedNote?.(spec); return n ? `\n${n}` : ''; };
|
|
248
|
+
/** What an export of a graph made while following says (the working folders and published versions it used), on a line of its own. */
|
|
249
|
+
const publishedLine = (spec, follow) => { const n = ws.packages?.publishedNote?.(spec, follow); return n ? `\n${n}` : ''; };
|
|
227
250
|
/** export without a path: the graph's targets (the default output's, a named one's, or all), inside exports/ */
|
|
228
251
|
const exportTargets = async (a) => {
|
|
229
252
|
const name = a.graph ?? a.name ?? 'main', spec = ws.getGraph(name);
|
|
253
|
+
const follow = exportFollow(a, spec);
|
|
230
254
|
const published = publishedOutputs(name, spec, engine.findOutput(spec).name);
|
|
231
255
|
const hint = (o) => `edit {ops:[{op:"export"${o === undefined ? '' : `, output:"${o}"`}, export:"glb"}]}`;
|
|
232
256
|
let chosen = published;
|
|
@@ -243,15 +267,15 @@ export function makeTools(ws, opts = {}) {
|
|
|
243
267
|
return text(`no output of "${name}" has an export target: set one with ${hint(undefined)}, or pass path`, true);
|
|
244
268
|
const prepared = [];
|
|
245
269
|
for (const p of targets) {
|
|
246
|
-
const r = await ws.cook(name, p.node, a.frame, { kind: 'export' });
|
|
270
|
+
const r = await ws.cook(name, p.node, a.frame, { kind: 'export', follow });
|
|
247
271
|
if (!r.ok || !r.geo)
|
|
248
272
|
return text(reportText(name, r), true);
|
|
249
|
-
prepared.push(await prepareTarget(r.geo, name, p, ws.exportDir, engine.host, { frame: r.frame, fps: r.fps, packages: packagesUsed(engine, spec, ws.packages?.published?.() ?? engine.root) }));
|
|
273
|
+
prepared.push(await prepareTarget(r.geo, name, p, ws.exportDir, engine.host, { frame: r.frame, fps: r.fps, packages: packagesUsed(engine, spec, ws.packages?.published?.(follow) ?? engine.root) }));
|
|
250
274
|
}
|
|
251
275
|
writeTargets(prepared, ws.exportDir);
|
|
252
276
|
const skipped = chosen.filter((p) => !p.target).map((p) => p.label);
|
|
253
277
|
return text(prepared.map((p) => exportReport(p.files, p.root, p.target.format, `${p.label}: ${p.summary}`, p.warnings, p.sourceFile, p.sourceManifest)).join('\n')
|
|
254
|
-
+ (skipped.length ? `\nno export target (skipped): ${skipped.join(', ')}` : '') + publishedLine(spec));
|
|
278
|
+
+ (skipped.length ? `\nno export target (skipped): ${skipped.join(', ')}` : '') + publishedLine(spec, follow));
|
|
255
279
|
};
|
|
256
280
|
const tools = [
|
|
257
281
|
{
|
|
@@ -474,13 +498,14 @@ export function makeTools(ws, opts = {}) {
|
|
|
474
498
|
instancing: { type: 'string', enum: ['packed', 'expand'], description: 'packed prims: glb/gltf (EXT_mesh_gpu_instancing), usda (PointInstancer) and geo (PackedGeometry) keep instances by default; expand writes real copies' },
|
|
475
499
|
instances: { type: 'string', enum: ['rows', 'expand'], description: 'csv / points.json of packed prims: rows (default) = one row per instance (full transform, Mesh column, anchor attributes) + <name>.meshes.json + <name>_meshes/<Mesh>.glb; expand = the points of the expanded geometry' },
|
|
476
500
|
meshes: { type: 'boolean', description: 'instance rows: also write one GLB per packed source (default true)' },
|
|
501
|
+
follow: { type: 'array', items: { type: 'string' }, description: 'packages ("owner/name") this session follows (workspace {action:"follow"}) whose working folders the export uses instead of their published copies: for a package with no published version yet, or edits not yet published. The source record lists them under "followed". Without it an export uses the published copies' },
|
|
477
502
|
...FRAME_PROP,
|
|
478
503
|
},
|
|
479
504
|
},
|
|
480
505
|
run: async (a) => {
|
|
481
506
|
if (a.path === undefined)
|
|
482
507
|
return exportTargets(a);
|
|
483
|
-
const { geo, name, r, scope } = await resolveNodeGeo(a, true);
|
|
508
|
+
const { geo, name, r, scope, follow } = await resolveNodeGeo(a, true);
|
|
484
509
|
const p = path.resolve(ws.dir, a.path);
|
|
485
510
|
const fmt0 = String(a.format ?? exportFormatFromPath(p)).toLowerCase();
|
|
486
511
|
const ext = ({ png: 'png16', raw: 'r16' }[fmt0] ?? fmt0);
|
|
@@ -491,7 +516,7 @@ export function makeTools(ws, opts = {}) {
|
|
|
491
516
|
format: ext, options: exportToolOptions(a), packages: packagesUsed(engine, ws.getGraph(name), scope ?? engine.root), version: TOPOTOPO_VERSION,
|
|
492
517
|
});
|
|
493
518
|
const report = await writeExport(geo, ext, p, a, engine.host, (files) => new ArtifactStore(ws.exportDir).record(files, { graph: name, node: r.target, format: ext }), source);
|
|
494
|
-
return text(`${report}\n(from ${name}/${r.target}${atFrame(r)}: ${geo.numPoints} points, ${geo.numPrims} prims)${publishedLine(ws.getGraph(name))}`);
|
|
519
|
+
return text(`${report}\n(from ${name}/${r.target}${atFrame(r)}: ${geo.numPoints} points, ${geo.numPrims} prims)${publishedLine(ws.getGraph(name), follow)}`);
|
|
495
520
|
},
|
|
496
521
|
},
|
|
497
522
|
{
|
package/dist/nodes/attributes.js
CHANGED
|
@@ -1391,13 +1391,18 @@ defineNode({
|
|
|
1391
1391
|
'its normal is closest to. Both sides of an axis share one projection, so the faces looking along +X, +Y and -Z get MIRRORED uv (a ' +
|
|
1392
1392
|
'texture reads backwards there, and their uv winding is opposite to the polygon\'s: inspect uv counts them as mirrored), while -X, -Y and ' +
|
|
1393
1393
|
'+Z read the right way round. cylindrical: u = angle around axis (one turn per scale[0]), v = height along axis / scale[1]; spherical: u ' +
|
|
1394
|
-
'= angle, v = polar angle (0..1 times scale[1]); both measured from center, with a seam where the angle wraps.'
|
|
1394
|
+
'= angle, v = polar angle (0..1 times scale[1]); both measured from center, with a seam where the angle wraps. For cylindrical and ' +
|
|
1395
|
+
'spherical scale[0] is the TILE COUNT around the axis (a number of repeats, not a length: 1 = the texture wraps the surface once, 4 = four ' +
|
|
1396
|
+
'repeats); scale[1] is metres per v tile for cylindrical. A cylindrical projection collapses the flat top and bottom faces of a tube or ' +
|
|
1397
|
+
'ring (all their points share one height, so the uv degenerates to a line): put those faces in a prim group and run a second uv_project ' +
|
|
1398
|
+
'with method box or planar and that group; group limits a projection to its prims and leaves the uv of the others untouched.',
|
|
1395
1399
|
aliases: ['uvproject', 'texture', 'uv_texture'],
|
|
1396
1400
|
inputs: [{ name: 'geo', desc: 'geometry' }],
|
|
1397
1401
|
params: {
|
|
1402
|
+
group: P.group('prim', 'prims to project ("" = all); the other prims keep their uv'),
|
|
1398
1403
|
method: { type: 'enum', options: ['box', 'planar', 'cylindrical', 'spherical'], default: 'box', desc: 'projection type' },
|
|
1399
1404
|
axis: { type: 'enum', options: ['y', 'x', 'z'], default: 'y', desc: 'projection axis (planar normal / cylinder axis)' },
|
|
1400
|
-
scale: { type: 'vec2', default: [1, 1], desc: 'world units per UV tile
|
|
1405
|
+
scale: { type: 'vec2', default: [1, 1], desc: 'box/planar: world units per UV tile; cylindrical/spherical: scale[0] is the number of tiles around the axis (a count, not a length), scale[1] is metres per tile along the axis (cylindrical) or the number of tiles pole to pole (spherical)' },
|
|
1401
1406
|
offset: { type: 'vec2', default: [0, 0], desc: 'uv offset' },
|
|
1402
1407
|
center: { type: 'vec3', default: [0, 0, 0], desc: 'projection center (cyl/sph)' },
|
|
1403
1408
|
},
|
|
@@ -1405,12 +1410,16 @@ defineNode({
|
|
|
1405
1410
|
example: { type: 'uv_project', params: { method: 'cylindrical', axis: 'y' } },
|
|
1406
1411
|
cook: ({ input, p }) => {
|
|
1407
1412
|
const g = input(0).clone();
|
|
1408
|
-
g
|
|
1413
|
+
const sel = mask(g, 'prim', p.group);
|
|
1414
|
+
if (!sel)
|
|
1415
|
+
g.points.delete('uv');
|
|
1409
1416
|
const uv = g.vertices.add('uv', 'float', 3).data;
|
|
1410
1417
|
const pn = primNormals(g), vprim = g.vertexPrims();
|
|
1411
1418
|
const Pd = g.P;
|
|
1412
1419
|
const ax = 'xyz'.indexOf(p.axis);
|
|
1413
1420
|
for (let v = 0; v < g.numVertices; v++) {
|
|
1421
|
+
if (sel && !sel[vprim[v]])
|
|
1422
|
+
continue;
|
|
1414
1423
|
const pt = g.vertexPoint[v];
|
|
1415
1424
|
const x = Pd[pt * 3], y = Pd[pt * 3 + 1], z = Pd[pt * 3 + 2];
|
|
1416
1425
|
let u = 0, w = 0;
|
package/dist/nodes/curves.js
CHANGED
|
@@ -642,7 +642,7 @@ defineNode({
|
|
|
642
642
|
type: 'sweep',
|
|
643
643
|
category: 'curve',
|
|
644
644
|
summary: 'Sweep a cross-section along curves using rotation-minimising frames (tubes, ribbons, rails, mouldings).',
|
|
645
|
-
description: 'The profile is drawn in the XY plane around the origin, looking along the curve: at every curve point it is placed with its +Z along the curve (the direction of travel), its +Y on the up direction (the "up" param, or the point attribute up) kept perpendicular to the curve, and its +X = Y × Z, to the left of the direction of travel when up points up. The frame then turns as little as possible from point to point (rotation-minimising), so a flat ribbon does not twist on its own; twist adds a turn. The sides are wound so a closed profile drawn counter-clockwise (seen from +Z) faces outward; caps on open curves face away from the curve. uv: u runs around the profile, v along the curve; caps take the profile\'s flat layout.',
|
|
645
|
+
description: 'The profile is drawn in the XY plane around the origin, looking along the curve: at every curve point it is placed with its +Z along the curve (the direction of travel), its +Y on the up direction (the "up" param, or the point attribute up) kept perpendicular to the curve, and its +X = Y × Z, to the left of the direction of travel when up points up. The frame then turns as little as possible from point to point (rotation-minimising), so a flat ribbon does not twist on its own; twist adds a turn. The sides are wound so a closed profile drawn counter-clockwise (seen from +Z) faces outward; caps on open curves face away from the curve. The end caps lie in the profile plane, perpendicular to the curve at its last point: where the last segment is tilted, the cap is tilted with it and its rim pokes above or below a horizontal plane the tube was meant to end on (a ground or snap plane). End the path with a short horizontal run, or cut the result with clip. uv: u runs around the profile, v along the curve; caps take the profile\'s flat layout.',
|
|
646
646
|
inputs: [
|
|
647
647
|
{ name: 'backbone', desc: 'curves to sweep along (Bezier/NURBS curves are sampled adaptively)' },
|
|
648
648
|
{ name: 'profile', desc: 'cross-section curve drawn in the XY plane (optional; one per backbone or a single shared one)', optional: true },
|
|
@@ -729,16 +729,16 @@ defineNode({
|
|
|
729
729
|
type: 'revolve',
|
|
730
730
|
category: 'curve',
|
|
731
731
|
summary: 'Lathe: revolve profile curves around an axis (Y through the origin by default). Profiles touching the axis close up.',
|
|
732
|
-
description: 'Each profile point turns around the axis line (through origin, along axis) at its own distance from it, so the profile can be drawn in any plane that holds the axis: the XY plane (x = radius) for the default Y axis, the XY plane (y = radius) for axis [1, 0, 0]. angle is measured from where the profile is drawn, turning counter-clockwise when the axis points at the viewer. Closed results face outward.',
|
|
732
|
+
description: 'Each profile point turns around the axis line (through origin, along axis) at its own distance from it, so the profile can be drawn in any plane that holds the axis: the XY plane (x = radius) for the default Y axis, the XY plane (y = radius) for axis [1, 0, 0]. angle is measured from where the profile is drawn, turning counter-clockwise when the axis points at the viewer. angle is measured from where the profile is drawn, so the plan angle of the result (atan2(z, x) seen from +Y) is minus the angle: a 0..90 revolve about Y ends at -90 in plan, towards -Z. Closed results face outward. Caps (caps on, partial angle) are only made for closed profiles, and then the result is a closed solid that is always oriented outward (flip has no effect on it). An open profile gives an open surface whose facing follows the profile direction and the sign of the angle span: if it faces the wrong way, set flip.',
|
|
733
733
|
aliases: ['lathe'],
|
|
734
734
|
inputs: [{ name: 'profile', desc: 'curves in a plane holding the axis (default: the XY plane, x = distance from the Y axis)' }],
|
|
735
735
|
params: {
|
|
736
736
|
axis: { type: 'vec3', default: [0, 1, 0], desc: 'direction of the axis to turn around', aliases: ['direction', 'dir'] },
|
|
737
737
|
origin: { type: 'vec3', default: [0, 0, 0], desc: 'a point on the axis', aliases: ['center', 'pivot'] },
|
|
738
738
|
segments: { type: 'int', default: 32, min: 3, max: 4096, desc: 'segments around', aliases: ['divisions', 'cols'] },
|
|
739
|
-
angle: { type: 'vec2', default: [0, 360], desc: 'start/end angle in degrees' },
|
|
740
|
-
caps: { type: 'bool', default: false, desc: 'cap partial revolves
|
|
741
|
-
flip: { type: 'bool', default: false, desc: 'reverse face orientation' },
|
|
739
|
+
angle: { type: 'vec2', default: [0, 360], desc: 'start/end angle in degrees, counter-clockwise seen from the axis tip (right-handed): 0..90 about Y runs from +X towards -Z' },
|
|
740
|
+
caps: { type: 'bool', default: false, desc: 'cap partial revolves of closed profiles (open profiles have no cap; the result is oriented outward)' },
|
|
741
|
+
flip: { type: 'bool', default: false, desc: 'reverse face orientation (open profiles; a closed solid is always re-oriented outward)' },
|
|
742
742
|
},
|
|
743
743
|
outputs: 'vertex uv',
|
|
744
744
|
example: {
|
|
@@ -852,12 +852,12 @@ defineNode({
|
|
|
852
852
|
aliases: ['linear_extrude', 'extrude2d'],
|
|
853
853
|
inputs: [{ name: 'shapes', desc: 'closed polygons lying in a plane (e.g. shape2d, circle, text)' }],
|
|
854
854
|
params: {
|
|
855
|
-
height: { type: 'float', default: 1, desc: 'extrusion distance along the plane normal', aliases: ['depth', 'distance', 'h'] },
|
|
855
|
+
height: { type: 'float', default: 1, desc: 'extrusion distance along the plane normal: plane xz extrudes along +Y, xy along +Z, yz along +X', aliases: ['depth', 'distance', 'h'] },
|
|
856
856
|
divisions: { type: 'int', default: 1, min: 1, max: 10000, desc: 'segments along the extrusion' },
|
|
857
857
|
twist: { type: 'float', default: 0, desc: 'twist in degrees (about each shape centroid)' },
|
|
858
858
|
scale_top: { type: 'vec2', default: [1, 1], desc: 'scale of the top cap (taper); [0,0] = pyramid' },
|
|
859
859
|
center: { type: 'bool', default: false, desc: 'extrude symmetrically about the shape plane' },
|
|
860
|
-
plane: { type: 'enum', options: ['auto', 'xz', 'xy', 'yz'], default: 'auto', desc: '
|
|
860
|
+
plane: { type: 'enum', options: ['auto', 'xz', 'xy', 'yz'], default: 'auto', desc: 'plane the shapes lie in, which sets the extrusion direction: xz extrudes along +Y, xy along +Z, yz along +X (auto = the flattest axis)' },
|
|
861
861
|
caps: { type: 'bool', default: true, desc: 'add top/bottom caps' },
|
|
862
862
|
},
|
|
863
863
|
outputs: 'prim groups top, bottom, side',
|
package/dist/nodes/material.js
CHANGED
|
@@ -31,11 +31,11 @@ defineNode({
|
|
|
31
31
|
from: { type: 'string', default: '', desc: 'input 1: which of its materials ("" = its only one)', aliases: ['source_material', 'use'] },
|
|
32
32
|
group: P.group('prim', 'prims to assign ("" = all). e.g. "top", "@P.y>0", "0-9"'),
|
|
33
33
|
base_color: { type: 'color', default: [0.8, 0.8, 0.8], desc: 'base colour [r,g,b] 0..1, "#rrggbb" or a name', aliases: ['basecolor', 'color', 'cd', 'albedo', 'diffuse'] },
|
|
34
|
-
metallic: { type: 'float', default: 0, min: 0, max: 1, desc: 'metalness 0..1', aliases: ['metal', 'metalness'] },
|
|
35
|
-
roughness: { type: 'float', default: 0.5, min: 0, max: 1, desc: 'roughness 0..1', aliases: ['rough'] },
|
|
34
|
+
metallic: { type: 'float', default: 0, min: 0, max: 1, desc: 'metalness 0..1 (the glTF metallicFactor; texture_to_material with an orm map sets its own factors and ignores this)', aliases: ['metal', 'metalness'] },
|
|
35
|
+
roughness: { type: 'float', default: 0.5, min: 0, max: 1, desc: 'roughness 0..1 (the glTF roughnessFactor, 1 under a roughness map; texture_to_material with an orm map sets its own factors and ignores this)', aliases: ['rough'] },
|
|
36
36
|
emissive: { type: 'color', default: [0, 0, 0], desc: 'emitted colour; components above 1 export with KHR_materials_emissive_strength', aliases: ['emission', 'emit'] },
|
|
37
37
|
alpha: { type: 'float', default: 1, min: 0, max: 1, desc: 'opacity; below 1 exports with alphaMode BLEND', aliases: ['opacity', 'opac'] },
|
|
38
|
-
alpha_mode: { type: 'enum', options: ['auto', 'opaque', 'mask', 'blend'], default: 'auto', desc: 'auto
|
|
38
|
+
alpha_mode: { type: 'enum', options: ['auto', 'opaque', 'mask', 'blend'], default: 'auto', desc: 'auto blends only when alpha is below 1 (vertex alpha never changes the mode); mask cuts out pixels below alpha_cutoff; explicit modes override auto' },
|
|
39
39
|
alpha_cutoff: { type: 'float', default: 0.5, min: 0, max: 1, desc: 'mask: discard where material alpha × texture alpha × vertex Alpha is below this value' },
|
|
40
40
|
double_sided: { type: 'bool', default: false, desc: 'render both faces', aliases: ['doublesided', 'two_sided'] },
|
|
41
41
|
unlit: { type: 'bool', default: false, desc: 'unlit shading (KHR_materials_unlit)', aliases: ['emissive_only', 'flat'] },
|
package/dist/nodes/solid.js
CHANGED
|
@@ -25,19 +25,46 @@ function withManifolds(fn) {
|
|
|
25
25
|
catch { /* already freed */ }
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* One manifold for a solid made of pieces that may overlap. The kernel takes a multi-piece mesh as it is, so where its
|
|
30
|
+
* pieces overlap the region counts twice and a cut leaves it standing; the pieces are built apart and unioned instead,
|
|
31
|
+
* each with the cavity walls it holds (`solid`/`solids` from outwardPieces). One piece, or pieces whose bounds stay
|
|
32
|
+
* apart, go through as they are.
|
|
33
|
+
*/
|
|
34
|
+
function solidManifold(g, L, o, track) {
|
|
35
|
+
const { solid, solids } = o;
|
|
36
|
+
if (solids < 2 || !o.overlap) {
|
|
37
|
+
const m = track(toManifold(g, L));
|
|
38
|
+
return { m, id: manifoldId(m) };
|
|
39
|
+
}
|
|
40
|
+
const { tris, triPrim } = triangulate(g);
|
|
41
|
+
const parts = Array.from({ length: solids }, () => ({ tris: [], triPrim: [] }));
|
|
42
|
+
for (let t = 0; t < triPrim.length; t++) {
|
|
43
|
+
const s = solid[triPrim[t]];
|
|
44
|
+
if (s < 0)
|
|
45
|
+
continue;
|
|
46
|
+
parts[s].tris.push(tris[t * 3], tris[t * 3 + 1], tris[t * 3 + 2]);
|
|
47
|
+
parts[s].triPrim.push(triPrim[t]);
|
|
48
|
+
}
|
|
49
|
+
const W = M(), id = W.Manifold.reserveIDs(1);
|
|
50
|
+
return { m: track(W.Manifold.union(parts.map((tri) => track(toManifold(g, L, { tri, id }))))), id };
|
|
51
|
+
}
|
|
28
52
|
defineNode({
|
|
29
53
|
type: 'boolean',
|
|
30
54
|
category: 'solid',
|
|
31
|
-
summary: 'Robust mesh boolean (union / subtract / intersect) of closed solids.
|
|
32
|
-
description: 'The result is a closed solid made of polygons: each input face that survives the cut comes out as one polygon (a face the cut leaves with a hole as a few polygons sharing flat edges), so a bevel or inset after the boolean sees the real edges, and edges shorter than "tolerance" are collapsed so no slivers are left. Inside-out input pieces (a mirror without a winding flip) are turned outward first, with a warning.',
|
|
55
|
+
summary: 'Robust mesh boolean (union / subtract / intersect) of closed solids. Each input’s overlapping pieces are unioned first; without B, the result is that union of A.',
|
|
56
|
+
description: 'Either input may be a merge of pieces that overlap: each input is first made one solid, the union of its pieces (the inner wall of a hollow piece stays with it, so the hollow is kept), and the operation runs on those two solids, so subtracting a merge of cutters removes everything any of them covers. The result is a closed solid made of polygons: each input face that survives the cut comes out as one polygon (a face the cut leaves with a hole as a few polygons sharing flat edges), so a bevel or inset after the boolean sees the real edges, and edges shorter than "tolerance" are collapsed so no slivers are left. Inside-out input pieces (a mirror without a winding flip) are turned outward first, with a warning.',
|
|
33
57
|
aliases: ['csg', 'bool', 'difference', 'union', 'intersect'],
|
|
34
|
-
inputs: [
|
|
58
|
+
inputs: [
|
|
59
|
+
{ name: 'a', desc: 'solid A: closed pieces, which may overlap (unioned first)' },
|
|
60
|
+
{ name: 'b', desc: 'solid B (optional): closed pieces, which may overlap (unioned first, so a merge of cutters cuts as one); its faces become the cut faces when subtracting', optional: true },
|
|
61
|
+
],
|
|
35
62
|
params: {
|
|
36
63
|
operation: { type: 'enum', options: ['union', 'subtract', 'intersect'], default: 'subtract', desc: 'A ∪ B, A − B, or A ∩ B', aliases: ['op', 'mode'] },
|
|
37
64
|
output: { type: 'enum', options: ['polygons', 'triangles'], default: 'polygons', desc: 'polygons = each surviving input face as one polygon (or a few around a hole); triangles = the kernel triangles as they come' },
|
|
38
65
|
tolerance: { type: 'float', default: 0.00001, min: 0, desc: 'after the cut, collapse edges shorter than this and flatten slivers thinner than it, keeping the solid closed (0 = rounding only)', aliases: ['simplify', 'sliver'] },
|
|
39
66
|
},
|
|
40
|
-
outputs: 'prim groups from_a, from_b (cut faces come from B when subtracting); float point/vertex attributes interpolated',
|
|
67
|
+
outputs: 'prim groups from_a, from_b (cut faces come from B when subtracting); each face keeps the prim attributes of the input face it comes from (a cut face B’s material); float point/vertex attributes interpolated',
|
|
41
68
|
example: {
|
|
42
69
|
nodes: {
|
|
43
70
|
box: { type: 'box' },
|
|
@@ -51,19 +78,19 @@ defineNode({
|
|
|
51
78
|
const r = outwardPieces(g);
|
|
52
79
|
if (r.flipped.length)
|
|
53
80
|
warn(`${label}: ${r.flipped.length} piece(s) were inside out (faces pointing inward, e.g. mirrored without a winding flip) and were turned outward first; first ${primWhere(g, r.flipped[0])}`);
|
|
54
|
-
return r
|
|
81
|
+
return r;
|
|
55
82
|
};
|
|
56
|
-
const
|
|
83
|
+
const oA = outward(input(0), 'A'), oB = hasInput(1) ? outward(input(1), 'B') : null;
|
|
84
|
+
const A = oA.geo, B = oB?.geo ?? null;
|
|
57
85
|
const L = propLayout(B ? [A, B] : [A]);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
r = track(p.operation === 'union' ? mA.add(mB) : p.operation === 'intersect' ? mA.intersect(mB) : mA.subtract(mB));
|
|
86
|
+
// overlapping pieces of either input are unioned first
|
|
87
|
+
const sA = solidManifold(A, L, oA, track);
|
|
88
|
+
let r = sA.m;
|
|
89
|
+
const sources = [{ geo: A, id: sA.id }];
|
|
90
|
+
if (oB && B) {
|
|
91
|
+
const sB = solidManifold(B, L, oB, track);
|
|
92
|
+
sources.push({ geo: B, id: sB.id });
|
|
93
|
+
r = track(p.operation === 'union' ? sA.m.add(sB.m) : p.operation === 'intersect' ? sA.m.intersect(sB.m) : sA.m.subtract(sB.m));
|
|
67
94
|
}
|
|
68
95
|
if (p.tolerance > 0)
|
|
69
96
|
r = track(r.simplify(p.tolerance));
|
package/dist/nodes/texture.js
CHANGED
|
@@ -185,7 +185,7 @@ defineNode({
|
|
|
185
185
|
'bricks with depth). grid is the opposite, a line mask: 1 on the lines (gap is their width), 0 inside the cells, so ' +
|
|
186
186
|
'multiplying a material by it darkens all but the lines; for cells separated by grooves use tiles (grid is 1 - tiles ' +
|
|
187
187
|
'without variation). checker alternates 1 and 0. Layer "id" holds a random 0..1 per cell (tex_colorize it with layer ' +
|
|
188
|
-
'"id" for per-brick colour). count = cells along u (columns) and v (rows); bricks and dots shift every other row by ' +
|
|
188
|
+
'"id" for per-brick colour). count = cells along u (columns) and v (rows); stripes are vertical (u count), and with a u count of 1 the v count makes horizontal stripes; bricks and dots shift every other row by ' +
|
|
189
189
|
'offset (keep the row count even for seamless tiling); hex uses offset for its staggered rows. gap and bevel are ' +
|
|
190
190
|
'fractions of the smaller cell side; variation darkens cells randomly.',
|
|
191
191
|
aliases: ['tile_generator', 'bricks', 'brick', 'checker', 'tiles_pattern', 'cop_pattern'],
|
|
@@ -551,7 +551,7 @@ defineNode({
|
|
|
551
551
|
params: {
|
|
552
552
|
resolution: resolutionParam(),
|
|
553
553
|
style: { type: 'enum', options: GRUNGE_STYLES, default: 'dirt', desc: 'dirt patches, vertical leaks or round spots', aliases: ['type', 'mode'] },
|
|
554
|
-
scale: { type: 'float', default: 4, min: 0.1, max: 256, desc: 'features across the image width', aliases: ['frequency'] },
|
|
554
|
+
scale: { type: 'float', default: 4, min: 0.1, max: 256, desc: 'features across the image width (1 to 256: larger values are clamped to 256)', aliases: ['frequency'] },
|
|
555
555
|
coverage: { type: 'float', default: 0.35, min: 0, max: 1, desc: 'fraction of the image that turns white', aliases: ['amount', 'density'] },
|
|
556
556
|
contrast: { type: 'float', default: 0.6, min: 0, max: 1, desc: 'edge hardness (1 = hard)', aliases: ['hardness'] },
|
|
557
557
|
detail: { type: 'float', default: 0.4, min: 0, max: 1, desc: 'fine breakup mixed in (0 = smooth shapes)', aliases: ['breakup'] },
|
|
@@ -891,14 +891,14 @@ defineNode({
|
|
|
891
891
|
usesNodeName: NAMED_BY_NODE,
|
|
892
892
|
category: 'texture',
|
|
893
893
|
summary: 'Offset, rotate, scale and tile an image (2D transform with wrap).',
|
|
894
|
-
description: 'Substance: Transformation 2D; Houdini COP: Transform. The content is repeated `tile` times, scaled by `scale` (> 1 enlarges), rotated about the centre and shifted by offset (uv). With tileable the source repeats, else the outside is 0. Whole-number tiling and offsets keep a tileable image tileable; other rotations generally do not.',
|
|
894
|
+
description: 'Substance: Transformation 2D; Houdini COP: Transform. The content is repeated `tile` times, scaled by `scale` (> 1 enlarges), rotated about the centre and shifted by offset (uv); tiling is about the lower-left corner, so cell 0 starts at uv (0, 0) and offset 0 keeps the cells aligned with the image edges. With tileable the source repeats, else the outside is 0. Whole-number tiling and offsets keep a tileable image tileable; other rotations generally do not.',
|
|
895
895
|
aliases: ['transform_texture', 'transformation_2d', 'offset_texture', 'tile_texture', 'cop_transform'],
|
|
896
896
|
inputs: FILTER_INPUT,
|
|
897
897
|
params: {
|
|
898
898
|
offset: { type: 'vec2', default: [0, 0], desc: 'shift in uv (0.5 = half the image)', aliases: ['translate', 't'] },
|
|
899
899
|
rotate: { type: 'float', default: 0, desc: 'rotation in degrees (counter-clockwise)', aliases: ['rotation', 'r', 'angle'] },
|
|
900
900
|
scale: { type: 'vec2', default: [1, 1], desc: 'zoom (> 1 enlarges the content)', aliases: ['s', 'zoom'] },
|
|
901
|
-
tile: { type: 'vec2', default: [1, 1], min: 0.001, desc: 'repeats of the content along u and v', aliases: ['tiling', 'repeat'] },
|
|
901
|
+
tile: { type: 'vec2', default: [1, 1], min: 0.001, desc: 'repeats of the content along u and v; cells start at the lower-left corner (uv 0, 0), so [1, 2] gives two stacked cells, each the whole image', aliases: ['tiling', 'repeat'] },
|
|
902
902
|
tileable: tileParam('repeat the source outside 0..1 (else black)'),
|
|
903
903
|
image: imageParam(), layer: layerParam(), name: renameParam(),
|
|
904
904
|
},
|
|
@@ -2078,8 +2078,8 @@ defineNode({
|
|
|
2078
2078
|
orm: { type: 'string', default: '', desc: 'packed occlusion / roughness / metallic image (R, G, B)', aliases: ['orm_map', 'packed'] },
|
|
2079
2079
|
group: P.group('prim', 'prims that get the material ("" = all prims when the material is new, else none)'),
|
|
2080
2080
|
base_color_tint: { type: 'color', default: [1, 1, 1], desc: 'base colour factor of a new material (glTF writes white under a base colour map)', aliases: ['tint'] },
|
|
2081
|
-
roughness_value: { type: 'float', default:
|
|
2082
|
-
metallic_value: { type: 'float', default:
|
|
2081
|
+
roughness_value: { type: 'float', default: -1, min: -1, max: 1, desc: 'roughness. -1 = unset: 0.8 for a new material; with an orm map the glTF roughnessFactor is 1 (a material on input 0 does not set it). A value is the roughnessFactor that multiplies the ORM green channel; for occlusion / metallic images packed here it fills the green channel when no roughness image is given' },
|
|
2082
|
+
metallic_value: { type: 'float', default: -1, min: -1, max: 1, desc: 'metallic. -1 = unset: 0 for a new material; with an orm map the glTF metallicFactor is 1 (a material on input 0 does not set it). A value is the metallicFactor that multiplies the ORM blue channel; for occlusion / metallic images packed here it fills the blue channel when no metallic image is given' },
|
|
2083
2083
|
},
|
|
2084
2084
|
outputs: 'prim "material", detail "materials" with image:<name> texture slots, the referenced images as image volumes',
|
|
2085
2085
|
example: {
|
|
@@ -2128,7 +2128,8 @@ defineNode({
|
|
|
2128
2128
|
};
|
|
2129
2129
|
const table = readMaterials(g);
|
|
2130
2130
|
const isNew = !table[mat];
|
|
2131
|
-
const
|
|
2131
|
+
const rv = Number(p.roughness_value) >= 0 ? Number(p.roughness_value) : null, mv = Number(p.metallic_value) >= 0 ? Number(p.metallic_value) : null;
|
|
2132
|
+
let entry = normalizeMaterial(table[mat] ?? { baseColor: p.base_color_tint, roughness: rv ?? 0.8, metallic: mv ?? 0 });
|
|
2132
2133
|
const tex = { ...(entry.textures ?? {}) };
|
|
2133
2134
|
const used = [];
|
|
2134
2135
|
for (const [param, slot] of SLOTS) {
|
|
@@ -2154,14 +2155,20 @@ defineNode({
|
|
|
2154
2155
|
const out = new Float32Array(n * 4);
|
|
2155
2156
|
for (let i = 0; i < n; i++) {
|
|
2156
2157
|
out[i * 4] = O ? O[i] : 1;
|
|
2157
|
-
out[i * 4 + 1] = R ? R[i] : entry.roughness;
|
|
2158
|
-
out[i * 4 + 2] = M ? M[i] : entry.metallic;
|
|
2158
|
+
out[i * 4 + 1] = R ? R[i] : rv ?? entry.roughness;
|
|
2159
|
+
out[i * 4 + 2] = M ? M[i] : mv ?? entry.metallic;
|
|
2159
2160
|
out[i * 4 + 3] = 1;
|
|
2160
2161
|
}
|
|
2161
2162
|
const orm = new Image(w, h, `${mat}_orm`).set(MAIN_LAYER, out);
|
|
2162
2163
|
used.push(orm);
|
|
2163
2164
|
tex.orm = `image:${orm.name}`;
|
|
2164
2165
|
delete tex.roughness;
|
|
2166
|
+
// the values are baked into the map: the factors that multiply it stay 1
|
|
2167
|
+
entry = { ...entry, roughness: 1, metallic: 1 };
|
|
2168
|
+
}
|
|
2169
|
+
else if (tex.orm) {
|
|
2170
|
+
// glTF semantics: the factors multiply the ORM map, so they default to 1; the input material's scalars do not apply
|
|
2171
|
+
entry = { ...entry, roughness: rv ?? 1, metallic: mv ?? 1 };
|
|
2165
2172
|
}
|
|
2166
2173
|
if (!used.length)
|
|
2167
2174
|
ctx.warn(`${type}: no image named in any slot (base_color, normal, roughness, metallic, occlusion, orm)`);
|
package/dist/nodes/topology.js
CHANGED
|
@@ -1356,9 +1356,10 @@ defineNode({
|
|
|
1356
1356
|
defineNode({
|
|
1357
1357
|
type: 'grid_split',
|
|
1358
1358
|
category: 'topology',
|
|
1359
|
-
summary: 'Split quads into a grid of cells by target size (facades → window cells) or fixed counts. Shared edges stay welded.',
|
|
1359
|
+
summary: 'Split quads into a grid of cells by target size (facades → window cells) or fixed counts. Shared edges stay welded. Only quads are split: cut first, then split.',
|
|
1360
|
+
description: 'Only 4-sided polygons are divided; triangles and n-gons pass through unsplit. After a boolean the faces around the cut are often n-gons, so they stay whole: run grid_split on the quads BEFORE the cut (or triangulate the n-gons first), not after it.',
|
|
1360
1361
|
aliases: ['divide_quads', 'facade_split', 'quad_split', 'split_faces'],
|
|
1361
|
-
inputs: [{ name: 'geo', desc: 'polygon mesh (quads are split;
|
|
1362
|
+
inputs: [{ name: 'geo', desc: 'polygon mesh (quads are split; triangles and n-gons pass through unsplit)' }],
|
|
1362
1363
|
params: {
|
|
1363
1364
|
group: P.group('prim', 'quads to split ("" = all)'),
|
|
1364
1365
|
mode: { type: 'enum', options: ['size', 'count'], default: 'size', desc: 'size = divide each edge by length / target size; count = fixed divisions' },
|
|
@@ -318,22 +318,35 @@ export declare class PackageUses implements SessionPackages {
|
|
|
318
318
|
uses(): Record<string, string>;
|
|
319
319
|
/**
|
|
320
320
|
* What exports and publishing resolve package names with: the published copies, whatever this session follows
|
|
321
|
-
* (following a working folder is for looking: the viewer, renders)
|
|
322
|
-
* followed.
|
|
321
|
+
* (following a working folder is for looking: the viewer, renders), but for the followed packages in `follow` (an
|
|
322
|
+
* export told to use their working folders). The package's own resolver while every followed package is in it.
|
|
323
323
|
*/
|
|
324
|
-
publishedResolver(): PackageResolver;
|
|
324
|
+
publishedResolver(follow?: readonly string[]): PackageResolver;
|
|
325
|
+
/** The followed packages among `follow`, sorted. */
|
|
326
|
+
private kept;
|
|
325
327
|
private publishedAt;
|
|
326
328
|
/**
|
|
327
329
|
* SessionPackages.published: while this session follows working folders, the scope exports cook in, like the root
|
|
328
|
-
* (its assets, graphs and folder) but resolving packages to their published copies
|
|
329
|
-
*
|
|
330
|
+
* (its assets, graphs and folder) but resolving packages to their published copies, the followed packages in `follow`
|
|
331
|
+
* to their working folders; null while every followed package is in `follow` (or nothing is followed): exports then
|
|
332
|
+
* cook in the root, as everything else.
|
|
330
333
|
*/
|
|
331
|
-
published(): Scope | null;
|
|
334
|
+
published(follow?: readonly string[]): Scope | null;
|
|
335
|
+
/**
|
|
336
|
+
* SessionPackages.unpublished: the followed packages `graph` names that an export would cook from published copies
|
|
337
|
+
* (those not in `follow`) while the package uses no published version of them: such an export cannot cook, and is
|
|
338
|
+
* refused, saying to publish them or to export from their working folders.
|
|
339
|
+
*/
|
|
340
|
+
unpublished(graph: GraphSpec, follow?: readonly string[]): {
|
|
341
|
+
package: string;
|
|
342
|
+
dir: string;
|
|
343
|
+
}[];
|
|
332
344
|
/**
|
|
333
345
|
* What an export of `graph` made while following says (null when the graph names no followed package): the
|
|
334
|
-
*
|
|
346
|
+
* working folders it used (those in `follow`: no published version, which its source record states under
|
|
347
|
+
* "followed"), and the published versions it used for the others, their working folders being for looking only.
|
|
335
348
|
*/
|
|
336
|
-
publishedNote(graph: GraphSpec): string | null;
|
|
349
|
+
publishedNote(graph: GraphSpec, follow?: readonly string[]): string | null;
|
|
337
350
|
/** SessionPackages: why the graphs cannot use packages (a folder in no package, a manifest that is not valid). */
|
|
338
351
|
notice(): string | null;
|
|
339
352
|
/** Load afresh, when next named, the copies that could not load or loaded with a warning (edited by hand). */
|
|
@@ -694,6 +694,8 @@ export function gatherCopies(ws) {
|
|
|
694
694
|
return out;
|
|
695
695
|
});
|
|
696
696
|
}
|
|
697
|
+
/** Whether a context resolves `pkg` to its working folder, when the session follows it. */
|
|
698
|
+
const followsIn = (ctx, pkg) => ctx.follows === true || (ctx.follows !== false && ctx.follows.has(pkg));
|
|
697
699
|
/**
|
|
698
700
|
* The packages of TopoTopo's built-in library at `dir`: topotopo/<name> for each folder <name> with versions/, a working
|
|
699
701
|
* folder too where it holds that package's manifest (in TopoTopo's repository). Sorted by name.
|
|
@@ -907,40 +909,69 @@ export class PackageUses {
|
|
|
907
909
|
uses() { return this.root.uses; }
|
|
908
910
|
/**
|
|
909
911
|
* What exports and publishing resolve package names with: the published copies, whatever this session follows
|
|
910
|
-
* (following a working folder is for looking: the viewer, renders)
|
|
911
|
-
* followed.
|
|
912
|
+
* (following a working folder is for looking: the viewer, renders), but for the followed packages in `follow` (an
|
|
913
|
+
* export told to use their working folders). The package's own resolver while every followed package is in it.
|
|
912
914
|
*/
|
|
913
|
-
publishedResolver() {
|
|
914
|
-
|
|
915
|
+
publishedResolver(follow = []) {
|
|
916
|
+
const kept = this.kept(follow);
|
|
917
|
+
if (kept.length === this.followed.size)
|
|
915
918
|
return this.resolver;
|
|
916
|
-
|
|
919
|
+
// the root as it is when asked (its uses change with use and update)
|
|
920
|
+
const follows = kept.length ? new Set(kept) : false, ctx = () => ({ ...this.root, follows });
|
|
921
|
+
return { resolve: (name) => this.resolveIn(ctx(), name), names: () => this.namesIn(ctx()) };
|
|
917
922
|
}
|
|
918
|
-
|
|
923
|
+
/** The followed packages among `follow`, sorted. */
|
|
924
|
+
kept(follow) { return [...new Set(follow)].filter((p) => this.followed.has(p)).sort(); }
|
|
925
|
+
publishedAt = new Map();
|
|
919
926
|
/**
|
|
920
927
|
* SessionPackages.published: while this session follows working folders, the scope exports cook in, like the root
|
|
921
|
-
* (its assets, graphs and folder) but resolving packages to their published copies
|
|
922
|
-
*
|
|
928
|
+
* (its assets, graphs and folder) but resolving packages to their published copies, the followed packages in `follow`
|
|
929
|
+
* to their working folders; null while every followed package is in `follow` (or nothing is followed): exports then
|
|
930
|
+
* cook in the root, as everything else.
|
|
923
931
|
*/
|
|
924
|
-
published() {
|
|
925
|
-
|
|
932
|
+
published(follow = []) {
|
|
933
|
+
const kept = this.kept(follow);
|
|
934
|
+
if (kept.length === this.followed.size)
|
|
926
935
|
return null;
|
|
936
|
+
const key = kept.join(','), have = this.publishedAt.get(key);
|
|
937
|
+
if (have)
|
|
938
|
+
return have;
|
|
927
939
|
const root = this.engine.root;
|
|
928
|
-
|
|
929
|
-
folder: root.files.resolvePath('.'), assets: root.assets, graphs: (n) => root.graphs?.(n), packages: this.publishedResolver(),
|
|
940
|
+
const scope = this.engine.createScope(`published copies ${sha(`${this.dir ?? ''}|${key}`).slice(0, 12)}`, {
|
|
941
|
+
folder: root.files.resolvePath('.'), assets: root.assets, graphs: (n) => root.graphs?.(n), packages: this.publishedResolver(kept),
|
|
930
942
|
});
|
|
931
|
-
|
|
943
|
+
this.publishedAt.set(key, scope);
|
|
944
|
+
return scope;
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* SessionPackages.unpublished: the followed packages `graph` names that an export would cook from published copies
|
|
948
|
+
* (those not in `follow`) while the package uses no published version of them: such an export cannot cook, and is
|
|
949
|
+
* refused, saying to publish them or to export from their working folders.
|
|
950
|
+
*/
|
|
951
|
+
unpublished(graph, follow = []) {
|
|
952
|
+
const named = new Set(packagesNamedIn(graph)), kept = new Set(follow);
|
|
953
|
+
return [...this.followed.values()].filter((f) => named.has(f.package) && !kept.has(f.package) && this.root.uses[f.package] === undefined)
|
|
954
|
+
.map((f) => ({ package: f.package, dir: f.dir }));
|
|
932
955
|
}
|
|
933
956
|
/**
|
|
934
957
|
* What an export of `graph` made while following says (null when the graph names no followed package): the
|
|
935
|
-
*
|
|
958
|
+
* working folders it used (those in `follow`: no published version, which its source record states under
|
|
959
|
+
* "followed"), and the published versions it used for the others, their working folders being for looking only.
|
|
936
960
|
*/
|
|
937
|
-
publishedNote(graph) {
|
|
938
|
-
const named = new Set(packagesNamedIn(graph));
|
|
961
|
+
publishedNote(graph, follow = []) {
|
|
962
|
+
const named = new Set(packagesNamedIn(graph)), kept = new Set(this.kept(follow));
|
|
939
963
|
const live = [...this.followed.values()].filter((f) => named.has(f.package));
|
|
940
964
|
if (!live.length)
|
|
941
965
|
return null;
|
|
942
|
-
const
|
|
943
|
-
|
|
966
|
+
const working = live.filter((f) => kept.has(f.package)), shown = live.filter((f) => !kept.has(f.package));
|
|
967
|
+
const notes = [];
|
|
968
|
+
if (working.length)
|
|
969
|
+
notes.push(`the export used the working folder of ${working.map((f) => f.package).join(', ')}, not a published version: its source record lists ${working.length === 1 ? 'it' : 'them'} under "followed"`);
|
|
970
|
+
if (shown.length) {
|
|
971
|
+
const used = shown.map((f) => (this.root.uses[f.package] ? `${f.package} ${this.root.uses[f.package]}` : `${f.package} (no published version in use: publish one, and use it)`));
|
|
972
|
+
notes.push(`this session shows ${shown.map((f) => f.package).join(', ')} live from ${shown.length === 1 ? 'its working folder' : 'their working folders'}, for looking; the export used the published ${used.join(', ')}`);
|
|
973
|
+
}
|
|
974
|
+
return notes.join('\n');
|
|
944
975
|
}
|
|
945
976
|
/** SessionPackages: why the graphs cannot use packages (a folder in no package, a manifest that is not valid). */
|
|
946
977
|
notice() {
|
|
@@ -1078,8 +1109,8 @@ export class PackageUses {
|
|
|
1078
1109
|
}
|
|
1079
1110
|
namesIn(ctx) {
|
|
1080
1111
|
const pkgs = new Set(Object.keys(ctx.uses));
|
|
1081
|
-
|
|
1082
|
-
|
|
1112
|
+
for (const k of this.followed.keys())
|
|
1113
|
+
if (followsIn(ctx, k))
|
|
1083
1114
|
pkgs.add(k);
|
|
1084
1115
|
if (ctx.self)
|
|
1085
1116
|
pkgs.add(ctx.self.package);
|
|
@@ -1099,7 +1130,7 @@ export class PackageUses {
|
|
|
1099
1130
|
// the package's own outputs: the same version (or working folder), with no entry in its uses
|
|
1100
1131
|
if (ctx.self?.package === pkg)
|
|
1101
1132
|
return ctx.self.get();
|
|
1102
|
-
if (
|
|
1133
|
+
if (this.followed.has(pkg) && followsIn(ctx, pkg))
|
|
1103
1134
|
return this.loadFollowed(pkg);
|
|
1104
1135
|
const v = ctx.uses[pkg];
|
|
1105
1136
|
if (v !== undefined)
|
|
@@ -1391,7 +1422,9 @@ export class PackageUses {
|
|
|
1391
1422
|
*/
|
|
1392
1423
|
locked(graph) {
|
|
1393
1424
|
const adds = this.dryRun(graph).adds.map((a) => `the graph names ${a.package}, which ${this.usesFileName} does not use: ${program()} use ${a.package} adds it (a cook without --locked adds it)`);
|
|
1394
|
-
|
|
1425
|
+
// a working folder followed for this run is no version: a build machine cooks published versions alone
|
|
1426
|
+
const working = this.unpublished(graph).map((u) => `the graph names ${u.package}, which ${this.usesFileName} does not use, and its working folder (followed) is no published version: publish ${u.package} (${program()} publish ${u.dir} --note "...") and use it`);
|
|
1427
|
+
return [...adds, ...working, ...(this.dir && this.manifest ? this.verifyCopies() : [])];
|
|
1395
1428
|
}
|
|
1396
1429
|
/** The packages a graph names that the package does not use yet (nor follows, nor is). */
|
|
1397
1430
|
freshIn(graph) {
|
|
@@ -1479,7 +1512,7 @@ export class PackageUses {
|
|
|
1479
1512
|
versionToAdd(pkg, v, scanned) {
|
|
1480
1513
|
const found = this.find(pkg, scanned);
|
|
1481
1514
|
if (!found.versions.size)
|
|
1482
|
-
throw new Error(`${pkg} is in ${found.place} (${found.dir}) but has no published version yet: publish one in its folder (${program()} publish ${found.working ? `${found.dir} ` : ''}--note "...")`);
|
|
1515
|
+
throw new Error(`${pkg} is in ${found.place} (${found.dir}) but has no published version yet: publish one in its folder (${program()} publish ${found.working ? `${found.dir} ` : ''}--note "...")${found.working ? `, or pass --follow ${pkg} to cook and export from its working folder, unpublished (MCP: workspace {action:"follow", package:"${pkg}", on:true}, then export {follow:["${pkg}"]})` : ''}`);
|
|
1483
1516
|
const version = v ?? newestOf(found.versions.keys());
|
|
1484
1517
|
const place = found.versions.get(version);
|
|
1485
1518
|
if (!place)
|
|
@@ -1675,7 +1708,7 @@ export class PackageUses {
|
|
|
1675
1708
|
this.restamp();
|
|
1676
1709
|
this.rewatch();
|
|
1677
1710
|
const v = this.root.uses[pkg];
|
|
1678
|
-
return `following ${pkg} for this session: its working folder ${found.dir} (${found.place}) instead of ${v ? `the copy of ${v}` : 'a copy (the package does not use it yet)'}; its edits re-cook, for looking: exports and publishing use the published copy`;
|
|
1711
|
+
return `following ${pkg} for this session: its working folder ${found.dir} (${found.place}) instead of ${v ? `the copy of ${v}` : 'a copy (the package does not use it yet)'}; its edits re-cook, for looking: exports and publishing use the published copy, but an export told to follow it (CLI --follow ${pkg}, MCP export {follow:["${pkg}"]}) exports from the working folder`;
|
|
1679
1712
|
}
|
|
1680
1713
|
/**
|
|
1681
1714
|
* Follow, for this session, every package in use whose one working folder the policy accepts (a
|