agentscape3d 1.0.0-beta.1 → 1.0.0-beta.2

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.
Files changed (386) hide show
  1. package/README.md +23 -48
  2. package/dist/core.d.ts +68 -0
  3. package/dist/core.js +209 -0
  4. package/dist/core.js.map +1 -0
  5. package/dist/index.d.ts +10 -229
  6. package/dist/index.js +192 -15462
  7. package/dist/index.js.map +1 -1
  8. package/package.json +11 -40
  9. package/cli.mjs +0 -27
  10. package/dist/AssetCompiler-CDFiElji.js +0 -2451
  11. package/dist/AssetCompiler-CDFiElji.js.map +0 -1
  12. package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
  13. package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
  14. package/dist/AssetRecipe-DmFpzxr-.js +0 -55
  15. package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
  16. package/dist/BrowserCodeWorker.js +0 -53615
  17. package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
  18. package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
  19. package/dist/SceneSerializer-DPVOyeRk.js +0 -353
  20. package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
  21. package/dist/StylePack-DNrdLeGI.js +0 -6314
  22. package/dist/StylePack-DNrdLeGI.js.map +0 -1
  23. package/dist/WorldArchive-pSBIGxLa.js +0 -420
  24. package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
  25. package/dist/WorldIO-wsDfZGM4.js +0 -150
  26. package/dist/WorldIO-wsDfZGM4.js.map +0 -1
  27. package/dist/blankWorld-CBWbwJGj.js +0 -76
  28. package/dist/blankWorld-CBWbwJGj.js.map +0 -1
  29. package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
  30. package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
  31. package/dist/environments-DgH66NqV.js +0 -4220
  32. package/dist/environments-DgH66NqV.js.map +0 -1
  33. package/dist/gltfIO-B87nJaat.js +0 -10
  34. package/dist/gltfIO-B87nJaat.js.map +0 -1
  35. package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
  36. package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
  37. package/dist/magicCabin-D64fD1E2.js +0 -11024
  38. package/dist/magicCabin-D64fD1E2.js.map +0 -1
  39. package/dist/mcp.d.ts +0 -2
  40. package/dist/mcp.js +0 -1
  41. package/dist/monumentHall-BKbs0UOQ.js +0 -404
  42. package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
  43. package/dist/node.d.ts +0 -16
  44. package/dist/node.js +0 -25
  45. package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
  46. package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
  47. package/dist/runtime/application/AgentTools.js +0 -25
  48. package/dist/runtime/application/README.md +0 -14
  49. package/dist/runtime/application/buildTaskObservation.js +0 -117
  50. package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
  51. package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
  52. package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
  53. package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
  54. package/dist/runtime/application/createSession.js +0 -66
  55. package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
  56. package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
  57. package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
  58. package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
  59. package/dist/runtime/application/native-scene/CodeProject.js +0 -119
  60. package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
  61. package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
  62. package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
  63. package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
  64. package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
  65. package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
  66. package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
  67. package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
  68. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
  69. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
  70. package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
  71. package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
  72. package/dist/runtime/application/scene/RequestWindow.js +0 -54
  73. package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
  74. package/dist/runtime/application/scene/SceneContracts.js +0 -45
  75. package/dist/runtime/application/scene/SceneEditService.js +0 -144
  76. package/dist/runtime/application/scene/SceneFacade.js +0 -267
  77. package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
  78. package/dist/runtime/application/scene/SceneJobController.js +0 -229
  79. package/dist/runtime/application/scene/ScenePackage.js +0 -162
  80. package/dist/runtime/application/scene/ScenePersistence.js +0 -50
  81. package/dist/runtime/application/scene/SceneProject.js +0 -95
  82. package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
  83. package/dist/runtime/application/scene/StarterScene.js +0 -56
  84. package/dist/runtime/application/scene/WorldArchive.js +0 -87
  85. package/dist/runtime/application/scene/WorldDirectory.js +0 -20
  86. package/dist/runtime/application/scene/WorldDocument.js +0 -74
  87. package/dist/runtime/application/scene/WorldIO.js +0 -103
  88. package/dist/runtime/application/scene/WorldStorage.js +0 -137
  89. package/dist/runtime/application/skills/SkillRegistry.js +0 -163
  90. package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
  91. package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
  92. package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
  93. package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
  94. package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
  95. package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
  96. package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
  97. package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
  98. package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
  99. package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
  100. package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
  101. package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
  102. package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
  103. package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
  104. package/dist/runtime/application/skills/skillPrimitives.js +0 -4
  105. package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
  106. package/dist/runtime/application/tasks.jsonl +0 -67
  107. package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
  108. package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
  109. package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
  110. package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
  111. package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
  112. package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
  113. package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
  114. package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
  115. package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
  116. package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
  117. package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
  118. package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
  119. package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
  120. package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
  121. package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
  122. package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
  123. package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
  124. package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
  125. package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
  126. package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
  127. package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
  128. package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
  129. package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
  130. package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
  131. package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
  132. package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
  133. package/dist/runtime/apps/mcp-server/README.md +0 -150
  134. package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
  135. package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
  136. package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
  137. package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
  138. package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
  139. package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
  140. package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
  141. package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
  142. package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
  143. package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
  144. package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
  145. package/dist/runtime/apps/mcp-server/main.mjs +0 -56
  146. package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
  147. package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
  148. package/dist/runtime/apps/mcp-server/security.js +0 -21
  149. package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
  150. package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
  151. package/dist/runtime/apps/server/README.md +0 -7
  152. package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
  153. package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
  154. package/dist/runtime/apps/server/tasks.jsonl +0 -10
  155. package/dist/runtime/foundation/EventBus.js +0 -18
  156. package/dist/runtime/foundation/JsonGateway.js +0 -47
  157. package/dist/runtime/foundation/PolicyEngine.js +0 -21
  158. package/dist/runtime/foundation/README.md +0 -7
  159. package/dist/runtime/foundation/TraceRecorder.js +0 -76
  160. package/dist/runtime/foundation/errors.js +0 -8
  161. package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
  162. package/dist/runtime/foundation/version.js +0 -2
  163. package/dist/runtime/modules/agent/README.md +0 -11
  164. package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
  165. package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
  166. package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
  167. package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
  168. package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
  169. package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
  170. package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
  171. package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
  172. package/dist/runtime/modules/agent/prompt/index.js +0 -46
  173. package/dist/runtime/modules/agent/tasks.jsonl +0 -94
  174. package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
  175. package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
  176. package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
  177. package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
  178. package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
  179. package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
  180. package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
  181. package/dist/runtime/modules/artifact/README.md +0 -7
  182. package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
  183. package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
  184. package/dist/runtime/modules/asset/AssetModule.js +0 -399
  185. package/dist/runtime/modules/asset/README.md +0 -54
  186. package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
  187. package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
  188. package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
  189. package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
  190. package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
  191. package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
  192. package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
  193. package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
  194. package/dist/runtime/modules/asset/model/admission.js +0 -117
  195. package/dist/runtime/modules/asset/model/errors.js +0 -6
  196. package/dist/runtime/modules/asset/model/parts.js +0 -27
  197. package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
  198. package/dist/runtime/modules/asset/model/schema.js +0 -150
  199. package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
  200. package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
  201. package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
  202. package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
  203. package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
  204. package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
  205. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
  206. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
  207. package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
  208. package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
  209. package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
  210. package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
  211. package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
  212. package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
  213. package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
  214. package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
  215. package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
  216. package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
  217. package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
  218. package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
  219. package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
  220. package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
  221. package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
  222. package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
  223. package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
  224. package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
  225. package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
  226. package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
  227. package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
  228. package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
  229. package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
  230. package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
  231. package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
  232. package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
  233. package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
  234. package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
  235. package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
  236. package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
  237. package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
  238. package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
  239. package/dist/runtime/modules/asset/tasks.jsonl +0 -87
  240. package/dist/runtime/modules/generation/README.md +0 -9
  241. package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
  242. package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
  243. package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
  244. package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
  245. package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
  246. package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
  247. package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
  248. package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
  249. package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
  250. package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
  251. package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
  252. package/dist/runtime/modules/generation/tasks.jsonl +0 -35
  253. package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
  254. package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
  255. package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
  256. package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
  257. package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
  258. package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
  259. package/dist/runtime/modules/rendering/README.md +0 -7
  260. package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
  261. package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
  262. package/dist/runtime/modules/rendering/createRenderer.js +0 -76
  263. package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
  264. package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
  265. package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
  266. package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
  267. package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
  268. package/dist/runtime/modules/world/README.md +0 -13
  269. package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
  270. package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
  271. package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
  272. package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
  273. package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
  274. package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
  275. package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
  276. package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
  277. package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
  278. package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
  279. package/dist/runtime/modules/world/content/blankWorld.js +0 -35
  280. package/dist/runtime/modules/world/content/environments.js +0 -84
  281. package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
  282. package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
  283. package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
  284. package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
  285. package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
  286. package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
  287. package/dist/runtime/modules/world/content/magicCabin.js +0 -190
  288. package/dist/runtime/modules/world/content/monumentHall.js +0 -154
  289. package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
  290. package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
  291. package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
  292. package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
  293. package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
  294. package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
  295. package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
  296. package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
  297. package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
  298. package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
  299. package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
  300. package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
  301. package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
  302. package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
  303. package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
  304. package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
  305. package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
  306. package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
  307. package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
  308. package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
  309. package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
  310. package/dist/runtime/modules/world/errors.js +0 -9
  311. package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
  312. package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
  313. package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
  314. package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
  315. package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
  316. package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
  317. package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
  318. package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
  319. package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
  320. package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
  321. package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
  322. package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
  323. package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
  324. package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
  325. package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
  326. package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
  327. package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
  328. package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
  329. package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
  330. package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
  331. package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
  332. package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
  333. package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
  334. package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
  335. package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
  336. package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
  337. package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
  338. package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
  339. package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
  340. package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
  341. package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
  342. package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
  343. package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
  344. package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
  345. package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
  346. package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
  347. package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
  348. package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
  349. package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
  350. package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
  351. package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
  352. package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
  353. package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
  354. package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
  355. package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
  356. package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
  357. package/dist/runtime/modules/world/tasks.jsonl +0 -530
  358. package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
  359. package/dist/runtime/modules/world/verification/Finding.js +0 -105
  360. package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
  361. package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
  362. package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
  363. package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
  364. package/dist/runtime/package-lock.json +0 -6245
  365. package/dist/runtime/package.json +0 -91
  366. package/dist/runtime/public/assets/cabinet.glb +0 -0
  367. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
  368. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
  369. package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
  370. package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
  371. package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
  372. package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
  373. package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
  374. package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
  375. package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
  376. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
  377. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
  378. package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
  379. package/dist/schema-Dudvovhu.js +0 -364
  380. package/dist/schema-Dudvovhu.js.map +0 -1
  381. package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
  382. package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
  383. package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
  384. package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
  385. package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
  386. package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
@@ -1,642 +0,0 @@
1
- /* 吴苑澄观 · 主程序
2
- * 渲染器 / 后处理、分阶段加载、双模式漫游、12 个定点观察视角、
3
- * 景点标注、小地图、性能 HUD、画质与天气自适应。
4
- */
5
- import * as THREE from 'three';
6
- import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
7
- import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
8
- import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
9
- import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
10
- import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
11
- import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
12
- import {
13
- WORLD, QUALITY, POIS, HOTSPOTS, LOD_LEVELS,
14
- buildTextures, buildMaterials, Batch, waterSDF, terrainHeight, clamp,
15
- } from './core.js';
16
- import { buildBuildings } from './buildings.js';
17
- import { buildRockery } from './rockery.js';
18
- import { createWater } from './water.js';
19
- import { createNature } from './nature.js';
20
- import { createSky } from './sky.js';
21
- import { LODManager } from './lod.js';
22
-
23
- const $ = s => document.querySelector(s);
24
- const $$ = s => Array.from(document.querySelectorAll(s));
25
- const nextFrame = () => new Promise(r => requestAnimationFrame(() => setTimeout(r, 0)));
26
- const lerp = THREE.MathUtils.lerp;
27
-
28
- /* 电影调色:轻微 S 曲线、冷暖分离、暗角与胶片颗粒 */
29
- const GradeShader = {
30
- uniforms: {
31
- tDiffuse: { value: null }, uTime: { value: 0 },
32
- uResolution: { value: new THREE.Vector2(1, 1) }, uStrength: { value: 1 },
33
- },
34
- vertexShader: `varying vec2 vUv; void main(){ vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); }`,
35
- fragmentShader: `
36
- precision highp float;
37
- uniform sampler2D tDiffuse; uniform float uTime; uniform vec2 uResolution; uniform float uStrength;
38
- varying vec2 vUv;
39
- void main(){
40
- vec3 c = texture2D(tDiffuse, vUv).rgb;
41
- vec3 o = c;
42
- c = clamp((c - 0.5) * 1.052 + 0.5, 0.0, 1.0);
43
- float l = dot(c, vec3(0.2126, 0.7152, 0.0722));
44
- c += vec3(0.015, 0.005, -0.012) * smoothstep(0.55, 1.0, l);
45
- c += vec3(-0.007, 0.001, 0.016) * (1.0 - smoothstep(0.0, 0.45, l));
46
- vec2 q = vUv - 0.5;
47
- c *= 1.0 - dot(q, q) * 0.46;
48
- float g = fract(sin(dot(vUv * uResolution + uTime * 29.0, vec2(12.9898, 78.233))) * 43758.5453);
49
- c += (g - 0.5) * 0.009;
50
- gl_FragColor = vec4(mix(o, c, uStrength), 1.0);
51
- }`,
52
- };
53
-
54
- function guessInitialQuality() {
55
- const p = new URLSearchParams(location.search);
56
- const forced = p.get('q');
57
- if (QUALITY[forced]) return forced;
58
- const dpr = window.devicePixelRatio || 1;
59
- const cores = navigator.hardwareConcurrency || 4;
60
- const mem = navigator.deviceMemory || 4;
61
- const area = window.innerWidth * window.innerHeight;
62
- if (cores <= 2 || mem <= 2 || /Android|iPhone|iPad/i.test(navigator.userAgent)) return 'low';
63
- if (cores <= 4 || mem <= 4 || area > 2600000 || dpr > 2.5) return 'medium';
64
- return 'high';
65
- }
66
-
67
- const state = {
68
- quality: guessInitialQuality(), auto: true, walk: false, labels: true,
69
- hour: WORLD.sunDefaultHour, weather: 'clear', poi: 'overview',
70
- fps: 60, frames: 0, acc: 0, lowFor: 0, highFor: 0, cooldown: 0,
71
- started: false, lodViz: false, lodVizParam: new URLSearchParams(location.search).get('lod') === '1',
72
- };
73
-
74
- let renderer, scene, camera, controls, composer, bloomPass, gradePass, outputPass, renderPass;
75
- let sky, water, nature, lod, mainGroup, plaques = [], labelEls = [], gpuTimer = null;
76
- let tween = null, toastTimer = null;
77
- let labelT = 0, mapT = 0;
78
- const keys = new Set();
79
- const clock = new THREE.Clock();
80
- const walkState = { yaw: 0, pitch: -0.10, eye: 1.70, vx: 0, vz: 0, locked: false };
81
-
82
- function progress(p, text) {
83
- const bar = $('#load-bar'), pct = $('#load-pct'), label = $('#load-label');
84
- if (bar) bar.style.width = `${Math.round(p * 100)}%`;
85
- if (pct) pct.textContent = `${Math.round(p * 100)}%`;
86
- if (label) label.textContent = text;
87
- }
88
-
89
- /* ================================================================== *
90
- * 启动
91
- * ================================================================== */
92
- async function boot() {
93
- const canvas = $('#scene');
94
- renderer = new THREE.WebGLRenderer({ canvas, antialias: true, powerPreference: 'high-performance', stencil: false });
95
- renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, QUALITY[state.quality].dpr));
96
- renderer.setSize(window.innerWidth, window.innerHeight);
97
- renderer.outputColorSpace = THREE.SRGBColorSpace;
98
- renderer.toneMapping = THREE.ACESFilmicToneMapping;
99
- renderer.toneMappingExposure = 1.08;
100
- renderer.shadowMap.enabled = true;
101
- renderer.shadowMap.type = THREE.PCFSoftShadowMap;
102
- renderer.shadowMap.autoUpdate = false; // 静态场景:仅时辰 / 画质变化时重绘阴影
103
- renderer.shadowMap.needsUpdate = true;
104
- renderer.info.autoReset = false;
105
-
106
- scene = new THREE.Scene();
107
- camera = new THREE.PerspectiveCamera(POIS[0].fov, window.innerWidth / window.innerHeight, 0.1, 3200);
108
- camera.position.set(...POIS[0].pos);
109
- camera.lookAt(...POIS[0].target);
110
-
111
- progress(0.04, '初始化渲染器与相机');
112
- await nextFrame();
113
-
114
- /* 材质贴图集 */
115
- progress(0.09, '生成白粉墙 / 黛瓦 / 太湖石等 PBR 纹理');
116
- await nextFrame();
117
- const T = buildTextures((p, k) => progress(0.09 + p * 0.17, `生成程序化材质:${k}`), QUALITY[state.quality].texScale);
118
- const M = buildMaterials(T);
119
- T && Object.values(T).forEach(t => {
120
- t.map.anisotropy = QUALITY[state.quality].aniso;
121
- t.normalMap.anisotropy = QUALITY[state.quality].aniso;
122
- t.roughnessMap.anisotropy = QUALITY[state.quality].aniso;
123
- });
124
- await nextFrame();
125
-
126
- /* 天空与光照 */
127
- progress(0.28, '布置江南午后天光、软阴影与大气雾');
128
- await nextFrame();
129
- sky = createSky(scene, renderer, M);
130
- sky.setHour(state.hour);
131
- sky.setQuality(QUALITY[state.quality]);
132
-
133
- /* 分批构建:建筑 → 假山 → 植被 → 水体 */
134
- lod = new LODManager(camera, scene);
135
- lod.setQuality(QUALITY[state.quality]);
136
- const B = new Batch(40);
137
- mainGroup = new THREE.Group(); mainGroup.name = '园林静态几何'; scene.add(mainGroup);
138
- const ctx = {
139
- B, M, scene, plaques, lod, BatchClass: Batch, quality: QUALITY[state.quality],
140
- waterfalls: [], streams: [],
141
- onProgress: (p, name) => progress(0.31 + p * 0.25, `构建建筑:${name}`),
142
- };
143
-
144
- progress(0.31, '构建中轴礼序与九大景区建筑群');
145
- await nextFrame();
146
- buildBuildings(ctx);
147
- await nextFrame();
148
-
149
- progress(0.57, '生成太湖石假山、洞壑与池岸驳岸');
150
- await nextFrame();
151
- ctx.onProgress = (p, name) => progress(0.57 + p * 0.13, `${name}`);
152
- buildRockery(ctx);
153
- const buildStats = B.build(mainGroup);
154
- console.log(`[场景] 静态合批 ${buildStats.meshes} 组 / ${Math.round(buildStats.tris)} 三角形`);
155
- await nextFrame();
156
-
157
- progress(0.71, '生成地形、园路、林木花木与远景借景');
158
- await nextFrame();
159
- nature = createNature(scene, M, ctx);
160
-
161
- progress(0.84, '布置水面、跌水与天气联动');
162
- await nextFrame();
163
- water = createWater(scene, ctx);
164
- water.setSky(sky.getState());
165
-
166
- /* LOD 注册 */
167
- [mainGroup, nature.trunkGroup, nature.pathGroup].forEach(g => g && lod.addBatchGroup(g));
168
- lod.setQuality(QUALITY[state.quality]);
169
- if (state.lodVizParam) setLodViz(true);
170
-
171
- progress(0.90, '装配漫游交互、后处理与画质分级');
172
- await nextFrame();
173
- controls = new OrbitControls(camera, renderer.domElement);
174
- controls.enableDamping = true;
175
- controls.dampingFactor = 0.055;
176
- controls.rotateSpeed = 0.55;
177
- controls.zoomSpeed = 0.9;
178
- controls.panSpeed = 0.75;
179
- controls.screenSpacePanning = false;
180
- controls.minDistance = 2.5;
181
- controls.maxDistance = 420;
182
- // 允许适度仰视(定点视角常需从人眼高度仰望檐口与远塔),
183
- // 过严的 89° 上限会把相机强行抬到目标之上,破坏人眼视高构图
184
- controls.minPolarAngle = 0.05;
185
- controls.maxPolarAngle = Math.PI * 0.62;
186
- controls.target.set(...POIS[0].target);
187
- controls.update();
188
-
189
- composer = new EffectComposer(renderer);
190
- renderPass = new RenderPass(scene, camera);
191
- bloomPass = new UnrealBloomPass(new THREE.Vector2(window.innerWidth, window.innerHeight), 0.26, 0.66, 0.92);
192
- outputPass = new OutputPass();
193
- gradePass = new ShaderPass(GradeShader);
194
- gradePass.uniforms.uResolution.value.set(window.innerWidth, window.innerHeight);
195
- composer.addPass(renderPass);
196
- composer.addPass(bloomPass);
197
- composer.addPass(outputPass);
198
- composer.addPass(gradePass);
199
- composer.setSize(window.innerWidth, window.innerHeight);
200
-
201
- buildLabels();
202
- bindUI();
203
- applyQuality(state.quality, true);
204
- setWeather(state.weather, true);
205
- onResize();
206
- window.addEventListener('resize', onResize);
207
-
208
- progress(1, '场景就绪');
209
- await nextFrame();
210
- $('#loader').classList.add('hidden');
211
- setTimeout(() => { const l = $('#loader'); if (l) l.style.display = 'none'; }, 900);
212
- state.started = true;
213
- state.loadedAt = performance.now();
214
- gpuTimer = initGpuTimer();
215
- lod.update(0, true);
216
-
217
- window.__garden = {
218
- goToPOI, applyQuality, setWeather, setLodViz, state, camera, controls, renderer,
219
- scene, sky, water, nature, lod, M, POIS, QUALITY, LOD_LEVELS,
220
- setHour: h => { state.hour = h; sky.setHour(h); water.setSky(sky.getState()); $('#time-slider').value = h; $('#time-val').textContent = fmtHour(h); },
221
- stats: buildStats,
222
- };
223
- clock.start();
224
- requestAnimationFrame(loop);
225
- const p = new URLSearchParams(location.search).get('poi');
226
- if (p && POIS.some(v => v.id === p)) goToPOI(p, true);
227
- toast('场景已就绪 · 拖拽旋转 / 滚轮缩放 / WASD 平移 / F 漫游 / 1–9 定点观察');
228
- }
229
-
230
- /* ================================================================== *
231
- * 景点标注
232
- * ================================================================== */
233
- function buildLabels() {
234
- const wrap = $('#labels');
235
- wrap.innerHTML = '';
236
- labelEls = HOTSPOTS.map(h => {
237
- const el = document.createElement('div');
238
- el.className = 'poi-label';
239
- el.innerHTML = `<span class="dot"></span><span class="txt">${h.name}</span>`;
240
- el.addEventListener('click', e => { e.stopPropagation(); showInfo(h.name, '', h.desc); });
241
- wrap.appendChild(el);
242
- return { el, data: h };
243
- });
244
- }
245
- const projV = new THREE.Vector3();
246
- function updateLabels() {
247
- const wrap = $('#labels');
248
- if (!state.labels) { wrap.style.display = 'none'; return; }
249
- wrap.style.display = 'block';
250
- const w = window.innerWidth, h = window.innerHeight;
251
- labelEls.forEach(({ el, data }) => {
252
- projV.set(...data.pos).project(camera);
253
- const d = camera.position.distanceTo(new THREE.Vector3(...data.pos));
254
- if (projV.z > 1 || projV.z < -1 || d > 180 || Math.abs(projV.x) > 1.05 || Math.abs(projV.y) > 1.05) {
255
- el.style.opacity = '0'; el.style.pointerEvents = 'none'; return;
256
- }
257
- el.style.transform = `translate(-50%, -50%) translate(${(projV.x * 0.5 + 0.5) * w}px, ${(-projV.y * 0.5 + 0.5) * h}px)`;
258
- el.style.opacity = String(clamp((180 - d) / 90, 0.15, 0.95));
259
- el.style.pointerEvents = 'auto';
260
- });
261
- }
262
-
263
- /* ================================================================== *
264
- * 定点观察视角
265
- * ================================================================== */
266
- function buildViewButtons() {
267
- const grid = $('#view-grid');
268
- grid.innerHTML = POIS.map((p, i) =>
269
- `<button class="view-btn${i === 0 ? ' active' : ''}" data-poi="${p.id}" title="${p.dir}">${p.key} · ${p.name}</button>`
270
- ).join('');
271
- }
272
- function goToPOI(id, instant) {
273
- const p = POIS.find(v => v.id === id) || POIS[0];
274
- state.poi = id;
275
- $$('.view-btn').forEach(b => b.classList.toggle('active', b.dataset.poi === id));
276
- if (state.walk) toggleWalk(false);
277
- if (instant) {
278
- camera.position.set(...p.pos);
279
- controls.target.set(...p.target);
280
- camera.fov = p.fov; camera.updateProjectionMatrix();
281
- camera.lookAt(controls.target);
282
- controls.update(); tween = null;
283
- } else {
284
- tween = {
285
- t: 0, dur: 1.45,
286
- fromPos: camera.position.clone(), toPos: new THREE.Vector3(...p.pos),
287
- fromTarget: controls.target.clone(), toTarget: new THREE.Vector3(...p.target),
288
- fromFov: camera.fov, toFov: p.fov,
289
- };
290
- }
291
- showInfo(p.name, p.dir, p.desc, true);
292
- lod && lod.update(0, true);
293
- }
294
- function updateTween(dt) {
295
- if (!tween) return;
296
- tween.t = Math.min(1, tween.t + dt / tween.dur);
297
- const k = tween.t < 0.5 ? 4 * tween.t ** 3 : 1 - Math.pow(-2 * tween.t + 2, 3) / 2;
298
- camera.position.lerpVectors(tween.fromPos, tween.toPos, k);
299
- controls.target.lerpVectors(tween.fromTarget, tween.toTarget, k);
300
- camera.fov = lerp(tween.fromFov, tween.toFov, k);
301
- camera.updateProjectionMatrix();
302
- camera.lookAt(controls.target);
303
- if (tween.t >= 1) tween = null;
304
- }
305
-
306
- /* ================================================================== *
307
- * 漫游
308
- * ================================================================== */
309
- function toggleWalk(on) {
310
- const target = on === undefined ? !state.walk : on;
311
- state.walk = target;
312
- controls.enabled = !target;
313
- $('#walk-btn').classList.toggle('active', target);
314
- $('#walk-btn').textContent = target ? '退出漫游 [F]' : '自由漫游 [F]';
315
- $('#walk-hint').classList.toggle('show', target);
316
- if (target) {
317
- const dir = new THREE.Vector3().subVectors(controls.target, camera.position).normalize();
318
- walkState.yaw = Math.atan2(dir.x, -dir.z);
319
- walkState.pitch = Math.asin(clamp(dir.y, -1, 1));
320
- walkState.locked = false;
321
- toast('第一人称漫游:点击画面锁定鼠标,WASD 移动,Shift 加速,Q/E 调整视高');
322
- } else {
323
- if (document.pointerLockElement) document.exitPointerLock();
324
- controls.target.copy(camera.position).add(new THREE.Vector3(
325
- Math.sin(walkState.yaw), Math.tan(walkState.pitch) * 0.4, -Math.cos(walkState.yaw)).multiplyScalar(12));
326
- controls.update();
327
- }
328
- }
329
- function updateWalk(dt) {
330
- if (!state.walk) return;
331
- const speed = (keys.has('ShiftLeft') || keys.has('ShiftRight')) ? 15 : 6.0;
332
- const f = (keys.has('KeyW') ? 1 : 0) - (keys.has('KeyS') ? 1 : 0);
333
- const s = (keys.has('KeyD') ? 1 : 0) - (keys.has('KeyA') ? 1 : 0);
334
- const fx = Math.sin(walkState.yaw), fz = -Math.cos(walkState.yaw);
335
- const rx = Math.cos(walkState.yaw), rz = Math.sin(walkState.yaw);
336
- const tx = fx * f + rx * s, tz = fz * f + rz * s;
337
- const l = Math.hypot(tx, tz) || 1;
338
- const mag = Math.min(1, Math.hypot(f, s));
339
- walkState.vx = lerp(walkState.vx, tx / l * speed * mag, 1 - Math.exp(-dt * 9));
340
- walkState.vz = lerp(walkState.vz, tz / l * speed * mag, 1 - Math.exp(-dt * 9));
341
- camera.position.x = clamp(camera.position.x + walkState.vx * dt, WORLD.bounds.minX, WORLD.bounds.maxX);
342
- camera.position.z = clamp(camera.position.z + walkState.vz * dt, WORLD.bounds.minZ, WORLD.bounds.maxZ);
343
- if (keys.has('KeyQ')) walkState.eye = clamp(walkState.eye - dt * 4, 0.9, 14);
344
- if (keys.has('KeyE')) walkState.eye = clamp(walkState.eye + dt * 4, 0.9, 14);
345
- // 水面区域按贴水石桥/平台处理,避免沉入池底
346
- const ground = waterSDF(camera.position.x, camera.position.z) < 0
347
- ? WORLD.waterY + 0.12 : terrainHeight(camera.position.x, camera.position.z);
348
- camera.position.y = lerp(camera.position.y, ground + walkState.eye, 1 - Math.exp(-dt * 10));
349
- const cp = Math.cos(walkState.pitch);
350
- const dir = new THREE.Vector3(Math.sin(walkState.yaw) * cp, Math.sin(walkState.pitch), -Math.cos(walkState.yaw) * cp);
351
- camera.lookAt(camera.position.clone().add(dir));
352
- }
353
- function panOrbit(dt) {
354
- if (state.walk || tween) return;
355
- const f = (keys.has('KeyW') ? 1 : 0) - (keys.has('KeyS') ? 1 : 0);
356
- const s = (keys.has('KeyD') ? 1 : 0) - (keys.has('KeyA') ? 1 : 0);
357
- if (!f && !s) return;
358
- const d = new THREE.Vector3().subVectors(controls.target, camera.position).normalize();
359
- d.y = 0; d.normalize();
360
- const right = new THREE.Vector3(-d.z, 0, d.x);
361
- const v = d.multiplyScalar(f).add(right.multiplyScalar(s)).multiplyScalar(dt * 22);
362
- camera.position.add(v); controls.target.add(v);
363
- controls.target.x = clamp(controls.target.x, WORLD.bounds.minX, WORLD.bounds.maxX);
364
- controls.target.z = clamp(controls.target.z, WORLD.bounds.minZ, WORLD.bounds.maxZ);
365
- }
366
-
367
- /* ================================================================== *
368
- * 画质 / 天气 / LOD 可视化
369
- * ================================================================== */
370
- function applyQuality(name, silent) {
371
- state.quality = name;
372
- const q = QUALITY[name];
373
- const pr = Math.min(window.devicePixelRatio || 1, q.dpr);
374
- renderer.setPixelRatio(pr);
375
- composer && composer.setPixelRatio(pr);
376
- sky.setQuality(q);
377
- nature && nature.applyQuality(q);
378
- lod && lod.setQuality(q);
379
- if (bloomPass) bloomPass.enabled = q.bloom;
380
- if (gradePass) gradePass.enabled = q.grade;
381
- $$('.q-btn').forEach(b => b.classList.toggle('active', b.dataset.quality === name));
382
- $('#quality-val').textContent = q.label;
383
- onResize();
384
- if (!silent) toast(`画质「${q.label}」· 阴影 ${q.shadow}² · 像素比 ${pr.toFixed(1)} · LOD 距离 ×${q.lodScale}`);
385
- }
386
- function setWeather(w, silent) {
387
- state.weather = w;
388
- sky.setWeather(w);
389
- water.setSky(sky.getState());
390
- nature.setWeather(w, sky.getState());
391
- $$('.w-btn').forEach(b => b.classList.toggle('active', b.dataset.weather === w));
392
- $('#weather-val').textContent = { clear: '晴', mist: '薄霭', rain: '细雨' }[w];
393
- if (!silent) toast(`天气切换为「${{ clear: '晴', mist: '薄霭', rain: '细雨' }[w]}」· 云量、雾密度与湿表面已联动`);
394
- }
395
- function setLodViz(on) {
396
- state.lodViz = on;
397
- lod.setVisualize(on);
398
- $('#lod-btn').classList.toggle('active', on);
399
- $('#lod-legend').classList.toggle('show', on);
400
- }
401
-
402
- /* ================================================================== *
403
- * UI
404
- * ================================================================== */
405
- function toast(msg) {
406
- const el = $('#toast');
407
- el.textContent = msg; el.classList.add('show');
408
- clearTimeout(toastTimer);
409
- toastTimer = setTimeout(() => el.classList.remove('show'), 3600);
410
- }
411
- function showInfo(title, dir, desc, quiet) {
412
- $('#info-title').textContent = title;
413
- $('#info-dir').textContent = dir || '';
414
- $('#info-dir').style.display = dir ? 'block' : 'none';
415
- $('#info-desc').textContent = desc || '';
416
- $('#info-card').classList.add('show');
417
- if (!quiet) $('#info-card').scrollTop = 0;
418
- }
419
- function bindUI() {
420
- buildViewButtons();
421
- $$('.view-btn').forEach(b => b.addEventListener('click', () => goToPOI(b.dataset.poi)));
422
- $$('.q-btn').forEach(b => b.addEventListener('click', () => applyQuality(b.dataset.quality)));
423
- $$('.w-btn').forEach(b => b.addEventListener('click', () => setWeather(b.dataset.weather)));
424
- $('#time-slider').addEventListener('input', e => {
425
- state.hour = parseFloat(e.target.value);
426
- sky.setHour(state.hour);
427
- water.setSky(sky.getState());
428
- $('#time-val').textContent = fmtHour(state.hour);
429
- });
430
- $('#walk-btn').addEventListener('click', () => toggleWalk());
431
- $('#lod-btn').addEventListener('click', () => setLodViz(!state.lodViz));
432
- $('#labels-toggle').addEventListener('click', () => {
433
- state.labels = !state.labels;
434
- $('#labels-toggle').classList.toggle('active', state.labels);
435
- $('#labels-toggle').textContent = state.labels ? '景点标注' : '标注已关';
436
- });
437
- $('#auto-toggle').addEventListener('click', () => {
438
- state.auto = !state.auto;
439
- $('#auto-toggle').classList.toggle('active', state.auto);
440
- });
441
- $('#info-close').addEventListener('click', () => $('#info-card').classList.remove('show'));
442
- $('#help-btn').addEventListener('click', () => $('#spec-modal').classList.add('show'));
443
- $('#spec-close').addEventListener('click', () => $('#spec-modal').classList.remove('show'));
444
- $('#spec-modal').addEventListener('click', e => { if (e.target.id === 'spec-modal') e.currentTarget.classList.remove('show'); });
445
- $('#reset-btn').addEventListener('click', () => goToPOI('overview'));
446
- $$('.fold-head').forEach(h => h.addEventListener('click', () => h.parentElement.classList.toggle('folded')));
447
-
448
- const keyMap = {};
449
- POIS.forEach(p => { keyMap[p.key] = p.id; });
450
- window.addEventListener('keydown', e => {
451
- if (e.target.tagName === 'INPUT') return;
452
- keys.add(e.code);
453
- if (e.code === 'KeyF') toggleWalk();
454
- if (e.code === 'KeyG') setLodViz(!state.lodViz);
455
- if (e.code === 'KeyL') $('#labels-toggle').click();
456
- if (e.code === 'KeyH') $('#help-btn').click();
457
- if (e.code === 'Escape') $('#spec-modal').classList.remove('show');
458
- const k = e.key;
459
- if (keyMap[k]) goToPOI(keyMap[k]);
460
- });
461
- window.addEventListener('keyup', e => keys.delete(e.code));
462
- window.addEventListener('blur', () => keys.clear());
463
- renderer.domElement.addEventListener('click', () => {
464
- if (state.walk && !walkState.locked && document.pointerLockElement !== renderer.domElement)
465
- renderer.domElement.requestPointerLock?.();
466
- });
467
- document.addEventListener('pointerlockchange', () => {
468
- walkState.locked = document.pointerLockElement === renderer.domElement;
469
- });
470
- document.addEventListener('mousemove', e => {
471
- if (!state.walk || !walkState.locked) return;
472
- walkState.yaw -= e.movementX * 0.0022;
473
- walkState.pitch = clamp(walkState.pitch - e.movementY * 0.0022, -1.35, 1.35);
474
- });
475
- }
476
- const fmtHour = h => `${String(Math.floor(h)).padStart(2, '0')}:${String(Math.round((h % 1) * 60)).padStart(2, '0')}`;
477
-
478
- /* ================================================================== *
479
- * 小地图
480
- * ================================================================== */
481
- const mini = { ctx: null };
482
- function drawMinimap() {
483
- if (!mini.ctx) mini.ctx = $('#minimap').getContext('2d');
484
- const c = mini.ctx, W = 212, H = 168;
485
- const mx = x => (x - WORLD.garden.minX - 20) / (WORLD.garden.maxX - WORLD.garden.minX + 40) * W;
486
- const mz = z => (z - WORLD.garden.minZ - 20) / (WORLD.garden.maxZ - WORLD.garden.minZ + 40) * H;
487
- c.clearRect(0, 0, W, H);
488
- c.fillStyle = '#1c2a24'; c.fillRect(0, 0, W, H);
489
- // 水系
490
- c.fillStyle = '#2e5559';
491
- const pools = [[0, -12, 62, 35], [-52, 6, 22, 20], [46, 8, 21, 16], [16, -42, 27, 14], [-28, -46, 19, 12]];
492
- pools.forEach(([x, z, rx, rz]) => {
493
- c.beginPath(); c.ellipse(mx(x), mz(z), rx / 260 * W, rz / 230 * H, 0, 0, Math.PI * 2); c.fill();
494
- });
495
- // 园墙
496
- c.strokeStyle = 'rgba(226,216,190,.72)'; c.lineWidth = 1.6;
497
- c.strokeRect(mx(-110), mz(-95), mx(110) - mx(-110), mz(95) - mz(-95));
498
- // 中轴
499
- c.strokeStyle = 'rgba(217,185,121,.55)'; c.lineWidth = 1;
500
- c.setLineDash([4, 3]);
501
- c.beginPath(); c.moveTo(mx(0), mz(95)); c.lineTo(mx(0), mz(22)); c.stroke();
502
- c.setLineDash([]);
503
- // 三岛
504
- c.fillStyle = '#6c7a4c';
505
- [[-8, -12, 11, 8], [-34, -24, 7, 5], [28, -18, 7, 5]].forEach(([x, z, rx, rz]) => {
506
- c.beginPath(); c.ellipse(mx(x), mz(z), rx / 260 * W, rz / 230 * H, 0, 0, Math.PI * 2); c.fill();
507
- });
508
- // 主要建筑
509
- const bl = [
510
- [0, 92, 14, 4, '宫门'], [0, 80, 20, 8, '轿厅'], [0, 58, 28, 12, '澄观堂'],
511
- [0, 30, 24, 10, '远香堂'], [-30, 18, 11, 6, '涵碧榭'], [20, -60, 18, 10, '见山楼'],
512
- [-8, -12, 7, 7, '雪香云蔚'], [44, 6, 7, 7, '荷风四面'], [-82, 34, 6, 6, '竹里馆'],
513
- [68, -54, 6, 6, '丛桂'], [-64, -40, 20, 18, '云根叠翠'], [38, -34, 18, 5, '不系舟'],
514
- ];
515
- c.font = '8px system-ui, sans-serif'; c.textAlign = 'center';
516
- bl.forEach(([x, z, w, d, n]) => {
517
- const px = mx(x - w / 2), py = mz(z - d / 2);
518
- const pw = w / 260 * W, ph = d / 230 * H;
519
- c.fillStyle = 'rgba(214,196,156,.80)'; c.fillRect(px, py, pw, ph);
520
- c.fillStyle = '#f0e6cc'; c.fillText(n, px + pw / 2, py + ph / 2 + 3);
521
- });
522
- // 借景塔方向
523
- c.strokeStyle = 'rgba(135,169,154,.5)'; c.setLineDash([3, 3]);
524
- c.beginPath(); c.moveTo(mx(44), mz(6)); c.lineTo(mx(-96), mz(-90)); c.stroke();
525
- c.setLineDash([]);
526
- c.fillStyle = '#87a99a'; c.fillText('借景 · 北寺塔', mx(-70), mz(-84));
527
- // 相机
528
- const dir = new THREE.Vector3().subVectors(controls.target, camera.position);
529
- const a = Math.atan2(dir.x, -dir.z);
530
- const cx = mx(camera.position.x), cy = mz(camera.position.z);
531
- c.save(); c.translate(cx, cy); c.rotate(a);
532
- c.fillStyle = '#ffcf7a'; c.beginPath(); c.moveTo(0, -8); c.lineTo(5, 6); c.lineTo(-5, 6); c.closePath(); c.fill();
533
- c.restore();
534
- c.strokeStyle = 'rgba(255,207,122,.45)'; c.beginPath(); c.arc(cx, cy, 10, 0, Math.PI * 2); c.stroke();
535
- c.fillStyle = '#9aa894'; c.textAlign = 'left'; c.font = '9px system-ui';
536
- c.fillText('N ↑', 6, 13); c.fillText('220m × 190m · 4.18ha', 6, H - 7);
537
- }
538
-
539
- /* ================================================================== *
540
- * 性能 HUD 与自适应降级
541
- * ================================================================== */
542
- function initGpuTimer() {
543
- const gl = renderer.getContext();
544
- const ext = gl.getExtension('EXT_disjoint_timer_query_webgl2');
545
- if (!ext) return null;
546
- return { gl, ext, query: null, lastMs: 0 };
547
- }
548
- function gpuBegin() {
549
- if (!gpuTimer || gpuTimer.query) return;
550
- const q = gpuTimer.gl.createQuery();
551
- gpuTimer.gl.beginQuery(gpuTimer.ext.TIME_ELAPSED_EXT, q);
552
- gpuTimer.query = q;
553
- }
554
- function gpuEnd() { if (gpuTimer && gpuTimer.query) gpuTimer.gl.endQuery(gpuTimer.ext.TIME_ELAPSED_EXT); }
555
- function gpuPoll() {
556
- if (!gpuTimer || !gpuTimer.query) return;
557
- const { gl, ext, query } = gpuTimer;
558
- if (!gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE)) return;
559
- if (!gl.getParameter(ext.GPU_DISJOINT_EXT)) gpuTimer.lastMs = gl.getQueryParameter(query, gl.QUERY_RESULT) / 1e6;
560
- gl.deleteQuery(query); gpuTimer.query = null;
561
- }
562
- let hudT = 0;
563
- function updateHUD(dt) {
564
- state.frames++; state.acc += dt; hudT += dt;
565
- if (hudT < 0.35) return;
566
- const fps = state.frames / state.acc;
567
- state.fps = lerp(state.fps, fps, 0.5);
568
- state.frames = 0; state.acc = 0; hudT = 0;
569
- const frameMs = Math.max(1000 / Math.max(fps, 1), gpuTimer?.lastMs || 0);
570
- const adaptFps = 1000 / Math.max(frameMs, 1);
571
- $('#fps').textContent = Math.round(state.fps);
572
- $('#fps').className = state.fps > 50 ? 'good' : state.fps > 32 ? 'mid' : 'bad';
573
- $('#ms').textContent = frameMs.toFixed(1);
574
- $('#calls').textContent = renderer.info.render.calls;
575
- $('#tris').textContent = (renderer.info.render.triangles / 1000).toFixed(0) + 'k';
576
- $('#lodinfo').textContent = lod.summary();
577
- $('#campos').textContent = `${camera.position.x.toFixed(0)}, ${camera.position.y.toFixed(0)}, ${camera.position.z.toFixed(0)}`;
578
-
579
- state.cooldown = Math.max(0, state.cooldown - 0.35);
580
- if (!state.auto || state.cooldown > 0) return;
581
- if (adaptFps < 38) { state.lowFor += 0.35; state.highFor = 0; }
582
- else if (adaptFps > 56) { state.highFor += 0.35; state.lowFor = 0; }
583
- else { state.lowFor *= 0.7; state.highFor *= 0.7; }
584
- if (state.lowFor > 2.1) {
585
- if (state.quality === 'high') applyQuality('medium');
586
- else if (state.quality === 'medium') applyQuality('low');
587
- state.lowFor = 0; state.cooldown = 6;
588
- toast('检测到帧率偏低,已自动降低细节密度以保证漫游流畅');
589
- } else if (state.highFor > 12 && state.quality === 'low') {
590
- applyQuality('medium'); state.highFor = 0; state.cooldown = 10;
591
- }
592
- }
593
-
594
- /* ================================================================== *
595
- * 主循环
596
- * ================================================================== */
597
- function loop() {
598
- requestAnimationFrame(loop);
599
- const rawDt = clock.getDelta();
600
- const dt = Math.min(rawDt, 0.1);
601
- const realDt = Math.min(rawDt, 0.5);
602
- const t = clock.elapsedTime;
603
- renderer.info.reset();
604
-
605
- if (tween) updateTween(realDt);
606
- else if (!state.walk) { panOrbit(dt); controls.update(); }
607
- updateWalk(dt);
608
-
609
- sky.update(t, camera);
610
- water.setTime(t);
611
- water.setCamera(camera);
612
- water.setSky(sky.getState());
613
- nature.update(t, camera);
614
- if (gradePass) gradePass.uniforms.uTime.value = t;
615
- lod.update(dt);
616
-
617
- labelT += realDt; if (labelT > 1 / 15) { labelT = 0; updateLabels(); }
618
- mapT += realDt; if (mapT > 1 / 5) { mapT = 0; drawMinimap(); }
619
-
620
- gpuBegin();
621
- composer.render();
622
- gpuEnd();
623
- gpuPoll();
624
- updateHUD(dt); // 在渲染之后读取 renderer.info,保证 draw call / 三角形为真实统计
625
- }
626
-
627
- function onResize() {
628
- if (!renderer || !camera) return;
629
- const w = window.innerWidth, h = window.innerHeight;
630
- camera.aspect = w / h;
631
- camera.updateProjectionMatrix();
632
- renderer.setSize(w, h);
633
- composer && composer.setSize(w, h);
634
- gradePass && gradePass.uniforms.uResolution.value.set(w, h);
635
- renderer.shadowMap.needsUpdate = true;
636
- }
637
-
638
- boot().catch(err => {
639
- console.error('[场景启动失败]', err);
640
- const l = $('#load-label');
641
- if (l) l.textContent = '场景启动失败:' + (err && err.message ? err.message : err);
642
- });