@vgai/engine 0.5.0 → 0.5.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/package.json +1 -1
- package/schemas/engine-capabilities.json +4 -4
- package/schemas/vgai-game.schema.json +2 -2
- package/src/adapter/authoring.ts +42 -0
- package/src/adapter/index.ts +3 -0
- package/src/adapter/ingest/overlay-apply.ts +50 -6
- package/src/adapter/ingest/scene-capture.ts +51 -2
- package/src/adapter/vgai-scene-game-adapter.ts +24 -0
- package/src/manifest/schema.ts +7 -3
- package/src/runtime/create-runtime.ts +97 -0
- package/src/runtime/game.ts +11 -1
- package/src/scene/asset-ref-check.ts +1 -1
- package/src/scene/scene-loader.ts +2 -2
- package/src/scene/user-data.ts +18 -0
- package/src/world3d-react/behavior.tsx +19 -11
- package/src/world3d-react/r3f-adapter.tsx +8 -0
- package/dist/adapter/adapter-surface.d.ts +0 -30
- package/dist/adapter/adapter-surface.d.ts.map +0 -1
- package/dist/adapter/adapter-surface.js +0 -18
- package/dist/adapter/authoring.d.ts +0 -461
- package/dist/adapter/authoring.d.ts.map +0 -1
- package/dist/adapter/authoring.js +0 -22
- package/dist/adapter/colyseus-networking-adapter.d.ts +0 -43
- package/dist/adapter/colyseus-networking-adapter.d.ts.map +0 -1
- package/dist/adapter/colyseus-networking-adapter.js +0 -38
- package/dist/adapter/first-party-systems.d.ts +0 -38
- package/dist/adapter/first-party-systems.d.ts.map +0 -1
- package/dist/adapter/first-party-systems.js +0 -77
- package/dist/adapter/game-adapter.d.ts +0 -133
- package/dist/adapter/game-adapter.d.ts.map +0 -1
- package/dist/adapter/game-adapter.js +0 -10
- package/dist/adapter/host-context.d.ts +0 -71
- package/dist/adapter/host-context.d.ts.map +0 -1
- package/dist/adapter/host-context.js +0 -16
- package/dist/adapter/index.d.ts +0 -22
- package/dist/adapter/index.d.ts.map +0 -1
- package/dist/adapter/index.js +0 -15
- package/dist/adapter/ingest/game-contract.d.ts +0 -53
- package/dist/adapter/ingest/game-contract.d.ts.map +0 -1
- package/dist/adapter/ingest/game-contract.js +0 -30
- package/dist/adapter/ingest/overlay-applier.d.ts +0 -118
- package/dist/adapter/ingest/overlay-applier.d.ts.map +0 -1
- package/dist/adapter/ingest/overlay-applier.js +0 -132
- package/dist/adapter/ingest/overlay-apply.d.ts +0 -60
- package/dist/adapter/ingest/overlay-apply.d.ts.map +0 -1
- package/dist/adapter/ingest/overlay-apply.js +0 -101
- package/dist/adapter/ingest/overlay-file.d.ts +0 -79
- package/dist/adapter/ingest/overlay-file.d.ts.map +0 -1
- package/dist/adapter/ingest/overlay-file.js +0 -66
- package/dist/adapter/ingest/overlay-report.d.ts +0 -113
- package/dist/adapter/ingest/overlay-report.d.ts.map +0 -1
- package/dist/adapter/ingest/overlay-report.js +0 -103
- package/dist/adapter/ingest/scene-capture.d.ts +0 -97
- package/dist/adapter/ingest/scene-capture.d.ts.map +0 -1
- package/dist/adapter/ingest/scene-capture.js +0 -248
- package/dist/adapter/ingest/upstream-pin.d.ts +0 -47
- package/dist/adapter/ingest/upstream-pin.d.ts.map +0 -1
- package/dist/adapter/ingest/upstream-pin.js +0 -50
- package/dist/adapter/loop-gate-report.d.ts +0 -34
- package/dist/adapter/loop-gate-report.d.ts.map +0 -1
- package/dist/adapter/loop-gate-report.js +0 -37
- package/dist/adapter/rapier-physics-adapter.d.ts +0 -12
- package/dist/adapter/rapier-physics-adapter.d.ts.map +0 -1
- package/dist/adapter/rapier-physics-adapter.js +0 -46
- package/dist/adapter/system-adapter.d.ts +0 -206
- package/dist/adapter/system-adapter.d.ts.map +0 -1
- package/dist/adapter/system-adapter.js +0 -13
- package/dist/adapter/transform.d.ts +0 -18
- package/dist/adapter/transform.d.ts.map +0 -1
- package/dist/adapter/transform.js +0 -1
- package/dist/adapter/vgai-scene-game-adapter.d.ts +0 -108
- package/dist/adapter/vgai-scene-game-adapter.d.ts.map +0 -1
- package/dist/adapter/vgai-scene-game-adapter.js +0 -762
- package/dist/ai/navigation.d.ts +0 -64
- package/dist/ai/navigation.d.ts.map +0 -1
- package/dist/ai/navigation.js +0 -133
- package/dist/animation/anim-graph-types.d.ts +0 -25
- package/dist/animation/anim-graph-types.d.ts.map +0 -1
- package/dist/animation/anim-graph-types.js +0 -1
- package/dist/animation/animation-clock.d.ts +0 -213
- package/dist/animation/animation-clock.d.ts.map +0 -1
- package/dist/animation/animation-clock.js +0 -301
- package/dist/animation/blend-node.d.ts +0 -22
- package/dist/animation/blend-node.d.ts.map +0 -1
- package/dist/animation/blend-node.js +0 -97
- package/dist/animation/camera-ownership.d.ts +0 -250
- package/dist/animation/camera-ownership.d.ts.map +0 -1
- package/dist/animation/camera-ownership.js +0 -169
- package/dist/animation/cinematic-cues.d.ts +0 -200
- package/dist/animation/cinematic-cues.d.ts.map +0 -1
- package/dist/animation/cinematic-cues.js +0 -213
- package/dist/animation/clip-map.d.ts +0 -12
- package/dist/animation/clip-map.d.ts.map +0 -1
- package/dist/animation/clip-map.js +0 -37
- package/dist/animation/gsap-registration.d.ts +0 -119
- package/dist/animation/gsap-registration.d.ts.map +0 -1
- package/dist/animation/gsap-registration.js +0 -92
- package/dist/animation/theatre-clock-binding.d.ts +0 -89
- package/dist/animation/theatre-clock-binding.d.ts.map +0 -1
- package/dist/animation/theatre-clock-binding.js +0 -29
- package/dist/animation/theatre-director.d.ts +0 -242
- package/dist/animation/theatre-director.d.ts.map +0 -1
- package/dist/animation/theatre-director.js +0 -235
- package/dist/animation/theatre-object-binding.d.ts +0 -305
- package/dist/animation/theatre-object-binding.d.ts.map +0 -1
- package/dist/animation/theatre-object-binding.js +0 -351
- package/dist/animation/xstate-animation-binding.d.ts +0 -56
- package/dist/animation/xstate-animation-binding.d.ts.map +0 -1
- package/dist/animation/xstate-animation-binding.js +0 -331
- package/dist/animation/xstate-animation-meta.d.ts +0 -266
- package/dist/animation/xstate-animation-meta.d.ts.map +0 -1
- package/dist/animation/xstate-animation-meta.js +0 -252
- package/dist/assets.d.ts +0 -26
- package/dist/assets.d.ts.map +0 -1
- package/dist/assets.js +0 -55
- package/dist/audio/index.d.ts +0 -4
- package/dist/audio/index.d.ts.map +0 -1
- package/dist/audio/index.js +0 -24
- package/dist/audio/tone-clock-binding.d.ts +0 -75
- package/dist/audio/tone-clock-binding.d.ts.map +0 -1
- package/dist/audio/tone-clock-binding.js +0 -29
- package/dist/audio/tone-context.d.ts +0 -114
- package/dist/audio/tone-context.d.ts.map +0 -1
- package/dist/audio/tone-context.js +0 -39
- package/dist/audio/tone-offline-render.d.ts +0 -90
- package/dist/audio/tone-offline-render.d.ts.map +0 -1
- package/dist/audio/tone-offline-render.js +0 -56
- package/dist/audio/wav-encode.d.ts +0 -38
- package/dist/audio/wav-encode.d.ts.map +0 -1
- package/dist/audio/wav-encode.js +0 -97
- package/dist/character/cloth-sim.d.ts +0 -179
- package/dist/character/cloth-sim.d.ts.map +0 -1
- package/dist/character/cloth-sim.js +0 -334
- package/dist/character/spring-chain.d.ts +0 -135
- package/dist/character/spring-chain.d.ts.map +0 -1
- package/dist/character/spring-chain.js +0 -165
- package/dist/core/game-loop.d.ts +0 -42
- package/dist/core/game-loop.d.ts.map +0 -1
- package/dist/core/game-loop.js +0 -167
- package/dist/core/seeded-random.d.ts +0 -69
- package/dist/core/seeded-random.d.ts.map +0 -1
- package/dist/core/seeded-random.js +0 -121
- package/dist/core/system-runner.d.ts +0 -120
- package/dist/core/system-runner.d.ts.map +0 -1
- package/dist/core/system-runner.js +0 -297
- package/dist/core/types.d.ts +0 -92
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js +0 -25
- package/dist/data/data-asset.d.ts +0 -101
- package/dist/data/data-asset.d.ts.map +0 -1
- package/dist/data/data-asset.js +0 -122
- package/dist/data/data-check-core.d.ts +0 -110
- package/dist/data/data-check-core.d.ts.map +0 -1
- package/dist/data/data-check-core.js +0 -178
- package/dist/data/data-ref.d.ts +0 -79
- package/dist/data/data-ref.d.ts.map +0 -1
- package/dist/data/data-ref.js +0 -130
- package/dist/data/vite-plugin-data.d.ts +0 -79
- package/dist/data/vite-plugin-data.d.ts.map +0 -1
- package/dist/data/vite-plugin-data.js +0 -217
- package/dist/dev/console-bridge.d.ts +0 -22
- package/dist/dev/console-bridge.d.ts.map +0 -1
- package/dist/dev/console-bridge.js +0 -71
- package/dist/dev/debug-draw.d.ts +0 -24
- package/dist/dev/debug-draw.d.ts.map +0 -1
- package/dist/dev/debug-draw.js +0 -73
- package/dist/dev/logger.d.ts +0 -30
- package/dist/dev/logger.d.ts.map +0 -1
- package/dist/dev/logger.js +0 -90
- package/dist/dev/performance-profiler.d.ts +0 -60
- package/dist/dev/performance-profiler.d.ts.map +0 -1
- package/dist/dev/performance-profiler.js +0 -181
- package/dist/dev/webgl-gpu-timer.d.ts +0 -8
- package/dist/dev/webgl-gpu-timer.d.ts.map +0 -1
- package/dist/dev/webgl-gpu-timer.js +0 -52
- package/dist/ecs/component-manager.d.ts +0 -205
- package/dist/ecs/component-manager.d.ts.map +0 -1
- package/dist/ecs/component-manager.js +0 -706
- package/dist/ecs/game-component.d.ts +0 -146
- package/dist/ecs/game-component.d.ts.map +0 -1
- package/dist/ecs/game-component.js +0 -141
- package/dist/ecs/hmr-swap-report.d.ts +0 -53
- package/dist/ecs/hmr-swap-report.d.ts.map +0 -1
- package/dist/ecs/hmr-swap-report.js +0 -55
- package/dist/humanoid/bake.operation.d.ts +0 -119
- package/dist/humanoid/bake.operation.d.ts.map +0 -1
- package/dist/humanoid/bake.operation.js +0 -228
- package/dist/humanoid/body.d.ts +0 -101
- package/dist/humanoid/body.d.ts.map +0 -1
- package/dist/humanoid/body.js +0 -530
- package/dist/humanoid/clips.d.ts +0 -62
- package/dist/humanoid/clips.d.ts.map +0 -1
- package/dist/humanoid/clips.js +0 -121
- package/dist/humanoid/compose.d.ts +0 -75
- package/dist/humanoid/compose.d.ts.map +0 -1
- package/dist/humanoid/compose.js +0 -176
- package/dist/humanoid/generate.d.ts +0 -92
- package/dist/humanoid/generate.d.ts.map +0 -1
- package/dist/humanoid/generate.js +0 -124
- package/dist/humanoid/index.d.ts +0 -24
- package/dist/humanoid/index.d.ts.map +0 -1
- package/dist/humanoid/index.js +0 -18
- package/dist/humanoid/schema.d.ts +0 -35
- package/dist/humanoid/schema.d.ts.map +0 -1
- package/dist/humanoid/schema.js +0 -87
- package/dist/humanoid/skeleton.d.ts +0 -103
- package/dist/humanoid/skeleton.d.ts.map +0 -1
- package/dist/humanoid/skeleton.js +0 -289
- package/dist/index.d.ts +0 -37
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -30
- package/dist/input/input-manager.d.ts +0 -945
- package/dist/input/input-manager.d.ts.map +0 -1
- package/dist/input/input-manager.js +0 -2207
- package/dist/input/input-types.d.ts +0 -174
- package/dist/input/input-types.d.ts.map +0 -1
- package/dist/input/input-types.js +0 -1
- package/dist/input/prompt-labels.d.ts +0 -21
- package/dist/input/prompt-labels.d.ts.map +0 -1
- package/dist/input/prompt-labels.js +0 -121
- package/dist/input/rebind-controller.d.ts +0 -59
- package/dist/input/rebind-controller.d.ts.map +0 -1
- package/dist/input/rebind-controller.js +0 -85
- package/dist/input/schema.d.ts +0 -16
- package/dist/input/schema.d.ts.map +0 -1
- package/dist/input/schema.js +0 -228
- package/dist/loader.d.ts +0 -43
- package/dist/loader.d.ts.map +0 -1
- package/dist/loader.js +0 -59
- package/dist/manifest/index.d.ts +0 -5
- package/dist/manifest/index.d.ts.map +0 -1
- package/dist/manifest/index.js +0 -8
- package/dist/manifest/load-file.d.ts +0 -4
- package/dist/manifest/load-file.d.ts.map +0 -1
- package/dist/manifest/load-file.js +0 -14
- package/dist/manifest/load.d.ts +0 -144
- package/dist/manifest/load.d.ts.map +0 -1
- package/dist/manifest/load.js +0 -273
- package/dist/manifest/schema.d.ts +0 -230
- package/dist/manifest/schema.d.ts.map +0 -1
- package/dist/manifest/schema.js +0 -394
- package/dist/physics/collision-system.d.ts +0 -41
- package/dist/physics/collision-system.d.ts.map +0 -1
- package/dist/physics/collision-system.js +0 -64
- package/dist/physics/physics-registry.d.ts +0 -45
- package/dist/physics/physics-registry.d.ts.map +0 -1
- package/dist/physics/physics-registry.js +0 -65
- package/dist/physics/transform-writer.d.ts +0 -16
- package/dist/physics/transform-writer.d.ts.map +0 -1
- package/dist/physics/transform-writer.js +0 -38
- package/dist/physics/trigger-dispatch.d.ts +0 -24
- package/dist/physics/trigger-dispatch.d.ts.map +0 -1
- package/dist/physics/trigger-dispatch.js +0 -80
- package/dist/react/game-state.d.ts +0 -156
- package/dist/react/game-state.d.ts.map +0 -1
- package/dist/react/game-state.js +0 -222
- package/dist/react/root-adapter.d.ts +0 -11
- package/dist/react/root-adapter.d.ts.map +0 -1
- package/dist/react/root-adapter.js +0 -41
- package/dist/react/unmanaged-root-detector.d.ts +0 -12
- package/dist/react/unmanaged-root-detector.d.ts.map +0 -1
- package/dist/react/unmanaged-root-detector.js +0 -45
- package/dist/react/use-data.d.ts +0 -60
- package/dist/react/use-data.d.ts.map +0 -1
- package/dist/react/use-data.js +0 -101
- package/dist/react/use-selection.d.ts +0 -75
- package/dist/react/use-selection.d.ts.map +0 -1
- package/dist/react/use-selection.js +0 -90
- package/dist/render/auto-batcher.d.ts +0 -34
- package/dist/render/auto-batcher.d.ts.map +0 -1
- package/dist/render/auto-batcher.js +0 -140
- package/dist/render/render-batch-system.d.ts +0 -33
- package/dist/render/render-batch-system.d.ts.map +0 -1
- package/dist/render/render-batch-system.js +0 -230
- package/dist/render/render-features.d.ts +0 -47
- package/dist/render/render-features.d.ts.map +0 -1
- package/dist/render/render-features.js +0 -105
- package/dist/render/render-settings.d.ts +0 -36
- package/dist/render/render-settings.d.ts.map +0 -1
- package/dist/render/render-settings.js +0 -51
- package/dist/runtime/create-runtime.d.ts +0 -249
- package/dist/runtime/create-runtime.d.ts.map +0 -1
- package/dist/runtime/create-runtime.js +0 -641
- package/dist/runtime/debug-bridge.d.ts +0 -257
- package/dist/runtime/debug-bridge.d.ts.map +0 -1
- package/dist/runtime/debug-bridge.js +0 -224
- package/dist/runtime/debug-registry.d.ts +0 -288
- package/dist/runtime/debug-registry.d.ts.map +0 -1
- package/dist/runtime/debug-registry.js +0 -513
- package/dist/runtime/frame-selector-cache.d.ts +0 -41
- package/dist/runtime/frame-selector-cache.d.ts.map +0 -1
- package/dist/runtime/frame-selector-cache.js +0 -65
- package/dist/runtime/game.d.ts +0 -496
- package/dist/runtime/game.d.ts.map +0 -1
- package/dist/runtime/game.js +0 -741
- package/dist/runtime/gameplay-rng-trap.d.ts +0 -48
- package/dist/runtime/gameplay-rng-trap.d.ts.map +0 -1
- package/dist/runtime/gameplay-rng-trap.js +0 -96
- package/dist/runtime/input-router.d.ts +0 -78
- package/dist/runtime/input-router.d.ts.map +0 -1
- package/dist/runtime/input-router.js +0 -171
- package/dist/runtime/mount-game.d.ts +0 -129
- package/dist/runtime/mount-game.d.ts.map +0 -1
- package/dist/runtime/mount-game.js +0 -152
- package/dist/runtime/mount-manifest.d.ts +0 -173
- package/dist/runtime/mount-manifest.d.ts.map +0 -1
- package/dist/runtime/mount-manifest.js +0 -297
- package/dist/runtime/render-audio-control.d.ts +0 -110
- package/dist/runtime/render-audio-control.d.ts.map +0 -1
- package/dist/runtime/render-audio-control.js +0 -111
- package/dist/runtime/render-control.d.ts +0 -291
- package/dist/runtime/render-control.d.ts.map +0 -1
- package/dist/runtime/render-control.js +0 -264
- package/dist/runtime/render-seed.d.ts +0 -57
- package/dist/runtime/render-seed.d.ts.map +0 -1
- package/dist/runtime/render-seed.js +0 -74
- package/dist/runtime/state-bridge.d.ts +0 -61
- package/dist/runtime/state-bridge.d.ts.map +0 -1
- package/dist/runtime/state-bridge.js +0 -63
- package/dist/runtime/types.d.ts +0 -253
- package/dist/runtime/types.d.ts.map +0 -1
- package/dist/runtime/types.js +0 -1
- package/dist/scene/asset-loaders.d.ts +0 -79
- package/dist/scene/asset-loaders.d.ts.map +0 -1
- package/dist/scene/asset-loaders.js +0 -141
- package/dist/scene/asset-paths.d.ts +0 -11
- package/dist/scene/asset-paths.d.ts.map +0 -1
- package/dist/scene/asset-paths.js +0 -108
- package/dist/scene/asset-ref-check.d.ts +0 -88
- package/dist/scene/asset-ref-check.d.ts.map +0 -1
- package/dist/scene/asset-ref-check.js +0 -214
- package/dist/scene/asset-registry.d.ts +0 -38
- package/dist/scene/asset-registry.d.ts.map +0 -1
- package/dist/scene/asset-registry.js +0 -66
- package/dist/scene/collider-dimensions.d.ts +0 -63
- package/dist/scene/collider-dimensions.d.ts.map +0 -1
- package/dist/scene/collider-dimensions.js +0 -98
- package/dist/scene/component-registry.d.ts +0 -22
- package/dist/scene/component-registry.d.ts.map +0 -1
- package/dist/scene/component-registry.js +0 -37
- package/dist/scene/defaults.d.ts +0 -252
- package/dist/scene/defaults.d.ts.map +0 -1
- package/dist/scene/defaults.js +0 -151
- package/dist/scene/geometries/index.d.ts +0 -8
- package/dist/scene/geometries/index.d.ts.map +0 -1
- package/dist/scene/geometries/index.js +0 -7
- package/dist/scene/geometries/terrain.d.ts +0 -2
- package/dist/scene/geometries/terrain.d.ts.map +0 -1
- package/dist/scene/geometries/terrain.js +0 -37
- package/dist/scene/geometry-registry.d.ts +0 -24
- package/dist/scene/geometry-registry.d.ts.map +0 -1
- package/dist/scene/geometry-registry.js +0 -20
- package/dist/scene/instance-registry.d.ts +0 -36
- package/dist/scene/instance-registry.d.ts.map +0 -1
- package/dist/scene/instance-registry.js +0 -55
- package/dist/scene/instancers/grid.d.ts +0 -2
- package/dist/scene/instancers/grid.d.ts.map +0 -1
- package/dist/scene/instancers/grid.js +0 -36
- package/dist/scene/instancers/index.d.ts +0 -8
- package/dist/scene/instancers/index.d.ts.map +0 -1
- package/dist/scene/instancers/index.js +0 -7
- package/dist/scene/light-camera-factory.d.ts +0 -23
- package/dist/scene/light-camera-factory.d.ts.map +0 -1
- package/dist/scene/light-camera-factory.js +0 -68
- package/dist/scene/material-factory.d.ts +0 -17
- package/dist/scene/material-factory.d.ts.map +0 -1
- package/dist/scene/material-factory.js +0 -197
- package/dist/scene/material-registry.d.ts +0 -40
- package/dist/scene/material-registry.d.ts.map +0 -1
- package/dist/scene/material-registry.js +0 -44
- package/dist/scene/materials/index.d.ts +0 -8
- package/dist/scene/materials/index.d.ts.map +0 -1
- package/dist/scene/materials/index.js +0 -7
- package/dist/scene/materials/water.d.ts +0 -2
- package/dist/scene/materials/water.d.ts.map +0 -1
- package/dist/scene/materials/water.js +0 -54
- package/dist/scene/parse.d.ts +0 -23
- package/dist/scene/parse.d.ts.map +0 -1
- package/dist/scene/parse.js +0 -179
- package/dist/scene/particles-factory.d.ts +0 -33
- package/dist/scene/particles-factory.d.ts.map +0 -1
- package/dist/scene/particles-factory.js +0 -282
- package/dist/scene/scene-apply.d.ts +0 -109
- package/dist/scene/scene-apply.d.ts.map +0 -1
- package/dist/scene/scene-apply.js +0 -370
- package/dist/scene/scene-diff-schema.d.ts +0 -285
- package/dist/scene/scene-diff-schema.d.ts.map +0 -1
- package/dist/scene/scene-diff-schema.js +0 -92
- package/dist/scene/scene-diff-types.d.ts +0 -40
- package/dist/scene/scene-diff-types.d.ts.map +0 -1
- package/dist/scene/scene-diff-types.js +0 -14
- package/dist/scene/scene-loader.d.ts +0 -167
- package/dist/scene/scene-loader.d.ts.map +0 -1
- package/dist/scene/scene-loader.js +0 -1211
- package/dist/scene/scene-query.d.ts +0 -11
- package/dist/scene/scene-query.d.ts.map +0 -1
- package/dist/scene/scene-query.js +0 -63
- package/dist/scene/scene-types.d.ts +0 -10
- package/dist/scene/scene-types.d.ts.map +0 -1
- package/dist/scene/scene-types.js +0 -8
- package/dist/scene/scene-version.d.ts +0 -26
- package/dist/scene/scene-version.d.ts.map +0 -1
- package/dist/scene/scene-version.js +0 -34
- package/dist/scene/schema/animation.d.ts +0 -8
- package/dist/scene/schema/animation.d.ts.map +0 -1
- package/dist/scene/schema/animation.js +0 -42
- package/dist/scene/schema/audio.d.ts +0 -13
- package/dist/scene/schema/audio.d.ts.map +0 -1
- package/dist/scene/schema/audio.js +0 -22
- package/dist/scene/schema/camera.d.ts +0 -28
- package/dist/scene/schema/camera.d.ts.map +0 -1
- package/dist/scene/schema/camera.js +0 -17
- package/dist/scene/schema/collider.d.ts +0 -40
- package/dist/scene/schema/collider.d.ts.map +0 -1
- package/dist/scene/schema/collider.js +0 -55
- package/dist/scene/schema/entity-ref.d.ts +0 -31
- package/dist/scene/schema/entity-ref.d.ts.map +0 -1
- package/dist/scene/schema/entity-ref.js +0 -61
- package/dist/scene/schema/entity.d.ts +0 -1036
- package/dist/scene/schema/entity.d.ts.map +0 -1
- package/dist/scene/schema/entity.js +0 -153
- package/dist/scene/schema/environment.d.ts +0 -425
- package/dist/scene/schema/environment.d.ts.map +0 -1
- package/dist/scene/schema/environment.js +0 -357
- package/dist/scene/schema/index.d.ts +0 -37
- package/dist/scene/schema/index.d.ts.map +0 -1
- package/dist/scene/schema/index.js +0 -19
- package/dist/scene/schema/instances.d.ts +0 -14
- package/dist/scene/schema/instances.d.ts.map +0 -1
- package/dist/scene/schema/instances.js +0 -28
- package/dist/scene/schema/joint.d.ts +0 -23
- package/dist/scene/schema/joint.d.ts.map +0 -1
- package/dist/scene/schema/joint.js +0 -23
- package/dist/scene/schema/light.d.ts +0 -38
- package/dist/scene/schema/light.d.ts.map +0 -1
- package/dist/scene/schema/light.js +0 -26
- package/dist/scene/schema/material.d.ts +0 -199
- package/dist/scene/schema/material.d.ts.map +0 -1
- package/dist/scene/schema/material.js +0 -103
- package/dist/scene/schema/mesh.d.ts +0 -48
- package/dist/scene/schema/mesh.d.ts.map +0 -1
- package/dist/scene/schema/mesh.js +0 -82
- package/dist/scene/schema/particles.d.ts +0 -2178
- package/dist/scene/schema/particles.d.ts.map +0 -1
- package/dist/scene/schema/particles.js +0 -321
- package/dist/scene/schema/physics.d.ts +0 -56
- package/dist/scene/schema/physics.d.ts.map +0 -1
- package/dist/scene/schema/physics.js +0 -37
- package/dist/scene/schema/scene-file.d.ts +0 -303
- package/dist/scene/schema/scene-file.d.ts.map +0 -1
- package/dist/scene/schema/scene-file.js +0 -256
- package/dist/scene/schema/shadow.d.ts +0 -28
- package/dist/scene/schema/shadow.d.ts.map +0 -1
- package/dist/scene/schema/shadow.js +0 -20
- package/dist/scene/schema/spline.d.ts +0 -25
- package/dist/scene/schema/spline.d.ts.map +0 -1
- package/dist/scene/schema/spline.js +0 -15
- package/dist/scene/schema/tuples.d.ts +0 -12
- package/dist/scene/schema/tuples.d.ts.map +0 -1
- package/dist/scene/schema/tuples.js +0 -14
- package/dist/scene/user-data.d.ts +0 -185
- package/dist/scene/user-data.d.ts.map +0 -1
- package/dist/scene/user-data.js +0 -144
- package/dist/setup/setup-audio.d.ts +0 -20
- package/dist/setup/setup-audio.d.ts.map +0 -1
- package/dist/setup/setup-audio.js +0 -41
- package/dist/setup/setup-particles.d.ts +0 -17
- package/dist/setup/setup-particles.d.ts.map +0 -1
- package/dist/setup/setup-particles.js +0 -16
- package/dist/setup/setup-physics.d.ts +0 -25
- package/dist/setup/setup-physics.d.ts.map +0 -1
- package/dist/setup/setup-physics.js +0 -51
- package/dist/setup/setup-renderer.d.ts +0 -69
- package/dist/setup/setup-renderer.d.ts.map +0 -1
- package/dist/setup/setup-renderer.js +0 -363
- package/dist/tools/define-tool.d.ts +0 -130
- package/dist/tools/define-tool.d.ts.map +0 -1
- package/dist/tools/define-tool.js +0 -96
- package/dist/world2d/authoring-2d.d.ts +0 -80
- package/dist/world2d/authoring-2d.d.ts.map +0 -1
- package/dist/world2d/authoring-2d.js +0 -195
- package/dist/world2d/capture-to-scene2d.d.ts +0 -5
- package/dist/world2d/capture-to-scene2d.d.ts.map +0 -1
- package/dist/world2d/capture-to-scene2d.js +0 -49
- package/dist/world2d/collision-2d.d.ts +0 -52
- package/dist/world2d/collision-2d.d.ts.map +0 -1
- package/dist/world2d/collision-2d.js +0 -70
- package/dist/world2d/components-2d.d.ts +0 -47
- package/dist/world2d/components-2d.d.ts.map +0 -1
- package/dist/world2d/components-2d.js +0 -77
- package/dist/world2d/index.d.ts +0 -34
- package/dist/world2d/index.d.ts.map +0 -1
- package/dist/world2d/index.js +0 -32
- package/dist/world2d/ingest-iframe-2d.d.ts +0 -82
- package/dist/world2d/ingest-iframe-2d.d.ts.map +0 -1
- package/dist/world2d/ingest-iframe-2d.js +0 -166
- package/dist/world2d/ingest2d.d.ts +0 -97
- package/dist/world2d/ingest2d.d.ts.map +0 -1
- package/dist/world2d/ingest2d.js +0 -40
- package/dist/world2d/physics2d-registry.d.ts +0 -24
- package/dist/world2d/physics2d-registry.d.ts.map +0 -1
- package/dist/world2d/physics2d-registry.js +0 -38
- package/dist/world2d/pixi-game-adapter.d.ts +0 -107
- package/dist/world2d/pixi-game-adapter.d.ts.map +0 -1
- package/dist/world2d/pixi-game-adapter.js +0 -210
- package/dist/world2d/pixi-surface.d.ts +0 -39
- package/dist/world2d/pixi-surface.d.ts.map +0 -1
- package/dist/world2d/pixi-surface.js +0 -47
- package/dist/world2d/scene-capture-2d.d.ts +0 -43
- package/dist/world2d/scene-capture-2d.d.ts.map +0 -1
- package/dist/world2d/scene-capture-2d.js +0 -92
- package/dist/world2d/scene2d-loader.d.ts +0 -27
- package/dist/world2d/scene2d-loader.d.ts.map +0 -1
- package/dist/world2d/scene2d-loader.js +0 -275
- package/dist/world2d/schema/entity2d.d.ts +0 -102
- package/dist/world2d/schema/entity2d.d.ts.map +0 -1
- package/dist/world2d/schema/entity2d.js +0 -119
- package/dist/world2d/schema/physics2d.d.ts +0 -46
- package/dist/world2d/schema/physics2d.d.ts.map +0 -1
- package/dist/world2d/schema/physics2d.js +0 -45
- package/dist/world2d/schema/sprite.d.ts +0 -42
- package/dist/world2d/schema/sprite.d.ts.map +0 -1
- package/dist/world2d/schema/sprite.js +0 -63
- package/dist/world2d/schema/tilemap.d.ts +0 -15
- package/dist/world2d/schema/tilemap.d.ts.map +0 -1
- package/dist/world2d/schema/tilemap.js +0 -19
- package/dist/world2d/schema/tuples2d.d.ts +0 -20
- package/dist/world2d/schema/tuples2d.d.ts.map +0 -1
- package/dist/world2d/schema/tuples2d.js +0 -19
- package/dist/world2d/system-adapters-2d.d.ts +0 -16
- package/dist/world2d/system-adapters-2d.d.ts.map +0 -1
- package/dist/world2d/system-adapters-2d.js +0 -37
- package/dist/world2d/transform-writer-2d.d.ts +0 -16
- package/dist/world2d/transform-writer-2d.d.ts.map +0 -1
- package/dist/world2d/transform-writer-2d.js +0 -22
- package/dist/world2d/types.d.ts +0 -59
- package/dist/world2d/types.d.ts.map +0 -1
- package/dist/world2d/types.js +0 -1
package/dist/humanoid/clips.js
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Standard-clip playback for generated humanoids: map Mixamo-named
|
|
3
|
-
* `AnimationClip`s (from any GLB/FBX-derived source) onto the engine's
|
|
4
|
-
* standard skeleton, across naming variants, with the translation-track
|
|
5
|
-
* policy body-type rescaling requires.
|
|
6
|
-
*
|
|
7
|
-
* TRANSLATION-TRACK POLICY (the reviewer-flagged trap, documented choice):
|
|
8
|
-
* humanoid clips carry per-bone `.position` tracks baked for the SOURCE
|
|
9
|
-
* rig's segment lengths — played raw on a rescaled skeleton they snap limb
|
|
10
|
-
* proportions back to the source's. `retargetClipToHumanoid` therefore
|
|
11
|
-
* - DROPS every non-hips `.position` track (bones keep the generated
|
|
12
|
-
* rig's rest translations — segment lengths come from the body params),
|
|
13
|
-
* - KEEPS the hips `.position` track but multiplies it by the rig's
|
|
14
|
-
* `hipsPositionScale` (root motion / bob authored for the reference
|
|
15
|
-
* hip height lands at the generated hip height),
|
|
16
|
-
* - DROPS `.scale` tracks (rest scale is always 1), and
|
|
17
|
-
* - KEEPS every `.quaternion` track verbatim — rotations are
|
|
18
|
-
* proportion-independent, which is the whole point of a shared rest
|
|
19
|
-
* pose. This is the standard humanoid-retarget policy (the alternative,
|
|
20
|
-
* per-bone translation rescale, buys nothing for rigid capsule bodies
|
|
21
|
-
* and reintroduces per-bone coupling).
|
|
22
|
-
*
|
|
23
|
-
* NAME VARIANTS: track node names resolve across the three spellings in the
|
|
24
|
-
* wild — sanitized `mixamorigHips` (what GLTFLoader yields), raw
|
|
25
|
-
* `mixamorig:Hips` / `mixamorig_Hips` (FBX-side exports), and bare `Hips`
|
|
26
|
-
* (renamed rigs). A track whose node cannot be resolved to a standard bone
|
|
27
|
-
* — or whose property is not a bone TRS channel — is collected, and
|
|
28
|
-
* `retargetClipToHumanoid` throws ONE hard error listing every unresolved
|
|
29
|
-
* track (degrade loudly, never a silently-frozen limb).
|
|
30
|
-
*/
|
|
31
|
-
import * as THREE from 'three';
|
|
32
|
-
import { buildClipMap } from '../animation/clip-map';
|
|
33
|
-
import { HUMANOID_HIPS_BONE } from './skeleton';
|
|
34
|
-
/** Resolve a clip-track node name to a canonical bone name, or null. */
|
|
35
|
-
export function resolveHumanoidBoneName(nodeName, bonesByName) {
|
|
36
|
-
if (bonesByName.has(nodeName))
|
|
37
|
-
return nodeName;
|
|
38
|
-
// `mixamorig:Hips` → `mixamorigHips` (what GLTFLoader itself does).
|
|
39
|
-
const sanitized = THREE.PropertyBinding.sanitizeNodeName(nodeName);
|
|
40
|
-
if (bonesByName.has(sanitized))
|
|
41
|
-
return sanitized;
|
|
42
|
-
// `mixamorig_Hips` → `Hips`; bare `Hips` passes through unchanged.
|
|
43
|
-
const bare = sanitized.replace(/^mixamorig_?/i, '');
|
|
44
|
-
const canonical = `mixamorig${bare}`;
|
|
45
|
-
if (bonesByName.has(canonical))
|
|
46
|
-
return canonical;
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
/** Retarget one track: a rebuilt track to keep, 'drop' (by policy), or
|
|
50
|
-
* 'unresolved' (not a standard bone TRS channel). */
|
|
51
|
-
function retargetTrack(track, target) {
|
|
52
|
-
const dot = track.name.lastIndexOf('.');
|
|
53
|
-
if (dot <= 0)
|
|
54
|
-
return 'unresolved';
|
|
55
|
-
const bone = resolveHumanoidBoneName(track.name.slice(0, dot), target.bonesByName);
|
|
56
|
-
if (!bone)
|
|
57
|
-
return 'unresolved';
|
|
58
|
-
const property = track.name.slice(dot + 1);
|
|
59
|
-
if (property === 'quaternion') {
|
|
60
|
-
const kept = track.clone();
|
|
61
|
-
kept.name = `${bone}.quaternion`;
|
|
62
|
-
return kept;
|
|
63
|
-
}
|
|
64
|
-
if (property === 'position') {
|
|
65
|
-
if (bone !== HUMANOID_HIPS_BONE)
|
|
66
|
-
return 'drop'; // policy: rest owns segment lengths
|
|
67
|
-
const kept = track.clone();
|
|
68
|
-
kept.name = `${bone}.position`;
|
|
69
|
-
const s = target.hipsPositionScale;
|
|
70
|
-
if (s !== 1)
|
|
71
|
-
kept.values = kept.values.map((v) => v * s);
|
|
72
|
-
return kept;
|
|
73
|
-
}
|
|
74
|
-
if (property === 'scale')
|
|
75
|
-
return 'drop'; // policy: rest scale is always 1
|
|
76
|
-
// Not a bone TRS channel (morphs etc.) — nothing on a generated humanoid
|
|
77
|
-
// can consume it; loud beats silent.
|
|
78
|
-
return 'unresolved';
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Rebuild `clip` for a generated humanoid: node names canonicalized, the
|
|
82
|
-
* translation policy above applied. The input clip is never mutated. Throws
|
|
83
|
-
* (listing every offender) if any track fails to resolve to a standard bone
|
|
84
|
-
* TRS channel.
|
|
85
|
-
*/
|
|
86
|
-
export function retargetClipToHumanoid(clip, target) {
|
|
87
|
-
const tracks = [];
|
|
88
|
-
const unresolved = [];
|
|
89
|
-
for (const track of clip.tracks) {
|
|
90
|
-
const result = retargetTrack(track, target);
|
|
91
|
-
if (result === 'unresolved')
|
|
92
|
-
unresolved.push(track.name);
|
|
93
|
-
else if (result !== 'drop')
|
|
94
|
-
tracks.push(result);
|
|
95
|
-
}
|
|
96
|
-
if (unresolved.length > 0) {
|
|
97
|
-
throw new Error(`humanoid: clip '${clip.name}' has ${unresolved.length} track(s) that do not resolve ` +
|
|
98
|
-
`to standard humanoid bones: ${unresolved.join(', ')}`);
|
|
99
|
-
}
|
|
100
|
-
return new THREE.AnimationClip(clip.name, clip.duration, tracks, clip.blendMode);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Build a name → clip library from a loaded GLB's `animations` array —
|
|
104
|
-
* `buildClipMap` semantics (exact names, case-insensitive lookup,
|
|
105
|
-
* armature-prefix stripping, `walking`→`walk`-style aliases), plus a
|
|
106
|
-
* loud getter.
|
|
107
|
-
*/
|
|
108
|
-
export function createHumanoidClipLibrary(animations, aliases = {}) {
|
|
109
|
-
const map = buildClipMap(animations, aliases);
|
|
110
|
-
return {
|
|
111
|
-
clips: map,
|
|
112
|
-
get(name) {
|
|
113
|
-
const clip = map.get(name) ?? map.get(name.toLowerCase());
|
|
114
|
-
if (!clip) {
|
|
115
|
-
const have = [...new Set(animations.map((c) => c.name))].join(', ');
|
|
116
|
-
throw new Error(`humanoid: no clip named '${name}' in library (have: ${have})`);
|
|
117
|
-
}
|
|
118
|
-
return clip;
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Character-composition primitives — how a generated humanoid BECOMES a
|
|
3
|
-
* distinct character (a viking, a policeman, …).
|
|
4
|
-
*
|
|
5
|
-
* PHILOSOPHY (owner directive): this file is deliberately NOT a customization
|
|
6
|
-
* system. No recipe DSL, no slot/preset registry, no outfit library. It ships
|
|
7
|
-
* the BARE MINIMUM an agent needs to compose ANY character with ordinary,
|
|
8
|
-
* idiomatic three.js code written at generation time:
|
|
9
|
-
*
|
|
10
|
-
* 1. `skinToHumanoid(geometry, rig)` — skin arbitrary generated geometry
|
|
11
|
-
* (a tunic lathe, a sleeve cylinder, …) to the rig's shared skeleton so
|
|
12
|
-
* it deforms with the body,
|
|
13
|
-
* 2. `attachToBone(rig, boneName, object)` — parent a rigid prop (helmet,
|
|
14
|
-
* axe, badge) to a named bone with a model-space authoring contract,
|
|
15
|
-
* 3. `restJointPosition(rig, boneName)` — the one placement query: agents
|
|
16
|
-
* must size/place geometry against the PARAMETRIC body (joints move
|
|
17
|
-
* with body-type params), and reading `bone.matrixWorld` is wrong once
|
|
18
|
-
* a clip is playing — rest pose comes from the bind data instead.
|
|
19
|
-
*
|
|
20
|
-
* Everything else (shapes, colors, layering, which prop goes where) is the
|
|
21
|
-
* agent's ordinary code. Worked agent-artifact examples:
|
|
22
|
-
* `packages/engine/e2e/humanoid-character-proof/{viking,policeman}.ts`.
|
|
23
|
-
*
|
|
24
|
-
* AUTHORING SPACE: both primitives speak the rig's MODEL SPACE — Y-up metres,
|
|
25
|
-
* rest pose, origin at the rig root (the same space `generateHumanoid` builds
|
|
26
|
-
* the body in, and the space `rig.mesh.geometry` positions live in). The
|
|
27
|
-
* armature's internal Z-up-centimetre frame (ARMATURE_SCALE) never leaks:
|
|
28
|
-
* `skinToHumanoid` binds with the body's own bind matrix, and `attachToBone`
|
|
29
|
-
* converts through the skeleton's inverse bind matrices.
|
|
30
|
-
*
|
|
31
|
-
* OWNERSHIP: both primitives parent their object under the rig (`rig.root`
|
|
32
|
-
* for skinned meshes, the bone for props), and `rig.dispose()` frees every
|
|
33
|
-
* geometry/material found under the root — dressing a rig hands the
|
|
34
|
-
* resources' lifetime to it. Detach first to keep something alive.
|
|
35
|
-
*/
|
|
36
|
-
import * as THREE from 'three';
|
|
37
|
-
import type { HumanoidRig } from './generate';
|
|
38
|
-
/** Rest-pose (bind-pose) position of a named joint in the rig's model space —
|
|
39
|
-
* stable regardless of the current animation pose, because it is read from
|
|
40
|
-
* the skeleton's inverse bind matrices rather than live bone transforms. */
|
|
41
|
-
export declare function restJointPosition(rig: HumanoidRig, boneName: string, target?: THREE.Vector3): THREE.Vector3;
|
|
42
|
-
/**
|
|
43
|
-
* Skin arbitrary generated geometry to a humanoid rig's skeleton.
|
|
44
|
-
*
|
|
45
|
-
* `geometry` is authored in the rig's model space (Y-up metres, rest pose —
|
|
46
|
-
* build a sleeve around the rest arm, a tunic around the rest torso). The
|
|
47
|
-
* function computes 4-wide zero-padded `skinIndex`/`skinWeight` attributes on
|
|
48
|
-
* the geometry (in place), wraps it in a `THREE.SkinnedMesh` bound to the
|
|
49
|
-
* SAME `THREE.Skeleton` as the body, parents it under `rig.root`, and returns
|
|
50
|
-
* it. From then on it deforms with the body and is freed by `rig.dispose()`.
|
|
51
|
-
*
|
|
52
|
-
* Weighting is the body's own analytic scheme, per vertex: pick the body
|
|
53
|
-
* segment whose SURFACE is nearest (distance to the joint-to-joint axis minus
|
|
54
|
-
* the part's radius — so a loose tunic still binds to the torso it covers),
|
|
55
|
-
* project the vertex onto that segment's axis, and apply the same smoothstep
|
|
56
|
-
* 2-bone joint blend the body uses (50/50 exactly at each joint). Geometry
|
|
57
|
-
* spanning a joint therefore blends across it exactly like the body does —
|
|
58
|
-
* give clothing a slightly larger radius than the body part underneath and
|
|
59
|
-
* the two move together with no relative sliding.
|
|
60
|
-
*/
|
|
61
|
-
export declare function skinToHumanoid(geometry: THREE.BufferGeometry, rig: HumanoidRig, material?: THREE.Material): THREE.SkinnedMesh;
|
|
62
|
-
/**
|
|
63
|
-
* Attach a rigid prop (helmet, axe, badge, …) to a named bone.
|
|
64
|
-
*
|
|
65
|
-
* Authoring contract: position/rotate/scale `object` in the rig's MODEL SPACE
|
|
66
|
-
* (Y-up metres, rest pose — e.g. a helmet at `restJointPosition(rig,
|
|
67
|
-
* 'mixamorigHead')` plus a bit of Y). The function converts that placement
|
|
68
|
-
* into the bone's local frame — including the armature's internal
|
|
69
|
-
* Z-up-centimetre transform, which is why the local values you'd read back
|
|
70
|
-
* afterwards look like centimetres with a ~100× scale — parents the object to
|
|
71
|
-
* the bone, and returns it. The prop then rides the bone through every pose,
|
|
72
|
-
* and `rig.dispose()` frees its geometry/materials.
|
|
73
|
-
*/
|
|
74
|
-
export declare function attachToBone<T extends THREE.Object3D>(rig: HumanoidRig, boneName: string, object: T): T;
|
|
75
|
-
//# sourceMappingURL=compose.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/humanoid/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C;;6EAE6E;AAC7E,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,gBAAsB,GAC3B,KAAK,CAAC,OAAO,CAGf;AA0CD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,KAAK,CAAC,cAAc,EAC9B,GAAG,EAAE,WAAW,EAChB,QAAQ,GAAE,KAAK,CAAC,QAA6D,GAC5E,KAAK,CAAC,WAAW,CAyDnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,CAAC,QAAQ,EACnD,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,CAAC,GACR,CAAC,CAYH"}
|
package/dist/humanoid/compose.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Character-composition primitives — how a generated humanoid BECOMES a
|
|
3
|
-
* distinct character (a viking, a policeman, …).
|
|
4
|
-
*
|
|
5
|
-
* PHILOSOPHY (owner directive): this file is deliberately NOT a customization
|
|
6
|
-
* system. No recipe DSL, no slot/preset registry, no outfit library. It ships
|
|
7
|
-
* the BARE MINIMUM an agent needs to compose ANY character with ordinary,
|
|
8
|
-
* idiomatic three.js code written at generation time:
|
|
9
|
-
*
|
|
10
|
-
* 1. `skinToHumanoid(geometry, rig)` — skin arbitrary generated geometry
|
|
11
|
-
* (a tunic lathe, a sleeve cylinder, …) to the rig's shared skeleton so
|
|
12
|
-
* it deforms with the body,
|
|
13
|
-
* 2. `attachToBone(rig, boneName, object)` — parent a rigid prop (helmet,
|
|
14
|
-
* axe, badge) to a named bone with a model-space authoring contract,
|
|
15
|
-
* 3. `restJointPosition(rig, boneName)` — the one placement query: agents
|
|
16
|
-
* must size/place geometry against the PARAMETRIC body (joints move
|
|
17
|
-
* with body-type params), and reading `bone.matrixWorld` is wrong once
|
|
18
|
-
* a clip is playing — rest pose comes from the bind data instead.
|
|
19
|
-
*
|
|
20
|
-
* Everything else (shapes, colors, layering, which prop goes where) is the
|
|
21
|
-
* agent's ordinary code. Worked agent-artifact examples:
|
|
22
|
-
* `packages/engine/e2e/humanoid-character-proof/{viking,policeman}.ts`.
|
|
23
|
-
*
|
|
24
|
-
* AUTHORING SPACE: both primitives speak the rig's MODEL SPACE — Y-up metres,
|
|
25
|
-
* rest pose, origin at the rig root (the same space `generateHumanoid` builds
|
|
26
|
-
* the body in, and the space `rig.mesh.geometry` positions live in). The
|
|
27
|
-
* armature's internal Z-up-centimetre frame (ARMATURE_SCALE) never leaks:
|
|
28
|
-
* `skinToHumanoid` binds with the body's own bind matrix, and `attachToBone`
|
|
29
|
-
* converts through the skeleton's inverse bind matrices.
|
|
30
|
-
*
|
|
31
|
-
* OWNERSHIP: both primitives parent their object under the rig (`rig.root`
|
|
32
|
-
* for skinned meshes, the bone for props), and `rig.dispose()` frees every
|
|
33
|
-
* geometry/material found under the root — dressing a rig hands the
|
|
34
|
-
* resources' lifetime to it. Detach first to keep something alive.
|
|
35
|
-
*/
|
|
36
|
-
import * as THREE from 'three';
|
|
37
|
-
import { computeBindingSegments, HEAD_CAPSULE_RADIUS, smoothstep, } from './body';
|
|
38
|
-
import { scaleSkeletonDef } from './skeleton';
|
|
39
|
-
/** Rest-pose (bind-pose) position of a named joint in the rig's model space —
|
|
40
|
-
* stable regardless of the current animation pose, because it is read from
|
|
41
|
-
* the skeleton's inverse bind matrices rather than live bone transforms. */
|
|
42
|
-
export function restJointPosition(rig, boneName, target = new THREE.Vector3()) {
|
|
43
|
-
const inverse = rig.skeleton.boneInverses[requireBoneIndex(rig, boneName)];
|
|
44
|
-
return target.setFromMatrixPosition(restMatrix.copy(inverse).invert());
|
|
45
|
-
}
|
|
46
|
-
const restMatrix = new THREE.Matrix4();
|
|
47
|
-
function requireBoneIndex(rig, boneName) {
|
|
48
|
-
const bone = rig.bonesByName.get(boneName);
|
|
49
|
-
const index = bone ? rig.bones.indexOf(bone) : -1;
|
|
50
|
-
if (index < 0) {
|
|
51
|
-
throw new Error(`humanoid: unknown bone '${boneName}' (standard names are the sanitized ` +
|
|
52
|
-
`Mixamo set, e.g. 'mixamorigHead', 'mixamorigRightHand')`);
|
|
53
|
-
}
|
|
54
|
-
return index;
|
|
55
|
-
}
|
|
56
|
-
/** Per-rig cache of the resolved binding segments (a rig is typically dressed
|
|
57
|
-
* with several meshes; the segment map is identical for all of them). */
|
|
58
|
-
const segmentCache = new WeakMap();
|
|
59
|
-
function bindingSegments(rig) {
|
|
60
|
-
let segments = segmentCache.get(rig);
|
|
61
|
-
if (segments)
|
|
62
|
-
return segments;
|
|
63
|
-
// The uniform height factor is a pure function of the rig's (resolved)
|
|
64
|
-
// params — recompute it exactly as `generateHumanoid` did rather than
|
|
65
|
-
// widening the public HumanoidRig surface with a field only this needs.
|
|
66
|
-
const { heightFactor } = scaleSkeletonDef(rig.params, HEAD_CAPSULE_RADIUS * rig.params.headSize);
|
|
67
|
-
segments = computeBindingSegments((name) => restJointPosition(rig, name), (name) => requireBoneIndex(rig, name), {
|
|
68
|
-
heightFactor,
|
|
69
|
-
limbThickness: rig.params.limbThickness,
|
|
70
|
-
torsoGirth: rig.params.torsoGirth,
|
|
71
|
-
headSize: rig.params.headSize,
|
|
72
|
-
hipWidth: rig.params.hipWidth,
|
|
73
|
-
});
|
|
74
|
-
segmentCache.set(rig, segments);
|
|
75
|
-
return segments;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Skin arbitrary generated geometry to a humanoid rig's skeleton.
|
|
79
|
-
*
|
|
80
|
-
* `geometry` is authored in the rig's model space (Y-up metres, rest pose —
|
|
81
|
-
* build a sleeve around the rest arm, a tunic around the rest torso). The
|
|
82
|
-
* function computes 4-wide zero-padded `skinIndex`/`skinWeight` attributes on
|
|
83
|
-
* the geometry (in place), wraps it in a `THREE.SkinnedMesh` bound to the
|
|
84
|
-
* SAME `THREE.Skeleton` as the body, parents it under `rig.root`, and returns
|
|
85
|
-
* it. From then on it deforms with the body and is freed by `rig.dispose()`.
|
|
86
|
-
*
|
|
87
|
-
* Weighting is the body's own analytic scheme, per vertex: pick the body
|
|
88
|
-
* segment whose SURFACE is nearest (distance to the joint-to-joint axis minus
|
|
89
|
-
* the part's radius — so a loose tunic still binds to the torso it covers),
|
|
90
|
-
* project the vertex onto that segment's axis, and apply the same smoothstep
|
|
91
|
-
* 2-bone joint blend the body uses (50/50 exactly at each joint). Geometry
|
|
92
|
-
* spanning a joint therefore blends across it exactly like the body does —
|
|
93
|
-
* give clothing a slightly larger radius than the body part underneath and
|
|
94
|
-
* the two move together with no relative sliding.
|
|
95
|
-
*/
|
|
96
|
-
export function skinToHumanoid(geometry, rig, material = new THREE.MeshStandardMaterial({ roughness: 0.8 })) {
|
|
97
|
-
const position = geometry.getAttribute('position');
|
|
98
|
-
if (!position)
|
|
99
|
-
throw new Error('humanoid: skinToHumanoid needs a position attribute');
|
|
100
|
-
const segments = bindingSegments(rig);
|
|
101
|
-
const n = position.count;
|
|
102
|
-
const skinIndex = new Uint16Array(n * 4);
|
|
103
|
-
const skinWeight = new Float32Array(n * 4);
|
|
104
|
-
const v = new THREE.Vector3();
|
|
105
|
-
const w = new THREE.Vector3();
|
|
106
|
-
for (let i = 0; i < n; i++) {
|
|
107
|
-
v.fromBufferAttribute(position, i);
|
|
108
|
-
// Nearest segment by distance to the part SURFACE (t clamped to the
|
|
109
|
-
// joint span for the distance test only).
|
|
110
|
-
let best = segments[0];
|
|
111
|
-
let bestT = 0;
|
|
112
|
-
let bestD = Number.POSITIVE_INFINITY;
|
|
113
|
-
for (const seg of segments) {
|
|
114
|
-
w.copy(v).sub(seg.p0);
|
|
115
|
-
const t = w.dot(seg.axis) / seg.len;
|
|
116
|
-
const tc = Math.min(1, Math.max(0, t));
|
|
117
|
-
const d = w.addScaledVector(seg.axis, -tc * seg.len).length() - seg.radius;
|
|
118
|
-
if (d < bestD) {
|
|
119
|
-
bestD = d;
|
|
120
|
-
best = seg;
|
|
121
|
-
bestT = t;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// The body's own 2-bone joint blend (skinSegment in body.ts), verbatim.
|
|
125
|
-
let other = best.bone;
|
|
126
|
-
let w2 = 0;
|
|
127
|
-
if (best.proximal >= 0 && bestT < best.blend) {
|
|
128
|
-
other = best.proximal;
|
|
129
|
-
w2 = 0.5 * (1 - smoothstep(bestT / best.blend));
|
|
130
|
-
}
|
|
131
|
-
else if (best.distal >= 0 && bestT > 1 - best.blend) {
|
|
132
|
-
other = best.distal;
|
|
133
|
-
w2 = 0.5 * smoothstep((bestT - (1 - best.blend)) / best.blend);
|
|
134
|
-
}
|
|
135
|
-
skinIndex.set([best.bone, other, 0, 0], i * 4);
|
|
136
|
-
skinWeight.set([1 - w2, w2, 0, 0], i * 4);
|
|
137
|
-
}
|
|
138
|
-
geometry.setAttribute('skinIndex', new THREE.BufferAttribute(skinIndex, 4));
|
|
139
|
-
geometry.setAttribute('skinWeight', new THREE.BufferAttribute(skinWeight, 4));
|
|
140
|
-
const mesh = new THREE.SkinnedMesh(geometry, material);
|
|
141
|
-
mesh.name = 'HumanoidSkinnedAttachment';
|
|
142
|
-
mesh.castShadow = true;
|
|
143
|
-
// Same as the body: an animated skinned mesh leaves its rest-pose bounds.
|
|
144
|
-
mesh.frustumCulled = false;
|
|
145
|
-
rig.root.add(mesh);
|
|
146
|
-
// Bind in the body's bind space (model space at generate time) — NOT the
|
|
147
|
-
// mesh's current matrixWorld, which already includes wherever the caller
|
|
148
|
-
// has moved `rig.root` by now.
|
|
149
|
-
mesh.bind(rig.skeleton, rig.mesh.bindMatrix.clone());
|
|
150
|
-
return mesh;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Attach a rigid prop (helmet, axe, badge, …) to a named bone.
|
|
154
|
-
*
|
|
155
|
-
* Authoring contract: position/rotate/scale `object` in the rig's MODEL SPACE
|
|
156
|
-
* (Y-up metres, rest pose — e.g. a helmet at `restJointPosition(rig,
|
|
157
|
-
* 'mixamorigHead')` plus a bit of Y). The function converts that placement
|
|
158
|
-
* into the bone's local frame — including the armature's internal
|
|
159
|
-
* Z-up-centimetre transform, which is why the local values you'd read back
|
|
160
|
-
* afterwards look like centimetres with a ~100× scale — parents the object to
|
|
161
|
-
* the bone, and returns it. The prop then rides the bone through every pose,
|
|
162
|
-
* and `rig.dispose()` frees its geometry/materials.
|
|
163
|
-
*/
|
|
164
|
-
export function attachToBone(rig, boneName, object) {
|
|
165
|
-
const index = requireBoneIndex(rig, boneName);
|
|
166
|
-
const bone = rig.bones[index];
|
|
167
|
-
object.updateMatrix();
|
|
168
|
-
// local = inverse(boneRestWorld) × authoredModelMatrix; boneInverses IS
|
|
169
|
-
// inverse(boneRestWorld) in model space (root at identity at bind time).
|
|
170
|
-
// The bone's rest world scale is uniform (ARMATURE_SCALE), so the
|
|
171
|
-
// decompose below is exact.
|
|
172
|
-
const local = rig.skeleton.boneInverses[index].clone().multiply(object.matrix);
|
|
173
|
-
local.decompose(object.position, object.quaternion, object.scale);
|
|
174
|
-
bone.add(object);
|
|
175
|
-
return object;
|
|
176
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `generateHumanoid` — the engine's procedural humanoid character generator.
|
|
3
|
-
*
|
|
4
|
-
* vgai generates buildings and terrain procedurally; this is the same idea
|
|
5
|
-
* for CHARACTERS: no downloaded model, no Quaternius/Mixamo mesh dependency —
|
|
6
|
-
* a ready-to-animate skinned humanoid built entirely from code:
|
|
7
|
-
*
|
|
8
|
-
* - the STANDARD skeleton (Mixamo-named, reference rest pose) rescaled by
|
|
9
|
-
* authored body-type params (`skeleton.ts`),
|
|
10
|
-
* - a fully procedural capsule/box body with analytic per-segment skin
|
|
11
|
-
* weights that stay correct across proportions (`body.ts`),
|
|
12
|
-
* - standard-clip playback with prefix-variant resolution and the
|
|
13
|
-
* translation-track retarget policy (`clips.ts`).
|
|
14
|
-
*
|
|
15
|
-
* The one external thing a game still supplies is ANIMATION CLIPS (from any
|
|
16
|
-
* Mixamo-named GLB — e.g. the repo's vendored Soldier.glb Idle/Walk/Run).
|
|
17
|
-
*
|
|
18
|
-
* Usage (a game's `setup()` or any three.js world):
|
|
19
|
-
*
|
|
20
|
-
* import { generateHumanoid, createHumanoidClipLibrary } from '@vgai/engine/humanoid';
|
|
21
|
-
*
|
|
22
|
-
* const rig = generateHumanoid({ height: 1.6, limbThickness: 1.3, torsoGirth: 1.4 });
|
|
23
|
-
* scene.add(rig.root);
|
|
24
|
-
* const clips = createHumanoidClipLibrary(gltf.animations);
|
|
25
|
-
* rig.playClip(clips.get('Walk'));
|
|
26
|
-
* // per frame: rig.update(dt) // e.g. from a SystemPhase.ANIMATION system
|
|
27
|
-
* // teardown: rig.dispose()
|
|
28
|
-
*
|
|
29
|
-
* Scene-file authoring status: this is a code API (like `GameComponent`
|
|
30
|
-
* schemas), NOT yet a `.vscn` generator — the scene `generator` seam
|
|
31
|
-
* (`scene/geometry-registry.ts`) produces bare `BufferGeometry`, while a
|
|
32
|
-
* humanoid is a SkinnedMesh + bone hierarchy + mixer. Wiring a scene-entity
|
|
33
|
-
* spelling is future work (see docs/PROCEDURAL-HUMANOID.md).
|
|
34
|
-
*/
|
|
35
|
-
import * as THREE from 'three';
|
|
36
|
-
import { type HumanoidBodyPart } from './body';
|
|
37
|
-
import { type HumanoidParams, type ResolvedHumanoidParams } from './schema';
|
|
38
|
-
export interface GenerateHumanoidOptions {
|
|
39
|
-
/** Override the body material (default: a vertex-colored MeshStandardMaterial
|
|
40
|
-
* that visualizes the body-part/blend-zone map). A caller-supplied material
|
|
41
|
-
* is NOT disposed by `rig.dispose()`. */
|
|
42
|
-
material?: THREE.Material;
|
|
43
|
-
}
|
|
44
|
-
export interface PlayClipOptions {
|
|
45
|
-
/** Crossfade seconds from the previous action (0 = hard cut). Default 0.25. */
|
|
46
|
-
fade?: number;
|
|
47
|
-
}
|
|
48
|
-
/** A generated, ready-to-use humanoid character rig. */
|
|
49
|
-
export interface HumanoidRig {
|
|
50
|
-
/** Add this to the scene; position/rotate/scale it like any Object3D. */
|
|
51
|
-
root: THREE.Group;
|
|
52
|
-
/** The single merged skinned body mesh (child of `root`). */
|
|
53
|
-
mesh: THREE.SkinnedMesh;
|
|
54
|
-
skeleton: THREE.Skeleton;
|
|
55
|
-
/** All bones in canonical row order (skinIndex order). */
|
|
56
|
-
bones: THREE.Bone[];
|
|
57
|
-
/** Bone lookup by canonical Mixamo name (`mixamorigHips`, …). */
|
|
58
|
-
bonesByName: ReadonlyMap<string, THREE.Bone>;
|
|
59
|
-
/** The resolved (defaulted) params this rig was generated from. */
|
|
60
|
-
params: ResolvedHumanoidParams;
|
|
61
|
-
/** Realized standing height in metres (crown of head, rest pose). */
|
|
62
|
-
height: number;
|
|
63
|
-
/** Hips-height ratio vs the reference rig — the hips `.position` track
|
|
64
|
-
* remap factor (see `clips.ts`). */
|
|
65
|
-
hipsPositionScale: number;
|
|
66
|
-
vertexCount: number;
|
|
67
|
-
/** Per-part vertex ranges + allowed bone influences (test/debug surface). */
|
|
68
|
-
parts: readonly HumanoidBodyPart[];
|
|
69
|
-
/** The rig's own mixer, rooted at `root`. Drive it via `update(dt)`. */
|
|
70
|
-
mixer: THREE.AnimationMixer;
|
|
71
|
-
/**
|
|
72
|
-
* Play a standard humanoid clip: retargets it (prefix variants, the
|
|
73
|
-
* translation-track policy — cached per source clip), crossfades from the
|
|
74
|
-
* currently-playing action, returns the started `AnimationAction` for
|
|
75
|
-
* further control (timeScale, loop mode, …). Throws, listing every
|
|
76
|
-
* offender, if the clip has tracks that don't resolve to standard bones.
|
|
77
|
-
*/
|
|
78
|
-
playClip(clip: THREE.AnimationClip, options?: PlayClipOptions): THREE.AnimationAction;
|
|
79
|
-
/** Advance the rig's animation. Call once per frame with seconds. */
|
|
80
|
-
update(dt: number): void;
|
|
81
|
-
/** Stop animation, release GPU resources (the body AND every geometry/
|
|
82
|
-
* material parented under the rig — skinned clothing, bone props),
|
|
83
|
-
* detach from parent. */
|
|
84
|
-
dispose(): void;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Generate a skinned humanoid character from body-type params (validated by
|
|
88
|
-
* `HumanoidParamsSchema`; `generateHumanoid()` with no args yields the
|
|
89
|
-
* reference body). Pure and synchronous — no assets are loaded.
|
|
90
|
-
*/
|
|
91
|
-
export declare function generateHumanoid(params?: HumanoidParams, options?: GenerateHumanoidOptions): HumanoidRig;
|
|
92
|
-
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/humanoid/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAA0C,KAAK,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAEvF,OAAO,EAAE,KAAK,cAAc,EAAwB,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGlG,MAAM,WAAW,uBAAuB;IACtC;;8CAE0C;IAC1C,QAAQ,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC;IAClB,6DAA6D;IAC7D,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;IACzB,0DAA0D;IAC1D,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IACpB,iEAAiE;IACjE,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7C,mEAAmE;IACnE,MAAM,EAAE,sBAAsB,CAAC;IAC/B,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf;yCACqC;IACrC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,6EAA6E;IAC7E,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACnC,wEAAwE;IACxE,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC;IACtF,qEAAqE;IACrE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;8BAE0B;IAC1B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,GAAE,cAAmB,EAC3B,OAAO,GAAE,uBAA4B,GACpC,WAAW,CAwFb"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `generateHumanoid` — the engine's procedural humanoid character generator.
|
|
3
|
-
*
|
|
4
|
-
* vgai generates buildings and terrain procedurally; this is the same idea
|
|
5
|
-
* for CHARACTERS: no downloaded model, no Quaternius/Mixamo mesh dependency —
|
|
6
|
-
* a ready-to-animate skinned humanoid built entirely from code:
|
|
7
|
-
*
|
|
8
|
-
* - the STANDARD skeleton (Mixamo-named, reference rest pose) rescaled by
|
|
9
|
-
* authored body-type params (`skeleton.ts`),
|
|
10
|
-
* - a fully procedural capsule/box body with analytic per-segment skin
|
|
11
|
-
* weights that stay correct across proportions (`body.ts`),
|
|
12
|
-
* - standard-clip playback with prefix-variant resolution and the
|
|
13
|
-
* translation-track retarget policy (`clips.ts`).
|
|
14
|
-
*
|
|
15
|
-
* The one external thing a game still supplies is ANIMATION CLIPS (from any
|
|
16
|
-
* Mixamo-named GLB — e.g. the repo's vendored Soldier.glb Idle/Walk/Run).
|
|
17
|
-
*
|
|
18
|
-
* Usage (a game's `setup()` or any three.js world):
|
|
19
|
-
*
|
|
20
|
-
* import { generateHumanoid, createHumanoidClipLibrary } from '@vgai/engine/humanoid';
|
|
21
|
-
*
|
|
22
|
-
* const rig = generateHumanoid({ height: 1.6, limbThickness: 1.3, torsoGirth: 1.4 });
|
|
23
|
-
* scene.add(rig.root);
|
|
24
|
-
* const clips = createHumanoidClipLibrary(gltf.animations);
|
|
25
|
-
* rig.playClip(clips.get('Walk'));
|
|
26
|
-
* // per frame: rig.update(dt) // e.g. from a SystemPhase.ANIMATION system
|
|
27
|
-
* // teardown: rig.dispose()
|
|
28
|
-
*
|
|
29
|
-
* Scene-file authoring status: this is a code API (like `GameComponent`
|
|
30
|
-
* schemas), NOT yet a `.vscn` generator — the scene `generator` seam
|
|
31
|
-
* (`scene/geometry-registry.ts`) produces bare `BufferGeometry`, while a
|
|
32
|
-
* humanoid is a SkinnedMesh + bone hierarchy + mixer. Wiring a scene-entity
|
|
33
|
-
* spelling is future work (see docs/PROCEDURAL-HUMANOID.md).
|
|
34
|
-
*/
|
|
35
|
-
import * as THREE from 'three';
|
|
36
|
-
import { buildHumanoidBody, HEAD_CAPSULE_RADIUS } from './body';
|
|
37
|
-
import { retargetClipToHumanoid } from './clips';
|
|
38
|
-
import { HumanoidParamsSchema } from './schema';
|
|
39
|
-
import { buildHumanoidSkeleton, createArmatureGroup, scaleSkeletonDef } from './skeleton';
|
|
40
|
-
/**
|
|
41
|
-
* Generate a skinned humanoid character from body-type params (validated by
|
|
42
|
-
* `HumanoidParamsSchema`; `generateHumanoid()` with no args yields the
|
|
43
|
-
* reference body). Pure and synchronous — no assets are loaded.
|
|
44
|
-
*/
|
|
45
|
-
export function generateHumanoid(params = {}, options = {}) {
|
|
46
|
-
const resolved = HumanoidParamsSchema.parse(params);
|
|
47
|
-
const scaledDef = scaleSkeletonDef(resolved, HEAD_CAPSULE_RADIUS * resolved.headSize);
|
|
48
|
-
const skeletonRig = buildHumanoidSkeleton(scaledDef.defs);
|
|
49
|
-
const root = new THREE.Group();
|
|
50
|
-
root.name = 'ProceduralHumanoid';
|
|
51
|
-
const armature = createArmatureGroup(skeletonRig);
|
|
52
|
-
root.add(armature);
|
|
53
|
-
// Rest-pose world matrices (root at identity) → bind pose + body geometry.
|
|
54
|
-
root.updateMatrixWorld(true);
|
|
55
|
-
const body = buildHumanoidBody(skeletonRig, {
|
|
56
|
-
heightFactor: scaledDef.heightFactor,
|
|
57
|
-
limbThickness: resolved.limbThickness,
|
|
58
|
-
torsoGirth: resolved.torsoGirth,
|
|
59
|
-
headSize: resolved.headSize,
|
|
60
|
-
hipWidth: resolved.hipWidth,
|
|
61
|
-
}, options.material);
|
|
62
|
-
root.add(body.mesh);
|
|
63
|
-
const mixer = new THREE.AnimationMixer(root);
|
|
64
|
-
const retargetCache = new Map();
|
|
65
|
-
let currentAction = null;
|
|
66
|
-
const rig = {
|
|
67
|
-
root,
|
|
68
|
-
mesh: body.mesh,
|
|
69
|
-
skeleton: body.skeleton,
|
|
70
|
-
bones: skeletonRig.bones,
|
|
71
|
-
bonesByName: skeletonRig.byName,
|
|
72
|
-
params: resolved,
|
|
73
|
-
height: scaledDef.height,
|
|
74
|
-
hipsPositionScale: scaledDef.hipsPositionScale,
|
|
75
|
-
vertexCount: body.vertexCount,
|
|
76
|
-
parts: body.parts,
|
|
77
|
-
mixer,
|
|
78
|
-
playClip(clip, playOptions = {}) {
|
|
79
|
-
const fade = playOptions.fade ?? 0.25;
|
|
80
|
-
let prepared = retargetCache.get(clip.uuid);
|
|
81
|
-
if (!prepared) {
|
|
82
|
-
prepared = retargetClipToHumanoid(clip, rig);
|
|
83
|
-
retargetCache.set(clip.uuid, prepared);
|
|
84
|
-
}
|
|
85
|
-
const action = mixer.clipAction(prepared);
|
|
86
|
-
const previous = currentAction;
|
|
87
|
-
if (previous && previous !== action && fade > 0) {
|
|
88
|
-
previous.fadeOut(fade);
|
|
89
|
-
action.reset().fadeIn(fade).play();
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
previous?.stop();
|
|
93
|
-
action.reset().play();
|
|
94
|
-
}
|
|
95
|
-
currentAction = action;
|
|
96
|
-
return action;
|
|
97
|
-
},
|
|
98
|
-
update(dt) {
|
|
99
|
-
mixer.update(dt);
|
|
100
|
-
},
|
|
101
|
-
dispose() {
|
|
102
|
-
mixer.stopAllAction();
|
|
103
|
-
mixer.uncacheRoot(root);
|
|
104
|
-
body.skeleton.dispose();
|
|
105
|
-
// Free EVERYTHING parented under the rig — the body plus whatever the
|
|
106
|
-
// composition primitives (`skinToHumanoid` clothing, `attachToBone`
|
|
107
|
-
// props — see compose.ts's ownership contract) added since. The one
|
|
108
|
-
// exception stays: a caller-supplied body material is never disposed.
|
|
109
|
-
root.traverse((obj) => {
|
|
110
|
-
const withResources = obj;
|
|
111
|
-
withResources.geometry?.dispose();
|
|
112
|
-
const material = withResources.material;
|
|
113
|
-
if (!material)
|
|
114
|
-
return;
|
|
115
|
-
for (const mat of Array.isArray(material) ? material : [material]) {
|
|
116
|
-
if (mat !== options.material)
|
|
117
|
-
mat.dispose();
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
root.removeFromParent();
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
return rig;
|
|
124
|
-
}
|
package/dist/humanoid/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@vgai/engine/humanoid` — procedural humanoid character generation.
|
|
3
|
-
*
|
|
4
|
-
* Generate skinned, animation-ready humanoid characters entirely from code
|
|
5
|
-
* (the way the engine generates terrain/props): a standard Mixamo-named
|
|
6
|
-
* skeleton rescaled by body-type params, a procedural capsule body with
|
|
7
|
-
* analytic skin weights, and standard-clip playback with the humanoid
|
|
8
|
-
* retarget policy. Start at `generateHumanoid`; turn the result into a
|
|
9
|
-
* distinct CHARACTER with the composition primitives (`skinToHumanoid`,
|
|
10
|
-
* `attachToBone`, `restJointPosition` — see compose.ts's philosophy note).
|
|
11
|
-
* Full guide: docs/PROCEDURAL-HUMANOID.md.
|
|
12
|
-
*/
|
|
13
|
-
export type { HumanoidBody, HumanoidBodyDims, HumanoidBodyPart } from './body';
|
|
14
|
-
export { buildHumanoidBody, HEAD_CAPSULE_RADIUS } from './body';
|
|
15
|
-
export type { HumanoidClipLibrary, HumanoidClipTarget } from './clips';
|
|
16
|
-
export { createHumanoidClipLibrary, resolveHumanoidBoneName, retargetClipToHumanoid, } from './clips';
|
|
17
|
-
export { attachToBone, restJointPosition, skinToHumanoid } from './compose';
|
|
18
|
-
export type { GenerateHumanoidOptions, HumanoidRig, PlayClipOptions } from './generate';
|
|
19
|
-
export { generateHumanoid } from './generate';
|
|
20
|
-
export type { HumanoidParams, ResolvedHumanoidParams } from './schema';
|
|
21
|
-
export { HumanoidParamsSchema } from './schema';
|
|
22
|
-
export type { BoneDef, BuiltSkeleton, ScaledSkeletonDef } from './skeleton';
|
|
23
|
-
export { ARMATURE_ROTATION_X, ARMATURE_SCALE, buildHumanoidSkeleton, createArmatureGroup, HUMANOID_HIPS_BONE, MIXAMO_SKELETON_DEF, scaleSkeletonDef, } from './skeleton';
|
|
24
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/humanoid/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAChE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC5E,YAAY,EAAE,uBAAuB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/humanoid/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@vgai/engine/humanoid` — procedural humanoid character generation.
|
|
3
|
-
*
|
|
4
|
-
* Generate skinned, animation-ready humanoid characters entirely from code
|
|
5
|
-
* (the way the engine generates terrain/props): a standard Mixamo-named
|
|
6
|
-
* skeleton rescaled by body-type params, a procedural capsule body with
|
|
7
|
-
* analytic skin weights, and standard-clip playback with the humanoid
|
|
8
|
-
* retarget policy. Start at `generateHumanoid`; turn the result into a
|
|
9
|
-
* distinct CHARACTER with the composition primitives (`skinToHumanoid`,
|
|
10
|
-
* `attachToBone`, `restJointPosition` — see compose.ts's philosophy note).
|
|
11
|
-
* Full guide: docs/PROCEDURAL-HUMANOID.md.
|
|
12
|
-
*/
|
|
13
|
-
export { buildHumanoidBody, HEAD_CAPSULE_RADIUS } from './body';
|
|
14
|
-
export { createHumanoidClipLibrary, resolveHumanoidBoneName, retargetClipToHumanoid, } from './clips';
|
|
15
|
-
export { attachToBone, restJointPosition, skinToHumanoid } from './compose';
|
|
16
|
-
export { generateHumanoid } from './generate';
|
|
17
|
-
export { HumanoidParamsSchema } from './schema';
|
|
18
|
-
export { ARMATURE_ROTATION_X, ARMATURE_SCALE, buildHumanoidSkeleton, createArmatureGroup, HUMANOID_HIPS_BONE, MIXAMO_SKELETON_DEF, scaleSkeletonDef, } from './skeleton';
|