@null3d/engine 0.1.0 → 0.1.1
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/wasm/single/null3d.js +10 -8
- package/dist/wasm/single/null3d_bg.wasm +0 -0
- package/dist/wasm/threaded/null3d.js +10 -8
- package/dist/wasm/threaded/null3d_bg.wasm +0 -0
- package/docs/api/animation.md +96 -24
- package/docs/api/assets.md +99 -29
- package/docs/api/cameras.md +38 -7
- package/docs/api/controls.md +47 -23
- package/docs/api/debug.md +105 -35
- package/docs/api/engine.md +108 -32
- package/docs/api/feature-draws.md +21 -15
- package/docs/api/feature-effects.md +8 -8
- package/docs/api/feature-instances.md +68 -17
- package/docs/api/features.md +68 -37
- package/docs/api/geometry.md +83 -14
- package/docs/api/grass.md +55 -13
- package/docs/api/impostors.md +92 -50
- package/docs/api/input.md +22 -9
- package/docs/api/lights.md +67 -16
- package/docs/api/lines.md +38 -13
- package/docs/api/materials.md +187 -59
- package/docs/api/math.md +6 -6
- package/docs/api/objects.md +40 -15
- package/docs/api/page.md +58 -7
- package/docs/api/particles.md +36 -11
- package/docs/api/points.md +18 -8
- package/docs/api/post.md +57 -23
- package/docs/api/quality.md +36 -16
- package/docs/api/raycast.md +57 -24
- package/docs/api/reference/animation.md +1 -2
- package/docs/api/reference/assets.md +7 -4
- package/docs/api/reference/cameras.md +3 -2
- package/docs/api/reference/controls.md +59 -2
- package/docs/api/reference/debug.md +58 -6
- package/docs/api/reference/engine.md +39 -10
- package/docs/api/reference/feature-draws.md +3 -4
- package/docs/api/reference/feature-effects.md +2 -3
- package/docs/api/reference/feature-instances.md +5 -4
- package/docs/api/reference/features.md +7 -4
- package/docs/api/reference/geometry.md +132 -21
- package/docs/api/reference/grass.md +62 -2
- package/docs/api/reference/impostors.md +120 -16
- package/docs/api/reference/input.md +1 -2
- package/docs/api/reference/lights.md +4 -3
- package/docs/api/reference/lines.md +3 -4
- package/docs/api/reference/materials.md +7 -6
- package/docs/api/reference/math.md +13 -2
- package/docs/api/reference/objects.md +2 -3
- package/docs/api/reference/particles.md +31 -6
- package/docs/api/reference/points.md +2 -3
- package/docs/api/reference/post.md +4 -3
- package/docs/api/reference/quality.md +1 -2
- package/docs/api/reference/raycast.md +1 -2
- package/docs/api/reference/render.md +4 -3
- package/docs/api/reference/scene.md +24 -5
- package/docs/api/reference/sketch.md +11 -11
- package/docs/api/reference/sound.md +33 -2
- package/docs/api/reference/splats.md +42 -3
- package/docs/api/reference/sprites.md +2 -3
- package/docs/api/reference/tasks.md +16 -3
- package/docs/api/reference/terrain.md +26 -5
- package/docs/api/reference/textures.md +1 -2
- package/docs/api/reference/three-compat.md +18 -7
- package/docs/api/reference/time.md +1 -2
- package/docs/api/reference/ui.md +10 -7
- package/docs/api/reference/vertex-draws.md +2 -3
- package/docs/api/reference/water.md +78 -5
- package/docs/api/reference/wind.md +15 -2
- package/docs/api/render.md +67 -25
- package/docs/api/scene.md +129 -36
- package/docs/api/sketch.md +45 -19
- package/docs/api/sound.md +48 -12
- package/docs/api/splats.md +42 -15
- package/docs/api/sprites.md +8 -6
- package/docs/api/tasks.md +31 -22
- package/docs/api/terrain.md +44 -12
- package/docs/api/textures.md +61 -12
- package/docs/api/three-compat.md +15 -7
- package/docs/api/time.md +3 -5
- package/docs/api/ui.md +18 -10
- package/docs/api/vertex-draws.md +13 -12
- package/docs/api/water.md +111 -67
- package/docs/api/wind.md +61 -15
- package/docs/cli/null3d.md +90 -15
- package/docs/concepts/architecture.md +69 -23
- package/docs/concepts/assets.md +57 -16
- package/docs/concepts/backends.md +65 -25
- package/docs/concepts/color-management.md +42 -13
- package/docs/concepts/culling.md +68 -47
- package/docs/concepts/handles.md +14 -5
- package/docs/concepts/instances.md +72 -23
- package/docs/concepts/large-worlds.md +17 -7
- package/docs/concepts/lighting.md +117 -44
- package/docs/concepts/lod.md +128 -33
- package/docs/concepts/materials.md +43 -12
- package/docs/concepts/particle-buffer.md +48 -35
- package/docs/concepts/post-processing.md +77 -14
- package/docs/concepts/quality-preset-tables.md +3 -2
- package/docs/concepts/quality-presets.md +122 -39
- package/docs/concepts/render-graph.md +56 -21
- package/docs/concepts/render-layers.md +9 -5
- package/docs/concepts/shadows.md +96 -25
- package/docs/concepts/static-dynamic.md +22 -7
- package/docs/cookbook/index.md +163 -119
- package/docs/data/threejs-mapping.json +301 -340
- package/docs/errors/E1101.md +23 -5
- package/docs/errors/E1102.md +11 -3
- package/docs/errors/E1103.md +11 -3
- package/docs/errors/E1104.md +11 -3
- package/docs/errors/E1105.md +13 -5
- package/docs/errors/E1106.md +11 -3
- package/docs/errors/E1107.md +15 -5
- package/docs/errors/E1108.md +11 -3
- package/docs/errors/E1109.md +32 -6
- package/docs/errors/E1110.md +23 -5
- package/docs/errors/E1111.md +11 -3
- package/docs/errors/E1112.md +11 -3
- package/docs/errors/E1203.md +12 -4
- package/docs/errors/E1204.md +11 -3
- package/docs/errors/E1205.md +11 -3
- package/docs/errors/E1206.md +28 -6
- package/docs/errors/E1207.md +11 -3
- package/docs/errors/E1208.md +12 -3
- package/docs/errors/E1209.md +11 -3
- package/docs/errors/E1213.md +27 -5
- package/docs/errors/E1214.md +11 -3
- package/docs/errors/E1215.md +31 -6
- package/docs/errors/E1216.md +31 -6
- package/docs/errors/E1217.md +29 -6
- package/docs/errors/E1218.md +22 -6
- package/docs/errors/E1219.md +11 -3
- package/docs/errors/E1220.md +24 -5
- package/docs/errors/E1221.md +24 -5
- package/docs/errors/E1222.md +11 -3
- package/docs/errors/E1223.md +39 -6
- package/docs/errors/E1224.md +11 -3
- package/docs/errors/E1225.md +11 -3
- package/docs/errors/E1301.md +11 -3
- package/docs/errors/E1302.md +11 -3
- package/docs/errors/E1303.md +11 -3
- package/docs/errors/E1304.md +11 -3
- package/docs/errors/E1305.md +13 -3
- package/docs/errors/E1306.md +11 -3
- package/docs/errors/E1307.md +23 -6
- package/docs/errors/E1401.md +11 -3
- package/docs/errors/E1402.md +13 -5
- package/docs/errors/E1403.md +11 -3
- package/docs/errors/E1404.md +13 -3
- package/docs/errors/E1405.md +15 -4
- package/docs/errors/E1406.md +31 -5
- package/docs/errors/E1407.md +11 -3
- package/docs/errors/E1408.md +11 -3
- package/docs/errors/E1409.md +11 -3
- package/docs/errors/E1410.md +13 -5
- package/docs/errors/E1411.md +11 -3
- package/docs/errors/E1412.md +29 -6
- package/docs/errors/E1413.md +11 -3
- package/docs/errors/E1414.md +11 -3
- package/docs/errors/E1415.md +11 -3
- package/docs/errors/E1416.md +27 -6
- package/docs/errors/E1417.md +11 -3
- package/docs/errors/E1418.md +12 -3
- package/docs/errors/E1419.md +13 -5
- package/docs/errors/E1420.md +11 -3
- package/docs/errors/E1421.md +11 -3
- package/docs/errors/E1422.md +12 -3
- package/docs/errors/E1423.md +12 -3
- package/docs/errors/E1424.md +24 -5
- package/docs/errors/E1425.md +11 -3
- package/docs/errors/E1426.md +11 -3
- package/docs/errors/E1430.md +11 -3
- package/docs/errors/E1431.md +11 -3
- package/docs/errors/E1432.md +11 -3
- package/docs/errors/E1433.md +11 -3
- package/docs/errors/E1434.md +15 -6
- package/docs/errors/E1435.md +11 -3
- package/docs/errors/E1436.md +11 -3
- package/docs/errors/E1437.md +14 -6
- package/docs/errors/E1501.md +41 -6
- package/docs/errors/E1502.md +13 -3
- package/docs/errors/E1503.md +11 -3
- package/docs/errors/E1504.md +11 -3
- package/docs/errors/E1505.md +23 -5
- package/docs/errors/E1506.md +11 -3
- package/docs/errors/index.md +52 -29
- package/docs/getting-started/cdn.md +15 -9
- package/docs/getting-started/first-scene.md +20 -12
- package/docs/getting-started/hosting.md +111 -63
- package/docs/getting-started/install.md +39 -24
- package/docs/getting-started/network-use.md +31 -21
- package/docs/getting-started/project-structure.md +20 -8
- package/docs/getting-started/third-party-notices.md +6 -10
- package/docs/guides/accessibility.md +4 -4
- package/docs/guides/add-ons.md +83 -13
- package/docs/guides/agents.md +2 -6
- package/docs/guides/assets-pipeline.md +248 -72
- package/docs/guides/audio.md +17 -15
- package/docs/guides/baked-light-data.md +44 -23
- package/docs/guides/car-paint.md +37 -31
- package/docs/guides/content-pages.md +53 -29
- package/docs/guides/custom-passes.md +59 -17
- package/docs/guides/custom-shaders.md +54 -37
- package/docs/guides/debugging.md +31 -41
- package/docs/guides/deploying.md +6 -27
- package/docs/guides/deterministic-simulation.md +23 -16
- package/docs/guides/first-use-shaders.md +83 -45
- package/docs/guides/lens-kit.md +29 -26
- package/docs/guides/loading-screens.md +70 -30
- package/docs/guides/multiple-views.md +22 -11
- package/docs/guides/performance.md +188 -37
- package/docs/guides/phones.md +71 -19
- package/docs/guides/physics.md +6 -10
- package/docs/guides/screens.md +41 -29
- package/docs/guides/start-time.md +120 -85
- package/docs/guides/testing.md +137 -98
- package/docs/guides/ui-overlays.md +17 -12
- package/docs/guides/video-textures.md +14 -13
- package/docs/images/api/animation/character.webp +0 -0
- package/docs/images/api/animation/look-at-ring.webp +0 -0
- package/docs/images/api/animation/morph-tulips.webp +0 -0
- package/docs/images/api/animation/skeleton-lines.webp +0 -0
- package/docs/images/api/controls/gizmo-handles.webp +0 -0
- package/docs/images/api/controls/walk-and-fly.webp +0 -0
- package/docs/images/api/debug/debug-shapes.webp +0 -0
- package/docs/images/api/debug/levels-view.webp +0 -0
- package/docs/images/api/engine/transparent-canvas.webp +0 -0
- package/docs/images/api/feature-draws/feature-draw-clouds.webp +0 -0
- package/docs/images/api/feature-instances/compute-instances.webp +0 -0
- package/docs/images/api/feature-instances/instances-shadow.webp +0 -0
- package/docs/images/api/geometry/extra-shapes.webp +0 -0
- package/docs/images/api/geometry/generators.webp +0 -0
- package/docs/images/api/geometry/mesh-arrays.webp +0 -0
- package/docs/images/api/geometry/vertex-updates.webp +0 -0
- package/docs/images/api/grass/grass-grove.webp +0 -0
- package/docs/images/api/grass/grass-presets.webp +0 -0
- package/docs/images/api/grass/grass-shadow.webp +0 -0
- package/docs/images/api/impostors/impostor-handover.webp +0 -0
- package/docs/images/api/impostors/impostor-shadow.webp +0 -0
- package/docs/images/api/impostors/impostors-forest.webp +0 -0
- package/docs/images/api/lights/spot-cookies.webp +0 -0
- package/docs/images/api/lines/lines-lit.webp +0 -0
- package/docs/images/api/lines/lines-widths.webp +0 -0
- package/docs/images/api/materials/coat-and-sheen.webp +0 -0
- package/docs/images/api/materials/decals.webp +0 -0
- package/docs/images/api/materials/iridescence-and-anisotropy.webp +0 -0
- package/docs/images/api/materials/relief.webp +0 -0
- package/docs/images/api/materials/shader-inputs.webp +0 -0
- package/docs/images/api/materials/standard-grid.webp +0 -0
- package/docs/images/api/materials/subsurface.webp +0 -0
- package/docs/images/api/materials/translucency.webp +0 -0
- package/docs/images/api/objects/objects-turntable.webp +0 -0
- package/docs/images/api/particles/campfire.webp +0 -0
- package/docs/images/api/points/galaxy.webp +0 -0
- package/docs/images/api/reference/textures/texture-wrap.webp +0 -0
- package/docs/images/api/render/fullscreen-glow.webp +0 -0
- package/docs/images/api/render/reflection-mirror.webp +0 -0
- package/docs/images/api/render/security-camera.webp +0 -0
- package/docs/images/api/scene/aurora-sky-layer.webp +0 -0
- package/docs/images/api/sound/sound-demo.webp +0 -0
- package/docs/images/api/splats/splats-demo.webp +0 -0
- package/docs/images/api/sprites/sprites-lines.webp +0 -0
- package/docs/images/api/terrain/terrain-demo.webp +0 -0
- package/docs/images/api/textures/canvas-screen.webp +0 -0
- package/docs/images/api/textures/mipmaps.webp +0 -0
- package/docs/images/api/vertex-draws/rain.webp +0 -0
- package/docs/images/api/water/ocean.webp +0 -0
- package/docs/images/api/water/water-demo.webp +0 -0
- package/docs/images/api/water/water-rain.webp +0 -0
- package/docs/images/api/water/waterfall.webp +0 -0
- package/docs/images/concepts/assets/gltf-model.webp +0 -0
- package/docs/images/concepts/color-management/tone-mapped.webp +0 -0
- package/docs/images/concepts/culling/far-from-origin.webp +0 -0
- package/docs/images/concepts/instances/instances.webp +0 -0
- package/docs/images/concepts/instances/per-row-colors.webp +0 -0
- package/docs/images/concepts/large-worlds/large-world.webp +0 -0
- package/docs/images/concepts/lighting/area-lights.webp +0 -0
- package/docs/images/concepts/lighting/atmosphere.webp +0 -0
- package/docs/images/concepts/lighting/environment.webp +0 -0
- package/docs/images/concepts/lighting/light-shafts.webp +0 -0
- package/docs/images/concepts/lighting/reflection-probes.webp +0 -0
- package/docs/images/concepts/lod/forest.webp +0 -0
- package/docs/images/concepts/materials/weighted-transparency.webp +0 -0
- package/docs/images/concepts/post-processing/auto-exposure.webp +0 -0
- package/docs/images/concepts/post-processing/bounce-light.webp +0 -0
- package/docs/images/concepts/post-processing/depth-of-field.webp +0 -0
- package/docs/images/concepts/post-processing/post-effects-alley.webp +0 -0
- package/docs/images/concepts/post-processing/sharpen.webp +0 -0
- package/docs/images/concepts/post-processing/ssr-wet-street.webp +0 -0
- package/docs/images/concepts/render-layers/layers-cottages.webp +0 -0
- package/docs/images/concepts/shadows/hero-shadow.webp +0 -0
- package/docs/images/cookbook/index/picking.webp +0 -0
- package/docs/images/cookbook/index/time-of-day.webp +0 -0
- package/docs/images/errors/E1431/area-lights-no-tables.webp +0 -0
- package/docs/images/guides/custom-passes/reflection-water.webp +0 -0
- package/docs/images/guides/deterministic-simulation/replay-demo.webp +0 -0
- package/docs/images/guides/multiple-views/split-screen.webp +0 -0
- package/docs/images/guides/performance/overdraw-view.webp +0 -0
- package/docs/images/guides/testing/hold-mode-frame.webp +0 -0
- package/docs/images/index/showcase-island.webp +0 -0
- package/docs/images/porting/threejs-shaders/dissolve.webp +0 -0
- package/docs/images/shaders/builtins/builtins.webp +0 -0
- package/docs/images/shaders/surface-functions/custom-surface.webp +0 -0
- package/docs/images/shaders/surface-functions/vertex-offset.webp +0 -0
- package/docs/images/shots.json +2231 -0
- package/docs/index.md +14 -23
- package/docs/moves.json +1 -0
- package/docs/nav.json +300 -0
- package/docs/pages.md +230 -212
- package/docs/porting/react-three-fiber.md +2 -6
- package/docs/porting/threejs-loop-and-threads.md +1 -5
- package/docs/porting/threejs-mapping.md +1248 -234
- package/docs/porting/threejs-materials.md +10 -5
- package/docs/porting/threejs-overview.md +26 -6
- package/docs/porting/threejs-postprocessing.md +2 -6
- package/docs/porting/threejs-shaders.md +16 -14
- package/docs/porting/threejs-unsupported.md +6 -6
- package/docs/porting/verification.md +0 -4
- package/docs/shaders/builtins.md +15 -4
- package/docs/shaders/library.md +9 -6
- package/docs/shaders/surface-functions.md +51 -16
- package/docs/shaders/wgsl-rules.md +12 -5
- package/lib/debug/debug.d.ts +2 -2
- package/lib/debug/draw.d.ts +2 -2
- package/lib/debug/draw.js +8 -4
- package/lib/debug/overlay-look.d.ts +6 -0
- package/lib/debug/overlay-look.js +29 -7
- package/lib/debug/overlay.js +15 -11
- package/lib/debug/stats-options.d.ts +13 -0
- package/lib/debug/stats-panel.d.ts +21 -6
- package/lib/debug/stats-panel.js +80 -13
- package/lib/errors/codes.d.ts +17 -3
- package/lib/errors/codes.js +111 -105
- package/lib/errors/fixes.js +18 -18
- package/lib/gpu/variants.d.ts +8 -2
- package/lib/gpu/variants.js +39 -7
- package/lib/gpu/webgl2/programs.js +1 -1
- package/lib/gpu/webgpu/pipelines.js +13 -13
- package/lib/index.d.ts +1 -1
- package/lib/page/capabilities.d.ts +1 -1
- package/lib/page/engine.d.ts +14 -5
- package/lib/page/engine.js +18 -2
- package/lib/page/label-loop.js +9 -4
- package/lib/page/stats-switch.js +2 -0
- package/lib/page/switches.d.ts +6 -4
- package/lib/page/switches.js +20 -4
- package/lib/scene/baked-light.d.ts +2 -2
- package/lib/scene/fake-call-values.js +2 -2
- package/lib/scene/frame-cameras.d.ts +16 -4
- package/lib/scene/frame-cameras.js +28 -10
- package/lib/scene/gltf.d.ts +1 -1
- package/lib/scene/level-rule.d.ts +6 -5
- package/lib/scene/level-rule.js +2 -2
- package/lib/scene/particles.d.ts +7 -3
- package/lib/scene/particles.js +3 -1
- package/lib/scene/post.d.ts +3 -2
- package/lib/scene/resources.d.ts +15 -9
- package/lib/scene/scene.d.ts +18 -2
- package/lib/scene/scene.js +47 -5
- package/lib/scene/time-of-day.d.ts +10 -5
- package/lib/scene/time-of-day.js +11 -7
- package/lib/shader-artifact.json +1 -1
- package/lib/shared/labels.d.ts +5 -2
- package/lib/shared/labels.js +5 -2
- package/lib/shared/permutation-words.d.ts +2 -0
- package/lib/shared/permutation-words.js +8 -0
- package/lib/shared/recording.d.ts +13 -5
- package/lib/shared/recording.js +31 -10
- package/lib/shared/sketch-data.d.ts +9 -0
- package/lib/shared/sketch-data.js +57 -0
- package/lib/shared/version.d.ts +1 -1
- package/lib/shared/version.js +1 -1
- package/lib/sketch/define-sketch.d.ts +16 -7
- package/lib/sketch/define-sketch.js +2 -1
- package/lib/sketch/runner.d.ts +4 -0
- package/lib/sketch/runner.js +5 -0
- package/lib/sketch/ui.js +4 -2
- package/lib/stats.d.ts +1 -0
- package/lib/workers/protocol.d.ts +10 -0
- package/lib/workers/render-worker.js +4 -1
- package/lib/workers/sketch-worker.js +4 -1
- package/package.json +1 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/** The file's first four bytes, which name the format. */
|
|
2
2
|
export declare const RECORDING_MAGIC = 1311982674;
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The format's version, which a reader refuses when it is newer than its own. Version 2 adds the
|
|
5
|
+
* sketch's start data; a reader takes version 1 as a recording without it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const RECORDING_VERSION = 2;
|
|
5
8
|
/** The most sketch time that a recording keeps, in seconds. */
|
|
6
9
|
export declare const MAX_RECORDING_SECONDS = 600;
|
|
7
10
|
/** The numbers of one event, as the recording stores them side by side: type, code, flags, id,
|
|
@@ -33,6 +36,8 @@ export interface ReplayProgram {
|
|
|
33
36
|
fixedRate: number;
|
|
34
37
|
/** The sketch's address when it was recorded, for a message about a different scene. */
|
|
35
38
|
sketch: string;
|
|
39
|
+
/** The start data that the sketch had, as JSON text, or undefined when it had none. */
|
|
40
|
+
data?: string;
|
|
36
41
|
/** True when the recording stopped at its limit before the session ended. */
|
|
37
42
|
stopped: boolean;
|
|
38
43
|
/** Each frame's step in seconds, which sums to the frame's sketch time. */
|
|
@@ -83,14 +88,17 @@ export declare class Recorder {
|
|
|
83
88
|
private growFrames;
|
|
84
89
|
private growEvents;
|
|
85
90
|
/**
|
|
86
|
-
* The file's bytes: the session's seed, the statistics that a replay needs, the
|
|
87
|
-
* the keys that the input used, and each frame's step with the input
|
|
91
|
+
* The file's bytes: the session's seed, the statistics that a replay needs, the sketch's start
|
|
92
|
+
* data, the dictionary of the keys that the input used, and each frame's step with the input
|
|
93
|
+
* that the sketch read.
|
|
88
94
|
*
|
|
89
|
-
* @param header The fixed rate of the sketch's fixed updates,
|
|
95
|
+
* @param header The fixed rate of the sketch's fixed updates, the sketch's address, and its
|
|
96
|
+
* start data as JSON text.
|
|
90
97
|
*/
|
|
91
98
|
encode(header: {
|
|
92
99
|
fixedRate: number;
|
|
93
100
|
sketch: string;
|
|
101
|
+
data?: string;
|
|
94
102
|
}): Uint8Array;
|
|
95
103
|
}
|
|
96
104
|
/**
|
package/lib/shared/recording.js
CHANGED
|
@@ -2,16 +2,21 @@
|
|
|
2
2
|
// a small binary file that replays on another machine to the same frames. The file holds the time
|
|
3
3
|
// of every frame as a step, delta-coded, and a dictionary of the keys that the input used. Replay
|
|
4
4
|
// runs the frames from the first one, with the sketch's setup as it started, so a session on a
|
|
5
|
-
// phone reproduces on a computer.
|
|
5
|
+
// phone reproduces on a computer. The file keeps the start data that the page gave the sketch, so
|
|
6
|
+
// the replay's setup reads the same data.
|
|
6
7
|
//
|
|
7
8
|
// The recorder lives on the sketch's thread, so it records what the sketch read, not what the page
|
|
8
9
|
// sent. A frame with no input costs sixteen bytes in its frame arrays and nine in the file: the
|
|
9
10
|
// step's eight-byte number and a one-byte count.
|
|
10
11
|
import { EVENT_KEY_DOWN, EVENT_KEY_UP } from './control.js';
|
|
12
|
+
import { MAX_SKETCH_DATA_BYTES } from './sketch-data.js';
|
|
11
13
|
/** The file's first four bytes, which name the format. */
|
|
12
14
|
export const RECORDING_MAGIC = 0x4e334452;
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The format's version, which a reader refuses when it is newer than its own. Version 2 adds the
|
|
17
|
+
* sketch's start data; a reader takes version 1 as a recording without it.
|
|
18
|
+
*/
|
|
19
|
+
export const RECORDING_VERSION = 2;
|
|
15
20
|
/** The most sketch time that a recording keeps, in seconds. */
|
|
16
21
|
export const MAX_RECORDING_SECONDS = 600;
|
|
17
22
|
/** The most frames and input records that a recording keeps, so a broken page cannot exhaust memory. */
|
|
@@ -19,6 +24,8 @@ const MAX_FRAMES = 2_000_000;
|
|
|
19
24
|
const MAX_EVENTS = 1_000_000;
|
|
20
25
|
/** The flag that marks a recording that stopped at its limit before the session ended. */
|
|
21
26
|
const FLAG_STOPPED = 1;
|
|
27
|
+
/** The flag that marks a recording whose header holds the sketch's start data. */
|
|
28
|
+
const FLAG_DATA = 2;
|
|
22
29
|
/** The numbers of one event, as the recording stores them side by side: type, code, flags, id,
|
|
23
30
|
* buttons, x and y. */
|
|
24
31
|
export const EVENT_STRIDE = 7;
|
|
@@ -262,19 +269,23 @@ export class Recorder {
|
|
|
262
269
|
this.events = events;
|
|
263
270
|
}
|
|
264
271
|
/**
|
|
265
|
-
* The file's bytes: the session's seed, the statistics that a replay needs, the
|
|
266
|
-
* the keys that the input used, and each frame's step with the input
|
|
272
|
+
* The file's bytes: the session's seed, the statistics that a replay needs, the sketch's start
|
|
273
|
+
* data, the dictionary of the keys that the input used, and each frame's step with the input
|
|
274
|
+
* that the sketch read.
|
|
267
275
|
*
|
|
268
|
-
* @param header The fixed rate of the sketch's fixed updates,
|
|
276
|
+
* @param header The fixed rate of the sketch's fixed updates, the sketch's address, and its
|
|
277
|
+
* start data as JSON text.
|
|
269
278
|
*/
|
|
270
279
|
encode(header) {
|
|
271
|
-
const out = new ByteWriter(64 + this.frameCount * 8);
|
|
280
|
+
const out = new ByteWriter(64 + (header.data?.length ?? 0) + this.frameCount * 8);
|
|
272
281
|
out.u32(RECORDING_MAGIC);
|
|
273
282
|
out.u8(RECORDING_VERSION);
|
|
274
|
-
out.u8(this.stopped ? FLAG_STOPPED : 0);
|
|
283
|
+
out.u8((this.stopped ? FLAG_STOPPED : 0) | (header.data === undefined ? 0 : FLAG_DATA));
|
|
275
284
|
out.u16(header.fixedRate);
|
|
276
285
|
out.u32(this.seed);
|
|
277
286
|
out.text(header.sketch);
|
|
287
|
+
if (header.data !== undefined)
|
|
288
|
+
out.text(header.data);
|
|
278
289
|
out.varint(this.keyNames.length);
|
|
279
290
|
for (const name of this.keyNames)
|
|
280
291
|
out.text(name);
|
|
@@ -313,12 +324,21 @@ export function decodeRecording(bytes) {
|
|
|
313
324
|
if (bytes.length < 4 || reader.u32() !== RECORDING_MAGIC)
|
|
314
325
|
throw new RecordingError('the file is not a null3D recording: it does not start with the format marker. Save the recording again, or ask for a new one.');
|
|
315
326
|
const version = reader.u8();
|
|
316
|
-
if (version
|
|
317
|
-
throw new RecordingError(`the file holds recording version ${version}, and this engine reads
|
|
327
|
+
if (version < 1 || version > RECORDING_VERSION)
|
|
328
|
+
throw new RecordingError(`the file holds recording version ${version}, and this engine reads versions 1 to ${RECORDING_VERSION}. Replay it with the engine that recorded it, or with a newer one.`);
|
|
318
329
|
const flags = reader.u8();
|
|
319
330
|
const fixedRate = whole(reader.u16(), 'the fixed step rate', 1, 1000);
|
|
320
331
|
const seed = reader.u32();
|
|
321
332
|
const sketch = reader.text(4096);
|
|
333
|
+
const data = (flags & FLAG_DATA) === 0 ? undefined : reader.text(MAX_SKETCH_DATA_BYTES);
|
|
334
|
+
if (data !== undefined) {
|
|
335
|
+
try {
|
|
336
|
+
JSON.parse(data);
|
|
337
|
+
}
|
|
338
|
+
catch {
|
|
339
|
+
throw new RecordingError("the file's start data for the sketch is not JSON text. Download it again, or record a new session.");
|
|
340
|
+
}
|
|
341
|
+
}
|
|
322
342
|
const keyCount = whole(reader.varint(), 'the dictionary of keys', 0, 512);
|
|
323
343
|
const keyNames = [];
|
|
324
344
|
for (let k = 0; k < keyCount; k++)
|
|
@@ -367,6 +387,7 @@ export function decodeRecording(bytes) {
|
|
|
367
387
|
seed,
|
|
368
388
|
fixedRate,
|
|
369
389
|
sketch,
|
|
390
|
+
data,
|
|
370
391
|
stopped: (flags & FLAG_STOPPED) !== 0,
|
|
371
392
|
steps,
|
|
372
393
|
starts,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The most bytes that the start data takes as JSON text, in UTF-8. */
|
|
2
|
+
export declare const MAX_SKETCH_DATA_BYTES = 65536;
|
|
3
|
+
/**
|
|
4
|
+
* The JSON text of `data`, or undefined for no data. Plain objects, arrays, strings, finite numbers,
|
|
5
|
+
* booleans and null pass, and a property whose value is undefined is left out, as JSON leaves it.
|
|
6
|
+
* Any other value fails with E1213, which names where it sits: JSON would change it or drop it, so
|
|
7
|
+
* the sketch and a replay would see other data than the page gave.
|
|
8
|
+
*/
|
|
9
|
+
export declare function sketchDataText(data: unknown): string | undefined;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// The start data that a page gives its sketch: plain JSON data, which travels to the sketch's thread
|
|
2
|
+
// as one string in the start message and which a recording keeps as the same text. The sketch's
|
|
3
|
+
// thread parses the text once, so the sketch gets its own copy on every thread.
|
|
4
|
+
import { EngineError } from '../errors/engine-error.js';
|
|
5
|
+
/** The most bytes that the start data takes as JSON text, in UTF-8. */
|
|
6
|
+
export const MAX_SKETCH_DATA_BYTES = 65_536;
|
|
7
|
+
/**
|
|
8
|
+
* The JSON text of `data`, or undefined for no data. Plain objects, arrays, strings, finite numbers,
|
|
9
|
+
* booleans and null pass, and a property whose value is undefined is left out, as JSON leaves it.
|
|
10
|
+
* Any other value fails with E1213, which names where it sits: JSON would change it or drop it, so
|
|
11
|
+
* the sketch and a replay would see other data than the page gave.
|
|
12
|
+
*/
|
|
13
|
+
export function sketchDataText(data) {
|
|
14
|
+
if (data === undefined)
|
|
15
|
+
return undefined;
|
|
16
|
+
checkValue(data, 'sketchData', new Set());
|
|
17
|
+
const text = JSON.stringify(data);
|
|
18
|
+
const bytes = new TextEncoder().encode(text).length;
|
|
19
|
+
if (bytes > MAX_SKETCH_DATA_BYTES)
|
|
20
|
+
throw new EngineError('E1213', `createEngine() got sketchData of ${bytes.toLocaleString('en')} bytes as JSON, over the limit of ${MAX_SKETCH_DATA_BYTES.toLocaleString('en')}. Pass a small start state, and load larger data in the sketch as a file.`);
|
|
21
|
+
return text;
|
|
22
|
+
}
|
|
23
|
+
/** Throws E1213 when `value`, at `path` in the data, is not plain JSON data. */
|
|
24
|
+
function checkValue(value, path, parents) {
|
|
25
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
26
|
+
return;
|
|
27
|
+
if (typeof value === 'number') {
|
|
28
|
+
if (Number.isFinite(value))
|
|
29
|
+
return;
|
|
30
|
+
refuse(path, String(value));
|
|
31
|
+
}
|
|
32
|
+
if (typeof value !== 'object')
|
|
33
|
+
refuse(path, `a ${typeof value}`);
|
|
34
|
+
if (parents.has(value))
|
|
35
|
+
refuse(path, 'an object that holds it');
|
|
36
|
+
parents.add(value);
|
|
37
|
+
if (Array.isArray(value)) {
|
|
38
|
+
for (let index = 0; index < value.length; index++) {
|
|
39
|
+
const item = value[index];
|
|
40
|
+
if (item === undefined)
|
|
41
|
+
refuse(`${path}[${index}]`, 'undefined');
|
|
42
|
+
checkValue(item, `${path}[${index}]`, parents);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const prototype = Object.getPrototypeOf(value);
|
|
47
|
+
if (prototype !== Object.prototype && prototype !== null)
|
|
48
|
+
refuse(path, `a ${value.constructor?.name ?? 'class instance'}`);
|
|
49
|
+
for (const [key, item] of Object.entries(value))
|
|
50
|
+
if (item !== undefined)
|
|
51
|
+
checkValue(item, `${path}.${key}`, parents);
|
|
52
|
+
}
|
|
53
|
+
parents.delete(value);
|
|
54
|
+
}
|
|
55
|
+
function refuse(path, what) {
|
|
56
|
+
throw new EngineError('E1213', `createEngine() got sketchData where ${path} is ${what}. sketchData takes plain JSON data: objects, arrays, strings, finite numbers, booleans and null.`);
|
|
57
|
+
}
|
package/lib/shared/version.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @category api/engine
|
|
5
5
|
*/
|
|
6
|
-
export declare const VERSION = "0.1.
|
|
6
|
+
export declare const VERSION = "0.1.1";
|
|
7
7
|
/**
|
|
8
8
|
* The version of the plugin interface that an add-on from another developer builds against. It is
|
|
9
9
|
* a whole number, and it changes only when a stable add-on hook changes, never with every engine
|
package/lib/shared/version.js
CHANGED
|
@@ -11,7 +11,7 @@ import { DEV } from './dev.js';
|
|
|
11
11
|
*
|
|
12
12
|
* @category api/engine
|
|
13
13
|
*/
|
|
14
|
-
export const VERSION = '0.1.
|
|
14
|
+
export const VERSION = '0.1.1';
|
|
15
15
|
/**
|
|
16
16
|
* The version of the plugin interface that an add-on from another developer builds against. It is
|
|
17
17
|
* a whole number, and it changes only when a stable add-on hook changes, never with every engine
|
|
@@ -135,11 +135,19 @@ export interface SketchPreferences {
|
|
|
135
135
|
onChange(handler: () => void): () => void;
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
|
-
* What the engine passes to a sketch's setup function.
|
|
138
|
+
* What the engine passes to a sketch's setup function. `Data` is the type of the start data that
|
|
139
|
+
* the page passes, which `defineSketch<Data>` names.
|
|
139
140
|
*
|
|
140
141
|
* @category api/sketch
|
|
141
142
|
*/
|
|
142
|
-
export interface SketchContext {
|
|
143
|
+
export interface SketchContext<Data = unknown> {
|
|
144
|
+
/**
|
|
145
|
+
* The start data that the page passed as `createEngine`'s `sketchData`, or undefined when it
|
|
146
|
+
* passed none. It is there from the start of the setup, before the first frame, also in hold
|
|
147
|
+
* mode. The sketch gets its own copy, so a change to it reaches neither the page nor a replay.
|
|
148
|
+
* A replay gives the data that the recording keeps.
|
|
149
|
+
*/
|
|
150
|
+
readonly data: Data | undefined;
|
|
143
151
|
/** Objects, cameras, lights and instance batches. */
|
|
144
152
|
scene: Scene;
|
|
145
153
|
/** Material factories. */
|
|
@@ -186,7 +194,7 @@ export interface SketchContext {
|
|
|
186
194
|
*
|
|
187
195
|
* @category api/sketch
|
|
188
196
|
*/
|
|
189
|
-
export type SketchSetup = (context: SketchContext) => SketchCallbacks | undefined | Promise<SketchCallbacks | undefined>;
|
|
197
|
+
export type SketchSetup<Data = unknown> = (context: SketchContext<Data>) => SketchCallbacks | undefined | Promise<SketchCallbacks | undefined>;
|
|
190
198
|
/**
|
|
191
199
|
* Options for `defineSketch`.
|
|
192
200
|
*
|
|
@@ -230,21 +238,22 @@ declare const SKETCH_MARKER: unique symbol;
|
|
|
230
238
|
*
|
|
231
239
|
* @category api/sketch
|
|
232
240
|
*/
|
|
233
|
-
export interface SketchDefinition {
|
|
241
|
+
export interface SketchDefinition<Data = unknown> {
|
|
234
242
|
readonly [SKETCH_MARKER]: true;
|
|
235
243
|
/** The setup function passed to `defineSketch`. */
|
|
236
|
-
readonly setup: SketchSetup
|
|
244
|
+
readonly setup: SketchSetup<Data>;
|
|
237
245
|
/** The options passed to `defineSketch`. */
|
|
238
246
|
readonly options: SketchOptions;
|
|
239
247
|
}
|
|
240
248
|
/**
|
|
241
249
|
* Declares a sketch. In null3D, a 3D scene is called a sketch: a module that builds the scene and
|
|
242
250
|
* updates it every frame, in the sketch worker. The module must export the result as its default
|
|
243
|
-
* export. `options` sets the rate of the fixed steps.
|
|
251
|
+
* export. `options` sets the rate of the fixed steps. `Data` types the start data that the setup
|
|
252
|
+
* reads as `ctx.data`, such as `defineSketch<{ stop: string }>(...)`.
|
|
244
253
|
*
|
|
245
254
|
* @category api/sketch
|
|
246
255
|
*/
|
|
247
|
-
export declare function defineSketch(setup: SketchSetup
|
|
256
|
+
export declare function defineSketch<Data = unknown>(setup: SketchSetup<Data>, options?: SketchOptions): SketchDefinition<Data>;
|
|
248
257
|
/** Imports the module at an address. */
|
|
249
258
|
type ModuleImport = (url: string) => Promise<{
|
|
250
259
|
default?: unknown;
|
|
@@ -19,7 +19,8 @@ const SKETCH_MARKER = Symbol.for('null3d.sketch');
|
|
|
19
19
|
/**
|
|
20
20
|
* Declares a sketch. In null3D, a 3D scene is called a sketch: a module that builds the scene and
|
|
21
21
|
* updates it every frame, in the sketch worker. The module must export the result as its default
|
|
22
|
-
* export. `options` sets the rate of the fixed steps.
|
|
22
|
+
* export. `options` sets the rate of the fixed steps. `Data` types the start data that the setup
|
|
23
|
+
* reads as `ctx.data`, such as `defineSketch<{ stop: string }>(...)`.
|
|
23
24
|
*
|
|
24
25
|
* @category api/sketch
|
|
25
26
|
*/
|
package/lib/sketch/runner.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface SketchCore {
|
|
|
46
46
|
pageUrl: string;
|
|
47
47
|
/** The sketch module's address, which a recording keeps and a replay compares. */
|
|
48
48
|
sketchUrl: string;
|
|
49
|
+
/** The start data that the page passed, as JSON text, which the sketch reads as `ctx.data`. */
|
|
50
|
+
data?: string;
|
|
49
51
|
/**
|
|
50
52
|
* The highest frame rate that the preset check and the governor aim for: the page's `targetFps`
|
|
51
53
|
* setting under the ?fps= cap, and infinity for the display's full rate.
|
|
@@ -272,6 +274,8 @@ export declare class SketchRunner {
|
|
|
272
274
|
private replaying;
|
|
273
275
|
/** True when the page records this session's frames and input. */
|
|
274
276
|
private readonly records;
|
|
277
|
+
/** The start data as JSON text: a replay's own, or the page's. A recording keeps it. */
|
|
278
|
+
private readonly dataText;
|
|
275
279
|
/**
|
|
276
280
|
* True when the session runs fixed frames rather than the page's: hold mode, which steps to a
|
|
277
281
|
* time, or a replay, which steps through a recording.
|
package/lib/sketch/runner.js
CHANGED
|
@@ -505,6 +505,8 @@ export class SketchRunner {
|
|
|
505
505
|
replaying = false;
|
|
506
506
|
/** True when the page records this session's frames and input. */
|
|
507
507
|
records;
|
|
508
|
+
/** The start data as JSON text: a replay's own, or the page's. A recording keeps it. */
|
|
509
|
+
dataText;
|
|
508
510
|
/**
|
|
509
511
|
* True when the session runs fixed frames rather than the page's: hold mode, which steps to a
|
|
510
512
|
* time, or a replay, which steps through a recording.
|
|
@@ -535,6 +537,7 @@ export class SketchRunner {
|
|
|
535
537
|
this.holdScript = holdScript;
|
|
536
538
|
this.replayProgram = replay;
|
|
537
539
|
this.records = record;
|
|
540
|
+
this.dataText = replay === undefined ? sketch.data : replay.data;
|
|
538
541
|
this.holdsFrames = holdSeconds !== undefined || replay !== undefined;
|
|
539
542
|
this.record = new FrameRecorder(metrics, Role.Sketch);
|
|
540
543
|
this.jobRecords = Array.from({ length: sketch.jobWorkers }, (_, k) => new FrameRecorder(metrics, Role.Job + k));
|
|
@@ -711,6 +714,7 @@ export class SketchRunner {
|
|
|
711
714
|
}
|
|
712
715
|
const holdsFrames = this.holdsFrames;
|
|
713
716
|
this.context = {
|
|
717
|
+
data: this.dataText === undefined ? undefined : JSON.parse(this.dataText),
|
|
714
718
|
time: this.time,
|
|
715
719
|
engine: {
|
|
716
720
|
viewport: this.viewport,
|
|
@@ -1720,6 +1724,7 @@ export class SketchRunner {
|
|
|
1720
1724
|
return this.recorder.encode({
|
|
1721
1725
|
fixedRate: Math.round(1 / this.fixed.step),
|
|
1722
1726
|
sketch: this.sketch.sketchUrl,
|
|
1727
|
+
data: this.dataText,
|
|
1723
1728
|
});
|
|
1724
1729
|
}
|
|
1725
1730
|
/** The dump steps that fall at the frame that is about to run, which read it after it ran. */
|
package/lib/sketch/ui.js
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
import { checkLive, checkVector, DEV } from '../errors/checks.js';
|
|
15
15
|
import { EngineError } from '../errors/engine-error.js';
|
|
16
16
|
import { FLAG_VISIBLE } from '../generated/core.js';
|
|
17
|
-
import { projectPoint, VIEW_CENTER_X, VIEW_CENTER_Y, VIEW_FAR, VIEW_FLOATS, VIEW_NEAR, VIEW_ORTHO, VIEW_SCALE_Y, } from '../scene/frame-cameras.js';
|
|
18
|
-
import { CAMERA_CENTER_X, CAMERA_CENTER_Y, CAMERA_HALF_HEIGHT, CAMERA_ORTHO, GENERATION_SHIFT, LABEL_DEPTH, LABEL_SHOWN, LABEL_STATE, LABEL_WORDS, LABEL_X, LABEL_Y, LABEL3D_MATRIX, LABEL3D_STATE, LABEL3D_WORDS, parityTable, parityTable3d, setParityCount, setParityCount3d, TABLE_3D, TABLE_SCREEN, } from '../shared/labels.js';
|
|
17
|
+
import { projectPoint, VIEW_CENTER_X, VIEW_CENTER_Y, VIEW_FAR, VIEW_FLOATS, VIEW_NEAR, VIEW_ORTHO, VIEW_SCALE_Y, VIEW_SHIFT_X, VIEW_SHIFT_Y, } from '../scene/frame-cameras.js';
|
|
18
|
+
import { CAMERA_CENTER_X, CAMERA_CENTER_Y, CAMERA_HALF_HEIGHT, CAMERA_ORTHO, CAMERA_SHIFT_X, CAMERA_SHIFT_Y, GENERATION_SHIFT, LABEL_DEPTH, LABEL_SHOWN, LABEL_STATE, LABEL_WORDS, LABEL_X, LABEL_Y, LABEL3D_MATRIX, LABEL3D_STATE, LABEL3D_WORDS, parityTable, parityTable3d, setParityCount, setParityCount3d, TABLE_3D, TABLE_SCREEN, } from '../shared/labels.js';
|
|
19
19
|
const GENERATIONS = 1 << 16;
|
|
20
20
|
/** The three transform modes, as the label's own tables number them. */
|
|
21
21
|
const SCREEN = 0;
|
|
@@ -375,6 +375,8 @@ function writeCamera(region, parity, view) {
|
|
|
375
375
|
record[CAMERA_ORTHO] = view[VIEW_ORTHO];
|
|
376
376
|
record[CAMERA_CENTER_X] = view[VIEW_CENTER_X];
|
|
377
377
|
record[CAMERA_CENTER_Y] = view[VIEW_CENTER_Y];
|
|
378
|
+
record[CAMERA_SHIFT_X] = view[VIEW_SHIFT_X];
|
|
379
|
+
record[CAMERA_SHIFT_Y] = view[VIEW_SHIFT_Y];
|
|
378
380
|
}
|
|
379
381
|
/** True when `object` and every ancestor it has are visible. */
|
|
380
382
|
function shownWithAncestors(object) {
|
package/lib/stats.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { MainThreadWindow, type MemoryMeasurement, measurePageMemory, type PageMemory, PageMemorySampler, pageHeapBytes, } from './debug/page-meters.js';
|
|
2
|
+
export type { StatsCorner } from './debug/stats-options.js';
|
|
2
3
|
export { type StatsFrameMode, StatsPanel, type StatsPanelFrame, type StatsPanelOptions, } from './debug/stats-panel.js';
|
|
3
4
|
export { type StatsFigures, type StatsGpuStep, type StatsMainThread, type StatsMemory, type StatsMemoryArea, type StatsThread, statsText, } from './debug/stats-text.js';
|
|
4
5
|
export { countPerSecond, type Percentiles, percentiles, ratePerSecond } from './shared/stats.js';
|
|
@@ -83,6 +83,8 @@ export type SketchWorkerInit = CoreHandoff & {
|
|
|
83
83
|
sketchUrl: string;
|
|
84
84
|
/** The page's address, which the sketch's relative asset addresses resolve against. */
|
|
85
85
|
pageUrl: string;
|
|
86
|
+
/** The start data that the page passed, as JSON text, which the sketch reads as `ctx.data`. */
|
|
87
|
+
data?: string;
|
|
86
88
|
/**
|
|
87
89
|
* The key names, in the order of the numbers that the page gives keys in the input ring. The
|
|
88
90
|
* page hands them over, so the sketch worker's file needs no copy.
|
|
@@ -185,6 +187,14 @@ export type WorkerReply = {
|
|
|
185
187
|
type: 'recorded';
|
|
186
188
|
role: 'sketch' | 'render';
|
|
187
189
|
permutations: number[];
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* In a development build, a permutation word that the drawing thread's pipelines found for the
|
|
193
|
+
* first time, which the page hands to the dev server to compare with the project's shader list.
|
|
194
|
+
*/
|
|
195
|
+
| {
|
|
196
|
+
type: 'permutation';
|
|
197
|
+
word: number;
|
|
188
198
|
} | {
|
|
189
199
|
type: 'error';
|
|
190
200
|
role: 'sketch' | 'render' | 'job';
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
// shared memory, so it runs no copy of the engine's core. The canvas cannot go back to the page once
|
|
4
4
|
// it is here, so when the engine stops, the worker keeps it: it frees its GPU device and lets go of
|
|
5
5
|
// the engine's memory, and the next engine on the same canvas starts it again with its own.
|
|
6
|
+
import { DEV } from '../errors/checks.js';
|
|
6
7
|
import { messageOf } from '../errors/message.js';
|
|
7
|
-
import { recordPermutations, stopRecordingPermutations } from '../gpu/variants.js';
|
|
8
|
+
import { recordPermutations, reportPermutations, stopRecordingPermutations } from '../gpu/variants.js';
|
|
8
9
|
import { captureFrame, captureImage, startDrawing, startEarly } from '../render/draw.js';
|
|
9
10
|
import { controlViews } from '../shared/control.js';
|
|
10
11
|
import { setWakeByMessage } from '../shared/wake.js';
|
|
@@ -41,6 +42,8 @@ startWorker('render', step, async (event) => {
|
|
|
41
42
|
// page stops it once the held frame has drawn them.
|
|
42
43
|
if (message.recordPermutations)
|
|
43
44
|
recordPermutations();
|
|
45
|
+
if (DEV)
|
|
46
|
+
reportPermutations((word) => replyToPage({ type: 'permutation', word }));
|
|
44
47
|
host = new DrawingHost();
|
|
45
48
|
imagePort = message.imagePort;
|
|
46
49
|
controlSlots = controlViews(message.control).slots;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// starts it again.
|
|
10
10
|
import { DEV } from '../errors/checks.js';
|
|
11
11
|
import { messageOf } from '../errors/message.js';
|
|
12
|
-
import { recordPermutations, stopRecordingPermutations } from '../gpu/variants.js';
|
|
12
|
+
import { recordPermutations, reportPermutations, stopRecordingPermutations } from '../gpu/variants.js';
|
|
13
13
|
import { loadDrawModule, preloadDrawing } from '../render/load-draw.js';
|
|
14
14
|
import { awaitLater } from '../shared/await-later.js';
|
|
15
15
|
import { controlViews } from '../shared/control.js';
|
|
@@ -126,6 +126,7 @@ startWorker('sketch', step, async (event) => {
|
|
|
126
126
|
...senders,
|
|
127
127
|
pageUrl: message.pageUrl,
|
|
128
128
|
sketchUrl: message.sketchUrl,
|
|
129
|
+
data: message.data,
|
|
129
130
|
maxTargetFps: message.maxTargetFps,
|
|
130
131
|
threads: message.threads,
|
|
131
132
|
twoStepProbe: message.twoStepProbe,
|
|
@@ -159,6 +160,8 @@ startWorker('sketch', step, async (event) => {
|
|
|
159
160
|
// pipelines ask for. The page stops it once the held frame has drawn them.
|
|
160
161
|
if (message.renderer.recordPermutations)
|
|
161
162
|
recordPermutations();
|
|
163
|
+
if (DEV)
|
|
164
|
+
reportPermutations((word) => replyToPage({ type: 'permutation', word }));
|
|
162
165
|
step('renderer loaded');
|
|
163
166
|
const started = early;
|
|
164
167
|
early = undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@null3d/engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "The null3D engine, a high-performance browser 3D engine for agents, faster than three.js, with wide device compatibility: the TypeScript API, the page shim, the worker entry points, both WebAssembly builds and the docs.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"author": "Ramesh Nair (https://hiddentao.com)",
|