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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Props in world coordinates (the island is centred on 0, 0; the river runs east-west near z = 2, the wheat field is north-east around 14, -13).
|
|
2
|
+
// Trees ring the meadow, the flock grazes south of the river, facing different ways. rot is yaw in radians.
|
|
3
|
+
export default [
|
|
4
|
+
{ id: 'tree-1', template: 'tree', x: -18, z: -10, scale: 1.1, rot: 0.4 },
|
|
5
|
+
{ id: 'tree-2', template: 'tree', x: -11, z: -17, scale: 0.9, rot: 2.1 },
|
|
6
|
+
{ id: 'tree-3', template: 'tree', x: -21, z: -2, scale: 1.0, rot: 4.0 },
|
|
7
|
+
{ id: 'tree-4', template: 'tree', x: 12, z: 17, scale: 1.0, rot: 1.2 },
|
|
8
|
+
{ id: 'tree-5', template: 'tree', x: 19, z: 13, scale: 0.85, rot: 5.3 },
|
|
9
|
+
{ id: 'tree-6', template: 'tree', x: -2, z: -19, scale: 1.2, rot: 3.1 },
|
|
10
|
+
{ id: 'tree-7', template: 'tree', x: 24, z: -2, scale: 0.9, rot: 0.9 },
|
|
11
|
+
{ id: 'sheep-1', template: 'sheep', x: -7, z: 12, rot: 0.3 },
|
|
12
|
+
{ id: 'sheep-2', template: 'sheep', x: -4.5, z: 13.5, rot: -0.8 },
|
|
13
|
+
{ id: 'sheep-3', template: 'sheep', x: -8.5, z: 15, rot: 2.4 },
|
|
14
|
+
{ id: 'sheep-4', template: 'sheep', x: -5.5, z: 16.5, rot: 1.1 },
|
|
15
|
+
{ id: 'sheep-5', template: 'sheep', x: -2.5, z: 11, rot: -2.0 },
|
|
16
|
+
{ id: 'sheep-6', template: 'sheep', x: -10, z: 11.5, rot: 0.9, scale: 0.9 },
|
|
17
|
+
{ id: 'sheep-7', template: 'sheep', x: -3, z: 15.5, rot: 3.6, scale: 1.05 },
|
|
18
|
+
{ id: 'sheep-8', template: 'sheep', x: -1, z: 13, rot: -0.2, scale: 0.85 },
|
|
19
|
+
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Vegetation: the wheat field. Tufts grow only on the ground type 'wheat' (main.js groundType), so the field's edge is the terrain's, not a list
|
|
2
|
+
// of positions. rule cannot hold functions (it is sent to a worker thread).
|
|
3
|
+
export default {
|
|
4
|
+
wheat: {
|
|
5
|
+
model: 'wheatTuft', wind: 0.04, castShadow: true,
|
|
6
|
+
rule: { perChunk: 9000, cluster: 'none', scale: [1.1, 1.4], stretch: [0.9, 1.15], sink: 0.02, biomes: { wheat: 1 }, avoidFlat: false },
|
|
7
|
+
},
|
|
8
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Sheep island: a small floating island built only from the engine's public entry points (the acceptance scene of docs/plans/acceptance-sheepisland.md).
|
|
3
|
+
// A meadow with a river, round trees, a wheat field and a flock of sheep on an island with a ragged rim, over a pale backdrop with no horizon.
|
|
4
|
+
// Parameters (params.js): time day | dusk | night, weather clear | snow, view overview | flock | field | river | rim.
|
|
5
|
+
// main.js holds wiring only: modules, the island's terrain functions, view switching and the snow-to-winter link. Objects are content (rule R33),
|
|
6
|
+
// the look is the style pack in style/.
|
|
7
|
+
import { params, VIEW_NAMES } from './params.js'; // first: rewrites ?time=dusk style words before the engine reads the URL
|
|
8
|
+
import { createEngine, openWorld, presets, content, fixedCamera } from '../../index.js';
|
|
9
|
+
import style, { assets } from './style/index.js';
|
|
10
|
+
import data from './content/index.js';
|
|
11
|
+
import { VIEWS } from './views.js';
|
|
12
|
+
|
|
13
|
+
// ---------- 1. The island: outline, height and ground types are world rules, so they live here, not in the style ----------
|
|
14
|
+
// Every function runs in terrain workers: pure, only its parameters and Math (recipe 28 §1).
|
|
15
|
+
const island = {
|
|
16
|
+
resolution: 48, // 64 m chunk / 48 = 1.33 m cells: the rim is cut along cells, so finer cells give a finer brushed edge (recipe 42 §4)
|
|
17
|
+
height: (x, z, n) => {
|
|
18
|
+
const d = Math.abs(z - (6 * Math.sin(x * 0.09) + 2)); // distance to the river's centre line
|
|
19
|
+
return 3 + 1.2 * n.fbm(x * 0.03, z * 0.03) - (d < 3.2 ? (1 - d / 3.2) * 0.6 : 0); // a gentle meadow, a shallow dip for the river
|
|
20
|
+
},
|
|
21
|
+
groundType: (x, z) => {
|
|
22
|
+
if (Math.abs(z - (6 * Math.sin(x * 0.09) + 2)) < 2.4) return 'river';
|
|
23
|
+
const fx = (x - 14) / 9.5, fz = (z + 13) / 6.5; // the wheat field: an ellipse north-east of the river
|
|
24
|
+
return fx * fx + fz * fz < 1 ? 'wheat' : 'grass';
|
|
25
|
+
},
|
|
26
|
+
shape: {
|
|
27
|
+
mask: (x, z) => 30 - Math.hypot(x, z * 1.15), // > 0 is ground: a 60 x 52 m oval
|
|
28
|
+
// a ragged outline and a chipped rim. round stays 0: with round > 0 the bent-down top leaves see-through gaps above the wall (acceptance notes)
|
|
29
|
+
edge: { noise: 3, size: 9, jitter: 0.5, round: 0 },
|
|
30
|
+
// own wall material: it takes no season tint, so in snow the earth walls stay brown under a white top
|
|
31
|
+
side: { depth: 2.5, material: engine => engine.makeMaterial('cliff', { vertexColors: true }) },
|
|
32
|
+
bottom: { depth: (x, z, n, m) => 1.5 + m * 0.35 + 2 * n.fbm(x * 0.08, z * 0.08), ground: 'rock' }, // hangs lower inland
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// ---------- 2. Engine: own style, open-world preset with a fixed sky; a two-season calendar so snow can turn the island white ----------
|
|
37
|
+
const WINTER_DAY = 1001; // seasons last 1000 days each, so the season never blends towards the next one (it does over the last 20%)
|
|
38
|
+
const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), style, saveKey: 'threedog-sheepisland',
|
|
39
|
+
ui: { loading: { title: 'sheep island' } } });
|
|
40
|
+
engine.use(openWorld({ camera: fixedCamera(), terrain: island, water: false, rigid: false, ambience: false,
|
|
41
|
+
sky: { ...presets.calendar.fixedTime, time: 0.5, seasons: ['summer', 'winter'], daysPerSeason: 1000 },
|
|
42
|
+
weather: { ...presets.weather.temperate, start: 'clear' }, autoWeather: false }), content());
|
|
43
|
+
engine.assets.manifest(assets);
|
|
44
|
+
engine.content.load(data);
|
|
45
|
+
|
|
46
|
+
// ---------- 3. Snow means winter: the engine's season tint (style.seasons.winter) whitens foliage and ground ----------
|
|
47
|
+
// The weather module sends no change event and a weather has no ground cover of its own, so the calendar day follows the weather each frame.
|
|
48
|
+
engine.onFrame(() => {
|
|
49
|
+
const day = engine.weather?.name === 'snow' ? WINTER_DAY : 1;
|
|
50
|
+
if (engine.sky.day !== day) engine.sky.day = day;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// ---------- 4. Views: an op, so the URL, the dev bridge and tests switch the same way ----------
|
|
54
|
+
const state = { view: params.view };
|
|
55
|
+
engine.ops.define('sheepisland.view', {
|
|
56
|
+
desc: 'Move the camera to a named view: overview, flock, field, river, rim', args: { name: 'string' },
|
|
57
|
+
can: (e, { name }) => VIEW_NAMES.includes(name) ? true : 'unknownView',
|
|
58
|
+
run: (e, { name }) => {
|
|
59
|
+
const cam = /** @type {any} */ (engine.cameraRig);
|
|
60
|
+
for (const [n, v] of Object.entries(VIEWS)) cam.add(n, { position: v.pos, lookAt: v.look });
|
|
61
|
+
state.view = name; cam.cut(name);
|
|
62
|
+
return name;
|
|
63
|
+
},
|
|
64
|
+
reasons: { unknownView: 'View names: overview, flock, field, river, rim' },
|
|
65
|
+
});
|
|
66
|
+
engine.describe.add('sheepisland', () => ({ view: state.view, season: engine.sky.season, weather: engine.weather?.name }));
|
|
67
|
+
engine.events.on('engine:ready', () => engine.ops.run('sheepisland.view', { name: params.view }));
|
|
68
|
+
if (params.badView) console.warn(`sheepisland: unknown view '${params.badView}', showing overview. Views: ${VIEW_NAMES.join(', ')}`);
|
|
69
|
+
|
|
70
|
+
engine.start();
|
|
71
|
+
window.engine = engine; // handy for debugging in the browser console
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// URL parameters of the sheep island page. Import this file first in main.js: it rewrites word values into the forms the engine's own
|
|
2
|
+
// URL state understands (time=dusk -> 18:30, weather=雪 -> snow) before createEngine reads the URL. Same words as the style test page.
|
|
3
|
+
// time day | dusk | night (白天 黄昏 夜晚), or HH:MM weather clear | snow (晴 雪), or any engine weather name
|
|
4
|
+
// view overview | flock | field | river | rim (总览 羊群 麦田 河 边缘)
|
|
5
|
+
/** @type {Record<string, string>} */
|
|
6
|
+
const TIME = { day: '12:00', 白天: '12:00', dusk: '18:30', 黄昏: '18:30', night: '23:00', 夜晚: '23:00' };
|
|
7
|
+
/** @type {Record<string, string>} */
|
|
8
|
+
const WEATHER = { 晴: 'clear', 雪: 'snow' };
|
|
9
|
+
/** @type {Record<string, string>} */
|
|
10
|
+
const VIEWS = { 总览: 'overview', 羊群: 'flock', 麦田: 'field', 河: 'river', 边缘: 'rim' };
|
|
11
|
+
export const VIEW_NAMES = ['overview', 'flock', 'field', 'river', 'rim'];
|
|
12
|
+
|
|
13
|
+
const url = new URL(location.href), q = url.searchParams;
|
|
14
|
+
let changed = false;
|
|
15
|
+
for (const [key, map] of /** @type {[string, Record<string, string>][]} */ ([['time', TIME], ['weather', WEATHER]])) {
|
|
16
|
+
const v = q.get(key);
|
|
17
|
+
if (v && map[v]) { q.set(key, map[v]); changed = true; }
|
|
18
|
+
}
|
|
19
|
+
if (changed) history.replaceState(null, '', url);
|
|
20
|
+
|
|
21
|
+
const view = VIEWS[q.get('view')] ?? q.get('view') ?? 'overview';
|
|
22
|
+
export const params = Object.freeze({
|
|
23
|
+
view: VIEW_NAMES.includes(view) ? view : 'overview',
|
|
24
|
+
badView: q.has('view') && !VIEW_NAMES.includes(view) ? q.get('view') : null,
|
|
25
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// sheepisland: a style pack, LOOKS ONLY (recipes/09-style-pack.md, 35-style-from-reference.md), started from the new-style template
|
|
2
|
+
// (packages/tools/templates/style). A soft painted diorama: few flat colors, round shapes, soft shadows, a pale warm background with no horizon.
|
|
3
|
+
// The world (island outline, river, wheat field) is the game's terrain() in ../main.js, never here.
|
|
4
|
+
import { makeMaterial, applyEffects } from '../../../index.js';
|
|
5
|
+
import { models, PALETTE } from './models.js';
|
|
6
|
+
|
|
7
|
+
export { models };
|
|
8
|
+
/** Asset pack of the procedural models: engine.assets.manifest(assets) registers roundTree, sheep and wheatTuft */
|
|
9
|
+
export const assets = { name: 'sheepisland', models };
|
|
10
|
+
|
|
11
|
+
// Background: zenith = horizon = fog color at every time, so the dome is one flat tone and no horizon line shows.
|
|
12
|
+
// [time 0-1, zenith, horizon (= fog), sun color, sun intensity, ambient intensity]
|
|
13
|
+
// Ground material with snow that survives shading: 'texture'. The engine's season tint runs at color_fragment, before the per-chunk color map is
|
|
14
|
+
// multiplied in, so in 'mix' mode the map paints the green back over the white. This patch repeats the season mix later (emissivemap_fragment,
|
|
15
|
+
// after every color patch, before lighting), reading the engine's own season uniforms under new names (the season patch declares the old ones).
|
|
16
|
+
/** @param {any} engine */
|
|
17
|
+
function snowyGround(engine) {
|
|
18
|
+
const u = engine.uniforms;
|
|
19
|
+
return applyEffects(makeMaterial('terrain', { vertexColors: true }, engine), { clouds: false, patches: [{
|
|
20
|
+
name: 'snowCover', cacheKey: 1, uniforms: { uSnowTint: u.uGroundTint, uSnowMix: u.uGroundMix },
|
|
21
|
+
glsl: { fragment: { pars: 'uniform vec3 uSnowTint; uniform float uSnowMix;',
|
|
22
|
+
emissivemap_fragment: 'diffuseColor.rgb = mix(diffuseColor.rgb, uSnowTint, uSnowMix);' } } }] });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const DAY = 0xefebe4, DUSK = 0xf0d9c4, NIGHT = 0x2c3346;
|
|
26
|
+
export default {
|
|
27
|
+
name: 'sheepisland',
|
|
28
|
+
exposure: 1,
|
|
29
|
+
toneMapping: 'neutral', // neutral keeps the painted colors close to what is written here (aces darkens and shifts them)
|
|
30
|
+
|
|
31
|
+
post: [], // restraint: the reference shows no outline, bloom or grain
|
|
32
|
+
|
|
33
|
+
materials: {
|
|
34
|
+
default: { type: 'lambert' },
|
|
35
|
+
leaf: { type: 'lambert' },
|
|
36
|
+
bark: { type: 'lambert' },
|
|
37
|
+
wool: { type: 'lambert' },
|
|
38
|
+
face: { type: 'lambert' },
|
|
39
|
+
cliff: { type: 'lambert' },
|
|
40
|
+
vegetation: { type: 'lambert', side: 2 }, // the wheat stalks are thin: both sides (THREE.DoubleSide = 2)
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
// Soft light: half-lambert wrap so the shade side of a round blob is not black, and a cool blue shade instead of a gray one
|
|
44
|
+
lighting: { wrap: 0.45, shadowTint: { color: 0x7d88b8, strength: 0.45, soft: 0.3 } },
|
|
45
|
+
|
|
46
|
+
palette: PALETTE,
|
|
47
|
+
|
|
48
|
+
sky: {
|
|
49
|
+
keyframes: [
|
|
50
|
+
[0.00, NIGHT, NIGHT, 0x9aaad8, 0.7, 0.85],
|
|
51
|
+
[0.22, NIGHT, NIGHT, 0x9aaad8, 0.7, 0.85],
|
|
52
|
+
[0.30, DAY, DAY, 0xfff0dc, 1.8, 1.0],
|
|
53
|
+
[0.50, DAY, DAY, 0xfffaf0, 2.3, 1.15],
|
|
54
|
+
[0.70, DAY, DAY, 0xffe6c8, 1.9, 1.0],
|
|
55
|
+
[0.77, DUSK, DUSK, 0xffb07a, 1.5, 0.85],
|
|
56
|
+
[0.84, NIGHT, NIGHT, 0x9aaad8, 0.7, 0.85],
|
|
57
|
+
[1.00, NIGHT, NIGHT, 0x9aaad8, 0.7, 0.85],
|
|
58
|
+
],
|
|
59
|
+
groundTint: 0xb8c49a, // ambient bounce from below: the green of the meadow, not gray
|
|
60
|
+
sunBrightness: 0, sunGlow: 0, moonBrightness: 0, starDensity: 0, // a flat painted backdrop: no disc, glow or stars
|
|
61
|
+
clouds: { coverage: 0 },
|
|
62
|
+
shadow: { type: 'pcf', radius: 4, extent: 45, mapSize: 2048 }, // soft edges; the island is small, so a tight box keeps them sharp enough
|
|
63
|
+
fog: { kind: 'exp', density: 0.0015 }, // barely there: the far rim fades a touch into the backdrop
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
terrain: {
|
|
67
|
+
config: { shading: 'texture', colorResolution: 256 }, // crisp river bank and field edge without more triangles (recipe 37); 128 (0.5 m pixels) shows stairs up close
|
|
68
|
+
colors: { grassA: 0x92c062, grassB: 0x86b658, river: 0x6aa6d6, riverDeep: 0x5b97ca, wheatA: 0xdcae48, wheatB: 0xd2a442,
|
|
69
|
+
earth: 0xb98d64, rock: 0x94705a },
|
|
70
|
+
biomeColors: { grass: ['grassA', 'grassB'], river: ['river', 'riverDeep'], wheat: ['wheatA', 'wheatB'], cliff: ['earth'], rock: ['rock'] },
|
|
71
|
+
variation: { blend: { size: 14, strength: 0.6 }, jitter: { size: 0.5, min: 0.97, range: 0.04 } }, // low texture: almost no grain
|
|
72
|
+
material: snowyGround,
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// Snow: winter in the calendar turns foliage and ground most of the way to white ('mix', so green does not go muddy)
|
|
76
|
+
seasons: { mode: /** @type {const} */ ('mix'), strength: 0.82, winter: { foliage: 0xf6f6f8, ground: 0xf4f5f8 } },
|
|
77
|
+
// snow greys the sky towards overcastColor and dims the sun: keep the backdrop pale and the island readable
|
|
78
|
+
weather: { snow: { color: 0xffffff }, overcastColor: 0xe6e3de, types: { snow: { sun: 0.8, grey: 0.25 } } },
|
|
79
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// sheepisland procedural models: a round tree, a sheep, a wheat tuft. Built in code, no files; registered as an asset pack (index.js `assets`).
|
|
2
|
+
// Colors come from the palette (the engine calls a `function` generator with this.palette = style.palette).
|
|
3
|
+
// Shapes are clusters of smooth spheres: the reference reads as soft blobs, not facets. Shadow flags are set here (the engine does not guess them).
|
|
4
|
+
import { THREE, makeMaterial, applyEffects, mergeColored } from '../../../index.js';
|
|
5
|
+
|
|
6
|
+
/** Default palette of this pack: style.palette */
|
|
7
|
+
export const PALETTE = {
|
|
8
|
+
leaf: 0x6fa64a, // tree crown, main
|
|
9
|
+
leafLight: 0x8fbf5c, // tree crown, upper blobs
|
|
10
|
+
bark: 0x8a6448,
|
|
11
|
+
wool: 0xf3efe6,
|
|
12
|
+
face: 0x2b2725, // sheep face and legs
|
|
13
|
+
wheat: 0xe2b448,
|
|
14
|
+
wheatTip: 0xf0cf6a,
|
|
15
|
+
};
|
|
16
|
+
const pal = ctx => ({ ...PALETTE, ...ctx?.palette });
|
|
17
|
+
|
|
18
|
+
const mesh = (geo, mat) => { const m = new THREE.Mesh(geo, mat); m.castShadow = m.receiveShadow = true; return m; };
|
|
19
|
+
const ball = (r, x, y, z, detail = 3) => new THREE.IcosahedronGeometry(r, detail).translate(x, y, z);
|
|
20
|
+
|
|
21
|
+
// Crown blobs of the round tree: [radius, x, y, z]. Fixed, so every tree has the same silhouette; props vary scale and rotation.
|
|
22
|
+
const CROWN = [[1.7, 0, 3.6, 0], [1.25, 1.1, 3.1, 0.4], [1.2, -1.0, 3.2, -0.5], [1.1, 0.2, 4.6, -0.3], [1.0, -0.4, 3.0, 1.0]];
|
|
23
|
+
|
|
24
|
+
export const models = {
|
|
25
|
+
/** A round tree: short trunk, crown of five soft blobs. The crown takes the season tint (foliage), so a winter style turns it white */
|
|
26
|
+
roundTree: function () {
|
|
27
|
+
const c = pal(this), g = new THREE.Group();
|
|
28
|
+
g.add(mesh(new THREE.CylinderGeometry(0.22, 0.32, 2.6, 8).translate(0, 1.3, 0), makeMaterial('bark', { color: c.bark })));
|
|
29
|
+
// two shades in one geometry: upper blobs lighter, as if lit from above; vertex colors so it stays one draw
|
|
30
|
+
const crown = mergeColored(CROWN.map(([r, x, y, z], i) => [ball(r, x, y, z), i === 3 ? c.leafLight : c.leaf]), { flat: false }); // flat: false = smooth blobs (the default is faceted)
|
|
31
|
+
// applyEffects season: material specs have no `season` key, so a code-built model opts in here (see the acceptance notes)
|
|
32
|
+
g.add(mesh(crown, applyEffects(makeMaterial('leaf', { vertexColors: true }), { season: 'foliage' })));
|
|
33
|
+
return g;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
/** A sheep, about 1.4 m long, facing +Z: a body of wool blobs, a black head and four black legs */
|
|
37
|
+
sheep: function () {
|
|
38
|
+
const c = pal(this), g = new THREE.Group();
|
|
39
|
+
const wool = mergeColored([[0.5, 0, 0.75, 0], [0.42, 0, 0.8, 0.38], [0.42, 0, 0.8, -0.38], [0.36, 0.22, 0.98, 0], [0.36, -0.22, 0.98, 0.1]]
|
|
40
|
+
.map(([r, x, y, z]) => [ball(r, x, y, z, 2), c.wool]), { flat: false });
|
|
41
|
+
g.add(mesh(wool, makeMaterial('wool', { vertexColors: true })));
|
|
42
|
+
const black = makeMaterial('face', { color: c.face });
|
|
43
|
+
g.add(mesh(new THREE.SphereGeometry(0.22, 16, 12).scale(0.85, 1, 1.25).translate(0, 0.9, 0.78), black)); // head
|
|
44
|
+
for (const [x, z] of [[0.2, 0.32], [-0.2, 0.32], [0.2, -0.32], [-0.2, -0.32]])
|
|
45
|
+
g.add(mesh(new THREE.CylinderGeometry(0.06, 0.06, 0.5, 6).translate(x, 0.25, z), black)); // legs
|
|
46
|
+
return g;
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
/** One wheat tuft for content vegetation (a generator returning a geometry): nine stalks with ears, vertex-colored, one draw per chunk */
|
|
50
|
+
wheatTuft: function () {
|
|
51
|
+
const c = pal(this), parts = [];
|
|
52
|
+
for (let i = 0; i < 9; i++) {
|
|
53
|
+
const a = i * 2.4, r = i ? 0.06 + 0.02 * i : 0, x = Math.cos(a) * r, z = Math.sin(a) * r, h = 0.85 + (i % 3) * 0.1;
|
|
54
|
+
parts.push([new THREE.CylinderGeometry(0.012, 0.018, h, 3).translate(x, h / 2, z), c.wheat]);
|
|
55
|
+
parts.push([new THREE.SphereGeometry(0.06, 5, 4).scale(1, 2.6, 1).translate(x, h + 0.08, z), c.wheatTip]);
|
|
56
|
+
}
|
|
57
|
+
return mergeColored(/** @type {any} */ (parts));
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Named camera positions of the sheep island. Same name = same framing every time, so two screenshots differ only by time, weather or style.
|
|
2
|
+
// The island is centred on (0, 0) and is about 60 m across; positions are [x, y, z] in world space.
|
|
3
|
+
export const VIEWS = {
|
|
4
|
+
overview: { pos: [0, 36, 48], look: [0, -1, 0] }, // the whole island floating on the backdrop, from the south, a little above
|
|
5
|
+
flock: { pos: [4, 7, 26], look: [-5, 1, 13] }, // the sheep, the river behind them
|
|
6
|
+
field: { pos: [26, 12, 6], look: [13, 1, -12] }, // the wheat field and the trees beyond
|
|
7
|
+
river: { pos: [-4, 12, 9], look: [-6, 1, 0] }, // the river banks from above: how crisp the ground-type border is
|
|
8
|
+
rim: { pos: [-30, 5, 30], look: [-20, 0, 16] }, // the ragged rim and the wall under it, seen from just above the edge
|
|
9
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Game map: styletest (generated, do not edit by hand)
|
|
2
|
+
|
|
3
|
+
> Generated by `npm run map` by scanning this folder; paths are relative to it. Pages: /styletest.html, entry `main.js`.
|
|
4
|
+
> Content data is in `content/*.js` (condition/effect syntax: `node_modules/threedog/docs/recipes/20-content-actions-save.md`), which main.js hands to the engine with `engine.content.load()`; for the engine API read `node_modules/threedog/docs/API.md` (index) first, then only the module pages listed below.
|
|
5
|
+
|
|
6
|
+
Content: items 3 · npcs 1 · places 2 · props 12 (from templates 6) · templates 6 · vegetation 5
|
|
7
|
+
|
|
8
|
+
## Design decisions (hand-written, from DESIGN.md)
|
|
9
|
+
|
|
10
|
+
None yet, write them in `DESIGN.md` (why it is designed this way, what not to change).
|
|
11
|
+
|
|
12
|
+
## Engine modules (engine.use)
|
|
13
|
+
|
|
14
|
+
- createEngine: { style: parts.length ? parts : undefined, strings: terrainStrings, saveKey: 'threedog-styletest', ui: { load…
|
|
15
|
+
- openWorld preset ({ camera: fixedCamera(), seed: SEED, terrain: terrainPreset(), flatten: [{ x: stage.x, z: stage.z, …) → world, terrain, vegetation, sky, weather, water, collision, rigid, characters, ambience, settings, debug
|
|
16
|
+
- interactions ({ ...presets.interactions.nearest })
|
|
17
|
+
- dialogue ({ holdSeconds: 1e6 })
|
|
18
|
+
- inventory ({ ...presets.keys.inventory })
|
|
19
|
+
- hud
|
|
20
|
+
- lightPool ({ point: 2 })
|
|
21
|
+
- content
|
|
22
|
+
|
|
23
|
+
## Read for this game (per installed module: recipe · api page; core API: `node_modules/threedog/docs/api/engine.md`)
|
|
24
|
+
|
|
25
|
+
- world: `node_modules/threedog/docs/recipes/18-world.md` · `node_modules/threedog/docs/api/world.md`
|
|
26
|
+
- terrain: `node_modules/threedog/docs/recipes/28-terrain.md` · `node_modules/threedog/docs/api/terrain.md`
|
|
27
|
+
- vegetation: `node_modules/threedog/docs/recipes/10-blender-level.md` · `node_modules/threedog/docs/api/vegetation.md`
|
|
28
|
+
- sky: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/sky.md`
|
|
29
|
+
- weather: `node_modules/threedog/docs/recipes/08-weather-sky.md` · `node_modules/threedog/docs/api/weather.md`
|
|
30
|
+
- water: `node_modules/threedog/docs/recipes/44-water-weather-look-hooks.md` · `node_modules/threedog/docs/api/water.md`
|
|
31
|
+
- collision: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/collision.md`
|
|
32
|
+
- rigid: `node_modules/threedog/docs/recipes/11-vehicles.md` · `node_modules/threedog/docs/api/rigid.md`
|
|
33
|
+
- characters: `node_modules/threedog/docs/recipes/12-navmesh.md` · `node_modules/threedog/docs/api/characters.md`
|
|
34
|
+
- ambience: `node_modules/threedog/docs/recipes/31-audio.md` · `node_modules/threedog/docs/api/ambience.md`
|
|
35
|
+
- …7 more modules: their pages are in `node_modules/threedog/docs/api/`
|
|
36
|
+
|
|
37
|
+
Not used yet (check these before writing the system yourself):
|
|
38
|
+
|
|
39
|
+
- saves: save your own state: `engine.saves.register(key, { version, save, load })` (node_modules/threedog/docs/recipes/20-content-actions-save.md)
|
|
40
|
+
- quests: goals with steps, conditions and rewards: `quests({ ...presets.keys.quests })` (keys required), content/quests.js (node_modules/threedog/docs/recipes/04-quests.md)
|
|
41
|
+
- grids: cell placement for farming and building: `grids()` (node_modules/threedog/docs/recipes/29-grid.md)
|
|
42
|
+
|
|
43
|
+
## Files
|
|
44
|
+
|
|
45
|
+
content/*.js is content data: how to write it in `node_modules/threedog/docs/recipes/` (02-npc, 03-items-pickups, 04-quests, 20-content-actions-save…).
|
|
46
|
+
|
|
47
|
+
| File | Lines | Description |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| content/index.js | 10 | |
|
|
50
|
+
| content/items.js | 9 | |
|
|
51
|
+
| content/npcs.js | 9 | |
|
|
52
|
+
| content/places.js | 6 | |
|
|
53
|
+
| content/props.js | 17 | |
|
|
54
|
+
| content/templates.js | 10 | |
|
|
55
|
+
| content/vegetation.js | 32 | |
|
|
56
|
+
| look.js | 12 | This example's look, a style part merged over the lowpoly pack (createEngine({ style: [lowpoly, loo… |
|
|
57
|
+
| main.js | 96 | @ts-check Style test: one fixed scene to judge a style pack by (and the check an AI runs after turn… |
|
|
58
|
+
| models.js | 88 | The exhibits that are not in the lowpoly asset pack, built in code and registered by name in main.j… |
|
|
59
|
+
| overrides.js | 34 | What the style workbench exports: the values the user changed, as a plain object literal to paste i… |
|
|
60
|
+
| panel.js | 136 | Style workbench (?panel=1): sliders and color pickers over the running style test, plus an export o… |
|
|
61
|
+
| params.js | 33 | URL parameters of the style test page. Import this file first in main.js: it rewrites word values i… |
|
|
62
|
+
| views.js | 32 | Named camera positions of the style test. Same name = same framing every time, so two screenshots d… |
|
|
63
|
+
|
|
64
|
+
## NPCs (content/npcs.js)
|
|
65
|
+
|
|
66
|
+
| id | Name | Schedule | Dialogue entry |
|
|
67
|
+
|---|---|---|---|
|
|
68
|
+
| guide | Guide | wander | — |
|
|
69
|
+
|
|
70
|
+
## Dialogues (content/dialogues.js, node → destination)
|
|
71
|
+
|
|
72
|
+
(none)
|
|
73
|
+
|
|
74
|
+
## Items (content/items.js)
|
|
75
|
+
|
|
76
|
+
| id | Name | Description | Stack |
|
|
77
|
+
|---|---|---|---|
|
|
78
|
+
| apple | 🍎 Apple | Crisp and a little sour | 20 |
|
|
79
|
+
| key | 🗝 Brass key | Opens nothing in particular | 1 |
|
|
80
|
+
| wood | 🪵 Wood | Dry and light | 99 |
|
|
81
|
+
|
|
82
|
+
Starting inventory: apple×5, key×1, wood×12. Pickups: 0.
|
|
83
|
+
|
|
84
|
+
## Quests (content/quests.js)
|
|
85
|
+
|
|
86
|
+
(none)
|
|
87
|
+
|
|
88
|
+
## Trigger zones, level markers, places
|
|
89
|
+
|
|
90
|
+
- Place stage: a flat spot near water (found at startup); all exhibits are placed relative to it
|
|
91
|
+
- Place water: the nearest water to the stage (found at startup)
|
|
92
|
+
|
|
93
|
+
## Object templates (content/templates.js; placed with props { template }, spawned with engine.spawn)
|
|
94
|
+
|
|
95
|
+
| Template | Model | Collide | Interact (op / label) | Container | State (defaults) | Instances |
|
|
96
|
+
|---|---|---|---|---|---|---|
|
|
97
|
+
| woodBlock | woodBlock | — | — | — | — | 1 placed (stage) |
|
|
98
|
+
| stoneBlock | stoneBlock | — | — | — | — | 1 placed (stage) |
|
|
99
|
+
| metalBall | metalBall | — | — | — | — | 1 placed (stage) |
|
|
100
|
+
| glassPanes | glassPanes | — | — | — | — | 1 placed (stage) |
|
|
101
|
+
| shadowStage | shadowStage | — | — | — | — | 1 placed (stage) |
|
|
102
|
+
| room | room | — | — | — | — | 1 placed (stage) |
|
|
103
|
+
|
|
104
|
+
## Placements (the level is content; counts per content file)
|
|
105
|
+
|
|
106
|
+
- content/props.js: 12 (pine×1, roundTree×1, rock×1, flower×3, template woodBlock×1, template stoneBlock×1, template metalBall×1, template glassPanes×1, template shadowStage×1, template room×1); 12 with an explicit id, places: stage
|
|
107
|
+
- content/npcs.js: 1 (guide)
|
|
108
|
+
- content/vegetation.js: 5 rules (instances generated from each rule)
|
|
109
|
+
|
|
110
|
+
Code that breaks saves or manages world models: none (rule R33).
|
|
111
|
+
|
|
112
|
+
## Timed events (engine.clock, engine.sky)
|
|
113
|
+
|
|
114
|
+
- between('18:00', '06:00') — main.js
|
|
115
|
+
|
|
116
|
+
## Key actions defined by the game (the engine's own are in node_modules/threedog/docs/CODEMAP.md)
|
|
117
|
+
|
|
118
|
+
(none)
|
|
119
|
+
|
|
120
|
+
## Events the game emits / listens to
|
|
121
|
+
|
|
122
|
+
| Event | Emitted by the game | Listened to by the game |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| engine:ready | — | main.js |
|
|
125
|
+
|
|
126
|
+
## Saves
|
|
127
|
+
|
|
128
|
+
- Save prefix saveKey: threedog-styletest
|
|
129
|
+
- Saved parts of the engine modules (vars, inventory, quests, timers, world...): `npx threedog catalog` (saves per module)
|
|
130
|
+
|
|
131
|
+
## Style pack keys
|
|
132
|
+
|
|
133
|
+
- Style pack: parts
|
|
134
|
+
- Models (asset names): pine, pineLow, roundTree, roundTreeLow, rock, grass, flower, woodBlock, stoneBlock, metalBall, glassPanes, shadowStage, room
|
|
135
|
+
- Vegetation (content/vegetation.js): 松树, 圆树, 石头, 草, 野花
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Merge every content file in content/ into one object that main.js passes to engine.content.load(). Add a line here for each new content file.
|
|
2
|
+
import places from './places.js';
|
|
3
|
+
import items, { startItems } from './items.js';
|
|
4
|
+
import npcs from './npcs.js';
|
|
5
|
+
import vegetation from './vegetation.js';
|
|
6
|
+
import templates from './templates.js';
|
|
7
|
+
import props from './props.js';
|
|
8
|
+
|
|
9
|
+
export default { places, items, startItems, npcs, vegetation, templates, props };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Items for the bag window of the ui view. stack is the max per slot; color is the color when dropped on the ground.
|
|
2
|
+
export default {
|
|
3
|
+
apple: { name: 'Apple', icon: '🍎', desc: 'Crisp and a little sour', stack: 20 },
|
|
4
|
+
key: { name: 'Brass key', icon: '🗝', desc: 'Opens nothing in particular', stack: 1, color: 0xc8a850 },
|
|
5
|
+
wood: { name: 'Wood', icon: '🪵', desc: 'Dry and light', color: 0x8a5a36 },
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const startItems = { apple: 5, key: 1, wood: 12 };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// One character for the close-up view: wander with radius 0 keeps it standing where it starts (a behavior without a schedule).
|
|
2
|
+
export default {
|
|
3
|
+
guide: {
|
|
4
|
+
name: 'Guide',
|
|
5
|
+
colors: { body: 0x4f6d8f, legs: 0x5b4a3a, hair: 0xd8d4cc },
|
|
6
|
+
start: { place: 'stage', x: 2.5, z: 4 }, behavior: 'wander', mind: { radius: 0 },
|
|
7
|
+
},
|
|
8
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Place names: main.js finds a flat spot near water at startup (terrain is procedural). `stage` is where every exhibit stands; `water` is a point on the nearest water.
|
|
2
|
+
export default {
|
|
3
|
+
stage: 'a flat spot near water (found at startup); all exhibits are placed relative to it',
|
|
4
|
+
water: 'the nearest water to the stage (found at startup)',
|
|
5
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The exhibits, relative to the stage (x right, z toward the overview camera, which stands at z = +24).
|
|
2
|
+
// Back row: trees, rock, flowers. Middle row: wood / stone / metal, glass, shadow receiver. Right: the room (interior and exterior in one piece).
|
|
3
|
+
export default [
|
|
4
|
+
{ id: 'pine', model: 'pine', place: 'stage', x: -14, z: -8, scale: 1.2 },
|
|
5
|
+
{ id: 'round-tree', model: 'roundTree', place: 'stage', x: -9, z: -8 },
|
|
6
|
+
{ id: 'rock', model: 'rock', place: 'stage', x: -5, z: -7, rot: 0.6, scale: 1.4 },
|
|
7
|
+
{ id: 'flower-a', model: ['flower', 0xf2d16b], place: 'stage', x: -2.4, z: -5 },
|
|
8
|
+
{ id: 'flower-b', model: ['flower', 0xe08aa0], place: 'stage', x: -1.4, z: -5.4 },
|
|
9
|
+
{ id: 'flower-c', model: ['flower', 0xa8c8f0], place: 'stage', x: -0.6, z: -4.8 },
|
|
10
|
+
{ id: 'wood', template: 'woodBlock', place: 'stage', x: 1.5, z: -3 },
|
|
11
|
+
{ id: 'stone', template: 'stoneBlock', place: 'stage', x: 4, z: -3 },
|
|
12
|
+
{ id: 'metal', template: 'metalBall', place: 'stage', x: 6.5, z: -3 },
|
|
13
|
+
{ id: 'glass', template: 'glassPanes', place: 'stage', x: -6, z: 2.5 },
|
|
14
|
+
{ id: 'shadow-stage', template: 'shadowStage', place: 'stage', x: -1.5, z: 3 },
|
|
15
|
+
{ id: 'room', template: 'room', place: 'stage', x: 14, z: -2, y: 0.02 },
|
|
16
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Templates: the exhibits. Model names are registered in main.js (models.js); trees, rocks and flowers come from the lowpoly asset pack.
|
|
2
|
+
export default {
|
|
3
|
+
woodBlock: { model: 'woodBlock' },
|
|
4
|
+
stoneBlock: { model: 'stoneBlock' },
|
|
5
|
+
metalBall: { model: 'metalBall' },
|
|
6
|
+
glassPanes: { model: 'glassPanes' },
|
|
7
|
+
shadowStage: { model: 'shadowStage' },
|
|
8
|
+
room: { model: 'room' },
|
|
9
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Vegetation: name -> model (an asset name from the lowpoly asset pack; use an array for parameters) and growth rule.
|
|
2
|
+
// rule.biomes lists the biomes it grows in, values are spawn probabilities; rule cannot hold functions (it is sent to a worker thread).
|
|
3
|
+
export default {
|
|
4
|
+
松树: {
|
|
5
|
+
model: 'pine', lod: 'pineLow', wind: 0.022,
|
|
6
|
+
rule: { perChunk: 130, minHeight: 1.6, maxHeight: 40, maxSlope: 0.6, cluster: 'forest', scale: [0.75, 1.6], stretch: [0.85, 1.2], sink: 0.15,
|
|
7
|
+
biomes: { forest: 1, meadow: 0.35, snow: 0.6, wetland: 0.3, riverbank: 0.3 }, collider: 0.35,
|
|
8
|
+
tints: [{ color: [1.35, 1.05, 0.55], chance: 0.06 }] },
|
|
9
|
+
},
|
|
10
|
+
圆树: {
|
|
11
|
+
model: 'roundTree', lod: 'roundTreeLow', wind: 0.03,
|
|
12
|
+
rule: { perChunk: 50, minHeight: 1.6, maxHeight: 22, maxSlope: 0.45, scale: [0.8, 1.3], collider: 0.3,
|
|
13
|
+
biomes: { meadow: 0.8, savanna: 0.35, riverbank: 0.9, forest: 0.3 },
|
|
14
|
+
tints: [{ color: [1.4, 1.0, 0.5], chance: 0.15 }] },
|
|
15
|
+
},
|
|
16
|
+
石头: {
|
|
17
|
+
model: 'rock', maxRing: 3,
|
|
18
|
+
rule: { perChunk: 14, chance: 0.6, minHeight: 0.5, maxHeight: 70, maxSlope: 2, scale: [0.4, 1.6], stretch: [0.5, 0.8], sink: 0.2, tintJitter: 0.15, collider: 0.6 },
|
|
19
|
+
},
|
|
20
|
+
草: {
|
|
21
|
+
model: 'grass', nearOnly: true, maxRing: 1, wind: 0.3,
|
|
22
|
+
rule: { perChunk: 1800, chance: 0.75, minHeight: 1.4, maxHeight: 20, maxSlope: 0.42, scale: [0.7, 1.4], sink: 0.05, avoidFlat: false,
|
|
23
|
+
biomes: { meadow: 1, forest: 0.6, riverbank: 1, wetland: 1, savanna: 0.8 } },
|
|
24
|
+
},
|
|
25
|
+
野花: {
|
|
26
|
+
model: ['flower', 0xf2d16b], nearOnly: true, maxRing: 1, wind: 0.25,
|
|
27
|
+
rule: { perChunk: 260, minHeight: 1.5, maxHeight: 14, maxSlope: 0.35, scale: [0.8, 1.3], sink: 0,
|
|
28
|
+
biomes: { meadow: 1, riverbank: 0.6 },
|
|
29
|
+
tints: [{ color: [1.6, 0.6, 0.7], chance: 0.35 }, { color: [0.8, 0.9, 1.6], chance: 0.25 }] },
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This example's look, a style part merged over the lowpoly pack (createEngine({ style: [lowpoly, look] })): how the test surfaces feel.
|
|
2
|
+
// The exhibits ask for roles wood / stone / metal / glass; a style that does not define them falls back to materials.default.
|
|
3
|
+
export default {
|
|
4
|
+
name: 'styletest',
|
|
5
|
+
materials: {
|
|
6
|
+
wood: { type: 'lambert' },
|
|
7
|
+
stone: { type: 'lambert', flatShading: true },
|
|
8
|
+
metal: { type: 'standard', metalness: 0.9, roughness: 0.3 }, // only looks like metal with environment light: ?env=1
|
|
9
|
+
glass: { type: 'phong', shininess: 100 },
|
|
10
|
+
},
|
|
11
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Style test: one fixed scene to judge a style pack by (and the check an AI runs after turning a reference picture into a style).
|
|
3
|
+
// Exhibits (content/): character, trees, rock, grass, flowers, water, terrain, glass, a shadow receiver, wood / stone / metal, a lit room (outside and inside),
|
|
4
|
+
// and the UI parts (HUD, dialogue, bag) on the `ui` view. Parameters (params.js): time, weather, style, env, view, panel. Camera views: views.js.
|
|
5
|
+
// main.js holds wiring only: modules, finding the stage, view switching, the lamp. The exhibits are content (rule R33).
|
|
6
|
+
import { params } from './params.js'; // first: rewrites ?time=dusk style words before the engine reads the URL
|
|
7
|
+
import { createEngine, openWorld, presets, content, interactions, dialogue, inventory, fixedCamera, hud, lightPool, createTerrain } from '../../index.js';
|
|
8
|
+
import lowpoly, { assets as lowpolyAssets } from '@threedog/style-lowpoly'; // optional package: the style under test, and the procedural trees / rocks
|
|
9
|
+
import { terrainPreset, riverAt, terrainStrings } from '@threedog/terrain-noise';
|
|
10
|
+
import look from './look.js';
|
|
11
|
+
import data from './content/index.js';
|
|
12
|
+
import { woodBlock, stoneBlock, metalBall, glassPanes, shadowStage, room } from './models.js';
|
|
13
|
+
import { makeViews, pathAt } from './views.js';
|
|
14
|
+
|
|
15
|
+
// ---------- 0. The stage: a flat spot with water close by (same seed = same place every run) ----------
|
|
16
|
+
const SEED = 1337, preview = createTerrain({ seed: SEED, ...terrainPreset() });
|
|
17
|
+
/** Nearest point under water within maxR of (x, z), or null */
|
|
18
|
+
function waterNear(x, z, maxR) {
|
|
19
|
+
for (let r = 8; r <= maxR; r += 3) for (let a = 0; a < 6.28; a += 0.3) {
|
|
20
|
+
const wx = x + Math.cos(a) * r, wz = z + Math.sin(a) * r;
|
|
21
|
+
if (preview.surface(wx, wz) < preview.waterLevel - 1.2) return { x: wx, z: wz };
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
let stage = { x: 0, z: 0 }, water = { x: 30, z: 0 };
|
|
26
|
+
for (let r = 0, found = false; r < 3000 && !found; r += 10) {
|
|
27
|
+
const a = r * 0.37, x = Math.cos(a) * r, z = Math.sin(a) * r, h = preview.surface(x, z);
|
|
28
|
+
if (h > 4 && h < 10 && preview.slope(x, z) < 0.2 && riverAt(x, z, preview.noise) === 0) {
|
|
29
|
+
const w = waterNear(x, z, 60);
|
|
30
|
+
if (w) { stage = { x, z }; water = w; found = true; }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ---------- 1. Engine: style under test + open-world preset with a fixed sky (no clock drift between screenshots) ----------
|
|
35
|
+
const parts = params.style === 'none' ? [] : [lowpoly, look];
|
|
36
|
+
if (params.overrides) parts.push(params.overrides); // the workbench's "rebuild preview" values
|
|
37
|
+
const engine = createEngine({ canvas: /** @type {HTMLCanvasElement} */ (document.getElementById('view')), style: parts.length ? parts : undefined, strings: terrainStrings, saveKey: 'threedog-styletest',
|
|
38
|
+
ui: { loading: { title: 'style test' } } });
|
|
39
|
+
engine.use(openWorld({ camera: fixedCamera(), seed: SEED, terrain: terrainPreset(), flatten: [{ x: stage.x, z: stage.z, radius: 30 }], sky: { ...presets.calendar.fixedTime, time: 0.5 },
|
|
40
|
+
weather: presets.weather.temperate, autoWeather: false }),
|
|
41
|
+
interactions({ ...presets.interactions.nearest }), dialogue({ holdSeconds: 1e6 }), inventory({ ...presets.keys.inventory }), hud(), lightPool({ point: 2 }), content());
|
|
42
|
+
|
|
43
|
+
engine.assets.manifest(lowpolyAssets);
|
|
44
|
+
engine.assets.manifest({ name: 'styletest', models: { woodBlock, stoneBlock, metalBall, glassPanes, shadowStage, room } }); // the names content/templates.js uses
|
|
45
|
+
engine.characters.createPlayer({ ...presets.player.thirdPerson, spawn: { x: stage.x + 0.5, z: stage.z + 6 } });
|
|
46
|
+
engine.content.load(data, { places: { stage, water } });
|
|
47
|
+
if (params.env) { engine.look.env.replace('sky'); engine.look.env.set({ intensity: 0.8 }); engine.sky.modify('env', { ambient: 0.6 }); } // soft ambient from the sky: lower the hemisphere ambient so shadows stay
|
|
48
|
+
|
|
49
|
+
// ---------- 2. The room's lamp: emissive plus one pooled light, on from 18:00 to 06:00 ----------
|
|
50
|
+
const lampPos = [stage.x + 14, engine.surface(stage.x + 14, stage.z - 2) + 2.7, stage.z - 2];
|
|
51
|
+
const lampLight = engine.lightPool.add({ x: lampPos[0], y: lampPos[1], z: lampPos[2] }, { color: 0xffc070, intensity: 0, distance: 9 });
|
|
52
|
+
let lampOn = false;
|
|
53
|
+
engine.sky.between('18:00', '06:00', { on: () => { lampOn = true; }, off: () => { lampOn = false; } });
|
|
54
|
+
engine.onFrame(() => {
|
|
55
|
+
const lamp = /** @type {import('three').Mesh<any, import('three').MeshLambertMaterial> | undefined} */ (engine.world.view('room')?.getObjectByName('lamp'));
|
|
56
|
+
if (lamp) lamp.material.emissiveIntensity = lampOn ? 1.6 : 0;
|
|
57
|
+
lampLight.set({ intensity: lampOn ? 5 : 0 });
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// ---------- 3. Views: an op, so the URL, the dev bridge and tests switch the same way ----------
|
|
61
|
+
/** @type {{ view: string, since: number, views: ReturnType<typeof makeViews> }} */
|
|
62
|
+
const state = { view: params.view, since: 0, views: /** @type {any} */ (null) };
|
|
63
|
+
/** Show the UI exhibits only on the ui view; close them when leaving it */
|
|
64
|
+
function showUi(on) {
|
|
65
|
+
if (on) {
|
|
66
|
+
engine.dialogue.say('The light is best just before dusk. Mind the step.', { speaker: 'Guide', lock: false });
|
|
67
|
+
engine.ui.open('inventory');
|
|
68
|
+
} else { engine.dialogue.end(); engine.ui.close('inventory'); }
|
|
69
|
+
}
|
|
70
|
+
/** Fixed camera (views.js shots): a view is a shot, cut to at once. The path shot is moved along its line every frame, from the moment it is chosen */
|
|
71
|
+
function setView(name) {
|
|
72
|
+
const cam = /** @type {any} */ (engine.cameraRig), views = makeViews(engine, stage, water);
|
|
73
|
+
for (const [n, v] of Object.entries(views)) cam.add(n, { position: v.pos, lookAt: v.look });
|
|
74
|
+
state.view = name; state.since = engine.elapsed; state.views = views;
|
|
75
|
+
showUi(name === 'ui');
|
|
76
|
+
cam.cut(name);
|
|
77
|
+
}
|
|
78
|
+
engine.onFrame(() => {
|
|
79
|
+
if (state.view === 'path' && state.views) /** @type {any} */ (engine.cameraRig).shots.path.position.fromArray(pathAt(state.views.path, engine.elapsed - state.since));
|
|
80
|
+
});
|
|
81
|
+
engine.ops.define('styletest.view', {
|
|
82
|
+
desc: 'Move the camera to a named view: overview, character, water, room, path, ui', args: { name: 'string' },
|
|
83
|
+
can: (e, { name }) => ['overview', 'character', 'water', 'room', 'path', 'ui'].includes(name) ? true : 'unknownView',
|
|
84
|
+
run: (e, { name }) => { setView(name); return name; },
|
|
85
|
+
reasons: { unknownView: 'View names: overview, character, water, room, path, ui' },
|
|
86
|
+
});
|
|
87
|
+
engine.describe.add('styletest', () => ({ view: state.view, style: params.style, env: params.env, panel: params.panel, stage: { x: +stage.x.toFixed(1), z: +stage.z.toFixed(1) } }));
|
|
88
|
+
engine.events.on('engine:ready', () => engine.ops.run('styletest.view', { name: params.view }));
|
|
89
|
+
if (params.badView) console.warn(`styletest: unknown view '${params.badView}', showing overview. Views: overview, character, water, room, path, ui`);
|
|
90
|
+
|
|
91
|
+
// The workbench is a dev tool loaded only on ?panel=1 (its package may be missing: panel.js then says so in the page)
|
|
92
|
+
if (params.panel) import('./panel.js').then(m => m.openPanel(engine, params.overrides));
|
|
93
|
+
|
|
94
|
+
engine.start();
|
|
95
|
+
window.engine = engine; // handy for debugging in the browser console
|