threedog 0.5.0 → 0.7.0
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/CHANGELOG.md +81 -1
- package/README.md +21 -13
- package/core/Assets.js +23 -12
- package/core/Audio.js +1 -1
- package/core/Baked.js +14 -23
- package/core/Budget.js +2 -2
- package/core/DebugOverrides.js +33 -18
- package/core/Describe.js +10 -11
- package/core/Engine.js +50 -46
- package/core/I18n.js +2 -2
- package/core/Input.js +11 -5
- package/core/Inspect.js +6 -3
- package/core/InspectMaterials.js +2 -3
- package/core/InspectPerf.js +11 -4
- package/core/MaterialInfo.js +7 -5
- package/core/Rays.js +7 -2
- package/core/Stream.js +2 -3
- package/core/UrlState.js +49 -9
- package/core/Views.js +1 -0
- package/core/adaptive.js +2 -2
- package/core/assetEntry.js +5 -2
- package/core/assetLoad.js +13 -15
- package/core/assetManifest.js +6 -3
- package/core/assetReport.js +4 -4
- package/core/batchGroups.js +9 -1
- package/core/catalog.js +16 -3
- package/core/chunkStream.js +1 -1
- package/core/copies.js +1 -1
- package/core/debugView.js +4 -4
- package/core/describeRender.js +104 -28
- package/core/describeText.js +6 -6
- package/core/errorCodes.js +72 -45
- package/core/errorHints.js +4 -1
- package/core/errors.js +4 -4
- package/core/events.generated.js +1 -0
- package/core/gameLights.js +9 -2
- package/core/lifecycle.js +2 -4
- package/core/lightWatch.js +5 -3
- package/core/loop.js +18 -11
- package/core/math.js +7 -0
- package/core/moduleSlots.js +32 -7
- package/core/moduleTypes.js +20 -7
- package/core/modules.js +7 -7
- package/core/namedModel.js +8 -4
- package/core/owned.js +33 -30
- package/core/page.js +43 -10
- package/core/pictureSlots.js +33 -0
- package/core/pictureWriters.js +343 -0
- package/core/plugins.js +64 -96
- package/core/sceneDelta.js +12 -4
- package/core/sceneMethods.js +2 -9
- package/core/services.js +1 -1
- package/core/shadowTypes.js +1 -1
- package/core/shadows.js +405 -0
- package/core/sharedPoint.js +5 -19
- package/core/stackFrames.js +16 -5
- package/core/stacks.js +6 -6
- package/core/startup.js +9 -11
- package/core/thingExplain.js +1 -1
- package/core/things.js +1 -1
- package/core/tier.js +1 -1
- package/core/util.js +1 -1
- package/core/validate.js +1 -1
- package/core/view.js +43 -0
- package/docs/AI.md +62 -58
- package/docs/API.md +15 -15
- package/docs/CODEMAP.md +36 -54
- package/docs/COMMANDS.md +28 -25
- package/docs/CONVENTIONS.md +36 -30
- package/docs/MIGRATING-0.4.md +93 -1
- package/docs/MIGRATING-0.6.md +126 -0
- package/docs/MIGRATING-0.7.md +39 -0
- package/docs/THREE.md +24 -22
- package/docs/api/assets.md +5 -3
- package/docs/api/audio.md +2 -2
- package/docs/api/budget.md +4 -0
- package/docs/api/characters.md +3 -1
- package/docs/api/collision.md +2 -2
- package/docs/api/engine.md +47 -20
- package/docs/api/events.md +2 -1
- package/docs/api/grids.md +8 -1
- package/docs/api/ground.md +1 -1
- package/docs/api/hud.md +3 -0
- package/docs/api/input.md +3 -2
- package/docs/api/interactions.md +3 -1
- package/docs/api/inventory.md +1 -2
- package/docs/api/level.md +0 -1
- package/docs/api/lightPool.md +1 -1
- package/docs/api/occlusion.md +5 -0
- package/docs/api/particles.md +6 -3
- package/docs/api/pickups.md +6 -0
- package/docs/api/post.md +5 -3
- package/docs/api/sky.md +12 -10
- package/docs/api/terrain.md +12 -6
- package/docs/api/terrainDraw.md +12 -0
- package/docs/api/tools.md +8 -7
- package/docs/api/triggers.md +2 -0
- package/docs/api/vegetation.md +7 -2
- package/docs/api/vegetationDraw.md +10 -0
- package/docs/api/water.md +6 -2
- package/docs/api/weather.md +5 -0
- package/docs/api/weatherDraw.md +10 -0
- package/docs/api/world.md +1 -1
- package/docs/recipes/01-new-game.md +19 -23
- package/docs/recipes/03-items-pickups.md +25 -4
- package/docs/recipes/05-props-bake.md +53 -37
- package/docs/recipes/06-clock-events.md +3 -3
- package/docs/recipes/07-flow-scenes-pause.md +12 -3
- package/docs/recipes/08-weather-sky.md +45 -57
- package/docs/recipes/09-materials-lights-models.md +185 -0
- package/docs/recipes/10-blender-level.md +2 -2
- package/docs/recipes/11-vehicles.md +3 -3
- package/docs/recipes/13-animation.md +13 -7
- package/docs/recipes/14-custom-module.md +7 -5
- package/docs/recipes/15-perf.md +3 -3
- package/docs/recipes/16-dev-bridge.md +22 -12
- package/docs/recipes/18-world.md +10 -8
- package/docs/recipes/19-shooting-picking.md +7 -5
- package/docs/recipes/20-content-actions-save.md +6 -2
- package/docs/recipes/21-camera.md +8 -3
- package/docs/recipes/23-ops.md +1 -1
- package/docs/recipes/26-ui-parts.md +35 -11
- package/docs/recipes/28-terrain.md +12 -12
- package/docs/recipes/29-grid.md +14 -5
- package/docs/recipes/30-templates.md +8 -3
- package/docs/recipes/31-audio.md +4 -4
- package/docs/recipes/32-action-game.md +18 -4
- package/docs/recipes/34-environment-lighting.md +102 -38
- package/docs/recipes/35-picture-from-reference.md +147 -0
- package/docs/recipes/36-sky-ground-plants.md +158 -0
- package/docs/recipes/{37-terrain-look-hooks.md → 37-terrain-hooks.md} +9 -13
- package/docs/recipes/38-environment-hooks.md +67 -0
- package/docs/recipes/40-scene.md +106 -27
- package/docs/recipes/42-terrain-shape.md +1 -1
- package/docs/recipes/{43-shader-patches-surface-looks.md → 43-shader-patches-surfaces.md} +66 -77
- package/docs/recipes/44-water-weather-hooks.md +191 -0
- package/docs/recipes/45-cascaded-shadows.md +121 -23
- package/docs/recipes/46-blender-art-route.md +17 -20
- package/docs/recipes/47-island-snow-backdrop.md +10 -12
- package/docs/recipes/49-game-module-contract.md +1 -1
- package/docs/recipes/50-own-renderer.md +3 -3
- package/docs/recipes/52-around-the-picture.md +181 -0
- package/docs/recipes/53-ground-up-close.md +12 -12
- package/docs/recipes/54-three-idioms.md +18 -18
- package/docs/recipes/55-mods-time-wrap.md +17 -5
- package/docs/recipes/56-webgpu-tsl.md +66 -23
- package/docs/recipes/57-control.md +39 -0
- package/docs/recipes/58-input.md +3 -0
- package/docs/recipes/59-depth-post-effects.md +5 -5
- package/docs/recipes/60-judge-the-picture.md +39 -24
- package/docs/recipes/61-deploy.md +27 -0
- package/docs/recipes/62-picture-code.md +244 -0
- package/docs/recipes/63-third-person-start.md +77 -0
- package/docs/recipes/64-particles.md +35 -0
- package/examples/action/.threedog/content-index.json +1 -1
- package/examples/action/GAMEMAP.md +7 -5
- package/examples/action/main.js +5 -4
- package/examples/action/models.js +12 -14
- package/examples/action/picture/index.js +13 -0
- package/examples/action/picture/lights.js +35 -0
- package/examples/action/picture/materials.js +8 -0
- package/examples/action/picture/palette.js +33 -0
- package/examples/plain-picture/.threedog/content-index.json +1 -0
- package/examples/plain-picture/FINDINGS.md +53 -0
- package/examples/plain-picture/GAMEMAP.md +90 -0
- package/examples/plain-picture/main.js +48 -0
- package/examples/plain-picture/picture/index.js +21 -0
- package/examples/plain-picture/picture/lights.js +54 -0
- package/examples/plain-picture/picture/materials.js +24 -0
- package/examples/plain-picture/picture/palette.js +16 -0
- package/examples/plain-picture/picture/sky.js +37 -0
- package/examples/pullable.json +31 -9
- package/examples/rc2d/GAMEMAP.md +8 -3
- package/examples/rc2d/README.md +11 -6
- package/examples/rc2d/main.js +25 -33
- package/examples/rc2d/picture/index.js +18 -0
- package/examples/rc2d/picture/lights.js +11 -0
- package/examples/rc2d/picture/materials.js +18 -0
- package/examples/rc2d/picture/palette.js +15 -0
- package/examples/rc2d/picture/post.js +11 -0
- package/examples/rc2d/rc2d.js +18 -28
- package/examples/sheepisland/.threedog/content-index.json +1 -1
- package/examples/sheepisland/GAMEMAP.md +13 -10
- package/examples/sheepisland/assets.js +2 -2
- package/examples/sheepisland/content/templates.js +1 -1
- package/examples/sheepisland/content/vegetation.js +3 -1
- package/examples/sheepisland/main.js +15 -9
- package/examples/sheepisland/{style/models.js → models.js} +13 -24
- package/examples/sheepisland/picture/index.js +20 -0
- package/examples/sheepisland/picture/lights.js +34 -0
- package/examples/sheepisland/picture/materials.js +61 -0
- package/examples/sheepisland/picture/palette.js +60 -0
- package/examples/sheepisland/picture/sky.js +20 -0
- package/examples/sheepisland/views.js +1 -1
- package/examples/styletest/.threedog/content-index.json +1 -1
- package/examples/styletest/GAMEMAP.md +15 -11
- package/examples/styletest/main.js +20 -30
- package/examples/styletest/models.js +29 -29
- package/examples/styletest/params.js +1 -4
- package/examples/styletest/picture/env.js +38 -0
- package/examples/styletest/picture/index.js +16 -0
- package/examples/styletest/picture/lights.js +9 -0
- package/examples/styletest/picture/materials.js +28 -0
- package/examples/styletest/picture/palette.js +22 -0
- package/examples/techniques/contact-shadows/README.md +22 -23
- package/examples/techniques/contact-shadows/contactShadows.js +32 -16
- package/examples/techniques/contact-shadows/main.js +20 -18
- package/examples/techniques/contact-shadows/picture/index.js +14 -0
- package/examples/techniques/contact-shadows/picture/lights.js +34 -0
- package/examples/techniques/contact-shadows/picture/materials.js +12 -0
- package/examples/techniques/contact-shadows/picture/palette.js +17 -0
- package/examples/techniques/day-night-grade/README.md +13 -16
- package/examples/techniques/day-night-grade/main.js +15 -25
- package/examples/techniques/day-night-grade/picture/index.js +20 -0
- package/examples/techniques/day-night-grade/picture/lights.js +45 -0
- package/examples/techniques/day-night-grade/picture/materials.js +15 -0
- package/examples/techniques/day-night-grade/picture/palette.js +59 -0
- package/examples/techniques/day-night-grade/picture/post.js +25 -0
- package/examples/techniques/day-night-grade/picture/sky.js +33 -0
- package/examples/techniques/interior-light/README.md +16 -13
- package/examples/techniques/interior-light/interiorLight.js +19 -17
- package/examples/techniques/interior-light/main.js +30 -67
- package/examples/techniques/interior-light/picture/index.js +24 -0
- package/examples/techniques/interior-light/picture/lights.js +52 -0
- package/examples/techniques/interior-light/picture/materials.js +13 -0
- package/examples/techniques/interior-light/picture/palette.js +32 -0
- package/examples/techniques/interior-light/picture/sky.js +40 -0
- package/examples/techniques/modular-building/README.md +4 -3
- package/examples/techniques/modular-building/kit.js +2 -2
- package/examples/techniques/modular-building/main.js +9 -17
- package/examples/techniques/modular-building/picture/index.js +17 -0
- package/examples/techniques/modular-building/picture/lights.js +26 -0
- package/examples/techniques/modular-building/picture/materials.js +13 -0
- package/examples/techniques/modular-building/picture/palette.js +23 -0
- package/examples/techniques/night-lights/README.md +15 -14
- package/examples/techniques/night-lights/main.js +20 -43
- package/examples/techniques/night-lights/nightLights.js +25 -21
- package/examples/techniques/night-lights/picture/index.js +18 -0
- package/examples/techniques/night-lights/picture/lights.js +44 -0
- package/examples/techniques/night-lights/picture/materials.js +15 -0
- package/examples/techniques/night-lights/picture/palette.js +34 -0
- package/examples/techniques/night-lights/picture/post.js +9 -0
- package/examples/techniques/night-lights/picture/sky.js +36 -0
- package/examples/techniques/outlines-and-rim/README.md +2 -2
- package/examples/techniques/outlines-and-rim/main.js +15 -38
- package/examples/techniques/outlines-and-rim/outlines.js +3 -3
- package/examples/techniques/outlines-and-rim/picture/index.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/lights.js +18 -0
- package/examples/techniques/outlines-and-rim/picture/materials.js +11 -0
- package/examples/techniques/outlines-and-rim/picture/palette.js +16 -0
- package/examples/techniques/outlines-and-rim/picture/post.js +10 -0
- package/examples/techniques/procedural-animation/README.md +5 -3
- package/examples/techniques/procedural-animation/main.js +9 -7
- package/examples/techniques/procedural-animation/picture/index.js +15 -0
- package/examples/techniques/procedural-animation/picture/lights.js +35 -0
- package/examples/techniques/procedural-animation/picture/materials.js +10 -0
- package/examples/techniques/procedural-animation/picture/palette.js +16 -0
- package/examples/techniques/procedural-animation/picture/sky.js +31 -0
- package/examples/techniques/procedural-animation/proceduralAnim.js +1 -1
- package/examples/techniques/procedural-surface/README.md +2 -0
- package/examples/techniques/procedural-surface/main.js +17 -55
- package/examples/techniques/procedural-surface/picture/index.js +14 -0
- package/examples/techniques/procedural-surface/picture/lights.js +18 -0
- package/examples/techniques/procedural-surface/picture/materials.js +34 -0
- package/examples/techniques/procedural-surface/picture/palette.js +15 -0
- package/examples/techniques/stylized-shading/README.md +13 -14
- package/examples/techniques/stylized-shading/main.js +11 -42
- package/examples/techniques/stylized-shading/picture/index.js +14 -0
- package/examples/techniques/stylized-shading/picture/lights.js +23 -0
- package/examples/techniques/stylized-shading/picture/materials.js +18 -0
- package/examples/techniques/stylized-shading/picture/palette.js +19 -0
- package/examples/techniques/stylized-shading/shading.js +2 -2
- package/examples/techniques/sun-and-key-light/README.md +20 -22
- package/examples/techniques/sun-and-key-light/keyLight.js +47 -29
- package/examples/techniques/sun-and-key-light/main.js +19 -63
- package/examples/techniques/sun-and-key-light/picture/index.js +13 -0
- package/examples/techniques/sun-and-key-light/picture/lights.js +33 -0
- package/examples/techniques/sun-and-key-light/picture/materials.js +9 -0
- package/examples/techniques/sun-and-key-light/picture/palette.js +29 -0
- package/examples/techniques/sun-and-key-light/picture/sky.js +16 -0
- package/examples/techniques/three-looks/README.md +21 -0
- package/examples/techniques/three-looks/main.js +58 -0
- package/examples/techniques/three-looks/picture/cartoon.js +23 -0
- package/examples/techniques/three-looks/picture/cinematic.js +27 -0
- package/examples/techniques/three-looks/picture/comic.js +27 -0
- package/examples/techniques/three-looks/picture/index.js +14 -0
- package/examples/techniques/three-looks/picture/sun.js +23 -0
- package/examples/techniques/wet-road/README.md +7 -4
- package/examples/techniques/wet-road/main.js +18 -38
- package/examples/techniques/wet-road/picture/index.js +17 -0
- package/examples/techniques/wet-road/picture/lights.js +57 -0
- package/examples/techniques/wet-road/picture/materials.js +16 -0
- package/examples/techniques/wet-road/picture/palette.js +24 -0
- package/examples/techniques/wet-road/picture/sky.js +46 -0
- package/examples/webgpu-tsl/GAMEMAP.md +9 -4
- package/examples/webgpu-tsl/README.md +13 -10
- package/examples/webgpu-tsl/main.js +30 -7
- package/examples/webgpu-tsl/picture/index.js +18 -0
- package/examples/webgpu-tsl/picture/lights.js +25 -0
- package/examples/webgpu-tsl/picture/materials.js +36 -0
- package/examples/webgpu-tsl/picture/palette.js +23 -0
- package/examples/webgpu-tsl/picture/post.js +16 -0
- package/examples/webgpu-tsl/picture/sky.js +30 -0
- package/examples/world/.threedog/content-index.json +1 -1
- package/examples/world/GAMEMAP.md +15 -12
- package/examples/world/art/humanoid.js +9 -13
- package/examples/world/art/index.js +2 -2
- package/examples/world/art/models.js +3 -4
- package/examples/world/art/shapes.js +2 -2
- package/examples/world/assets.js +2 -2
- package/examples/world/content/audio.js +1 -1
- package/examples/world/content/items.js +1 -1
- package/examples/world/content/props.js +1 -1
- package/examples/world/content/templates.js +1 -1
- package/examples/world/content/vegetation.js +1 -1
- package/examples/world/main.js +10 -10
- package/examples/world/models.js +17 -7
- package/examples/world/picture/index.js +20 -0
- package/examples/world/picture/lights.js +41 -0
- package/examples/world/picture/materials.js +34 -0
- package/examples/world/picture/palette.js +74 -0
- package/examples/world/picture/post.js +9 -0
- package/examples/world/picture/sky.js +39 -0
- package/index.d.ts +7 -16
- package/index.js +7 -7
- package/llms.txt +15 -13
- package/modules/ambience/Ambience.js +1 -1
- package/modules/calendar/Calendar.js +1 -1
- package/modules/calendar/index.js +1 -0
- package/modules/camera/FirstPersonCamera.js +1 -1
- package/modules/camera/FixedCamera.js +2 -2
- package/modules/camera/RtsCamera.js +1 -1
- package/modules/camera/common.js +7 -5
- package/modules/characters/Character.js +15 -10
- package/modules/characters/NPC.js +5 -5
- package/modules/characters/assetModel.js +5 -4
- package/modules/characters/index.js +28 -3
- package/modules/characters/movers/common.js +6 -1
- package/modules/characters/movers/manual.js +3 -0
- package/modules/characters/movers/support.js +25 -11
- package/modules/characters/npcSim.js +5 -1
- package/modules/characters/proceduralRig.js +18 -4
- package/modules/characters/useModel.js +2 -2
- package/modules/collision/Collision.js +4 -2
- package/modules/content/index.js +8 -0
- package/modules/content/models.js +56 -11
- package/modules/content/props.js +5 -3
- package/modules/content/rules.js +12 -4
- package/modules/content/templates.js +5 -3
- package/modules/gameplay/Interactions.js +91 -16
- package/modules/gameplay/Inventory.js +3 -3
- package/modules/gameplay/dialogueBox.js +1 -1
- package/modules/gameplay/dialogueBubbles.js +1 -1
- package/modules/gameplay/interactionPrompt.js +1 -1
- package/modules/gameplay/interactions.contract.js +1 -1
- package/modules/gameplay/inventoryOps.js +2 -2
- package/modules/gameplay/pickups.js +62 -24
- package/modules/gameplay/questLog.js +2 -2
- package/modules/grid/Layer.js +13 -0
- package/modules/grid/index.js +40 -11
- package/modules/grid/preview.js +24 -15
- package/modules/grid/tiles.js +15 -19
- package/modules/hlod/index.js +3 -2
- package/modules/hud/index.js +13 -0
- package/modules/hud/parts.js +9 -7
- package/modules/level/index.js +5 -4
- package/modules/lights/index.js +12 -8
- package/modules/music/Music.js +1 -1
- package/modules/particles/Particles.js +41 -20
- package/modules/particles/effect.js +21 -6
- package/modules/photo/Photo.js +11 -10
- package/modules/settings/Settings.js +7 -7
- package/modules/settings/apply.js +5 -5
- package/modules/settings/sections.js +2 -2
- package/modules/settings/strings.js +1 -1
- package/modules/sky/Sky.js +104 -89
- package/modules/sky/clouds.js +16 -17
- package/modules/sky/dome.js +100 -0
- package/modules/sky/domeLayers.js +5 -5
- package/modules/sky/environment.js +45 -169
- package/modules/sky/fog.js +5 -180
- package/modules/sky/frame.js +26 -90
- package/modules/sky/season.js +3 -3
- package/modules/sky/shader.js +35 -29
- package/modules/sky/skyModule.js +25 -22
- package/modules/sky/tint.js +9 -11
- package/modules/terrain/ChunkManager.js +29 -12
- package/modules/terrain/draw.js +154 -0
- package/modules/terrain/index.js +44 -66
- package/modules/terrain/terrainDefaults.js +2 -2
- package/modules/terrain/terrainEdit.js +1 -1
- package/modules/terrain/terrainGen.js +2 -2
- package/modules/triggers/index.js +10 -6
- package/modules/vegetation/Vegetation.js +58 -17
- package/modules/vegetation/draw.js +191 -0
- package/modules/vegetation/groundChunks.js +1 -1
- package/modules/vegetation/index.js +10 -10
- package/modules/water/Water.js +135 -88
- package/modules/water/surface.js +53 -53
- package/modules/weather/Weather.js +52 -17
- package/modules/weather/particles.js +13 -5
- package/modules/weather/shaders.js +1 -1
- package/modules/weather/weatherDraw.js +141 -0
- package/modules/world/World.js +2 -2
- package/modules/world/views.js +1 -1
- package/package.json +3 -2
- package/presets.js +2 -2
- package/render/PostFX.js +199 -41
- package/render/backend.js +52 -6
- package/render/cascades.js +195 -0
- package/render/cascades.tsl.js +96 -0
- package/render/daylight.js +39 -0
- package/render/detail.js +5 -5
- package/render/effects.js +41 -26
- package/render/fx/cel.tsl.js +42 -0
- package/render/fx/index.js +7 -5
- package/render/fx/patchNodes.tsl.js +1 -1
- package/render/fx/postWebGPU.tsl.js +30 -7
- package/render/fx/sky.tsl.js +19 -92
- package/render/fx/water.tsl.js +1 -1
- package/render/layers.js +14 -0
- package/render/lighting.js +6 -5
- package/render/lightmap.js +142 -0
- package/render/lights.js +23 -201
- package/render/materials.js +44 -160
- package/render/neutral.js +23 -0
- package/render/occlusion.js +184 -0
- package/render/ownFrame.js +1 -1
- package/render/patches.js +34 -29
- package/render/postWebGL.js +11 -3
- package/render/probes.js +179 -122
- package/render/slots.js +4 -4
- package/render/terms.js +53 -101
- package/render/uniformDecl.js +1 -1
- package/types/core.d.ts +333 -296
- package/types/gameplay.d.ts +65 -26
- package/types/generated/core/Audio.d.ts +1 -1
- package/types/generated/core/DebugOverrides.d.ts +14 -6
- package/types/generated/core/Input.d.ts +9 -2
- package/types/generated/core/page.d.ts +9 -2
- package/types/generated/modules/grid/Layer.d.ts +8 -0
- package/types/generated/modules/grid/index.d.ts +29 -5
- package/types/generated/modules/particles/Particles.d.ts +13 -6
- package/types/generated/modules/sky/Sky.d.ts +85 -18
- package/types/generated/modules/sky/skyModule.d.ts +1 -1
- package/types/generated/modules/water/Water.d.ts +50 -3
- package/types/generated/modules/weather/Weather.d.ts +33 -3
- package/types/generated/modules/weather/weatherDraw.d.ts +11 -0
- package/types/generated/modules/world/World.d.ts +2 -2
- package/types/generated/render/PostFX.d.ts +53 -10
- package/types/generated/render/lighting.d.ts +29 -0
- package/types/generated/render/materials.d.ts +19 -44
- package/types/generated/render/occlusion.d.ts +13 -0
- package/types/physics.d.ts +5 -3
- package/types/tsl.d.ts +8 -0
- package/types/world.d.ts +376 -57
- package/ui/Focus.js +12 -2
- package/ui/LoadingScreen.js +2 -2
- package/ui/Parts.js +8 -4
- package/ui/UI.js +10 -10
- package/ui/cursor.js +1 -1
- package/ui/theme.js +33 -27
- package/ui/touchPart.js +1 -1
- package/core/look/coreParts.js +0 -219
- package/core/look/part.js +0 -253
- package/core/look/points.js +0 -255
- package/core/look/report.js +0 -96
- package/core/look/shadowPart.js +0 -63
- package/core/look/state.js +0 -45
- package/core/look/write.js +0 -70
- package/core/styleParts.js +0 -114
- package/docs/api/style.md +0 -136
- package/docs/api/terrainLook.md +0 -10
- package/docs/api/vegetationLook.md +0 -10
- package/docs/api/weatherLook.md +0 -10
- package/docs/recipes/09-style.md +0 -218
- package/docs/recipes/35-style-from-reference.md +0 -153
- package/docs/recipes/36-sky-ground-plant-looks.md +0 -118
- package/docs/recipes/38-environment-look-hooks.md +0 -99
- package/docs/recipes/41-thing-registry.md +0 -97
- package/docs/recipes/44-water-weather-look-hooks.md +0 -144
- package/docs/recipes/48-make-material.md +0 -75
- package/docs/recipes/52-look.md +0 -282
- package/examples/action/look.js +0 -5
- package/examples/sheepisland/style/index.js +0 -79
- package/examples/styletest/look.js +0 -11
- package/examples/techniques/day-night-grade/dayNightGrade.js +0 -76
- package/examples/webgpu-tsl/tslScene.js +0 -75
- package/examples/world/style/index.js +0 -61
- package/examples/world/style/plugins/10-bloom.js +0 -5
- package/modules/sky/cascades.js +0 -186
- package/modules/sky/cascades.tsl.js +0 -82
- package/modules/sky/look.js +0 -54
- package/modules/sky/lookFog.js +0 -76
- package/modules/sky/lookShadow.js +0 -62
- package/modules/sky/lookSky.js +0 -169
- package/modules/sky/shadow.js +0 -98
- package/modules/terrain/look.js +0 -83
- package/modules/terrain/lookGround.js +0 -66
- package/modules/vegetation/look.js +0 -119
- package/modules/vegetation/lookWind.js +0 -98
- package/modules/water/look.js +0 -91
- package/modules/water/surfaceDefaults.js +0 -3
- package/modules/weather/look.js +0 -74
- package/modules/weather/weatherLook.js +0 -135
- package/render/lookGlow.js +0 -139
- package/render/lookSurface.js +0 -224
- package/render/postLook.js +0 -164
- package/render/surface.js +0 -105
- package/types/generated/modules/weather/weatherLook.d.ts +0 -12
- package/types/style.d.ts +0 -671
|
@@ -4,21 +4,20 @@
|
|
|
4
4
|
// The mover owns position: only the mover (movers/) changes a character's position inside move(); other systems (pathfinding, triggers, vehicles, loading)
|
|
5
5
|
// request movement via placeAt (teleport), move (direction), enter / exit (vehicles).
|
|
6
6
|
// Characters backed by a world record (the player, recordId = 'player') write position and motion state back to the record after every move / placeAt / enter / exit;
|
|
7
|
-
// the record is saved, world splits near/far by it, the model is just its
|
|
7
|
+
// the record is saved, world splits near/far by it, the model is just its picture.
|
|
8
8
|
// Radius and step height default to engine.movement (the single source of "can walk through" parameters); passing radius / stepHeight overrides it for this character only.
|
|
9
9
|
// How to walk is decided by the mover (movers/: 'simple' default, 'rapier' character controller); feel parameters are identical for both.
|
|
10
10
|
// The procedural body (capsule, rig read from a model asset, limb swing) is in proceduralRig.js; loading a body by asset name in assetModel.js.
|
|
11
11
|
import { engineOwned } from '../../core/things.js';
|
|
12
12
|
import * as THREE from 'three';
|
|
13
|
-
import { xzOf } from '../../core/math.js';
|
|
14
|
-
import { placeY } from '../../core/ground.js';
|
|
13
|
+
import { xzOf, yOf } from '../../core/math.js';
|
|
15
14
|
import { warnOnce, warnMissing, DEV } from '../../core/validate.js';
|
|
16
15
|
import { reportError } from '../../core/errors.js';
|
|
17
16
|
import { simpleMover } from './movers/simple.js';
|
|
18
17
|
import { rapierMover } from './movers/rapier.js';
|
|
19
18
|
import { manualMover } from './movers/manual.js';
|
|
20
19
|
import { moveStacks, stat, jumpOf, WATER_MODES } from './movers/common.js';
|
|
21
|
-
import { stateOf, detach, registry } from './movers/support.js';
|
|
20
|
+
import { stateOf, detach, registry, placeAtHeight } from './movers/support.js';
|
|
22
21
|
import { loadAssetModel, buildNow } from './assetModel.js';
|
|
23
22
|
import { NO_CHARACTER, capsule, useRig, animateRig, rigFromObject, tintParts } from './proceduralRig.js';
|
|
24
23
|
import { walkTo } from './walkTo.js';
|
|
@@ -38,7 +37,7 @@ export class Character {
|
|
|
38
37
|
* @param engine
|
|
39
38
|
* @param o model: the body, one path for all: a model asset name (a procedural builder from an asset pack, or a GLB name), or what
|
|
40
39
|
* engine.assets.model() returned; without model and rig a gray capsule (warned once). rig: a ready body (proceduralRig.js format)
|
|
41
|
-
* colors: { body, skin, legs, hair } per-character part colors (meshes marked userData.part
|
|
40
|
+
* colors: { body, skin, legs, hair } per-character part colors (meshes marked userData.part; a capsule takes colors.body)
|
|
42
41
|
* speed walk speed, runSpeed run speed (m/s), radius collision radius
|
|
43
42
|
* water what water deeper than swimDepth does: 'swim' (default, floats, state 'swim') | 'block' (never enters it) | 'wade' (walks the
|
|
44
43
|
* bottom) | (character, { depth, x, z }) => one of those (per spot: a swim skill, a boat, depth); character:water fires on each change.
|
|
@@ -114,7 +113,7 @@ export class Character {
|
|
|
114
113
|
const now = typeof model === 'string' ? buildNow(engine, model) : model;
|
|
115
114
|
if (now) { this._useModel(now, clips, animation); return; }
|
|
116
115
|
if (!rig && !model) warnOnce(NO_CHARACTER);
|
|
117
|
-
useRig(this, rig || capsule(colors.body
|
|
116
|
+
useRig(this, rig || capsule(colors.body, engine));
|
|
118
117
|
if (model) this._whenReady = loadAssetModel(this, model, m => this._useModel(m, clips, animation));
|
|
119
118
|
}
|
|
120
119
|
/** A model object with userData.rig is a procedural body (limb swing); anything else animates by its clips */
|
|
@@ -197,11 +196,16 @@ export class Character {
|
|
|
197
196
|
/** The character's three.js root object (= root): add children, set visible, scale on it */
|
|
198
197
|
get object() { return this.root; }
|
|
199
198
|
addTo(scene = this.engine.scene) { scene.add(engineOwned('characters', this.root)); return this; }
|
|
200
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* Place at a position (Vector3 / Object3D / [x, y, z] / { x, z }). With a y it stands on what a character at that height stands on: the floor there, or a
|
|
201
|
+
* registered support within step height above it, so a place under a deck stays under it. With { x, z } it stands on the highest support there, else the ground.
|
|
202
|
+
*/
|
|
201
203
|
placeAt(position) {
|
|
202
|
-
const [x, z] = xzOf(position);
|
|
203
|
-
this.root.position.set(x,
|
|
204
|
-
detach(this);
|
|
204
|
+
const [x, z] = xzOf(position), at = placeAtHeight(this.engine, 'character.placeAt()', x, z, yOf(position), this.stepHeight, this.root.position.y);
|
|
205
|
+
this.root.position.set(x, at.y, z);
|
|
206
|
+
detach(this);
|
|
207
|
+
// ground is a safe spot. A support may be unsafe or moving, which only a step can tell: the next mover step applies the rule in endMove
|
|
208
|
+
if (!at.on) (this.safeGround ??= new THREE.Vector3()).copy(this.root.position);
|
|
205
209
|
this._store(); return this;
|
|
206
210
|
}
|
|
207
211
|
/** Write position and motion state back to the world record (only if recordId is set; saveMotion writes into the record without allocating) @internal */
|
|
@@ -282,6 +286,7 @@ export class Character {
|
|
|
282
286
|
this.exit();
|
|
283
287
|
this.anim?.dispose();
|
|
284
288
|
for (const m of Object.values(this._movers)) m.dispose?.();
|
|
289
|
+
this.engine.characters?._capsules.delete(this._rig?.capsule);
|
|
285
290
|
this.engine.remove(this.root);
|
|
286
291
|
}
|
|
287
292
|
/**
|
|
@@ -37,8 +37,8 @@ import { warnOnce, fmt, DEV } from '../../core/validate.js';
|
|
|
37
37
|
import { readParams, keysSchema } from '../../core/params.js';
|
|
38
38
|
import { NpcAvoid } from './npcAvoid.js';
|
|
39
39
|
import { parseClock } from '../../core/dayTime.js';
|
|
40
|
-
import { xzOf } from '../../core/math.js';
|
|
41
|
-
import {
|
|
40
|
+
import { xzOf, yOf } from '../../core/math.js';
|
|
41
|
+
import { placeAtHeight } from './movers/support.js';
|
|
42
42
|
import { stopIndex, timeOfDay, npcChannel } from './npcSim.js';
|
|
43
43
|
import { Behaviors } from './behaviors.js';
|
|
44
44
|
import { codedError } from '../../core/errorHints.js';
|
|
@@ -109,8 +109,8 @@ export class NPC {
|
|
|
109
109
|
placeAt(position) {
|
|
110
110
|
const e = this._m.engine, W = this._m.world, rec = this.data; if (!rec) return this;
|
|
111
111
|
const [x, z] = xzOf(position), ch = this.character;
|
|
112
|
-
if (ch) ch.placeAt(
|
|
113
|
-
W.move(this.id, { x, y: ch ? ch.root.position.y :
|
|
112
|
+
if (ch) ch.placeAt(position);
|
|
113
|
+
W.move(this.id, { x, y: ch ? ch.root.position.y : placeAtHeight(e, `npc.placeAt() (${this.id})`, x, z, yOf(position), rec.look?.stepHeight ?? e.movement.stepHeight, rec.position.y).y, z });
|
|
114
114
|
rec.nav.path = null; rec.nav.repath = 0;
|
|
115
115
|
return this;
|
|
116
116
|
}
|
|
@@ -260,7 +260,7 @@ export class NPCManager {
|
|
|
260
260
|
} else {
|
|
261
261
|
const i = stopIndex(sched, timeOfDay(e)), [x, z] = xzOf(position ?? (i != null ? sched[i] : { x: 0, z: 0 }));
|
|
262
262
|
const nav = { stop: null, path: null, repath: 0 };
|
|
263
|
-
W.add({ id, kind: KIND, position: [x,
|
|
263
|
+
W.add({ id, kind: KIND, position: [x, placeAtHeight(e, `npcs.${id}`, x, z, undefined, 0, 0).y, z], ...def, state: 'idle', busy: false, nav, motion: null }, { initial });
|
|
264
264
|
}
|
|
265
265
|
return this._handle(id);
|
|
266
266
|
}
|
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
import * as THREE from 'three';
|
|
8
8
|
import { warnOnce } from '../../core/validate.js';
|
|
9
9
|
import { fmt } from '../../core/opsCheck.js';
|
|
10
|
-
import {
|
|
10
|
+
import { neutralMaterial } from '../../render/neutral.js';
|
|
11
11
|
import { codedError } from '../../core/errorHints.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Build a procedural model asset now (synchronously) when `name` is a registered builder; null when it is a file model, unknown, or the
|
|
15
|
-
* builder is async (those load through loadAssetModel). The builder gets this = { palette:
|
|
15
|
+
* builder is async (those load through loadAssetModel). The builder gets this = { palette: engine.assets.palette, engine } like any generator in the manifest.
|
|
16
16
|
*/
|
|
17
17
|
export function buildNow(engine, name) {
|
|
18
18
|
const build = engine.assets.builder(name);
|
|
19
19
|
if (!build) return null;
|
|
20
|
-
const v = build.call({ palette: engine.
|
|
20
|
+
const v = build.call({ palette: engine.assets.palette, engine });
|
|
21
21
|
if (!v || typeof v.then === 'function') return null;
|
|
22
|
-
if (v.isBufferGeometry) return new THREE.Mesh(v,
|
|
22
|
+
if (v.isBufferGeometry) return new THREE.Mesh(v, neutralMaterial('character', { vertexColors: !!v.attributes.color }));
|
|
23
23
|
if (!v.name) v.name = name;
|
|
24
24
|
return v;
|
|
25
25
|
}
|
|
@@ -48,6 +48,7 @@ export function loadAssetModel(ch, name, use) {
|
|
|
48
48
|
if (m.name === 'placeholder' && e.loading.get(name, 'model')?.phase === 'failed') { e.remove(m); fail('load failed'); return; }
|
|
49
49
|
const rig = ch._rig; // drop the placeholder body and the joint properties it put on the character
|
|
50
50
|
for (const k in rig.joints || {}) if (ch[k] === rig.joints[k]) delete ch[k];
|
|
51
|
+
e.characters?._capsules.delete(rig.capsule);
|
|
51
52
|
e.remove(rig.root);
|
|
52
53
|
ch._rig = ch.hips = ch.head = null; ch.limbs = [];
|
|
53
54
|
use(m);
|
|
@@ -23,6 +23,8 @@ import { moveStacks } from './movers/common.js';
|
|
|
23
23
|
import { DEV_STRINGS, STRINGS, validControl } from './playerStrings.js';
|
|
24
24
|
import { footstepSynth, stepSound } from './footsteps.js';
|
|
25
25
|
import { xzOf } from '../../core/math.js';
|
|
26
|
+
import { isEngineMade } from '../../render/patches.js';
|
|
27
|
+
import { capsuleDefault, capsuleMaterial } from './proceduralRig.js';
|
|
26
28
|
export { Character, NPC };
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -52,14 +54,14 @@ function solvePath(e, from, to, o) {
|
|
|
52
54
|
return detailed ? res : res.path;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
const CHARACTERS_PARAMS = keysSchema(['npcs', 'npcTiers']);
|
|
57
|
+
const CHARACTERS_PARAMS = keysSchema(['npcs', 'npcTiers', 'animation']);
|
|
56
58
|
|
|
57
59
|
export function characters(opts = {}) {
|
|
58
60
|
readParams('characters', CHARACTERS_PARAMS, opts);
|
|
59
|
-
const { npcs = true, npcTiers } = opts;
|
|
61
|
+
const { npcs = true, npcTiers, animation } = opts;
|
|
60
62
|
// the player's per-step drive / per-frame animation: set by createPlayer, run by this module's own fixed / frame hooks (not engine.onFixed), so a game
|
|
61
63
|
// onFixed sees the same player position whether it was registered before or after createPlayer (phase 'early' = before the move, 'late' = after)
|
|
62
|
-
let mgr = null, paths = null, disposePlayer = null, animatePlayer = null;
|
|
64
|
+
let mgr = null, paths = null, disposePlayer = null, animatePlayer = null, material = null;
|
|
63
65
|
return {
|
|
64
66
|
// before rigid: the player's move this step is in the physics step that follows (as when control was an onFixed)
|
|
65
67
|
name: 'characters', type: 'actor', params: CHARACTERS_PARAMS, options: opts, label: 'Characters', before: ['rigid'], noSkip: 'fixed only flushes path requests; schedules read the calendar clock', optional: ['cameraRig', 'calendar', 'interactions', 'dialogue', 'nav', 'collision', 'rigid', 'world'],
|
|
@@ -76,11 +78,34 @@ export function characters(opts = {}) {
|
|
|
76
78
|
if (npcs) { mgr = new NPCManager(e, ctx.track); e.npcs = mgr; if (npcTiers) mgr.tiers(npcTiers); }
|
|
77
79
|
else if (npcTiers) throw codedError('module-params', 'characters({ npcTiers }) needs NPCs: drop npcs: false, or drop npcTiers');
|
|
78
80
|
paths = new AsyncPaths(e);
|
|
81
|
+
const share = m => { e.assets.shared.add(m); return m; }; // every capsule draws with it: removing one character must not dispose it
|
|
79
82
|
// control (core/control.js) finds a held character by id: the player, else an NPC's model (null while it is far)
|
|
80
83
|
e.control.resolveWith(id => (id === PLAYER ? e.player : mgr?.character(id)) ?? null);
|
|
81
84
|
ctx.track(e.events.on('ground:change', b => paths.dropTiles(b))); // dug or raised ground: resample the path rasters there
|
|
82
85
|
ctx.track(e.events.on('level:loaded', () => paths.tiles.clear())); // another level: none of the cached rasters describe it
|
|
83
86
|
const api = {
|
|
87
|
+
/** @internal characters({ animation }): what every model's Animator starts from (useModel.js) */
|
|
88
|
+
_animation: animation,
|
|
89
|
+
/** @internal live capsule mesh -> its colors.body (undefined: none), what a swap of .material walks */
|
|
90
|
+
_capsules: new Map(),
|
|
91
|
+
/**
|
|
92
|
+
* The three.js material of every placeholder capsule. Set it to swap the look of all of them at once; it is used as given, with no patches added.
|
|
93
|
+
* A character with colors.body draws with a copy of it in that color. A model's own materials are the model's: this never touches them.
|
|
94
|
+
* @example engine.characters.material = new THREE.MeshToonMaterial({ color: 0xd9a066 });
|
|
95
|
+
* @type {THREE.Material}
|
|
96
|
+
*/
|
|
97
|
+
get material() { return (material ??= share(capsuleDefault())); },
|
|
98
|
+
set material(m) {
|
|
99
|
+
if (!m?.isMaterial) throw codedError('character-option', `engine.characters.material takes a three.js material, got ${m}. Example: engine.characters.material = new THREE.MeshStandardMaterial({ color: 0xd9a066 })`);
|
|
100
|
+
const old = api.material;
|
|
101
|
+
if (m === old) return;
|
|
102
|
+
material = share(m);
|
|
103
|
+
for (const [mesh, color] of api._capsules) {
|
|
104
|
+
if (mesh.material !== old) mesh.material.dispose(); // the copy in a character's own color
|
|
105
|
+
mesh.material = capsuleMaterial(m, color);
|
|
106
|
+
}
|
|
107
|
+
if (isEngineMade(old)) old.dispose(); // a material the game gave stays the game's
|
|
108
|
+
},
|
|
84
109
|
/**
|
|
85
110
|
* Find a spawn point: spiral outward from position (default origin) for walkable ground (no obstacles, gentle slope) that is not in water. Returns a
|
|
86
111
|
* Vector3 (y is ground height).
|
|
@@ -136,5 +136,10 @@ export function finish(c, dt) {
|
|
|
136
136
|
if (c.state !== c._stateMark) warnOnce(STATE_WRITTEN);
|
|
137
137
|
const base = c.swimming ? 'swim' : !c.grounded ? (c.vy > 0 ? 'jump' : 'fall') : sp > stat(c, 'speed') * 1.3 ? 'run' : sp > 0.4 ? 'walk' : 'idle';
|
|
138
138
|
// the game's states hook adds its own (crouch, climb, glide, dash...) on top of the built-in ones without taking the mover over; null keeps base
|
|
139
|
-
|
|
139
|
+
ownState(c, base, sp);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** @internal the state after a mover's step: the game's states hook, or base when it returns null */
|
|
143
|
+
export function ownState(c, base, speed) {
|
|
144
|
+
c.state = c._stateMark = (c.states && c.states(c, { base, speed, grounded: c.grounded, swimming: c.swimming, vy: c.vy, water: WATER_KEY.get(c) ?? null })) || base;
|
|
140
145
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// position. 'manual' is the takeover level for the position itself, so a hand-written controller (a platformer's own physics) keeps the
|
|
6
6
|
// platform, safe-ground and fall behaviour without fighting the built-in integration.
|
|
7
7
|
import { groundAt, beginMove, endMove, stateOf } from './support.js';
|
|
8
|
+
import { ownState } from './common.js';
|
|
8
9
|
|
|
9
10
|
/** Create the 'manual' mover (c is the character) */
|
|
10
11
|
export function manualMover(c) {
|
|
@@ -15,6 +16,8 @@ export function manualMover(c) {
|
|
|
15
16
|
const p = c.root.position, g = groundAt(c, p.x, p.z, p.y);
|
|
16
17
|
c.grounded = p.y <= g + 1e-3; c.swimming = false;
|
|
17
18
|
endMove(c, dt, c.grounded ? stateOf(c).hit : null, 'ground');
|
|
19
|
+
// only with a hook: without one the game owns the state too. A ladder is manual plus states, so the climb clip plays with no gravity to fight
|
|
20
|
+
if (c.states) ownState(c, c.grounded ? 'idle' : 'fall', 0);
|
|
18
21
|
},
|
|
19
22
|
};
|
|
20
23
|
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// platform carry, placeAt and a load all move the position outside the mover, so the mover compares with where it left the character (exact).
|
|
10
10
|
import * as THREE from 'three';
|
|
11
11
|
import { codedError } from '../../../core/errorHints.js';
|
|
12
|
+
import { placeY } from '../../../core/ground.js';
|
|
12
13
|
|
|
13
14
|
const REG = new WeakMap(); // engine -> { list: Map<id, entry>, riders: Set<character> }
|
|
14
15
|
const STATE = new WeakMap(); // character -> per-character support state (private: games read character.support / safeGround)
|
|
@@ -66,18 +67,31 @@ function topAt(entry, x, z) {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/**
|
|
69
|
-
* @internal
|
|
70
|
-
* above y
|
|
70
|
+
* @internal What stands at (x, z): { y, on } with on the support that won, or null. With a height y: engine.surface plus every registered support whose
|
|
71
|
+
* top is within `step` above y, higher ones are passed under. Without y (undefined): the highest support top, so a placement on a boat at sea stands on
|
|
72
|
+
* the deck and not on the sea floor. y may be -Infinity beyond terrain({ shape }). The one rule for walking, placing and data-only NPCs: one place, one answer.
|
|
71
73
|
*/
|
|
72
|
-
export function
|
|
73
|
-
|
|
74
|
-
let h = e.surface(x, z, y); s.hit = null;
|
|
74
|
+
export function standAt(e, x, z, y, step) {
|
|
75
|
+
let h = e.surface(x, z, y), on = null;
|
|
75
76
|
const R = REG.get(e);
|
|
76
77
|
if (R?.list.size) for (const en of R.list.values()) {
|
|
77
78
|
const t = topAt(en, x, z);
|
|
78
|
-
if (t != null && t <= y +
|
|
79
|
+
if (t != null && t > h && (y === undefined || t <= y + step + 1e-3)) { h = t; on = en; }
|
|
79
80
|
}
|
|
80
|
-
return h;
|
|
81
|
+
return { y: h, on };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** @internal Ground height under (x, z) for a character at height y (standAt). Sets the state's `hit` to the support that won (or null) */
|
|
85
|
+
export function groundAt(c, x, z, y) {
|
|
86
|
+
const r = standAt(c.engine, x, z, y, c.stepHeight);
|
|
87
|
+
stateOf(c).hit = r.on;
|
|
88
|
+
return r.y;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** @internal standAt for a place-it-here entry: off the ground it fails the way placeY does (dev throws with the fix, release keeps fallback) */
|
|
92
|
+
export function placeAtHeight(e, who, x, z, y, step, fallback) {
|
|
93
|
+
const r = standAt(e, x, z, y, step);
|
|
94
|
+
return r.y !== -Infinity ? r : { y: placeY(e, who, x, z, y, fallback), on: null };
|
|
81
95
|
}
|
|
82
96
|
|
|
83
97
|
/**
|
|
@@ -124,7 +138,7 @@ export function beginMove(c) {
|
|
|
124
138
|
export function endMove(c, dt, hit, ground = 'ground') {
|
|
125
139
|
const s = stateOf(c), p = c.root.position, R = registry(c.engine);
|
|
126
140
|
s.vel.copy(s.acc).divideScalar(dt > 0 ? dt : 1); s.acc.set(0, 0, 0);
|
|
127
|
-
const now = c.grounded && !c.swimming ? hit : null;
|
|
141
|
+
const now = c.grounded && !c.swimming ? hit : null, landed = !!now && now !== s.on;
|
|
128
142
|
if (now !== s.on) {
|
|
129
143
|
if (s.on) leave(c);
|
|
130
144
|
if (now) { s.on = now; now.object.updateWorldMatrix(true, false); s.m.copy(now.object.matrixWorld); R.riders.add(c); s.inherit.set(0, 0); }
|
|
@@ -134,8 +148,8 @@ export function endMove(c, dt, hit, ground = 'ground') {
|
|
|
134
148
|
v.kind = c.swimming ? 'water' : s.on ? 'platform' : c.grounded ? ground : null;
|
|
135
149
|
v.object = s.on?.object ?? null; v.id = s.on?.id ?? null; v.safe = s.on ? s.on.safe : v.kind !== 'water';
|
|
136
150
|
v.velocity.x = s.vel.x; v.velocity.y = s.vel.y; v.velocity.z = s.vel.z;
|
|
137
|
-
// safe spot: standing still on something that is not moving and not marked unsafe
|
|
138
|
-
if (c.grounded && !c.swimming && v.safe && s.vel.lengthSq() < 1e-8) (c.safeGround ??= new THREE.Vector3()).copy(p);
|
|
151
|
+
// safe spot: standing still on something that is not moving and not marked unsafe. Not on the landing step: nothing has carried the rider yet, so a moving platform still reads as speed 0
|
|
152
|
+
if (c.grounded && !c.swimming && v.safe && !landed && s.vel.lengthSq() < 1e-8) (c.safeGround ??= new THREE.Vector3()).copy(p);
|
|
139
153
|
fallCheck(c, s);
|
|
140
154
|
(s.last ??= new THREE.Vector3()).copy(p);
|
|
141
155
|
}
|
|
@@ -151,7 +165,7 @@ function fallCheck(c, s) {
|
|
|
151
165
|
const ev = { character: c, safe: c.safeGround ? c.safeGround.clone() : null, prevented: false, preventDefault() { this.prevented = true; } };
|
|
152
166
|
c.engine.events.emit('character:fall', ev);
|
|
153
167
|
if (ev.prevented) return;
|
|
154
|
-
// the exact spot, not placeAt:
|
|
168
|
+
// the exact spot, not placeAt: a platform that was under this spot may have moved away, and placeAt would land on the ground below it
|
|
155
169
|
if (c.safeGround) c.root.position.copy(c.safeGround);
|
|
156
170
|
detach(c); c.velocity.set(0, 0); c.vy = 0; c._push = 0; c.grounded = true;
|
|
157
171
|
s.fell = false;
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// as if it had kept running.
|
|
7
7
|
// See the top of NPC.js for record fields.
|
|
8
8
|
|
|
9
|
+
import { standAt } from './movers/support.js';
|
|
10
|
+
|
|
9
11
|
/** Fixed steps an NPC waits for a findPathAsync answer before asking again (answers normally land 4 steps later; a long queue adds perStep batches) */
|
|
10
12
|
const PATH_WAIT = 300;
|
|
11
13
|
|
|
@@ -78,7 +80,9 @@ export function settle(e, W, rec, x, z, moving) {
|
|
|
78
80
|
noteState(e, rec, moving ? 'walk' : 'idle');
|
|
79
81
|
// NPC of another level: this level's ground height is meaningless for it, keep its y
|
|
80
82
|
const here = rec.zone == null || W.zone == null || rec.zone === W.zone;
|
|
81
|
-
|
|
83
|
+
// the same rule the model uses (support.js standAt), from the height it is at: without it an NPC on a deck or an upper floor dropped to the ground in the data
|
|
84
|
+
const y = here ? standAt(e, x, z, p.y, rec.look?.stepHeight ?? e.movement.stepHeight).y : p.y;
|
|
85
|
+
W.move(rec.id, { x, y: y === -Infinity ? p.y : y, z });
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
/**
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// A model asset carries the same thing as plain data by object NAME in root.userData.rig: names, not references, because userData survives
|
|
5
5
|
// clone and GLB export and object references do not; so a procedural builder and a baked / hand-made GLB with those names animate the same way.
|
|
6
6
|
import * as THREE from 'three';
|
|
7
|
-
import {
|
|
8
|
-
import { copyPatches } from '../../render/patches.js';
|
|
7
|
+
import { neutralMaterial } from '../../render/neutral.js';
|
|
8
|
+
import { copyPatches, isEngineMade, markEngineMade } from '../../render/patches.js';
|
|
9
9
|
import { warnOnce } from '../../core/validate.js';
|
|
10
10
|
|
|
11
11
|
/** Warned once when no model gives the character a body */
|
|
@@ -45,13 +45,27 @@ export function tintParts(root, colors) {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/** The gray every capsule is until the game sets engine.characters.material (colors.body gives one capsule a copy in its own color) @internal */
|
|
49
|
+
export const capsuleDefault = () => neutralMaterial('character', { color: 0x8a8a8a });
|
|
50
|
+
|
|
51
|
+
/** A capsule's material: the shared one, or a copy of it in the character's own color (a material without .color has nothing to tint) @internal */
|
|
52
|
+
export function capsuleMaterial(base, color) {
|
|
53
|
+
if (color == null) return base;
|
|
54
|
+
const m = copyPatches(base, base.clone());
|
|
55
|
+
m.color?.set(color);
|
|
56
|
+
if (isEngineMade(base)) markEngineMade(m);
|
|
57
|
+
return m;
|
|
58
|
+
}
|
|
59
|
+
|
|
48
60
|
/** Neutral placeholder when no model gives a body: one gray capsule, no limbs (body shapes belong to asset packs) */
|
|
49
61
|
export function capsule(color, engine) {
|
|
50
62
|
const body = new THREE.Group(); body.position.y = 0.85;
|
|
51
|
-
|
|
63
|
+
// new Character() also works without the characters module: then this capsule has no shared material to take
|
|
64
|
+
const m = new THREE.Mesh(new THREE.CapsuleGeometry(0.3, 1.0, 4, 12).translate(0, -0.05, 0), capsuleMaterial(engine.characters?.material ?? capsuleDefault(), color));
|
|
65
|
+
engine.characters?._capsules.set(m, color); // not the scene: a character is drawn only after addTo, and a swap must reach it before that too
|
|
52
66
|
m.castShadow = true; body.add(m);
|
|
53
67
|
const root = new THREE.Group(); root.add(body);
|
|
54
|
-
return { root, body };
|
|
68
|
+
return { root, body, capsule: m };
|
|
55
69
|
}
|
|
56
70
|
|
|
57
71
|
/** Put a rig under the character root and remember its parts */
|
|
@@ -16,7 +16,7 @@ export function useModel(ch, model, clips, animation) {
|
|
|
16
16
|
const have = model.userData.animations || [], map = engine.assets.mapping(model), mapped = map?.states || {};
|
|
17
17
|
for (const [st, clip] of Object.entries(DEFAULT_CLIPS)) if (!mapped[st] && findClip(have, clip)) states[st] = { clip };
|
|
18
18
|
for (const [st, clip] of Object.entries(clips || {})) states[st] = { clip };
|
|
19
|
-
// the model's own mapping (fade, transitions) beats the
|
|
20
|
-
ch.anim = engine.assets.animate(model, { ...engine.
|
|
19
|
+
// the model's own mapping (fade, transitions) beats characters({ animation }), the default for every character; the game's per-character config beats both
|
|
20
|
+
ch.anim = engine.assets.animate(model, { ...engine.characters?._animation, ...map, states, ...(animation || {}) });
|
|
21
21
|
ch.anim.afterPose = dt => ch._firePose(dt); // a mixer pose is applied inside the Animator's update, so the Animator tells us when it is done
|
|
22
22
|
}
|
|
@@ -24,9 +24,11 @@ export class Collision {
|
|
|
24
24
|
/**
|
|
25
25
|
* maxClimb: max walkable slope (height diff / horizontal distance; default slopeRatio derived from engine.movement.maxSlope); canopyHeight: a camera above this height is not blocked by trees
|
|
26
26
|
* cameraPad: camera margin from obstacles; cameraMin: closest camera distance; walkableWaterMargin: how far above the water surface counts as walkable
|
|
27
|
-
* cameraOcclusion: what camera occlusion tests: 'colliders' circles and boxes
|
|
27
|
+
* cameraOcclusion: what camera occlusion tests: 'both' (default) | 'colliders' circles and boxes only | 'meshes' only meshes registered as camera blockers (level buildings, col_ meshes,
|
|
28
|
+
* engine.rays.addStatic(mesh, { occluder: true })). Why both: a collider is a footprint for walkers, so a crown or an eave above it never stopped the arm, and a registered mesh was ignored
|
|
29
|
+
* unless the game also found this option. The ray skips every mesh that is no blocker on one flag check, so 'both' costs only for the blockers
|
|
28
30
|
*/
|
|
29
|
-
constructor(engine, { maxClimb = engine.movement.slopeRatio, canopyHeight = 5, cameraPad = 0.5, cameraMin = 1.5, walkableWaterMargin = 0.2, cameraOcclusion = '
|
|
31
|
+
constructor(engine, { maxClimb = engine.movement.slopeRatio, canopyHeight = 5, cameraPad = 0.5, cameraMin = 1.5, walkableWaterMargin = 0.2, cameraOcclusion = 'both' } = {}) {
|
|
30
32
|
this.engine = engine;
|
|
31
33
|
Object.assign(this, { maxClimb, canopyHeight, cameraPad, cameraMin, walkableWaterMargin, cameraOcclusion });
|
|
32
34
|
// Sets, not arrays: they keep insertion order (forEachStatic and every consumer see colliders in the order added) and delete in O(1),
|
package/modules/content/index.js
CHANGED
|
@@ -216,6 +216,14 @@ export function content() {
|
|
|
216
216
|
return api;
|
|
217
217
|
},
|
|
218
218
|
isReady() { return api.ready; },
|
|
219
|
+
// ?at=<place> / applyState({ at }): this module owns the names, core does the placing with what it gets back. An unknown name stops here: a picture of the
|
|
220
|
+
// spawn point taken for "the pier" would look fine and be wrong
|
|
221
|
+
applyState(e, { at }) {
|
|
222
|
+
if (at == null) return;
|
|
223
|
+
const p = api.place(at);
|
|
224
|
+
if (!p) throw codedError('content-place', `applyState({ at: '${at}' }): no such place. Places: ${Object.keys(places).join(', ') || '(none loaded)'}; a level marker works too`);
|
|
225
|
+
return p;
|
|
226
|
+
},
|
|
219
227
|
describe() {
|
|
220
228
|
return { props: e.world ? e.world.query({ kind: 'prop' }).length : 0, templates: [...st.templates.keys()], markers: api.markers.size };
|
|
221
229
|
},
|
|
@@ -1,39 +1,84 @@
|
|
|
1
1
|
// Models of placed content records: clone the shared prototype of a model name (core/namedModel.js protoOf, the one path every system uses),
|
|
2
2
|
// align it and its collision to the record (props and template instances).
|
|
3
3
|
import { protoOf } from '../../core/namedModel.js';
|
|
4
|
+
import { Vector3 } from 'three';
|
|
4
5
|
import { list } from './rules.js';
|
|
5
6
|
|
|
7
|
+
const BASE_BAND = 0.2; // the share of the model's height above the ground that counts as its base
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Where a model stands, in model space, measured once per prototype: { x, z } centre and width of the base (its larger side, so a plain box keeps the same radius).
|
|
11
|
+
* Why this measure: the base is the geometry in the lowest fifth of the height above y = 0 (above its lowest point when it floats), clipped from the triangles, because a crown or an arm starts higher, a tall box has no vertex halfway up and a boulder's belly is what walkers hit.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export function baseOf(proto) {
|
|
15
|
+
if (proto.base) return proto.base;
|
|
16
|
+
const meshes = [], p = new Vector3();
|
|
17
|
+
let bottom = Infinity, top = -Infinity, instanced = false;
|
|
18
|
+
proto.obj.updateMatrixWorld(true);
|
|
19
|
+
proto.obj.traverse(m => {
|
|
20
|
+
if (!m.isMesh || !m.geometry?.attributes.position) return;
|
|
21
|
+
instanced ||= !!(m.isInstancedMesh || m.isBatchedMesh);
|
|
22
|
+
const pos = m.geometry.attributes.position, at = new Float32Array(pos.count * 3);
|
|
23
|
+
for (let i = 0; i < pos.count; i++) {
|
|
24
|
+
p.fromBufferAttribute(pos, i).applyMatrix4(m.matrixWorld).toArray(at, i * 3);
|
|
25
|
+
bottom = Math.min(bottom, p.y); top = Math.max(top, p.y);
|
|
26
|
+
}
|
|
27
|
+
meshes.push({ at, index: m.geometry.index });
|
|
28
|
+
});
|
|
29
|
+
const low = top > 0 ? Math.max(bottom, 0) : bottom, high = low + (top - low) * BASE_BAND;
|
|
30
|
+
let x0 = Infinity, x1 = -Infinity, z0 = Infinity, z1 = -Infinity;
|
|
31
|
+
const take = (x, z) => { x0 = Math.min(x0, x); x1 = Math.max(x1, x); z0 = Math.min(z0, z); z1 = Math.max(z1, z); };
|
|
32
|
+
const edge = (at, a, b) => {
|
|
33
|
+
const ay = at[a + 1], by = at[b + 1];
|
|
34
|
+
if (ay >= low && ay <= high) take(at[a], at[a + 2]);
|
|
35
|
+
for (const y of [low, high]) if ((ay - y) * (by - y) < 0) { const t = (y - ay) / (by - ay); take(at[a] + (at[b] - at[a]) * t, at[a + 2] + (at[b + 2] - at[a + 2]) * t); }
|
|
36
|
+
};
|
|
37
|
+
for (const { at, index } of meshes) {
|
|
38
|
+
const n = index ? index.count : at.length / 3, v = i => (index ? index.getX(i) : i) * 3;
|
|
39
|
+
for (let i = 0; i + 2 < n; i += 3) { const a = v(i), b = v(i + 1), c = v(i + 2); edge(at, a, b); edge(at, b, c); edge(at, c, a); }
|
|
40
|
+
}
|
|
41
|
+
// shortcut: instanced parts and models without triangles (points, lines, sprites) use the bounding box; measure their instances if a prop ever needs it
|
|
42
|
+
const { size, center } = proto;
|
|
43
|
+
return proto.base = instanced || x0 > x1 ? { x: center.x, z: center.z, width: Math.max(size.x, size.z) }
|
|
44
|
+
: { x: (x0 + x1) / 2, z: (z0 + z1) / 2, width: Math.max(x1 - x0, z1 - z0) };
|
|
45
|
+
}
|
|
46
|
+
|
|
6
47
|
/**
|
|
7
48
|
* Align a built model and its collision to the record (once when built, again after the record moved or rot / scale changed).
|
|
8
|
-
*
|
|
49
|
+
* solid = { collide, static } comes from the prop record, or from the template definition for template instances.
|
|
50
|
+
* A circle stands on the model's base (baseOf); { circle: radius } gives the radius in model meters, so it follows the scale as the model does.
|
|
9
51
|
* mul: a template stage's scale, multiplied onto the record's own scale (the record keeps only its authored scale). @internal
|
|
10
52
|
*/
|
|
11
|
-
export function settle(e, rec, o,
|
|
53
|
+
export function settle(e, rec, o, solid, mul = 1) {
|
|
12
54
|
const { x, z } = rec.position, rot = rec.rot ?? 0, scale = (rec.scale ?? 1) * mul, ud = o.userData;
|
|
13
55
|
ud.fit = fitKey(rec, mul);
|
|
14
56
|
rec.position.y = e.surface(x, z, rec.floor) + (rec.offsetY ?? 0);
|
|
15
57
|
o.position.y = rec.position.y; o.rotation.y = rot; o.scale.setScalar(scale);
|
|
16
58
|
ud.unstatic?.remove(); ud.unstatic = null;
|
|
17
59
|
for (const h of ud.colliders.splice(0)) h.remove();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
60
|
+
// a solid prop blocks the camera with its whole mesh, not only its footprint collider: crowns and eaves stand outside the footprint, and no game code should have to say so
|
|
61
|
+
const blocks = !!solid.collide && solid.collide.occluder !== false && solid.occluder !== false;
|
|
62
|
+
if (solid.static !== false && e.rays) { o.updateMatrixWorld(true); ud.unstatic = e.rays.addStatic(o, { occluder: blocks }); }
|
|
63
|
+
if (!solid.collide || !e.collision) return;
|
|
64
|
+
const { collide } = solid, set = typeof collide === 'object' ? collide : null, base = set || collide === 'circle' ? baseOf(ud.proto) : null;
|
|
65
|
+
const size = ud.proto.size.clone().multiplyScalar(scale), c = base ?? ud.proto.center, ox = c.x * scale, oz = c.z * scale;
|
|
66
|
+
const cx = x + ox * Math.cos(rot) + oz * Math.sin(rot), cz = z - ox * Math.sin(rot) + oz * Math.cos(rot);
|
|
67
|
+
ud.colliders.push(base
|
|
68
|
+
? e.collision.addCircle({ x: cx, z: cz }, { radius: (set?.circle ?? base.width / 2) * scale, height: size.y, occluder: blocks })
|
|
69
|
+
: e.collision.addBox({ x: cx, z: cz }, { halfWidth: size.x / 2, halfDepth: size.z / 2, rotation: rot, height: size.y, occluder: blocks }));
|
|
25
70
|
}
|
|
26
71
|
/** What settle last aligned to; update compares it because world.move sends no event @internal */
|
|
27
72
|
export const fitKey = (rec, mul = 1) => `${rec.position.x},${rec.position.z},${rec.rot ?? 0},${(rec.scale ?? 1) * mul}`;
|
|
28
73
|
|
|
29
74
|
/** Clone the shared prototype of a model for one record and align it (props and template instances) @internal */
|
|
30
|
-
export async function buildModel(e, api, rec, model,
|
|
75
|
+
export async function buildModel(e, api, rec, model, solid, mul = 1) {
|
|
31
76
|
const proto = await protoOf(e, api, model), o = proto.obj.clone(), name = list(model)[0];
|
|
32
77
|
o.name ||= name; o.userData.name ??= name;
|
|
33
78
|
o.userData.proto = proto; o.userData.colliders = [];
|
|
34
79
|
if (rec.batch === false) o.userData.batch = false; // opt out of engine.batching for this record
|
|
35
80
|
o.position.set(rec.position.x, 0, rec.position.z); // world puts the model on the record after build; height and collision are aligned here
|
|
36
|
-
settle(e, rec, o,
|
|
81
|
+
settle(e, rec, o, solid, mul);
|
|
37
82
|
return o;
|
|
38
83
|
}
|
|
39
84
|
/** Tear down only: geometry and material belong to the shared prototype, the next build clones it again @internal */
|
package/modules/content/props.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Props (each item of content/props.js): data is a plain record in engine.world with kind 'prop'; model and collision are "presentation that exists only when
|
|
2
2
|
// near".
|
|
3
|
-
// record: { id, kind: 'prop', position: {x,y,z}, model, rot?, scale?, collide?, offsetY?, static?, batch?, zone? } (plain values only)
|
|
3
|
+
// record: { id, kind: 'prop', position: {x,y,z}, model, rot?, scale?, collide?, occluder?, offsetY?, static?, batch?, zone? } (plain values only)
|
|
4
4
|
// Initial world data (initial: true on add): the save records only moves / removals, independent of content.load running before or after loading a save;
|
|
5
5
|
// positions using level markers carry a zone (data is kept across level changes).
|
|
6
6
|
// id: the written id if content gives one; otherwise `prop:<model name>:<index in this props array>` (same on every load of the same content, no collisions).
|
|
@@ -16,7 +16,7 @@ import { buildModel, settle, fitKey, unbuildModel } from './models.js';
|
|
|
16
16
|
import { placeTemplate } from './templates.js';
|
|
17
17
|
import { srcOf } from './ids.js';
|
|
18
18
|
import { placeY } from '../../core/ground.js';
|
|
19
|
-
import { list, PLACEMENT_FIELDS } from './rules.js';
|
|
19
|
+
import { list, PLACEMENT_FIELDS, collideProblem } from './rules.js';
|
|
20
20
|
import { DEV, fmt, closest } from '../../core/validate.js';
|
|
21
21
|
import { codedError } from '../../core/errorHints.js';
|
|
22
22
|
|
|
@@ -35,11 +35,13 @@ export function addProps(e, api, props, st, zoneOf, ids) {
|
|
|
35
35
|
const at = DEV ? srcOf(props, i) : null;
|
|
36
36
|
if (p.template) return placeTemplate(e, api, st, p, i, zoneOf(p), ids, at); // an instance of a content template (templates.js), not a plain prop
|
|
37
37
|
if (p.grid) return placeGridItem(e, p, i, zoneOf(p), ids, at); // a pre-placed grid item (grid module)
|
|
38
|
+
const collide = collideProblem(p.collide);
|
|
39
|
+
if (collide) throw codedError('content-misuse', `props[${i}] (model ${JSON.stringify(p.model)}): collide ${collide}`);
|
|
38
40
|
const id = propId(p, i), { x, y, z } = api.where(p), zone = zoneOf(p), floor = api._floorOf(p);
|
|
39
41
|
if (p.id != null) ids.claim(p.id, `props[${i}] (model ${JSON.stringify(p.model)})`);
|
|
40
42
|
// compute y from the ground now (same as when the model is built): unmoved props equal the content and stay out of the save
|
|
41
43
|
const def = { id, kind: 'prop', position: { x, y: y ?? placeY(e, `props[${i}] (model ${JSON.stringify(p.model)})`, x, z), z }, model: p.model };
|
|
42
|
-
for (const k of ['rot', 'scale', 'collide', 'static', 'batch']) if (p[k] !== undefined) def[k] = p[k];
|
|
44
|
+
for (const k of ['rot', 'scale', 'collide', 'occluder', 'static', 'batch']) if (p[k] !== undefined) def[k] = p[k];
|
|
43
45
|
if (p.y) def.offsetY = p.y;
|
|
44
46
|
if (floor !== undefined) def.floor = floor; // kept so a moved prop lands on the same storey
|
|
45
47
|
if (zone != null) def.zone = zone;
|
package/modules/content/rules.js
CHANGED
|
@@ -86,21 +86,22 @@ const RULE_STRINGS = {
|
|
|
86
86
|
floor: { type: 'number', optional: true, desc: 'reference height of the storey it stands on (multi-layer ground)' },
|
|
87
87
|
y: { type: 'number', optional: true, desc: 'meters above the ground it stands on' },
|
|
88
88
|
};
|
|
89
|
-
const
|
|
89
|
+
const pose = {
|
|
90
90
|
rot: { type: 'number', optional: true, desc: 'facing around the vertical axis, radians' },
|
|
91
91
|
scale: { type: 'number', optional: true, min: 0, desc: 'uniform scale (1 = model size)' },
|
|
92
92
|
};
|
|
93
93
|
return {
|
|
94
94
|
props: {
|
|
95
95
|
id: { type: 'string', optional: true, desc: 'stable id (needed when entries are later inserted in the middle)' },
|
|
96
|
-
model: { type: 'any', desc: "model name, or [name, ...args] for a generated model" }, ...at, ...
|
|
97
|
-
collide: { type: 'any', optional: true,
|
|
96
|
+
model: { type: 'any', desc: "model name, or [name, ...args] for a generated model" }, ...at, ...pose,
|
|
97
|
+
collide: { type: 'any', optional: true, desc: "collision: 'box', 'circle', { circle: radius, occluder?: false }, or false = none" },
|
|
98
|
+
occluder: { type: 'bool', optional: true, desc: 'false = a solid prop the follow camera may pass through (walkers are still stopped)' },
|
|
98
99
|
static: { type: 'bool', optional: true, desc: 'never moves (may be merged into one draw call)' },
|
|
99
100
|
batch: { type: 'bool', optional: true, desc: 'false = never batch this copy' },
|
|
100
101
|
},
|
|
101
102
|
'props.template': {
|
|
102
103
|
template: { type: 'string', desc: 'template name (content/templates.js)' },
|
|
103
|
-
id: { type: 'string', optional: true, desc: 'stable id; instances with state should have one' }, ...at, ...
|
|
104
|
+
id: { type: 'string', optional: true, desc: 'stable id; instances with state should have one' }, ...at, ...pose,
|
|
104
105
|
items: { type: 'object', optional: true, desc: "starting goods of the instance's container { itemId: count }" },
|
|
105
106
|
},
|
|
106
107
|
'props.grid': {
|
|
@@ -147,6 +148,13 @@ export const REFS = RULE_STRINGS.refs;
|
|
|
147
148
|
export const CONTENT_FILES = RULE_STRINGS.files;
|
|
148
149
|
/** content entry shape -> { key: field spec } (core/params.js format): 'props', 'props.template', 'props.grid', 'pickups', 'views'. Read via fields.js */
|
|
149
150
|
export const PLACEMENT_FIELDS = RULE_STRINGS.fields;
|
|
151
|
+
/** Why a prop's or template's `collide` is wrong, or null. One rule for the load and content-check: a mistyped object must not quietly become a box */
|
|
152
|
+
export function collideProblem(v) {
|
|
153
|
+
if (v === undefined || v === false || v === 'box' || v === 'circle') return null;
|
|
154
|
+
const form = !!v && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).every(k => k === 'circle' || k === 'occluder');
|
|
155
|
+
if (form && Number.isFinite(v.circle) && v.circle > 0 && (v.occluder === undefined || typeof v.occluder === 'boolean')) return null;
|
|
156
|
+
return `must be one of false, "box", "circle" or { circle: radius in meters above 0, occluder?: false }, got ${JSON.stringify(v)}`;
|
|
157
|
+
}
|
|
150
158
|
/** Clock time notation 'HH:MM' (24-hour) */
|
|
151
159
|
export const CLOCK_RE = /^([01]\d|2[0-3]):[0-5]\d$/;
|
|
152
160
|
|