agentshire 1.0.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 +36 -0
- package/LICENSE +21 -0
- package/README.md +437 -0
- package/README.zh-CN.md +441 -0
- package/ROADMAP.md +207 -0
- package/THIRD_PARTY_NOTICES.md +49 -0
- package/VISION.md +101 -0
- package/index.ts +386 -0
- package/openclaw.plugin.json +27 -0
- package/package.json +100 -0
- package/src/bridge/AGENTS.md +136 -0
- package/src/bridge/ActivityStream.ts +184 -0
- package/src/bridge/CitizenManager.ts +280 -0
- package/src/bridge/DirectorBridge.ts +1076 -0
- package/src/bridge/EventTranslator.ts +142 -0
- package/src/bridge/NpcEventQueue.ts +61 -0
- package/src/bridge/ReconnectManager.ts +42 -0
- package/src/bridge/RouteManager.ts +270 -0
- package/src/bridge/StateTracker.ts +100 -0
- package/src/bridge/ToolVfxMapper.ts +94 -0
- package/src/bridge/__tests__/ActivityStream.test.ts +156 -0
- package/src/bridge/__tests__/CitizenManager.test.ts +174 -0
- package/src/bridge/__tests__/EventTranslator.test.ts +292 -0
- package/src/bridge/__tests__/NpcEventQueue.test.ts +92 -0
- package/src/bridge/__tests__/RouteManager.test.ts +106 -0
- package/src/bridge/data/route-config.json +36 -0
- package/src/bridge/data/route-config.ts +19 -0
- package/src/bridge/implicit-chat.ts +192 -0
- package/src/bridge/index.ts +12 -0
- package/src/contracts/agent-state.ts +87 -0
- package/src/contracts/agui.ts +212 -0
- package/src/contracts/chat.ts +67 -0
- package/src/contracts/events.ts +170 -0
- package/src/contracts/index.ts +71 -0
- package/src/contracts/media.ts +77 -0
- package/src/contracts/registry.ts +32 -0
- package/src/plugin/AGENTS.md +192 -0
- package/src/plugin/__tests__/editor-serve-megapack.test.ts +150 -0
- package/src/plugin/__tests__/hook-translator.test.ts +197 -0
- package/src/plugin/auto-config.ts +131 -0
- package/src/plugin/channel.ts +399 -0
- package/src/plugin/chat-asset-resolver.ts +75 -0
- package/src/plugin/chat-session-watcher.ts +98 -0
- package/src/plugin/citizen-agent-manager.ts +178 -0
- package/src/plugin/citizen-chat-router.ts +83 -0
- package/src/plugin/citizen-workshop-manager.ts +96 -0
- package/src/plugin/custom-asset-manager.ts +250 -0
- package/src/plugin/editor-serve.ts +1368 -0
- package/src/plugin/group-discussion.ts +223 -0
- package/src/plugin/hook-translator.ts +202 -0
- package/src/plugin/llm-agent-proxy.ts +193 -0
- package/src/plugin/outbound-adapter.ts +187 -0
- package/src/plugin/paths.ts +33 -0
- package/src/plugin/plan-manager.ts +594 -0
- package/src/plugin/runtime.ts +9 -0
- package/src/plugin/session-history.ts +838 -0
- package/src/plugin/session-log-watcher.ts +221 -0
- package/src/plugin/soul-prompt-template.ts +290 -0
- package/src/plugin/subagent-tracker.ts +205 -0
- package/src/plugin/tools.ts +493 -0
- package/src/plugin/town-session.ts +40 -0
- package/src/plugin/ws-server.ts +680 -0
- package/src/town-souls.ts +134 -0
- package/town-frontend/dist/assets/CustomAssetStore-oi8aIurt.js +2 -0
- package/town-frontend/dist/assets/GLTFLoader-BA5RqSME.js +3804 -0
- package/town-frontend/dist/assets/OrbitControls-ZmySp9sQ.js +2 -0
- package/town-frontend/dist/assets/SettingsPanel-BO52reJe.js +2 -0
- package/town-frontend/dist/assets/SkeletonUtils-BCVmgslc.js +2 -0
- package/town-frontend/dist/assets/SkillLearnCard-Dk38iDpy.js +6 -0
- package/town-frontend/dist/assets/TopicSetupPanel-DLaLHB_Z.js +2 -0
- package/town-frontend/dist/assets/Trap-Bold-CT0JBE39.woff2 +0 -0
- package/town-frontend/dist/assets/Trap-SemiBold-R4_-Ld0j.woff2 +0 -0
- package/town-frontend/dist/assets/WeatherSystem-Cb3BvHes.js +550 -0
- package/town-frontend/dist/assets/avatars/char-female-a.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-female-b.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-female-c.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-female-d.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-female-e.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-female-f.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-male-a.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-male-b.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-male-c.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-male-d.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-male-e.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-male-f.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-beaver.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-bee.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-bunny.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-cat.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-caterpillar.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-chick.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-cow.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-crab.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-deer.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-dog.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-elephant.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-fish.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-fox.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-giraffe.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-hog.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-koala.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-lion.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-monkey.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-panda.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-parrot.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-penguin.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-pig.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-polar.webp +0 -0
- package/town-frontend/dist/assets/avatars/char-pet-tiger.webp +0 -0
- package/town-frontend/dist/assets/character-catalog-DSmLtlNC.js +2 -0
- package/town-frontend/dist/assets/citizenEditor-DubGSJOQ.js +296 -0
- package/town-frontend/dist/assets/command-parser-BUd15Bmv.js +12 -0
- package/town-frontend/dist/assets/editor-B5QO0OtX.js +258 -0
- package/town-frontend/dist/assets/editor-Bk8g1NCD.css +1 -0
- package/town-frontend/dist/assets/index-BWfrufil.js +2 -0
- package/town-frontend/dist/assets/index-faS20RJk.js +6 -0
- package/town-frontend/dist/assets/logo-DJI6EtST.png +0 -0
- package/town-frontend/dist/assets/logo-title-AdKPZX5E.png +0 -0
- package/town-frontend/dist/assets/main-CqsN43aT.js +224 -0
- package/town-frontend/dist/assets/main-D7neuy3w.css +1 -0
- package/town-frontend/dist/assets/models/buildings/base.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/base.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/bench.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/bench.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/box_A.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/box_A.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/box_B.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/box_B.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_A.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_A.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_A_withoutBase.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_A_withoutBase.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_B.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_B.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_B_withoutBase.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_B_withoutBase.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_C.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_C.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_C_withoutBase.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_C_withoutBase.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_D.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_D.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_D_withoutBase.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_D_withoutBase.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_E.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_E.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_E_withoutBase.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_E_withoutBase.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_F.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_F.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_F_withoutBase.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_F_withoutBase.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_G.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_G.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_G_withoutBase.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_G_withoutBase.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_H.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_H.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/building_H_withoutBase.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/building_H_withoutBase.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/bush.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/bush.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/car_hatchback.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/car_hatchback.gltf +442 -0
- package/town-frontend/dist/assets/models/buildings/car_police.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/car_police.gltf +442 -0
- package/town-frontend/dist/assets/models/buildings/car_sedan.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/car_sedan.gltf +442 -0
- package/town-frontend/dist/assets/models/buildings/car_stationwagon.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/car_stationwagon.gltf +442 -0
- package/town-frontend/dist/assets/models/buildings/car_taxi.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/car_taxi.gltf +442 -0
- package/town-frontend/dist/assets/models/buildings/citybits_texture.png +0 -0
- package/town-frontend/dist/assets/models/buildings/dumpster.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/dumpster.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/firehydrant.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/firehydrant.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/road_corner.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/road_corner.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/road_corner_curved.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/road_corner_curved.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/road_junction.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/road_junction.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/road_straight.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/road_straight.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/road_straight_crossing.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/road_straight_crossing.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/road_tsplit.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/road_tsplit.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/streetlight.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/streetlight.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/trafficlight_A.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/trafficlight_A.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/trafficlight_B.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/trafficlight_B.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/trafficlight_C.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/trafficlight_C.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/trash_A.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/trash_A.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/trash_B.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/trash_B.gltf +136 -0
- package/town-frontend/dist/assets/models/buildings/watertower.bin +0 -0
- package/town-frontend/dist/assets/models/buildings/watertower.gltf +136 -0
- package/town-frontend/dist/assets/models/characters/Textures/colormap.png +0 -0
- package/town-frontend/dist/assets/models/characters/character-female-a.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-female-b.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-female-c.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-female-d.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-female-e.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-female-f.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-male-a.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-male-b.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-male-c.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-male-d.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-male-e.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-male-f.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-beaver.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-bee.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-bunny.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-cat.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-caterpillar.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-chick.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-cow.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-crab.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-deer.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-dog.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-elephant.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-fish.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-fox.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-giraffe.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-hog.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-koala.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-lion.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-monkey.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-panda.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-parrot.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-penguin.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-pig.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-polar.glb +0 -0
- package/town-frontend/dist/assets/models/characters/character-pet-tiger.glb +0 -0
- package/town-frontend/dist/assets/models/characters/colormap.png +0 -0
- package/town-frontend/dist/assets/models/furniture/armchair.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/armchair.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/armchair_pillows.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/armchair_pillows.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/bed_double_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/bed_double_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/bed_double_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/bed_double_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/bed_single_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/bed_single_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/bed_single_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/bed_single_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/book_set.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/book_set.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/book_single.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/book_single.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/cabinet_medium.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/cabinet_medium.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/cabinet_medium_decorated.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/cabinet_medium_decorated.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/cabinet_small.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/cabinet_small.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/cabinet_small_decorated.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/cabinet_small_decorated.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/cactus_medium_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/cactus_medium_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/cactus_medium_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/cactus_medium_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/cactus_small_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/cactus_small_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/cactus_small_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/cactus_small_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/chair_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/chair_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/chair_A_wood.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/chair_A_wood.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/chair_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/chair_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/chair_B_wood.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/chair_B_wood.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/chair_C.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/chair_C.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/chair_stool.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/chair_stool.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/chair_stool_wood.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/chair_stool_wood.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/couch.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/couch.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/couch_pillows.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/couch_pillows.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/furniturebits_texture.png +0 -0
- package/town-frontend/dist/assets/models/furniture/lamp_standing.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/lamp_standing.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/lamp_table.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/lamp_table.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_large_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_large_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_large_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_large_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_medium.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_medium.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_small_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_small_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_small_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_small_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_small_C.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_small_C.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_standing_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_standing_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_standing_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/pictureframe_standing_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/pillow_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/pillow_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/pillow_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/pillow_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/rug_oval_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/rug_oval_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/rug_oval_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/rug_oval_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/rug_rectangle_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/rug_rectangle_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/rug_rectangle_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/rug_rectangle_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_A.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_A.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_B.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/rug_rectangle_stripes_B.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/shelf_A_big.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/shelf_A_big.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/shelf_A_small.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/shelf_A_small.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/shelf_B_large.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/shelf_B_large.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/shelf_B_large_decorated.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/shelf_B_large_decorated.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/shelf_B_small.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/shelf_B_small.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/shelf_B_small_decorated.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/shelf_B_small_decorated.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/table_low.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/table_low.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/table_medium.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/table_medium.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/table_medium_long.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/table_medium_long.gltf +136 -0
- package/town-frontend/dist/assets/models/furniture/table_small.bin +0 -0
- package/town-frontend/dist/assets/models/furniture/table_small.gltf +136 -0
- package/town-frontend/dist/assets/models/props/bench.bin +0 -0
- package/town-frontend/dist/assets/models/props/bench.gltf +136 -0
- package/town-frontend/dist/assets/models/props/bush.bin +0 -0
- package/town-frontend/dist/assets/models/props/bush.gltf +136 -0
- package/town-frontend/dist/assets/models/props/capybara.glb +0 -0
- package/town-frontend/dist/assets/models/props/car_hatchback.bin +0 -0
- package/town-frontend/dist/assets/models/props/car_hatchback.gltf +442 -0
- package/town-frontend/dist/assets/models/props/car_sedan.bin +0 -0
- package/town-frontend/dist/assets/models/props/car_sedan.gltf +442 -0
- package/town-frontend/dist/assets/models/props/car_taxi.bin +0 -0
- package/town-frontend/dist/assets/models/props/car_taxi.gltf +442 -0
- package/town-frontend/dist/assets/models/props/citybits_texture.png +0 -0
- package/town-frontend/dist/assets/models/props/dumpster.bin +0 -0
- package/town-frontend/dist/assets/models/props/dumpster.gltf +136 -0
- package/town-frontend/dist/assets/models/props/firehydrant.bin +0 -0
- package/town-frontend/dist/assets/models/props/firehydrant.gltf +136 -0
- package/town-frontend/dist/assets/models/props/streetlight.bin +0 -0
- package/town-frontend/dist/assets/models/props/streetlight.gltf +136 -0
- package/town-frontend/dist/assets/models/props/trafficlight_A.bin +0 -0
- package/town-frontend/dist/assets/models/props/trafficlight_A.gltf +136 -0
- package/town-frontend/dist/assets/models/props/trash_A.bin +0 -0
- package/town-frontend/dist/assets/models/props/trash_A.gltf +136 -0
- package/town-frontend/dist/assets/models/props/watertower.bin +0 -0
- package/town-frontend/dist/assets/models/props/watertower.gltf +136 -0
- package/town-frontend/dist/assets/models/stage-deco/Flowers_1_D.glb +0 -0
- package/town-frontend/dist/assets/models/stage-deco/Flowers_2_B.glb +0 -0
- package/town-frontend/dist/assets/models/stage-deco/Grass_A_1.glb +0 -0
- package/town-frontend/dist/assets/models/stage-deco/Park_GrassHill_A.glb +0 -0
- package/town-frontend/dist/assets/models/stage-deco/Pebles_1_A_2.glb +0 -0
- package/town-frontend/dist/assets/music/bgm_day.mp3 +0 -0
- package/town-frontend/dist/assets/music/bgm_dusk.mp3 +0 -0
- package/town-frontend/dist/assets/music/bgm_night.mp3 +0 -0
- package/town-frontend/dist/assets/music/bgm_work.mp3 +0 -0
- package/town-frontend/dist/assets/office-whiteboard-idle-CyEwBrq_.webp +0 -0
- package/town-frontend/dist/assets/preview-B6hYEQij.js +2 -0
- package/town-frontend/dist/assets/town-BKesnERP.js +8888 -0
- package/town-frontend/dist/assets/town-BnswKsjF.css +1 -0
- package/town-frontend/dist/citizen-editor.html +166 -0
- package/town-frontend/dist/editor.html +227 -0
- package/town-frontend/dist/index.html +22 -0
- package/town-frontend/dist/preview.html +56 -0
- package/town-frontend/dist/town.html +165 -0
- package/town-frontend/dist/viewer.html +91 -0
- package/town-souls/CHEN.md +130 -0
- package/town-souls/CHENGZI.md +92 -0
- package/town-souls/CITIZEN_tpl.md +16 -0
- package/town-souls/DIANDIAN.md +92 -0
- package/town-souls/HAITANG.md +94 -0
- package/town-souls/QIQI.md +119 -0
- package/town-souls/SOUL.md +141 -0
- package/town-souls/SOUL_tpl.md +135 -0
- package/town-souls/XIAOLIE.md +107 -0
- package/town-souls/YAN.md +107 -0
- package/town-workspace/IDENTITY.md +5 -0
- package/town-workspace/SOUL.md +141 -0
- package/town-workspace/project-workflow.md +81 -0
- package/town-workspace/town-defaults.json +92 -0
- package/town-workspace/town-guide.md +45 -0
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
var Rt=Object.defineProperty;var Gt=(y,t,e)=>t in y?Rt(y,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):y[t]=e;var r=(y,t,e)=>Gt(y,typeof t!="symbol"?t+"":t,e);import{M,O as Et,v as B,y as yt,z as $,U as pt,o as D,E as it,I as nt,N as Ot,a as Bt,C as u,V as g,J as rt,l as T,x as Dt,K as $t,Q as tt,T as U,g as X,B as ht,e as ot,G as W,X as E,Y as Ut,Z as at,s as et,w as q,_ as H,j as _t,$ as Pt,a0 as Ft,t as gt,i as Nt,a1 as Vt,a2 as Wt,k as ct,a3 as Ht,a4 as Kt,n as N,F as Qt,a5 as Yt,d as ut}from"./GLTFLoader-BA5RqSME.js";import{c as wt}from"./SkeletonUtils-BCVmgslc.js";import{b as qt}from"./character-catalog-DSmLtlNC.js";const Lt={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
2
|
+
|
|
3
|
+
varying vec2 vUv;
|
|
4
|
+
|
|
5
|
+
void main() {
|
|
6
|
+
|
|
7
|
+
vUv = uv;
|
|
8
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
9
|
+
|
|
10
|
+
}`,fragmentShader:`
|
|
11
|
+
|
|
12
|
+
uniform float opacity;
|
|
13
|
+
|
|
14
|
+
uniform sampler2D tDiffuse;
|
|
15
|
+
|
|
16
|
+
varying vec2 vUv;
|
|
17
|
+
|
|
18
|
+
void main() {
|
|
19
|
+
|
|
20
|
+
vec4 texel = texture2D( tDiffuse, vUv );
|
|
21
|
+
gl_FragColor = opacity * texel;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
}`};class st{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Xt=new Et(-1,1,1,-1,0,1);class jt extends B{constructor(){super(),this.setAttribute("position",new yt([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new yt([0,2,0,0,2,0],2))}}const Zt=new jt;class zt{constructor(t){this._mesh=new M(Zt,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,Xt)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}class Jt extends st{constructor(t,e){super(),this.textureID=e!==void 0?e:"tDiffuse",t instanceof $?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=pt.clone(t.uniforms),this.material=new $({name:t.name!==void 0?t.name:"unspecified",defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this.fsQuad=new zt(this.material)}render(t,e,s){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=s.texture),this.fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class Mt extends st{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,s){const i=t.getContext(),n=t.state;n.buffers.color.setMask(!1),n.buffers.depth.setMask(!1),n.buffers.color.setLocked(!0),n.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),n.buffers.stencil.setTest(!0),n.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),n.buffers.stencil.setFunc(i.ALWAYS,a,4294967295),n.buffers.stencil.setClear(o),n.buffers.stencil.setLocked(!0),t.setRenderTarget(s),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),n.buffers.color.setLocked(!1),n.buffers.depth.setLocked(!1),n.buffers.color.setMask(!0),n.buffers.depth.setMask(!0),n.buffers.stencil.setLocked(!1),n.buffers.stencil.setFunc(i.EQUAL,1,4294967295),n.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),n.buffers.stencil.setLocked(!0)}}class te extends st{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class ee{constructor(t,e){if(this.renderer=t,this._pixelRatio=t.getPixelRatio(),e===void 0){const s=t.getSize(new D);this._width=s.width,this._height=s.height,e=new it(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:nt}),e.texture.name="EffectComposer.rt1"}else this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new Jt(Lt),this.copyPass.material.blending=Ot,this.clock=new Bt}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);e!==-1&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){t===void 0&&(t=this.clock.getDelta());const e=this.renderer.getRenderTarget();let s=!1;for(let i=0,n=this.passes.length;i<n;i++){const a=this.passes[i];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),a.render(this.renderer,this.writeBuffer,this.readBuffer,t,s),a.needsSwap){if(s){const o=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),l.setFunc(o.EQUAL,1,4294967295)}this.swapBuffers()}Mt!==void 0&&(a instanceof Mt?s=!0:a instanceof te&&(s=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(t===void 0){const e=this.renderer.getSize(new D);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,t=this.renderTarget1.clone(),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const s=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(s,i),this.renderTarget2.setSize(s,i);for(let n=0;n<this.passes.length;n++)this.passes[n].setSize(s,i)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class se extends st{constructor(t,e,s=null,i=null,n=null){super(),this.scene=t,this.camera=e,this.overrideMaterial=s,this.clearColor=i,this.clearAlpha=n,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new u}render(t,e,s){const i=t.autoClear;t.autoClear=!1;let n,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(t.getClearColor(this._oldClearColor),t.setClearColor(this.clearColor)),this.clearAlpha!==null&&(n=t.getClearAlpha(),t.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:s),this.clear===!0&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),this.clearColor!==null&&t.setClearColor(this._oldClearColor),this.clearAlpha!==null&&t.setClearAlpha(n),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),t.autoClear=i}}const ie={uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new u(0)},defaultOpacity:{value:0}},vertexShader:`
|
|
25
|
+
|
|
26
|
+
varying vec2 vUv;
|
|
27
|
+
|
|
28
|
+
void main() {
|
|
29
|
+
|
|
30
|
+
vUv = uv;
|
|
31
|
+
|
|
32
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
33
|
+
|
|
34
|
+
}`,fragmentShader:`
|
|
35
|
+
|
|
36
|
+
uniform sampler2D tDiffuse;
|
|
37
|
+
uniform vec3 defaultColor;
|
|
38
|
+
uniform float defaultOpacity;
|
|
39
|
+
uniform float luminosityThreshold;
|
|
40
|
+
uniform float smoothWidth;
|
|
41
|
+
|
|
42
|
+
varying vec2 vUv;
|
|
43
|
+
|
|
44
|
+
void main() {
|
|
45
|
+
|
|
46
|
+
vec4 texel = texture2D( tDiffuse, vUv );
|
|
47
|
+
|
|
48
|
+
vec3 luma = vec3( 0.299, 0.587, 0.114 );
|
|
49
|
+
|
|
50
|
+
float v = dot( texel.xyz, luma );
|
|
51
|
+
|
|
52
|
+
vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
|
|
53
|
+
|
|
54
|
+
float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
|
|
55
|
+
|
|
56
|
+
gl_FragColor = mix( outputColor, texel, alpha );
|
|
57
|
+
|
|
58
|
+
}`};class j extends st{constructor(t,e,s,i){super(),this.strength=e!==void 0?e:1,this.radius=s,this.threshold=i,this.resolution=t!==void 0?new D(t.x,t.y):new D(256,256),this.clearColor=new u(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let n=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new it(n,a,{type:nt}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let f=0;f<this.nMips;f++){const p=new it(n,a,{type:nt});p.texture.name="UnrealBloomPass.h"+f,p.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(p);const m=new it(n,a,{type:nt});m.texture.name="UnrealBloomPass.v"+f,m.texture.generateMipmaps=!1,this.renderTargetsVertical.push(m),n=Math.round(n/2),a=Math.round(a/2)}const o=ie;this.highPassUniforms=pt.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=i,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new $({uniforms:this.highPassUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader}),this.separableBlurMaterials=[];const l=[3,5,7,9,11];n=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let f=0;f<this.nMips;f++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(l[f])),this.separableBlurMaterials[f].uniforms.invSize.value=new D(1/n,1/a),n=Math.round(n/2),a=Math.round(a/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=e,this.compositeMaterial.uniforms.bloomRadius.value=.1;const h=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=h,this.bloomTintColors=[new g(1,1,1),new g(1,1,1),new g(1,1,1),new g(1,1,1),new g(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors;const c=Lt;this.copyUniforms=pt.clone(c.uniforms),this.blendMaterial=new $({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:rt,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new u,this.oldClearAlpha=1,this.basic=new T,this.fsQuad=new zt(null)}dispose(){for(let t=0;t<this.renderTargetsHorizontal.length;t++)this.renderTargetsHorizontal[t].dispose();for(let t=0;t<this.renderTargetsVertical.length;t++)this.renderTargetsVertical[t].dispose();this.renderTargetBright.dispose();for(let t=0;t<this.separableBlurMaterials.length;t++)this.separableBlurMaterials[t].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this.basic.dispose(),this.fsQuad.dispose()}setSize(t,e){let s=Math.round(t/2),i=Math.round(e/2);this.renderTargetBright.setSize(s,i);for(let n=0;n<this.nMips;n++)this.renderTargetsHorizontal[n].setSize(s,i),this.renderTargetsVertical[n].setSize(s,i),this.separableBlurMaterials[n].uniforms.invSize.value=new D(1/s,1/i),s=Math.round(s/2),i=Math.round(i/2)}render(t,e,s,i,n){t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const a=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),n&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=s.texture,t.setRenderTarget(null),t.clear(),this.fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=s.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this.fsQuad.render(t);let o=this.renderTargetBright;for(let l=0;l<this.nMips;l++)this.fsQuad.material=this.separableBlurMaterials[l],this.separableBlurMaterials[l].uniforms.colorTexture.value=o.texture,this.separableBlurMaterials[l].uniforms.direction.value=j.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[l]),t.clear(),this.fsQuad.render(t),this.separableBlurMaterials[l].uniforms.colorTexture.value=this.renderTargetsHorizontal[l].texture,this.separableBlurMaterials[l].uniforms.direction.value=j.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[l]),t.clear(),this.fsQuad.render(t),o=this.renderTargetsVertical[l];this.fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,n&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(s),this.fsQuad.render(t)),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=a}getSeperableBlurMaterial(t){const e=[];for(let s=0;s<t;s++)e.push(.39894*Math.exp(-.5*s*s/(t*t))/t);return new $({defines:{KERNEL_RADIUS:t},uniforms:{colorTexture:{value:null},invSize:{value:new D(.5,.5)},direction:{value:new D(.5,.5)},gaussianCoefficients:{value:e}},vertexShader:`varying vec2 vUv;
|
|
59
|
+
void main() {
|
|
60
|
+
vUv = uv;
|
|
61
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
62
|
+
}`,fragmentShader:`#include <common>
|
|
63
|
+
varying vec2 vUv;
|
|
64
|
+
uniform sampler2D colorTexture;
|
|
65
|
+
uniform vec2 invSize;
|
|
66
|
+
uniform vec2 direction;
|
|
67
|
+
uniform float gaussianCoefficients[KERNEL_RADIUS];
|
|
68
|
+
|
|
69
|
+
void main() {
|
|
70
|
+
float weightSum = gaussianCoefficients[0];
|
|
71
|
+
vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
|
|
72
|
+
for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
|
|
73
|
+
float x = float(i);
|
|
74
|
+
float w = gaussianCoefficients[i];
|
|
75
|
+
vec2 uvOffset = direction * invSize * x;
|
|
76
|
+
vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
|
|
77
|
+
vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
|
|
78
|
+
diffuseSum += (sample1 + sample2) * w;
|
|
79
|
+
weightSum += 2.0 * w;
|
|
80
|
+
}
|
|
81
|
+
gl_FragColor = vec4(diffuseSum/weightSum, 1.0);
|
|
82
|
+
}`})}getCompositeMaterial(t){return new $({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`varying vec2 vUv;
|
|
83
|
+
void main() {
|
|
84
|
+
vUv = uv;
|
|
85
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
86
|
+
}`,fragmentShader:`varying vec2 vUv;
|
|
87
|
+
uniform sampler2D blurTexture1;
|
|
88
|
+
uniform sampler2D blurTexture2;
|
|
89
|
+
uniform sampler2D blurTexture3;
|
|
90
|
+
uniform sampler2D blurTexture4;
|
|
91
|
+
uniform sampler2D blurTexture5;
|
|
92
|
+
uniform float bloomStrength;
|
|
93
|
+
uniform float bloomRadius;
|
|
94
|
+
uniform float bloomFactors[NUM_MIPS];
|
|
95
|
+
uniform vec3 bloomTintColors[NUM_MIPS];
|
|
96
|
+
|
|
97
|
+
float lerpBloomFactor(const in float factor) {
|
|
98
|
+
float mirrorFactor = 1.2 - factor;
|
|
99
|
+
return mix(factor, mirrorFactor, bloomRadius);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
void main() {
|
|
103
|
+
gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +
|
|
104
|
+
lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +
|
|
105
|
+
lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +
|
|
106
|
+
lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +
|
|
107
|
+
lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );
|
|
108
|
+
}`})}}j.BlurDirectionX=new D(1,0);j.BlurDirectionY=new D(0,1);class ts{constructor(t,e,s){r(this,"composer");r(this,"renderPass");r(this,"bloomPass");this.composer=new ee(t),this.renderPass=new se(e,s),this.composer.addPass(this.renderPass);const i=t.getSize(new D);this.bloomPass=new j(i,.4,.3,.85),this.composer.addPass(this.bloomPass)}setScene(t){this.renderPass.scene=t}setCamera(t){this.renderPass.camera=t}setSize(t,e){this.composer.setSize(t,e)}render(){this.composer.render()}getComposer(){return this.composer}setBloomStrength(t){this.bloomPass.strength=t}getBloomStrength(){return this.bloomPass.strength}dispose(){this.composer.dispose()}}function es(){const y=navigator.deviceMemory,t=navigator.hardwareConcurrency||4;return y!==void 0&&y<=2||t<=2?"low":t>=8||y&&y>=8?"high":"medium"}const d="./assets/models",ne="./assets/Characters_1/gLTF",ae={characters:{"char-male-a":`${d}/characters/character-male-a.glb`,"char-male-b":`${d}/characters/character-male-b.glb`,"char-male-c":`${d}/characters/character-male-c.glb`,"char-male-d":`${d}/characters/character-male-d.glb`,"char-male-e":`${d}/characters/character-male-e.glb`,"char-male-f":`${d}/characters/character-male-f.glb`,"char-female-a":`${d}/characters/character-female-a.glb`,"char-female-b":`${d}/characters/character-female-b.glb`,"char-female-c":`${d}/characters/character-female-c.glb`,"char-female-d":`${d}/characters/character-female-d.glb`,"char-female-e":`${d}/characters/character-female-e.glb`,"char-female-f":`${d}/characters/character-female-f.glb`,"char-pet-beaver":`${d}/characters/character-pet-beaver.glb`,"char-pet-bee":`${d}/characters/character-pet-bee.glb`,"char-pet-bunny":`${d}/characters/character-pet-bunny.glb`,"char-pet-cat":`${d}/characters/character-pet-cat.glb`,"char-pet-caterpillar":`${d}/characters/character-pet-caterpillar.glb`,"char-pet-chick":`${d}/characters/character-pet-chick.glb`,"char-pet-cow":`${d}/characters/character-pet-cow.glb`,"char-pet-crab":`${d}/characters/character-pet-crab.glb`,"char-pet-deer":`${d}/characters/character-pet-deer.glb`,"char-pet-dog":`${d}/characters/character-pet-dog.glb`,"char-pet-elephant":`${d}/characters/character-pet-elephant.glb`,"char-pet-fish":`${d}/characters/character-pet-fish.glb`,"char-pet-fox":`${d}/characters/character-pet-fox.glb`,"char-pet-giraffe":`${d}/characters/character-pet-giraffe.glb`,"char-pet-hog":`${d}/characters/character-pet-hog.glb`,"char-pet-koala":`${d}/characters/character-pet-koala.glb`,"char-pet-lion":`${d}/characters/character-pet-lion.glb`,"char-pet-monkey":`${d}/characters/character-pet-monkey.glb`,"char-pet-panda":`${d}/characters/character-pet-panda.glb`,"char-pet-parrot":`${d}/characters/character-pet-parrot.glb`,"char-pet-penguin":`${d}/characters/character-pet-penguin.glb`,"char-pet-pig":`${d}/characters/character-pet-pig.glb`,"char-pet-polar":`${d}/characters/character-pet-polar.glb`,"char-pet-tiger":`${d}/characters/character-pet-tiger.glb`},buildings:{building_A:`${d}/buildings/building_A.gltf`,building_B:`${d}/buildings/building_B.gltf`,building_C:`${d}/buildings/building_C.gltf`,building_D:`${d}/buildings/building_D.gltf`,building_E:`${d}/buildings/building_E.gltf`,building_F:`${d}/buildings/building_F.gltf`,building_G:`${d}/buildings/building_G.gltf`,building_H:`${d}/buildings/building_H.gltf`,base:`${d}/buildings/base.gltf`,road_straight:`${d}/buildings/road_straight.gltf`,road_corner:`${d}/buildings/road_corner.gltf`,road_junction:`${d}/buildings/road_junction.gltf`,road_tsplit:`${d}/buildings/road_tsplit.gltf`,road_straight_crossing:`${d}/buildings/road_straight_crossing.gltf`,watertower:`${d}/buildings/watertower.gltf`},furniture:{table_medium:`${d}/furniture/table_medium.gltf`,table_medium_long:`${d}/furniture/table_medium_long.gltf`,table_small:`${d}/furniture/table_small.gltf`,table_low:`${d}/furniture/table_low.gltf`,chair_A:`${d}/furniture/chair_A.gltf`,chair_B:`${d}/furniture/chair_B.gltf`,chair_C:`${d}/furniture/chair_C.gltf`,chair_stool:`${d}/furniture/chair_stool.gltf`,armchair:`${d}/furniture/armchair.gltf`,armchair_pillows:`${d}/furniture/armchair_pillows.gltf`,couch:`${d}/furniture/couch.gltf`,couch_pillows:`${d}/furniture/couch_pillows.gltf`,shelf_A_big:`${d}/furniture/shelf_A_big.gltf`,shelf_A_small:`${d}/furniture/shelf_A_small.gltf`,shelf_B_large:`${d}/furniture/shelf_B_large.gltf`,shelf_B_large_decorated:`${d}/furniture/shelf_B_large_decorated.gltf`,shelf_B_small:`${d}/furniture/shelf_B_small.gltf`,shelf_B_small_decorated:`${d}/furniture/shelf_B_small_decorated.gltf`,book_set:`${d}/furniture/book_set.gltf`,book_single:`${d}/furniture/book_single.gltf`,cabinet_medium:`${d}/furniture/cabinet_medium.gltf`,cabinet_medium_decorated:`${d}/furniture/cabinet_medium_decorated.gltf`,cabinet_small:`${d}/furniture/cabinet_small.gltf`,lamp_standing:`${d}/furniture/lamp_standing.gltf`,lamp_table:`${d}/furniture/lamp_table.gltf`,bed_single_A:`${d}/furniture/bed_single_A.gltf`,bed_double_A:`${d}/furniture/bed_double_A.gltf`,rug_rectangle_A:`${d}/furniture/rug_rectangle_A.gltf`,rug_oval_A:`${d}/furniture/rug_oval_A.gltf`,pictureframe_large_A:`${d}/furniture/pictureframe_large_A.gltf`,pictureframe_large_B:`${d}/furniture/pictureframe_large_B.gltf`,pictureframe_medium:`${d}/furniture/pictureframe_medium.gltf`,cactus_medium_A:`${d}/furniture/cactus_medium_A.gltf`,cactus_small_A:`${d}/furniture/cactus_small_A.gltf`,pillow_A:`${d}/furniture/pillow_A.gltf`},props:{bench:`${d}/props/bench.gltf`,streetlight:`${d}/props/streetlight.gltf`,car_sedan:`${d}/props/car_sedan.gltf`,car_hatchback:`${d}/props/car_hatchback.gltf`,car_taxi:`${d}/props/car_taxi.gltf`,bush:`${d}/props/bush.gltf`,firehydrant:`${d}/props/firehydrant.gltf`,trash_A:`${d}/props/trash_A.gltf`,dumpster:`${d}/props/dumpster.gltf`,trafficlight:`${d}/props/trafficlight_A.gltf`,capybara:`${d}/props/capybara.glb`}};class ss{constructor(){r(this,"loader",new Dt);r(this,"cache",new Map);r(this,"skinned",new Set);r(this,"animations",new Map);r(this,"loaded",!1);r(this,"sharedLibraryAnims",null);r(this,"loadingPromises",new Map)}async preload(t=["characters","buildings","furniture","props"],e){const s=[];for(const l of t)for(const[h,c]of Object.entries(ae[l]))s.push([`${l}/${h}`,c]);let i=0;const n=s.length,a=async([l,h])=>{try{const c=await this.loader.loadAsync(h),f=c.scene;let p=!1;f.traverse(m=>{if(m.isMesh){const v=m;v.castShadow=!0,v.receiveShadow=!0}m.isSkinnedMesh&&(p=!0)}),this.cache.set(l,f),p&&this.skinned.add(l),c.animations.length>0&&this.animations.set(l,c.animations)}catch{console.warn(`[AssetLoader] Failed to load: ${l} (${h})`)}i++,e==null||e(i,n)},o=6;for(let l=0;l<s.length;l+=o)await Promise.all(s.slice(l,l+o).map(a));this.loaded=!0}getModel(t,e){const s=`${t}/${e}`,i=this.cache.get(s);return i?this.skinned.has(s)?wt(i):i.clone():null}getAnimations(t,e){return this.animations.get(`${t}/${e}`)??[]}isLoaded(){return this.loaded}getCharacterModel(t){return this.getModel("characters",t)}getBuildingModel(t){return this.getModel("buildings",t)}getFurnitureModel(t){return this.getModel("furniture",t)}getPropModel(t){return this.getModel("props",t)}async loadSharedLibraryAnimations(){if(this.sharedLibraryAnims)return this.sharedLibraryAnims;const t="/ext-assets/Characters_1/gLTF/Animations/Animations.glb";try{const e=await this.loader.loadAsync(t);return this.sharedLibraryAnims=e.animations,e.animations}catch{return console.warn("[AssetLoader] Failed to load shared library animations"),[]}}async loadGltfToCache(t,e,s){if(!this.cache.has(t))try{const i=await this.loader.loadAsync(e),n=i.scene;let a=!1;n.traverse(l=>{if(l.isMesh){const h=l;h.castShadow=!0,h.receiveShadow=!0}l.isSkinnedMesh&&(a=!0)}),this.cache.set(t,n),a&&this.skinned.add(t);const o=i.animations.length>0?i.animations:s??[];o.length>0&&this.animations.set(t,o)}catch{console.warn(`[AssetLoader] Failed to load: ${t} (${e})`)}}async loadLibraryCharacter(t){const e=`characters/${t}`;if(!this.cache.has(e)){if(!this.loadingPromises.has(e)){const s=(async()=>{const i=await this.loadSharedLibraryAnimations(),n=`${ne}/Characters/${t}.glb`;await this.loadGltfToCache(e,n,i)})();this.loadingPromises.set(e,s)}await this.loadingPromises.get(e)}return this.getModelFromCache(e)}async loadLibraryCharacterByUrl(t){const e=`characters/lib-url-${t}`;if(!this.cache.has(e)){if(!this.loadingPromises.has(e)){const s=(async()=>{const i=await this.loadSharedLibraryAnimations();await this.loadGltfToCache(e,t,i)})();this.loadingPromises.set(e,s)}await this.loadingPromises.get(e)}return this.getModelFromCache(e)}async loadCustomCharacter(t,e){const s=`characters/custom-${t}`;if(!this.cache.has(s)){if(!this.loadingPromises.has(s)){const i=(async()=>{const n=[];if(e!=null&&e.length)for(const a of e)try{const o=await this.loader.loadAsync(a);n.push(...o.animations)}catch{console.warn(`[AssetLoader] Failed to load custom animation: ${a}`)}await this.loadGltfToCache(s,t,n.length>0?n:void 0),this.fixCustomMaterials(s)})();this.loadingPromises.set(s,i)}await this.loadingPromises.get(s)}return this.getModelFromCache(s)}fixCustomMaterials(t){const e=this.cache.get(t);e&&e.traverse(s=>{if(!s.isMesh)return;const i=Array.isArray(s.material)?s.material:[s.material];for(const n of i)n.transparent&&(n.transparent=!1,n.alphaTest=.5,n.opacity=1),n.alphaMap&&(n.alphaTest=Math.max(n.alphaTest,.5)),n.depthWrite=!0,n.side=$t})}getAnimationsForKey(t){return this.animations.get(t)??[]}getModelFromCache(t){const e=this.cache.get(t);return e?this.skinned.has(t)?wt(e):e.clone():null}}const P=class P{constructor(t,e){r(this,"camera");r(this,"container");r(this,"targetLookAt",new g(20,0,12));r(this,"currentLookAt",new g(20,0,12));r(this,"cameraOffset",new g(0,18,14));r(this,"baseOffset",new g(0,18,14));r(this,"dragStartLookAt",new g);r(this,"isDragging",!1);r(this,"autoPilotEnabled",!1);r(this,"lastInteractionTime",0);r(this,"autoPilotTarget",null);r(this,"autoIdleDelay",5e3);r(this,"followTarget",null);r(this,"lerpSpeed",.04);r(this,"officeMode",!1);r(this,"officeBaseOffset",new g(0,20,16));r(this,"zoomLevel",1);r(this,"onWheel",t=>{t.preventDefault(),this.applyZoom(t.deltaY>0?1.06:.94),this.lastInteractionTime=performance.now(),this.followTarget=null,this.autoPilotEnabled=!1,this.autoPilotTarget=null});this.camera=t,this.container=e}init(){this.camera.fov=42,this.camera.updateProjectionMatrix(),this.updateCameraPosition(!0),this.container.addEventListener("wheel",this.onWheel,{passive:!1}),this.lastInteractionTime=performance.now()}follow(t){this.followTarget=t,t&&(this.autoPilotEnabled=!1,this.autoPilotTarget=null,this.targetLookAt.set(t.position.x,0,t.position.z))}moveTo(t,e){this.targetLookAt.set(t.x,0,t.z),this.clampBounds(this.targetLookAt),e&&(this.currentLookAt.copy(this.targetLookAt),this.updateCameraPosition(!0))}setAutoPilot(t){this.autoPilotEnabled=t,t||(this.autoPilotTarget=null)}onDrag(t,e,s){t==="start"?(this.isDragging=!0,this.dragStartLookAt.copy(this.targetLookAt),this.followTarget=null,this.autoPilotEnabled=!1,this.autoPilotTarget=null,this.lastInteractionTime=performance.now()):t==="move"&&this.isDragging?(this.targetLookAt.set(this.dragStartLookAt.x-s.x*P.DRAG_SCALE,0,this.dragStartLookAt.z-s.y*P.DRAG_SCALE),this.officeMode?this.clampOfficeBounds(this.targetLookAt):this.clampBounds(this.targetLookAt)):t==="end"&&(this.isDragging=!1,this.lastInteractionTime=performance.now())}onPinch(t){this.applyZoom(t>1?.96:1.04),this.lastInteractionTime=performance.now()}applyZoom(t){this.zoomLevel=Math.max(P.ZOOM_MIN,Math.min(P.ZOOM_MAX,this.zoomLevel*t)),this.cameraOffset.copy(this.baseOffset).multiplyScalar(this.zoomLevel)}update(t){this.followTarget?(this.targetLookAt.set(this.followTarget.position.x,0,this.followTarget.position.z),this.clampBounds(this.targetLookAt)):this.autoPilotEnabled&&performance.now()-this.lastInteractionTime>this.autoIdleDelay&&(this.autoPilotTarget||this.updateAutoPilot(),this.autoPilotTarget&&(this.targetLookAt.lerp(this.autoPilotTarget,P.AUTO_PILOT_LERP),this.targetLookAt.distanceTo(this.autoPilotTarget)<.3&&(this.autoPilotTarget=null))),this.currentLookAt.lerp(this.targetLookAt,this.lerpSpeed),this.updateCameraPosition(!1)}updateAutoPilot(){const t=P.PATROL_POINTS,e=Math.floor(Math.random()*t.length);this.autoPilotTarget=new g(t[e].x,0,t[e].z)}updateCameraPosition(t){const e=this.currentLookAt.clone().add(this.cameraOffset);t?this.camera.position.copy(e):this.camera.position.lerp(e,this.lerpSpeed),this.camera.lookAt(this.currentLookAt)}enterOfficeMode(){this.officeMode=!0,this.followTarget=null,this.autoPilotEnabled=!1,this.autoPilotTarget=null,this.zoomLevel=1,this.targetLookAt.copy(P.OFFICE_LOOK_AT),this.currentLookAt.copy(P.OFFICE_LOOK_AT);const t=P.OFFICE_LOOK_AT.clone().add(this.officeBaseOffset);this.camera.position.copy(t),this.camera.lookAt(this.currentLookAt)}leaveOfficeMode(){this.officeMode=!1}updateOfficePan(t){this.currentLookAt.lerp(this.targetLookAt,this.lerpSpeed);const e=this.officeBaseOffset.clone().multiplyScalar(this.zoomLevel),s=this.currentLookAt.clone().add(e);this.camera.position.lerp(s,this.lerpSpeed),this.camera.lookAt(this.currentLookAt)}animateTo(t,e=2e3){this.followTarget=null,this.autoPilotEnabled=!1,this.autoPilotTarget=null;const s=this.targetLookAt.clone(),i=new g(t.x,0,t.z);this.clampBounds(i);const n=performance.now();return new Promise(a=>{const o=()=>{const l=Math.min((performance.now()-n)/e,1),h=l<.5?4*l*l*l:1-Math.pow(-2*l+2,3)/2;this.targetLookAt.lerpVectors(s,i,h),l<1?requestAnimationFrame(o):a()};requestAnimationFrame(o)})}clampBounds(t){return t.x=Math.max(5,Math.min(35,t.x)),t.z=Math.max(3,Math.min(21,t.z)),t}clampOfficeBounds(t){const e=P.OFFICE_PAN_BOUNDS;return t.x=Math.max(e.minX,Math.min(e.maxX,t.x)),t.z=Math.max(e.minZ,Math.min(e.maxZ,t.z)),t}destroy(){this.container.removeEventListener("wheel",this.onWheel),this.followTarget=null,this.autoPilotTarget=null}};r(P,"OFFICE_LOOK_AT",new g(14,0,12)),r(P,"OFFICE_PAN_BOUNDS",{minX:3,maxX:26,minZ:5,maxZ:22}),r(P,"DRAG_SCALE",.06),r(P,"AUTO_PILOT_LERP",.01),r(P,"ZOOM_MIN",.5),r(P,"ZOOM_MAX",1.6),r(P,"PATROL_POINTS",[{x:18,z:13},{x:17,z:5},{x:3,z:10},{x:32,z:9},{x:12,z:20},{x:32,z:15},{x:7,z:18}]);let bt=P;class is{constructor(t){r(this,"scene");r(this,"particles",[]);this.scene=t}summonRipple(t){const e=new tt(.5,.7,32),s=new T({color:16777215,transparent:!0,opacity:.8,side:U}),i=new M(e,s);i.rotation.x=-Math.PI/2,i.position.copy(t),i.position.y=.1,this.scene.add(i);let n=1;this.particles.push({mesh:i,update:a=>(n+=a*8,i.scale.set(n,n,1),i.material.opacity-=a*1.5,i.material.opacity<=0?(this.scene.remove(i),i.geometry.dispose(),i.material.dispose(),!1):!0)})}completionStars(t){for(let e=0;e<8;e++){const s=new X(.08,6,6),i=new T({color:4521796}),n=new M(s,i);n.position.copy(t),n.position.y+=1,this.scene.add(n);const a=(Math.random()-.5)*3,o=2+Math.random()*3,l=(Math.random()-.5)*3;let h=0;this.particles.push({mesh:n,update:c=>(h+=c,n.position.x+=a*c,n.position.y+=(o-h*5)*c,n.position.z+=l*c,n.scale.setScalar(Math.max(0,1-h)),h>1.2?(this.scene.remove(n),s.dispose(),i.dispose(),!1):!0)})}}errorSparks(t){for(let e=0;e<6;e++){const s=new ht(.06,.06,.06),i=new T({color:16729156}),n=new M(s,i);n.position.copy(t),n.position.y+=1,this.scene.add(n);const a=e/6*Math.PI*2,o=2+Math.random()*2,l=Math.cos(a)*o,h=Math.sin(a)*o;let c=0;this.particles.push({mesh:n,update:f=>(c+=f,n.position.x+=l*f,n.position.y+=(1-c*4)*f,n.position.z+=h*f,n.rotation.x+=f*10,n.rotation.y+=f*8,c>.8?(this.scene.remove(n),s.dispose(),i.dispose(),!1):!0)})}}goldenPillar(t){const e=new ot(.3,.6,5,8),s=new T({color:16766720,transparent:!0,opacity:.5}),i=new M(e,s);i.position.copy(t),i.position.y=2.5,this.scene.add(i);let n=0;this.particles.push({mesh:i,update:a=>(n+=a,i.scale.y=1+Math.sin(n*3)*.1,s.opacity=Math.max(0,.5-n*.15),n>3?(this.scene.remove(i),e.dispose(),s.dispose(),!1):!0)}),this.completionStars(t)}exclamation(t){const e=new W,s=new ht(.08,.3,.08),i=new ht(.08,.08,.08),n=new T({color:16729156}),a=new M(s,n);a.position.y=.15;const o=new M(i,n.clone());o.position.y=-.1,e.add(a,o);const l=new g;t.getWorldPosition(l),e.position.set(l.x,l.y+2.5,l.z),this.scene.add(e);let h=0;this.particles.push({mesh:e,update:c=>(h+=c,t.getWorldPosition(l),e.position.set(l.x,l.y+2.5+Math.sin(h*5)*.1,l.z),h>1.5?(this.scene.remove(e),s.dispose(),i.dispose(),n.dispose(),!1):!0)})}update(t){this.particles=this.particles.filter(e=>e.update(t))}setScene(t){this.scene=t}clear(){for(const t of this.particles)this.scene.remove(t.mesh);this.particles=[]}}const Z=512,O=new g;class re{constructor(){r(this,"positions");r(this,"colors");r(this,"sizes");r(this,"particles",[]);r(this,"pointsMesh")}init(t){this.positions=new Float32Array(Z*3),this.colors=new Float32Array(Z*4),this.sizes=new Float32Array(Z);for(let i=0;i<Z;i++)this.particles.push({active:!1,position:new g,velocity:new g,color:new u(1,1,1),size:.1,life:0,maxLife:1,emissive:0});const e=new B;e.setAttribute("position",new E(this.positions,3)),e.setAttribute("color",new E(this.colors,4)),e.setAttribute("size",new E(this.sizes,1));const s=new Ut({size:.15,vertexColors:!0,transparent:!0,blending:rt,depthWrite:!1,sizeAttenuation:!0});this.pointsMesh=new at(e,s),this.pointsMesh.frustumCulled=!1,t.add(this.pointsMesh)}allocParticle(){for(const t of this.particles)if(!t.active)return t;return null}emitParticles(t,e,s){var i,n,a,o;for(let l=0;l<t;l++){const h=this.allocParticle();if(!h)break;h.active=!0,h.position.copy(e),h.velocity.copy(((i=s.velocity)==null?void 0:i.call(s))??new g(0,1,0)),h.color.copy(((n=s.color)==null?void 0:n.call(s))??new u(1,1,1)),h.size=((a=s.size)==null?void 0:a.call(s))??.1,h.life=0,h.maxLife=((o=s.life)==null?void 0:o.call(s))??1,h.emissive=s.emissive??1}}update(t){for(let s=0;s<Z;s++){const i=this.particles[s];if(i.active)if(i.life+=t,i.life>=i.maxLife)i.active=!1;else{i.position.addScaledVector(i.velocity,t),i.velocity.y-=t*3;const n=1-i.life/i.maxLife;this.positions[s*3]=i.position.x,this.positions[s*3+1]=i.position.y,this.positions[s*3+2]=i.position.z,this.colors[s*4]=i.color.r*i.emissive,this.colors[s*4+1]=i.color.g*i.emissive,this.colors[s*4+2]=i.color.b*i.emissive,this.colors[s*4+3]=n,this.sizes[s]=i.size*(.5+n*.5);continue}this.positions[s*3]=0,this.positions[s*3+1]=-1e3,this.positions[s*3+2]=0,this.colors[s*4+3]=0,this.sizes[s]=0}const e=this.pointsMesh.geometry;e.attributes.position.needsUpdate=!0,e.attributes.color.needsUpdate=!0,e.attributes.size.needsUpdate=!0}setScene(t){this.pointsMesh.parent&&this.pointsMesh.parent.remove(this.pointsMesh),t.add(this.pointsMesh)}clear(){for(const t of this.particles)t.active=!1}}class oe{constructor(){r(this,"scene");r(this,"effects",[]);r(this,"meshEffects",[]);r(this,"nextEffectId",0);r(this,"shakeIntensity",0);r(this,"cameraRef",null)}setScene(t){this.scene=t}getScene(){return this.scene}setCamera(t){this.cameraRef=t}nextId(){return this.nextEffectId++}addEffect(t){this.effects.push(t)}addMeshEffect(t){this.meshEffects.push(t)}addMeshToScene(t){this.scene.add(t)}removeMeshFromScene(t){this.scene.remove(t)}findEffect(t){return this.effects.find(e=>e.id===t)}removeEffectsByFilter(t){this.effects=this.effects.filter(e=>!t(e))}stopEffectById(t){var s,i;const e=this.effects.findIndex(n=>n.id===t);if(e>=0){const n=this.effects[e],a=n.params.ring;a&&(this.scene.remove(a),(s=n.params.ringGeo)==null||s.dispose(),(i=n.params.ringMat)==null||i.dispose()),this.effects.splice(e,1)}}update(t){this.effects=this.effects.filter(e=>e.update(t,e,this)),this.meshEffects=this.meshEffects.filter(e=>e.update(t)),this.shakeIntensity>0&&this.cameraRef&&(this.cameraRef.position.x+=(Math.random()-.5)*this.shakeIntensity,this.cameraRef.position.y+=(Math.random()-.5)*this.shakeIntensity,this.shakeIntensity*=.9,this.shakeIntensity<.005&&(this.shakeIntensity=0))}clear(){for(const t of this.meshEffects)this.scene.remove(t.mesh);this.meshEffects=[];for(const t of this.effects){const e=t.params.ring;e&&this.scene.remove(e)}this.effects=[]}}class le{constructor(t,e,s){this.pool=t,this.registry=e,this.fallback=s}summonShockwave(t){this.fallback.summonRipple(t);const e=this.registry.getScene(),s=new ot(.15,.4,6,8),i=new T({color:16766720,transparent:!0,opacity:.6}),n=new M(s,i);n.position.copy(t),n.position.y=3,e.add(n);let a=0;this.registry.addMeshEffect({mesh:n,update:o=>(a+=o,n.scale.y=1+Math.sin(a*4)*.15,i.opacity=Math.max(0,.6-a*.25),a>2.5?(e.remove(n),s.dispose(),i.dispose(),!1):!0)}),this.pool.emitParticles(30,t.clone().add(new g(0,.5,0)),{velocity:()=>{const o=Math.random()*Math.PI*2,l=2+Math.random()*3;return new g(Math.cos(o)*l,2+Math.random()*3,Math.sin(o)*l)},color:()=>new u().setHSL(.12+Math.random()*.08,1,.6+Math.random()*.3),size:()=>.08+Math.random()*.06,life:()=>.8+Math.random()*.6,emissive:3})}completionFirework(t){this.pool.emitParticles(3,t.clone().add(new g(0,1,0)),{velocity:()=>new g((Math.random()-.5)*.5,6+Math.random()*2,(Math.random()-.5)*.5),color:()=>new u(1,.9,.5),size:()=>.12,life:()=>.6,emissive:4}),setTimeout(()=>{const e=t.clone().add(new g(0,5,0)),s=Math.random();this.pool.emitParticles(40,e,{velocity:()=>{const i=Math.random()*Math.PI*2,n=Math.random()*Math.PI,a=2+Math.random()*4;return new g(Math.sin(n)*Math.cos(i)*a,Math.sin(n)*Math.sin(i)*a-1,Math.cos(n)*a)},color:()=>new u().setHSL(s+(Math.random()-.5)*.15,1,.6),size:()=>.06+Math.random()*.06,life:()=>1+Math.random()*.8,emissive:3})},500)}errorLightning(t){this.fallback.errorSparks(t);const e=this.registry.getScene();this.pool.emitParticles(15,t.clone().add(new g(0,1,0)),{velocity:()=>{const h=Math.random()*Math.PI*2,c=1.5+Math.random()*2;return new g(Math.cos(h)*c,1+Math.random()*2,Math.sin(h)*c)},color:()=>new u().setHSL(0,.9,.5+Math.random()*.3),size:()=>.05+Math.random()*.05,life:()=>.5+Math.random()*.4,emissive:2});const s=[];let i=t.clone();i.y+=2.5;for(let h=0;h<6;h++)s.push(i.clone()),i=i.clone().add(new g((Math.random()-.5)*.8,-.4,(Math.random()-.5)*.8));const n=new B().setFromPoints(s),a=new et({color:16720418,transparent:!0,opacity:1}),o=new q(n,a);e.add(o);let l=0;this.registry.addMeshEffect({mesh:o,update:h=>(l+=h,a.opacity=Math.max(0,1-l*3),l>.4?(e.remove(o),n.dispose(),a.dispose(),!1):!0)}),this.registry.shakeIntensity=Math.max(this.registry.shakeIntensity,.15)}personaTransform(t){const e=new g;t.getWorldPosition(e);const s=this.registry.getScene(),i=4.2,n=new tt(.6,.75,48),a=new T({color:11167487,transparent:!0,opacity:0,side:U}),o=new M(n,a);o.rotation.x=-Math.PI/2,o.position.set(e.x,.05,e.z),s.add(o);const l=new tt(.25,.35,6),h=new T({color:14527231,transparent:!0,opacity:0,side:U}),c=new M(l,h);c.rotation.x=-Math.PI/2,c.position.set(e.x,.06,e.z),s.add(c);const f=new ot(.55,.45,2.8,24,1,!0),p=new T({color:13404415,transparent:!0,opacity:0,side:U}),m=new M(f,p);m.position.set(e.x,1.4,e.z),m.visible=!1,s.add(m);const v=new tt(.1,.3,32),x=new T({color:16777215,transparent:!0,opacity:0,side:U}),C=new M(v,x);C.rotation.x=-Math.PI/2,C.position.set(e.x,1,e.z),C.visible=!1,s.add(C);const L=t.rotation.y;let _=0,K=0,z=!1;const w=new W;w.add(o),this.registry.addMeshEffect({mesh:w,update:S=>{if(_+=S,K+=S,t.getWorldPosition(e),_<1.5){const b=_/1.5;if(a.opacity=Math.min(b*1.5,.7),h.opacity=Math.min(b*1.5,.5),o.position.set(e.x,.05,e.z),o.rotation.z+=S*2,c.position.set(e.x,.06,e.z),c.rotation.z-=S*3.5,t.rotation.y+=S*(2+b*6),K>.06){K=0;const k=_*8+Math.random()*.5,R=1.8*(1-b*.5),I=e.clone().add(new g(Math.cos(k)*R,.2+Math.random()*2,Math.sin(k)*R));this.pool.emitParticles(2,I,{velocity:()=>{const G=e.clone().sub(I).normalize().multiplyScalar(2+Math.random());return G.y=.5+Math.random()*.5,G},color:()=>new u().setHSL(.72+Math.random()*.12,.85,.55+Math.random()*.2),size:()=>.05+Math.random()*.04,life:()=>.6+Math.random()*.4,emissive:2.5})}}if(_>=1.5&&_<2.8){const b=(_-1.5)/1.3;if(m.visible=!0,m.position.set(e.x,1.4,e.z),m.rotation.y+=S*10,p.opacity=b<.3?b/.3*.7:.7,p.color.setHSL(.75+Math.sin(_*12)*.05,.8,.5+b*.2),m.scale.set(1+Math.sin(_*15)*.08,1,1+Math.sin(_*15)*.08),a.opacity=.7+.3*Math.sin(_*10),o.position.set(e.x,.05,e.z),o.rotation.z+=S*5,c.position.set(e.x,.06,e.z),c.rotation.z-=S*8,t.rotation.y+=S*14,K>.04){K=0;const k=Math.random()*Math.PI*2;this.pool.emitParticles(1,e.clone().add(new g(Math.cos(k)*.5,Math.random()*2.5,Math.sin(k)*.5)),{velocity:()=>new g((Math.random()-.5)*.3,1.5+Math.random(),(Math.random()-.5)*.3),color:()=>new u().setHSL(.78+Math.random()*.08,1,.7),size:()=>.06,life:()=>.5+Math.random()*.3,emissive:3})}}if(_>=2.8){z||(z=!0,C.visible=!0,p.opacity=0,m.visible=!1,this.pool.emitParticles(50,e.clone().add(new g(0,1.2,0)),{velocity:()=>{const R=Math.random()*Math.PI*2,I=Math.acos(2*Math.random()-1),G=3+Math.random()*4;return new g(Math.sin(I)*Math.cos(R)*G,Math.sin(I)*Math.sin(R)*G,Math.cos(I)*G)},color:()=>{const R=[.72,.78,.85,.12,.55];return new u().setHSL(R[Math.floor(Math.random()*R.length)],1,.6+Math.random()*.3)},size:()=>.07+Math.random()*.06,life:()=>.8+Math.random()*.6,emissive:4}),this.registry.shakeIntensity=Math.max(this.registry.shakeIntensity,.12),t.rotation.y=L);const b=(_-2.8)/(i-2.8);C.position.set(e.x,1,e.z);const k=1+b*8;C.scale.set(k,k,k),x.opacity=Math.max(0,.9-b*1.2),a.opacity=Math.max(0,.5*(1-b)),h.opacity=Math.max(0,.3*(1-b))}return _>i?(s.remove(o),s.remove(c),s.remove(m),s.remove(C),n.dispose(),a.dispose(),l.dispose(),h.dispose(),f.dispose(),p.dispose(),v.dispose(),x.dispose(),!1):!0}})}}class he{constructor(t,e){this.pool=t,this.registry=e}thinkingAura(t){const e=this.registry.nextId();this.registry.addEffect({id:e,type:"thinkingAura",target:t,elapsed:0,duration:1/0,params:{},update:(l,h)=>{var f;if(h.elapsed+=l,!h.target)return!1;if(((f=h.target.userData)==null?void 0:f.isInActiveScene)===!1)return!0;const c=new g;if(h.target.getWorldPosition(c),c.y+=2,Math.random()<l*8){const p=Math.random()*Math.PI*2,m=.3+Math.random()*.2;this.pool.emitParticles(1,c.clone().add(new g(Math.cos(p)*m,0,Math.sin(p)*m)),{velocity:()=>new g((Math.random()-.5)*.2,.5+Math.random()*.5,(Math.random()-.5)*.2),color:()=>new u().setHSL(.15+Math.random()*.1,.8,.7),size:()=>.06+Math.random()*.04,life:()=>.8+Math.random()*.6,emissive:2})}return!0}});const s=this.registry.getScene(),i=new H(.35,.03,8,24),n=new T({color:16763972,transparent:!0,opacity:.4,side:U}),a=new M(i,n);a.rotation.x=-Math.PI/2;const o=new g;t.getWorldPosition(o),a.position.set(o.x,o.y+2,o.z),s.add(a),this.registry.addMeshEffect({mesh:a,update:l=>{var h;return this.registry.findEffect(e)?((h=t.userData)==null?void 0:h.isInActiveScene)===!1?(a.visible=!1,!0):(a.visible=!0,t.getWorldPosition(o),a.position.set(o.x,o.y+2,o.z),a.rotation.z+=l*2,n.opacity=.3+.15*Math.sin(this.registry.findEffect(e).elapsed*3),!0):(s.remove(a),i.dispose(),n.dispose(),!1)}})}stopThinkingAura(t){this.registry.removeEffectsByFilter(e=>e.type==="thinkingAura"&&e.target===t)}workingStream(t){const e=this.registry.nextId();this.registry.addEffect({id:e,type:"workingStream",target:t,elapsed:0,duration:1/0,params:{},update:(s,i)=>{var a;if(i.elapsed+=s,!i.target)return!1;if(((a=i.target.userData)==null?void 0:a.isInActiveScene)===!1)return!0;const n=new g;return i.target.getWorldPosition(n),n.y+=1,Math.random()<s*12&&this.pool.emitParticles(1,n.clone().add(new g((Math.random()-.5)*.3,0,(Math.random()-.5)*.3)),{velocity:()=>new g((Math.random()-.5)*.5,-1.5-Math.random(),(Math.random()-.5)*.5),color:()=>{const o=[.3,.55,.1,.45];return new u().setHSL(o[Math.floor(Math.random()*o.length)],.9,.65)},size:()=>.04+Math.random()*.03,life:()=>.5+Math.random()*.4,emissive:1.5}),!0}})}stopWorkingStream(t){this.registry.removeEffectsByFilter(e=>e.type==="workingStream"&&e.target===t)}fileIcon(t,e){const s=new g;t.getWorldPosition(s),s.y+=1.5;const i=this.registry.getScene(),n=document.createElement("canvas");n.width=64,n.height=64;const a=n.getContext("2d");a.fillStyle="#ffffff",a.fillRect(8,4,48,56),a.fillStyle="#4488cc",a.fillRect(8,4,48,14),a.fillStyle="#ffffff",a.font="9px monospace",a.fillText(e.slice(0,8),12,14),a.fillStyle="#888888";for(let f=0;f<4;f++)a.fillRect(14,24+f*8,20+Math.random()*16,4);const o=new _t(n),l=new Pt({map:o,transparent:!0,opacity:0}),h=new Ft(l);h.scale.set(.5,.5,1),h.position.copy(s),i.add(h);let c=0;this.registry.addMeshEffect({mesh:h,update:f=>(c+=f,h.position.y=s.y+c*.5,c<.3?(l.opacity=c/.3,h.scale.setScalar(.3+c/.3*.2)):c>2?l.opacity=Math.max(0,1-(c-2)*2):(l.opacity=1,h.scale.setScalar(.5)),h.scale.z=1,c>2.5?(i.remove(h),o.dispose(),l.dispose(),!1):!0)})}searchRadar(t){const e=new g;t.getWorldPosition(e),e.y+=2.2;const s=this.registry.getScene();for(let i=0;i<3;i++)setTimeout(()=>{const n=new H(.1,.015,6,24),a=new T({color:56831,transparent:!0,opacity:.7}),o=new M(n,a);o.rotation.x=-Math.PI/2,t.getWorldPosition(e),o.position.set(e.x,e.y+2.2,e.z),s.add(o);let l=0;this.registry.addMeshEffect({mesh:o,update:h=>{l+=h,t.getWorldPosition(O),o.position.set(O.x,O.y+2.2,O.z);const c=1+l*6;return o.scale.set(c,c,1),a.opacity=Math.max(0,.7-l*.9),l>.8?(s.remove(o),n.dispose(),a.dispose(),!1):!0}})},i*300)}connectionBeam(t,e){const s=new g,i=new g;t.getWorldPosition(s),s.y+=1.2,e.getWorldPosition(i),i.y+=1.2;const n=this.registry.getScene(),a=new B().setFromPoints([s,i]),o=new et({color:4500223,transparent:!0,opacity:.6}),l=new q(a,o);n.add(l);const h=s.clone().lerp(i,.5);this.pool.emitParticles(8,h,{velocity:()=>i.clone().sub(s).normalize().multiplyScalar(2+Math.random()*2).add(new g(0,.5,0)),color:()=>new u(.3,.7,1),size:()=>.05,life:()=>.6+Math.random()*.4,emissive:2});let c=0;this.registry.addMeshEffect({mesh:l,update:f=>{c+=f,t.getWorldPosition(s),s.y+=1.2,e.getWorldPosition(i),i.y+=1.2;const p=a.attributes.position;return p.setXYZ(0,s.x,s.y,s.z),p.setXYZ(1,i.x,i.y,i.z),p.needsUpdate=!0,o.opacity=Math.max(0,.6-c*.3),c>2?(n.remove(l),a.dispose(),o.dispose(),!1):!0}})}hookFlash(t){const e=new g;t.getWorldPosition(e),e.y+=2,this.pool.emitParticles(6,e,{velocity:()=>new g((Math.random()-.5)*2,1+Math.random(),(Math.random()-.5)*2),color:()=>new u(1,.8,.2),size:()=>.08,life:()=>.4+Math.random()*.3,emissive:2})}progressRing(t){const e=this.registry.nextId(),s=this.registry.getScene(),i=new H(.25,.02,6,32),n=new T({color:4508927,transparent:!0,opacity:.6}),a=new M(i,n);return a.rotation.x=-Math.PI/2,s.add(a),this.registry.addEffect({id:e,type:"progressRing",target:t,elapsed:0,duration:1/0,params:{ring:a,ringGeo:i,ringMat:n},update:(o,l)=>(l.elapsed+=o,l.target?(t.getWorldPosition(O),a.position.set(O.x,O.y+2.3,O.z),a.rotation.z+=o*3,n.opacity=.4+.2*Math.sin(l.elapsed*4),!0):!1)}),e}}class ce{constructor(t,e,s){this.pool=t,this.registry=e,this.spawn=s}deployFireworks(t){for(let e=0;e<5;e++)setTimeout(()=>{const s=new g((Math.random()-.5)*8,0,(Math.random()-.5)*8);this.spawn.completionFirework(t.clone().add(s))},e*600+Math.random()*400)}confetti(t,e=200,s=3e3){const i=[16739179,5164484,16770669,9822675,15958401],n=t.clone();n.y=5;const a=10,o=10,l=10,h=Math.ceil(e/l);for(let c=0;c<l;c++)setTimeout(()=>{for(let f=0;f<h;f++){const p=n.clone().add(new g((Math.random()-.5)*a,Math.random()*.5,(Math.random()-.5)*o));this.pool.emitParticles(1,p,{velocity:()=>new g((Math.random()-.5)*1.5,-1.5-Math.random()*1.5,(Math.random()-.5)*1.5),color:()=>new u(i[Math.floor(Math.random()*i.length)]),size:()=>.05+Math.random()*.1,life:()=>3+Math.random()*2,emissive:1.5})}},c/l*s)}lightPillar(t,e=1500){const s=this.registry.getScene(),i=new ot(.6,.6,8,16),n=new T({color:16777215,transparent:!0,opacity:0}),a=new M(i,n);a.position.set(t.x,4,t.z),s.add(a);let o=0;this.registry.addMeshEffect({mesh:a,update:l=>{o+=l;const h=o/(e/1e3);if(h<.2)n.opacity=h/.2*.4;else if(h<.7)n.opacity=.4;else if(h<1)n.opacity=.4*(1-(h-.7)/.3);else return n.opacity=0,s.remove(a),i.dispose(),n.dispose(),!1;return!0}})}skillLearnCeremony(t){const e=new g;t.getWorldPosition(e);const s=this.registry.getScene(),i=8,n=.9,a=e.y+2,o=document.createElement("canvas");o.width=128,o.height=128;const l=o.getContext("2d"),h=l.createLinearGradient(0,0,128,128);h.addColorStop(0,"#ffd700"),h.addColorStop(1,"#ff6b00");const c=24;l.beginPath(),l.moveTo(c,0),l.lineTo(128-c,0),l.quadraticCurveTo(128,0,128,c),l.lineTo(128,128-c),l.quadraticCurveTo(128,128,128-c,128),l.lineTo(c,128),l.quadraticCurveTo(0,128,0,128-c),l.lineTo(0,c),l.quadraticCurveTo(0,0,c,0),l.fillStyle=h,l.fill(),l.shadowColor="#fff",l.shadowBlur=12,l.fillStyle="#ffffff",l.font="bold 52px sans-serif",l.textAlign="center",l.textBaseline="middle",l.fillText("✦",64,64);const f=new _t(o),p=new Pt({map:f,transparent:!0,opacity:0}),m=new Ft(p);m.scale.set(n,n,1),m.position.set(e.x,i,e.z),s.add(m);const v=[16766720,16739072,54527],x=[];for(let z=0;z<3;z++){const w=new H(.5+z*.25,.03,8,32),S=new T({color:v[z],transparent:!0,opacity:0,side:U}),b=new M(w,S);b.position.copy(m.position),b.rotation.x=Math.PI*.3*(z-1),s.add(b),x.push({mesh:b,geo:w,mat:S})}const C=[];let L=0,_=!1,K=!1;this.registry.addMeshEffect({mesh:m,update:z=>{if(L+=z,t.getWorldPosition(e),L<2){const w=L/2;p.opacity=Math.min(w*2,1);const S=1+Math.sin(L*8)*.12;m.scale.set(n*S,n*S,1);for(let b=0;b<x.length;b++){const k=x[b];k.mat.opacity=Math.min(w*2,.7),k.mesh.position.copy(m.position),k.mesh.rotation.z+=z*(3+b*2),k.mesh.rotation.y+=z*(1+b*.5)}if(Math.random()<z*18){const b=L*5+Math.random()*Math.PI,k=1.5+Math.random()*.5,R=m.position.clone().add(new g(Math.cos(b)*k,(Math.random()-.5)*1.5,Math.sin(b)*k));this.pool.emitParticles(2,R,{velocity:()=>m.position.clone().sub(R).normalize().multiplyScalar(2.5+Math.random()),color:()=>new u().setHSL(.08+Math.random()*.12,1,.6+Math.random()*.3),size:()=>.07+Math.random()*.05,life:()=>.4+Math.random()*.3,emissive:3.5})}}if(L>=2&&L<3.5){const w=(L-2)/1.5,S=w*w*w,b=i+(a-i)*S;m.position.set(e.x,b,e.z);const k=1+w*8;for(let I=0;I<x.length;I++){const G=x[I];G.mesh.position.copy(m.position),G.mesh.rotation.z+=z*k*(3+I*2),G.mesh.rotation.y+=z*k;const lt=1-w*.6;G.mesh.scale.set(lt,lt,lt),G.mat.opacity=Math.max(0,.7*(1-w*.8))}const R=Math.floor(z*25*(1+w*3));for(let I=0;I<R;I++)this.pool.emitParticles(1,m.position.clone(),{velocity:()=>new g((Math.random()-.5)*1.5,2+Math.random()*3,(Math.random()-.5)*1.5),color:()=>new u().setHSL([.08,.12,.55,0][Math.floor(Math.random()*4)],1,.5+Math.random()*.4),size:()=>.06+Math.random()*.05,life:()=>.3+Math.random()*.4,emissive:3})}if(L>=3.5&&!_){_=!0,p.opacity=0;for(const w of x)w.mat.opacity=0;this.pool.emitParticles(60,e.clone().add(new g(0,1.5,0)),{velocity:()=>{const w=Math.random()*Math.PI*2,S=Math.acos(2*Math.random()-1),b=4+Math.random()*6;return new g(Math.sin(S)*Math.cos(w)*b,Math.abs(Math.sin(S)*Math.sin(w))*b,Math.cos(S)*b)},color:()=>{const w=[.08,.12,.55,.72,0];return new u().setHSL(w[Math.floor(Math.random()*w.length)],1,.55+Math.random()*.35)},size:()=>.08+Math.random()*.07,life:()=>1+Math.random()*.8,emissive:4.5}),this.registry.shakeIntensity=Math.max(this.registry.shakeIntensity,.2)}if(L>=3.5&&!K){K=!0;for(let w=0;w<3;w++)setTimeout(()=>{const S=new tt(.1,.25,32),b=new T({color:16766720,transparent:!0,opacity:.8,side:U}),k=new M(S,b);k.rotation.x=-Math.PI/2,t.getWorldPosition(O),k.position.set(O.x,O.y+.5+w*.4,O.z),s.add(k),C.push({mesh:k,geo:S,mat:b,born:L})},w*150)}for(const w of C){const S=L-w.born;if(S<0)continue;const b=1+S*8;w.mesh.scale.set(b,b,1),w.mat.opacity=Math.max(0,.8-S*1.2),w.mat.opacity<=0&&w.mesh.parent&&(s.remove(w.mesh),w.geo.dispose(),w.mat.dispose())}if(L>=3.8&&L<5.5&&Math.random()<z*20){const w=Math.random()*Math.PI*2,S=Math.random()*.4;this.pool.emitParticles(1,e.clone().add(new g(Math.cos(w)*S,Math.random()*2.5,Math.sin(w)*S)),{velocity:()=>new g((Math.random()-.5)*.3,3+Math.random()*2,(Math.random()-.5)*.3),color:()=>new u().setHSL(.12+Math.random()*.06,1,.6+Math.random()*.3),size:()=>.05+Math.random()*.04,life:()=>.5+Math.random()*.4,emissive:3})}if(L>8){s.remove(m);for(const w of x)s.remove(w.mesh),w.geo.dispose(),w.mat.dispose();for(const w of C)w.mesh.parent&&s.remove(w.mesh),w.geo.dispose(),w.mat.dispose();return f.dispose(),p.dispose(),!1}return!0}}),setTimeout(()=>{t.getWorldPosition(e),this.lightPillar(e,2e3)},3800)}}class ue{constructor(t){this.registry=t}routeDebugPath(t,e=3399935,s=5e3){if(!t||t.length<2)return;const i=this.registry.getScene(),n=t.map(v=>new g(v.x,v.y??.06,v.z)),a=new B().setFromPoints(n),o=new et({color:e,transparent:!0,opacity:.8}),l=new q(a,o);i.add(l);const h=new W,c=new X(.08,10,10),f=new T({color:e,transparent:!0,opacity:.9});for(const v of n){const x=new M(c,f);x.position.copy(v),h.add(x)}i.add(h);const p=Math.max(.6,s/1e3);let m=0;this.registry.addMeshEffect({mesh:h,update:v=>{m+=v;const x=Math.max(0,1-m/p);return o.opacity=.8*x,f.opacity=.9*x,m>=p?(i.remove(l),i.remove(h),a.dispose(),o.dispose(),c.dispose(),f.dispose(),!1):!0}})}}class ns{constructor(t,e){r(this,"pool");r(this,"registry");r(this,"fallback");r(this,"spawn");r(this,"work");r(this,"celebration");r(this,"debug");this.fallback=e,this.pool=new re,this.pool.init(t),this.registry=new oe,this.registry.setScene(t),this.spawn=new le(this.pool,this.registry,e),this.work=new he(this.pool,this.registry),this.celebration=new ce(this.pool,this.registry,this.spawn),this.debug=new ue(this.registry)}setCamera(t){this.registry.setCamera(t)}summonShockwave(t){this.spawn.summonShockwave(t)}completionFirework(t){this.spawn.completionFirework(t)}errorLightning(t){this.spawn.errorLightning(t)}personaTransform(t){this.spawn.personaTransform(t)}thinkingAura(t){this.work.thinkingAura(t)}stopThinkingAura(t){this.work.stopThinkingAura(t)}workingStream(t){this.work.workingStream(t)}stopWorkingStream(t){this.work.stopWorkingStream(t)}fileIcon(t,e){this.work.fileIcon(t,e)}searchRadar(t){this.work.searchRadar(t)}connectionBeam(t,e){this.work.connectionBeam(t,e)}hookFlash(t){this.work.hookFlash(t)}progressRing(t){return this.work.progressRing(t)}stopEffect(t){this.registry.stopEffectById(t)}deployFireworks(t){this.celebration.deployFireworks(t)}confetti(t,e,s){this.celebration.confetti(t,e,s)}lightPillar(t,e){this.celebration.lightPillar(t,e)}skillLearnCeremony(t){this.celebration.skillLearnCeremony(t)}routeDebugPath(t,e,s){this.debug.routeDebugPath(t,e,s)}update(t){this.fallback.update(t),this.registry.update(t),this.pool.update(t)}setScene(t){this.pool.setScene(t),this.registry.setScene(t),this.fallback.setScene(t)}clear(){this.pool.clear(),this.registry.clear(),this.fallback.clear()}}const de={typing:{src:"typing.mp3",volume:.15,throttleMs:150},footstep:{src:"footstep.mp3",volume:.12,throttleMs:250},summon:{src:"summon.mp3",volume:.4},complete:{src:"complete.mp3",volume:.35},error:{src:"error.mp3",volume:.25},scene_switch:{src:"whoosh.mp3",volume:.3},chat_pop:{src:"pop.mp3",volume:.2,throttleMs:300},deploy:{src:"fanfare.mp3",volume:.45},click:{src:"click.mp3",volume:.2,throttleMs:100}},fe="town_ambient.mp3";class me{constructor(t="/assets/music/"){r(this,"audioContext",null);r(this,"masterGain",null);r(this,"sfxGain",null);r(this,"bgmGain",null);r(this,"sounds",new Map);r(this,"bgmBuffer",null);r(this,"currentBgmSource",null);r(this,"_masterVolume",.7);r(this,"_bgmVolume",.4);r(this,"_muted",!1);r(this,"basePath");r(this,"initialized",!1);this.basePath=t}async init(){try{return this.audioContext=new(window.AudioContext||window.webkitAudioContext),this.masterGain=this.audioContext.createGain(),this.masterGain.connect(this.audioContext.destination),this.masterGain.gain.value=this._masterVolume,this.sfxGain=this.audioContext.createGain(),this.sfxGain.connect(this.masterGain),this.bgmGain=this.audioContext.createGain(),this.bgmGain.connect(this.masterGain),this.bgmGain.gain.value=this._bgmVolume,this.initialized=!0,!0}catch{return!1}}async ensureResumed(){var t;if(((t=this.audioContext)==null?void 0:t.state)==="suspended")try{await this.audioContext.resume()}catch{}}async preload(){this.audioContext||await this.init();for(const[t,e]of Object.entries(de))try{const s=await this.loadAudioFile(e.src);this.sounds.set(t,{buffer:s,config:e,lastPlayTime:0})}catch{}try{this.bgmBuffer=await this.loadAudioFile(fe)}catch{}}async loadAudioFile(t){if(!this.audioContext)throw new Error("AudioContext not initialized");const e=await fetch(this.basePath+t);if(!e.ok)throw new Error(`Audio file not found: ${t}`);return await this.audioContext.decodeAudioData(await e.arrayBuffer())}play(t,e){if(!this.initialized||this._muted||!this.audioContext||!this.sfxGain)return;const s=this.sounds.get(t);if(!s)return;const i=performance.now();if(!(s.config.throttleMs&&i-s.lastPlayTime<s.config.throttleMs))try{const n=this.audioContext.createBufferSource();n.buffer=s.buffer,s.config.loop&&(n.loop=!0);const a=this.audioContext.createGain();a.gain.value=((e==null?void 0:e.volume)??1)*(s.config.volume??1),n.connect(a),a.connect(this.sfxGain),n.start(0),s.lastPlayTime=i}catch{}}getAudioContext(){return this.audioContext}getSfxGain(){return this.sfxGain}isReady(){return this.initialized}playBGM(){if(!(!this.initialized||!this.audioContext||!this.bgmGain||!this.bgmBuffer)){this.stopBGM();try{this.currentBgmSource=this.audioContext.createBufferSource(),this.currentBgmSource.buffer=this.bgmBuffer,this.currentBgmSource.loop=!0,this.currentBgmSource.connect(this.bgmGain),this.currentBgmSource.start(0)}catch{}}}stopBGM(){if(this.currentBgmSource){try{this.currentBgmSource.stop()}catch{}this.currentBgmSource=null}}get masterVolume(){return this._masterVolume}set masterVolume(t){this._masterVolume=Math.max(0,Math.min(1,t)),this.masterGain&&(this.masterGain.gain.value=this._masterVolume)}get muted(){return this._muted}set muted(t){this._muted=t,this.masterGain&&(this.masterGain.gain.value=t?0:this._masterVolume)}toggleMute(){this.muted=!this.muted}destroy(){this.stopBGM(),this.audioContext&&(this.audioContext.close(),this.audioContext=null),this.sounds.clear(),this.bgmBuffer=null,this.initialized=!1}}let dt=null;function as(){return dt||(dt=new me),dt}function ft(y,t,e){const s=y.sampleRate,i=s*t,n=y.createBuffer(1,i,s),a=n.getChannelData(0);let o=0,l=0,h=0,c=0,f=0,p=0,m=0;for(let v=0;v<i;v++){const x=Math.random()*2-1;e==="white"?a[v]=x:e==="pink"?(o=.99886*o+x*.0555179,l=.99332*l+x*.0750759,h=.969*h+x*.153852,c=.8665*c+x*.3104856,f=.55*f+x*.5329522,p=-.7616*p-x*.016898,a[v]=(o+l+h+c+f+p+m+x*.5362)*.11,m=x*.115926):(o=(o+.02*x)/1.02,a[v]=o*3.5)}return n}class rs{constructor(){r(this,"ctx",null);r(this,"masterGain",null);r(this,"outputGain",null);r(this,"rainLayer",null);r(this,"windLayer",null);r(this,"thunderLayer",null);r(this,"birdsLayer",null);r(this,"nightLayer",null);r(this,"trafficLayer",null);r(this,"noiseBuffers",null);r(this,"currentWeather","clear");r(this,"currentPeriod","morning");r(this,"enabled",!0);r(this,"_volume",.5);r(this,"_pendingInit",!1);r(this,"_destination",null);r(this,"_windPhase",0)}init(t,e){this.ctx=t,this._destination=e,this._pendingInit=!0}startLayers(){!this.ctx||!this._destination||(this._pendingInit=!1,this.outputGain=this.ctx.createGain(),this.outputGain.gain.value=this._volume,this.outputGain.connect(this._destination),this.masterGain=this.outputGain,this.noiseBuffers={white:ft(this.ctx,4,"white"),pink:ft(this.ctx,4,"pink"),brown:ft(this.ctx,4,"brown")},this.rainLayer=this.createNoiseLayer("pink",200,3e3,0),this.windLayer=this.createNoiseLayer("brown",50,800,0),this.birdsLayer=this.createBirdsLayer(),this.nightLayer=this.createNightLayer(),this.trafficLayer=this.createTrafficLayer())}createNoiseLayer(t,e,s,i){if(!this.ctx||!this.masterGain||!this.noiseBuffers)throw new Error("Not initialized");const n=this.ctx.createBufferSource();n.buffer=this.noiseBuffers[t],n.loop=!0;const a=this.ctx.createBiquadFilter();a.type="lowpass",a.frequency.value=s;const o=this.ctx.createBiquadFilter();o.type="highpass",o.frequency.value=e;const l=this.ctx.createGain();return l.gain.value=i,n.connect(o),o.connect(a),a.connect(l),l.connect(this.masterGain),n.start(0),{source:n,gain:l,targetVolume:i,currentVolume:i}}createBirdsLayer(){if(!this.ctx||!this.masterGain)throw new Error("Not initialized");const t=this.ctx.createGain();return t.gain.value=0,t.connect(this.masterGain),this.scheduleBirdChirps(t),{source:null,gain:t,targetVolume:0,currentVolume:0}}scheduleBirdChirps(t){if(!this.ctx)return;const e=()=>{if(!this.ctx||!this.enabled)return;if(this.birdsLayer&&this.birdsLayer.targetVolume<.01){setTimeout(e,2e3+Math.random()*4e3);return}const s=this.ctx.createOscillator(),i=this.ctx.createGain(),n=2e3+Math.random()*2e3;s.type="sine",s.frequency.setValueAtTime(n,this.ctx.currentTime),s.frequency.exponentialRampToValueAtTime(n*1.3,this.ctx.currentTime+.05),s.frequency.exponentialRampToValueAtTime(n*.8,this.ctx.currentTime+.12),i.gain.setValueAtTime(0,this.ctx.currentTime),i.gain.linearRampToValueAtTime(.08,this.ctx.currentTime+.02),i.gain.linearRampToValueAtTime(0,this.ctx.currentTime+.15),s.connect(i),i.connect(t),s.start(this.ctx.currentTime),s.stop(this.ctx.currentTime+.2),setTimeout(e,800+Math.random()*3e3)};setTimeout(e,1e3)}createNightLayer(){if(!this.ctx||!this.masterGain)throw new Error("Not initialized");const t=this.ctx.createGain();return t.gain.value=0,t.connect(this.masterGain),this.scheduleCrickets(t),{source:null,gain:t,targetVolume:0,currentVolume:0}}scheduleCrickets(t){if(!this.ctx)return;const e=()=>{if(!this.ctx||!this.enabled)return;if(this.nightLayer&&this.nightLayer.targetVolume<.01){setTimeout(e,1e3+Math.random()*2e3);return}const s=this.ctx.createOscillator(),i=this.ctx.createGain();s.type="sine",s.frequency.value=4200+Math.random()*800;const n=this.ctx.currentTime,a=3+Math.floor(Math.random()*4);for(let o=0;o<a;o++){const l=n+o*.06;i.gain.setValueAtTime(0,l),i.gain.linearRampToValueAtTime(.04,l+.015),i.gain.linearRampToValueAtTime(0,l+.04)}s.connect(i),i.connect(t),s.start(n),s.stop(n+a*.06+.05),setTimeout(e,500+Math.random()*1500)};setTimeout(e,500)}createTrafficLayer(){if(!this.ctx||!this.masterGain||!this.noiseBuffers)throw new Error("Not initialized");const t=this.ctx.createGain();t.gain.value=0,t.connect(this.masterGain);const e=this.ctx.createBufferSource();e.buffer=this.noiseBuffers.pink,e.loop=!0;const s=this.ctx.createBiquadFilter();s.type="lowpass",s.frequency.value=400;const i=this.ctx.createBiquadFilter();i.type="highpass",i.frequency.value=80;const n=this.ctx.createGain();return n.gain.value=.15,e.connect(i),i.connect(s),s.connect(n),n.connect(t),e.start(0),this.scheduleHonks(t),{source:e,gain:t,targetVolume:0,currentVolume:0}}getTrafficProfile(){switch(this.currentPeriod){case"morning":return{interval:4e3+Math.random()*4e3,volume:.5,burstChance:.3};case"noon":return{interval:1e4+Math.random()*1e4,volume:.25,burstChance:.05};case"afternoon":return{interval:6e3+Math.random()*6e3,volume:.4,burstChance:.15};case"dusk":return{interval:5e3+Math.random()*5e3,volume:.45,burstChance:.25};case"dawn":return{interval:15e3+Math.random()*15e3,volume:.15,burstChance:0};default:return{interval:8e3,volume:0,burstChance:0}}}scheduleHonks(t){if(!this.ctx)return;const e=()=>{if(!this.ctx||!this.enabled)return;if(this.trafficLayer&&this.trafficLayer.targetVolume<.01){setTimeout(e,3e3+Math.random()*6e3);return}const s=this.getTrafficProfile(),i=this.ctx.currentTime,n=.25+Math.random()*.5,o=(this.currentPeriod==="morning"||this.currentPeriod==="dusk")&&Math.random()<.2?[220,310]:[280,370],l=Math.random()>.3,h=this.ctx.createGain(),c=.5*s.volume;h.gain.setValueAtTime(0,i),h.gain.linearRampToValueAtTime(c,i+.01),h.gain.setValueAtTime(c,i+n-.02),h.gain.linearRampToValueAtTime(0,i+n),h.connect(t);const f=this.ctx.createBiquadFilter();f.type="lowpass",f.frequency.value=1400,f.connect(h);for(const p of l?o:[o[0]]){const m=this.ctx.createOscillator();m.type="triangle",m.frequency.value=p*(.97+Math.random()*.06),m.connect(f),m.start(i),m.stop(i+n+.01)}Math.random()<s.burstChance?setTimeout(e,250+Math.random()*400):setTimeout(e,s.interval)};setTimeout(e,2e3+Math.random()*5e3)}update(t,e,s){if(!this.enabled||!this.ctx||this.ctx.state==="suspended")return;if(t=Math.min(t,.1),this._pendingInit)try{this.startLayers()}catch{return}if(!this.masterGain)return;this.currentWeather=e,this.currentPeriod=s;const i=s==="morning"||s==="noon"||s==="afternoon",n=s==="dusk"||s==="dawn",a=s==="night",o={drizzle:.05,rain:.15,heavyRain:.2,storm:.25},h={cloudy:.015,drizzle:.02,rain:.04,heavyRain:.08,storm:.12,blizzard:.25,sandstorm:.35,snow:.02,lightSnow:.01}[e]??0;this._windPhase+=t*.12;const c=this._windPhase,f=Math.max(0,Math.sin(c)*Math.sin(c*.37+.5)),p=f*f,m=h>.1?.4:0,v=h*(m+(1-m)*p),x=(i?.7:n?.3:0)*(e==="clear"||e==="cloudy"?1:e==="drizzle"?.3:0),C=a?.6:n?.25:0,_=(i?.5:n?.15:s==="dawn"?.1:0)*(e==="clear"||e==="cloudy"||e==="drizzle"?1:.3);this.setLayerTarget(this.rainLayer,o[e]??0),this.setLayerTarget(this.windLayer,v),this.setLayerTarget(this.birdsLayer,x),this.setLayerTarget(this.nightLayer,C),this.setLayerTarget(this.trafficLayer,_),this.smoothVolumes(t)}setLayerTarget(t,e){t&&(t.targetVolume=e)}smoothVolumes(t){const e=t*.8,s=t*.3,i=(n,a)=>{n&&(n.currentVolume+=(n.targetVolume-n.currentVolume)*a,n.currentVolume<.001&&(n.currentVolume=0),n.gain.gain.value=n.currentVolume)};i(this.rainLayer,e),i(this.windLayer,s),i(this.birdsLayer,e),i(this.nightLayer,e),i(this.trafficLayer,e)}playThunder(t){if(!this.ctx||!this.masterGain||!this.noiseBuffers)return;const e=this.ctx.currentTime,s=.3+Math.random()*1.2,i=1+Math.floor(Math.random()*3);let n=s;for(let a=0;a<i;a++){const o=1.2+Math.random()*3.5,l=(.6+Math.random()*.4)*t*(1-a*.15),h=l*(.3+Math.random()*.3),c=this.ctx.createBufferSource();c.buffer=this.noiseBuffers.brown;const f=this.ctx.createBiquadFilter();f.type="lowpass",f.frequency.value=300+t*500;const p=this.ctx.createGain();p.gain.setValueAtTime(0,e),p.gain.linearRampToValueAtTime(0,e+n),p.gain.linearRampToValueAtTime(l,e+n+.06),p.gain.setValueAtTime(h,e+n+.35),p.gain.exponentialRampToValueAtTime(.01,e+n+o),c.connect(f),f.connect(p),p.connect(this.masterGain),c.start(e),c.stop(e+n+o+.5),n+=o*.35+Math.random()*.6}}setVolume(t){this._volume=Math.max(0,Math.min(1,t)),this.outputGain&&(this.outputGain.gain.value=this._volume)}setEnabled(t){this.enabled=t,!t&&this.outputGain?this.outputGain.gain.value=0:t&&this.outputGain&&(this.outputGain.gain.value=this._volume)}destroy(){this.enabled=!1;const t=e=>{if(e)try{e.source&&e.source.stop()}catch{}};t(this.rainLayer),t(this.windLayer),this.rainLayer=null,this.windLayer=null,this.birdsLayer=null,this.nightLayer=null,this.trafficLayer=null}}const pe={day:"bgm_day.mp3",dusk:"bgm_dusk.mp3",night:"bgm_night.mp3",work:"bgm_work.mp3"},ge=3.5,vt=30,ye=3,we=.22;function Me(y,t,e){return e==="office"?"work":t==="night"?"night":t==="dusk"||t==="dawn"?"dusk":"day"}class os{constructor(){r(this,"ctx",null);r(this,"output",null);r(this,"buffers",new Map);r(this,"current",null);r(this,"fading",null);r(this,"pendingTrack",null);r(this,"debounceTimer",0);r(this,"loading",!1);r(this,"enabled",!0);r(this,"_volume",we);r(this,"basePath","/assets/music/")}async init(t,e){this.ctx=t,this.output=t.createGain(),this.output.gain.value=this._volume,this.output.connect(e),await this.preloadAll()}async preloadAll(){if(!this.ctx)return;this.loading=!0;const t=Object.entries(pe);await Promise.all(t.map(async([e,s])=>{try{const i=await fetch(this.basePath+s);if(!i.ok)return;const n=await this.ctx.decodeAudioData(await i.arrayBuffer());this.buffers.set(e,n)}catch{}})),this.loading=!1}update(t,e,s,i){var o;if(!this.enabled||!this.ctx||this.loading||this.ctx.state==="suspended")return;const n=Me(e,s,i);if(this.current&&this.current.track===n){this.pendingTrack=null,this.debounceTimer=0,this.updateFade(t);return}if(n==="work"||((o=this.current)==null?void 0:o.track)==="work"&&n!=="work"){this.switchTo(n);return}this.pendingTrack!==n&&(this.pendingTrack=n,this.debounceTimer=ye),this.debounceTimer-=t,this.debounceTimer<=0&&this.pendingTrack&&(this.current?this.ctx.currentTime-this.current.startedAt:vt)>=vt&&(this.switchTo(this.pendingTrack),this.pendingTrack=null),this.updateFade(t)}switchTo(t){if(!this.ctx||!this.output)return;const e=this.buffers.get(t);if(!e)return;this.fading&&(this.stopSource(this.fading),this.fading=null),this.current&&(this.fading=this.current,this.current=null);const s=this.ctx.createBufferSource();s.buffer=e,s.loop=!0,s.loopStart=.05,s.loopEnd=e.duration-.05;const i=this.ctx.createGain();i.gain.value=this.fading?0:1,s.connect(i),i.connect(this.output),s.start(0),this.current={source:s,gain:i,track:t,startedAt:this.ctx.currentTime}}updateFade(t){if(!this.fading||!this.current||!this.ctx)return;const e=this.ctx.currentTime-this.current.startedAt,s=Math.min(e/ge,1);this.current.gain.gain.value=Math.sin(s*Math.PI/2),this.fading.gain.gain.value=Math.cos(s*Math.PI/2),s>=1&&(this.stopSource(this.fading),this.fading=null)}stopSource(t){try{t.source.stop()}catch{}try{t.source.disconnect()}catch{}try{t.gain.disconnect()}catch{}}forceTrack(t){this.switchTo(t)}setVolume(t){this._volume=Math.max(0,Math.min(1,t)),this.output&&(this.output.gain.value=this._volume)}setEnabled(t){this.enabled=t,t||(this.current&&(this.stopSource(this.current),this.current=null),this.fading&&(this.stopSource(this.fading),this.fading=null))}destroy(){this.setEnabled(!1),this.buffers.clear()}}const be=`<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">
|
|
109
|
+
<style>
|
|
110
|
+
.sc-bg {
|
|
111
|
+
animation: sc-pop-in 0.5s ease-out forwards;
|
|
112
|
+
}
|
|
113
|
+
.sc-star {
|
|
114
|
+
animation: sc-star-in 0.5s ease-out 0.5s forwards, sc-star-twinkle 1.6s ease-in-out 1.0s infinite;
|
|
115
|
+
}
|
|
116
|
+
.sc-c1 { animation: sc-burst-1 1.8s ease-out 0.8s infinite; }
|
|
117
|
+
.sc-c2 { animation: sc-burst-2 1.8s ease-out 0.8s infinite; }
|
|
118
|
+
.sc-c3 { animation: sc-burst-3 1.8s ease-out 0.8s infinite; }
|
|
119
|
+
.sc-c4 { animation: sc-burst-4 1.8s ease-out 0.8s infinite; }
|
|
120
|
+
.sc-c5 { animation: sc-burst-5 1.8s ease-out 0.8s infinite; }
|
|
121
|
+
.sc-c6 { animation: sc-burst-6 1.8s ease-out 0.8s infinite; }
|
|
122
|
+
|
|
123
|
+
.sc-s1 { animation: sc-twinkle 1.2s ease-in-out 0.8s infinite; }
|
|
124
|
+
.sc-s2 { animation: sc-twinkle 1.2s ease-in-out 1.2s infinite; }
|
|
125
|
+
.sc-s3 { animation: sc-twinkle 1.2s ease-in-out 1.6s infinite; }
|
|
126
|
+
|
|
127
|
+
@keyframes sc-pop-in {
|
|
128
|
+
0% { transform: scale(0); }
|
|
129
|
+
80% { transform: scale(1.06); }
|
|
130
|
+
100% { transform: scale(1); }
|
|
131
|
+
}
|
|
132
|
+
@keyframes sc-star-in {
|
|
133
|
+
0% { transform: scale(0); opacity: 0; }
|
|
134
|
+
70% { transform: scale(1.15); opacity: 1; }
|
|
135
|
+
100% { transform: scale(1); opacity: 1; }
|
|
136
|
+
}
|
|
137
|
+
@keyframes sc-star-twinkle {
|
|
138
|
+
0%, 100% { transform: scale(1); opacity: 1; }
|
|
139
|
+
50% { transform: scale(0.8); opacity: 0.5; }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@keyframes sc-burst-1 {
|
|
143
|
+
0% { transform: translate(0,0) scale(1); opacity: 1; }
|
|
144
|
+
60% { transform: translate(18px,-24px) scale(0.6); opacity: 0.8; }
|
|
145
|
+
100% { transform: translate(26px,-32px) scale(0); opacity: 0; }
|
|
146
|
+
}
|
|
147
|
+
@keyframes sc-burst-2 {
|
|
148
|
+
0% { transform: translate(0,0) scale(1); opacity: 1; }
|
|
149
|
+
60% { transform: translate(24px,-12px) scale(0.6); opacity: 0.8; }
|
|
150
|
+
100% { transform: translate(34px,-16px) scale(0); opacity: 0; }
|
|
151
|
+
}
|
|
152
|
+
@keyframes sc-burst-3 {
|
|
153
|
+
0% { transform: translate(0,0) scale(1); opacity: 1; }
|
|
154
|
+
60% { transform: translate(26px,6px) scale(0.6); opacity: 0.8; }
|
|
155
|
+
100% { transform: translate(36px,8px) scale(0); opacity: 0; }
|
|
156
|
+
}
|
|
157
|
+
@keyframes sc-burst-4 {
|
|
158
|
+
0% { transform: translate(0,0) scale(1); opacity: 1; }
|
|
159
|
+
60% { transform: translate(14px,-30px) scale(0.6); opacity: 0.8; }
|
|
160
|
+
100% { transform: translate(20px,-40px) scale(0); opacity: 0; }
|
|
161
|
+
}
|
|
162
|
+
@keyframes sc-burst-5 {
|
|
163
|
+
0% { transform: translate(0,0) scale(1); opacity: 1; }
|
|
164
|
+
60% { transform: translate(30px,-4px) scale(0.6); opacity: 0.8; }
|
|
165
|
+
100% { transform: translate(40px,-6px) scale(0); opacity: 0; }
|
|
166
|
+
}
|
|
167
|
+
@keyframes sc-burst-6 {
|
|
168
|
+
0% { transform: translate(0,0) scale(1); opacity: 1; }
|
|
169
|
+
60% { transform: translate(20px,16px) scale(0.6); opacity: 0.8; }
|
|
170
|
+
100% { transform: translate(28px,22px) scale(0); opacity: 0; }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
@keyframes sc-twinkle {
|
|
174
|
+
0%, 100% { transform: scale(0); opacity: 0; }
|
|
175
|
+
50% { transform: scale(1); opacity: 1; }
|
|
176
|
+
}
|
|
177
|
+
</style>
|
|
178
|
+
|
|
179
|
+
<rect class="sc-bg" x="8" y="8" width="104" height="104" rx="24" fill="#f59e0b"
|
|
180
|
+
style="transform-origin:60px 60px; transform:scale(0)"/>
|
|
181
|
+
|
|
182
|
+
<polygon class="sc-star" points="60,28 67,48 88,48 71,60 78,80 60,68 42,80 49,60 32,48 53,48"
|
|
183
|
+
fill="#fff" opacity="0"
|
|
184
|
+
style="transform-origin:60px 56px"/>
|
|
185
|
+
|
|
186
|
+
<rect class="sc-c1" x="52" y="48" width="5" height="5" rx="1" fill="#fff" transform="rotate(20 54 50)"/>
|
|
187
|
+
<rect class="sc-c2" x="56" y="42" width="5" height="5" rx="1" fill="#fef3c7" transform="rotate(-15 58 44)"/>
|
|
188
|
+
<circle class="sc-c3" cx="58" cy="56" r="3" fill="#fff"/>
|
|
189
|
+
<circle class="sc-c4" cx="54" cy="52" r="3" fill="#fef3c7"/>
|
|
190
|
+
<rect class="sc-c5" x="50" y="46" width="4" height="6" rx="1" fill="#fff" transform="rotate(30 52 49)"/>
|
|
191
|
+
<rect class="sc-c6" x="54" y="58" width="5" height="4" rx="1" fill="#fef3c7" transform="rotate(-25 56 60)"/>
|
|
192
|
+
|
|
193
|
+
<polygon class="sc-s1" points="24,28 28,18 32,28 42,32 32,36 28,46 24,36 14,32"
|
|
194
|
+
fill="#fff" style="transform-origin:28px 32px"/>
|
|
195
|
+
<polygon class="sc-s2" points="82,18 86,8 90,18 100,22 90,26 86,36 82,26 72,22"
|
|
196
|
+
fill="#fff" style="transform-origin:86px 22px"/>
|
|
197
|
+
<polygon class="sc-s3" points="86,72 90,62 94,72 104,76 94,80 90,90 86,80 76,76"
|
|
198
|
+
fill="#fff" style="transform-origin:90px 76px"/>
|
|
199
|
+
</svg>
|
|
200
|
+
`,ve=`<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">
|
|
201
|
+
<style>
|
|
202
|
+
.se-bg { animation: se-pop-in 0.5s ease-out forwards; }
|
|
203
|
+
.se-x1 { animation: se-draw 0.3s ease-in-out 0.3s forwards; }
|
|
204
|
+
.se-x2 { animation: se-draw 0.3s ease-in-out 0.5s forwards; }
|
|
205
|
+
.se-shake { animation: se-shake 0.5s ease-in-out 0.6s; }
|
|
206
|
+
@keyframes se-pop-in {
|
|
207
|
+
0% { transform: scale(0); }
|
|
208
|
+
80% { transform: scale(1.06); }
|
|
209
|
+
100% { transform: scale(1); }
|
|
210
|
+
}
|
|
211
|
+
@keyframes se-draw {
|
|
212
|
+
to { stroke-dashoffset: 0; }
|
|
213
|
+
}
|
|
214
|
+
@keyframes se-shake {
|
|
215
|
+
0%, 100% { transform: translateX(0); }
|
|
216
|
+
15% { transform: translateX(-8px); }
|
|
217
|
+
30% { transform: translateX(8px); }
|
|
218
|
+
45% { transform: translateX(-6px); }
|
|
219
|
+
60% { transform: translateX(6px); }
|
|
220
|
+
75% { transform: translateX(-3px); }
|
|
221
|
+
90% { transform: translateX(3px); }
|
|
222
|
+
}
|
|
223
|
+
</style>
|
|
224
|
+
<g class="se-shake">
|
|
225
|
+
<rect class="se-bg" x="8" y="8" width="104" height="104" rx="24" fill="#ef4444"
|
|
226
|
+
style="transform-origin:60px 60px; transform:scale(0)"/>
|
|
227
|
+
<line class="se-x1" x1="42" y1="42" x2="78" y2="78"
|
|
228
|
+
stroke="#fff" stroke-width="8" stroke-linecap="round"
|
|
229
|
+
stroke-dasharray="52" stroke-dashoffset="52"/>
|
|
230
|
+
<line class="se-x2" x1="78" y1="42" x2="42" y2="78"
|
|
231
|
+
stroke="#fff" stroke-width="8" stroke-linecap="round"
|
|
232
|
+
stroke-dasharray="52" stroke-dashoffset="52"/>
|
|
233
|
+
</g>
|
|
234
|
+
</svg>
|
|
235
|
+
`,xe=`<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">
|
|
236
|
+
<style>
|
|
237
|
+
.ss-bg { animation: ss-pop-in 0.5s ease-out forwards; }
|
|
238
|
+
.ss-check { animation: ss-draw 0.6s ease-in-out 0.3s forwards; }
|
|
239
|
+
@keyframes ss-pop-in {
|
|
240
|
+
0% { transform: scale(0); }
|
|
241
|
+
80% { transform: scale(1.06); }
|
|
242
|
+
100% { transform: scale(1); }
|
|
243
|
+
}
|
|
244
|
+
@keyframes ss-draw {
|
|
245
|
+
to { stroke-dashoffset: 0; }
|
|
246
|
+
}
|
|
247
|
+
</style>
|
|
248
|
+
<rect class="ss-bg" x="8" y="8" width="104" height="104" rx="24" fill="#22c55e"
|
|
249
|
+
style="transform-origin:60px 60px; transform:scale(0)"/>
|
|
250
|
+
<path class="ss-check" d="M36 62 L52 78 L84 42"
|
|
251
|
+
fill="none" stroke="#fff" stroke-width="8"
|
|
252
|
+
stroke-linecap="round" stroke-linejoin="round"
|
|
253
|
+
stroke-dasharray="90" stroke-dashoffset="90"/>
|
|
254
|
+
</svg>
|
|
255
|
+
`,Se=`<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120">
|
|
256
|
+
<style>
|
|
257
|
+
.sw-bg {
|
|
258
|
+
animation: sw-pop-in 0.5s ease-out forwards, sw-bg-pulse 2.5s ease-out 0.8s infinite;
|
|
259
|
+
}
|
|
260
|
+
.sw-k1, .sw-k2, .sw-k3, .sw-k4 { opacity: 0; }
|
|
261
|
+
.sw-k1 { animation: sw-pop-in 0.3s ease-out 0.25s forwards, sw-press-1 2.5s ease-out 0.8s infinite; }
|
|
262
|
+
.sw-k2 { animation: sw-pop-in 0.3s ease-out 0.3s forwards, sw-press-2 2.5s ease-out 0.8s infinite; }
|
|
263
|
+
.sw-k3 { animation: sw-pop-in 0.3s ease-out 0.35s forwards, sw-press-3 2.5s ease-out 0.8s infinite; }
|
|
264
|
+
.sw-k4 { animation: sw-pop-in 0.3s ease-out 0.4s forwards, sw-press-4 2.5s ease-out 0.8s infinite; }
|
|
265
|
+
.sw-k1 .sw-cap { animation: sw-cap-1 2.5s ease-out 0.8s infinite; }
|
|
266
|
+
.sw-k2 .sw-cap { animation: sw-cap-2 2.5s ease-out 0.8s infinite; }
|
|
267
|
+
.sw-k3 .sw-cap { animation: sw-cap-3 2.5s ease-out 0.8s infinite; }
|
|
268
|
+
.sw-k4 .sw-cap { animation: sw-cap-4 2.5s ease-out 0.8s infinite; }
|
|
269
|
+
|
|
270
|
+
@keyframes sw-pop-in {
|
|
271
|
+
0% { transform: scale(0); opacity: 0; }
|
|
272
|
+
100% { transform: scale(1); opacity: 1; }
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
@keyframes sw-bg-pulse {
|
|
276
|
+
0% { opacity: 0.7; } 6% { opacity: 1; }
|
|
277
|
+
17% { opacity: 0.7; } 23% { opacity: 1; }
|
|
278
|
+
34% { opacity: 0.7; } 40% { opacity: 1; }
|
|
279
|
+
50% { opacity: 0.7; } 56% { opacity: 1; }
|
|
280
|
+
100% { opacity: 1; }
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
@keyframes sw-press-1 {
|
|
284
|
+
0% { transform: scale(0.78); } 4% { transform: scale(0.78); }
|
|
285
|
+
14% { transform: scale(1); } 100% { transform: scale(1); }
|
|
286
|
+
}
|
|
287
|
+
@keyframes sw-cap-1 {
|
|
288
|
+
0% { opacity: 0.4; } 4% { opacity: 0.4; }
|
|
289
|
+
14% { opacity: 1; } 100% { opacity: 1; }
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
@keyframes sw-press-2 {
|
|
293
|
+
0% { transform: scale(1); } 17% { transform: scale(1); }
|
|
294
|
+
21% { transform: scale(0.78); } 31% { transform: scale(1); }
|
|
295
|
+
100% { transform: scale(1); }
|
|
296
|
+
}
|
|
297
|
+
@keyframes sw-cap-2 {
|
|
298
|
+
0% { opacity: 1; } 17% { opacity: 1; }
|
|
299
|
+
21% { opacity: 0.4; } 31% { opacity: 1; }
|
|
300
|
+
100% { opacity: 1; }
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
@keyframes sw-press-3 {
|
|
304
|
+
0% { transform: scale(1); } 34% { transform: scale(1); }
|
|
305
|
+
38% { transform: scale(0.78); } 48% { transform: scale(1); }
|
|
306
|
+
100% { transform: scale(1); }
|
|
307
|
+
}
|
|
308
|
+
@keyframes sw-cap-3 {
|
|
309
|
+
0% { opacity: 1; } 34% { opacity: 1; }
|
|
310
|
+
38% { opacity: 0.4; } 48% { opacity: 1; }
|
|
311
|
+
100% { opacity: 1; }
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
@keyframes sw-press-4 {
|
|
315
|
+
0% { transform: scale(1); } 50% { transform: scale(1); }
|
|
316
|
+
54% { transform: scale(0.78); } 64% { transform: scale(1); }
|
|
317
|
+
100% { transform: scale(1); }
|
|
318
|
+
}
|
|
319
|
+
@keyframes sw-cap-4 {
|
|
320
|
+
0% { opacity: 1; } 50% { opacity: 1; }
|
|
321
|
+
54% { opacity: 0.4; } 64% { opacity: 1; }
|
|
322
|
+
100% { opacity: 1; }
|
|
323
|
+
}
|
|
324
|
+
</style>
|
|
325
|
+
<rect class="sw-bg" x="8" y="8" width="104" height="104" rx="24" fill="#3b82f6"
|
|
326
|
+
style="transform-origin:60px 60px; transform:scale(0)"/>
|
|
327
|
+
<g class="sw-k1" style="transform-origin:35px 51px">
|
|
328
|
+
<rect x="24" y="40" width="22" height="22" rx="4" fill="#1d4ed8"/>
|
|
329
|
+
<rect class="sw-cap" x="26" y="41.5" width="18" height="18" rx="3" fill="#dbeafe"/>
|
|
330
|
+
</g>
|
|
331
|
+
<g class="sw-k2" style="transform-origin:60px 51px">
|
|
332
|
+
<rect x="49" y="40" width="22" height="22" rx="4" fill="#1d4ed8"/>
|
|
333
|
+
<rect class="sw-cap" x="51" y="41.5" width="18" height="18" rx="3" fill="#dbeafe"/>
|
|
334
|
+
</g>
|
|
335
|
+
<g class="sw-k3" style="transform-origin:85px 51px">
|
|
336
|
+
<rect x="74" y="40" width="22" height="22" rx="4" fill="#1d4ed8"/>
|
|
337
|
+
<rect class="sw-cap" x="76" y="41.5" width="18" height="18" rx="3" fill="#dbeafe"/>
|
|
338
|
+
</g>
|
|
339
|
+
<g class="sw-k4" style="transform-origin:60px 75px">
|
|
340
|
+
<rect x="24" y="66" width="72" height="18" rx="4" fill="#1d4ed8"/>
|
|
341
|
+
<rect class="sw-cap" x="26" y="67.5" width="68" height="14" rx="3" fill="#dbeafe"/>
|
|
342
|
+
</g>
|
|
343
|
+
</svg>
|
|
344
|
+
`;class Ae{constructor(t){r(this,"group");r(this,"state","idle");r(this,"elapsed",0);r(this,"currentMeshes",[]);r(this,"parent");this.parent=t,this.group=new W,this.group.position.y=2,t.add(this.group)}setState(t){if(this.state!==t)switch(this.state=t,this.elapsed=0,this.clearMeshes(),t){case"thinking":this.buildThinking();break;case"working":this.buildWorking();break;case"waiting":this.buildWaiting();break;case"done":this.buildDone();break;case"error":this.buildError();break}}getState(){return this.state}setHeight(t){this.group.position.y=t}clearMeshes(){for(const t of this.currentMeshes)this.group.remove(t),t.traverse(e=>{e instanceof M&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(s=>s.dispose()):e.material.dispose()),e instanceof q&&(e.geometry.dispose(),e.material.dispose())});this.currentMeshes=[]}buildThinking(){const t=new M(new H(.2,.025,6,16),new T({color:16763972,transparent:!0,opacity:.6}));t.rotation.x=-Math.PI/2;const e=new X(.04,6,6),s=new T({color:16768358,transparent:!0,opacity:.8}),i=new W;for(let n=0;n<3;n++){const a=new M(e,s.clone()),o=n/3*Math.PI*2;a.position.set(Math.cos(o)*.12,.25,Math.sin(o)*.12),i.add(a)}this.group.add(t),this.group.add(i),this.currentMeshes.push(t,i)}buildWorking(){const s=new X(.035,8,8),i=new W;for(let f=0;f<5;f++){const p=f/5,m=new T({color:new u().setHSL(.62,.92,.5+p*.2),transparent:!0,opacity:.3+p*.7}),v=new M(s,m);v.scale.setScalar(.5+p*.5),i.add(v)}const n=new X(.06,10,10),a=new T({color:3900150,transparent:!0,opacity:.85}),o=new M(n,a);o.position.y=.05;const l=new H(.16,.008,6,32),h=new T({color:3900150,transparent:!0,opacity:.15}),c=new M(l,h);c.rotation.x=-Math.PI/2,c.position.y=.05,this.group.add(c),this.group.add(o),this.group.add(i),this.currentMeshes.push(c,o,i)}buildWaiting(){const t=new gt(.1,.15,6),e=new gt(.1,.15,6),s=new T({color:16755200,transparent:!0,opacity:.7}),i=new M(t,s);i.position.y=.12;const n=new M(e,s.clone());n.position.y=-.05,n.rotation.x=Math.PI;const a=new W;a.add(i,n),this.group.add(a),this.currentMeshes.push(a)}buildDone(){const t=[new g(-.1,0,0),new g(-.03,-.08,0),new g(.12,.1,0)],e=new B().setFromPoints(t),s=new et({color:4521796,linewidth:2}),i=new q(e,s),n=new H(.18,.015,6,24),a=new T({color:4521796,transparent:!0,opacity:.5}),o=new M(n,a);o.rotation.x=-Math.PI/2,this.group.add(i),this.group.add(o),this.currentMeshes.push(i,o)}buildError(){const t=[new g(-.08,.08,0),new g(.08,-.08,0)],e=[new g(.08,.08,0),new g(-.08,-.08,0)],s=new et({color:16729156,linewidth:2}),i=new q(new B().setFromPoints(t),s),n=new q(new B().setFromPoints(e),s.clone()),a=new H(.15,.015,6,24),o=new T({color:16729156,transparent:!0,opacity:.5}),l=new M(a,o);l.rotation.x=-Math.PI/2,this.group.add(i,n,l),this.currentMeshes.push(i,n,l)}update(t){if(this.state!=="idle")switch(this.elapsed+=t,this.state){case"thinking":{const e=this.currentMeshes[0];e&&(e.rotation.z=this.elapsed*1.5);const s=this.currentMeshes[1];s&&s.children.forEach((i,n)=>{i.position.y=.25+Math.sin(this.elapsed*3+n*1.2)*.06,i.material&&i.material.opacity!==void 0&&(i.material.opacity=.5+.4*Math.sin(this.elapsed*4+n))});break}case"working":{const a=this.currentMeshes[1];if(a){const l=.85+.15*Math.sin(this.elapsed*4);a.material.opacity=l;const h=1+.08*Math.sin(this.elapsed*4);a.scale.setScalar(h)}const o=this.currentMeshes[2];if(o){const l=this.elapsed*3.5;for(let h=0;h<5;h++){const c=o.children[h];if(!c)continue;const f=h/5*.6,p=l-f*Math.PI*2;c.position.set(Math.cos(p)*.16,.05+Math.sin(this.elapsed*2.5+h*.8)*.03,Math.sin(p)*.16)}}break}case"waiting":{const e=this.currentMeshes[0];e&&(e.rotation.z=this.elapsed*2);break}case"done":{const e=this.currentMeshes[1];if(e&&this.elapsed<1){const s=1+this.elapsed*2;e.scale.set(s,s,1),e.material.opacity=Math.max(0,.5-this.elapsed*.4)}break}case"error":{const e=Math.sin(this.elapsed*20)*.03;this.group.position.x=e,this.elapsed>.5&&(this.group.position.x=0);break}}}destroy(){this.clearMeshes(),this.group.parent&&this.group.parent.remove(this.group)}}const Te=qt.models??[];function ke(y,t){return t||"char-male-a"}function ls(y){const t=y instanceof Map?new Set(y.values()):y;for(const e of Te)if(!t.has(e.id))return e.id;return"char-male-a"}const xt={gold:16766720,cyan:3900150,yellow:16763904,green:4521796,red:16729156,gray:8947848},mt=new g,Q=new g,Ce={idle:new Set(["walking","working","thinking","celebrating","emoting","departing"]),walking:new Set(["idle","working"]),working:new Set(["idle","thinking","celebrating","departing"]),thinking:new Set(["idle","working","celebrating"]),celebrating:new Set(["idle","departing"]),emoting:new Set(["idle"]),departing:new Set(["idle"])},F=class F{constructor(t){r(this,"id");r(this,"name");r(this,"color");r(this,"role");r(this,"mesh");r(this,"state","idle");r(this,"npcState","idle");r(this,"label");r(this,"labelElement",null);r(this,"targetPos",null);r(this,"speed",3);r(this,"moveResolve",null);r(this,"bobPhase",0);r(this,"isMoving",!1);r(this,"bodyMesh",null);r(this,"headMesh",null);r(this,"usingGLTF",!1);r(this,"_characterKey");r(this,"modelRoot");r(this,"mixer",null);r(this,"idleAction",null);r(this,"walkAction",null);r(this,"typingAction",null);r(this,"waveAction",null);r(this,"cheerAction",null);r(this,"readingAction",null);r(this,"frustratedAction",null);r(this,"dancingAction",null);r(this,"currentAction",null);r(this,"glowRing",null);r(this,"glowColor","none");r(this,"glowPhase",0);r(this,"labelYOffset",1.95);r(this,"statusSpan",null);r(this,"labelTextSpan",null);r(this,"indicator");r(this,"isInActiveScene",!0);r(this,"desiredRotationY",null);r(this,"smoothTurnSpeed",10);r(this,"characterTransition",null);r(this,"_modelUrl");r(this,"_modelTransform");r(this,"_animMapping");r(this,"_animFileUrls");r(this,"onAnimFinished",t=>{(this.npcState==="celebrating"||this.npcState==="emoting")&&this.transitionTo("idle")});r(this,"currentStatusKey",null);this.id=t.id,this.name=t.name,this.color=t.color,this.role=t.role,this.label=t.label??t.name,this._characterKey=ke(t.id,t.characterKey),this._modelUrl=t.modelUrl,this._modelTransform=t.modelTransform,this._animMapping=t.animMapping,this._animFileUrls=t.animFileUrls,this.mesh=new W,this.mesh.position.set(t.spawn.x,t.spawn.y,t.spawn.z),this.mesh.userData.npcId=this.id,this.modelRoot=new W,this.mesh.add(this.modelRoot),this.indicator=new Ae(this.mesh),this.buildModel()}get characterKey(){return this._characterKey}get animationMixer(){return this.mixer}static setAssetLoader(t){F.assetLoader=t}buildModel(){if(!F.assetLoader){this.buildFallbackModel();return}const t=this._characterKey;if(t.startsWith("lib-")||t.startsWith("custom-")){this.buildFallbackModel(),this.loadModelAsync();return}const e=F.assetLoader.getCharacterModel(t);if(!e){this.buildFallbackModel();return}this.applyModel(e,F.assetLoader.getAnimations("characters",t))}async loadModelAsync(){if(!F.assetLoader)return;const t=this._characterKey;let e=null,s=[];try{if(t.startsWith("lib-")&&this._modelUrl){if(e=await F.assetLoader.loadLibraryCharacterByUrl(this._modelUrl),e){const i=`characters/lib-url-${this._modelUrl}`;s=F.assetLoader.getAnimationsForKey(i)}}else if(t.startsWith("custom-")&&this._modelUrl&&(e=await F.assetLoader.loadCustomCharacter(this._modelUrl,this._animFileUrls),e)){const i=`characters/custom-${this._modelUrl}`;s=F.assetLoader.getAnimationsForKey(i)}}catch(i){console.warn(`[NPC] Async model load failed for ${this.id} (${t}):`,i)}e&&(this.clearModel(),this.applyModel(e,s),this.state==="walking"&&this.walkAction?this.crossFadeTo(this.walkAction):this.idleAction&&this.crossFadeTo(this.idleAction))}applyModel(t,e){const s=this._modelTransform,i=(s==null?void 0:s.scale)??2.8;t.scale.set(i,i,i),t.updateMatrixWorld(!0);const n=new Nt().setFromObject(t).max.y;if(this.modelRoot.add(t),this.usingGLTF=!0,this.labelYOffset=n,s){const o=Math.PI/180;this.modelRoot.rotation.set(s.rotationX*o,s.rotationY*o,s.rotationZ*o),this.modelRoot.position.set(s.offsetX,s.offsetY,s.offsetZ)}if(e.length>0){if(this.mixer=new Vt(t),this.bindAnimations(e),this.idleAction)this.idleAction.play(),this.currentAction=this.idleAction;else if(e.length>0){const o=this.mixer.clipAction(e[0]);o.play(),this.currentAction=o}this.mixer.addEventListener("finished",this.onAnimFinished)}this.createGlowRing();const a=(s==null?void 0:s.offsetY)??0;this.indicator.setHeight(n+a+.15)}bindAnimations(t){if(!this.mixer)return;const e=this._animMapping;if(e&&Object.keys(e).length>0){const s=new Map(t.map(n=>[n.name,n])),i=n=>{const a=e[n];if(!a)return null;const o=s.get(a);return o?this.mixer.clipAction(o):null};this.idleAction=i("idle"),this.walkAction=i("walk"),this.typingAction=i("typing"),this.waveAction=i("wave"),this.cheerAction=i("cheer"),this.readingAction=i("reading"),this.frustratedAction=i("frustrated"),this.dancingAction=i("dancing")}else{const s={};for(const m of t)s[m.name.toLowerCase()]=m;const i=(...m)=>{for(const v of m)if(s[v])return s[v];for(const v of m)for(const[x,C]of Object.entries(s))if(x.includes(v))return C;return null},n=i("idle"),a=i("walk"),o=i("interact-right","interact-left","interact","typing"),l=i("emote-yes","wave","pick-up"),h=i("jump","cheer"),c=i("interact","interact-left"),f=i("emote-no"),p=i("dance");n&&(this.idleAction=this.mixer.clipAction(n)),a&&(this.walkAction=this.mixer.clipAction(a)),o&&(this.typingAction=this.mixer.clipAction(o)),l&&(this.waveAction=this.mixer.clipAction(l)),h&&(this.cheerAction=this.mixer.clipAction(h)),c&&(this.readingAction=this.mixer.clipAction(c)),f&&(this.frustratedAction=this.mixer.clipAction(f)),p&&(this.dancingAction=this.mixer.clipAction(p))}}buildFallbackModel(){this.usingGLTF=!1,this.labelYOffset=1.95;const t=new Wt(.3,.8,8,16),e=new ct({color:this.color,roughness:.6,metalness:.1});this.bodyMesh=new M(t,e),this.bodyMesh.position.y=.7,this.bodyMesh.castShadow=!0,this.modelRoot.add(this.bodyMesh);const s=new u(this.color);s.lerp(new u(16777215),.25);const i=new X(.3,16,16),n=new ct({color:s,roughness:.5,metalness:.1});if(this.headMesh=new M(i,n),this.headMesh.position.y=1.4,this.headMesh.castShadow=!0,this.modelRoot.add(this.headMesh),this.role==="user"){const a=new gt(.12,.25,5),o=new ct({color:16766720,emissive:16766720,emissiveIntensity:.4,roughness:.3,metalness:.6}),l=new M(a,o);l.position.y=1.85,this.modelRoot.add(l)}this.createGlowRing()}crossFadeTo(t){if(this.currentAction!==t){if(t.reset(),t.setEffectiveTimeScale(1),t.setEffectiveWeight(1),t.play(),this.currentAction){const e=this.currentAction.getClip();this.currentAction.clampWhenFinished&&e.duration>0&&this.currentAction.time>=e.duration-.01?this.currentAction.stop():this.currentAction.crossFadeTo(t,.25,!1)}this.currentAction=t}}transitionTo(t,e){var s;return this.npcState===t?!0:(s=Ce[this.npcState])!=null&&s.has(t)?(this.npcState=t,this.onEnterState(t,e),!0):t==="idle"?(this.npcState="idle",this.state="idle",this.playAnimInternal("idle"),!0):(console.warn(`[NPC:${this.id}] Invalid transition: ${this.npcState} → ${t}`),!1)}onEnterState(t,e){switch(t){case"idle":this.state="idle",this.playAnimInternal("idle");break;case"walking":this.state="walking",this.playAnimInternal("walk");break;case"working":this.state=(e==null?void 0:e.anim)==="reading"?"reading":"typing",this.playAnimInternal((e==null?void 0:e.anim)==="reading"?"reading":"typing");break;case"thinking":this.state="thinking",this.playAnimInternal("thinking");break;case"celebrating":this.state="cheer",this.playAnimInternal("cheer");break;case"emoting":this.state=(e==null?void 0:e.anim)??"wave",this.playAnimInternal((e==null?void 0:e.anim)??"wave");break;case"departing":this.state="walking",this.playAnimInternal("walk");break}}playAnimInternal(t){const e={idle:this.idleAction,walk:this.walkAction,typing:this.typingAction,wave:this.waveAction,cheer:this.cheerAction,reading:this.readingAction??this.typingAction,frustrated:this.frustratedAction??this.idleAction,dancing:this.dancingAction??this.cheerAction,thinking:this.idleAction},s=e[t]??e.idle;if(!s)return;const n=new Set(["wave","cheer","frustrated","dancing"]).has(t),a=n&&(t==="frustrated"&&s===this.idleAction||t==="dancing"&&s===this.cheerAction);n&&!a?(s.setLoop(Ht,1),s.clampWhenFinished=!0):(s.setLoop(Kt,1/0),s.clampWhenFinished=!1),t==="thinking"?s.setEffectiveTimeScale(.5):s.setEffectiveTimeScale(1),this.crossFadeTo(s)}createGlowRing(){if(this.glowRing)return;const t=new H(.4,.05,8,32),e=new T({color:16777215,transparent:!0,opacity:0,side:U});this.glowRing=new M(t,e),this.glowRing.rotation.x=-Math.PI/2,this.glowRing.position.y=.02,this.glowRing.visible=!1,this.mesh.add(this.glowRing)}createLabel(t){const e=document.createElement("div");e.className="npc-label",Object.assign(e.style,{position:"absolute",left:"0",top:"0",willChange:"transform",color:"#ffffff",fontSize:"13px",fontWeight:"600",fontFamily:"sans-serif",textShadow:"0 0 4px rgba(0,0,0,0.8), 0 1px 2px rgba(0,0,0,0.6)",pointerEvents:"none",whiteSpace:"nowrap",userSelect:"none",display:"flex",alignItems:"center",gap:"4px"});const s=document.createElement("span");s.textContent=this.label,e.appendChild(s),this.labelTextSpan=s,t.appendChild(e),this.labelElement=e}setLabel(t){this.label=t,this.name=t,this.labelTextSpan&&(this.labelTextSpan.textContent=t)}setCharacterKey(t,e){!t||this._characterKey===t||(this._characterKey=t,(e==null?void 0:e.modelUrl)!==void 0&&(this._modelUrl=e.modelUrl),(e==null?void 0:e.modelTransform)!==void 0&&(this._modelTransform=e.modelTransform),(e==null?void 0:e.animMapping)!==void 0&&(this._animMapping=e.animMapping),(e==null?void 0:e.animFileUrls)!==void 0&&(this._animFileUrls=e.animFileUrls),this.clearModel(),this.buildModel(),this.state==="walking"&&this.walkAction?this.crossFadeTo(this.walkAction):this.idleAction&&this.crossFadeTo(this.idleAction))}transitionCharacterKey(t,e=1600,s){if(!t||this._characterKey===t)return Promise.resolve();this.characterTransition&&(this.characterTransition.resolve(),this.characterTransition=null);const i=Math.max(.15,e/2e3);return this.ensureModelMaterialsFadeReady(),new Promise(n=>{this.characterTransition={phase:"fadeOut",nextCharacterKey:t,elapsed:0,halfDuration:i,resolve:n,modelOpts:s}})}resolveMove(t){if(!this.moveResolve)return;const e=this.moveResolve;this.moveResolve=null,e(t)}finishMove(t){this.isMoving=!1,this.targetPos=null,this.desiredRotationY=null,this.transitionTo("idle"),this.resolveMove(t)}stopMoving(){this.isMoving&&this.finishMove("interrupted")}moveTo(t,e){return new Promise(s=>{this.moveResolve&&this.finishMove("interrupted"),this.isMoving=!0,this.moveResolve=s,this.speed=e??3,this.targetPos=new g(t.x,0,t.z),this.npcState!=="idle"&&this.npcState!=="walking"&&this.transitionTo("idle"),this.transitionTo("walking")})}async walkPath(t,e){for(const s of t)if(await this.moveTo(s,e)!=="arrived")return}setGlow(t){if(this.glowColor=t,!!this.glowRing){if(t==="none"||!xt[t]){this.glowRing.visible=!1,this.glowRing.material.opacity=0;return}this.glowRing.material.color.setHex(xt[t]),this.glowRing.visible=!0,this.glowPhase=0}}setVisible(t){this.mesh.visible=t,this.labelElement&&(this.labelElement.style.display=t?"":"none")}update(t){if(this.mixer&&this.mixer.update(t),this.indicator.update(t),this.updateCharacterTransition(t),!this.usingGLTF&&this.bodyMesh&&this.headMesh){this.bobPhase+=t*(this.isMoving?8:2);const e=this.isMoving?.08:.03,s=Math.sin(this.bobPhase)*e;this.bodyMesh.position.y=.7+s,this.headMesh.position.y=1.4+s}if(this.targetPos&&this.isMoving){const e=this.mesh.position,s=this.targetPos.x-e.x,i=this.targetPos.z-e.z,n=Math.sqrt(s*s+i*i);if(n<.15)e.set(this.targetPos.x,0,this.targetPos.z),this.finishMove("arrived");else{const a=Math.min(this.speed*t,n),o=s/n,l=i/n;e.x+=o*a,e.z+=l*a,this.desiredRotationY=Math.atan2(o,l)}}if(this.desiredRotationY!==null){let e=this.mesh.rotation.y,s=this.desiredRotationY-e;s>Math.PI&&(s-=Math.PI*2),s<-Math.PI&&(s+=Math.PI*2),Math.abs(s)<.02?(this.mesh.rotation.y=this.desiredRotationY,this.isMoving||(this.desiredRotationY=null)):this.mesh.rotation.y=e+s*Math.min(1,this.smoothTurnSpeed*t)}if(this.glowRing&&this.glowRing.visible){this.glowPhase+=t*3;const e=.35+.3*Math.sin(this.glowPhase);this.glowRing.material.opacity=e}}updateCharacterTransition(t){if(!this.characterTransition)return;this.characterTransition.elapsed+=t;const e=Math.min(this.characterTransition.elapsed/this.characterTransition.halfDuration,1);if(this.characterTransition.phase==="fadeOut"){if(this.setModelOpacity(1-e),e>=1){const s=this.characterTransition.nextCharacterKey,i=this._characterKey;this._characterKey=s;const n=this.characterTransition.modelOpts;(n==null?void 0:n.modelUrl)!==void 0&&(this._modelUrl=n.modelUrl),(n==null?void 0:n.modelTransform)!==void 0&&(this._modelTransform=n.modelTransform),(n==null?void 0:n.animMapping)!==void 0&&(this._animMapping=n.animMapping),(n==null?void 0:n.animFileUrls)!==void 0&&(this._animFileUrls=n.animFileUrls),this.clearModel(),this.buildModel(),this.ensureModelMaterialsFadeReady(),this.setModelOpacity(0),console.log(`[NPC][PersonaTransition] npc=${this.id} swapped model ${i} -> ${s}`),this.state==="walking"&&this.walkAction?this.crossFadeTo(this.walkAction):this.idleAction&&this.crossFadeTo(this.idleAction),this.characterTransition.phase="fadeIn",this.characterTransition.elapsed=0}return}if(this.setModelOpacity(e),e>=1){this.setModelOpacity(1);const s=this.characterTransition.resolve;this.characterTransition=null,s()}}ensureModelMaterialsFadeReady(){this.modelRoot.traverse(t=>{t instanceof M&&(Array.isArray(t.material)?t.material=t.material.map(e=>{const s=e.clone();return s.transparent=!0,s.opacity=1,s.userData={...s.userData??{},npcOwnedMaterial:!0},s}):(t.material=t.material.clone(),t.material.transparent=!0,t.material.opacity=1,t.material.userData={...t.material.userData??{},npcOwnedMaterial:!0}))})}setModelOpacity(t){const e=Math.max(0,Math.min(1,t));this.modelRoot.traverse(s=>{if(s instanceof M)if(Array.isArray(s.material))for(const i of s.material)i.transparent=!0,i.opacity=e;else s.material.transparent=!0,s.material.opacity=e})}async fadeOut(t=500){this.labelElement&&(this.labelElement.style.display="none");const e=Date.now();return new Promise(s=>{const i=()=>{const n=Math.min(1,(Date.now()-e)/t),a=1-n;this.mesh.scale.setScalar(Math.max(.01,a)),this.setModelOpacity(a),n<1?requestAnimationFrame(i):s()};i()})}restoreVisual(){this.mesh.scale.setScalar(1),this.setModelOpacity(1)}updateLabel(t,e){if(!this.labelElement)return;if(!this.isInActiveScene||!this.mesh.visible){this.labelElement.style.display="none";return}if(this.mesh.getWorldPosition(mt),mt.y+=this.labelYOffset,Q.copy(mt).project(t),Q.z>1||Q.x<-1||Q.x>1||Q.y<-1||Q.y>1){this.labelElement.style.display="none";return}const s=e.domElement,i=(Q.x*.5+.5)*s.clientWidth,n=(-Q.y*.5+.5)*s.clientHeight;this.labelElement.style.display="",this.labelElement.style.transform=`translate3d(${i}px, ${n}px, 0) translate(-50%, -100%)`}getPosition(){return this.mesh.position.clone()}lookAtTarget(t){const e=t.x-this.mesh.position.x,s=t.z-this.mesh.position.z;(e!==0||s!==0)&&(this.mesh.rotation.y=Math.atan2(e,s))}smoothLookAt(t){const e=t.x-this.mesh.position.x,s=t.z-this.mesh.position.z;(e!==0||s!==0)&&(this.desiredRotationY=Math.atan2(e,s))}playAnim(t){const s={idle:"idle",walk:"walking",typing:"working",thinking:"thinking",cheer:"celebrating",wave:"emoting",frustrated:"emoting",dancing:"emoting",reading:"working"}[t]??"idle";this.transitionTo(s,{anim:t})||(this.transitionTo("idle"),this.transitionTo(s,{anim:t}))}static loadStatusSvgs(){var e;if(F.svgsLoaded)return;F.svgsLoaded=!0;const t=Object.assign({"../assets/status-celebrate.svg":be,"../assets/status-error.svg":ve,"../assets/status-success.svg":xe,"../assets/status-working.svg":Se});for(const[s,i]of Object.entries(t)){const n=(e=s.match(/status-(\w+)\.svg$/))==null?void 0:e[1];n&&(F.STATUS_SVGS[n]=i)}}setStatusEmoji(t){if(!this.labelElement||t===this.currentStatusKey||(this.currentStatusKey=t,F.loadStatusSvgs(),this.statusSpan&&(this.statusSpan.remove(),this.statusSpan=null),!t))return;const s={working:"working",success:"success",error:"error",celebrate:"celebrate"}[t],i=s?F.STATUS_SVGS[s]:null,n=document.createElement("span");n.className="npc-si",Object.assign(n.style,{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px"}),i?n.innerHTML=i.replace(/width="120"/,'width="18"').replace(/height="120"/,'height="18"'):(n.textContent=t,n.style.fontSize="14px"),this.labelElement.appendChild(n),this.statusSpan=n}updateStatusPosition(t,e,s){}clearModel(){const t=!this.usingGLTF;this.mixer&&(this.mixer.removeEventListener("finished",this.onAnimFinished),this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.modelRoot),this.mixer=null),this.idleAction=null,this.walkAction=null,this.typingAction=null,this.waveAction=null,this.cheerAction=null,this.readingAction=null,this.frustratedAction=null,this.dancingAction=null,this.currentAction=null,this.bodyMesh=null,this.headMesh=null,this.usingGLTF=!1,this.modelRoot.traverse(e=>{if(!(e instanceof M))return;const s=i=>{var a;!!((a=i.userData)!=null&&a.npcOwnedMaterial)&&i.dispose()};Array.isArray(e.material)?e.material.forEach(s):s(e.material)}),t&&this.modelRoot.traverse(e=>{e instanceof M&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(s=>s.dispose()):e.material.dispose())}),this.modelRoot.clear()}destroy(){this.labelElement&&this.labelElement.parentElement&&(this.labelElement.parentElement.removeChild(this.labelElement),this.labelElement=null),this.clearModel(),this.indicator.destroy(),this.statusSpan&&(this.statusSpan.remove(),this.statusSpan=null),this.glowRing&&(this.glowRing.geometry.dispose(),Array.isArray(this.glowRing.material)?this.glowRing.material.forEach(t=>t.dispose()):this.glowRing.material.dispose(),this.glowRing=null),this.mesh.parent&&this.mesh.parent.remove(this.mesh),this.targetPos=null,this.moveResolve&&this.resolveMove("interrupted"),this.characterTransition&&(this.characterTransition.resolve(),this.characterTransition=null)}};r(F,"assetLoader",null),r(F,"STATUS_SVGS",{}),r(F,"svgsLoaded",!1);let St=F;const _e=[{period:"dawn",startHour:5,endHour:7},{period:"morning",startHour:7,endHour:12},{period:"noon",startHour:12,endHour:14},{period:"afternoon",startHour:14,endHour:17},{period:"dusk",startHour:17,endHour:19},{period:"night",startHour:19,endHour:5}],Pe={startHour:6,dayDurationRealMs:36e5,nightSpeedMultiplier:3,paused:!1},Fe="agentshire_clock";class hs{constructor(t={}){r(this,"config");r(this,"gameSeconds");r(this,"dayCount",0);r(this,"lastPeriod");r(this,"periodCallbacks",new Map);r(this,"storageKey",Fe);r(this,"saveCounter",0);this.config={...Pe,...t},this.gameSeconds=this.config.startHour*3600,this.restoreFromStorage(),this.lastPeriod=this.getPeriod()}setStorageKey(t){this.storageKey=t,localStorage.getItem(this.storageKey)?this.restoreFromStorage():(this.gameSeconds=this.config.startHour*3600,this.dayCount=0),this.lastPeriod=this.getPeriod()}restoreFromStorage(){try{const t=localStorage.getItem(this.storageKey);if(!t)return;const e=JSON.parse(t);typeof e.dayCount=="number"&&typeof e.gameSeconds=="number"&&(this.dayCount=e.dayCount,this.gameSeconds=e.gameSeconds)}catch{}}persistToStorage(){try{const t={dayCount:this.dayCount,gameSeconds:this.gameSeconds,savedAt:Date.now()};localStorage.setItem(this.storageKey,JSON.stringify(t))}catch{}}update(t){if(this.config.paused)return;const s=this.getPeriod()==="night"?this.config.nightSpeedMultiplier:1,i=24*3600/(this.config.dayDurationRealMs/1e3);Math.floor(this.gameSeconds/3600),this.gameSeconds+=t*i*s,this.gameSeconds>=24*3600&&(this.gameSeconds-=24*3600,this.dayCount++,this.persistToStorage());const n=this.getPeriod();if(n!==this.lastPeriod){this.lastPeriod=n;const a=this.getState();for(const o of this.periodCallbacks.values())o(a);this.persistToStorage()}this.saveCounter++,this.saveCounter>=600&&(this.saveCounter=0,this.persistToStorage())}getState(){const t=this.gameSeconds,e=Math.floor(t/3600)%24,s=Math.floor(t%3600/60);return{hour:e,minute:s,normalizedTime:t/(24*3600),period:this.getPeriod(),dayCount:this.dayCount,isNight:this.isNight()}}getFormattedTime(){const t=this.getState();return`${String(t.hour).padStart(2,"0")}:${String(t.minute).padStart(2,"0")}`}getPeriod(){const t=this.gameSeconds/3600%24;for(const e of _e)if(e.period==="night"){if(t>=e.startHour||t<e.endHour)return"night"}else if(t>=e.startHour&&t<e.endHour)return e.period;return"morning"}getNormalizedTime(){return this.gameSeconds/(24*3600)}getGameHour(){return this.gameSeconds/3600%24}isNight(){const t=this.getGameHour();return t>=19||t<5}isPaused(){return this.config.paused}pause(){this.config.paused=!0}resume(){this.config.paused=!1}setSpeed(t){this.config.dayDurationRealMs=t}setTime(t){this.gameSeconds=t%24*3600,this.lastPeriod=this.getPeriod()}advanceTime(t){for(this.gameSeconds+=t*3600;this.gameSeconds>=24*3600;)this.gameSeconds-=24*3600,this.dayCount++;this.lastPeriod=this.getPeriod(),this.persistToStorage()}onPeriodChange(t,e){this.periodCallbacks.set(t,e)}offPeriodChange(t){this.periodCallbacks.delete(t)}}const Y=[{hour:5,preset:{sunColor:new u(16766112),sunIntensity:.6,sunAngleDeg:10,ambientColor:new u(14735560),ambientIntensity:.35,hemiSkyColor:new u(16763812),hemiGroundColor:new u(8413248),hemiIntensity:.25,skyColor:new u(16763812),fogNear:35,fogFar:75,bloomStrength:.4,streetLightIntensity:.5,windowEmissiveIntensity:.2}},{hour:7,preset:{sunColor:new u(16774624),sunIntensity:1,sunAngleDeg:35,ambientColor:new u(14213360),ambientIntensity:.55,hemiSkyColor:new u(8900331),hemiGroundColor:new u(4876336),hemiIntensity:.35,skyColor:new u(8900331),fogNear:40,fogFar:85,bloomStrength:.3,streetLightIntensity:0,windowEmissiveIntensity:0}},{hour:12,preset:{sunColor:new u(16776949),sunIntensity:1.3,sunAngleDeg:80,ambientColor:new u(14739711),ambientIntensity:.65,hemiSkyColor:new u(10541311),hemiGroundColor:new u(4876336),hemiIntensity:.35,skyColor:new u(10541311),fogNear:45,fogFar:90,bloomStrength:.25,streetLightIntensity:0,windowEmissiveIntensity:0}},{hour:14,preset:{sunColor:new u(16773328),sunIntensity:1.1,sunAngleDeg:60,ambientColor:new u(14213360),ambientIntensity:.58,hemiSkyColor:new u(9490672),hemiGroundColor:new u(4876336),hemiIntensity:.35,skyColor:new u(8900331),fogNear:42,fogFar:85,bloomStrength:.3,streetLightIntensity:0,windowEmissiveIntensity:0}},{hour:16,preset:{sunColor:new u(16771248),sunIntensity:.95,sunAngleDeg:40,ambientColor:new u(14212328),ambientIntensity:.55,hemiSkyColor:new u(9488608),hemiGroundColor:new u(4876336),hemiIntensity:.32,skyColor:new u(8767720),fogNear:40,fogFar:82,bloomStrength:.32,streetLightIntensity:0,windowEmissiveIntensity:0}},{hour:17.5,preset:{sunColor:new u(16748624),sunIntensity:.7,sunAngleDeg:12,ambientColor:new u(14207152),ambientIntensity:.45,hemiSkyColor:new u(14712896),hemiGroundColor:new u(6307888),hemiIntensity:.28,skyColor:new u(16746581),fogNear:36,fogFar:78,bloomStrength:.4,streetLightIntensity:.5,windowEmissiveIntensity:.2}},{hour:18.5,preset:{sunColor:new u(12607552),sunIntensity:.35,sunAngleDeg:3,ambientColor:new u(12628136),ambientIntensity:.4,hemiSkyColor:new u(9461840),hemiGroundColor:new u(5259320),hemiIntensity:.25,skyColor:new u(8405072),fogNear:34,fogFar:75,bloomStrength:.45,streetLightIntensity:1.2,windowEmissiveIntensity:.45}},{hour:19.5,preset:{sunColor:new u(8425664),sunIntensity:.15,sunAngleDeg:-10,ambientColor:new u(11581648),ambientIntensity:.4,hemiSkyColor:new u(5269640),hemiGroundColor:new u(3162184),hemiIntensity:.25,skyColor:new u(1714768),fogNear:35,fogFar:75,bloomStrength:.5,streetLightIntensity:2,windowEmissiveIntensity:.7}},{hour:23,preset:{sunColor:new u(7372976),sunIntensity:.12,sunAngleDeg:-25,ambientColor:new u(10528960),ambientIntensity:.35,hemiSkyColor:new u(4214896),hemiGroundColor:new u(2633792),hemiIntensity:.22,skyColor:new u(1383994),fogNear:32,fogFar:72,bloomStrength:.5,streetLightIntensity:2,windowEmissiveIntensity:.7}},{hour:27,preset:{sunColor:new u(7372976),sunIntensity:.12,sunAngleDeg:-25,ambientColor:new u(10528960),ambientIntensity:.35,hemiSkyColor:new u(4214896),hemiGroundColor:new u(2633792),hemiIntensity:.22,skyColor:new u(1383994),fogNear:32,fogFar:72,bloomStrength:.5,streetLightIntensity:2,windowEmissiveIntensity:.7}},{hour:29,preset:{sunColor:new u(16766112),sunIntensity:.6,sunAngleDeg:10,ambientColor:new u(14735560),ambientIntensity:.35,hemiSkyColor:new u(16763812),hemiGroundColor:new u(8413248),hemiIntensity:.25,skyColor:new u(16763812),fogNear:35,fogFar:75,bloomStrength:.4,streetLightIntensity:.5,windowEmissiveIntensity:.2}}];class cs{constructor(t,e,s){r(this,"refs");r(this,"scene");r(this,"postProcess");r(this,"enabled",!0);r(this,"updateCounter",0);r(this,"currentSunColor",new u);r(this,"currentAmbientColor",new u);r(this,"currentHemiSkyColor",new u);r(this,"currentHemiGroundColor",new u);r(this,"currentSkyColor",new u);r(this,"currentSunIntensity",1);r(this,"currentAmbientIntensity",.6);r(this,"currentHemiIntensity",.35);r(this,"currentSunAngle",35);r(this,"currentFogNear",40);r(this,"currentFogFar",80);r(this,"currentBloom",.35);r(this,"currentStreetLight",0);r(this,"currentWindowEmissive",0);r(this,"weatherSunMul",1);r(this,"weatherAmbMul",1);r(this,"weatherAmbTint",new u(1,1,1));r(this,"weatherFogNearOff",0);r(this,"weatherFogFarOff",0);r(this,"weatherSkyTint",new u(1,1,1));r(this,"flashActive",!1);r(this,"flashSunOverride",0);r(this,"flashAmbOverride",0);this.scene=t,this.refs=e,this.postProcess=s,this.currentSunColor.copy(e.directional.color),this.currentAmbientColor.copy(e.ambient.color),this.currentHemiSkyColor.set(8900331),this.currentHemiGroundColor.set(3825696),this.currentSkyColor.set(8900331)}update(t){if(!this.enabled||(this.updateCounter++,this.updateCounter%10!==0))return;const e=t.getGameHour(),s=this.samplePreset(e),i=.5;this.currentSunColor.lerp(s.sunColor,i),this.currentAmbientColor.lerp(s.ambientColor,i),this.currentHemiSkyColor.lerp(s.hemiSkyColor,i),this.currentHemiGroundColor.lerp(s.hemiGroundColor,i),this.currentSkyColor.lerp(s.skyColor,i),this.currentSunIntensity=N.lerp(this.currentSunIntensity,s.sunIntensity,i),this.currentAmbientIntensity=N.lerp(this.currentAmbientIntensity,s.ambientIntensity,i),this.currentHemiIntensity=N.lerp(this.currentHemiIntensity,s.hemiIntensity,i),this.currentSunAngle=N.lerp(this.currentSunAngle,s.sunAngleDeg,i),this.currentFogNear=N.lerp(this.currentFogNear,s.fogNear,i),this.currentFogFar=N.lerp(this.currentFogFar,s.fogFar,i),this.currentBloom=N.lerp(this.currentBloom,s.bloomStrength,i),this.currentStreetLight=N.lerp(this.currentStreetLight,s.streetLightIntensity,i),this.currentWindowEmissive=N.lerp(this.currentWindowEmissive,s.windowEmissiveIntensity,i),this.apply()}setEnabled(t){this.enabled=t}getStreetLights(){return this.refs.streetLightPoints}getCurrentBloom(){return this.currentBloom}applyWeatherOverride(t,e,s,i,n,a){this.weatherSunMul=t,this.weatherAmbMul=e,this.weatherAmbTint.copy(s),this.weatherFogNearOff=i,this.weatherFogFarOff=n,this.weatherSkyTint.copy(a),this.apply()}applyFlashOverride(t){this.flashActive=!0,this.flashSunOverride=t,this.flashAmbOverride=t*.6,this.apply()}clearFlashOverride(){this.flashActive=!1,this.flashSunOverride=0,this.flashAmbOverride=0,this.apply()}samplePreset(t){let e=t;e<5&&(e+=24);let s=Y[0],i=Y[1];for(let l=0;l<Y.length-1;l++)if(e>=Y[l].hour&&e<Y[l+1].hour){s=Y[l],i=Y[l+1];break}const n=i.hour-s.hour,a=n>0?(e-s.hour)/n:0,o=ze(a);return{sunColor:new u().copy(s.preset.sunColor).lerp(i.preset.sunColor,o),sunIntensity:V(s.preset.sunIntensity,i.preset.sunIntensity,o),sunAngleDeg:V(s.preset.sunAngleDeg,i.preset.sunAngleDeg,o),ambientColor:new u().copy(s.preset.ambientColor).lerp(i.preset.ambientColor,o),ambientIntensity:V(s.preset.ambientIntensity,i.preset.ambientIntensity,o),hemiSkyColor:new u().copy(s.preset.hemiSkyColor).lerp(i.preset.hemiSkyColor,o),hemiGroundColor:new u().copy(s.preset.hemiGroundColor).lerp(i.preset.hemiGroundColor,o),hemiIntensity:V(s.preset.hemiIntensity,i.preset.hemiIntensity,o),skyColor:new u().copy(s.preset.skyColor).lerp(i.preset.skyColor,o),fogNear:V(s.preset.fogNear,i.preset.fogNear,o),fogFar:V(s.preset.fogFar,i.preset.fogFar,o),bloomStrength:V(s.preset.bloomStrength,i.preset.bloomStrength,o),streetLightIntensity:V(s.preset.streetLightIntensity,i.preset.streetLightIntensity,o),windowEmissiveIntensity:V(s.preset.windowEmissiveIntensity,i.preset.windowEmissiveIntensity,o)}}apply(){const{directional:t,ambient:e,hemisphere:s,streetLightPoints:i,windowLights:n}=this.refs;t.color.copy(this.currentSunColor),t.intensity=this.flashActive?this.flashSunOverride:this.currentSunIntensity*this.weatherSunMul;const a=Le(this.currentSunAngle);t.position.copy(a),e.color.copy(this.currentAmbientColor).multiply(this.weatherAmbTint),e.intensity=this.flashActive?this.flashAmbOverride:this.currentAmbientIntensity*this.weatherAmbMul,s.color.copy(this.currentHemiSkyColor),s.groundColor.copy(this.currentHemiGroundColor),s.intensity=this.currentHemiIntensity,this.scene.background instanceof u&&this.scene.background.copy(this.currentSkyColor).multiply(this.weatherSkyTint),this.scene.fog instanceof Qt&&(this.scene.fog.color.copy(this.currentSkyColor).multiply(this.weatherSkyTint),this.scene.fog.near=this.currentFogNear+this.weatherFogNearOff,this.scene.fog.far=this.currentFogFar+this.weatherFogFarOff);for(const o of i)o.intensity=this.currentStreetLight;for(const o of n)o.intensity=this.currentWindowEmissive;this.postProcess&&this.postProcess.setBloomStrength(this.currentBloom)}}function Le(y){const t=y*Math.PI/180,e=30,s=Math.sin(t)*e,i=Math.cos(t)*e;return new g(i,Math.max(s,1),-10)}function ze(y){const t=Math.max(0,Math.min(1,y));return t*t*(3-2*t)}function V(y,t,e){return y+(t-y)*e}const At={low:8e3,medium:8e3,high:25e3},Tt={low:4e3,medium:4e3,high:12e3},kt={low:3e3,medium:3e3,high:1e4},Ie={low:80,medium:80,high:200},Re=`
|
|
345
|
+
attribute vec2 aRandom;
|
|
346
|
+
uniform float time;
|
|
347
|
+
uniform float intensity;
|
|
348
|
+
uniform vec3 windForce;
|
|
349
|
+
uniform float spawnHeight;
|
|
350
|
+
uniform float spawnRadius;
|
|
351
|
+
uniform float dropLength;
|
|
352
|
+
varying float vAlpha;
|
|
353
|
+
|
|
354
|
+
float hash(float n) { return fract(sin(n) * 43758.5453); }
|
|
355
|
+
|
|
356
|
+
void main() {
|
|
357
|
+
float seed = aRandom.x;
|
|
358
|
+
float phase = aRandom.y;
|
|
359
|
+
float vertIdx = mod(float(gl_VertexID), 2.0);
|
|
360
|
+
vec3 pos = position;
|
|
361
|
+
float fallSpeed = -15.0 * (0.8 + seed * 0.4);
|
|
362
|
+
float t = time + phase * 10.0;
|
|
363
|
+
pos.y = mod(pos.y + fallSpeed * t, spawnHeight);
|
|
364
|
+
float fallProgress = 1.0 - pos.y / spawnHeight;
|
|
365
|
+
pos.x += windForce.x * fallProgress * 0.5;
|
|
366
|
+
pos.z += windForce.z * fallProgress * 0.5;
|
|
367
|
+
pos.x = mod(pos.x + spawnRadius, spawnRadius * 2.0) - spawnRadius;
|
|
368
|
+
pos.z = mod(pos.z + spawnRadius, spawnRadius * 2.0) - spawnRadius;
|
|
369
|
+
if (vertIdx > 0.5) {
|
|
370
|
+
float stretch = dropLength * (1.0 + length(windForce) * 0.05);
|
|
371
|
+
pos.y -= stretch;
|
|
372
|
+
pos.x += windForce.x * 0.01;
|
|
373
|
+
}
|
|
374
|
+
vAlpha = step(seed, intensity) * 0.35;
|
|
375
|
+
float dist = length(pos.xz);
|
|
376
|
+
vAlpha *= smoothstep(spawnRadius, spawnRadius * 0.6, dist);
|
|
377
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
|
|
378
|
+
}
|
|
379
|
+
`,Ge=`
|
|
380
|
+
precision highp float;
|
|
381
|
+
varying float vAlpha;
|
|
382
|
+
void main() {
|
|
383
|
+
if (vAlpha < 0.01) discard;
|
|
384
|
+
gl_FragColor = vec4(0.7, 0.75, 0.9, vAlpha);
|
|
385
|
+
}
|
|
386
|
+
`,Ee=`
|
|
387
|
+
attribute vec3 aSeed;
|
|
388
|
+
uniform float time;
|
|
389
|
+
uniform float intensity;
|
|
390
|
+
uniform vec3 windForce;
|
|
391
|
+
uniform float spawnHeight;
|
|
392
|
+
uniform float spawnRadius;
|
|
393
|
+
uniform float flutterAmp;
|
|
394
|
+
uniform float pointSize;
|
|
395
|
+
varying float vAlpha;
|
|
396
|
+
varying float vSize;
|
|
397
|
+
varying float vSeed;
|
|
398
|
+
|
|
399
|
+
void main() {
|
|
400
|
+
float seed = aSeed.x;
|
|
401
|
+
float phase = aSeed.y;
|
|
402
|
+
float sizeVar = aSeed.z;
|
|
403
|
+
vec3 pos = position;
|
|
404
|
+
float fallSpeed = -1.5 * (0.6 + seed * 0.8);
|
|
405
|
+
float t = time + phase * 8.0;
|
|
406
|
+
pos.y = mod(pos.y + fallSpeed * t, spawnHeight);
|
|
407
|
+
float flutter = sin(t * (1.5 + seed * 2.0) + phase) * flutterAmp;
|
|
408
|
+
float flutter2 = cos(t * (1.0 + seed * 1.5) + phase * 2.0) * flutterAmp * 0.7;
|
|
409
|
+
pos.x += flutter + windForce.x * (1.0 - pos.y / spawnHeight) * 0.8;
|
|
410
|
+
pos.z += flutter2 + windForce.z * (1.0 - pos.y / spawnHeight) * 0.8;
|
|
411
|
+
pos.x = mod(pos.x + spawnRadius, spawnRadius * 2.0) - spawnRadius;
|
|
412
|
+
pos.z = mod(pos.z + spawnRadius, spawnRadius * 2.0) - spawnRadius;
|
|
413
|
+
vAlpha = step(seed, intensity) * 0.8;
|
|
414
|
+
float dist = length(pos.xz);
|
|
415
|
+
vAlpha *= smoothstep(spawnRadius, spawnRadius * 0.5, dist);
|
|
416
|
+
vSize = sizeVar;
|
|
417
|
+
vSeed = seed;
|
|
418
|
+
vec4 mvPos = modelViewMatrix * vec4(pos, 1.0);
|
|
419
|
+
gl_Position = projectionMatrix * mvPos;
|
|
420
|
+
gl_PointSize = clamp(pointSize * sizeVar * (160.0 / -mvPos.z), 1.5, 24.0);
|
|
421
|
+
}
|
|
422
|
+
`,Oe=`
|
|
423
|
+
precision highp float;
|
|
424
|
+
varying float vAlpha;
|
|
425
|
+
varying float vSize;
|
|
426
|
+
varying float vSeed;
|
|
427
|
+
|
|
428
|
+
void main() {
|
|
429
|
+
if (vAlpha < 0.01) discard;
|
|
430
|
+
vec2 center = gl_PointCoord - 0.5;
|
|
431
|
+
float d = length(center);
|
|
432
|
+
float circle = smoothstep(0.5, 0.15, d);
|
|
433
|
+
|
|
434
|
+
float shape = circle;
|
|
435
|
+
// ~10% of flakes become ❄️ six-pointed stars
|
|
436
|
+
if (vSeed > 0.7) {
|
|
437
|
+
float angle = atan(center.y, center.x);
|
|
438
|
+
float arms = abs(sin(angle * 3.0));
|
|
439
|
+
float star = smoothstep(0.48, 0.12, d - arms * 0.2);
|
|
440
|
+
shape = star;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
if (shape < 0.05) discard;
|
|
444
|
+
float sparkle = max(sin(d * 30.0 + vSize * 12.0) * 0.1, 0.0);
|
|
445
|
+
gl_FragColor = vec4(0.95 + sparkle, 0.97 + sparkle, 1.0, shape * vAlpha);
|
|
446
|
+
}
|
|
447
|
+
`,Be=`
|
|
448
|
+
attribute float aSeed;
|
|
449
|
+
uniform float time;
|
|
450
|
+
uniform vec3 windForce;
|
|
451
|
+
uniform float pointSize;
|
|
452
|
+
uniform float intensity;
|
|
453
|
+
varying float vAlpha;
|
|
454
|
+
|
|
455
|
+
void main() {
|
|
456
|
+
vec3 pos = position;
|
|
457
|
+
float t = time + aSeed * 20.0;
|
|
458
|
+
pos.x += windForce.x * t * 0.3 + sin(t * 2.0 + aSeed * 6.28) * 2.0;
|
|
459
|
+
pos.z += windForce.z * t * 0.3 + cos(t * 1.5 + aSeed * 6.28) * 2.0;
|
|
460
|
+
pos.y += sin(t * 3.0 + aSeed * 10.0) * 1.5;
|
|
461
|
+
float r = 40.0;
|
|
462
|
+
pos.x = mod(pos.x + r, r * 2.0) - r;
|
|
463
|
+
pos.z = mod(pos.z + r, r * 2.0) - r;
|
|
464
|
+
pos.y = mod(pos.y, 15.0);
|
|
465
|
+
vAlpha = step(aSeed, intensity) * (0.2 + aSeed * 0.2);
|
|
466
|
+
vec4 mvPos = modelViewMatrix * vec4(pos, 1.0);
|
|
467
|
+
gl_Position = projectionMatrix * mvPos;
|
|
468
|
+
gl_PointSize = clamp(pointSize * (80.0 / -mvPos.z), 1.0, 8.0);
|
|
469
|
+
}
|
|
470
|
+
`,De=`
|
|
471
|
+
precision highp float;
|
|
472
|
+
uniform vec3 dustColor;
|
|
473
|
+
varying float vAlpha;
|
|
474
|
+
void main() {
|
|
475
|
+
vec2 c = gl_PointCoord - 0.5;
|
|
476
|
+
float d = length(c);
|
|
477
|
+
float alpha = smoothstep(0.5, 0.2, d);
|
|
478
|
+
if (alpha < 0.01) discard;
|
|
479
|
+
gl_FragColor = vec4(dustColor, alpha * vAlpha);
|
|
480
|
+
}
|
|
481
|
+
`,$e=`
|
|
482
|
+
attribute float size;
|
|
483
|
+
attribute float alpha;
|
|
484
|
+
varying float vAlpha;
|
|
485
|
+
void main() {
|
|
486
|
+
vAlpha = alpha;
|
|
487
|
+
vec4 mvPos = modelViewMatrix * vec4(position, 1.0);
|
|
488
|
+
gl_PointSize = clamp(size * (80.0 / -mvPos.z), 1.0, 14.0);
|
|
489
|
+
gl_Position = projectionMatrix * mvPos;
|
|
490
|
+
}
|
|
491
|
+
`,Ue=`
|
|
492
|
+
varying float vAlpha;
|
|
493
|
+
void main() {
|
|
494
|
+
float d = length(gl_PointCoord - vec2(0.5));
|
|
495
|
+
float ring = 1.0 - smoothstep(0.3, 0.5, d);
|
|
496
|
+
ring *= smoothstep(0.1, 0.25, d);
|
|
497
|
+
if (ring < 0.05) discard;
|
|
498
|
+
gl_FragColor = vec4(0.8, 0.85, 0.9, vAlpha * ring * 0.5);
|
|
499
|
+
}
|
|
500
|
+
`,Ne=`
|
|
501
|
+
uniform float time;
|
|
502
|
+
uniform float intensity;
|
|
503
|
+
varying vec2 vUv;
|
|
504
|
+
varying float vIntensity;
|
|
505
|
+
|
|
506
|
+
void main() {
|
|
507
|
+
vUv = uv;
|
|
508
|
+
vec3 pos = position;
|
|
509
|
+
|
|
510
|
+
float wave1 = sin(pos.x * 0.02 + time * 0.3) * 8.0;
|
|
511
|
+
float wave2 = sin(pos.x * 0.05 + time * 0.7) * 3.0;
|
|
512
|
+
float wave3 = cos(pos.x * 0.03 + time * 0.15) * 5.0;
|
|
513
|
+
pos.y += wave1 + wave2;
|
|
514
|
+
pos.z += wave3;
|
|
515
|
+
|
|
516
|
+
float ruffle = sin(pos.x * 0.1 + time * 1.5) * 2.0 * uv.y;
|
|
517
|
+
pos.z += ruffle;
|
|
518
|
+
|
|
519
|
+
vIntensity = smoothstep(0.0, 0.3, uv.y) * smoothstep(1.0, 0.6, uv.y);
|
|
520
|
+
vIntensity *= (0.5 + 0.5 * sin(pos.x * 0.03 + time * 0.2)) * intensity;
|
|
521
|
+
|
|
522
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
|
|
523
|
+
}
|
|
524
|
+
`,Ve=`
|
|
525
|
+
precision highp float;
|
|
526
|
+
uniform vec3 color1;
|
|
527
|
+
uniform vec3 color2;
|
|
528
|
+
uniform vec3 color3;
|
|
529
|
+
varying vec2 vUv;
|
|
530
|
+
varying float vIntensity;
|
|
531
|
+
|
|
532
|
+
void main() {
|
|
533
|
+
vec3 col;
|
|
534
|
+
if (vUv.y < 0.4) {
|
|
535
|
+
col = mix(color2, color1, vUv.y / 0.4);
|
|
536
|
+
} else if (vUv.y < 0.7) {
|
|
537
|
+
col = mix(color1, color3, (vUv.y - 0.4) / 0.3);
|
|
538
|
+
} else {
|
|
539
|
+
col = mix(color3, color2, (vUv.y - 0.7) / 0.3);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
float hVar = sin(vUv.x * 20.0) * 0.1 + 0.9;
|
|
543
|
+
float alpha = vIntensity * hVar;
|
|
544
|
+
alpha *= smoothstep(0.0, 0.1, vUv.y) * smoothstep(1.0, 0.85, vUv.y);
|
|
545
|
+
|
|
546
|
+
if (alpha < 0.01) discard;
|
|
547
|
+
gl_FragColor = vec4(col * 1.5, alpha * 0.6);
|
|
548
|
+
}
|
|
549
|
+
`;class We{constructor(t,e,s){r(this,"scene");r(this,"profile");r(this,"enabled",!0);r(this,"time",0);r(this,"rainMesh",null);r(this,"rainMaterial",null);r(this,"snowMesh",null);r(this,"snowMaterial",null);r(this,"dustMesh",null);r(this,"dustMaterial",null);r(this,"splashMesh",null);r(this,"splashPositions",null);r(this,"splashSizes",null);r(this,"splashAlphas",null);r(this,"splashParticles",[]);r(this,"splashCount");r(this,"snowGround",null);r(this,"snowGroundOpacity",0);r(this,"fogPlane",null);r(this,"auroraMesh",null);r(this,"auroraMaterial",null);r(this,"RADIUS",40);r(this,"SPAWN_HEIGHT",30);this.scene=t,this.profile=s,this.splashCount=Ie[s],At[s]>0&&this.initRain(At[s]),Tt[s]>0&&this.initSnow(Tt[s]),kt[s]>0&&this.initDust(kt[s]),this.splashCount>0&&this.initSplash(),this.initSnowGround(),this.initFogPlane(),this.initAurora()}initRain(t){const e=this.RADIUS,s=this.SPAWN_HEIGHT,i=t*2,n=new Float32Array(i*3),a=new Float32Array(i*2);for(let l=0;l<t;l++){const h=(Math.random()-.5)*e*2,c=Math.random()*s,f=(Math.random()-.5)*e*2,p=Math.random(),m=Math.random();n[l*6]=h,n[l*6+1]=c,n[l*6+2]=f,n[l*6+3]=h,n[l*6+4]=c-.3,n[l*6+5]=f,a[l*4]=p,a[l*4+1]=m,a[l*4+2]=p,a[l*4+3]=m}const o=new B;o.setAttribute("position",new E(n,3)),o.setAttribute("aRandom",new E(a,2)),this.rainMaterial=new $({vertexShader:Re,fragmentShader:Ge,transparent:!0,depthWrite:!1,blending:rt,uniforms:{time:{value:0},intensity:{value:0},windForce:{value:new g(5,0,2)},spawnHeight:{value:s},spawnRadius:{value:e},dropLength:{value:.3}}}),this.rainMesh=new Yt(o,this.rainMaterial),this.rainMesh.frustumCulled=!1,this.rainMesh.visible=!1,this.scene.add(this.rainMesh)}initSnow(t){const e=this.RADIUS,s=25,i=new Float32Array(t*3),n=new Float32Array(t*3);for(let o=0;o<t;o++)i[o*3]=(Math.random()-.5)*e*2,i[o*3+1]=Math.random()*s,i[o*3+2]=(Math.random()-.5)*e*2,n[o*3]=Math.random(),n[o*3+1]=Math.random()*Math.PI*2,n[o*3+2]=.4+Math.random()*1;const a=new B;a.setAttribute("position",new E(i,3)),a.setAttribute("aSeed",new E(n,3)),this.snowMaterial=new $({vertexShader:Ee,fragmentShader:Oe,transparent:!0,depthWrite:!1,uniforms:{time:{value:0},intensity:{value:0},windForce:{value:new g(1,0,.5)},spawnHeight:{value:s},spawnRadius:{value:e},flutterAmp:{value:2},pointSize:{value:3}}}),this.snowMesh=new at(a,this.snowMaterial),this.snowMesh.frustumCulled=!1,this.snowMesh.visible=!1,this.scene.add(this.snowMesh)}initDust(t){const e=new Float32Array(t*3),s=new Float32Array(t);for(let n=0;n<t;n++)e[n*3]=(Math.random()-.5)*80,e[n*3+1]=Math.random()*15,e[n*3+2]=(Math.random()-.5)*80,s[n]=Math.random();const i=new B;i.setAttribute("position",new E(e,3)),i.setAttribute("aSeed",new E(s,1)),this.dustMaterial=new $({vertexShader:Be,fragmentShader:De,transparent:!0,depthWrite:!1,uniforms:{time:{value:0},intensity:{value:0},dustColor:{value:new u(12886112)},windForce:{value:new g(8,0,2)},pointSize:{value:3}}}),this.dustMesh=new at(i,this.dustMaterial),this.dustMesh.frustumCulled=!1,this.dustMesh.visible=!1,this.scene.add(this.dustMesh)}initSplash(){const t=this.splashCount;this.splashPositions=new Float32Array(t*3),this.splashSizes=new Float32Array(t),this.splashAlphas=new Float32Array(t);for(let i=0;i<t;i++)this.splashParticles.push({life:0,maxLife:0,x:0,z:0}),this.splashPositions[i*3+1]=-1e3,this.splashAlphas[i]=0,this.splashSizes[i]=2;const e=new B;e.setAttribute("position",new E(this.splashPositions,3)),e.setAttribute("size",new E(this.splashSizes,1)),e.setAttribute("alpha",new E(this.splashAlphas,1));const s=new $({vertexShader:$e,fragmentShader:Ue,transparent:!0,depthWrite:!1});this.splashMesh=new at(e,s),this.splashMesh.frustumCulled=!1,this.splashMesh.visible=!1,this.scene.add(this.splashMesh)}initSnowGround(){const t=new ut(60,40),e=new T({color:15791354,transparent:!0,opacity:0,depthWrite:!1});this.snowGround=new M(t,e),this.snowGround.rotation.x=-Math.PI/2,this.snowGround.position.set(18,.03,12),this.snowGround.visible=!1,this.scene.add(this.snowGround)}initFogPlane(){const t=new ut(100,60,1,1),e=new T({color:13421772,transparent:!0,opacity:0,depthWrite:!1,side:U});this.fogPlane=new M(t,e),this.fogPlane.rotation.x=-Math.PI/2,this.fogPlane.position.set(18,1.5,12),this.fogPlane.visible=!1,this.scene.add(this.fogPlane)}initAurora(){const t=new ut(200,25,96,12);this.auroraMaterial=new $({vertexShader:Ne,fragmentShader:Ve,transparent:!0,depthWrite:!1,side:U,blending:rt,uniforms:{time:{value:0},intensity:{value:0},color1:{value:new u(65416)},color2:{value:new u(4456703)},color3:{value:new u(16711782)}}}),this.auroraMesh=new M(t,this.auroraMaterial),this.auroraMesh.position.set(18,12,-15),this.auroraMesh.rotation.x=-.15,this.auroraMesh.visible=!1,this.scene.add(this.auroraMesh)}setEnabled(t){this.enabled=t,t||this.hideAll()}updateVisuals(t,e,s){if(!this.enabled)return;this.time+=t;const i=e.position.x,n=e.position.z;if(this.rainMesh&&this.rainMaterial){const a=s.rain>.01;if(this.rainMesh.visible=a,a){this.rainMesh.position.set(i,0,n);const o=this.rainMaterial.uniforms;o.time.value=this.time,o.intensity.value=s.rain,o.windForce.value.set(s.windX,0,s.windZ),o.dropLength.value=.15+s.rain*.35}}if(this.snowMesh&&this.snowMaterial){const a=s.snow>.01;if(this.snowMesh.visible=a,a){this.snowMesh.position.set(i,0,n);const o=this.snowMaterial.uniforms;o.time.value=this.time,o.intensity.value=s.snow,o.windForce.value.set(s.windX*2,0,s.windZ*1),o.flutterAmp.value=2-s.snow*1.5,o.pointSize.value=1.5+s.snow*3.5}}if(this.dustMesh&&this.dustMaterial){const a=s.dust>.01;if(this.dustMesh.visible=a,a){this.dustMesh.position.set(i,0,n);const o=this.dustMaterial.uniforms;o.time.value=this.time,o.intensity.value=s.dust,o.windForce.value.set(s.windX,0,s.windZ)}}if(this.updateSplash(t,i,n,s.rain),this.updateSnowGround(t,s.snowGround),this.updateFogPlane(s.groundFog),this.auroraMesh&&this.auroraMaterial){const a=s.aurora>.01;this.auroraMesh.visible=a,a&&(this.auroraMaterial.uniforms.time.value=this.time,this.auroraMaterial.uniforms.intensity.value=s.aurora)}}triggerLightningFlash(){}updateSplash(t,e,s,i){if(!this.splashMesh||!this.splashPositions||!this.splashAlphas||!this.splashSizes)return;const n=i>.1;if(this.splashMesh.visible=n,!n)return;const a=Math.floor(this.splashCount*i),o=1-i*.6,l=1+i*2.5,h=2+i*6,c=this.RADIUS*(.6+i*.9);for(let p=0;p<this.splashCount;p++){if(p>=a){this.splashPositions[p*3+1]=-1e3,this.splashAlphas[p]=0;continue}const m=this.splashParticles[p];m.life+=t,m.life>=m.maxLife&&(m.life=0,m.maxLife=(.1+Math.random()*.15)*o,m.x=e+(Math.random()-.5)*c*2,m.z=s+(Math.random()-.5)*c*2);const v=m.life/m.maxLife;this.splashPositions[p*3]=m.x,this.splashPositions[p*3+1]=.05,this.splashPositions[p*3+2]=m.z,this.splashAlphas[p]=Math.min(i*1.2,1)*(1-v),this.splashSizes[p]=l+v*h}const f=this.splashMesh.geometry;f.attributes.position.needsUpdate=!0,f.attributes.alpha.needsUpdate=!0,f.attributes.size.needsUpdate=!0}updateSnowGround(t,e){if(!this.snowGround)return;const s=this.snowGround.material,i=e>.05?e*.5:0;this.snowGroundOpacity=N.lerp(this.snowGroundOpacity,i,t*.5),s.opacity=this.snowGroundOpacity,this.snowGround.visible=this.snowGroundOpacity>.01}updateFogPlane(t){if(!this.fogPlane)return;const e=this.fogPlane.material;e.opacity=t*.2,this.fogPlane.visible=t>.02}hideAll(){this.rainMesh&&(this.rainMesh.visible=!1),this.snowMesh&&(this.snowMesh.visible=!1),this.dustMesh&&(this.dustMesh.visible=!1),this.splashMesh&&(this.splashMesh.visible=!1),this.snowGround&&(this.snowGround.visible=!1),this.fogPlane&&(this.fogPlane.visible=!1),this.auroraMesh&&(this.auroraMesh.visible=!1)}setScene(t){const e=s=>{var i;s&&((i=s.parent)==null||i.remove(s),t.add(s))};e(this.rainMesh),e(this.snowMesh),e(this.dustMesh),e(this.splashMesh),e(this.snowGround),e(this.fogPlane),e(this.auroraMesh),this.scene=t}clear(){this.hideAll()}destroy(){const t=e=>{var s;if(e){if("geometry"in e&&e.geometry&&e.geometry.dispose(),"material"in e){const i=e.material;Array.isArray(i)?i.forEach(n=>n.dispose()):i!=null&&i.dispose&&i.dispose()}(s=e.parent)==null||s.remove(e)}};t(this.rainMesh),t(this.snowMesh),t(this.dustMesh),t(this.splashMesh),t(this.snowGround),t(this.fogPlane),t(this.auroraMesh)}}const J={clear:{rain:0,snow:0,dust:0,lightning:0,aurora:0,fogDensityAdd:0,groundFog:0,snowGround:0,skyDarkness:0,windMul:.5,sunMul:1,ambMul:1,ambTint:[1,1,1],skyTint:[1,1,1],fogNearOff:0,fogFarOff:0,bloomAdd:0},cloudy:{rain:0,snow:0,dust:0,lightning:0,aurora:0,fogDensityAdd:0,groundFog:0,snowGround:0,skyDarkness:.2,windMul:.8,sunMul:.5,ambMul:.85,ambTint:[.82,.84,.9],skyTint:[.72,.74,.78],fogNearOff:-8,fogFarOff:-15,bloomAdd:0},drizzle:{rain:.3,snow:0,dust:0,lightning:0,aurora:0,fogDensityAdd:0,groundFog:0,snowGround:0,skyDarkness:.3,windMul:.7,sunMul:.45,ambMul:.8,ambTint:[.78,.8,.88],skyTint:[.65,.68,.74],fogNearOff:-10,fogFarOff:-18,bloomAdd:.02},rain:{rain:.7,snow:0,dust:0,lightning:.1,aurora:0,fogDensityAdd:0,groundFog:0,snowGround:0,skyDarkness:.5,windMul:1.2,sunMul:.3,ambMul:.7,ambTint:[.7,.72,.8],skyTint:[.5,.53,.6],fogNearOff:-12,fogFarOff:-25,bloomAdd:.1},heavyRain:{rain:1,snow:0,dust:0,lightning:.3,aurora:0,fogDensityAdd:0,groundFog:0,snowGround:0,skyDarkness:.7,windMul:1.8,sunMul:.15,ambMul:.6,ambTint:[.6,.62,.72],skyTint:[.4,.42,.5],fogNearOff:-16,fogFarOff:-32,bloomAdd:.15},storm:{rain:1,snow:0,dust:0,lightning:.6,aurora:0,fogDensityAdd:0,groundFog:0,snowGround:0,skyDarkness:.85,windMul:2.5,sunMul:.05,ambMul:.45,ambTint:[.5,.5,.6],skyTint:[.25,.25,.32],fogNearOff:-25,fogFarOff:-32,bloomAdd:.2},lightSnow:{rain:0,snow:.3,dust:0,lightning:0,aurora:0,fogDensityAdd:0,groundFog:0,snowGround:.2,skyDarkness:.15,windMul:.6,sunMul:.5,ambMul:.9,ambTint:[.88,.9,.96],skyTint:[.82,.86,.92],fogNearOff:-6,fogFarOff:-12,bloomAdd:.03},snow:{rain:0,snow:.85,dust:0,lightning:0,aurora:0,fogDensityAdd:0,groundFog:0,snowGround:.6,skyDarkness:.25,windMul:1,sunMul:.35,ambMul:.88,ambTint:[.88,.9,.96],skyTint:[.82,.85,.9],fogNearOff:-10,fogFarOff:-20,bloomAdd:.05},blizzard:{rain:0,snow:1,dust:0,lightning:0,aurora:0,fogDensityAdd:0,groundFog:0,snowGround:.9,skyDarkness:.4,windMul:4,sunMul:.12,ambMul:.7,ambTint:[.88,.9,.95],skyTint:[.85,.87,.92],fogNearOff:-18,fogFarOff:-38,bloomAdd:.08},fog:{rain:0,snow:0,dust:0,lightning:0,aurora:0,fogDensityAdd:0,groundFog:0,snowGround:0,skyDarkness:.2,windMul:.2,sunMul:.25,ambMul:.8,ambTint:[.88,.88,.9],skyTint:[.78,.78,.8],fogNearOff:-18,fogFarOff:-35,bloomAdd:.02},sandstorm:{rain:0,snow:0,dust:1,lightning:.1,aurora:0,fogDensityAdd:0,groundFog:0,snowGround:0,skyDarkness:.5,windMul:3,sunMul:.25,ambMul:.55,ambTint:[.9,.65,.35],skyTint:[.7,.5,.25],fogNearOff:-20,fogFarOff:-38,bloomAdd:.08},aurora:{rain:0,snow:0,dust:0,lightning:0,aurora:1,fogDensityAdd:0,groundFog:0,snowGround:0,skyDarkness:0,windMul:.3,sunMul:1,ambMul:1.5,ambTint:[.7,1,.9],skyTint:[.6,.85,.8],fogNearOff:0,fogFarOff:0,bloomAdd:.4}},He={"storm→clear":["rain","cloudy","clear"],"blizzard→clear":["snow","lightSnow","clear"],"clear→storm":["cloudy","rain","heavyRain","storm"],"clear→blizzard":["lightSnow","snow","blizzard"],"heavyRain→clear":["rain","cloudy","clear"],"storm→cloudy":["rain","cloudy"],"blizzard→cloudy":["snow","lightSnow","cloudy"]};function Ke(y,t){const e=`${y}→${t}`;return He[e]??[t]}const It=[{theme:"sunny",weight:30},{theme:"overcast",weight:18},{theme:"drizzleDay",weight:15},{theme:"rainy",weight:14},{theme:"stormy",weight:4},{theme:"snowy",weight:6},{theme:"blizzardDay",weight:3},{theme:"foggy",weight:4},{theme:"sandstormDay",weight:3},{theme:"auroraDay",weight:3}],Qe=It.reduce((y,t)=>y+t.weight,0),Ct={sunny:{dawn:"clear",morning:"clear",noon:"clear",afternoon:"clear",dusk:"clear",night:"clear"},overcast:{dawn:"clear",morning:"cloudy",noon:"cloudy",afternoon:"cloudy",dusk:"cloudy",night:"clear"},drizzleDay:{dawn:"cloudy",morning:"drizzle",noon:"drizzle",afternoon:"drizzle",dusk:"cloudy",night:"clear"},rainy:{dawn:"cloudy",morning:"drizzle",noon:"rain",afternoon:"rain",dusk:"drizzle",night:"cloudy"},stormy:{dawn:"cloudy",morning:"rain",noon:"heavyRain",afternoon:"storm",dusk:"heavyRain",night:"rain"},snowy:{dawn:"cloudy",morning:"lightSnow",noon:"snow",afternoon:"snow",dusk:"lightSnow",night:"cloudy"},blizzardDay:{dawn:"lightSnow",morning:"snow",noon:"blizzard",afternoon:"blizzard",dusk:"snow",night:"lightSnow"},foggy:{dawn:"fog",morning:"fog",noon:"cloudy",afternoon:"cloudy",dusk:"fog",night:"fog"},sandstormDay:{dawn:"cloudy",morning:"sandstorm",noon:"sandstorm",afternoon:"sandstorm",dusk:"cloudy",night:"clear"},auroraDay:{dawn:"clear",morning:"clear",noon:"clear",afternoon:"clear",dusk:"clear",night:"aurora"}};function Ye(){const y=Math.random()*Qe;let t=0;for(const e of It)if(t+=e.weight,y<t)return e.theme;return"sunny"}class us{constructor(t,e,s,i,n){r(this,"scene");r(this,"lighting");r(this,"postProcess");r(this,"camera");r(this,"effects");r(this,"currentWeather","clear");r(this,"targetWeather","clear");r(this,"transitionProgress",1);r(this,"transitionSpeed",.4);r(this,"transitionQueue",[]);r(this,"enabled",!0);r(this,"updateCounter",0);r(this,"lastDayCount",-1);r(this,"lastPeriod",null);r(this,"currentTheme","sunny");r(this,"thunderTimer",0);r(this,"lightningFlashTimer",0);r(this,"baseBloomAdd",0);r(this,"_onThunderCb",null);r(this,"_tint",new u);r(this,"_sky",new u);r(this,"_elapsed",0);this.scene=t,this.camera=e,this.lighting=s,this.postProcess=i,this.effects=new We(t,e,n)}getWeather(){return this.currentWeather}getDisplayWeather(){return this.transitionQueue.length>0?this.transitionQueue[this.transitionQueue.length-1]:this.targetWeather}getDayTheme(){return this.currentTheme}onThunder(t){this._onThunderCb=t}setEnabled(t){this.enabled=t,this.effects.setEnabled(t)}forceWeather(t){J[t]&&(this.transitionQueue=[],this.currentWeather=t,this.targetWeather=t,this.transitionProgress=1)}forceTheme(t){const e=t;Ct[e]&&(this.currentTheme=e,this.lastPeriod=null)}resetToAutomatic(){this.lastPeriod=null,this.transitionQueue=[]}startTransitionTo(t){if(t===this.targetWeather&&this.transitionQueue.length===0)return;const e=Ke(this.getDisplayWeather(),t);this.transitionQueue=e,this.advanceQueue()}advanceQueue(){if(this.transitionQueue.length===0)return;const t=this.transitionQueue.shift();this.currentWeather=this.targetWeather,this.targetWeather=t,this.transitionProgress=0}update(t,e){var h;if(!this.enabled)return;this._elapsed+=t;const s=e.getState();if(s.dayCount!==this.lastDayCount&&(this.lastDayCount=s.dayCount,this.currentTheme=Ye(),this.lastPeriod=null),s.period!==this.lastPeriod){this.lastPeriod=s.period;const c=((h=Ct[this.currentTheme])==null?void 0:h[s.period])??"clear";c!==this.getDisplayWeather()&&this.startTransitionTo(c)}this.transitionProgress<1&&(this.transitionProgress=Math.min(1,this.transitionProgress+t*this.transitionSpeed),this.transitionProgress>=1&&(this.currentWeather=this.targetWeather,this.transitionQueue.length>0&&this.advanceQueue()));const i=qe(this.transitionProgress),n=J[this.currentWeather]??J.clear,a=J[this.targetWeather]??J.clear,o=A(n.windMul,a.windMul,i)*5,l={rain:A(n.rain,a.rain,i),snow:A(n.snow,a.snow,i),dust:A(n.dust,a.dust,i),lightning:A(n.lightning,a.lightning,i),aurora:A(n.aurora,a.aurora,i),windX:o,windZ:o*.4,fogDensityAdd:A(n.fogDensityAdd,a.fogDensityAdd,i),groundFog:A(n.groundFog,a.groundFog,i),snowGround:A(n.snowGround,a.snowGround,i)};this.effects.updateVisuals(t,this.camera,l),this.updateCounter++,this.updateCounter%10===0&&(this.applyLighting(i,n,a),this.updateThunder(t*10,l.lightning))}applyLighting(t,e,s){const i=A(e.sunMul,s.sunMul,t),n=A(e.ambMul,s.ambMul,t),a=A(e.fogNearOff,s.fogNearOff,t),o=A(e.fogFarOff,s.fogFarOff,t),l=A(e.bloomAdd,s.bloomAdd,t);this.baseBloomAdd=l,this._tint.setRGB(A(e.ambTint[0],s.ambTint[0],t),A(e.ambTint[1],s.ambTint[1],t),A(e.ambTint[2],s.ambTint[2],t)),this._sky.setRGB(A(e.skyTint[0],s.skyTint[0],t),A(e.skyTint[1],s.skyTint[1],t),A(e.skyTint[2],s.skyTint[2],t));const h=A(e.aurora,s.aurora,t);if(h>.01){const c=this._elapsed*.2,f=Math.sin(c)*.5+.5,p=Math.sin(c+2.1)*.5+.5,m=A(.15,.5,p),v=A(.6,1,f),x=A(.5,1,p),C=h*.8;this._tint.r=A(this._tint.r,m,C),this._tint.g=A(this._tint.g,v,C),this._tint.b=A(this._tint.b,x,C),this._sky.r=A(this._sky.r,m*.4,C*.6),this._sky.g=A(this._sky.g,v*.4,C*.6),this._sky.b=A(this._sky.b,x*.4,C*.6)}this.lighting.applyWeatherOverride(i,n,this._tint,a,o,this._sky),this.lightningFlashTimer<=0&&this.postProcess&&this.postProcess.setBloomStrength(this.lighting.getCurrentBloom()+l)}updateThunder(t,e){var s;if(e<.05){this.lightningFlashTimer=0;return}if(this.lightningFlashTimer>0&&(this.lightningFlashTimer-=t,this.lightningFlashTimer<=0&&(this.lightningFlashTimer=0,this.postProcess&&this.postProcess.setBloomStrength(this.lighting.getCurrentBloom()+this.baseBloomAdd),this.lighting.clearFlashOverride())),this.thunderTimer-=t,this.thunderTimer<=0){Math.random()<.7&&this.triggerLightning();const n=e>=.6?.9:.65;(s=this._onThunderCb)==null||s.call(this,n),this.thunderTimer=1/e*(1.5+Math.random()*3.5)}}triggerLightning(){this.postProcess&&this.postProcess.setBloomStrength(3),this.lighting.applyFlashOverride(5),this.lightningFlashTimer=.25,this.effects.triggerLightningFlash()}setScene(t){this.scene=t,this.effects.setScene(t)}clear(){this.effects.clear()}destroy(){this.effects.destroy()}}function qe(y){const t=Math.max(0,Math.min(1,y));return t*t*(3-2*t)}function A(y,t,e){return y+(t-y)*e}export{rs as A,os as B,bt as C,is as E,hs as G,St as N,ts as P,cs as T,ns as V,us as W,ke as a,ss as b,es as d,as as g,ls as p};
|
|
550
|
+
//# sourceMappingURL=WeatherSystem-Cb3BvHes.js.map
|