@null3d/engine 0.1.0 → 0.1.2
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 +40 -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 +68 -24
- 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/E1308.md +31 -0
- 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 +53 -29
- package/docs/getting-started/cdn.md +15 -9
- package/docs/getting-started/first-scene.md +20 -12
- package/docs/getting-started/hosting.md +113 -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 +13 -14
- package/docs/guides/assets-pipeline.md +294 -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 +86 -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 +10 -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 +74 -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 +126 -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 +116 -105
- package/lib/errors/engine-error.js +1 -1
- package/lib/errors/fixes.d.ts +1 -0
- package/lib/errors/fixes.js +19 -18
- package/lib/generated/shader-permutations.d.ts +6 -0
- package/lib/generated/shader-permutations.js +6 -0
- 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 +29 -7
- package/lib/page/engine.js +79 -7
- 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 +8 -0
- package/lib/shared/permutation-words.js +14 -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/tier.d.ts +9 -0
- package/lib/shared/tier.js +4 -1
- 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
|
@@ -2927,8 +2927,9 @@ export function setOcclusionReadSlot(slot) {
|
|
|
2927
2927
|
/**
|
|
2928
2928
|
* Draws from this camera object with an orthographic lens. The call values give the view's height
|
|
2929
2929
|
* and width, with a width of 0 following the canvas's aspect ratio, how far right of and above
|
|
2930
|
-
* the camera's axis it is centered,
|
|
2931
|
-
*
|
|
2930
|
+
* the camera's axis it is centered, the near and far distances, and the lens shift across and up,
|
|
2931
|
+
* in fractions of the view's width and height. It draws the objects whose layer masks share a bit
|
|
2932
|
+
* with `layers`. With `target` the shadows' camera, it fits the main
|
|
2932
2933
|
* directional light's cascades.
|
|
2933
2934
|
* @param {number} camera
|
|
2934
2935
|
* @param {number} layers
|
|
@@ -3001,8 +3002,9 @@ export function setPassValues(place) {
|
|
|
3001
3002
|
/**
|
|
3002
3003
|
* Draws from this camera object with a perspective lens, the objects whose layer masks share a
|
|
3003
3004
|
* bit with `layers`. The call values give the vertical field of view in degrees, the near
|
|
3004
|
-
* distance
|
|
3005
|
-
* the camera
|
|
3005
|
+
* distance, the far distance and the lens shift across and up, in fractions of the view's width and
|
|
3006
|
+
* height. With `target` the shadows' camera (`constants::camera_target`), the camera fits the main
|
|
3007
|
+
* directional light's cascades instead.
|
|
3006
3008
|
* @param {number} camera
|
|
3007
3009
|
* @param {number} layers
|
|
3008
3010
|
* @param {number} target
|
|
@@ -3752,13 +3754,13 @@ export function writeParticleRecords(id, count, first) {
|
|
|
3752
3754
|
function __wbg_get_imports() {
|
|
3753
3755
|
const import0 = {
|
|
3754
3756
|
__proto__: null,
|
|
3755
|
-
|
|
3757
|
+
__wbg___null3dWantJobWorkers_a7e579abfe5104c1: function() {
|
|
3756
3758
|
globalThis.__null3dWantJobWorkers();
|
|
3757
3759
|
},
|
|
3758
|
-
|
|
3760
|
+
__wbg_error_1b4739328f95458f: function(arg0, arg1) {
|
|
3759
3761
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
3760
3762
|
},
|
|
3761
|
-
|
|
3763
|
+
__wbg_now_2d6cdf5b44f2ba86: function() {
|
|
3762
3764
|
const ret = performance.now();
|
|
3763
3765
|
return ret;
|
|
3764
3766
|
},
|
|
@@ -3969,4 +3971,4 @@ async function __wbg_init(module_or_path) {
|
|
|
3969
3971
|
|
|
3970
3972
|
export { initSync, __wbg_init as default };
|
|
3971
3973
|
|
|
3972
|
-
export const coreSources = "
|
|
3974
|
+
export const coreSources = "971a5051f735f1c8";
|
|
Binary file
|
|
@@ -2927,8 +2927,9 @@ export function setOcclusionReadSlot(slot) {
|
|
|
2927
2927
|
/**
|
|
2928
2928
|
* Draws from this camera object with an orthographic lens. The call values give the view's height
|
|
2929
2929
|
* and width, with a width of 0 following the canvas's aspect ratio, how far right of and above
|
|
2930
|
-
* the camera's axis it is centered,
|
|
2931
|
-
*
|
|
2930
|
+
* the camera's axis it is centered, the near and far distances, and the lens shift across and up,
|
|
2931
|
+
* in fractions of the view's width and height. It draws the objects whose layer masks share a bit
|
|
2932
|
+
* with `layers`. With `target` the shadows' camera, it fits the main
|
|
2932
2933
|
* directional light's cascades.
|
|
2933
2934
|
* @param {number} camera
|
|
2934
2935
|
* @param {number} layers
|
|
@@ -3001,8 +3002,9 @@ export function setPassValues(place) {
|
|
|
3001
3002
|
/**
|
|
3002
3003
|
* Draws from this camera object with a perspective lens, the objects whose layer masks share a
|
|
3003
3004
|
* bit with `layers`. The call values give the vertical field of view in degrees, the near
|
|
3004
|
-
* distance
|
|
3005
|
-
* the camera
|
|
3005
|
+
* distance, the far distance and the lens shift across and up, in fractions of the view's width and
|
|
3006
|
+
* height. With `target` the shadows' camera (`constants::camera_target`), the camera fits the main
|
|
3007
|
+
* directional light's cascades instead.
|
|
3006
3008
|
* @param {number} camera
|
|
3007
3009
|
* @param {number} layers
|
|
3008
3010
|
* @param {number} target
|
|
@@ -3752,13 +3754,13 @@ export function writeParticleRecords(id, count, first) {
|
|
|
3752
3754
|
function __wbg_get_imports(memory) {
|
|
3753
3755
|
const import0 = {
|
|
3754
3756
|
__proto__: null,
|
|
3755
|
-
|
|
3757
|
+
__wbg___null3dWantJobWorkers_a7e579abfe5104c1: function() {
|
|
3756
3758
|
globalThis.__null3dWantJobWorkers();
|
|
3757
3759
|
},
|
|
3758
|
-
|
|
3760
|
+
__wbg_error_1b4739328f95458f: function(arg0, arg1) {
|
|
3759
3761
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
3760
3762
|
},
|
|
3761
|
-
|
|
3763
|
+
__wbg_now_2d6cdf5b44f2ba86: function() {
|
|
3762
3764
|
const ret = performance.now();
|
|
3763
3765
|
return ret;
|
|
3764
3766
|
},
|
|
@@ -3985,4 +3987,4 @@ export function releaseInstance() {
|
|
|
3985
3987
|
dropMemoryViews();
|
|
3986
3988
|
}
|
|
3987
3989
|
|
|
3988
|
-
export const coreSources = "
|
|
3990
|
+
export const coreSources = "971a5051f735f1c8";
|
|
Binary file
|
package/docs/api/animation.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: api/animation
|
|
3
3
|
title: Animation
|
|
4
|
-
status: experimental
|
|
5
|
-
since: "0.2"
|
|
6
4
|
summary: "The animator; play, crossFade, clip weights, start times, 1D blends, layers, joint masks, additive clips, joint overrides and look-at, events; property animation of lights, cameras and materials, glTF's KHR_animation_pointer; morph weights."
|
|
7
5
|
---
|
|
8
6
|
|
|
9
7
|
# Animation
|
|
10
8
|
|
|
11
|
-
> Roadmap step 0.2, first released in null3D 0.1.0. The API is experimental, so it can still change between versions.
|
|
12
|
-
|
|
13
9
|
```mermaid
|
|
14
10
|
flowchart LR
|
|
15
11
|
calls["Your sketch:<br/>play, crossFade, stop,<br/>clip and layer weights,<br/>blend values, joint rotations,<br/>look-at targets"] --> state["Each object's clips:<br/>times, weights and fades,<br/>joint overrides"]
|
|
@@ -26,6 +22,10 @@ Characters animate on the job workers, in the engine's WebAssembly core. Each fr
|
|
|
26
22
|
|
|
27
23
|
`assets.loadGltf` reads a model's skins, its clips and its morph targets. Each copy that `scene.instantiate` makes gets an animator on its group, which plays the model's clips. `prefab.clips` lists their names. The [character demo](https://github.com/null3d-engine/null3d/tree/main/examples/character) blends a character's clips by its speed, and swings its sword on an upper-body layer.
|
|
28
24
|
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
The animated characters demo. In the cookbook, say it is the demo, not the recipe: its camera orbits.
|
|
28
|
+
|
|
29
29
|
```ts
|
|
30
30
|
const knight = await assets.loadGltf('/models/knight.glb');
|
|
31
31
|
const hero = scene.instantiate(knight, { position: [0, 0, 0] });
|
|
@@ -49,12 +49,16 @@ A model's morph targets load with their default weights, and its clips animate t
|
|
|
49
49
|
|
|
50
50
|
The engine keeps each clip at one fixed rate of keys. The loader hands every clip to the job workers, which put it at that rate between frames. A track whose keys already sit at the rate is copied, and the job workers resample the others. A model's clips are ready when `loadGltf` resolves. In the single-threaded mode, the sketch's thread does this work a few milliseconds at a time.
|
|
51
51
|
|
|
52
|
-
Files from `bunx @null3d/cli assets optimize` store every clip at the engine's rate, so they load with copies alone. [The asset pipeline](../guides/assets-pipeline.md#what-it-does-to-clips) says how.
|
|
52
|
+
Files from `bunx @null3d/cli assets optimize` store every clip at the engine's rate, so they load with copies alone. [The asset pipeline](../guides/assets-pipeline.md#what-it-does-to-clips) says how. In Chrome on a MacBook Pro, on the engine's test page, the KayKit Knight's 76 clips took 16.5 ms on two job workers from its source file. From the command's output they took 8 ms, and the output's binary part is 46% smaller.
|
|
53
53
|
|
|
54
54
|
## Seeing the skeleton
|
|
55
55
|
|
|
56
56
|
`debug.skeleton(object)` draws the joints of an animated object, such as a copy's group, in the frame's pose. It draws a line from each joint of a skin to its parent joint. A line is blue at the joint and green at its parent. Pass a color to draw every line in that color. Call it in `onUpdate`, as every debug drawing call. Only development builds draw it.
|
|
57
57
|
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
debug.skeleton with the default colors and with one color.
|
|
61
|
+
|
|
58
62
|
```ts
|
|
59
63
|
return {
|
|
60
64
|
onUpdate() {
|
|
@@ -94,11 +98,20 @@ return {
|
|
|
94
98
|
| `weight` | 1 | The clip's own weight, 0 or more. A play with a weight joins the other clips of its layer instead of fading them out, as [Clip weights](#clip-weights) shows. |
|
|
95
99
|
| `transition` | `'blend'` | How a play with a fade switches what its layer plays. `'blend'` cross-fades the layer's old clips with the new one, and samples both while the fade runs. `'inertial'` samples only the new clip: the pose the layer leaves carries on at its own speed and eases into the new clip, as [Inertial transitions](#inertial-transitions) shows. It needs a fade above 0, no `weight`, a clip to switch from, and a new clip that does not already play on the layer. An additive play always cross-fades. |
|
|
96
100
|
|
|
97
|
-
`crossFade(name, duration, options)` is `play` with a fade of `duration` seconds, and takes `play`'s other options, such as `layer`, `loop` and `weight`. It always cross-fades, whatever its `transition`, so it shows the mix of the clips while the fade runs. A cross-fade always takes over its layer, with a weight too.
|
|
101
|
+
`crossFade(name, duration, options)` is `play` with a fade of `duration` seconds, and takes `play`'s other options, such as `layer`, `loop` and `weight`. It always cross-fades, whatever its `transition`, so it shows the mix of the clips while the fade runs. A cross-fade always takes over its layer, with a weight too.
|
|
102
|
+
|
|
103
|
+
A clip that already plays on its layer keeps its time when you play it again, and fades back in from its current weight. So calling `play` with the same clip again does no harm. A clip that played once and reached its end starts again.
|
|
98
104
|
|
|
99
105
|
A plain play fades out only the plain clips of its layer, and an additive play only the additive clips. So a walk keeps playing when a breath starts on its layer as an additive clip.
|
|
100
106
|
|
|
101
|
-
Keep the options of the plays that a game repeats in frozen constants. The animator reads a frozen options object once and keeps what it read, so a clip switch allocates nothing.
|
|
107
|
+
Keep the options of the plays that a game repeats in frozen constants. The animator reads a frozen options object once and keeps what it read, so a clip switch allocates nothing. The same holds for the points of `playBlend`.
|
|
108
|
+
|
|
109
|
+
<details>
|
|
110
|
+
<summary>Technical details: why a frozen options object allocates nothing</summary>
|
|
111
|
+
|
|
112
|
+
From an object that is not frozen, the animator reads at every play. The browser then makes a new 12-byte number for each fraction it reads.
|
|
113
|
+
|
|
114
|
+
</details>
|
|
102
115
|
|
|
103
116
|
```ts
|
|
104
117
|
const TO_RUN = Object.freeze({ fade: 0.3, weight: 0.75 });
|
|
@@ -123,7 +136,7 @@ for (const [k, knight] of knights.entries()) {
|
|
|
123
136
|
|
|
124
137
|
## Property animation
|
|
125
138
|
|
|
126
|
-
A clip can move values other than bones and morph weights. A glTF file with `KHR_animation_pointer` moves a material's color or opacity, and where its maps sit on the texture coordinates. It also moves a light's intensity or color, or a node's visibility. These tracks follow the clip's time, speed, fades and weights. A sketch starts the same kind of animation in code with `scene.animateProperty`.
|
|
139
|
+
A clip can move values other than bones and morph weights. A glTF file with `KHR_animation_pointer` moves a material's color or opacity, and where its maps sit on the texture coordinates. It also moves a light's intensity or color, or a node's visibility. These tracks follow the clip's time, speed, fades and weights. A sketch starts the same kind of animation in code with `scene.animateProperty`. The [animated values demo](https://github.com/null3d-engine/null3d/tree/main/examples/property-animation) moves a lamp, a material and a camera with keyframes.
|
|
127
140
|
|
|
128
141
|
```ts
|
|
129
142
|
const pulse = scene.animateProperty(lamp, 'light.intensity', {
|
|
@@ -173,14 +186,20 @@ An animation of a material changes every object that uses the material, as a cha
|
|
|
173
186
|
|
|
174
187
|
### Files with KHR_animation_pointer
|
|
175
188
|
|
|
176
|
-
The loader reads a pointer to a node's transform, its morph weights, or its visibility under `KHR_node_visibility`. It also reads a pointer to a material's values, and to a light's intensity, color or range. A base color factor moves the material's color, and its fourth number moves the opacity. The offset and scale of a base color texture's or an emissive texture's `KHR_texture_transform` move that map's own transform, and leave the material's other maps as the file places them.
|
|
189
|
+
The loader reads a pointer to a node's transform, its morph weights, or its visibility under `KHR_node_visibility`. It also reads a pointer to a material's values, and to a light's intensity, color or range. A base color factor moves the material's color, and its fourth number moves the opacity. The offset and scale of a base color texture's or an emissive texture's `KHR_texture_transform` move that map's own transform, and leave the material's other maps as the file places them.
|
|
190
|
+
|
|
191
|
+
Each track joins its clip, so `animator().play(name)` plays it with the clip's other tracks. A clip at less than full weight mixes the value with the value that the file gave the property.
|
|
177
192
|
|
|
178
193
|
```ts
|
|
179
194
|
const copy = scene.instantiate(await assets.loadGltf(url));
|
|
180
195
|
copy.animator().play('Cube Animation');
|
|
181
196
|
```
|
|
182
197
|
|
|
183
|
-
A pointer that the engine does not read leaves the value as the file has it. Development builds warn about each one. The names show the kind.
|
|
198
|
+
A pointer that the engine does not read leaves the value as the file has it. Development builds warn about each one. The names show the kind.
|
|
199
|
+
|
|
200
|
+
The engine leaves out a camera's values, because it reads no cameras from files. It leaves out an animated texture transform's rotation, and an animated transform of every texture but a base color or an emissive one. It leaves out a light's inner cone angle. It also leaves out `normalTexture/scale`, and the pointers of `KHR_materials_ior`, `KHR_materials_volume`'s attenuation color and distance, and `KHR_materials_iridescence`'s thickness range.
|
|
201
|
+
|
|
202
|
+
It leaves out the values of extensions that it does not draw. A file's own transforms stay per map, so a file that places its maps differently draws that way.
|
|
184
203
|
|
|
185
204
|
## Clip weights
|
|
186
205
|
|
|
@@ -239,7 +258,9 @@ never uses one pays nothing, and a transition that starts allocates nothing.
|
|
|
239
258
|
|
|
240
259
|
## 1D blends
|
|
241
260
|
|
|
242
|
-
A 1D blend mixes clips by one value, such as the character's speed. `playBlend(points, options)` gives each clip a point on a line. At a clip's point, that clip plays in full. Between two points, the two clips around the value share it. Past the first or the last point, that point's clip plays in full.
|
|
261
|
+
A 1D blend mixes clips by one value, such as the character's speed. `playBlend(points, options)` gives each clip a point on a line. At a clip's point, that clip plays in full. Between two points, the two clips around the value share it. Past the first or the last point, that point's clip plays in full.
|
|
262
|
+
|
|
263
|
+
`setBlend(value, layer)` moves the value. It writes engine memory, so you can call it every frame at no cost.
|
|
243
264
|
|
|
244
265
|
```ts
|
|
245
266
|
const anim = knight.animator();
|
|
@@ -265,11 +286,13 @@ The clips of a blend share one phase, as PlayCanvas's blend trees and Godot's cy
|
|
|
265
286
|
| `layer` | 0 | The layer, from 0 to 3. |
|
|
266
287
|
| `phase` | the layer's phase | The share of the cycle, from 0 to 1, at which the clips start. |
|
|
267
288
|
|
|
268
|
-
A blend holds 1 to 8 clips, each at a point of its own. Without a `phase`, a blend starts at the phase of the layer's blend. Failing that, it takes the phase of the first of its clips that the layer plays. So a switch from a walk to a blend with the walk keeps the step.
|
|
289
|
+
A blend holds 1 to 8 clips, each at a point of its own. Without a `phase`, a blend starts at the phase of the layer's blend. Failing that, it takes the phase of the first of its clips that the layer plays. So a switch from a walk to a blend with the walk keeps the step.
|
|
290
|
+
|
|
291
|
+
`play` or `crossFade` on the layer ends the blend. Each of its clips then keeps the weight and the rate it had, and fades out. A call to `setWeight` on a clip of a blend multiplies its share of the blend.
|
|
269
292
|
|
|
270
293
|
## Layers and joint masks
|
|
271
294
|
|
|
272
|
-
Each animator has four layers, numbered 0 to 3. Layer 0 blends its clips with the rest pose. Each layer above replaces the pose of the layers below, by the layer's weight.
|
|
295
|
+
Each animator has four layers, numbered 0 to 3. Layer 0 blends its clips with the rest pose. Each layer above replaces the pose of the layers below, by the layer's weight. The [character demo](https://github.com/null3d-engine/null3d/tree/main/examples/character) swings its sword on an upper-body layer.
|
|
273
296
|
|
|
274
297
|
`setLayerMask(layer, joints)` limits a layer to some joints: each named joint and every joint below it. Pass the name of a joint, or an array of names. `null` gives the layer every joint again.
|
|
275
298
|
|
|
@@ -322,7 +345,11 @@ The joints below a turned joint follow it, and so do the meshes that hang on the
|
|
|
322
345
|
|
|
323
346
|
### Looking at a point
|
|
324
347
|
|
|
325
|
-
`lookAt(target, options, weight)` turns a chain of joints so that the last one aims at a point in the world. The engine aims again in each frame from the animated pose, until `lookAt(null)` stops it. So a soldier keeps its rifle on a target while its walk sways its body. Call `lookAt` every frame to follow a moving point.
|
|
348
|
+
`lookAt(target, options, weight)` turns a chain of joints so that the last one aims at a point in the world. The engine aims again in each frame from the animated pose, until `lookAt(null)` stops it. So a soldier keeps its rifle on a target while its walk sways its body. Call `lookAt` every frame to follow a moving point. The [look-at demo](https://github.com/null3d-engine/null3d/tree/main/examples/look-at) turns seven knights' heads toward a wisp of light.
|
|
349
|
+
|
|
350
|
+

|
|
351
|
+
|
|
352
|
+
Joint overrides that look at a point.
|
|
326
353
|
|
|
327
354
|
```ts
|
|
328
355
|
const AIM = Object.freeze({ joints: ['Spine', 'Chest', 'Neck'], limit: 0.8 });
|
|
@@ -355,7 +382,12 @@ In each frame, the clips blend first, then each joint rotation applies in the or
|
|
|
355
382
|
|
|
356
383
|
A scene that never calls a joint call pays nothing: the engine makes the table of joint overrides at the first call. After that, an object without overrides costs a few reads in each frame. A joint rotation costs one quaternion blend. A look-at costs a few matrix products for each joint between the skeleton's root and the chain's last joint.
|
|
357
384
|
|
|
358
|
-
The calls allocate nothing, but
|
|
385
|
+
The calls allocate nothing, but in a crowd, a weight that is a fraction and changes in each frame can make garbage for the collector. To stop this, call the joint calls from a small function of its own that takes only objects and whole numbers. The default weight, 1, never allocates. The same holds for every engine call that takes a fraction, such as `setPosition` or `setLayerWeight`.
|
|
386
|
+
|
|
387
|
+
<details>
|
|
388
|
+
<summary>Technical details: why a fraction can allocate, and how to stop it</summary>
|
|
389
|
+
|
|
390
|
+
The browser inlines a small call into the function that makes it. In a large frame step, it may stop doing so, and then it passes each fraction as a new 12-byte number object. One knight per frame does not matter; a crowd of them makes garbage for the collector. The rotation and the target cross in arrays, so they never box. Give the small function only objects and whole numbers, such as the animator and its index, and let it read the frame's fractions from an array:
|
|
359
391
|
|
|
360
392
|
```ts
|
|
361
393
|
const now = new Float64Array(1);
|
|
@@ -371,7 +403,7 @@ return {
|
|
|
371
403
|
};
|
|
372
404
|
```
|
|
373
405
|
|
|
374
|
-
|
|
406
|
+
</details>
|
|
375
407
|
|
|
376
408
|
## Events
|
|
377
409
|
|
|
@@ -382,6 +414,8 @@ Events come from the clip's data. The animator also reports two events of its ow
|
|
|
382
414
|
- `'loop'` fires each time a repeating clip starts again.
|
|
383
415
|
- `'finished'` fires once when a clip that plays once reaches its end.
|
|
384
416
|
|
|
417
|
+
The [character demo](https://github.com/null3d-engine/null3d/tree/main/examples/character) listens for `'finished'` and stops the sword swing when it ends.
|
|
418
|
+
|
|
385
419
|
Each event fires once each time the clip's time passes it, however long the frame was. An event at a clip's last frame fires as the clip loops, as one at its first frame does. Backward clips fire events too, in their order of play.
|
|
386
420
|
|
|
387
421
|
Handlers run on your sketch's thread at the start of the next frame, before `onFixedUpdate` and `onUpdate`. So your update code sees what the clips reached in the frame before. A clip that a handler plays starts in that frame.
|
|
@@ -403,7 +437,9 @@ A cubic spline track, as glTF stores one, keeps an in-tangent and an out-tangent
|
|
|
403
437
|
|
|
404
438
|
## Blending
|
|
405
439
|
|
|
406
|
-
An object blends up to eight clips in a frame, each at its own time and weight. Two layers that each cross-fade between two clips, with an additive clip on top, fit with room to spare. So does a three-clip blend that cross-fades to another while a second layer cross-fades between two clips.
|
|
440
|
+
An object blends up to eight clips in a frame, each at its own time and weight. Two layers that each cross-fade between two clips, with an additive clip on top, fit with room to spare. So does a three-clip blend that cross-fades to another while a second layer cross-fades between two clips.
|
|
441
|
+
|
|
442
|
+
When all eight are busy, a new clip takes the place of a clip that fades out, the one that counts least. Only when no clip fades out does it take the place of the clip that counts least at that moment.
|
|
407
443
|
|
|
408
444
|
Within a layer, the engine blends clips joint by joint:
|
|
409
445
|
|
|
@@ -417,15 +453,30 @@ Rotations between keys and rotations in a blend use a corrected form of normaliz
|
|
|
417
453
|
|
|
418
454
|
A skinned mesh's vertices follow the joints of an animated object. Each vertex names up to four joints, with a weight for each. Its skinned place is the sum of its joints' skinning matrices applied to it, each times its weight. The mesh's own world matrix then places it.
|
|
419
455
|
|
|
420
|
-
On both paths, the vertex shader of each pass that draws a skinned mesh skins it. The shadow passes skin it again.
|
|
456
|
+
On both GPU paths, the vertex shader of each pass that draws a skinned mesh skins it. The shadow passes skin it again. Each frame uploads the animated objects' skinning matrices to one float texture, 48 bytes per joint. Every material skins in the vertex shader, custom materials included. Skinned meshes that share a mesh and a material draw in one instanced draw in each pass, so a crowd costs few draw calls.
|
|
457
|
+
|
|
458
|
+
On WebGPU, a custom material's [skinning builds](../guides/custom-shaders.md) download the first time the material draws a skinned mesh. A page whose custom materials never draw one never downloads them. The mesh draws once they have arrived, so call `await scene.warmUp()` in the setup to load them before play.
|
|
459
|
+
|
|
460
|
+
<details>
|
|
461
|
+
<summary>Technical details: why the vertex shader skins</summary>
|
|
462
|
+
|
|
463
|
+
On the devices that the engine was measured on, skinning in each pass's vertex shader was as fast as skinning once per frame, or faster. Those measurements skinned once per frame with a compute pass on WebGPU and with transform feedback on WebGL2. `?skinning=compute` makes WebGPU skin every skinned mesh in its compute pass, so you can compare the two methods on your device ([Testing](../guides/testing.md#switches-for-tests)).
|
|
464
|
+
|
|
465
|
+
</details>
|
|
421
466
|
|
|
422
|
-
On WebGPU, a compute pass, the skinning pass, skins two kinds of mesh once per frame instead. It runs before the shadow passes and the scene passes. The first kind is morphed meshes, which it morphs first. The second is meshes that a debug view draws, or that a [full shader](../guides/custom-shaders.md#full-shaders) of the sketch's draws. Neither has a skinning build of its vertex shader.
|
|
467
|
+
On WebGPU, a compute pass, the skinning pass, skins two kinds of mesh once per frame instead. It runs before the shadow passes and the scene passes. The first kind is morphed meshes, which it morphs first. The second is meshes that a debug view draws, or that a [full shader](../guides/custom-shaders.md#full-shaders) of the sketch's draws. Neither has a skinning build of its vertex shader.
|
|
468
|
+
|
|
469
|
+
The passes then draw the skinned vertices as a plain mesh. Each mesh that the pass skins draws on its own, as it has vertices of its own. The pass skips a mesh that no view draws in a frame, neither the camera nor a shadow cascade. It also skips a mesh whose pose and morph weights did not change since its last skin.
|
|
470
|
+
|
|
471
|
+
The `?skinning=compute` switch makes the pass skin every skinned mesh, to compare the two ways ([Testing](../guides/testing.md#switches-for-tests)).
|
|
423
472
|
|
|
424
473
|
A skinned mesh culls with a sphere that its pose moves. The engine keeps a sphere for each joint around the vertices it moves. Each frame it moves those spheres with the pose and takes the sphere around them all. So a limb that swings out never leaves the mesh's bounds. The work is one matrix product per joint, however many vertices the mesh has. Skinned meshes cast and receive shadows that follow their poses.
|
|
425
474
|
|
|
426
475
|
## Crowds
|
|
427
476
|
|
|
428
|
-
A crowd of copies of one model draws in one instanced draw per part. Its cost is the work of its animation and its vertices.
|
|
477
|
+
A crowd of copies of one model draws in one instanced draw per part. Its cost is the work of its animation and its vertices. The [battle comparison](https://github.com/null3d-engine/null3d/tree/main/examples/compare/battle) draws hundreds of animated soldiers and mechs.
|
|
478
|
+
|
|
479
|
+
`animator.setUpdateInterval(frames)` sets the frames between two updates of one character's pose. The value 1, the default, updates it in every frame. A larger number, up to 64, samples and composes it once every that many frames. It holds the last pose in between. `animator.updateInterval` reads the value back.
|
|
429
480
|
|
|
430
481
|
Give a character the camera sees from far more frames between its updates. Hold the ones near the camera at 1, so they never step. The `farAnimationInterval` quality setting, which the [governor](quality.md#the-frame-budget-governor) may raise, gives the interval for far characters:
|
|
431
482
|
|
|
@@ -439,11 +490,15 @@ return {
|
|
|
439
490
|
};
|
|
440
491
|
```
|
|
441
492
|
|
|
442
|
-
The clips keep their real speed. Each update covers the frames that it skipped, so a slower rate does not slow a character down. Its pose holds between updates, so a far character steps a little. Its events reach your handlers on its next update, up to `frames` frames late.
|
|
493
|
+
The clips keep their real speed. Each update covers the frames that it skipped, so a slower rate does not slow a character down. Its pose holds between updates, so a far character steps a little. Its events reach your handlers on its next update, up to `frames` frames late.
|
|
494
|
+
|
|
495
|
+
A scene that never calls `setUpdateInterval` updates every character in every frame. A character that stands still is posed again in every frame at 1. At 1 it costs the job workers as much as a moving one. What it saves is the upload of the joint matrices: no frame repeats it while no pose changes.
|
|
496
|
+
|
|
497
|
+
Its skinning work also stays, because the vertex shader of each pass that draws it skins it again, shadows included. Only a mesh that the skinning pass skins skips a pose that did not change. Those are morphed meshes, and meshes that a debug view or a full shader of the sketch draws ([Limits of skinning](#limits-of-skinning)).
|
|
443
498
|
|
|
444
499
|
### Limits of skinning
|
|
445
500
|
|
|
446
|
-
- On WebGPU, each copy that the skinning pass skins or morphs keeps its skinned vertices in GPU memory, even when copies share a mesh. Positions take 32-bit floats. Normals and tangents take 8 bits per component, as unit directions, which is as precise as the asset tool's optimized meshes store them. The other attributes keep their types. With `?skinning=compute`, a knight of the S5 benchmark takes 20 bytes per vertex, so its 500 knights of about 5,000 vertices take about 50 MB.
|
|
501
|
+
- On WebGPU, each copy that the skinning pass skins or morphs keeps its skinned vertices in GPU memory, even when copies share a mesh. Positions take 32-bit floats. Normals and tangents take 8 bits per component, as unit directions, which is as precise as the asset tool's optimized meshes store them. The other attributes keep their types. With `?skinning=compute`, a knight of the [S5 benchmark](../porting/threejs-overview.md#what-gets-faster) takes 20 bytes per vertex, so its 500 knights of about 5,000 vertices take about 50 MB.
|
|
447
502
|
- Those vertices fill at most 8 GPU buffers, each as large as the device lets a shader read. That is 1 GiB in all at WebGPU's default limit of 128 MiB per buffer.
|
|
448
503
|
- Skinned meshes fill at most 32 mesh buffers. Each mesh buffer holds meshes with one set of vertex attributes, up to that same size.
|
|
449
504
|
- A scene past either limit draws nothing in its frames, and gives [E1501](../errors/E1501.md), which names the limit. The canvas keeps the last whole frame, and the scene draws again once it fits.
|
|
@@ -452,7 +507,15 @@ The clips keep their real speed. Each update covers the frames that it skipped,
|
|
|
452
507
|
|
|
453
508
|
## Morph targets
|
|
454
509
|
|
|
455
|
-
A morph target is another shape of a mesh, such as a smile or a blink. Each object of a mesh with targets blends them in by its own weights. A weight of 0 leaves a target out, 1 adds all of it, and other numbers scale it. The
|
|
510
|
+
A morph target is another shape of a mesh, such as a smile or a blink. Each object of a mesh with targets blends them in by its own weights. A weight of 0 leaves a target out, 1 adds all of it, and other numbers scale it. The [morph targets demo](https://github.com/null3d-engine/null3d/tree/main/examples/morph-flowers) opens a bed of tulips in a wave.
|
|
511
|
+
|
|
512
|
+

|
|
513
|
+
|
|
514
|
+
One morph target per tulip head. The targets are made in code, not loaded from a file.
|
|
515
|
+
|
|
516
|
+
The call `setMorphWeight` sets a weight by the target's number or name. The call `getMorphWeight` reads it back. The mesh geometry's `morphTargetNames` lists the names in target order, such as `prefab.find('Face')?.mesh?.morphTargetNames`.
|
|
517
|
+
|
|
518
|
+
A target can move positions, normals and tangents, and change vertex colors, as a glTF file's `COLOR_0` targets do. A morphed vertex color stays between 0 and 1, as the glTF specification asks. A target that leaves out `COLOR_0` while another target of the mesh has it changes no color. A mesh from a glTF file has the file's targets and default weights. A mesh that you build takes its targets from `morphTargets` in [geometry.fromArrays](geometry.md#morph-targets).
|
|
456
519
|
|
|
457
520
|
```ts
|
|
458
521
|
const head = scene.instantiate(face).find('Head') as Mesh;
|
|
@@ -462,7 +525,14 @@ head.setMorphWeight(1, Math.sin(time.now) * 0.5 + 0.5);
|
|
|
462
525
|
|
|
463
526
|
A clip of a glTF file can animate a mesh's weights. While it plays, it blends its weights with the object's own. A clip at full weight sets the weights, and a fade blends the two. The object's own weights hold when no clip animates them. The call `setMorphWeight` sets the object's own weight, so a weight that you set shows in full only where no clip animates it. Layers and joint masks work on weights too: a layer masked to a node's name takes that node's weights.
|
|
464
527
|
|
|
465
|
-
On WebGPU, the skinning pass morphs each morphed mesh once per frame, before its joints skin it. On WebGL2, the vertex shader of each pass morphs it.
|
|
528
|
+
On WebGPU, the skinning pass morphs each morphed mesh once per frame, before its joints skin it. On WebGL2, the vertex shader of each pass morphs it.
|
|
529
|
+
|
|
530
|
+
<details>
|
|
531
|
+
<summary>Technical details: how each backend morphs</summary>
|
|
532
|
+
|
|
533
|
+
Each object then keeps only the weights farthest from 0, by the `morphTargets` quality setting: 8 on Low, 16 on Medium, 32 on High and 64 on Ultra. WebGPU keeps every weight. The first morphed mesh that a WebGL2 page draws loads the morph shaders, about 20 KB after compression, and draws once they arrive. On WebGPU, it loads the skinning pass's shaders. `createEngine`'s `preload` option loads either before the first frame ([Loading screens](../guides/loading-screens.md#loading-everything-up-front)).
|
|
534
|
+
|
|
535
|
+
</details>
|
|
466
536
|
|
|
467
537
|
A morphed object culls with a sphere that its weights grow: each target's longest move times the size of its weight. On WebGL2, a custom material draws a morphed mesh in its shape at rest.
|
|
468
538
|
|
|
@@ -487,6 +557,8 @@ The engine takes animation off the main thread, and does less work and stores le
|
|
|
487
557
|
| [E1101](../errors/E1101.md) | An animator call after its object was destroyed |
|
|
488
558
|
| [E1501](../errors/E1501.md) | A crowd of skinned meshes past WebGPU skinning's limits (see [Limits of skinning](#limits-of-skinning)) |
|
|
489
559
|
|
|
560
|
+
Development builds run every check in this table. Release builds keep only the checks that guard engine memory, such as a clip name that the object does not have, and skip the rest, such as range checks and `setWeight` on a clip that does not play.
|
|
561
|
+
|
|
490
562
|
## API reference
|
|
491
563
|
|
|
492
564
|
[The API reference](reference/animation.md) lists every export of this page with its type and description. The engine's doc comments make it.
|