Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Make the flag film read as thin fabric: ripples in the fall, a crumpled ridge, a layer under 5 cm (#696)

Nguyen Xuan Aneff4a4a5ac56
diff --git a/docs/physics.md b/docs/physics.md
index 25723b1f..fe92f335 100644
--- a/docs/physics.md
+++ b/docs/physics.md
@@ -443,10 +443,10 @@ A recipe `cloth` section records deformable sheets with a position-based solver
Soft body films (`scripts/soft-body-film.mjs`, `tests/soft-body-film.test.js`): a jelly cube landing and a flag lowered into folds on itself, each one recipe that the test bakes twice and the preview script renders.
- Jelly cube: a rounded box 0.5 m across (384 particles) dropped from 1.95 m, `softBody { shape: 0.15, pressure: 1 }`. It first rests on the floor at frame 48 (0.8 s) and is dented 0.0503 m (10 percent of its height) at frame 49, one step later, while its width grows from 0.5 m to 0.547 m; the frame before contact has no dent.
-- Flag: a 24 by 24 grid, 1 m tall, hung by its top edge from a pole (`pinTo`) that swings out and down to the floor in 1.5 s, drags the cloth flat, then pushes back 0.4 m. The sheet sets `thickness: 0.005`, so its self collision layers stack 1 cm apart (the earlier film used the mesh-based 3.7 cm, left the pole held 0.25 m up, and piled a block 0.547 m tall). First touch is at step 66 (1.1 s); the final frame (step 239, 4 s) has every vertex under 0.0467 m above the floor, spread over 1.6 m by 0.8 m, with one rolled fold at the near edge. With `selfCollision: true` the closest pair of particles not joined by an edge is never under 5 mm apart in any sampled frame after touch (0.0096 m at the lowest sample); the same film without it comes down to 0.3 mm (layers merged).
+- Flag: a 30 by 30 grid, 1 m tall, hung by its top edge from a pole (`pinTo`). The pole swings 0.3 m from side to side while it falls for 1.3 s so the sheet ripples, lands, then pulls the cloth 1.1 m across the floor, which gathers a crumpled ridge near the pole and flattens the rest. The sheet sets `bend: 0.001`, `stiffness: 0.6` and `thickness: 0.003`, so its self collision layers stack 6 mm apart (the first film used the mesh-based 3.7 cm and piled a block 0.547 m tall; the second was a flat card in the air and a smooth sheet at rest). Measured in the test: first touch at step 70; normal spread (0 flat, toward 1 scattered) is 0 at the start, 0.597 mid fall (step 49) and 0.300 at rest, the sheet bends 0.3 m or more out of its plane mid fall, and the final frame (step 239) has every vertex under 0.0491 m above the floor. With `selfCollision: true` the closest pair of particles not joined by an edge is never under 5 mm apart in any sampled frame after touch (0.0060 m); the same film without it comes down to 3 mm. A 36 by 36 grid exceeds the cloth work limit for 4 s. The look is a dark red cloth on a mid grey floor under a low side key light (`environment.lightDirection`), so folds cast shadows.
- Both films bake to the same bytes in every frame across two runs; the test compares every frame's vertex buffer.
- Frame time, in milliseconds per solver step (the bake is one call, so this is its total over the steps, on a machine shared with other sessions, so read it as a range): jelly 6 to 9 ms a step over 120 steps, flag 27 to 29 ms a step over 240 steps (16 ms a step without self collision, 625 particles). Sampling a recorded frame for playback costs about 1.5 to 2 ms.
-- `node scripts/render-soft-body-film.mjs <folder>` (run it through gpu-lock) writes a 960 by 540, 60 fps preview MP4 of each film (one video frame per simulation step, so frame N is step N), stills at contact and at the deepest dent for the jelly and at mid fall, first touch and final rest for the flag, `jelly-cube-compare.png` (both side by side with the measured width and height drawn on it) and `soft-body-film.json` with every number, its unit and its step. It needs `npm run build:lib` first. No default changes.
+- `node scripts/render-soft-body-film.mjs <folder> [--flag-only]` (run it through gpu-lock) writes a 960 by 540, 60 fps preview MP4 of each film (one video frame per simulation step, so frame N is step N), stills at contact and at the deepest dent for the jelly and at start, mid fall, first touch, settling and final rest for the flag (`--flag-only` skips the jelly cube), `jelly-cube-compare.png` (both side by side with the measured width and height drawn on it) and `soft-body-film.json` with every number, its unit and its step. It needs `npm run build:lib` first. No default changes.
Blender comparison (`scripts/blender-cloth.py`, Blender 5.2.2, default stiffness, mass set from the same kg/m2; `tests/cloth-blender.test.js`):
diff --git a/scripts/render-soft-body-film.mjs b/scripts/render-soft-body-film.mjs
index bd53e814..fca7945b 100644
--- a/scripts/render-soft-body-film.mjs
+++ b/scripts/render-soft-body-film.mjs
@@ -1,5 +1,5 @@
// Renders a preview MP4 of each soft body film (960 by 540, 60 fps, one video frame per simulation step), stills at contact
-// and at the deepest dent, a side-by-side still of the two with the measured size drawn on it, and one JSON of the numbers. Usage: node scripts/render-soft-body-film.mjs <output directory>
+// and at the deepest dent, a side-by-side still of the two with the measured size drawn on it, and one JSON of the numbers. Usage: node scripts/render-soft-body-film.mjs <output directory> [--flag-only]
// Run it through gpu-lock on a shared machine. It needs `npm run build:lib` first.
import { execFileSync } from 'node:child_process';
import { copyFile, mkdir, writeFile } from 'node:fs/promises';
@@ -10,7 +10,7 @@ import { setTimeout as delay } from 'node:timers/promises';
import { createAgentScene } from '../src/agent-scene.js';
import { Client } from '@modelcontextprotocol/client';
import { StdioClientTransport } from '@modelcontextprotocol/client/stdio';
-import { FILM_FRAMES_PER_SECOND, FLAG_FILM_SECONDS, axisRange, foldingFlagRecipe, jellyCubeRecipe, measureLanding, recordFilm, unjoinedMinimumDistance } from './soft-body-film.mjs';
+import { FILM_FRAMES_PER_SECOND, FLAG_FILM_SECONDS, axisRange, foldingFlagRecipe, jellyCubeRecipe, measureLanding, normalSpread, recordFilm, unjoinedMinimumDistance } from './soft-body-film.mjs';
const PREVIEW = { width: 960, height: 540, fps: FILM_FRAMES_PER_SECOND };
const FONT_FILE = 'C\\:/Windows/Fonts/arial.ttf';
@@ -85,19 +85,44 @@ function writeComparisonStill(outputDirectory, files, captions) {
execFileSync('ffmpeg', ['-y', '-loglevel', 'error', ...inputs, '-filter_complex', filterGraph, '-frames:v', '1', join(outputDirectory, 'jelly-cube-compare.png')]);
}
+/** The jelly cube half of the summary: sizes at rest, contact and the deepest dent, plus the side by side still. */
+function summarizeJelly(outputDirectory, jelly, jellyFiles, landing, jellyFrames) {
+ const atContact = cubeSize(jelly.record.frames[landing.contact]);
+ const atMaxDent = cubeSize(jelly.record.frames[landing.maxDentFrame]);
+ writeComparisonStill(outputDirectory, jellyFiles.files, {
+ contact: `contact: step ${landing.contact} (${seconds(landing.contact).toFixed(3)} s)
+width ${atContact.widthMeters.toFixed(4)} m, height ${atContact.heightMeters.toFixed(4)} m`,
+ 'max-dent': `max dent: step ${landing.maxDentFrame} (${seconds(landing.maxDentFrame).toFixed(3)} s)
+width ${atMaxDent.widthMeters.toFixed(4)} m, height ${atMaxDent.heightMeters.toFixed(4)} m
+dent ${landing.maxDentDepth.toFixed(4)} m`,
+ });
+ jellyFiles.files.compare = 'jelly-cube-compare.png';
+ return {
+ simulationSteps: jellyFrames,
+ restSize: { widthMeters: meters(axisRange(jelly.record.frames[0], 0).extent), heightMeters: meters(landing.restHeight) },
+ contact: { step: landing.contact, timeSeconds: seconds(landing.contact), ...atContact },
+ maxDent: { step: landing.maxDentFrame, timeSeconds: seconds(landing.maxDentFrame), depthMeters: meters(landing.maxDentDepth), ...atMaxDent },
+ frameTimes: jelly.frameTimes,
+ files: jellyFiles.files,
+ };
+}
+
async function main() {
if (!existsSync(new URL('../build/mcp/server.mjs', import.meta.url))) throw new Error('Run npm run build:lib first: the MCP server is not built.');
- const outputDirectory = resolve(process.argv[2] ?? '');
- if (!process.argv[2]) throw new Error('Pass the output directory: node scripts/render-soft-body-film.mjs <directory>');
+ const flagOnly = process.argv.includes('--flag-only');
+ const directoryArgument = process.argv.slice(2).find(argument => !argument.startsWith('--'));
+ const outputDirectory = resolve(directoryArgument ?? '');
+ if (!directoryArgument) throw new Error('Pass the output directory: node scripts/render-soft-body-film.mjs <directory>');
await mkdir(outputDirectory, { recursive: true });
const jellyFrames = 120;
const flagFrames = FLAG_FILM_SECONDS * FILM_FRAMES_PER_SECOND;
- const jelly = filmNumbers(jellyCubeRecipe(), 'cube', jellyFrames);
- const landing = measureLanding(jelly.record.frames, axisRange(jelly.record.frames[0], 1).extent);
+ const jelly = flagOnly ? null : filmNumbers(jellyCubeRecipe(), 'cube', jellyFrames);
+ const landing = flagOnly ? null : measureLanding(jelly.record.frames, axisRange(jelly.record.frames[0], 1).extent);
const flag = filmNumbers(foldingFlagRecipe(), 'flag', flagFrames);
const flagTouch = measureLanding(flag.record.frames, axisRange(flag.record.frames[0], 1).extent).contact;
const flagMidFall = Math.round(flagTouch * 0.7);
+ const flagSettling = Math.round(flagTouch * 2);
const flagHash = flag.record.hashes[flagFrames - 1];
const jobsDirectory = join(tmpdir(), `67js-soft-body-film-${process.pid}`);
@@ -106,38 +131,23 @@ async function main() {
await client.connect(transport);
try {
const call = (name, toolArguments) => client.callTool({ name, arguments: toolArguments }, { timeout: 300000 });
- const jellyFiles = await renderFilm(call, outputDirectory, {
+ const jellyFiles = flagOnly ? null : await renderFilm(call, outputDirectory, {
name: 'jelly-cube', recipe: jellyCubeRecipe(), nodeId: 'cube', frameCount: jellyFrames, videoSeconds: jellyFrames / FILM_FRAMES_PER_SECOND,
stillTimes: { contact: landing.contact / FILM_FRAMES_PER_SECOND, 'max-dent': landing.maxDentFrame / FILM_FRAMES_PER_SECOND },
});
const flagFiles = await renderFilm(call, outputDirectory, {
name: 'folding-flag', recipe: foldingFlagRecipe(), nodeId: 'flag', frameCount: flagFrames, videoSeconds: flagFrames / FILM_FRAMES_PER_SECOND,
- stillTimes: { 'mid-fall': flagMidFall / FILM_FRAMES_PER_SECOND, 'first-touch': flagTouch / FILM_FRAMES_PER_SECOND, 'final-rest': (flagFrames - 1) / FILM_FRAMES_PER_SECOND },
+ stillTimes: { start: 0, 'mid-fall': flagMidFall / FILM_FRAMES_PER_SECOND, 'first-touch': flagTouch / FILM_FRAMES_PER_SECOND, settling: flagSettling / FILM_FRAMES_PER_SECOND, 'final-rest': (flagFrames - 1) / FILM_FRAMES_PER_SECOND },
});
- const restFrame = jelly.record.frames[0];
- const atContact = cubeSize(jelly.record.frames[landing.contact]);
- const atMaxDent = cubeSize(jelly.record.frames[landing.maxDentFrame]);
const withoutSelfCollision = recordFilm(foldingFlagRecipe({ selfCollision: false }), 'flag', flagFrames);
const flagIndices = createAgentScene(foldingFlagRecipe()).parts.find(part => part.name === 'flag').geometry.indices;
const lastFlagStep = flagFrames - 1;
- writeComparisonStill(outputDirectory, jellyFiles.files, {
- contact: `contact: step ${landing.contact} (${seconds(landing.contact).toFixed(3)} s)
-width ${atContact.widthMeters.toFixed(4)} m, height ${atContact.heightMeters.toFixed(4)} m`,
- 'max-dent': `max dent: step ${landing.maxDentFrame} (${seconds(landing.maxDentFrame).toFixed(3)} s)
-width ${atMaxDent.widthMeters.toFixed(4)} m, height ${atMaxDent.heightMeters.toFixed(4)} m
-dent ${landing.maxDentDepth.toFixed(4)} m`,
- });
- jellyFiles.files.compare = 'jelly-cube-compare.png';
+ const jellyCube = flagOnly ? undefined : summarizeJelly(outputDirectory, jelly, jellyFiles, landing, jellyFrames);
+ const flagStart = flag.record.frames[0];
+ const flagIndicesForSpread = flagIndices;
const summary = {
preview: { ...PREVIEW, videoFrameToStep: 'one video frame is one simulation step: frame N is step N, at N / 60 s' },
- jellyCube: {
- simulationSteps: jellyFrames,
- restSize: { widthMeters: meters(axisRange(restFrame, 0).extent), heightMeters: meters(landing.restHeight) },
- contact: { step: landing.contact, timeSeconds: seconds(landing.contact), ...atContact },
- maxDent: { step: landing.maxDentFrame, timeSeconds: seconds(landing.maxDentFrame), depthMeters: meters(landing.maxDentDepth), ...atMaxDent },
- frameTimes: jelly.frameTimes,
- files: jellyFiles.files,
- },
+ jellyCube,
foldingFlag: {
simulationSteps: flagFrames,
finalStep: lastFlagStep,
@@ -146,6 +156,14 @@ dent ${landing.maxDentDepth.toFixed(4)} m`,
midFallStep: flagMidFall,
firstTouchStep: flagTouch,
pileHeightMeters: meters(axisRange(flag.record.frames[lastFlagStep], 1).extent),
+ normalSpread: {
+ start: meters(normalSpread(flagStart, flagIndicesForSpread)),
+ midFall: meters(normalSpread(flag.record.frames[flagMidFall], flagIndicesForSpread)),
+ settling: meters(normalSpread(flag.record.frames[flagSettling], flagIndicesForSpread)),
+ rest: meters(normalSpread(flag.record.frames[lastFlagStep], flagIndicesForSpread)),
+ },
+ midFallDepthMeters: meters(axisRange(flag.record.frames[flagMidFall], 2).extent),
+ settlingStep: flagSettling,
closestUnjoinedGapMeters: {
atStep: lastFlagStep,
withSelfCollision: meters(unjoinedMinimumDistance(flag.record.frames[lastFlagStep], flagIndices)),
diff --git a/scripts/soft-body-film.mjs b/scripts/soft-body-film.mjs
index 8aef3fc7..0b9ef9fd 100644
--- a/scripts/soft-body-film.mjs
+++ b/scripts/soft-body-film.mjs
@@ -9,15 +9,16 @@ const FLOOR_THICKNESS = 0.01;
const GROUND_NODE = { id: 'ground', geometry: 'floor', material: 'stone', translation: [0, -0.5, 0], scale: [8, 1, 8] };
const CAMERA = { fov: 34 };
-function baseRecipe({ geometries, materials, nodes, motion, cloth, camera }) {
+function baseRecipe({ geometries, materials, nodes, motion, cloth, camera, floorColor = [0.55, 0.55, 0.58], environment }) {
return {
format: '67js.scene', schemaVersion: 1,
geometries: [...geometries, { id: 'floor', type: 'box', bevel: 0 }],
- materials: [...materials, { id: 'stone', color: [0.55, 0.55, 0.58] }],
+ materials: [...materials, { id: 'stone', color: floorColor }],
nodes: [...nodes, GROUND_NODE],
camera: { ...CAMERA, ...camera },
motion,
cloth,
+ ...(environment ? { environment } : {}),
};
}
@@ -41,40 +42,80 @@ export function jellyCubeRecipe() {
});
}
-// The pole's path: a swing out and down so the flag ripples, a drag across the floor to lay it flat, then a short push back that crumples the near end.
+// The pole's path: a side to side swing on the way down so the sheet ripples, a landing, then a pull across the floor that gathers
+// the cloth into a crumpled ridge and flattens the rest into a thin layer.
const POLE_KEYFRAMES = [
{ time: 0, value: [0, 2.6, 0] },
- { time: 0.3, value: [0, 2.6, 0] },
- { time: 0.9, value: [0.25, 1.2, 0.4] },
- { time: 1.5, value: [0, 0.012, 1] },
- { time: 2.2, value: [0, 0.012, 1.3] },
- { time: 3.2, value: [0, 0.012, 0.9] },
- { time: 4, value: [0, 0.012, 0.9] },
+ { time: 0.2, value: [0.1, 2.5, 0.3] },
+ { time: 0.4, value: [-0.1, 2.1, -0.3] },
+ { time: 0.6, value: [0.12, 1.7, 0.35] },
+ { time: 0.8, value: [-0.1, 1.2, -0.3] },
+ { time: 1.0, value: [0.1, 0.7, 0.3] },
+ { time: 1.3, value: [0, 0.012, 0.9] },
+ { time: 2.2, value: [0, 0.012, 2] },
+ { time: 4, value: [0, 0.012, 2] },
];
export const FLAG_FILM_SECONDS = 4;
+// A dark saturated cloth on a mid grey floor, lit by a low key from the side so every fold casts a shadow.
+const FLAG_LOOK = { lightDirection: [-0.9, 0.45, 0.55], keyIntensity: 1.6, fillIntensity: 0.15, ambientIntensity: 0.25 };
/**
- * A flag hung from a pole by its top edge. The pole swings down to the floor and drags the cloth flat, so it ends as a thin layer with
- * a fold. The sheet sets thickness 5 mm, which also sets the self collision radius, so layers stack 1 cm apart instead of 3.7 cm.
+ * A flag hung from a pole by its top edge. The pole swings from side to side while it falls, so the sheet ripples, lands on the floor and
+ * drags the cloth into a crumpled ridge on a thin layer. The sheet sets thickness 3.5 mm, which also sets the self collision radius,
+ * so layers stack 6 mm apart instead of 3.7 cm.
*/
export function foldingFlagRecipe({ selfCollision = true } = {}) {
return baseRecipe({
- geometries: [{ id: 'flag', type: 'grid', segments: 24 }],
- materials: [{ id: 'fabric', color: [0.9, 0.2, 0.2], doubleSided: true }],
+ geometries: [{ id: 'flag', type: 'grid', segments: 30 }],
+ materials: [{ id: 'fabric', color: [0.62, 0.05, 0.1], doubleSided: true }],
nodes: [
{ id: 'flag', geometry: 'flag', material: 'fabric', translation: [0, 2.1, 0], scale: [1.6, 1, 1] },
{ id: 'pole', translation: [0, 2.6, 0] },
],
motion: { duration: FLAG_FILM_SECONDS, loop: false, tracks: [{ kind: 'node', id: 'pole', property: 'translation', interpolation: 'LINEAR', keyframes: POLE_KEYFRAMES }] },
- camera: { eye: [1.1, 1.1, 4.3], target: [0, 0.75, 0.4] },
+ camera: { eye: [1.1, 1.1, 4.3], target: [0, 0.75, 0.9] },
+ floorColor: [0.4, 0.4, 0.42],
+ environment: FLAG_LOOK,
cloth: {
duration: FLAG_FILM_SECONDS,
- sheets: [{ node: 'flag', pin: ['top'], pinTo: { node: 'pole' }, selfCollision, stiffness: 0.9, bend: 0.01, damping: 2.5, friction: 0.25, thickness: 0.005 }],
+ sheets: [{ node: 'flag', pin: ['top'], pinTo: { node: 'pole' }, selfCollision, stiffness: 0.6, bend: 0.001, damping: 2.5, friction: 0.25, thickness: 0.003 }],
colliders: [{ node: 'ground', shape: 'box' }],
},
});
}
+/**
+ * How far the sheet's triangles face different ways: 0 for a flat sheet, toward 1 as the normals scatter. A triangle's normal is
+ * taken up to its sign (a cloth has two faces), summed, and the length of that sum over the triangle count is taken from 1.
+ */
+export function normalSpread(vertices, indices) {
+ let sumX = 0;
+ let sumY = 0;
+ let sumZ = 0;
+ let counted = 0;
+ for (let corner = 0; corner < indices.length; corner += 3) {
+ const a = indices[corner] * 3;
+ const b = indices[corner + 1] * 3;
+ const c = indices[corner + 2] * 3;
+ const edgeOne = [vertices[b] - vertices[a], vertices[b + 1] - vertices[a + 1], vertices[b + 2] - vertices[a + 2]];
+ const edgeTwo = [vertices[c] - vertices[a], vertices[c + 1] - vertices[a + 1], vertices[c + 2] - vertices[a + 2]];
+ let normalX = edgeOne[1] * edgeTwo[2] - edgeOne[2] * edgeTwo[1];
+ let normalY = edgeOne[2] * edgeTwo[0] - edgeOne[0] * edgeTwo[2];
+ let normalZ = edgeOne[0] * edgeTwo[1] - edgeOne[1] * edgeTwo[0];
+ const length = Math.hypot(normalX, normalY, normalZ);
+ if (length < 1e-12) continue;
+ const sign = normalZ < 0 ? -1 / length : 1 / length;
+ normalX *= sign;
+ normalY *= sign;
+ normalZ *= sign;
+ sumX += normalX;
+ sumY += normalY;
+ sumZ += normalZ;
+ counted++;
+ }
+ return counted === 0 ? 0 : 1 - Math.hypot(sumX, sumY, sumZ) / counted;
+}
+
/** The cloth node's vertices at `time` in world space (the recipe nodes use translation and scale only), as a copy. */
export function clothVertices(scene, node, time) {
scene.sampleMotion(time);
diff --git a/tests/soft-body-film.test.js b/tests/soft-body-film.test.js
index 107fa06c..97910999 100644
--- a/tests/soft-body-film.test.js
+++ b/tests/soft-body-film.test.js
@@ -1,7 +1,7 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createAgentScene } from '../src/agent-scene.js';
-import { FILM_FRAMES_PER_SECOND, FLAG_FILM_SECONDS, axisRange, foldingFlagRecipe, jellyCubeRecipe, measureLanding, recordFilm, unjoinedMinimumDistance } from '../scripts/soft-body-film.mjs';
+import { FILM_FRAMES_PER_SECOND, FLAG_FILM_SECONDS, axisRange, foldingFlagRecipe, jellyCubeRecipe, measureLanding, normalSpread, recordFilm, unjoinedMinimumDistance } from '../scripts/soft-body-film.mjs';
// Film tests for #696: each film is one recipe baked twice. The frames must match byte for byte, and the numbers a viewer
// would see (the landing, the dent, the height and layers of the fold) are measured from the baked vertices, not read off a picture.
@@ -50,9 +50,18 @@ test('a flag dropped by its pole falls to the floor and ends as a thin layer who
assert.ok(touch > 30 && touch < 90, `the hanging flag first touches the floor within frames 30 to 90, got ${touch}`);
const midFall = Math.round(touch * 0.7);
assert.ok(axisRange(first.frames[midFall], 1).extent > restHeight * 0.6, 'mid fall the flag is still hanging in the air');
+ // A stiff card would stay one plane: its normals agree and it has no depth. Cloth ripples, so both measures are well above zero.
+ const spreadAtStart = normalSpread(first.frames[0], indices);
+ const spreadMidFall = normalSpread(first.frames[midFall], indices);
+ const depthMidFall = axisRange(first.frames[midFall], 2).extent;
+ assert.ok(spreadAtStart < 0.001, `the hanging flag starts flat, spread ${spreadAtStart}`);
+ assert.ok(spreadMidFall > 0.25, `mid fall the triangle normals scatter (spread ${spreadMidFall}), the sheet is rippled`);
+ assert.ok(depthMidFall > 0.3, `mid fall the sheet bends ${depthMidFall} m out of its plane`);
const finalRange = axisRange(first.frames[last], 1);
- assert.ok(finalRange.high < 0.055, `the flag ends no more than 5.5 cm above the floor, got ${finalRange.high} m`);
+ assert.ok(finalRange.high < 0.05, `the flag ends no more than 5 cm above the floor, got ${finalRange.high} m`);
+ const spreadAtRest = normalSpread(first.frames[last], indices);
+ assert.ok(spreadAtRest > 0.2, `the flag rests crumpled, not as a flat sheet (spread ${spreadAtRest})`);
assert.ok(axisRange(first.frames[last], 2).extent > 0.7, 'the flag lies spread over the floor, not stacked in one place');
const without = recordFilm(foldingFlagRecipe({ selfCollision: false }), 'flag', FLAG_FRAMES);
@@ -66,6 +75,6 @@ test('a flag dropped by its pole falls to the floor and ends as a thin layer who
assert.ok(closestWithout < closestWith * 0.9, `without self collision the layers come closer (${closestWithout} m)`);
const bake = first.bakeMilliseconds;
- context.diagnostic(`flag: touch at frame ${touch}, final height ${finalRange.high.toFixed(4)} m from ${restHeight.toFixed(3)} m, closest unjoined pair ${closestWith.toFixed(4)} m (${closestWithout.toFixed(4)} m without self collision)`);
+ context.diagnostic(`flag: touch at frame ${touch}, final height ${finalRange.high.toFixed(4)} m from ${restHeight.toFixed(3)} m, spread mid fall ${spreadMidFall.toFixed(3)}, at rest ${spreadAtRest.toFixed(3)}, closest unjoined pair ${closestWith.toFixed(4)} m (${closestWithout.toFixed(4)} m without self collision)`);
context.diagnostic(`flag: bake ${milliseconds(bake)} ms for ${FLAG_FRAMES} steps (${milliseconds(bake / FLAG_FRAMES)} ms a step with self collision, ${milliseconds(without.bakeMilliseconds / FLAG_FRAMES)} ms without)`);
});