3D engine that AI agents drive
Add brick, whiteNoise, coord and mapping material graph nodes (#708)
Nguyen Xuan And0a98ae78bce
diff --git a/changes/708.md b/changes/708.mdnew file mode 100644index 00000000..142e23f7--- /dev/null+++ b/changes/708.md@@ -0,0 +1 @@+- Material graphs get `brick`, `whiteNoise`, `coord` and `mapping` nodes, so a procedural material works on a mesh without UVs (#708)diff --git a/changes/708.size.md b/changes/708.size.mdnew file mode 100644index 00000000..6556373f--- /dev/null+++ b/changes/708.size.md@@ -0,0 +1,3 @@+- scene:agent-scene: the node names and the coordinate topic text sit in scene_capabilities (338 bytes gzip), which agents read to use the nodes; an agent without the text cannot use brick, whiteNoise, coord or mapping+- scene:agent-scene+lazy: brick, whiteNoise, coord and mapping compile in the lazy material graph (1121 bytes gzip in all, text included); they make a procedural material usable on a mesh without UVs+- goal:agent-scene: the bundle is over its goal already; the growth is agent-facing capability with a rendered proof (a brick wall and confetti on UV-less meshes)diff --git a/docs/agent-scene.md b/docs/agent-scene.mdindex a8acebdb..aef6b1b9 100644--- a/docs/agent-scene.md+++ b/docs/agent-scene.md@@ -185,6 +185,15 @@ it. Scales and counts are whole numbers (1 to 64, even for `checker`), so every(2D, detail `octaves - 1`, roughness 0.5, lacunarity 2, normalized; `seed` moves the lattice by whole cells) with the latticewrapped so it repeats. `"tile": false` matches Blender's Noise Texture exactly, does not repeat.+Placement and pattern nodes:++- `brick` (`columns` 8, `rows` 8 and even, `mortar` 0.05 of a brick, `offset` 0.5 for every other row, `seed`, `output`: `mortar` is 1 in the joint, `edge` is 0 at a joint and 1 at the brick centre, `cell` is one random value per brick) lays a running bond and costs 4. Whole columns and even rows keep it tiling.+- `whiteNoise` (`scale` 16, `seed`, `output`: `value` or `color` for three independent values) is one random value per cell of a `scale` by `scale` grid. It tiles and is the same for the same seed.+- `coord` (`"generated"`, `"object"` or `"world"`) is a vector for `at`. `generated` is the unit tile, `object` and `world` are metres across the tile (texture u and v times the pattern `size`). A baked texture is projected onto the mesh, so it knows only the two axes of that projection and the third is 0; `object` and `world` are the same because box mapping reads the placed, scaled position.+- `mapping` (`vector`, default `{ "coord": "generated" }`; `scale` a number or `[x, y, z]`; `rotate` radians around Z; `offset` `[x, y, z]`) scales, turns and moves a vector, as Blender's Mapping node does. Feed it to `at`.++These make a material work on a mesh without UVs: box mapping (the default) projects the baked graph along the object axes, so a brick wall or a noise pattern needs no unwrap. `vertex_color` on a mesh already multiplies the baked colour. Not in graphs yet: ambient occlusion, bevel and curvature masks, fresnel and an image texture node (they need per-vertex or per-pixel data that a bake from `u` and `v` alone does not have).+Limits, checked while the recipe is read: at most 64 nodes in all outputs, depth 12 (the field expression limits), at most 8 rampstops, `resolution` of 256, 512 or 1024, and a work budget of 30 million units, where a plain node costs 1, a `noise` octave 3and a `voronoi` 8, per pixel and per pixel of the texture. A heavy graph at 1024 can be over it; use 512. A graph that is over adiff --git a/src/agent-scene-capabilities.js b/src/agent-scene-capabilities.jsindex 646b005a..2a32ae55 100644--- a/src/agent-scene-capabilities.js+++ b/src/agent-scene-capabilities.js@@ -52,7 +52,7 @@ export const MAX_MATERIAL_PATTERNS = 16;// expression limits; maxWork is work units per pixel times pixels, so a costly graph needs a smaller texture.export const MATERIAL_GRAPH_OUTPUTS = Object.freeze(['color', 'roughness', 'metallic', 'emission', 'height', 'opacity', 'clearcoat', 'transmission', 'aov']);export const MATERIAL_GRAPH_OPERATORS = Object.freeze([- 'uv', 'vec', 'ramp', 'noise', 'voronoi', 'wave', 'checker', 'gradient',+ 'uv', 'coord', 'mapping', 'vec', 'ramp', 'noise', 'whiteNoise', 'brick', 'voronoi', 'wave', 'checker', 'gradient','add', 'sub', 'mul', 'div', 'min', 'max', 'pow', 'abs', 'floor', 'fract', 'sqrt', 'invert', 'clamp', 'smoothstep', 'mix','layer', 'hue', 'curve',]);@@ -78,9 +78,12 @@ export const MATERIAL_GRAPH_NODES = Object.freeze({wave: '{"wave":{"frequency":4,"direction":"u"|"v"|"diagonal","shape":"sine"|"saw"|"triangle"}}',checker: '{"checker":{"count":8}} (even)',gradient: '{"gradient":{"type":"u"|"v"|"radial"}}',+ whiteNoise: '{"whiteNoise":{"scale":16,"seed":1,"output":"value"|"color"}} one random value per cell, tiles.',+ brick: '{"brick":{"columns":8,"rows":4,"mortar":0.05,"offset":0.5,"seed":1,"output":"mortar"|"edge"|"cell"}} running bond; rows even.',note: 'Each takes "at", a vector such as {"uv":"both"}. Scales are whole numbers 1-64.',}),uv: '{"uv":"u"|"v"|"both"} coordinates.',+ coordinates: '{"coord":"generated"|"object"|"world"} vector of where the texel sits: generated is the unit tile, object and world are metres across the tile (u * size); the third axis is 0 because a baked texture is projected. {"mapping":{"vector":node,"scale":n|[x,y,z],"offset":[x,y,z],"rotate":radians}} scales, turns around Z and moves a vector (default: generated). Feed either to "at". Meshes without UVs use box mapping; vertex_color already multiplies the baked colour. Not in graphs yet: AO, bevel, curvature, fresnel, image.',ramp: '{"ramp":{"value":node,"stops":[[0,[r,g,b]],[1,[r,g,b]]]}} 2-8 stops rising from 0 to 1.',mixing: '{"layer":{"base","top","mask","edge","softness"}}; {"hue":{"color","shift","saturation","value"}}; {"curve":{"value","points":[[x,y]]}}.',maths: 'add sub mul div min max pow take [a,b]; abs floor fract sqrt invert take one node; clamp smoothstep mix take [a,b,c]; {"vec":[r,g,b]}.',diff --git a/src/material-graph.js b/src/material-graph.jsindex d7cd8237..b5c94251 100644--- a/src/material-graph.js+++ b/src/material-graph.js@@ -1,5 +1,5 @@import { MATERIAL_GRAPH_LIMITS, MATERIAL_GRAPH_OUTPUTS, MATERIAL_GRAPH_OPERATORS } from './agent-scene-capabilities.js';-import { clampUnit, smoothStep, wrapCell, cellularNoise, linearToSrgbByte, createImage, normalMapFromHeightFunction } from './material-texture-kit.js';+import { clampUnit, smoothStep, wrapCell, hashCell, cellularNoise, linearToSrgbByte, createImage, normalMapFromHeightFunction } from './material-texture-kit.js';// A bounded material node graph. Like a field expression (src/mesh-fields.js), a graph is data and never code: it is// walked as plain objects against a fixed table of operators, checked against its limits before any pixel is@@ -433,8 +433,95 @@ function compileCurve(node, state, depth) {return liftComponentwise([compileNode(settings.value, state, depth + 1)], remap);}+const COORDINATE_SPACES = ['generated', 'object', 'world'];++// Where a texel sits on the surface. A baked texture is projected onto the mesh (box mapping along the object axes, or+// its UVs), so the two axes it knows are the only ones a texel can report: the third is 0. "generated" is the unit tile,+// "object" and "world" are metres across the tile (u * size). Box mapping reads the placed, scaled position, so the+// two are the same here.+function compileCoordinate(node, state) {+ const space = oneOf(node.coord, COORDINATE_SPACES, 'coord');+ if (Object.keys(node).length !== 1) throw graphError('coord takes no other fields.');+ const metres = space === 'generated' ? 1 : state.size;+ return vectorValue(u => u * metres, (u, v) => v * metres, () => 0);+}++const MAPPING_FIELDS = ['vector', 'scale', 'offset', 'rotate'];++function mappingTriple(value, fallback, label) {+ if (value === undefined) return fallback;+ const triple = typeof value === 'number' ? [value, value, value] : value;+ if (!Array.isArray(triple) || triple.length !== 3 || !triple.every(finiteLiteral)) throw graphError(`mapping "${label}" is a number or [x, y, z] of finite numbers.`);+ return triple;+}++// Blender's Mapping node (point): scale, then rotate around Z, then move. The vector defaults to {"coord":"generated"}.+function compileMapping(node, state, depth) {+ const settings = textureSettings(node, 'mapping', MAPPING_FIELDS);+ const [scaleX, scaleY, scaleZ] = mappingTriple(settings.scale, [1, 1, 1], 'scale');+ const [offsetX, offsetY, offsetZ] = mappingTriple(settings.offset, [0, 0, 0], 'offset');+ const rotation = settings.rotate ?? 0;+ if (!finiteLiteral(rotation)) throw graphError('mapping "rotate" is an angle in radians around Z.');+ const input = compileNode(settings.vector ?? { coord: 'generated' }, state, depth + 1);+ if (input.kind !== 'vector') throw graphError('mapping "vector" needs a vector such as {"coord":"generated"}.');+ const [inputX, inputY, inputZ] = input.parts;+ const cosine = Math.cos(rotation);+ const sine = Math.sin(rotation);+ const rotatedX = (u, v) => inputX(u, v) * scaleX * cosine - inputY(u, v) * scaleY * sine + offsetX;+ const rotatedY = (u, v) => inputX(u, v) * scaleX * sine + inputY(u, v) * scaleY * cosine + offsetY;+ return vectorValue(rotatedX, rotatedY, (u, v) => inputZ(u, v) * scaleZ + offsetZ);+}++const BRICK_OUTPUTS = ['mortar', 'edge', 'cell'];+const BRICK_COST = 4;++// Blender's Brick Texture, laid in a running bond. Whole columns and an even number of rows keep it tileable.+function compileBrick(node, state, depth) {+ const settings = textureSettings(node, 'brick', ['columns', 'rows', 'mortar', 'offset', 'seed', 'output', 'at']);+ const columns = integerInRange(settings.columns ?? 8, 1, NOISE_SCALE_LIMIT, 'brick columns');+ const rows = integerInRange(settings.rows ?? 8, 2, NOISE_SCALE_LIMIT, 'brick rows');+ if (rows % 2 !== 0) throw graphError('brick rows must be even so the bond tiles.');+ const seed = integerInRange(settings.seed ?? 0, 0, MAX_SEED, 'brick seed');+ const output = oneOf(settings.output ?? 'mortar', BRICK_OUTPUTS, 'brick output');+ const mortar = settings.mortar ?? 0.05;+ const offset = settings.offset ?? 0.5;+ if (!finiteLiteral(mortar) || mortar < 0 || mortar > 0.5) throw graphError('brick mortar is the joint width as a share of a brick, from 0 to 0.5.');+ if (!finiteLiteral(offset) || offset < 0 || offset >= 1) throw graphError('brick offset is the shift of every other row as a share of a brick, from 0 up to 1.');+ state.cost += BRICK_COST;+ const [positionU, positionV] = compilePosition(settings, state, depth);+ return scalarValue((u, v) => {+ const scaledV = positionV(u, v) * rows;+ const row = Math.floor(scaledV);+ const scaledU = positionU(u, v) * columns + (wrapCell(row, 2) === 1 ? offset : 0);+ const column = Math.floor(scaledU);+ if (output === 'cell') return hashCell(wrapCell(column, columns), wrapCell(row, rows), seed) / 4294967296;+ const fractionU = scaledU - column;+ const fractionV = scaledV - row;+ const distance = Math.min(fractionU, 1 - fractionU, fractionV, 1 - fractionV);+ if (output === 'edge') return clampUnit(distance * 2);+ return mortar === 0 ? 0 : 1 - smoothStep(mortar * 0.5, mortar, distance);+ });+}++const WHITE_NOISE_OUTPUTS = ['value', 'color'];++// A random value per cell of a scale by scale grid; the cells wrap, so it tiles. "color" is three independent values.+function compileWhiteNoise(node, state, depth) {+ const settings = textureSettings(node, 'whiteNoise', ['scale', 'seed', 'output', 'at']);+ const scale = integerInRange(settings.scale ?? 16, 1, NOISE_SCALE_LIMIT, 'whiteNoise scale');+ const seed = integerInRange(settings.seed ?? 0, 0, MAX_SEED, 'whiteNoise seed');+ const output = oneOf(settings.output ?? 'value', WHITE_NOISE_OUTPUTS, 'whiteNoise output');+ const [positionU, positionV] = compilePosition(settings, state, depth);+ const channel = channelIndex => (u, v) => {+ const cellX = wrapCell(Math.floor(positionU(u, v) * scale), scale);+ const cellY = wrapCell(Math.floor(positionV(u, v) * scale), scale);+ return hashCell(cellX, cellY, (seed + channelIndex * 7919) | 0) / 4294967296;+ };+ return output === 'color' ? vectorValue(channel(1), channel(2), channel(3)) : scalarValue(channel(0));+}+const TEXTURE_COMPILERS = new Map([- ['noise', compileNoise], ['voronoi', compileVoronoi], ['wave', compileWave], ['checker', compileChecker], ['gradient', compileGradient],+ ['noise', compileNoise], ['whiteNoise', compileWhiteNoise], ['brick', compileBrick], ['voronoi', compileVoronoi], ['wave', compileWave], ['checker', compileChecker], ['gradient', compileGradient],]);function compileNode(node, state, depth) {@@ -456,6 +543,8 @@ function compileNode(node, state, depth) {if (keys.length !== 1) throw graphError(`a node holds exactly one operator; got ${keys.length}.`);const name = keys[0];if (name === 'uv') return compileCoordinates(node);+ if (name === 'coord') return compileCoordinate(node, state);+ if (name === 'mapping') return compileMapping(node, state, depth);if (name === 'vec') return compileVector(node, state, depth);if (name === 'ramp') return compileRamp(node, state, depth);if (name === 'layer') return compileLayer(node, state, depth);@@ -469,15 +558,15 @@ function compileNode(node, state, depth) {const SCALAR_OUTPUTS = ['roughness', 'metallic', 'height', 'opacity', 'clearcoat', 'transmission'];/**- * Check a graph and compile each output. Limits on nodes, depth and work per pixel are enforced here, before any+ * Check a graph and compile each output. `size` is the metres one texture tile covers, which object and world coordinates report. Limits on nodes, depth and work per pixel are enforced here, before any* pixel is evaluated. Returns { outputs: { name: compiled }, nodeCount, cost }.*/-export function compileMaterialGraph(graph) {+export function compileMaterialGraph(graph, { size = 1 } = {}) {if (!isPlainObject(graph)) throw graphError(`graph must be an object with outputs: ${MATERIAL_GRAPH_OUTPUTS.join(', ')}.`);onlyKeys(graph, MATERIAL_GRAPH_OUTPUTS, 'graph');const names = Object.keys(graph);if (names.length === 0) throw graphError(`graph needs at least one output: ${MATERIAL_GRAPH_OUTPUTS.join(', ')}.`);- const state = { nodeCount: 0, cost: 0 };+ const state = { nodeCount: 0, cost: 0, size };const outputs = {};for (const name of names) {outputs[name] = compileNode(graph[name], state, 0);@@ -526,8 +615,8 @@ function writeColor(data, offset, channels) {}/** Bake a normalized graph into texture descriptors, one for each output the graph has. Deterministic. */-export function bakeMaterialGraph(graph, { resolution, bump }) {- const compiled = compileMaterialGraph(graph);+export function bakeMaterialGraph(graph, { resolution, bump, size = 1 }) {+ const compiled = compileMaterialGraph(graph, { size });checkMaterialGraphWork(compiled, resolution);const { color, roughness, metallic, emission, height, opacity, clearcoat, transmission, aov } = compiled.outputs;const pixelCount = resolution * resolution;diff --git a/tests/material-graph-geometry.test.js b/tests/material-graph-geometry.test.jsnew file mode 100644index 00000000..b7637319--- /dev/null+++ b/tests/material-graph-geometry.test.js@@ -0,0 +1,119 @@+import './support/load-agent-scene-modules.mjs';+import assert from 'node:assert/strict';+import test from 'node:test';+import { bakeMaterialPattern, normalizeMaterialPattern } from '../src/material-patterns.js';+import { compileMaterialGraph } from '../src/material-graph.js';+import { AGENT_SCENE_CAPABILITIES } from '../src/agent-scene-capabilities.js';++function evaluate(graph, output, u = 0.3, v = 0.6, options) {+ const compiled = compileMaterialGraph(graph, options).outputs[output];+ return compiled.kind === 'vector' ? compiled.parts.map(part => part(u, v)) : compiled.evaluate(u, v);+}++test('coord reports the unit tile as generated and metres across the tile as object and world', () => {+ assert.deepEqual(evaluate({ color: { coord: 'generated' } }, 'color', 0.25, 0.5, { size: 4 }), [0.25, 0.5, 0]);+ assert.deepEqual(evaluate({ color: { coord: 'object' } }, 'color', 0.25, 0.5, { size: 4 }), [1, 2, 0]);+ assert.deepEqual(evaluate({ color: { coord: 'world' } }, 'color', 0.25, 0.5, { size: 4 }), [1, 2, 0]);+});++test('mapping scales, turns around Z and moves a vector, defaulting to the generated coordinates', () => {+ const mapped = settings => evaluate({ color: { mapping: settings } }, 'color', 0.5, 0.25);+ assert.deepEqual(mapped({ scale: 2 }), [1, 0.5, 0]);+ assert.deepEqual(mapped({ offset: [1, 2, 3] }), [1.5, 2.25, 3]);+ const [turnedX, turnedY] = mapped({ rotate: Math.PI / 2 });+ assert.ok(Math.abs(turnedX + 0.25) < 1e-12 && Math.abs(turnedY - 0.5) < 1e-12);+ assert.deepEqual(evaluate({ color: { mapping: { vector: { coord: 'object' }, scale: [1, 1, 1] } } }, 'color', 0.5, 0.25, { size: 2 }), [1, 0.5, 0]);+});++test('a mapped vector can place a texture through "at"', () => {+ const stretched = evaluate({ height: { gradient: { type: 'u', at: { mapping: { scale: [0.5, 1, 1] } } } } }, 'height', 0.5, 0.5);+ assert.equal(stretched, 0.25);+});++test('brick lays a running bond: mortar between bricks, a random value inside each brick, offset on odd rows', () => {+ const brick = (output, u, v, extra = {}) => evaluate({ height: { brick: { columns: 4, rows: 4, mortar: 0.2, output, ...extra } } }, 'height', u, v);+ assert.equal(brick('mortar', 0.125, 0.125), 0, 'centre of a brick is not mortar');+ assert.equal(brick('mortar', 0.25, 0.125), 1, 'the vertical joint is mortar');+ assert.equal(brick('mortar', 0.125, 0.25), 1, 'the horizontal joint is mortar');+ assert.equal(brick('mortar', 0.25, 0.375), 0, 'odd rows shift by half a brick, so a joint of row 0 is a brick centre in row 1');+ assert.equal(brick('edge', 0.125, 0.125), 1);+ assert.equal(brick('edge', 0.25, 0.125), 0);+ assert.equal(brick('cell', 0.1, 0.1), brick('cell', 0.2, 0.2), 'one value for the whole brick');+ assert.notEqual(brick('cell', 0.1, 0.1), brick('cell', 0.1, 0.4));+ assert.notEqual(brick('cell', 0.1, 0.1, { seed: 1 }), brick('cell', 0.1, 0.1, { seed: 2 }));+});++test('brick and whiteNoise tile over the unit square and are deterministic for the same seed', () => {+ const graph = seed => ({+ height: { add: [{ brick: { columns: 5, rows: 6, output: 'cell', seed } }, { whiteNoise: { scale: 7, seed } }] },+ });+ const first = compileMaterialGraph(graph(3)).outputs.height;+ const second = compileMaterialGraph(graph(3)).outputs.height;+ const other = compileMaterialGraph(graph(4)).outputs.height;+ const epsilon = 1e-9;+ for (const v of [0.05, 0.33, 0.9]) {+ assert.equal(first.evaluate(epsilon, v), first.evaluate(1 + epsilon, v));+ assert.equal(first.evaluate(v, epsilon), first.evaluate(v, 1 + epsilon));+ assert.equal(first.evaluate(v, 0.4), second.evaluate(v, 0.4));+ }+ assert.notEqual(first.evaluate(0.31, 0.77), other.evaluate(0.31, 0.77));+});++test('whiteNoise is one value per cell and a colour is three independent values', () => {+ const value = (u, v) => evaluate({ height: { whiteNoise: { scale: 4, seed: 9 } } }, 'height', u, v);+ assert.equal(value(0.01, 0.01), value(0.24, 0.24));+ assert.notEqual(value(0.01, 0.01), value(0.3, 0.01));+ const [red, green, blue] = evaluate({ color: { whiteNoise: { scale: 4, output: 'color' } } }, 'color', 0.1, 0.1);+ assert.ok(red !== green && green !== blue);+ for (const channel of [red, green, blue, value(0.5, 0.5)]) assert.ok(channel >= 0 && channel < 1);+});++test('invalid input names the node and the fix', () => {+ const failing = (graph, message) => assert.throws(() => compileMaterialGraph(graph), message);+ failing({ color: { coord: 'camera' } }, /coord must be one of generated, object, world/);+ failing({ color: { coord: 'object', extra: 1 } }, /one operator|coord takes no other fields/);+ failing({ color: { mapping: { scale: 'big' } } }, /mapping "scale" is a number or \[x, y, z\]/);+ failing({ color: { mapping: { vector: 0.5 } } }, /mapping "vector" needs a vector/);+ failing({ color: { mapping: { rotate: Infinity } } }, /mapping "rotate" is an angle/);+ failing({ color: { mapping: { colour: 1 } } }, /mapping does not take "colour"/);+ failing({ height: { brick: { rows: 3 } } }, /brick rows must be even/);+ failing({ height: { brick: { columns: 0 } } }, /brick columns must be a whole number from 1 to 64/);+ failing({ height: { brick: { mortar: 0.9 } } }, /brick mortar is the joint width/);+ failing({ height: { brick: { output: 'shine' } } }, /brick output must be one of mortar, edge, cell/);+ failing({ height: { whiteNoise: { scale: 100 } } }, /whiteNoise scale must be a whole number from 1 to 64/);+ failing({ height: { whiteNoise: { output: 'rgb' } } }, /whiteNoise output must be one of value, color/);+});++test('a graph with the new nodes bakes on box mapping without UVs and counts toward the work budget', () => {+ const pattern = normalizeMaterialPattern({+ type: 'graph', resolution: 256, size: 2,+ graph: {+ color: { ramp: { value: { brick: { columns: 4, rows: 4, output: 'cell' } }, stops: [[0, [0.4, 0.1, 0.05]], [1, [0.7, 0.3, 0.2]]] } },+ height: { invert: { brick: { columns: 4, rows: 4, mortar: 0.1 } } },+ },+ });+ assert.equal(pattern.mapping, undefined, 'box mapping, so the mesh needs no UVs');+ const first = bakeMaterialPattern(pattern);+ const second = bakeMaterialPattern(pattern);+ assert.ok(first.map && first.normalMap);+ assert.ok(first.boxMapScale > 0);+ assert.deepEqual(first.map.image.data, second.map.image.data);+ assert.throws(() => normalizeMaterialPattern({+ type: 'graph', resolution: 1024,+ graph: Object.fromEntries(['color', 'roughness', 'metallic', 'height'].map(name => [name, { brick: { columns: 64, rows: 64, at: { mapping: { scale: 2, vector: { mapping: { scale: 2 } } } } } }])),+ }), /work units per pixel|nodes/);+});++test('object coordinates follow the pattern size when baked', () => {+ const graph = { color: { fract: { coord: 'object' } } };+ const small = bakeMaterialPattern(normalizeMaterialPattern({ type: 'graph', resolution: 256, size: 0.5, graph }));+ const large = bakeMaterialPattern(normalizeMaterialPattern({ type: 'graph', resolution: 256, size: 4, graph }));+ assert.notDeepEqual(small.map.image.data, large.map.image.data);+});++test('scene_capabilities lists the new operators and the coordinate topic text', () => {+ const { materialGraph } = AGENT_SCENE_CAPABILITIES;+ for (const operator of ['coord', 'mapping', 'brick', 'whiteNoise']) assert.ok(materialGraph.operators.includes(operator), operator);+ assert.ok(materialGraph.nodes.coordinates.includes('"coord"'));+ assert.ok(materialGraph.nodes.textures.brick && materialGraph.nodes.textures.whiteNoise);+});diff --git a/tests/material-graph.test.js b/tests/material-graph.test.jsindex 54d293f6..c70332bb 100644--- a/tests/material-graph.test.js+++ b/tests/material-graph.test.js@@ -177,7 +177,7 @@ test('graph and preset fields do not mix', () => {test('every capability operator compiles, and no other operator does', () => {const samples = {- uv: { uv: 'u' }, vec: { vec: [1, 2, 3] }, ramp: { ramp: { value: 0.5, stops: [[0, 0], [1, 1]] } },+ uv: { uv: 'u' }, coord: { coord: 'object' }, mapping: { mapping: {} }, whiteNoise: { whiteNoise: {} }, brick: { brick: {} }, vec: { vec: [1, 2, 3] }, ramp: { ramp: { value: 0.5, stops: [[0, 0], [1, 1]] } },noise: { noise: {} }, voronoi: { voronoi: {} }, wave: { wave: {} }, checker: { checker: {} }, gradient: { gradient: {} },layer: { layer: { base: [0, 0, 0], top: [1, 1, 1], mask: 0.5 } }, hue: { hue: { color: [1, 0, 0], shift: 0.1 } }, curve: { curve: { value: 0.5, points: [[0, 0], [1, 1]] } },};@@ -285,7 +285,7 @@ test('the same graph shares one baked texture set across materials', () => {});test('graph errors name the valid options, and scene_capabilities lists the nodes an agent can use', () => {- assert.throws(() => compileMaterialGraph({ color: { glow: 1 } }), /unknown operator "glow"\. Use one of uv, vec, ramp/);+ assert.throws(() => compileMaterialGraph({ color: { glow: 1 } }), /unknown operator "glow"\. Use one of uv, coord, mapping, vec, ramp/);assert.throws(() => compileMaterialGraph({ shine: 1 }), /color, roughness, metallic, emission, height/);assert.throws(() => compileMaterialGraph({ color: { noise: { size: 4 } } }), /does not take "size"; fields: /);assert.throws(() => compileMaterialGraph({ color: { wave: { frequency: 4, shape: 'square' } } }), /must be one of sine, saw, triangle/);