threedog 0.0.0-stage → 0.2.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 +5 -0
- package/LICENSE +21 -0
- package/README.md +39 -2
- package/core/Animator.js +268 -0
- package/core/Assets.js +256 -0
- package/core/Audio.js +267 -0
- package/core/Baked.js +72 -0
- package/core/Batching.js +247 -0
- package/core/Budget.js +221 -0
- package/core/Clock.js +94 -0
- package/core/Commits.js +77 -0
- package/core/DebugOverrides.js +143 -0
- package/core/Describe.js +145 -0
- package/core/Engine.js +184 -0
- package/core/Events.js +153 -0
- package/core/I18n.js +94 -0
- package/core/Input.js +245 -0
- package/core/Inspect.js +77 -0
- package/core/InspectScene.js +191 -0
- package/core/Jobs.js +146 -0
- package/core/Loading.js +149 -0
- package/core/MaterialInfo.js +32 -0
- package/core/Ops.js +256 -0
- package/core/Random.js +52 -0
- package/core/Rays.js +160 -0
- package/core/SaveStore.js +85 -0
- package/core/Saves.js +254 -0
- package/core/Stream.js +279 -0
- package/core/Threads.js +158 -0
- package/core/UrlState.js +94 -0
- package/core/Vars.js +35 -0
- package/core/Views.js +49 -0
- package/core/actor.js +23 -0
- package/core/assetEntry.js +89 -0
- package/core/assetLoad.js +190 -0
- package/core/assetManifest.js +35 -0
- package/core/assetReport.js +83 -0
- package/core/audioRules.js +121 -0
- package/core/audioVoice.js +225 -0
- package/core/batchGroups.js +116 -0
- package/core/canvasBox.js +63 -0
- package/core/catalog.js +169 -0
- package/core/checks.js +67 -0
- package/core/claims.js +51 -0
- package/core/dayTime.js +15 -0
- package/core/debugView.js +76 -0
- package/core/describeRender.js +45 -0
- package/core/describeText.js +143 -0
- package/core/easing.js +34 -0
- package/core/errorCodes.js +205 -0
- package/core/errorHints.js +208 -0
- package/core/errors.js +40 -0
- package/core/events.generated.js +84 -0
- package/core/ground.js +102 -0
- package/core/holds.js +106 -0
- package/core/inputContext.js +69 -0
- package/core/inputDefaults.js +22 -0
- package/core/inputPad.js +35 -0
- package/core/inputPointer.js +48 -0
- package/core/inputTouch.js +48 -0
- package/core/lifecycle.js +69 -0
- package/core/lightWatch.js +56 -0
- package/core/look/coreParts.js +112 -0
- package/core/look/layers.js +136 -0
- package/core/look/part.js +173 -0
- package/core/look/report.js +79 -0
- package/core/look/write.js +86 -0
- package/core/loop.js +200 -0
- package/core/math.js +33 -0
- package/core/modules.js +196 -0
- package/core/movement.js +19 -0
- package/core/mulberry32.js +14 -0
- package/core/opsAtomic.js +31 -0
- package/core/opsCheck.js +97 -0
- package/core/opsFail.js +20 -0
- package/core/opsGuard.js +26 -0
- package/core/opsHistory.js +27 -0
- package/core/opsRun.js +77 -0
- package/core/page.js +78 -0
- package/core/params.js +132 -0
- package/core/pureWorker.js +5 -0
- package/core/renamed.js +21 -0
- package/core/saveApply.js +128 -0
- package/core/saveFiles.js +139 -0
- package/core/saveIds.js +53 -0
- package/core/saveVersions.js +97 -0
- package/core/scatter.js +92 -0
- package/core/sceneMethods.js +100 -0
- package/core/screenToGround.js +39 -0
- package/core/services.js +73 -0
- package/core/session.js +171 -0
- package/core/shadowTypes.js +15 -0
- package/core/skip.js +104 -0
- package/core/startup.js +135 -0
- package/core/streamCells.js +24 -0
- package/core/streamSources.js +73 -0
- package/core/styleParts.js +96 -0
- package/core/targeting.js +64 -0
- package/core/thingExplain.js +68 -0
- package/core/thingOps.js +168 -0
- package/core/things.js +212 -0
- package/core/threadPure.js +120 -0
- package/core/threadServe.js +25 -0
- package/core/tier.js +11 -0
- package/core/util.js +11 -0
- package/core/validate.js +204 -0
- package/docs/AI.md +123 -0
- package/docs/API.md +83 -0
- package/docs/CODEMAP.md +347 -0
- package/docs/COMMANDS.md +108 -0
- package/docs/CONVENTIONS.md +145 -0
- package/docs/PERF.md +217 -0
- package/docs/THREE.md +86 -0
- package/docs/api/ambience.md +15 -0
- package/docs/api/assets.md +62 -0
- package/docs/api/audio.md +53 -0
- package/docs/api/budget.md +40 -0
- package/docs/api/cameraRig.md +120 -0
- package/docs/api/characters.md +144 -0
- package/docs/api/clock.md +7 -0
- package/docs/api/collision.md +39 -0
- package/docs/api/content.md +64 -0
- package/docs/api/dialogue.md +39 -0
- package/docs/api/engine.md +199 -0
- package/docs/api/entities.md +61 -0
- package/docs/api/events.md +95 -0
- package/docs/api/flow.md +27 -0
- package/docs/api/grids.md +11 -0
- package/docs/api/ground.md +16 -0
- package/docs/api/hlod.md +34 -0
- package/docs/api/hud.md +31 -0
- package/docs/api/i18n.md +10 -0
- package/docs/api/input.md +24 -0
- package/docs/api/interactions.md +31 -0
- package/docs/api/inventory.md +66 -0
- package/docs/api/jobs.md +10 -0
- package/docs/api/level.md +41 -0
- package/docs/api/lightPool.md +56 -0
- package/docs/api/music.md +34 -0
- package/docs/api/nav.md +26 -0
- package/docs/api/net.md +14 -0
- package/docs/api/openWorld.md +24 -0
- package/docs/api/particles.md +41 -0
- package/docs/api/photo.md +15 -0
- package/docs/api/post.md +10 -0
- package/docs/api/quests.md +36 -0
- package/docs/api/rays.md +26 -0
- package/docs/api/rigid.md +84 -0
- package/docs/api/saves.md +32 -0
- package/docs/api/settings.md +36 -0
- package/docs/api/sky.md +58 -0
- package/docs/api/stream.md +31 -0
- package/docs/api/style.md +134 -0
- package/docs/api/terrain.md +34 -0
- package/docs/api/timeline.md +39 -0
- package/docs/api/tools.md +57 -0
- package/docs/api/triggers.md +56 -0
- package/docs/api/vars.md +9 -0
- package/docs/api/vegetation.md +52 -0
- package/docs/api/water.md +48 -0
- package/docs/api/weather.md +29 -0
- package/docs/api/world.md +30 -0
- package/docs/recipes/01-new-game.md +148 -0
- package/docs/recipes/02-npc.md +167 -0
- package/docs/recipes/03-items-pickups.md +158 -0
- package/docs/recipes/04-quests.md +83 -0
- package/docs/recipes/05-props-bake.md +159 -0
- package/docs/recipes/06-clock-events.md +117 -0
- package/docs/recipes/07-flow-scenes-pause.md +132 -0
- package/docs/recipes/08-weather-sky.md +74 -0
- package/docs/recipes/09-style-pack.md +234 -0
- package/docs/recipes/10-blender-level.md +67 -0
- package/docs/recipes/11-vehicles.md +55 -0
- package/docs/recipes/12-navmesh.md +79 -0
- package/docs/recipes/13-animation.md +149 -0
- package/docs/recipes/14-custom-module.md +91 -0
- package/docs/recipes/15-perf.md +78 -0
- package/docs/recipes/16-dev-bridge.md +180 -0
- package/docs/recipes/18-world.md +185 -0
- package/docs/recipes/19-shooting-picking.md +76 -0
- package/docs/recipes/20-content-actions-save.md +176 -0
- package/docs/recipes/21-camera.md +153 -0
- package/docs/recipes/22-shop-gold.md +107 -0
- package/docs/recipes/23-ops.md +175 -0
- package/docs/recipes/26-ui-parts.md +138 -0
- package/docs/recipes/27-net.md +96 -0
- package/docs/recipes/28-terrain.md +80 -0
- package/docs/recipes/29-grid.md +87 -0
- package/docs/recipes/30-templates.md +131 -0
- package/docs/recipes/31-audio.md +126 -0
- package/docs/recipes/32-action-game.md +33 -0
- package/docs/recipes/33-stream-sources.md +37 -0
- package/docs/recipes/34-environment-lighting.md +36 -0
- package/docs/recipes/35-style-from-reference.md +89 -0
- package/docs/recipes/36-sky-ground-plant-looks.md +116 -0
- package/docs/recipes/37-terrain-look-hooks.md +97 -0
- package/docs/recipes/38-environment-look-hooks.md +83 -0
- package/docs/recipes/40-scene.md +108 -0
- package/docs/recipes/41-thing-registry.md +93 -0
- package/docs/recipes/42-terrain-shape.md +64 -0
- package/docs/recipes/43-shader-patches-surface-looks.md +120 -0
- package/docs/recipes/44-water-weather-look-hooks.md +135 -0
- package/docs/recipes/45-cascaded-shadows.md +51 -0
- package/docs/recipes/46-blender-art-route.md +114 -0
- package/docs/recipes/47-island-snow-backdrop.md +44 -0
- package/docs/recipes/48-make-material.md +70 -0
- package/docs/recipes/49-game-module-contract.md +71 -0
- package/docs/recipes/50-own-renderer.md +12 -0
- package/docs/recipes/51-capability-catalog.md +63 -0
- package/docs/recipes/52-look.md +108 -0
- package/examples/action/DESIGN.md +3 -0
- package/examples/action/GAMEMAP.md +127 -0
- package/examples/action/content/actions.js +8 -0
- package/examples/action/content/audio.js +9 -0
- package/examples/action/content/index.js +10 -0
- package/examples/action/content/items.js +4 -0
- package/examples/action/content/places.js +4 -0
- package/examples/action/content/props.js +11 -0
- package/examples/action/content/templates.js +10 -0
- package/examples/action/content/views.js +6 -0
- package/examples/action/look.js +5 -0
- package/examples/action/main.js +137 -0
- package/examples/action/models.js +25 -0
- package/examples/sheepisland/GAMEMAP.md +107 -0
- package/examples/sheepisland/content/index.js +6 -0
- package/examples/sheepisland/content/props.js +19 -0
- package/examples/sheepisland/content/templates.js +5 -0
- package/examples/sheepisland/content/vegetation.js +8 -0
- package/examples/sheepisland/main.js +71 -0
- package/examples/sheepisland/params.js +25 -0
- package/examples/sheepisland/style/index.js +79 -0
- package/examples/sheepisland/style/models.js +59 -0
- package/examples/sheepisland/views.js +9 -0
- package/examples/styletest/GAMEMAP.md +135 -0
- package/examples/styletest/content/index.js +9 -0
- package/examples/styletest/content/items.js +8 -0
- package/examples/styletest/content/npcs.js +8 -0
- package/examples/styletest/content/places.js +5 -0
- package/examples/styletest/content/props.js +16 -0
- package/examples/styletest/content/templates.js +9 -0
- package/examples/styletest/content/vegetation.js +31 -0
- package/examples/styletest/look.js +11 -0
- package/examples/styletest/main.js +95 -0
- package/examples/styletest/models.js +87 -0
- package/examples/styletest/overrides.js +33 -0
- package/examples/styletest/panel.js +135 -0
- package/examples/styletest/params.js +32 -0
- package/examples/styletest/views.js +31 -0
- package/examples/world/DESIGN.md +5 -0
- package/examples/world/GAMEMAP.md +171 -0
- package/examples/world/content/actions.js +8 -0
- package/examples/world/content/audio.js +25 -0
- package/examples/world/content/bodies.js +12 -0
- package/examples/world/content/containers.js +4 -0
- package/examples/world/content/dialogues.js +33 -0
- package/examples/world/content/index.js +17 -0
- package/examples/world/content/items.js +10 -0
- package/examples/world/content/npcs.js +14 -0
- package/examples/world/content/pickups.js +11 -0
- package/examples/world/content/places.js +6 -0
- package/examples/world/content/props.js +12 -0
- package/examples/world/content/quests.js +15 -0
- package/examples/world/content/rules.js +23 -0
- package/examples/world/content/templates.js +5 -0
- package/examples/world/content/vegetation.js +32 -0
- package/examples/world/main.js +168 -0
- package/examples/world/models.js +28 -0
- package/index.d.ts +306 -0
- package/index.js +122 -0
- package/llms.txt +61 -0
- package/modules/ambience/Ambience.js +186 -0
- package/modules/camera/FirstPersonCamera.js +131 -0
- package/modules/camera/FixedCamera.js +162 -0
- package/modules/camera/FollowCamera.js +91 -0
- package/modules/camera/RtsCamera.js +132 -0
- package/modules/camera/common.js +182 -0
- package/modules/camera/index.js +11 -0
- package/modules/camera/projection.js +34 -0
- package/modules/characters/Character.js +235 -0
- package/modules/characters/NPC.js +242 -0
- package/modules/characters/assetModel.js +42 -0
- package/modules/characters/astar.js +66 -0
- package/modules/characters/behaviors.js +72 -0
- package/modules/characters/footsteps.js +13 -0
- package/modules/characters/index.js +215 -0
- package/modules/characters/moveHelpers.js +29 -0
- package/modules/characters/movers/common.js +62 -0
- package/modules/characters/movers/rapier.js +74 -0
- package/modules/characters/movers/simple.js +43 -0
- package/modules/characters/npcAvoid.js +129 -0
- package/modules/characters/npcSim.js +150 -0
- package/modules/characters/npcView.js +42 -0
- package/modules/characters/pathAsync.js +113 -0
- package/modules/characters/pathJob.js +62 -0
- package/modules/characters/pathWorker.js +7 -0
- package/modules/characters/playerStrings.js +12 -0
- package/modules/characters/proceduralRig.js +58 -0
- package/modules/characters/useModel.js +22 -0
- package/modules/characters/walkTo.js +58 -0
- package/modules/collision/Collision.js +274 -0
- package/modules/collision/grid.js +63 -0
- package/modules/content/explain.js +13 -0
- package/modules/content/ids.js +95 -0
- package/modules/content/index.js +154 -0
- package/modules/content/loader.js +190 -0
- package/modules/content/models.js +69 -0
- package/modules/content/packs.js +69 -0
- package/modules/content/props.js +89 -0
- package/modules/content/rules.js +134 -0
- package/modules/content/templates.js +189 -0
- package/modules/debug/DebugPanel.js +174 -0
- package/modules/entities/Entities.js +243 -0
- package/modules/entities/build.js +25 -0
- package/modules/entities/index.js +4 -0
- package/modules/flow/index.js +101 -0
- package/modules/gameplay/Container.js +227 -0
- package/modules/gameplay/Containers.js +89 -0
- package/modules/gameplay/Dialogue.js +219 -0
- package/modules/gameplay/Interactions.js +253 -0
- package/modules/gameplay/Inventory.js +224 -0
- package/modules/gameplay/Quests.js +205 -0
- package/modules/gameplay/boxOps.js +60 -0
- package/modules/gameplay/dialogueBox.js +48 -0
- package/modules/gameplay/interactionPrompt.js +28 -0
- package/modules/gameplay/inventoryOps.js +137 -0
- package/modules/gameplay/pickups.js +115 -0
- package/modules/gameplay/questLog.js +54 -0
- package/modules/gameplay/questSave.js +71 -0
- package/modules/grid/Grid.js +184 -0
- package/modules/grid/Layer.js +142 -0
- package/modules/grid/index.js +236 -0
- package/modules/grid/ops.js +73 -0
- package/modules/grid/preview.js +85 -0
- package/modules/grid/tiles.js +79 -0
- package/modules/hlod/index.js +167 -0
- package/modules/hud/index.js +167 -0
- package/modules/hud/parts.js +80 -0
- package/modules/level/geometry.js +46 -0
- package/modules/level/heightfield.js +160 -0
- package/modules/level/index.js +233 -0
- package/modules/level/nodes.js +84 -0
- package/modules/lights/index.js +227 -0
- package/modules/music/Music.js +294 -0
- package/modules/music/index.js +2 -0
- package/modules/music/rules.js +28 -0
- package/modules/nav/index.js +156 -0
- package/modules/nav/navPath.js +17 -0
- package/modules/net/Client.js +137 -0
- package/modules/net/Host.js +117 -0
- package/modules/net/Net.js +49 -0
- package/modules/net/index.js +77 -0
- package/modules/net/sync.js +114 -0
- package/modules/net/transports.js +118 -0
- package/modules/particles/Particles.js +179 -0
- package/modules/particles/effect.js +112 -0
- package/modules/particles/shaders.js +28 -0
- package/modules/photo/Photo.js +146 -0
- package/modules/rigid/RigidBodies.js +265 -0
- package/modules/rigid/Vehicles.js +97 -0
- package/modules/rigid/sync.js +158 -0
- package/modules/settings/Settings.js +297 -0
- package/modules/settings/apply.js +21 -0
- package/modules/settings/index.js +3 -0
- package/modules/settings/sections.js +156 -0
- package/modules/settings/strings.js +53 -0
- package/modules/settings/view.js +65 -0
- package/modules/sky/Sky.js +259 -0
- package/modules/sky/calendar.js +80 -0
- package/modules/sky/cascades.js +125 -0
- package/modules/sky/clouds.js +79 -0
- package/modules/sky/domeLayers.js +33 -0
- package/modules/sky/environment.js +141 -0
- package/modules/sky/fog.js +139 -0
- package/modules/sky/frame.js +77 -0
- package/modules/sky/layers.js +69 -0
- package/modules/sky/look.js +51 -0
- package/modules/sky/lookFog.js +80 -0
- package/modules/sky/lookShadow.js +50 -0
- package/modules/sky/lookSky.js +108 -0
- package/modules/sky/schedule.js +80 -0
- package/modules/sky/shader.js +96 -0
- package/modules/sky/shadow.js +74 -0
- package/modules/sky/skyModule.js +60 -0
- package/modules/terrain/ChunkManager.js +260 -0
- package/modules/terrain/chunkJob.js +19 -0
- package/modules/terrain/chunkLevels.js +40 -0
- package/modules/terrain/chunkQueries.js +42 -0
- package/modules/terrain/chunkWorker.js +5 -0
- package/modules/terrain/index.js +118 -0
- package/modules/terrain/lookGround.js +61 -0
- package/modules/terrain/mountTerrain.js +32 -0
- package/modules/terrain/terrainColorMap.js +41 -0
- package/modules/terrain/terrainDefaults.js +39 -0
- package/modules/terrain/terrainEdit.js +139 -0
- package/modules/terrain/terrainGen.js +155 -0
- package/modules/terrain/terrainIsland.js +131 -0
- package/modules/terrain/terrainMesh.js +92 -0
- package/modules/terrain/terrainShape.js +108 -0
- package/modules/terrain/terrainShapeMain.js +41 -0
- package/modules/terrain/terrainTexture.js +44 -0
- package/modules/timeline/Timeline.js +253 -0
- package/modules/timeline/Tween.js +114 -0
- package/modules/timeline/letterbox.js +24 -0
- package/modules/timeline/shots.js +90 -0
- package/modules/triggers/index.js +268 -0
- package/modules/vegetation/Vegetation.js +256 -0
- package/modules/vegetation/groundChunks.js +177 -0
- package/modules/vegetation/index.js +43 -0
- package/modules/vegetation/lookWind.js +37 -0
- package/modules/vegetation/modelGeometry.js +21 -0
- package/modules/water/Water.js +160 -0
- package/modules/water/look.js +80 -0
- package/modules/water/surface.js +88 -0
- package/modules/weather/Weather.js +242 -0
- package/modules/weather/look.js +75 -0
- package/modules/weather/particles.js +92 -0
- package/modules/weather/shaders.js +49 -0
- package/modules/weather/strings.js +15 -0
- package/modules/world/World.js +231 -0
- package/modules/world/cells.js +42 -0
- package/modules/world/explain.js +11 -0
- package/modules/world/index.js +71 -0
- package/modules/world/persist.js +107 -0
- package/modules/world/pos.js +20 -0
- package/modules/world/records.js +89 -0
- package/modules/world/sim.js +175 -0
- package/modules/world/simFar.js +82 -0
- package/modules/world/state.js +115 -0
- package/modules/world/thingSource.js +44 -0
- package/modules/world/views.js +182 -0
- package/package.json +66 -4
- package/presets.js +96 -0
- package/render/PostFX.js +240 -0
- package/render/detail.js +105 -0
- package/render/effects.js +144 -0
- package/render/engineUniforms.js +23 -0
- package/render/fuse.js +84 -0
- package/render/lighting.js +100 -0
- package/render/lights.js +18 -0
- package/render/lookSurface.js +161 -0
- package/render/materials.js +220 -0
- package/render/patches.js +252 -0
- package/render/postLook.js +86 -0
- package/render/surface.js +69 -0
- package/render/uniformDecl.js +29 -0
- package/types/common.d.ts +34 -0
- package/types/core.d.ts +1965 -0
- package/types/gameplay.d.ts +1822 -0
- package/types/generated/core/Audio.d.ts +200 -0
- package/types/generated/core/Batching.d.ts +47 -0
- package/types/generated/core/Budget.d.ts +90 -0
- package/types/generated/core/Commits.d.ts +31 -0
- package/types/generated/core/DebugOverrides.d.ts +52 -0
- package/types/generated/core/Events.d.ts +89 -0
- package/types/generated/core/I18n.d.ts +30 -0
- package/types/generated/core/Input.d.ts +118 -0
- package/types/generated/core/Jobs.d.ts +41 -0
- package/types/generated/core/Ops.d.ts +203 -0
- package/types/generated/core/Random.d.ts +49 -0
- package/types/generated/core/Rays.d.ts +49 -0
- package/types/generated/core/Saves.d.ts +162 -0
- package/types/generated/core/Stream.d.ts +93 -0
- package/types/generated/core/Threads.d.ts +82 -0
- package/types/generated/core/Views.d.ts +33 -0
- package/types/generated/core/audioVoice.d.ts +47 -0
- package/types/generated/core/page.d.ts +18 -0
- package/types/generated/core/session.d.ts +48 -0
- package/types/generated/modules/ambience/Ambience.d.ts +48 -0
- package/types/generated/modules/debug/DebugPanel.d.ts +24 -0
- package/types/generated/modules/flow/index.d.ts +10 -0
- package/types/generated/modules/grid/Grid.d.ts +151 -0
- package/types/generated/modules/grid/Layer.d.ts +65 -0
- package/types/generated/modules/grid/index.d.ts +86 -0
- package/types/generated/modules/hlod/index.d.ts +11 -0
- package/types/generated/modules/hud/index.d.ts +10 -0
- package/types/generated/modules/lights/index.d.ts +13 -0
- package/types/generated/modules/music/Music.d.ts +111 -0
- package/types/generated/modules/net/Net.d.ts +34 -0
- package/types/generated/modules/net/index.d.ts +53 -0
- package/types/generated/modules/net/transports.d.ts +58 -0
- package/types/generated/modules/particles/Particles.d.ts +69 -0
- package/types/generated/modules/sky/Sky.d.ts +145 -0
- package/types/generated/modules/sky/skyModule.d.ts +10 -0
- package/types/generated/modules/timeline/Timeline.d.ts +51 -0
- package/types/generated/modules/water/Water.d.ts +29 -0
- package/types/generated/modules/weather/Weather.d.ts +62 -0
- package/types/generated/modules/world/World.d.ts +242 -0
- package/types/generated/modules/world/index.d.ts +15 -0
- package/types/generated/render/PostFX.d.ts +125 -0
- package/types/generated/render/materials.d.ts +100 -0
- package/types/generated/render/patches.d.ts +41 -0
- package/types/generated/ui/Focus.d.ts +11 -0
- package/types/generated/ui/LoadingScreen.d.ts +2 -0
- package/types/generated/ui/UI.d.ts +57 -0
- package/types/nav.d.ts +52 -0
- package/types/physics.d.ts +592 -0
- package/types/style.d.ts +638 -0
- package/types/worker.d.ts +11 -0
- package/types/world.d.ts +772 -0
- package/ui/Focus.js +51 -0
- package/ui/LoadingScreen.js +42 -0
- package/ui/Parts.js +199 -0
- package/ui/UI.js +167 -0
- package/ui/defaults.js +85 -0
- package/ui/theme.js +124 -0
- package/ui/touchPart.js +49 -0
package/core/things.js
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// Object registry behind engine.thing: every root handed to engine.add gets a small entry saying what it is called, where it was made, who manages
|
|
2
|
+
// it and how much a save keeps. Why a table and not a scene walk: "what is this, will a save keep it?" must work for a plain three.js object too, and a
|
|
3
|
+
// release build may pay only two table writes per add (WeakMap entry + id -> WeakRef), no traversal and no per-frame cost.
|
|
4
|
+
// The WeakMap does not keep objects alive and the id map holds only WeakRefs, so a game that drops an object without engine.remove leaks nothing.
|
|
5
|
+
// Overrides (thing.set / thing.remove on objects the game's code rebuilds each start) live here too and are the 'scene' save part (version 1):
|
|
6
|
+
// { set: { id: { position?, rotation?, scale?, visible? } }, removed: [id] }; ids a save names before the object exists wait in pending.
|
|
7
|
+
import { DEV, warnOnce } from './validate.js';
|
|
8
|
+
import { codedError, coded } from './errorHints.js';
|
|
9
|
+
|
|
10
|
+
/** Stacks taken per session in dev: bullets or debris added every frame must not slow dev builds down for a file:line nobody reads */
|
|
11
|
+
const STACK_CAP = 2000;
|
|
12
|
+
const KEYS = ['position', 'rotation', 'scale', 'visible'];
|
|
13
|
+
const FRAME = /\(?((?:[a-z]+:\/\/[^/\s]+)?[^\s()]+?\.[cm]?[jt]sx?)(?:\?[^:\s)]*)?:(\d+):\d+\)?\s*$/i;
|
|
14
|
+
|
|
15
|
+
/** 'main.js:50' from a captured Error: frame 0 is captureStack, 1 engine.add, 2 its caller; the host part of a URL is dropped */
|
|
16
|
+
function stackAt(err) {
|
|
17
|
+
const frames = String(err?.stack ?? '').split('\n').map(l => FRAME.exec(l)).filter(Boolean);
|
|
18
|
+
const f = frames[2]; if (!f) return null;
|
|
19
|
+
return `${f[1].replace(/^[a-z]+:\/\/[^/]+\//i, '').replace(/^\/+/, '')}:${f[2]}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** One registered root. `at` parses the stack the first time it is read (V8 formats a stack only when .stack is read) */
|
|
23
|
+
class Entry {
|
|
24
|
+
constructor(id, stable, owner, phase, op, tick, save, stack) {
|
|
25
|
+
this.id = id; this.stable = stable; this.owner = owner; this.phase = phase; this.op = op; this.tick = tick; this.save = save; this._stack = stack;
|
|
26
|
+
this._at = stack ? undefined : null;
|
|
27
|
+
}
|
|
28
|
+
get at() { if (this._at === undefined) { this._at = stackAt(this._stack); this._stack = null; } return this._at; }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Plain-data transform of an object, in the shape the 'scene' part stores */
|
|
32
|
+
export const snap = o => ({ position: o.position.toArray(), rotation: [o.rotation.x, o.rotation.y, o.rotation.z], scale: o.scale.toArray(), visible: o.visible });
|
|
33
|
+
/** Write a (normalised) patch onto an object */
|
|
34
|
+
export function write(o, p) {
|
|
35
|
+
if (p.position) o.position.fromArray(p.position);
|
|
36
|
+
if (p.rotation) o.rotation.set(p.rotation[0], p.rotation[1], p.rotation[2]);
|
|
37
|
+
if (p.scale) o.scale.fromArray(p.scale);
|
|
38
|
+
if (p.visible !== undefined) o.visible = p.visible;
|
|
39
|
+
}
|
|
40
|
+
const pick = (o, keys) => Object.fromEntries(keys.filter(k => k in o).map(k => [k, o[k]]));
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Ids are one space shared by engine.add objects and world records, checked from both sides. obj = the object engine.add is registering; null when
|
|
44
|
+
* world.add asks (record ids such as 'crate#3' may hold '#', and the world does not know the object). Only an explicit { id } is a stable id: obj.name is
|
|
45
|
+
* never one (GLB roots are all called 'Scene' / 'Cube', so a save would follow creation order). @internal
|
|
46
|
+
*/
|
|
47
|
+
export function claimId(e, id, obj = null) {
|
|
48
|
+
const T = e._things, who = obj ? `engine.add(obj, { id: '${id}' })` : `world.add({ id: '${id}' })`;
|
|
49
|
+
if (obj && (typeof id !== 'string' || !id || id.includes('#'))) throw codedError('thing-id', `engine.add(obj, { id: ${JSON.stringify(id)} }): an id is a non-empty string without '#' ('#' marks runtime ids such as obj#3), e.g. { id: 'windmill' }`);
|
|
50
|
+
if (obj && T.source(id)) throw codedError('thing-id', `${who}: '${id}' is a world record id (engine.thing('${id}') shows it). Ids are shared with world records: pick another`);
|
|
51
|
+
const other = T.live(id);
|
|
52
|
+
if (other && other !== obj && T.byObj.get(other).owner !== 'world') {
|
|
53
|
+
const at = T.byObj.get(other).at;
|
|
54
|
+
throw codedError('thing-id', `${who}: '${id}' is already the id of ${obj ? 'another object' : 'an object added with engine.add'}${at ? ` (added at ${at})` : ''}. Ids are unique across engine.add and world records: pick another`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** engine._things (internal): the registry. The public face is engine.thing (thingOps.js) and engine.add / remove (sceneMethods.js) @internal */
|
|
59
|
+
export class Things {
|
|
60
|
+
constructor(e) {
|
|
61
|
+
this.e = e;
|
|
62
|
+
this.sources = []; // record stores (world) registered with addSource; core knows only their shape
|
|
63
|
+
this.byObj = new WeakMap();
|
|
64
|
+
this.byId = new Map(); // id -> WeakRef(root)
|
|
65
|
+
this.n = 0; // session ids obj#n
|
|
66
|
+
this.stacks = 0;
|
|
67
|
+
this.setup = false; // true inside session:start listeners: what they add is rebuilt by code every playthrough
|
|
68
|
+
this.over = new Map(); // stable id -> { orig, cur }: thing.set overrides (orig = the code-built transform, for load / newGame / undo)
|
|
69
|
+
this.removed = new Set(); // stable ids removed with thing.remove (saved)
|
|
70
|
+
this.gone = new Map(); // id -> { obj, parent }: removed with thing.remove, detached and held so undo or a load can put it back
|
|
71
|
+
this.pending = { set: {}, removed: new Set() }; // from a loaded save, objects not registered yet (orphans if they never come)
|
|
72
|
+
this.unsaved = new Set(); // WeakRefs of session-tier objects someone expected to keep (save: true, or made inside an op)
|
|
73
|
+
this.conflicts = []; // dev: "two systems manage one object" findings, newest last
|
|
74
|
+
e.events.on('session:start', () => { this.setup = true; queueMicrotask(() => { this.setup = false; }); });
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A store of records that share the id space with engine.add objects (the world module registers itself at install). The shape core uses:
|
|
78
|
+
* { has(id), get(id) -> { position, ... }, ids(), idOf(obj) -> id | null (model -> record), view(id) -> Object3D | null,
|
|
79
|
+
* explain(id) -> the record as a thing, set(id, patch) -> undo values, remove(id) -> restore token, restore(token) }
|
|
80
|
+
* @param {any} src @returns {{ remove(): void }}
|
|
81
|
+
*/
|
|
82
|
+
addSource(src) { this.sources.push(src); return { remove: () => { this.sources = this.sources.filter(s => s !== src); } }; }
|
|
83
|
+
/** The source that has a record under id, else null */
|
|
84
|
+
source(id) { return this.sources.find(s => s.has(id)) ?? null; }
|
|
85
|
+
/** The record id whose model is obj, else null */
|
|
86
|
+
idOf(obj) { for (const s of this.sources) { const id = s.idOf?.(obj); if (id) return id; } return null; }
|
|
87
|
+
/** Every record id (for "did you mean") */
|
|
88
|
+
recordIds() { return this.sources.flatMap(s => s.ids?.() ?? []); }
|
|
89
|
+
/** Whether a dev stack should be taken for this add (cap reached = no) */
|
|
90
|
+
wantStack() { return this.stacks < STACK_CAP && ++this.stacks > 0; }
|
|
91
|
+
get atCapped() { return this.stacks >= STACK_CAP; }
|
|
92
|
+
|
|
93
|
+
/** The live root registered under id, else null (a dead WeakRef or a re-registered object is cleaned up on the way) */
|
|
94
|
+
live(id) {
|
|
95
|
+
const ref = this.byId.get(id); if (!ref) return null;
|
|
96
|
+
const o = ref.deref();
|
|
97
|
+
if (o && this.byObj.get(o)?.id === id) return o;
|
|
98
|
+
this.byId.delete(id); return null;
|
|
99
|
+
}
|
|
100
|
+
/** [entry, root] for obj or its nearest registered ancestor */
|
|
101
|
+
entryOf(obj) { for (let o = obj; o; o = o.parent) { const en = this.byObj.get(o); if (en) return [en, o]; } return null; }
|
|
102
|
+
/** Save tier, judged in order (recipe 41) */
|
|
103
|
+
tier(en) { return en.owner === 'world' ? 'record' : en.owner !== 'game' ? 'engine' : en.stable && en.phase === 'setup' ? 'code' : 'session'; }
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Register one root (engine.add). owner: 'game' (default) | 'world' | 'level' | 'stream' | 'engine:<module>'. Re-adding a detached object keeps its entry.
|
|
107
|
+
* @param {any} obj @param {{ id?: string, owner?: string, save?: boolean } | null} opts @param {Error | null} stack
|
|
108
|
+
*/
|
|
109
|
+
add(obj, opts, stack) {
|
|
110
|
+
const owner = opts?.owner ?? 'game', old = this.byObj.get(obj);
|
|
111
|
+
if (old && (opts?.id == null || opts.id === old.id)) return old;
|
|
112
|
+
let id = opts?.id ?? null, stable = id != null;
|
|
113
|
+
if (stable && owner !== 'world') claimId(this.e, id, obj);
|
|
114
|
+
if (!stable) id = `obj#${++this.n}`;
|
|
115
|
+
const e = this.e, play = e.ready && !this.setup;
|
|
116
|
+
const en = new Entry(id, stable, owner, play ? 'play' : 'setup', play ? e.ops.running : null, play ? e.tick : null, opts?.save, stack);
|
|
117
|
+
this.byObj.set(obj, en); this.byId.set(id, new WeakRef(obj));
|
|
118
|
+
if (owner === 'game') this.adopt(obj, en);
|
|
119
|
+
return en;
|
|
120
|
+
}
|
|
121
|
+
/** engine.remove: forget the entry (detach keeps it, the object may come back) */
|
|
122
|
+
forget(obj) {
|
|
123
|
+
const en = this.byObj.get(obj); if (!en) return;
|
|
124
|
+
this.byObj.delete(obj);
|
|
125
|
+
if (this.byId.get(en.id)?.deref() === obj) this.byId.delete(en.id);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** A game root just registered: dev warnings, and the loaded save's override / removal for its id */
|
|
129
|
+
adopt(obj, en) {
|
|
130
|
+
const tier = this.tier(en);
|
|
131
|
+
if (tier === 'session' && (en.save === true || en.op)) {
|
|
132
|
+
this.unsaved.add(new WeakRef(obj));
|
|
133
|
+
if (DEV && en.save === true) warnOnce(coded('thing-unsaved', `engine.add(obj, { save: true })${en.at ? ` at ${en.at}` : ''}: this object cannot be saved (${en.stable ? 'it was made during play' : 'it has no stable id'}), so it will not come back after a load. Give it an id and add it at setup (engine.add(obj, { id: 'name' })), or make it a template and create it inside an op with engine.spawn(name, at)`));
|
|
134
|
+
}
|
|
135
|
+
if (tier === 'code') this.applySaved(obj, en.id);
|
|
136
|
+
}
|
|
137
|
+
/** The loaded save's override / removal for a code-tier id, now that its object exists */
|
|
138
|
+
applySaved(obj, id) {
|
|
139
|
+
const p = this.pending;
|
|
140
|
+
if (id in p.set) { this.override(id, obj, p.set[id]); delete p.set[id]; }
|
|
141
|
+
if (p.removed.has(id)) { p.removed.delete(id); this.hide(id, obj); }
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Write a normalised patch as an override; returns the values it replaced (undo puts them back) */
|
|
145
|
+
override(id, obj, patch) {
|
|
146
|
+
const keys = KEYS.filter(k => k in patch), now = snap(obj), before = { patch: pick(now, keys), had: this.over.has(id) };
|
|
147
|
+
let o = this.over.get(id);
|
|
148
|
+
if (!o) this.over.set(id, o = { orig: now, cur: {} });
|
|
149
|
+
write(obj, patch); Object.assign(o.cur, pick(snap(obj), keys));
|
|
150
|
+
return before;
|
|
151
|
+
}
|
|
152
|
+
/** thing.remove on a game object: detach, hold for undo / load; a stable id is remembered by the save */
|
|
153
|
+
hide(id, obj, saved = true) {
|
|
154
|
+
this.gone.set(id, { obj, parent: obj.parent ?? this.e.scene });
|
|
155
|
+
obj.removeFromParent();
|
|
156
|
+
if (saved) this.removed.add(id);
|
|
157
|
+
}
|
|
158
|
+
/** Put a held object back (undo of thing.remove, or a load that does not remove it) */
|
|
159
|
+
unhide(id) {
|
|
160
|
+
const g = this.gone.get(id); if (!g) return;
|
|
161
|
+
this.gone.delete(id); this.removed.delete(id);
|
|
162
|
+
g.parent.add(g.obj);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// ---------- the 'scene' save part ----------
|
|
166
|
+
save() {
|
|
167
|
+
const set = {}, removed = [...this.removed];
|
|
168
|
+
for (const [id, o] of this.over) set[id] = o.cur;
|
|
169
|
+
// orphans from the loaded save ride along: a later build that brings the object back still gets its data
|
|
170
|
+
for (const id in this.pending.set) set[id] ??= this.pending.set[id];
|
|
171
|
+
for (const id of this.pending.removed) if (!this.removed.has(id)) removed.push(id);
|
|
172
|
+
if (DEV) this.warnLost('saves.save()');
|
|
173
|
+
return { set, removed };
|
|
174
|
+
}
|
|
175
|
+
/** Replace overrides with the save's: undo the current ones first (newGame applies an empty part), then apply to live objects, keep the rest pending */
|
|
176
|
+
load(d) {
|
|
177
|
+
for (const [id, o] of this.over) { const obj = this.live(id); if (obj) write(obj, pick(o.orig, Object.keys(o.cur))); }
|
|
178
|
+
this.over.clear();
|
|
179
|
+
for (const id of [...this.removed]) this.unhide(id);
|
|
180
|
+
this.pending = { set: { ...d?.set }, removed: new Set(d?.removed ?? []) };
|
|
181
|
+
for (const id of Object.keys(this.pending.set).concat([...this.pending.removed])) {
|
|
182
|
+
const obj = this.live(id);
|
|
183
|
+
if (obj && this.tier(this.byObj.get(obj)) === 'code') this.applySaved(obj, id);
|
|
184
|
+
}
|
|
185
|
+
if (this.e.ready) this.warnOrphans();
|
|
186
|
+
}
|
|
187
|
+
/** Saved ids no object claimed: kept in the save (the code may bring them back), said once */
|
|
188
|
+
orphans() { return [...new Set([...Object.keys(this.pending.set), ...this.pending.removed])]; }
|
|
189
|
+
warnOrphans() {
|
|
190
|
+
const ids = this.orphans();
|
|
191
|
+
if (DEV && ids.length) warnOnce(coded('thing-orphan', `scene save part: no object has id ${ids.slice(0, 8).map(i => `'${i}'`).join(', ')}${ids.length > 8 ? ', …' : ''} (the code that added it with engine.add(obj, { id }) changed or no longer runs). The saved changes are kept; rename the id back, or ignore if it was deleted on purpose`));
|
|
192
|
+
}
|
|
193
|
+
/** Session-tier objects someone expected to keep, still alive: [{ id, at, op }] */
|
|
194
|
+
lost() {
|
|
195
|
+
const out = [];
|
|
196
|
+
for (const ref of this.unsaved) {
|
|
197
|
+
const o = ref.deref(), en = o && this.byObj.get(o);
|
|
198
|
+
if (!en || !o.parent) { this.unsaved.delete(ref); continue; }
|
|
199
|
+
out.push(en);
|
|
200
|
+
}
|
|
201
|
+
return out;
|
|
202
|
+
}
|
|
203
|
+
warnLost(where) {
|
|
204
|
+
const l = this.lost(); if (!l.length) return;
|
|
205
|
+
warnOnce(coded('thing-unsaved', `${where}: ${l.length} object(s) added with engine.add during play will not come back after a load (${l.slice(0, 5).map(en => `${en.id}${en.at ? ` at ${en.at}` : ''}${en.op ? ` in op ${en.op}` : ''}`).join(', ')}). To keep such things, make them a template and create them inside the op with engine.spawn(name, at)`));
|
|
206
|
+
}
|
|
207
|
+
/** Dev finding: two systems manage one object (kept for describe().scene.conflicts, warned once per text) */
|
|
208
|
+
conflict(text) {
|
|
209
|
+
if (!this.conflicts.includes(text)) { this.conflicts.push(text); if (this.conflicts.length > 20) this.conflicts.shift(); }
|
|
210
|
+
warnOnce(coded('thing-owned', text));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// Pure functions for workers: a function is sent as its source text and recompiled, so it cannot carry closure variables, `this`, or imports.
|
|
2
|
+
// The main thread runs the SAME recompiled copy (not the original), so a function that reads an outside variable fails identically with threads on or off,
|
|
3
|
+
// instead of working in development (threads off) and breaking only on machines with workers. Worker-safe: no imports.
|
|
4
|
+
const PURE_STRINGS = {
|
|
5
|
+
native: '{label}: must be a written-out function (not a built-in, bound or class method); it is sent to a worker as source text',
|
|
6
|
+
async: '{label}: cannot be async or a generator; a worker batch needs the result immediately',
|
|
7
|
+
parse: '{label}: could not be recompiled from its source text ({msg}); write it as (rec, dt) => { ... } or function (rec, dt) { ... }',
|
|
8
|
+
closure: '{label} runs in a worker and only sees its own parameters and globals like Math: {msg}. Put constants inside the function, or store the value on the record',
|
|
9
|
+
unknown: '[threads] pure function {key} was not defined in this worker',
|
|
10
|
+
};
|
|
11
|
+
const fmt = (s, o) => s.replace(/\{(\w+)\}/g, (m, k) => o[k] ?? m); // own copy: this file stays import-free for workers
|
|
12
|
+
/** Errors carry the stable code 'pure-function' (errorHints.js) as err.code and a [pure-function] tag */
|
|
13
|
+
const pureError = msg => Object.assign(new Error(msg + ' [pure-function]'), { code: 'pure-function' });
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Recompile a function from its source in an empty scope.
|
|
17
|
+
* @param {Function | string} fnOrSrc
|
|
18
|
+
* @param {string} label
|
|
19
|
+
* @returns {{ src: string, label: string, fn: Function, call: (...args: any[]) => any }}
|
|
20
|
+
*/
|
|
21
|
+
export function compilePure(fnOrSrc, label) {
|
|
22
|
+
const src = typeof fnOrSrc === 'string' ? fnOrSrc : Function.prototype.toString.call(fnOrSrc);
|
|
23
|
+
if (/\{\s*\[native code\]\s*\}$/.test(src) || /^class\b/.test(src)) throw pureError(fmt(PURE_STRINGS.native, { label }));
|
|
24
|
+
if (/^async\b|^function\s*\*|^\*/.test(src)) throw pureError(fmt(PURE_STRINGS.async, { label }));
|
|
25
|
+
let fn = null, used = src;
|
|
26
|
+
// method shorthand `grow(rec, dt) { ... }` is not an expression; read it as a function expression instead
|
|
27
|
+
for (const text of [src, 'function ' + src]) {
|
|
28
|
+
try { fn = new Function('"use strict"; return (' + text + ');')(); used = text; break; }
|
|
29
|
+
catch (err) { if (text !== src) throw pureError(fmt(PURE_STRINGS.parse, { label, msg: err.message })); }
|
|
30
|
+
}
|
|
31
|
+
const free = freeNames(used);
|
|
32
|
+
// caught here, not on the first call: in a worker that call happens steps later and far from the line that registered the function
|
|
33
|
+
if (free.length) throw pureError(fmt(PURE_STRINGS.closure, { label, msg: `it reads ${free.map(n => `'${n}'`).join(', ')}, which is neither its parameter nor a global` }));
|
|
34
|
+
const call = (...args) => {
|
|
35
|
+
try { return fn(...args); } catch (err) {
|
|
36
|
+
if (err instanceof ReferenceError) throw pureError(fmt(PURE_STRINGS.closure, { label, msg: err.message }));
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return { src, label, fn, call };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const KEYWORDS = new Set(('break case catch const continue debugger default delete do else false finally for function if in instanceof let new null of return switch this throw '
|
|
44
|
+
+ 'true try typeof var void while yield arguments undefined NaN Infinity get set static async await').split(' '));
|
|
45
|
+
// Globals a worker has too (plain JavaScript, no DOM): a name outside this list, such as engine, window, document or localStorage, exists only on the main
|
|
46
|
+
// thread, so reading it would work with threads off and fail in a worker. A fixed list, not `name in globalThis`, so both behave the same.
|
|
47
|
+
const WORKER_GLOBALS = new Set(('Math JSON Number String Boolean Array Object Symbol BigInt Date RegExp Map Set WeakMap WeakSet Promise Reflect Error TypeError '
|
|
48
|
+
+ 'RangeError ReferenceError SyntaxError parseInt parseFloat isNaN isFinite Float32Array Float64Array Int8Array Int16Array Int32Array Uint8Array '
|
|
49
|
+
+ 'Uint8ClampedArray Uint16Array Uint32Array BigInt64Array BigUint64Array ArrayBuffer DataView structuredClone console encodeURIComponent '
|
|
50
|
+
+ 'decodeURIComponent atob btoa TextEncoder TextDecoder Intl').split(' '));
|
|
51
|
+
/**
|
|
52
|
+
* Names a function's source reads that it neither declares nor gets from the worker-safe globals (a static scan: strings, comments and template text are
|
|
53
|
+
* skipped;
|
|
54
|
+
* property names after '.', object keys and shorthand methods are not reads). Errs on the side of missing a name rather than flagging a valid one.
|
|
55
|
+
* @param {string} src
|
|
56
|
+
*/
|
|
57
|
+
function freeNames(src) {
|
|
58
|
+
const code = src.replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*|'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|`(?:\\.|[^`\\])*`/g, ' 0 ');
|
|
59
|
+
const declared = new Set(), add = s => { for (const m of s.matchAll(/[A-Za-z_$][\w$]*/g)) declared.add(m[0]); };
|
|
60
|
+
// parameters (function, arrow, catch) and let / const / var / function / class names, destructuring included; default values are over-collected, which only hides names
|
|
61
|
+
for (const m of code.matchAll(/function\b[^(]*\(([^)]*)\)|\(([^()]*(?:\([^()]*\)[^()]*)*)\)\s*=>|([A-Za-z_$][\w$]*)\s*=>|catch\s*\(([^)]*)\)/g)) add(m[1] ?? m[2] ?? m[3] ?? m[4] ?? '');
|
|
62
|
+
for (const m of code.matchAll(/\b(?:let|const|var)\s+/g)) for (const t of declarators(code, m.index + m[0].length)) add(t);
|
|
63
|
+
for (const m of code.matchAll(/\b(?:function|class)\s+([A-Za-z_$][\w$]*)/g)) declared.add(m[1]);
|
|
64
|
+
for (const m of code.matchAll(/([A-Za-z_$][\w$]*)\s*\(([^()]*)\)\s*\{/g)) if (!/^(if|for|while|switch|catch|with|function)$/.test(m[1])) add(m[2]); // shorthand method parameters
|
|
65
|
+
const out = new Set();
|
|
66
|
+
for (const m of code.matchAll(/[A-Za-z_$][\w$]*/g)) {
|
|
67
|
+
const n = m[0], before = code.slice(0, m.index).trimEnd(), after = code.slice(m.index + n.length).trimStart();
|
|
68
|
+
if (declared.has(n) || KEYWORDS.has(n) || WORKER_GLOBALS.has(n) || /\.$/.test(before) || /^\d/.test(n)) continue;
|
|
69
|
+
if (/[{,]$/.test(before) && /^(:|\()/.test(after)) continue; // object key or shorthand method
|
|
70
|
+
out.add(n);
|
|
71
|
+
}
|
|
72
|
+
return [...out];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Binding targets of one let / const / var statement starting at i: `a = 1, { b, c } = o, d` gives 'a ', '{ b, c } ', 'd'. Declarators are split
|
|
77
|
+
* at commas outside brackets (a minifier joins consecutive declarations into one statement, so every one counts, not only the first); the
|
|
78
|
+
* statement ends at a ';' or a closing bracket outside them. `for (const x of list)` ends the target at of / in.
|
|
79
|
+
* @param {string} code
|
|
80
|
+
* @param {number} i
|
|
81
|
+
*/
|
|
82
|
+
function declarators(code, i) {
|
|
83
|
+
const out = [], cut = t => t.split(/\b(?:of|in)\b/)[0];
|
|
84
|
+
let depth = 0, start = i, target = null;
|
|
85
|
+
for (; i < code.length; i++) {
|
|
86
|
+
const ch = code[i];
|
|
87
|
+
if (ch === '(' || ch === '[' || ch === '{') depth++;
|
|
88
|
+
else if (ch === ')' || ch === ']' || ch === '}') { if (--depth < 0) break; }
|
|
89
|
+
else if (depth === 0 && ch === '=' && target === null && code[i + 1] !== '=' && code[i + 1] !== '>' && !/[=!<>]/.test(code[i - 1])) target = code.slice(start, i);
|
|
90
|
+
else if (depth === 0 && (ch === ',' || ch === ';')) {
|
|
91
|
+
out.push(cut(target ?? code.slice(start, i))); target = null; start = i + 1;
|
|
92
|
+
if (ch === ';') return out;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
out.push(cut(target ?? code.slice(start, i)));
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Collect the ArrayBuffers of typed arrays in a reply (a few levels deep) so postMessage moves them instead of copying. Shared buffers are skipped: they are already visible everywhere. */
|
|
100
|
+
export function transferables(v, out = [], depth = 0) {
|
|
101
|
+
if (!v || typeof v !== 'object' || depth > 3) return out;
|
|
102
|
+
if (ArrayBuffer.isView(v)) { if (v.buffer instanceof ArrayBuffer && !out.includes(v.buffer)) out.push(v.buffer); return out; }
|
|
103
|
+
for (const k in v) transferables(v[k], out, depth + 1);
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Handler for pure-function batches (also the body of core/pureWorker.js; engine.threads.pureLane() uses it as the local handler).
|
|
109
|
+
* { def: key, src, label } compiles once; { call: key, items: [[...args], ...] } calls fn(...args) for each item and replies with each item's arguments after the call
|
|
110
|
+
* (functions such as world far change their first argument in place) and its return value.
|
|
111
|
+
*/
|
|
112
|
+
export function pureHandler() {
|
|
113
|
+
const fns = new Map();
|
|
114
|
+
return msg => {
|
|
115
|
+
if (msg.def) { fns.set(msg.def, compilePure(msg.src, msg.label)); return null; }
|
|
116
|
+
const p = fns.get(msg.call);
|
|
117
|
+
if (!p) throw pureError(PURE_STRINGS.unknown.replace('{key}', msg.call));
|
|
118
|
+
return msg.items.map(args => { const value = p.call(...args); return { args, value }; });
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Worker side of engine.threads lanes: serve(handler) answers { id, data } messages with { id, data } (or { id, error }).
|
|
2
|
+
// id 0 is a broadcast (setup data): handled, no reply. Typed arrays in a reply are transferred, not copied.
|
|
3
|
+
// Worker-safe: imports only threadPure.js; never import three.js or Threads.js here (Threads.js creates workers, a worker bundle must not contain itself).
|
|
4
|
+
import { transferables } from './threadPure.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Start answering lane messages in a worker. handler is the same function the lane's local() returns on the main thread.
|
|
8
|
+
* @param {(msg: any) => any} handler
|
|
9
|
+
* @example // myWorker.js
|
|
10
|
+
* import { serve } from '../../core/threadServe.js';
|
|
11
|
+
* import { makeHandler } from './handler.js';
|
|
12
|
+
* serve(makeHandler());
|
|
13
|
+
*/
|
|
14
|
+
export function serve(handler) {
|
|
15
|
+
const fail = (id, err) => { if (id) self.postMessage({ id, error: err?.message || String(err) }); else console.error(err); };
|
|
16
|
+
const reply = (id, out) => { if (id) self.postMessage({ id, data: out }, transferables(out)); };
|
|
17
|
+
self.onmessage = e => {
|
|
18
|
+
const { id, data } = e.data;
|
|
19
|
+
let out;
|
|
20
|
+
try { out = handler(data); } catch (err) { fail(id, err); return; }
|
|
21
|
+
// a handler that must load something first (the path worker loads Recast) may answer with a promise
|
|
22
|
+
if (out && typeof out.then === 'function') out.then(v => reply(id, v), err => fail(id, err));
|
|
23
|
+
else reply(id, out);
|
|
24
|
+
};
|
|
25
|
+
}
|
package/core/tier.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Device tier: Engine uses it at construction to pick default quality (low-end devices default to no bloom and lower render resolution).
|
|
2
|
+
/** Roughly detect the device tier: phones and integrated GPUs count as low. Only sets defaults; the player can change it in settings. */
|
|
3
|
+
export function detectTier(renderer) {
|
|
4
|
+
try {
|
|
5
|
+
if (matchMedia('(pointer: coarse)').matches) return 'low';
|
|
6
|
+
const gl = renderer.getContext(), ext = gl.getExtension('WEBGL_debug_renderer_info');
|
|
7
|
+
const name = ext ? gl.getParameter(ext.UNMASKED_RENDERER_WEBGL) : '';
|
|
8
|
+
if (/intel|uhd|iris|mali|adreno|powervr|swiftshader|llvmpipe|software/i.test(name)) return 'low';
|
|
9
|
+
} catch { /* cannot tell: assume high-end */ }
|
|
10
|
+
return 'high';
|
|
11
|
+
}
|
package/core/util.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Small helpers several core files need. One definition each, so "what counts as a plain object" and "how a dotted path is read" cannot drift apart.
|
|
2
|
+
|
|
3
|
+
/** A plain data object: { } or Object.create(null); not an array, class instance, three.js object or function */
|
|
4
|
+
export const isPlainObject = v => v !== null && typeof v === 'object' && !Array.isArray(v) && [Object.prototype, null].includes(Object.getPrototypeOf(v));
|
|
5
|
+
|
|
6
|
+
/** Read a dotted path ('look.fog.color'); undefined as soon as a step is missing @param {any} obj @param {string} path */
|
|
7
|
+
export function getPath(obj, path) {
|
|
8
|
+
let v = obj;
|
|
9
|
+
for (const k of path.split('.')) v = v?.[k];
|
|
10
|
+
return v;
|
|
11
|
+
}
|
package/core/validate.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// Runtime checks: when an option or name is misspelled, print the fix to the console ("did you mean `xxx`?").
|
|
2
|
+
// Type checking (npm run types) catches mistakes while you write code; this catches the same kind at runtime, which also works for code without type checking.
|
|
3
|
+
//
|
|
4
|
+
// checkOptions('npcs.add()', opts, ['name', 'schedule', ...]) // warns once on a key in opts that is not recognized
|
|
5
|
+
// warnMissing('action', 'jupm', ['jump', 'run']) // 'action "jupm" does not exist, did you mean `jump`? (available: jump, run)'
|
|
6
|
+
// ownedProps('sky.sun.intensity', () => sun.intensity, "use engine.sky.modify('layerName', { sun })") // warns when the game edits a property that is
|
|
7
|
+
// overwritten every frame
|
|
8
|
+
//
|
|
9
|
+
// On by default; createEngine({ validate: false }) turns it all off (for release builds). Each message warns only once.
|
|
10
|
+
|
|
11
|
+
import { hintText } from './errorHints.js';
|
|
12
|
+
|
|
13
|
+
const STRINGS = {
|
|
14
|
+
unknownKey: '{where}: unknown option "{key}", {hint}',
|
|
15
|
+
didYouMean: 'did you mean `{name}`?',
|
|
16
|
+
available: 'available options: {list}',
|
|
17
|
+
missing: '{what} "{name}" does not exist, {hint} (available: {list})',
|
|
18
|
+
missingFar: '{what} "{name}" does not exist (available: {list})',
|
|
19
|
+
none: 'none yet',
|
|
20
|
+
more: ', ... {n} total',
|
|
21
|
+
eventTypo: 'event "{name}" was never emitted or listened to; did you mean `{hint}`? (shown only because the names are similar; ignore it if this really is a new event)',
|
|
22
|
+
requires: 'module {module} requires module "{name}", which is not installed; did you mean `{hint}`? (installed: {list})',
|
|
23
|
+
notOptions: '{where}: the second argument must be an options object {{ … }}, got {got}. API convention: a position is one argument, and size and the like go in the options object (see the API conventions)',
|
|
24
|
+
owned: '{where} is recomputed every frame, so setting it directly gets overwritten{hint}',
|
|
25
|
+
// Display names for each kind of name (the kind passed to warnMissing)
|
|
26
|
+
kinds: {
|
|
27
|
+
action: 'action', bus: 'audio bus', synth: 'synth', event: 'event', particle: 'particle effect', asset: 'asset', text: 'text key', module: 'module', weather: 'weather',
|
|
28
|
+
dialogue: 'dialogue', node: 'dialogue node', shot: 'camera shot', track: 'music track', entityType: 'entity type', quest: 'quest', ease: 'easing',
|
|
29
|
+
step: 'timeline step', animState: 'animation state', clip: 'animation clip', item: 'item', vegetation: 'vegetation', state: 'scenario', condition: 'condition word', effect: 'effect word', flowState: 'flow state', material: 'material role',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Fill {name} placeholders from p (an unknown or null one stays as written). The one copy core shares (threadPure.js keeps its own: it must stay import-free).
|
|
35
|
+
*/
|
|
36
|
+
export const fmt = (s, p) => s.replace(/\{(\w+)\}/g, (m, k) => p[k] ?? m);
|
|
37
|
+
// Page-wide by design: the validate switch, the warn-once set and allowOwned exemptions are shared by every engine on the page
|
|
38
|
+
// (one validate setting per page; tests that run several engines all use the same setting).
|
|
39
|
+
let enabled = true;
|
|
40
|
+
/** Dev mode: npm run dev, or the test bundle built by npm test / npm run shot (vite.config defines import.meta.env.THREEDOG_TEST when THREEDOG_TEST is set). */
|
|
41
|
+
// Written exactly `import.meta.env`: the Vite 8 dev server only rewrites that literal form; `(import.meta).env` stayed undefined there, so every dev check was
|
|
42
|
+
// off under npm run dev
|
|
43
|
+
// @ts-ignore Vite's import.meta.env (undefined outside Vite)
|
|
44
|
+
const ENV = import.meta.env;
|
|
45
|
+
export const DEV = !!(ENV?.DEV || ENV?.THREEDOG_TEST);
|
|
46
|
+
const warned = new Set();
|
|
47
|
+
|
|
48
|
+
/** Global switch (the validate option of createEngine) */
|
|
49
|
+
export function setValidate(on) { enabled = on !== false; }
|
|
50
|
+
|
|
51
|
+
/** Warn only once (no warning when checks are off) */
|
|
52
|
+
export function warnOnce(msg) {
|
|
53
|
+
if (!enabled || warned.has(msg)) return;
|
|
54
|
+
warned.add(msg);
|
|
55
|
+
console.warn(DEV ? msg + hintText(msg) : msg); // the fix + doc page only in dev: release builds drop the hint table
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Edit distance (case-insensitive; swapping two adjacent letters counts as 1, e.g. jupm -> jump) */
|
|
59
|
+
function distance(a, b) {
|
|
60
|
+
a = a.toLowerCase(); b = b.toLowerCase();
|
|
61
|
+
const d = Array.from({ length: a.length + 1 }, (_, i) => [i]);
|
|
62
|
+
for (let j = 1; j <= b.length; j++) d[0][j] = j;
|
|
63
|
+
for (let i = 1; i <= a.length; i++) for (let j = 1; j <= b.length; j++) {
|
|
64
|
+
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
65
|
+
if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
|
|
66
|
+
}
|
|
67
|
+
return d[a.length][b.length];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The entry of list closest to name; null if too far. Without maxDist the limit scales with length (longer names tolerate more errors). */
|
|
71
|
+
export function closest(name, list, maxDist) {
|
|
72
|
+
name = String(name);
|
|
73
|
+
const limit = maxDist ?? (name.length <= 4 ? 1 : name.length <= 8 ? 2 : 3);
|
|
74
|
+
let best = null, bd = Infinity;
|
|
75
|
+
for (const c of list) { if (c === name) continue; const d = distance(name, String(c)); if (d < bd) { bd = d; best = c; } }
|
|
76
|
+
return bd <= limit ? best : null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const listText = list => { const a = [...list]; return a.length ? a.slice(0, 15).join(', ') + (a.length > 15 ? fmt(STRINGS.more, { n: a.length }) : '') : STRINGS.none; };
|
|
80
|
+
|
|
81
|
+
/** Text like 'xxx "name" does not exist, did you mean `yyy`? (available: a, b, c)', shared by errors and warnings. */
|
|
82
|
+
export function missingText(kind, name, list) {
|
|
83
|
+
const c = closest(name, list), p = { what: STRINGS.kinds[kind] || kind, name, list: listText(list) };
|
|
84
|
+
return c ? fmt(STRINGS.missing, { ...p, hint: fmt(STRINGS.didYouMean, { name: c }) }) : fmt(STRINGS.missingFar, p);
|
|
85
|
+
}
|
|
86
|
+
/** A name does not exist: warn once */
|
|
87
|
+
export function warnMissing(kind, name, list) {
|
|
88
|
+
const id = kind + '\0' + name; // may be called every frame: count each name once
|
|
89
|
+
if (!enabled || warned.has(id)) return;
|
|
90
|
+
warned.add(id);
|
|
91
|
+
warnOnce(missingText(kind, name, list));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The one unknown-option rule, shared by readParams (strict) and checkOptions (loose): text for a key not in known, or null when it is fine.
|
|
96
|
+
* Why one function: the "did you mean" search and the wording must not drift between the two readers.
|
|
97
|
+
* soft: a key with no close match is not reported (data like items and entities, where games add their own fields).
|
|
98
|
+
*/
|
|
99
|
+
export function unknownOptionText(where, key, known, { soft = false } = {}) {
|
|
100
|
+
if (known.includes(key)) return null;
|
|
101
|
+
const c = closest(key, known);
|
|
102
|
+
if (!c && soft) return null;
|
|
103
|
+
return fmt(STRINGS.unknownKey, { where, key, hint: c ? fmt(STRINGS.didYouMean, { name: c }) : fmt(STRINGS.available, { list: known.join(', ') }) });
|
|
104
|
+
}
|
|
105
|
+
/** Is options an object a game passed (not a Three.js object, array or missing)? */
|
|
106
|
+
export const isOptionsObject = o => !!o && typeof o === 'object' && !Array.isArray(o) && !o.isObject3D && !o.isVector3;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Check an options object for unknown keys (the loose mode of readParams: same detection, same hint, but nothing is read or filled in).
|
|
110
|
+
* where is the origin (such as 'npcs.add()'), known are the keys the code actually reads.
|
|
111
|
+
* It only warns (once), in every build: the callers are hand-written checks of data and style objects that games and tests deliberately feed
|
|
112
|
+
* misspellings, and their known lists can lag behind the code. The module factories that went through readParams (the strict mode: dev throws,
|
|
113
|
+
* release warns once, decision 2026-11-01) get the throw there. loose: report only near-misses (items and entities, where games add their own fields).
|
|
114
|
+
*/
|
|
115
|
+
export function checkOptions(where, opts, known, { loose = false } = {}) {
|
|
116
|
+
if (!enabled || !isOptionsObject(opts)) return;
|
|
117
|
+
for (const k of Object.keys(opts)) {
|
|
118
|
+
const msg = unknownOptionText(where, k, known, { soft: loose });
|
|
119
|
+
if (!msg) continue;
|
|
120
|
+
warnOnce(msg);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Options argument under the new API convention: warn if a number or string was passed (most likely the old positional form), otherwise same as checkOptions.
|
|
126
|
+
*/
|
|
127
|
+
export function checkOptionsArg(where, opts, known) {
|
|
128
|
+
if (opts != null && typeof opts !== 'object') { warnOnce(fmt(STRINGS.notOptions, { where, got: JSON.stringify(opts) }).replace('{{ … }}', '{ … }')); return; }
|
|
129
|
+
checkOptions(where, opts, known);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Event name very close to another known event (dev only): warn only when 1 letter differs (2 for long names), to avoid false positives on the game's own
|
|
134
|
+
* events.
|
|
135
|
+
*/
|
|
136
|
+
export function checkEventName(name, known) {
|
|
137
|
+
const c = closest(name, known, name.length >= 12 ? 2 : 1), digits = s => s.replace(/\d+/g, '#');
|
|
138
|
+
if (c && digits(c) !== digits(name)) warnOnce(fmt(STRINGS.eventTypo, { name, hint: c }));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** An engine.use dependency is not installed: text with the fix when the name is close to an installed module, otherwise null. */
|
|
142
|
+
export function requiresText(module, name, installed) {
|
|
143
|
+
const c = closest(name, installed);
|
|
144
|
+
return c ? fmt(STRINGS.requires, { module, name, hint: c, list: listText(installed) }) : null;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ---------- properties overwritten every frame ----------
|
|
148
|
+
// Properties a module recomputes every frame (sky lights, camera position...) are silently overwritten if the game edits them directly. A module calls check()
|
|
149
|
+
// before writing and mark() after:
|
|
150
|
+
// if check() finds a value different from the last mark(), someone changed it in between, and it warns once. Active only in dev with checks on.
|
|
151
|
+
|
|
152
|
+
const exempt = new Set();
|
|
153
|
+
/** Legitimately take over these properties temporarily (such as a timeline tweening a light): allowOwned('timeline') ... allowOwned('timeline', false) */
|
|
154
|
+
export function allowOwned(owner, on = true) { if (on) exempt.add(owner); else exempt.delete(owner); }
|
|
155
|
+
/** where is the property name (for the message), read() returns a number or array of numbers (objects work too, compared by reference), hint is the fix. */
|
|
156
|
+
export function ownedProps(where, read, hint = '') {
|
|
157
|
+
let snap = null;
|
|
158
|
+
const on = () => enabled && DEV;
|
|
159
|
+
return {
|
|
160
|
+
check() {
|
|
161
|
+
if (!on() || !snap || exempt.size) return;
|
|
162
|
+
const v = [].concat(read());
|
|
163
|
+
if (v.length !== snap.length || v.some((x, i) => x !== snap[i])) warnOnce(fmt(STRINGS.owned, { where, hint: hint ? '. ' + hint : '' }));
|
|
164
|
+
},
|
|
165
|
+
mark() { if (on()) snap = [].concat(read()); },
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Freeze a shared definition (content template, item, entity type) and every plain object / array inside it, in place; returns it.
|
|
171
|
+
* Every instance reads the same definition, so a write would silently change all of them: frozen, the write throws instead
|
|
172
|
+
* (error hint 'frozen-definition' says to keep per-instance state on the world record). Functions and class instances are left alone.
|
|
173
|
+
* @example const def = freezeDef({ state: { opened: false } }); def.state.opened = true; // TypeError: Cannot assign to read only property 'opened'
|
|
174
|
+
* @template T
|
|
175
|
+
* @param {T} v
|
|
176
|
+
* @returns {T}
|
|
177
|
+
*/
|
|
178
|
+
export function freezeDef(v) {
|
|
179
|
+
if (!v || typeof v !== 'object' || Object.isFrozen(v)) return v;
|
|
180
|
+
const proto = Object.getPrototypeOf(v);
|
|
181
|
+
if (proto !== Object.prototype && proto !== Array.prototype && proto !== null) return v;
|
|
182
|
+
Object.freeze(v);
|
|
183
|
+
for (const k of Object.keys(v)) freezeDef(v[k]);
|
|
184
|
+
return v;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* A module's key for its action (inventory's open key, quests', photo's): the game passes keys (keys: [] for none), binds the action itself in
|
|
189
|
+
* createEngine({ bindings }), or spreads a presets.keys bundle. No module picks a key on its own: I / J / P are one genre's habits, not every game's.
|
|
190
|
+
* @param {string} fn the module call for the message, e.g. 'inventory()'
|
|
191
|
+
* @param {string} action
|
|
192
|
+
* @param {string | string[] | undefined} keys
|
|
193
|
+
* @param {string} preset the presets.keys entry that bundles a key, e.g. 'inventory'
|
|
194
|
+
* @param {any} input engine.input
|
|
195
|
+
* @returns {string[]}
|
|
196
|
+
* @internal
|
|
197
|
+
*/
|
|
198
|
+
export function moduleKeys(fn, action, keys, preset, input) {
|
|
199
|
+
if (keys !== undefined) return [].concat(keys);
|
|
200
|
+
if (input._bound[action]) return [].concat(input._bound[action]);
|
|
201
|
+
const call = fn.replace('()', '');
|
|
202
|
+
throw new TypeError(`[input-keys] ${fn}: no key for the '${action}' action (the engine binds no gameplay key). Pick one: ${call}({ ...presets.keys.${preset} }) `
|
|
203
|
+
+ `(import { presets } from 'threedog'), ${call}({ keys: ['KeyX'] }), createEngine({ bindings: { ${action}: ['KeyX'] } }), or ${call}({ keys: [] }) for no key`);
|
|
204
|
+
}
|