A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(modeling): scatter stands copies off a path in rows - rows 1 or 2 with sweep, lift and up lays the leaflets of a frond or the barbs of a feather in one step where each was a step of its own, and sizes shapes them along the path; a palm of 386 steps is 40
yhh27feea6c68bb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b0404027e..5d588ecd3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,7 @@ published separately; it ships inside the editor.### Added- **A layer with a grain is read without repeat and without hexagons.** Near the eye a terrain layer is read in hexagonal cells, each shifted and turned at random, so no tile shows. A layer with a direction to it (sand in ripples, rock in beds) turned cell by cell has its normal map lit cell by cell, and the ground showed a mosaic of light and dark hexagons a metre wide. `u_antiTileTurn` on the Terrain and Terrain Layers materials is how far round a cell may be turned: 1, the default, is any way as before; 0 shifts the cell and does not turn it, which is the setting for a layer with a grain.+- **An AI can lay leaflets along a stem in one step.** `scatter` along a `path` pointed every copy the way the path runs, turned at random, so the leaflets of a frond, the barbs of a feather or the legs of a centipede had to be written out one step each: a palm was 386 steps and a 749 KB model file. `rows` (1 or 2) stands the copies off the path instead, in a row or in pairs, `sweep` degrees from the way it runs and `lift` out of the plane, each as one number or as a start and an end. A copy's +z faces `up`, so a flat blade keeps its face to the sky whichever way it points. `sizes` shapes them along the path, widest in the middle if you say so. The same palm is 40 steps and 38 KB, and bakes to the same triangle count. A scatter without `rows` is as it was.- **A game calls its own native code by name.** A packaged Android or iOS game can link an ad SDK, a store or a sign-in library, and had no way to reach it: the native host answered the engine's own calls and nothing else. `NativeChannel.call(method, args)` now runs a handler the app registered (`com.estella.host.NativeChannel.register` in Java, `EstellaNativeChannel` in Objective-C) and resolves with what it answered; `has` says whether a name is answered and `on` hears what the native side raises on its own. Values cross as JSON. `Ads` rides on it: once the app's code answers `ads.show`, `Ads.available` is true on a device and `showRewarded` works as it does in a mini-game. The engine links no ad SDK; which one is the project's choice. An exported Android Studio project keeps your Java under `app/src/game`, which a re-export leaves alone. Elsewhere `has` is false and nothing is called, so a game that asks first runs unchanged on the web.- **Text has letter spacing.** `Text.letterSpacing` is extra space after every glyph, in the same px as `fontSize`; a negative value draws the glyphs closer. The layout always took a spacing, and `measureText` did, but the component had no field for it and nothing handed one over, so a label could not be spaced. Wrapping, alignment, `Ellipsis` and `Shrink` measure with it, `Shrink` scales it with the type, and it is in the Details panel beside Line Height. The default, 0, is the text as it was.- **A cliff's beds can wander.** A terrain layer seen from the side is read by height, so the beds of a cliff texture lie level, and ran dead straight along a whole wall like lines on ruled paper. The Terrain Layers material's `u_strataWarp` is how far they wander up and down, by slow noise `u_strataSpan` wide. At 0, the default, they are straight as before.diff --git a/desktop b/desktopindex f5cd3df2e..1cfa0589b 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit f5cd3df2e19d3c85210776267229ede4c6ca9db8+Subproject commit 1cfa0589b8e81741bd8cb8f77a1e10ba8093aca7diff --git a/pipeline/src/modeling/modelSource.ts b/pipeline/src/modeling/modelSource.tsindex 3d817f554..bbf2fc0d4 100644--- a/pipeline/src/modeling/modelSource.ts+++ b/pipeline/src/modeling/modelSource.ts@@ -152,7 +152,7 @@ export const MODEL_OPS: Record<string, OpSpec> = {subdivide: { params: { faces: 'faces', levels: 'integer', crease: 'number' }, required: [], run: subdivide as unknown as OpSpec['run'], says: 'rounds whole shells into smooth surfaces, keeping edges sharper than `crease` degrees' },displace: { params: { faces: 'faces', near: 'near', pattern: 'pattern', amplitude: 'number', scale: 'number', octaves: 'integer', seed: 'integer', stretch: 'vec3', warp: 'number', width: 'number', count: 'integer', axis: 'axis', mirror: 'axis', detail: 'number', along: 'vec3', long: 'number' }, required: ['pattern', 'amplitude', 'scale'], run: ((mesh: PolyMesh, params: never) => displace(mesh, params)) as OpSpec['run'], says: 'pushes fine detail out of the surface along its normal, splitting faces as far as the pattern needs: bumps, wrinkles, cracks, scales, pores, ribs, weave, scratches, pleats or folds' },hair: { params: { faces: 'faces', count: 'integer', length: 'number', guides: 'guides', gather: 'number', width: 'number', segments: 'integer', droop: 'number', comb: 'vec3', spread: 'number', uneven: 'number', wave: 'number', taper: 'number', seed: 'integer', color: 'color', tipColor: 'color', tag: 'string' }, required: ['faces'], run: hair as unknown as OpSpec['run'], says: 'grows cards of hair from these faces, falling around what is there, or along `guides` for a ponytail or a fringe; run it again for another layer, and only the cards are kept' },- scatter: { params: { source: 'faces', count: 'integer', faces: 'faces', path: 'vec3s', within: 'vec3s', scale: 'number|numbers', taper: 'number', spin: 'number', tilt: 'number', colors: 'vec3s', keep: 'boolean', seed: 'integer', tag: 'string' }, required: ['source', 'count'], run: scatter as unknown as OpSpec['run'], says: 'puts copies of the `source` faces across `faces`, along a `path` or through a box `within`, each sized, turned and coloured at random: feathers, rivets, the lights of a far city' },+ scatter: { params: { source: 'faces', count: 'integer', faces: 'faces', path: 'vec3s', within: 'vec3s', scale: 'number|numbers', taper: 'number', sizes: 'numbers', rows: 'integer', sweep: 'number|numbers', lift: 'number|numbers', up: 'vec3', spin: 'number', tilt: 'number', colors: 'vec3s', keep: 'boolean', seed: 'integer', tag: 'string' }, required: ['source', 'count'], run: scatter as unknown as OpSpec['run'], says: 'puts copies of the `source` faces across `faces`, along a `path` or through a box `within`, each sized, turned and coloured at random: feathers, rivets, the lights of a far city. Along a `path`, `rows` 1 or 2 stands them off it in a row or in pairs, `sweep` degrees from the way it runs and `lift` out of the plane, their +z facing `up`, sized by `sizes` from start to end: the leaflets of a frond, the barbs of a feather' },stain: { params: { faces: 'faces', near: 'near', line: 'line', hard: 'boolean', color: 'color', roughness: 'number', metallic: 'number', alpha: 'number', amount: 'number', pattern: 'pattern', scale: 'number', octaves: 'integer', seed: 'integer', stretch: 'vec3', warp: 'number', width: 'number', axis: 'axis', mirror: 'axis', threshold: 'number', softness: 'number', where: 'where', reach: 'number', facing: 'vec3', detail: 'number' }, required: [], run: ((mesh: PolyMesh, params: never) => stain(mesh, params)) as OpSpec['run'], says: 'lays colour, `roughness`, `metallic` or `alpha` over the surface by a pattern, by shape (`where`: cavity for dirt in what is sunken, edges for wear on what stands out), by which way it faces, around a spot, or along a `line`: pupils, eyelids, seams, moss, grime' },sculpt: { params: { faces: 'faces', from: 'view', strokes: 'strokes', detail: 'number' }, required: ['strokes'], run: sculpt as unknown as OpSpec['run'], says: 'works a surface stroke by stroke where one particular fold or hollow goes: `press` along a line, `move`, `inflate`, `smooth`; `from` takes places in the two axes of a view, as read off a picture' },decimate: { params: { from: 'string', faces: 'faces', ratio: 'number', triangles: 'integer', error: 'number' }, required: [], run: decimate as unknown as OpSpec['run'], says: 'leaves fewer triangles over the same surface: `ratio` to keep or `triangles` to end with, stopping sooner if the surface would move more than `error` (default 0.02) of its size; `from` thins the surface as it stood after that step, before its fine detail' },diff --git a/pipeline/src/modeling/scatter.ts b/pipeline/src/modeling/scatter.tsindex 73924924c..91a090f50 100644--- a/pipeline/src/modeling/scatter.ts+++ b/pipeline/src/modeling/scatter.ts@@ -5,6 +5,11 @@** Feathers along a limb, rivets on a plate, the lights of a far city: each is one small shape and a rule for where* the rest go, where writing them out step by step would run to hundreds. The same seed lays them out the same way.+ *+ * Along a path there are two rules. Without `rows` each copy points the way the path runs: scales down a tail.+ * With `rows` each stands OFF the path at an angle, in one row or in a pair of them: the leaflets of a frond, the+ * barbs of a feather, the legs of a centipede. That second rule is a frame and not a turn, because such a copy+ * has a face as well as a direction: a leaflet's flat side looks up, whichever way the leaflet points.*/import { hash3 } from './hash';import { triangulateFace } from './triangulate';@@ -26,6 +31,20 @@ export interface ScatterParams {scale?: number | readonly number[];/** Along a `path`, the size at its end as a share of its start. Default 1. */taper?: number;+ /** Along a `path`, sizes at even steps from its start to its end, each place taking the one between: [0.5, 1, 0.3] is widest in the middle. Multiplies `scale` and `taper`. */+ sizes?: readonly number[];+ /**+ * With `path`: copies stand off it in this many rows, 1 or 2, in place of pointing along it. Two is a pair at each+ * place, one to each side, so `count` places make twice as many copies. A copy's +y runs out along its row, its +z+ * faces `up`, and `spin` defaults to 0.+ */+ rows?: number;+ /** With `rows`: degrees between a copy and the way the path runs, or [at the start, at the end]. 90 is straight out, less leans toward the end of the path. Default 60. */+ sweep?: number | readonly number[];+ /** With `rows`: degrees a copy is raised out of the rows' plane toward `up`, or [at the start, at the end]. Negative hangs. Default 0. */+ lift?: number | readonly number[];+ /** With `rows`: the side of the path the rows face. One row lies to the left of the path seen from there, running away. Default [0, 1, 0]. */+ up?: Vec3;/** How far each is turned about its own +y at random, in degrees. Default 180. */spin?: number;/** How far each leans off where it would point at random, in degrees. Default 0. */@@ -56,7 +75,45 @@ function frameFor(up: Vec3): (v: Vec3) => Vec3 {return (v) => turned(v, unitAxis, angle);}-interface Spot { at: Vec3; up: Vec3; along: number }+interface Spot { at: Vec3; up: Vec3; along: number; /** In a row: +1 or -1, the side of the path. */ side?: number }++/** A value given once, or as [at the start, at the end] of a path. */+const ranged = (v: number | readonly number[] | undefined, fallback: number, along: number): number => {+ if (v === undefined) return fallback;+ if (typeof v === 'number') return v;+ const [a, b] = [v[0] ?? fallback, v[1] ?? v[0] ?? fallback];+ return a + (b - a) * along;+};++/** @p sizes read at @p along, as points at even steps joined by straight lines. */+function sizeAt(sizes: readonly number[] | undefined, along: number): number {+ if (!sizes || sizes.length === 0) return 1;+ if (sizes.length === 1) return sizes[0]!;+ const f = Math.min(1, Math.max(0, along)) * (sizes.length - 1);+ const i = Math.min(sizes.length - 2, Math.floor(f));+ return sizes[i]! + (sizes[i + 1]! - sizes[i]!) * (f - i);+}++/**+ * Where a copy in a row points and which way it faces: its +y off the path by `sweep`, raised by `lift`, and its +z as+ * near to `up` as a thing pointing that way can have it.+ */+function rowFrame(tangent: Vec3, upWanted: Vec3, side: number, sweep: number, lift: number): { x: Vec3; y: Vec3; z: Vec3 } {+ // The rows' plane holds the path; `up` is its normal once what runs along the path is taken out of it.+ let up = sub(upWanted, scale(tangent, dot(upWanted, tangent)));+ if (length(up) < 1e-6) {+ const other: Vec3 = Math.abs(tangent[0]) < 0.9 ? [1, 0, 0] : [0, 0, 1];+ up = sub(other, scale(tangent, dot(other, tangent)));+ }+ up = normalize(up);+ const out = cross(up, tangent);+ const y = normalize(add(scale(tangent, Math.cos(sweep)),+ add(scale(out, side * Math.sin(sweep) * Math.cos(lift)), scale(up, Math.sin(sweep) * Math.sin(lift)))));+ let z = sub(up, scale(y, dot(up, y)));+ if (length(z) < 1e-6) z = cross(y, out);+ z = normalize(z);+ return { x: cross(y, z), y, z };+}function surfaceSpots(mesh: PolyMesh, picked: readonly number[], count: number, seed: number): Spot[] {const pieces: { a: Vec3; b: Vec3; c: Vec3; n: Vec3 }[] = [];@@ -104,6 +161,16 @@ export function scatter(mesh: PolyMesh, p: ScatterParams): PolyMesh {if (!Number.isInteger(p.count) || p.count < 1 || p.count > MAX_COPIES) throw new Error(`count ${p.count} must be 1..${MAX_COPIES}`);const places = [p.faces, p.path, p.within].filter((v) => v !== undefined).length;if (places !== 1) throw new Error('say where they go with one of `faces`, `path` or `within`');+ const rows = p.rows;+ if (rows !== undefined && rows !== 1 && rows !== 2) throw new Error(`rows ${rows} must be 1 or 2`);+ if (rows !== undefined && p.path === undefined) throw new Error('`rows` stand off a `path`: give one');+ if (rows === undefined) {+ const lone = (['sweep', 'lift', 'up'] as const).find((k) => p[k] !== undefined);+ if (lone) throw new Error(`\`${lone}\` goes with \`rows\`: say how many, 1 or 2`);+ }+ if (p.sizes !== undefined && p.path === undefined) throw new Error('`sizes` goes along a `path`: give one');+ if (p.sizes?.some((v) => !(v >= 0))) throw new Error('`sizes` must each be 0 or more');+ if (p.up !== undefined && length(p.up) < 1e-6) throw new Error('`up` must point somewhere');const taken = selectFaces(mesh, p.source);if (taken.length === 0) throw new Error(`\`source\` ${JSON.stringify(p.source)} matched no face`);const seed = p.seed ?? 1;@@ -119,6 +186,10 @@ export function scatter(mesh: PolyMesh, p: ScatterParams): PolyMesh {spots = surfaceSpots(mesh, picked, p.count, seed);} else if (p.path !== undefined) {spots = pathSpots(p.path, p.count, seed);+ // A pair shares its place: the two of it are one spot, once to each side.+ if (rows === 2) spots = spots.flatMap((spot) => [{ ...spot, side: 1 }, { ...spot, side: -1 }]);+ else if (rows === 1) spots = spots.map((spot) => ({ ...spot, side: 1 }));+ if (spots.length > MAX_COPIES) throw new Error(`${spots.length} copies is past the ${MAX_COPIES} a step may make`);} else {const [lo, hi] = p.within as readonly [Vec3, Vec3];if (!lo || !hi || p.within!.length !== 2) throw new Error('`within` must be [min, max]');@@ -130,17 +201,31 @@ export function scatter(mesh: PolyMesh, p: ScatterParams): PolyMesh {}const [smallest, largest] = typeof p.scale === 'number' ? [p.scale, p.scale] : p.scale ? [p.scale[0] ?? 1, p.scale[1] ?? p.scale[0] ?? 1] : [1, 1];- const spin = ((p.spin ?? 180) * Math.PI) / 180;+ const spin = ((p.spin ?? (rows === undefined ? 180 : 0)) * Math.PI) / 180;+ const upWanted = normalize(p.up ?? [0, 1, 0]);+ const degrees = Math.PI / 180;const tilt = ((p.tilt ?? 0) * Math.PI) / 180;const keep = mesh.faces.filter((_, f) => p.keep || !isTaken.has(f));const positions: Vec3[] = [...mesh.positions];const faces: Face[] = [...keep];spots.forEach((spot, i) => {- const size = (smallest + (largest - smallest) * unit(i, 6, seed)) * (1 + ((p.taper ?? 1) - 1) * spot.along);+ const size = (smallest + (largest - smallest) * unit(i, 6, seed)) * (1 + ((p.taper ?? 1) - 1) * spot.along) * sizeAt(p.sizes, spot.along);const lean = (unit(i, 7, seed) - 0.5) * 2 * tilt;- const leanAbout = normalize(cross(spot.up, [unit(i, 8, seed) - 0.5, unit(i, 9, seed) - 0.5, unit(i, 10, seed) - 0.5 + 1e-3]));- const up = lean === 0 ? spot.up : normalize(turned(spot.up, leanAbout, lean));- const toFrame = frameFor(up);+ let toFrame: (v: Vec3) => Vec3;+ if (spot.side !== undefined) {+ let frame = rowFrame(spot.up, upWanted, spot.side, ranged(p.sweep, 60, spot.along) * degrees, ranged(p.lift, 0, spot.along) * degrees);+ if (lean !== 0) {+ // The lean is about the copy's own across, so it nods up and down its row and keeps its face.+ const about = frame.x;+ frame = { x: about, y: normalize(turned(frame.y, about, lean)), z: normalize(turned(frame.z, about, lean)) };+ }+ const { x, y, z } = frame;+ toFrame = (v) => add(add(scale(x, v[0]), scale(y, v[1])), scale(z, v[2]));+ } else {+ const leanAbout = normalize(cross(spot.up, [unit(i, 8, seed) - 0.5, unit(i, 9, seed) - 0.5, unit(i, 10, seed) - 0.5 + 1e-3]));+ const up = lean === 0 ? spot.up : normalize(turned(spot.up, leanAbout, lean));+ toFrame = frameFor(up);+ }const about = (unit(i, 11, seed) - 0.5) * 2 * spin;const colour = p.colors?.length ? p.colors[Math.min(p.colors.length - 1, Math.floor(unit(i, 12, seed) * p.colors.length))] : undefined;const seen = new Map<number, number>();diff --git a/pipeline/tests/modeling-scatter.test.ts b/pipeline/tests/modeling-scatter.test.tsindex d1764c3b5..6d2113dc7 100644--- a/pipeline/tests/modeling-scatter.test.ts+++ b/pipeline/tests/modeling-scatter.test.ts@@ -84,3 +84,110 @@ describe('scatter', () => {expect(() => validateModelSource({ steps: [seed, { op: 'scatter', source: 'seed' }] })).toThrow(/count/);});});++describe('scatter in rows off a path', () => {+ // A blade: 0.2 across (x), 0.4 long (y), 0.02 thick (z). Its +y is the way it points and its +z is its face.+ const blade: ModelStep = { op: 'box', size: [0.2, 0.4, 0.02], tag: 'blade', at: [50, 50, 50] };+ const rows = (scatter: Record<string, unknown>) =>+ bakeModel({ version: 1, smoothAngle: 0, steps: [blade, { op: 'scatter', source: 'blade', tag: 'copy', path: [[0, 0, 0], [10, 0, 0]], count: 5, ...scatter }] }).poly;+ /** Each copy's eight corners, in the order they were made. */+ const copies = (m: ReturnType<typeof rows>): number[][][] => {+ const faces = m.faces.filter((f) => f.tag === 'copy');+ return Array.from({ length: faces.length / 6 }, (_, i) => {+ const used = new Set(faces.slice(i * 6, (i + 1) * 6).flatMap((f) => [...f.v]));+ return [...used].map((v) => [...m.positions[v]!]);+ });+ };+ const span = (pts: number[][], axis: number): [number, number] => [Math.min(...pts.map((p) => p[axis]!)), Math.max(...pts.map((p) => p[axis]!))];++ it('makes a pair at each place, one to each side', () => {+ const all = copies(rows({ rows: 2, sweep: 90 }));+ expect(all).toHaveLength(10);+ for (let i = 0; i < 10; i += 2) {+ const [a, b] = [span(all[i]!, 2), span(all[i + 1]!, 2)];+ // Straight out: each reaches 0.4 from the path, on opposite sides of it.+ expect(a[0]).toBeCloseTo(-0.4, 5);+ expect(a[1]).toBeCloseTo(0, 5);+ expect(b[0]).toBeCloseTo(0, 5);+ expect(b[1]).toBeCloseTo(0.4, 5);+ // And the two stand at the same place along it.+ expect(span(all[i]!, 0)[0]).toBeCloseTo(span(all[i + 1]!, 0)[0], 5);+ }+ });++ it('keeps one row to the left of the path, seen from up', () => {+ const all = copies(rows({ rows: 1, sweep: 90 }));+ expect(all).toHaveLength(5);+ // The path runs +x under a +y up: left is -z.+ for (const c of all) expect(span(c, 2)[1]).toBeLessThan(1e-6);+ const flipped = copies(rows({ rows: 1, sweep: 90, up: [0, -1, 0] }));+ for (const c of flipped) expect(span(c, 2)[0]).toBeGreaterThan(-1e-6);+ });++ it('faces every copy up, whichever way it points', () => {+ // Thin in y, wherever the 0.02 of the blade went: in a turn by the shortest way it would have rolled.+ for (const sweep of [90, 60, 25]) {+ for (const c of copies(rows({ rows: 2, sweep }))) {+ const [lo, hi] = span(c, 1);+ expect(hi - lo).toBeCloseTo(0.02, 5);+ }+ }+ const sideways = copies(rows({ rows: 2, sweep: 90, up: [0, 0, 1] }));+ for (const c of sideways) expect(span(c, 2)[1] - span(c, 2)[0]).toBeCloseTo(0.02, 5);+ });++ it('leans them toward the end of the path by `sweep`, from one angle to another along it', () => {+ const reach = (c: number[][]): number => span(c, 0)[1] - span(c, 0)[0];+ // At 90 a blade covers its own width along the path; at 30 it lies most of its length along it.+ const out = copies(rows({ rows: 2, sweep: 90 }));+ const swept = copies(rows({ rows: 2, sweep: 30 }));+ expect(reach(out[0]!)).toBeCloseTo(0.2, 5);+ expect(reach(swept[0]!)).toBeCloseTo(0.4 * Math.cos(Math.PI / 6) + 0.2 * Math.sin(Math.PI / 6), 5);+ const turning = copies(rows({ rows: 2, sweep: [90, 30] }));+ expect(reach(turning[0]!)).toBeCloseTo(0.2, 1);+ expect(reach(turning.at(-1)!)).toBeGreaterThan(0.4);+ });++ it('raises them out of the plane by `lift`, and hangs them when it is negative', () => {+ const raised = copies(rows({ rows: 2, sweep: 90, lift: 30 }));+ for (const c of raised) expect(span(c, 1)[1]).toBeCloseTo(0.4 * 0.5 + 0.01 * Math.cos(Math.PI / 6), 5);+ const hung = copies(rows({ rows: 2, sweep: 90, lift: -30 }));+ for (const c of hung) expect(span(c, 1)[0]).toBeCloseTo(-(0.4 * 0.5 + 0.01 * Math.cos(Math.PI / 6)), 5);+ });++ it('sizes them along the path by `sizes`', () => {+ const lengths = copies(rows({ rows: 1, sweep: 90, count: 9, sizes: [0.25, 1, 0.25] })).map((c) => span(c, 2)[1] - span(c, 2)[0]);+ expect(lengths[4]!).toBeCloseTo(0.4, 1);+ expect(lengths[0]!).toBeLessThan(0.15);+ expect(lengths[8]!).toBeLessThan(0.15);+ expect(lengths[2]!).toBeGreaterThan(lengths[0]!);+ // Without rows too: it is a rule about the path, not about the rows.+ const along = bakeModel({ version: 1, smoothAngle: 0, steps: [blade, { op: 'scatter', source: 'blade', tag: 'copy', path: [[0, 0, 0], [10, 0, 0]], count: 3, spin: 0, sizes: [1, 0.5] }] }).poly;+ const made = copies(along).map((c) => span(c, 0)[1] - span(c, 0)[0]);+ expect(made[2]!).toBeLessThan(made[0]! * 0.6);+ });++ it('stands off a path that runs straight up, and off one that bends', () => {+ const upright = bakeModel({ version: 1, smoothAngle: 0, steps: [blade, { op: 'scatter', source: 'blade', tag: 'copy', path: [[0, 0, 0], [0, 10, 0]], count: 4, rows: 2, sweep: 90 }] }).poly;+ for (const p of upright.positions) for (const v of p) expect(Number.isFinite(v)).toBe(true);+ const bent = copies(bakeModel({ version: 1, smoothAngle: 0, steps: [blade, { op: 'scatter', source: 'blade', tag: 'copy', path: [[0, 0, 0], [5, 0, 0], [5, 0, 5]], count: 9, rows: 1, sweep: 90 }] }).poly);+ // On the second leg the path runs +z, so left of it is +x.+ expect(span(bent.at(-1)!, 0)[1]).toBeCloseTo(5.4, 5);+ });++ it('lays them out the same way for a seed', () => {+ const place = (s: number) => rows({ rows: 2, tilt: 20, spin: 10, seed: s }).positions;+ expect(place(5)).toEqual(place(5));+ expect(place(5)).not.toEqual(place(6));+ });++ it('says what is wrong', () => {+ expect(() => rows({ rows: 3 })).toThrow(/rows 3 must be 1 or 2/);+ expect(() => rows({ sweep: 40 })).toThrow(/`sweep` goes with `rows`/);+ expect(() => rows({ lift: 10 })).toThrow(/`lift` goes with `rows`/);+ expect(() => rows({ rows: 2, up: [0, 0, 0] })).toThrow(/`up` must point somewhere/);+ expect(() => rows({ sizes: [1, -1] })).toThrow(/`sizes` must each be 0 or more/);+ expect(() => bakeModel({ version: 1, steps: [blade, { op: 'scatter', source: 'blade', within: [[0, 0, 0], [1, 1, 1]], count: 2, rows: 2 }] })).toThrow(/`rows` stand off a `path`/);+ expect(() => bakeModel({ version: 1, steps: [blade, { op: 'scatter', source: 'blade', within: [[0, 0, 0], [1, 1, 1]], count: 2, sizes: [1, 2] }] })).toThrow(/`sizes` goes along a `path`/);+ });+});diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 13e584771..2c1c391c5 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -4572,6 +4572,8 @@ export const NOTED = {{"note": "A game calls its own native code by name."},"fix(aot): the engine digest counts TilemapLayer.lit - the field landed without it, so a packaged native game refused its own compiled systems as built against a different engine; the digest and the two conformance files are regenerated":{"internal": "Repairs a field added since the last release: no released build refused its compiled systems."},+ "feat(modeling): scatter stands copies off a path in rows - rows 1 or 2 with sweep, lift and up lays the leaflets of a frond or the barbs of a feather in one step where each was a step of its own, and sizes shapes them along the path; a palm of 386 steps is 40":+ {"note": "An AI can lay leaflets along a stem in one step."},"feat(sky): a sky of your own shades the ground under its clouds - defineSkyEffect takes groundShadow and a second function, skyShadow(world, sun), what is left of the light at a world position, and the sky pass multiplies every surface it finds by it, as Sky Atmosphere does with its own clouds":{"note": "A sky of your own shades the ground under its clouds."},"fix(terrain): a colour map and an occlusion map lie the way the heightmap does - Terrain.colorMap, Terrain.occlusionMap and Foliage.colorMap were sampled with their rows turned over, so a picture painted to match a heightmap, a splatmap or a density map came out mirrored north to south under them; an image over an area now has its first row along the least z whoever reads it":