agentscape3d-engine 0.0.0-stage → 1.0.0-beta.3

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 (457) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -2
  3. package/cli.mjs +53 -0
  4. package/dist/ArticulationVerifier-BfGxXY8V.js +337 -0
  5. package/dist/ArticulationVerifier-BfGxXY8V.js.map +1 -0
  6. package/dist/AssetCompiler-BLj09iu1.js +2424 -0
  7. package/dist/AssetCompiler-BLj09iu1.js.map +1 -0
  8. package/dist/AssetModule-DME-XaFS.js +2637 -0
  9. package/dist/AssetModule-DME-XaFS.js.map +1 -0
  10. package/dist/AssetRecipe-g8dZBhgJ.js +298 -0
  11. package/dist/AssetRecipe-g8dZBhgJ.js.map +1 -0
  12. package/dist/BrowserCodeWorker.js +53856 -0
  13. package/dist/BrowserCodeWorker.js.map +1 -0
  14. package/dist/CarryCapability-CXwHU5ay.js +104 -0
  15. package/dist/CarryCapability-CXwHU5ay.js.map +1 -0
  16. package/dist/KinematicHypothesisScreen-C3TKiuYR.js +241 -0
  17. package/dist/KinematicHypothesisScreen-C3TKiuYR.js.map +1 -0
  18. package/dist/ObjectTransform-BlQUNK7c.js +61 -0
  19. package/dist/ObjectTransform-BlQUNK7c.js.map +1 -0
  20. package/dist/RapierPhysicsBackend-B2wQe_Vl.js +3259 -0
  21. package/dist/RapierPhysicsBackend-B2wQe_Vl.js.map +1 -0
  22. package/dist/RenderingSystem-WIr1ZuGu.js +1042 -0
  23. package/dist/RenderingSystem-WIr1ZuGu.js.map +1 -0
  24. package/dist/ScenePresentation-LsYiDxbm.js +152 -0
  25. package/dist/ScenePresentation-LsYiDxbm.js.map +1 -0
  26. package/dist/SceneProject-K7HH1s8o.js +2687 -0
  27. package/dist/SceneProject-K7HH1s8o.js.map +1 -0
  28. package/dist/SceneSerializer-zOzbX4jZ.js +932 -0
  29. package/dist/SceneSerializer-zOzbX4jZ.js.map +1 -0
  30. package/dist/SimulationProfile-DSYZbBLQ.js +165 -0
  31. package/dist/SimulationProfile-DSYZbBLQ.js.map +1 -0
  32. package/dist/StylePack-DcRa_kU0.js +88 -0
  33. package/dist/StylePack-DcRa_kU0.js.map +1 -0
  34. package/dist/WorldArchive-BiFGLt--.js +451 -0
  35. package/dist/WorldArchive-BiFGLt--.js.map +1 -0
  36. package/dist/WorldCommands-Debj7V4L.js +2207 -0
  37. package/dist/WorldCommands-Debj7V4L.js.map +1 -0
  38. package/dist/WorldIO-Ch8QBfKY.js +151 -0
  39. package/dist/WorldIO-Ch8QBfKY.js.map +1 -0
  40. package/dist/admission-CVEvsrdz.js +121 -0
  41. package/dist/admission-CVEvsrdz.js.map +1 -0
  42. package/dist/blankWorld-B0MW6g7q.js +75 -0
  43. package/dist/blankWorld-B0MW6g7q.js.map +1 -0
  44. package/dist/core.d.ts +68 -0
  45. package/dist/core.js +209 -0
  46. package/dist/core.js.map +1 -0
  47. package/dist/disposeObject3D-DIMzy0FA.js +128 -0
  48. package/dist/disposeObject3D-DIMzy0FA.js.map +1 -0
  49. package/dist/environments-HOe3sJXH.js +567 -0
  50. package/dist/environments-HOe3sJXH.js.map +1 -0
  51. package/dist/gltfIO-BzVKLyaL.js +339 -0
  52. package/dist/gltfIO-BzVKLyaL.js.map +1 -0
  53. package/dist/grandUrbanBlock-DRndRZjF.js +515 -0
  54. package/dist/grandUrbanBlock-DRndRZjF.js.map +1 -0
  55. package/dist/index.d.ts +345 -0
  56. package/dist/index.js +16952 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/magicCabin-CfBZjx2Q.js +11019 -0
  59. package/dist/magicCabin-CfBZjx2Q.js.map +1 -0
  60. package/dist/manifests-D0LwbJ36.js +866 -0
  61. package/dist/manifests-D0LwbJ36.js.map +1 -0
  62. package/dist/mcp.d.ts +2 -0
  63. package/dist/mcp.js +1 -0
  64. package/dist/monumentHall-awZiGtda.js +403 -0
  65. package/dist/monumentHall-awZiGtda.js.map +1 -0
  66. package/dist/node.d.ts +16 -0
  67. package/dist/node.js +26 -0
  68. package/dist/parts-DrEcfJRl.js +37 -0
  69. package/dist/parts-DrEcfJRl.js.map +1 -0
  70. package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
  71. package/dist/ruinedCourtyard-DuF7NmUU.js +696 -0
  72. package/dist/ruinedCourtyard-DuF7NmUU.js.map +1 -0
  73. package/dist/runtime/application/AgentTools.js +28 -0
  74. package/dist/runtime/application/README.md +14 -0
  75. package/dist/runtime/application/agent/ProgressiveAgentTools.js +92 -0
  76. package/dist/runtime/application/agent/StudioMcpAllowlist.js +10 -0
  77. package/dist/runtime/application/agent/StudioProjectTools.js +18 -0
  78. package/dist/runtime/application/agent/TaskEvidence.js +199 -0
  79. package/dist/runtime/application/buildTaskObservation.js +117 -0
  80. package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +50 -0
  81. package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +35 -0
  82. package/dist/runtime/application/code-execution/BrowserCodeWorker.js +17 -0
  83. package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +82 -0
  84. package/dist/runtime/application/createSession.js +66 -0
  85. package/dist/runtime/application/createWorldAuthoringContext.js +400 -0
  86. package/dist/runtime/application/generation/GenerationOrchestrator.js +630 -0
  87. package/dist/runtime/application/generation/GenerationRuntime.js +215 -0
  88. package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +289 -0
  89. package/dist/runtime/application/native-scene/CodeProject.js +215 -0
  90. package/dist/runtime/application/native-scene/CodeProjectModules.js +143 -0
  91. package/dist/runtime/application/native-scene/ExampleWorldCatalog.js +35 -0
  92. package/dist/runtime/application/native-scene/NativeArticulation.js +53 -0
  93. package/dist/runtime/application/native-scene/NativeEditableRegistry.js +150 -0
  94. package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +85 -0
  95. package/dist/runtime/application/native-scene/NativeLightingInspection.js +33 -0
  96. package/dist/runtime/application/native-scene/NativeMaterialInspection.js +52 -0
  97. package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +127 -0
  98. package/dist/runtime/application/native-scene/NativePhysicsGeometry.js +64 -0
  99. package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +51 -0
  100. package/dist/runtime/application/native-scene/NativeSceneHost.js +406 -0
  101. package/dist/runtime/application/native-scene/NativeSceneInspection.js +203 -0
  102. package/dist/runtime/application/native-scene/NativeSceneOverlay.js +116 -0
  103. package/dist/runtime/application/native-scene/NativeSceneQuery.js +123 -0
  104. package/dist/runtime/application/native-scene/NativeSceneReview.js +132 -0
  105. package/dist/runtime/application/native-scene/NativeThreeModule.js +16 -0
  106. package/dist/runtime/application/native-scene/SceneObserver.js +97 -0
  107. package/dist/runtime/application/native-scene/VisualCapturePolicy.js +4 -0
  108. package/dist/runtime/application/object-forge/SceneObjectForge.js +263 -0
  109. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +59 -0
  110. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +22 -0
  111. package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +40 -0
  112. package/dist/runtime/application/scene/CapabilityResolver.js +90 -0
  113. package/dist/runtime/application/scene/NativeEditableContracts.js +18 -0
  114. package/dist/runtime/application/scene/RequestWindow.js +54 -0
  115. package/dist/runtime/application/scene/SceneAgentTools.js +21 -0
  116. package/dist/runtime/application/scene/SceneContracts.js +49 -0
  117. package/dist/runtime/application/scene/SceneEditService.js +154 -0
  118. package/dist/runtime/application/scene/SceneFacade.js +356 -0
  119. package/dist/runtime/application/scene/SceneInteractionAdapters.js +41 -0
  120. package/dist/runtime/application/scene/SceneJobController.js +320 -0
  121. package/dist/runtime/application/scene/SceneLifecycle.js +57 -0
  122. package/dist/runtime/application/scene/ScenePackage.js +173 -0
  123. package/dist/runtime/application/scene/ScenePersistence.js +50 -0
  124. package/dist/runtime/application/scene/SceneProject.js +95 -0
  125. package/dist/runtime/application/scene/SceneSkillNames.js +5 -0
  126. package/dist/runtime/application/scene/StarterScene.js +56 -0
  127. package/dist/runtime/application/scene/WorldArchive.js +89 -0
  128. package/dist/runtime/application/scene/WorldDirectory.js +20 -0
  129. package/dist/runtime/application/scene/WorldDocument.js +76 -0
  130. package/dist/runtime/application/scene/WorldIO.js +103 -0
  131. package/dist/runtime/application/scene/WorldStorage.js +155 -0
  132. package/dist/runtime/application/skills/SkillRegistry.js +193 -0
  133. package/dist/runtime/application/skills/packs/acceptanceSkills.js +32 -0
  134. package/dist/runtime/application/skills/packs/affordanceSkills.js +36 -0
  135. package/dist/runtime/application/skills/packs/assetSkills.js +46 -0
  136. package/dist/runtime/application/skills/packs/authoringSkills.js +16 -0
  137. package/dist/runtime/application/skills/packs/batchSkills.js +22 -0
  138. package/dist/runtime/application/skills/packs/codeSkills.js +106 -0
  139. package/dist/runtime/application/skills/packs/generationSkills.js +45 -0
  140. package/dist/runtime/application/skills/packs/interactionSkills.js +46 -0
  141. package/dist/runtime/application/skills/packs/recoverySkills.js +80 -0
  142. package/dist/runtime/application/skills/packs/sceneSkills.js +24 -0
  143. package/dist/runtime/application/skills/packs/spatialSkills.js +35 -0
  144. package/dist/runtime/application/skills/packs/verificationSkills.js +14 -0
  145. package/dist/runtime/application/skills/packs/worldSkills.js +45 -0
  146. package/dist/runtime/application/skills/registerCoreSkills.js +31 -0
  147. package/dist/runtime/application/skills/skillPrimitives.js +4 -0
  148. package/dist/runtime/application/tasks/CabinetCupTask.js +76 -0
  149. package/dist/runtime/application/tasks.jsonl +67 -0
  150. package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +42 -0
  151. package/dist/runtime/application/world-authoring/AuthoringDiff.js +149 -0
  152. package/dist/runtime/application/world-authoring/AuthoringDocument.js +825 -0
  153. package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +109 -0
  154. package/dist/runtime/application/world-authoring/AuthoringIdentity.js +17 -0
  155. package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +29 -0
  156. package/dist/runtime/application/world-authoring/AuthoringPatch.js +118 -0
  157. package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +334 -0
  158. package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +126 -0
  159. package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +144 -0
  160. package/dist/runtime/application/world-authoring/HeadlessImageExport.js +92 -0
  161. package/dist/runtime/application/world-authoring/ModelRef.js +62 -0
  162. package/dist/runtime/application/world-authoring/SceneGLBExport.js +88 -0
  163. package/dist/runtime/apps/mcp-server/AUTHORING.md +71 -0
  164. package/dist/runtime/apps/mcp-server/AgentMcpCompat.js +68 -0
  165. package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +1 -0
  166. package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +30 -0
  167. package/dist/runtime/apps/mcp-server/BuildEnvironment.js +17 -0
  168. package/dist/runtime/apps/mcp-server/CodeExecutor.js +71 -0
  169. package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +42 -0
  170. package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +66 -0
  171. package/dist/runtime/apps/mcp-server/FileAssetRepository.js +159 -0
  172. package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +8 -0
  173. package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +47 -0
  174. package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +157 -0
  175. package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +6 -0
  176. package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +116 -0
  177. package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +60 -0
  178. package/dist/runtime/apps/mcp-server/README.md +269 -0
  179. package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +1 -0
  180. package/dist/runtime/apps/mcp-server/SandboxBundle.js +13 -0
  181. package/dist/runtime/apps/mcp-server/SessionManager.js +148 -0
  182. package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +75 -0
  183. package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +246 -0
  184. package/dist/runtime/apps/mcp-server/StudioProjectToolContracts.js +58 -0
  185. package/dist/runtime/apps/mcp-server/TransferHttp.js +47 -0
  186. package/dist/runtime/apps/mcp-server/TransferLimits.js +6 -0
  187. package/dist/runtime/apps/mcp-server/TransferStore.js +134 -0
  188. package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +16 -0
  189. package/dist/runtime/apps/mcp-server/VALIDATION.md +45 -0
  190. package/dist/runtime/apps/mcp-server/acceptance-evidence.json +332 -0
  191. package/dist/runtime/apps/mcp-server/errorDiagnostics.js +32 -0
  192. package/dist/runtime/apps/mcp-server/examples/code-house.js +24 -0
  193. package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +85 -0
  194. package/dist/runtime/apps/mcp-server/main.mjs +82 -0
  195. package/dist/runtime/apps/mcp-server/registerTools.js +274 -0
  196. package/dist/runtime/apps/mcp-server/sandbox/run.mjs +23 -0
  197. package/dist/runtime/apps/mcp-server/security.js +23 -0
  198. package/dist/runtime/apps/mcp-server/tasks.jsonl +9 -0
  199. package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +157 -0
  200. package/dist/runtime/apps/server/README.md +7 -0
  201. package/dist/runtime/apps/server/WorldRepository.js +338 -0
  202. package/dist/runtime/apps/server/WorldRepositoryHttp.js +96 -0
  203. package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +278 -0
  204. package/dist/runtime/apps/server/tasks.jsonl +10 -0
  205. package/dist/runtime/apps/shared/node/WorldDiskStorage.js +62 -0
  206. package/dist/runtime/foundation/EventBus.js +26 -0
  207. package/dist/runtime/foundation/JsonGateway.js +47 -0
  208. package/dist/runtime/foundation/PngRgba.js +99 -0
  209. package/dist/runtime/foundation/PolicyEngine.js +21 -0
  210. package/dist/runtime/foundation/README.md +7 -0
  211. package/dist/runtime/foundation/TraceRecorder.js +76 -0
  212. package/dist/runtime/foundation/errors.js +8 -0
  213. package/dist/runtime/foundation/simulation/SimulationProfile.js +143 -0
  214. package/dist/runtime/foundation/version.js +2 -0
  215. package/dist/runtime/modules/agent/README.md +11 -0
  216. package/dist/runtime/modules/agent/ToolCallingAgent.js +19 -0
  217. package/dist/runtime/modules/agent/bootstrapWorld.js +10 -0
  218. package/dist/runtime/modules/agent/buildRecoveryProposals.js +533 -0
  219. package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +128 -0
  220. package/dist/runtime/modules/agent/execution/AgentRunResults.js +55 -0
  221. package/dist/runtime/modules/agent/execution/AgentRunSession.js +393 -0
  222. package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +40 -0
  223. package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +19 -0
  224. package/dist/runtime/modules/agent/prompt/index.js +52 -0
  225. package/dist/runtime/modules/agent/tasks.jsonl +94 -0
  226. package/dist/runtime/modules/artifact/ArtifactContentGate.js +144 -0
  227. package/dist/runtime/modules/artifact/ArtifactDescriptor.js +280 -0
  228. package/dist/runtime/modules/artifact/ArtifactImporter.js +185 -0
  229. package/dist/runtime/modules/artifact/ArtifactModule.js +111 -0
  230. package/dist/runtime/modules/artifact/ArtifactRegistry.js +197 -0
  231. package/dist/runtime/modules/artifact/IncrementalSha256.js +129 -0
  232. package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +115 -0
  233. package/dist/runtime/modules/artifact/README.md +7 -0
  234. package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +67 -0
  235. package/dist/runtime/modules/artifact/tasks.jsonl +31 -0
  236. package/dist/runtime/modules/asset/AssetModule.js +416 -0
  237. package/dist/runtime/modules/asset/README.md +67 -0
  238. package/dist/runtime/modules/asset/loading/AssetLoader.js +157 -0
  239. package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +61 -0
  240. package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +95 -0
  241. package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +33 -0
  242. package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +103 -0
  243. package/dist/runtime/modules/asset/model/AssetInputContracts.js +139 -0
  244. package/dist/runtime/modules/asset/model/AssetRef.js +12 -0
  245. package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +172 -0
  246. package/dist/runtime/modules/asset/model/ProceduralTextureContract.js +24 -0
  247. package/dist/runtime/modules/asset/model/admission.js +117 -0
  248. package/dist/runtime/modules/asset/model/errors.js +6 -0
  249. package/dist/runtime/modules/asset/model/parts.js +27 -0
  250. package/dist/runtime/modules/asset/model/resourceBudget.js +10 -0
  251. package/dist/runtime/modules/asset/model/schema.js +150 -0
  252. package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +78 -0
  253. package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +84 -0
  254. package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +86 -0
  255. package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +81 -0
  256. package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +272 -0
  257. package/dist/runtime/modules/asset/production/AssetRecipe.js +91 -0
  258. package/dist/runtime/modules/asset/production/ProceduralTexture.js +85 -0
  259. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +45 -0
  260. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +590 -0
  261. package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +173 -0
  262. package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +124 -0
  263. package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +56 -0
  264. package/dist/runtime/modules/asset/production/compiler/gltfIO.js +6 -0
  265. package/dist/runtime/modules/asset/production/compiler/partGeometry.js +74 -0
  266. package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +63 -0
  267. package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +48 -0
  268. package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +16 -0
  269. package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +30 -0
  270. package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +75 -0
  271. package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +20 -0
  272. package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +34 -0
  273. package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +32 -0
  274. package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +116 -0
  275. package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +84 -0
  276. package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +63 -0
  277. package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +16 -0
  278. package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +23 -0
  279. package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +50 -0
  280. package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +60 -0
  281. package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +93 -0
  282. package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +32 -0
  283. package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +55 -0
  284. package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +203 -0
  285. package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +43 -0
  286. package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +33 -0
  287. package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +60 -0
  288. package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +23 -0
  289. package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +198 -0
  290. package/dist/runtime/modules/asset/registry/AssetCatalog.js +72 -0
  291. package/dist/runtime/modules/asset/registry/AssetRegistry.js +51 -0
  292. package/dist/runtime/modules/asset/registry/manifests/index.js +173 -0
  293. package/dist/runtime/modules/asset/tasks.jsonl +87 -0
  294. package/dist/runtime/modules/generation/README.md +9 -0
  295. package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +45 -0
  296. package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +169 -0
  297. package/dist/runtime/modules/generation/connector/ConnectorClient.js +192 -0
  298. package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +167 -0
  299. package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +179 -0
  300. package/dist/runtime/modules/generation/connector/ConnectorSession.js +202 -0
  301. package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +239 -0
  302. package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +99 -0
  303. package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +91 -0
  304. package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +50 -0
  305. package/dist/runtime/modules/generation/providers/ProviderRegistry.js +304 -0
  306. package/dist/runtime/modules/generation/tasks.jsonl +35 -0
  307. package/dist/runtime/modules/navigation/NavigationBackend.js +17 -0
  308. package/dist/runtime/modules/navigation/RecastNavigationBackend.js +263 -0
  309. package/dist/runtime/modules/physics/JoltPhysicsBackend.js +850 -0
  310. package/dist/runtime/modules/physics/PhysicsApiSurface.js +660 -0
  311. package/dist/runtime/modules/physics/PhysicsBackend.js +88 -0
  312. package/dist/runtime/modules/physics/RapierPhysicsBackend.js +414 -0
  313. package/dist/runtime/modules/rendering/README.md +7 -0
  314. package/dist/runtime/modules/rendering/RendererProbe.js +153 -0
  315. package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +140 -0
  316. package/dist/runtime/modules/rendering/captureStill.js +54 -0
  317. package/dist/runtime/modules/rendering/createRenderer.js +76 -0
  318. package/dist/runtime/modules/rendering/disposeObject3D.js +37 -0
  319. package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +74 -0
  320. package/dist/runtime/modules/rendering/spatial/ThreeBvhRuntime.js +107 -0
  321. package/dist/runtime/modules/rendering/style/StylePack.js +34 -0
  322. package/dist/runtime/modules/rendering/style/StyleSystem.js +173 -0
  323. package/dist/runtime/modules/rendering/tasks.jsonl +7 -0
  324. package/dist/runtime/modules/world/README.md +13 -0
  325. package/dist/runtime/modules/world/build/WorldBuilder.js +170 -0
  326. package/dist/runtime/modules/world/compiler/PipelineEngine.js +32 -0
  327. package/dist/runtime/modules/world/compiler/WorldAdmission.js +43 -0
  328. package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +68 -0
  329. package/dist/runtime/modules/world/compiler/WorldCompilation.js +157 -0
  330. package/dist/runtime/modules/world/compiler/WorldComposer.js +201 -0
  331. package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +76 -0
  332. package/dist/runtime/modules/world/compiler/WorldRecompiler.js +356 -0
  333. package/dist/runtime/modules/world/compiler/WorldRetry.js +75 -0
  334. package/dist/runtime/modules/world/compiler/createWorldPipeline.js +379 -0
  335. package/dist/runtime/modules/world/content/blankWorld.js +35 -0
  336. package/dist/runtime/modules/world/content/environments.js +84 -0
  337. package/dist/runtime/modules/world/content/grandUrbanBlock.js +189 -0
  338. package/dist/runtime/modules/world/content/magic-cabin/README.md +28 -0
  339. package/dist/runtime/modules/world/content/magic-cabin/affordances.js +64 -0
  340. package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +7078 -0
  341. package/dist/runtime/modules/world/content/magic-cabin/lighting.js +26 -0
  342. package/dist/runtime/modules/world/content/magic-cabin/materials.js +20 -0
  343. package/dist/runtime/modules/world/content/magicCabin.js +190 -0
  344. package/dist/runtime/modules/world/content/monumentHall.js +154 -0
  345. package/dist/runtime/modules/world/content/ruinedCourtyard.js +196 -0
  346. package/dist/runtime/modules/world/content/suzhouGarden/README.md +141 -0
  347. package/dist/runtime/modules/world/content/suzhouGarden/index.js +137 -0
  348. package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +491 -0
  349. package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +670 -0
  350. package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +578 -0
  351. package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +127 -0
  352. package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +642 -0
  353. package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +650 -0
  354. package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +280 -0
  355. package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +242 -0
  356. package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +215 -0
  357. package/dist/runtime/modules/world/content/woodlandWorkshop.js +192 -0
  358. package/dist/runtime/modules/world/content/yuanmingyuan/README.md +36 -0
  359. package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +351 -0
  360. package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +490 -0
  361. package/dist/runtime/modules/world/content/yuanmingyuan/core.js +505 -0
  362. package/dist/runtime/modules/world/content/yuanmingyuan/index.js +101 -0
  363. package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +435 -0
  364. package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +169 -0
  365. package/dist/runtime/modules/world/content/yuanmingyuan/water.js +245 -0
  366. package/dist/runtime/modules/world/errors.js +9 -0
  367. package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +50 -0
  368. package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +297 -0
  369. package/dist/runtime/modules/world/runtime/CommandHistory.js +111 -0
  370. package/dist/runtime/modules/world/runtime/EntityCapabilityRegistry.js +165 -0
  371. package/dist/runtime/modules/world/runtime/NativeNavigationGeometry.js +84 -0
  372. package/dist/runtime/modules/world/runtime/NativePhysicsSnapshot.js +245 -0
  373. package/dist/runtime/modules/world/runtime/ObjectStore.js +31 -0
  374. package/dist/runtime/modules/world/runtime/ObjectTransform.js +62 -0
  375. package/dist/runtime/modules/world/runtime/ObservedEntity.js +37 -0
  376. package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +240 -0
  377. package/dist/runtime/modules/world/runtime/SceneExtensions.js +36 -0
  378. package/dist/runtime/modules/world/runtime/ScenePresentation.js +101 -0
  379. package/dist/runtime/modules/world/runtime/SceneSerializer.js +281 -0
  380. package/dist/runtime/modules/world/runtime/WorldAuthority.js +41 -0
  381. package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +14 -0
  382. package/dist/runtime/modules/world/runtime/WorldCommands.js +503 -0
  383. package/dist/runtime/modules/world/runtime/WorldObservation.js +71 -0
  384. package/dist/runtime/modules/world/runtime/WorldQueries.js +340 -0
  385. package/dist/runtime/modules/world/runtime/WorldRecovery.js +78 -0
  386. package/dist/runtime/modules/world/runtime/WorldRuntime.js +806 -0
  387. package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +110 -0
  388. package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +130 -0
  389. package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +79 -0
  390. package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +195 -0
  391. package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +70 -0
  392. package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +115 -0
  393. package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +390 -0
  394. package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +214 -0
  395. package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +65 -0
  396. package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +244 -0
  397. package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +147 -0
  398. package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +57 -0
  399. package/dist/runtime/modules/world/runtime/interaction/ManipulationActions.js +7 -0
  400. package/dist/runtime/modules/world/runtime/interaction/NativePhysicalTarget.js +31 -0
  401. package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +123 -0
  402. package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +134 -0
  403. package/dist/runtime/modules/world/runtime/semantic/NativePhysicsState.js +89 -0
  404. package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +129 -0
  405. package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +89 -0
  406. package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +104 -0
  407. package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +269 -0
  408. package/dist/runtime/modules/world/runtime/simulation/WorldTimeline.js +110 -0
  409. package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +56 -0
  410. package/dist/runtime/modules/world/runtime/spatial/VisualMeshBounds.js +41 -0
  411. package/dist/runtime/modules/world/runtime/systems/AudioSystem.js +306 -0
  412. package/dist/runtime/modules/world/runtime/systems/Instrument.js +39 -0
  413. package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +806 -0
  414. package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +281 -0
  415. package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +561 -0
  416. package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +1752 -0
  417. package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +527 -0
  418. package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +402 -0
  419. package/dist/runtime/modules/world/spec/WorldIR.js +165 -0
  420. package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +86 -0
  421. package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +51 -0
  422. package/dist/runtime/modules/world/spec/WorldRevision.js +231 -0
  423. package/dist/runtime/modules/world/spec/WorldSpec.js +86 -0
  424. package/dist/runtime/modules/world/tasks.jsonl +530 -0
  425. package/dist/runtime/modules/world/verification/ArticulationVerifier.js +254 -0
  426. package/dist/runtime/modules/world/verification/Finding.js +105 -0
  427. package/dist/runtime/modules/world/verification/InteractionEvidence.js +73 -0
  428. package/dist/runtime/modules/world/verification/RepairEngine.js +49 -0
  429. package/dist/runtime/modules/world/verification/VisualLayoutAcceptance.js +58 -0
  430. package/dist/runtime/modules/world/verification/WorldAcceptance.js +176 -0
  431. package/dist/runtime/modules/world/verification/WorldValidator.js +67 -0
  432. package/dist/runtime/package-lock.json +16071 -0
  433. package/dist/runtime/package.json +106 -0
  434. package/dist/runtime/public/assets/cabinet.glb +0 -0
  435. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
  436. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
  437. package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
  438. package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
  439. package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
  440. package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
  441. package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
  442. package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
  443. package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
  444. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
  445. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
  446. package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
  447. package/dist/schema-DT7K9NjP.js +165 -0
  448. package/dist/schema-DT7K9NjP.js.map +1 -0
  449. package/dist/suzhouGarden-Y3hny8j6.js +6150 -0
  450. package/dist/suzhouGarden-Y3hny8j6.js.map +1 -0
  451. package/dist/version-CHc-i8ch.js +5 -0
  452. package/dist/version-CHc-i8ch.js.map +1 -0
  453. package/dist/woodlandWorkshop-DsScU-cx.js +483 -0
  454. package/dist/woodlandWorkshop-DsScU-cx.js.map +1 -0
  455. package/dist/yuanmingyuan-DsFnPzzR.js +4955 -0
  456. package/dist/yuanmingyuan-DsFnPzzR.js.map +1 -0
  457. package/package.json +75 -4
@@ -0,0 +1,670 @@
1
+ /* 吴苑澄观 · 建筑与景区组装
2
+ * 前朝 190 m 礼序中轴 + 后苑「一池三山」九个园中园景区;
3
+ * 含厅、堂、楼、阁、亭(四角/六角/扇面)、榭、舫、廊(水廊/曲廊/爬山廊)、
4
+ * 桥(九曲/拱桥/廊桥)、门楼、云墙、漏窗、月洞门与园外借景北寺塔。
5
+ */
6
+ import * as THREE from 'three';
7
+ import {
8
+ boxGeo, transform, tube, lathe, extrudePolygon, clamp, mulberry32, rr,
9
+ WORLD, waterSDF, terrainHeight,
10
+ } from './core.js';
11
+ import {
12
+ put, roofGeo, addHipRoof, addPyramidRoof, addColumn, addDougong, addGeWindow,
13
+ addGualuo, addRailing, addWall, addLeakWindowCore, addMoonGate, addBrickGate,
14
+ addPavingPatch, addLantern, makePlaque, addStoneLantern,
15
+ } from './arch.js';
16
+
17
+ const P = (ctx, geo, mat, pos, rot = [0, 0, 0], lod = 0, opts = {}) => put(ctx.B, geo, mat, pos, rot, lod, opts);
18
+
19
+ function plaque(ctx, text, pos, rotY = 0, w = 2.8, h = 0.72, maxLevel = 1) {
20
+ const m = makePlaque(text, w, h);
21
+ m.position.set(pos[0], pos[1], pos[2]);
22
+ m.rotation.y = rotY;
23
+ ctx.scene.add(m);
24
+ ctx.plaques.push(m);
25
+ if (ctx.lod) ctx.lod.addDetail(m, pos, 0.5, maxLevel);
26
+ }
27
+
28
+ /* ------------------------------------------------------------------ *
29
+ * 建筑原型
30
+ * ------------------------------------------------------------------ */
31
+ /** 厅堂:台基 + 柱列 + 粉墙 + 格扇 + 斗拱挂落 + 歇山/卷棚顶 + 月台 */
32
+ function hall(ctx, o) {
33
+ const { B, M } = ctx;
34
+ const x = o.x, z = o.z, w = o.w, d = o.d;
35
+ const base = o.base ?? 0.86, colH = o.colH ?? 5.6, eaveY = base + colH;
36
+ const rot = o.rot ?? 0, face = o.face ?? -1; // face=-1 正面朝北(-Z)
37
+ const bays = o.bays ?? 5;
38
+ const cs = Math.cos(rot), sn = Math.sin(rot);
39
+ const G = (g, m, px, py, pz, L = 0, r2 = [0, 0, 0], op = {}) =>
40
+ P(ctx, g, m, [x + px * cs + pz * sn, py, z - px * sn + pz * cs], [r2[0], rot + r2[1], r2[2]], L, op);
41
+
42
+ // 台基与踏跺
43
+ G(boxGeo(w + 1.6, base, d + 1.6, 0.4), M.stone, 0, base / 2, 0);
44
+ G(boxGeo(w + 1.9, 0.12, d + 1.9, 0.4), M.stoneDark, 0, base - 0.04, 0);
45
+ G(boxGeo(w + 2.2, 0.10, d + 2.2, 0.4), M.graybrick, 0, 0.05, 0);
46
+ const steps = 4;
47
+ for (let s = 0; s < steps; s++) {
48
+ G(boxGeo(o.stairW ?? 5.2, 0.16, 0.52), M.stone,
49
+ 0, base - (s + 0.5) * base / steps, -face * (d / 2 + 0.85 + s * 0.5));
50
+ }
51
+ // 柱列(前后檐 + 山面)
52
+ const xs = [], zs = [-d / 2, d / 2];
53
+ for (let i = 0; i <= bays; i++) xs.push(-w / 2 + i * w / bays);
54
+ const colAt = (px, pz, r = 0.17) => {
55
+ G(new THREE.CylinderGeometry(r * 0.92, r, colH, 10), M.wood, px, base + colH / 2, pz);
56
+ G(new THREE.CylinderGeometry(r * 1.42, r * 1.55, 0.12, 10), M.stone, px, base + 0.06, pz);
57
+ G(new THREE.CylinderGeometry(r * 1.18, r * 1.05, 0.10, 10), M.darkWood, px, eaveY - 0.05, pz, 1);
58
+ };
59
+ for (const px of xs) for (const pz of zs) colAt(px, pz);
60
+ for (const pz of [-d / 4, d / 4]) for (const px of [-w / 2, w / 2]) colAt(px, pz, 0.15);
61
+ // 檐枋(四周)
62
+ G(boxGeo(w + 0.5, 0.28, 0.24), M.wood, 0, eaveY - 0.22, -d / 2);
63
+ G(boxGeo(w + 0.5, 0.28, 0.24), M.wood, 0, eaveY - 0.22, d / 2);
64
+ G(boxGeo(0.24, 0.28, d + 0.4), M.wood, -w / 2, eaveY - 0.22, 0);
65
+ G(boxGeo(0.24, 0.28, d + 0.4), M.wood, w / 2, eaveY - 0.22, 0);
66
+ // 斗拱(L0 细节)
67
+ if (o.dougong !== false) {
68
+ for (const px of xs) for (const pz of zs) {
69
+ const wx = x + px * cs + pz * sn, wz = z - px * sn + pz * cs;
70
+ addDougong(B, M, wx, eaveY - 0.16, wz, 1, 1);
71
+ }
72
+ }
73
+ // 墙体:两山墙 + 背立面
74
+ G(boxGeo(0.30, colH - 0.3, d - 0.5), M.plaster, -w / 2, base + (colH - 0.3) / 2, 0);
75
+ G(boxGeo(0.30, colH - 0.3, d - 0.5), M.plaster, w / 2, base + (colH - 0.3) / 2, 0);
76
+ G(boxGeo(w - 0.4, colH - 0.3, 0.30), M.plaster, 0, base + (colH - 0.3) / 2, -face * d / 2);
77
+ // 背立面方窗
78
+ for (let i = 1; i < bays; i += 2) {
79
+ const px = -w / 2 + i * w / bays;
80
+ G(boxGeo(1.5, 1.6, 0.12), M.darkWood, px, base + colH * 0.55, -face * d / 2 - 0.02, 2);
81
+ G(boxGeo(1.35, 1.45, 0.06), M.paper, px, base + colH * 0.55, -face * d / 2 - 0.09, 2);
82
+ }
83
+ // 正面整排格扇长窗
84
+ if (o.windows !== false) {
85
+ for (let i = 0; i < bays; i++) {
86
+ const px = -w / 2 + (i + 0.5) * w / bays;
87
+ const wx = x + px * cs + (face * d / 2) * sn;
88
+ const wz = z - px * sn + (face * d / 2) * cs;
89
+ addGeWindow(B, M, {
90
+ x: wx, y: base + colH * 0.50, z: wz,
91
+ w: w / bays - 0.22, h: colH - 0.55, rot,
92
+ pattern: i % 3 === 0 ? 'binglie' : 'jin',
93
+ });
94
+ }
95
+ // 挂落
96
+ for (let i = 0; i < bays; i++) {
97
+ const px = -w / 2 + (i + 0.5) * w / bays;
98
+ const wx = x + px * cs + (face * d / 2) * sn;
99
+ const wz = z - px * sn + (face * d / 2) * cs;
100
+ addGualuo(B, M, wx, eaveY - 0.52, wz, w / bays - 0.2, rot, 1);
101
+ }
102
+ }
103
+ // 屋顶
104
+ addHipRoof(B, M, {
105
+ cx: x, cz: z, w: w + 1.8, d: d + 1.8, eaveY, rise: o.rise ?? 3.2,
106
+ lift: o.lift ?? 0.70, type: o.type ?? 'xieshan', rot,
107
+ tileMat: o.tileMat || M.tile, nx: o.nx ?? 44, nz: o.nz ?? 28,
108
+ });
109
+ // 匾额与灯笼
110
+ if (o.name) {
111
+ const pz = face * (d / 2 + 0.36);
112
+ plaque(ctx, o.name, [x + pz * sn, eaveY - 0.72, z + pz * cs],
113
+ rot + (face === -1 ? Math.PI : 0), o.plaqueW ?? 2.8, 0.72);
114
+ }
115
+ for (const s of [-1, 1]) {
116
+ const px = s * (w / 2 - 0.8), pz = face * (d / 2 + 0.25);
117
+ addLantern(B, M, x + px * cs + pz * sn, eaveY - 0.72, z - px * sn + pz * cs, 0.9, 1);
118
+ }
119
+ // 月台 / 临水平台
120
+ if (o.terrace) {
121
+ const tz = face * (d / 2 + o.terrace.d / 2 + 0.2);
122
+ G(boxGeo(w + 2.4, 0.24, o.terrace.d, 0.4), M.stone, 0, base - 0.02, tz);
123
+ G(boxGeo(w + 2.4, 0.10, o.terrace.d + 0.2, 0.4), M.paving, 0, base + 0.14, tz, 1);
124
+ const wx1 = x + (-w / 2) * cs + (face * (d / 2 + o.terrace.d)) * sn;
125
+ const wz1 = z - (-w / 2) * sn + (face * (d / 2 + o.terrace.d)) * cs;
126
+ const wx2 = x + (w / 2) * cs + (face * (d / 2 + o.terrace.d)) * sn;
127
+ const wz2 = z - (w / 2) * sn + (face * (d / 2 + o.terrace.d)) * cs;
128
+ addRailing(B, M, { x1: wx1, z1: wz1, x2: wx2, z2: wz2, y: base + 0.14, kind: o.terrace.rail || 'stone' });
129
+ }
130
+ return { x, z, w, d, eaveY, rot, face };
131
+ }
132
+ /** 两层楼阁(见山楼):一层厅 + 二层四周外廊 + 歇山顶 */
133
+ function twoStorey(ctx, o) {
134
+ const { B, M } = ctx;
135
+ const { x, z } = o, rot = o.rot ?? 0, face = o.face ?? -1;
136
+ const w1 = o.w, d1 = o.d, base = 0.9, h1 = o.h1 ?? 5.4, e1 = base + h1;
137
+ const w2 = w1 - 3.2, d2 = d1 - 2.4, h2 = o.h2 ?? 4.2, e2 = e1 + h2;
138
+ const cs = Math.cos(rot), sn = Math.sin(rot);
139
+ const G = (g, m, px, py, pz, L = 0, r2 = [0, 0, 0]) =>
140
+ P(ctx, g, m, [x + px * cs + pz * sn, py, z - px * sn + pz * cs], [r2[0], rot + r2[1], r2[2]], L);
141
+ // 一层
142
+ G(boxGeo(w1 + 1.8, base, d1 + 1.8), M.stone, 0, base / 2, 0);
143
+ G(boxGeo(w1, h1, d1), M.plaster, 0, base + h1 / 2, 0);
144
+ G(boxGeo(w1 + 0.6, 0.30, d1 + 0.6), M.wood, 0, e1 - 0.18, 0);
145
+ for (let i = 0; i <= 5; i++) {
146
+ const px = -w1 / 2 + i * w1 / 5;
147
+ for (const pz of [-d1 / 2, d1 / 2]) addColumn(B, M, x + px * cs + pz * sn, base, z - px * sn + pz * cs, h1, 0.17, M.wood, 0);
148
+ }
149
+ // 一层腰檐(四面披檐)
150
+ G(roofGeo(w1 / 2 + 1.15, d1 / 2 + 1.15, 0, 1.35, { lift: 0.42, eave: 0.5, nx: 40, nz: 26 }), M.tile, 0, e1 - 0.15, 0);
151
+ // 二层
152
+ G(boxGeo(w2, h2, d2), M.plaster, 0, e1 + h2 / 2, 0);
153
+ G(boxGeo(w2 + 0.5, 0.28, d2 + 0.5), M.wood, 0, e2 - 0.18, 0);
154
+ for (let i = 0; i <= 4; i++) {
155
+ const px = -w2 / 2 + i * w2 / 4;
156
+ for (const pz of [-d2 / 2, d2 / 2]) addColumn(B, M, x + px * cs + pz * sn, e1, z - px * sn + pz * cs, h2, 0.15, M.wood, 0);
157
+ addGeWindow(B, M, {
158
+ x: x + px * cs + (-d2 / 2) * sn, y: e1 + h2 * 0.52, z: z - px * sn + (-d2 / 2) * cs,
159
+ w: w2 / 4 - 0.24, h: h2 - 0.6, rot, pattern: 'jin',
160
+ });
161
+ }
162
+ // 二层外廊与栏杆(制高点俯瞰站位点)
163
+ G(boxGeo(w1 + 1.4, 0.18, d1 + 1.4), M.woodPale, 0, e1 + 0.06, 0);
164
+ const railY = e1 + 0.16;
165
+ for (const [a, b, c, e] of [
166
+ [-w1 / 2 - 0.6, -d1 / 2 - 0.6, w1 / 2 + 0.6, -d1 / 2 - 0.6],
167
+ [-w1 / 2 - 0.6, d1 / 2 + 0.6, w1 / 2 + 0.6, d1 / 2 + 0.6],
168
+ [-w1 / 2 - 0.6, -d1 / 2 - 0.6, -w1 / 2 - 0.6, d1 / 2 + 0.6],
169
+ [w1 / 2 + 0.6, -d1 / 2 - 0.6, w1 / 2 + 0.6, d1 / 2 + 0.6],
170
+ ]) {
171
+ addRailing(B, M, {
172
+ x1: x + a * cs + b * sn, z1: z - a * sn + b * cs,
173
+ x2: x + c * cs + e * sn, z2: z - c * sn + e * cs, y: railY, kind: 'mei',
174
+ });
175
+ }
176
+ // 屋顶
177
+ addHipRoof(B, M, { cx: x, cz: z, w: w2 + 2.2, d: d2 + 2.2, eaveY: e2, rise: o.rise ?? 3.0, lift: 0.66, type: 'xieshan', rot });
178
+ plaque(ctx, o.name || '见山楼',
179
+ [x + (face * (d2 / 2 + 0.4)) * sn, e2 - 0.74, z + (face * (d2 / 2 + 0.4)) * cs],
180
+ rot + (face === -1 ? Math.PI : 0), 3.0, 0.78);
181
+ for (const s of [-1, 1]) {
182
+ const px = s * (w2 / 2 - 0.5), pz = face * (d2 / 2 + 0.2);
183
+ addLantern(B, M, x + px * cs + pz * sn, e2 - 0.7, z - px * sn + pz * cs, 0.85, 1);
184
+ }
185
+ return { e1, e2 };
186
+ }
187
+
188
+ /** 亭:四角 / 六角 / 八角攒尖,可带坐凳与美人靠 */
189
+ function pavilion(ctx, o) {
190
+ const { B, M } = ctx;
191
+ const { x, z } = o, sides = o.sides ?? 4, r = o.r ?? 3.2;
192
+ const base = o.base ?? 0.45, colH = o.colH ?? 3.4, eaveY = base + colH;
193
+ const rot = o.rot ?? 0;
194
+ // 台基
195
+ P(ctx, new THREE.CylinderGeometry(r + 0.45, r + 0.55, base, sides === 4 ? 8 : sides), M.stone, [x, base / 2, z], [0, rot, 0]);
196
+ P(ctx, new THREE.CylinderGeometry(r + 0.30, r + 0.36, 0.10, sides === 4 ? 8 : sides), M.stoneDark, [x, base + 0.02, z], [0, rot, 0]);
197
+ // 柱
198
+ for (let i = 0; i < sides; i++) {
199
+ const a = rot + Math.PI / sides + i * Math.PI * 2 / sides;
200
+ addColumn(B, M, x + Math.cos(a) * r * 0.86, base, z + Math.sin(a) * r * 0.86, colH, 0.14, o.woodMat || M.wood, 0);
201
+ }
202
+ // 檐枋 + 斗拱 + 挂落
203
+ for (let i = 0; i < sides; i++) {
204
+ const a0 = rot + Math.PI / sides + i * Math.PI * 2 / sides;
205
+ const a1 = rot + Math.PI / sides + (i + 1) * Math.PI * 2 / sides;
206
+ const p0 = [x + Math.cos(a0) * r * 0.86, z + Math.sin(a0) * r * 0.86];
207
+ const p1 = [x + Math.cos(a1) * r * 0.86, z + Math.sin(a1) * r * 0.86];
208
+ const mx = (p0[0] + p1[0]) / 2, mz = (p0[1] + p1[1]) / 2;
209
+ const len = Math.hypot(p1[0] - p0[0], p1[1] - p0[1]);
210
+ const ang = -Math.atan2(p1[1] - p0[1], p1[0] - p0[0]);
211
+ P(ctx, boxGeo(len, 0.24, 0.20), M.wood, [mx, eaveY - 0.20, mz], [0, ang, 0]);
212
+ addGualuo(B, M, mx, eaveY - 0.48, mz, len - 0.25, ang, 1);
213
+ if (o.rail !== false && i < sides) {
214
+ addRailing(B, M, {
215
+ x1: p0[0], z1: p0[1], x2: p1[0], z2: p1[1], y: base + 0.06,
216
+ kind: 'mei', segments: 3,
217
+ });
218
+ }
219
+ addDougong(B, M, p0[0], eaveY - 0.12, p0[1], 0.78, 1);
220
+ }
221
+ addPyramidRoof(B, M, { cx: x, cy: eaveY, cz: z, r: r + 0.9, rise: o.rise ?? r * 0.82, lift: o.lift ?? 0.55, sides, rot, rings: 8, steps: 8 });
222
+ if (o.name) {
223
+ const off = r * 0.88;
224
+ plaque(ctx, o.name, [x + Math.sin(rot) * off, eaveY - 0.62, z + Math.cos(rot) * off], rot, 1.9, 0.52);
225
+ }
226
+ return { eaveY };
227
+ }
228
+
229
+ /** 水榭:临水低台基 + 卷棚歇山 + 美人靠 */
230
+ function watersideXie(ctx, o) {
231
+ const h = hall(ctx, {
232
+ x: o.x, z: o.z, w: o.w ?? 12, d: o.d ?? 6.4, base: 0.42, colH: 3.7,
233
+ rise: 1.85, lift: 0.42, bays: 3, rot: o.rot ?? 0, face: o.face ?? -1,
234
+ name: o.name, type: 'xieshan', dougong: false, windows: true,
235
+ terrace: { d: 2.6, rail: 'mei' }, nx: 32, nz: 20,
236
+ });
237
+ return h;
238
+ }
239
+
240
+ /** 石舫「不系舟」:船身石台 + 前舱 / 中舱 / 后舱楼 + 卷棚顶 */
241
+ function stoneBoat(ctx, o) {
242
+ const { B, M } = ctx;
243
+ const x = o.x, z = o.z, rot = o.rot ?? 0;
244
+ const cs = Math.cos(rot), sn = Math.sin(rot);
245
+ const G = (g, m, px, py, pz, L = 0, r2 = [0, 0, 0]) =>
246
+ P(ctx, g, m, [x + px * cs + pz * sn, py, z - px * sn + pz * cs], [r2[0], rot + r2[1], r2[2]], L);
247
+ // 船身:前窄后宽的花岗岩船体
248
+ const hull = extrudePolygon([
249
+ [-9.0, -1.5], [-7.4, -2.35], [5.6, -2.35], [8.8, -1.15],
250
+ [9.4, 0], [8.8, 1.15], [5.6, 2.35], [-7.4, 2.35], [-9.0, 1.5],
251
+ ], 0.72);
252
+ G(hull, M.stone, 0, -0.28, 0, 0, [-Math.PI / 2, 0, 0]);
253
+ G(boxGeo(16.5, 0.18, 4.6), M.woodPale, 0, 0.52, 0);
254
+ // 船首石雕与缆桩
255
+ for (const s of [-1, 1]) {
256
+ G(new THREE.CylinderGeometry(0.16, 0.20, 0.85, 8), M.stoneDark, 7.2, 0.85, s * 1.55, 1);
257
+ G(new THREE.SphereGeometry(0.20, 8, 6), M.stoneDark, 7.2, 1.30, s * 1.55, 1);
258
+ }
259
+ // 中舱(低)
260
+ G(boxGeo(7.6, 2.6, 3.8), M.plaster, -0.6, 1.9, 0);
261
+ for (let i = 0; i < 4; i++) {
262
+ G(boxGeo(1.45, 1.7, 0.08), M.darkWood, -3.5 + i * 1.9, 2.0, 1.92, 2);
263
+ G(boxGeo(1.32, 1.55, 0.05), M.paper, -3.5 + i * 1.9, 2.0, 1.97, 2);
264
+ }
265
+ G(roofGeo(4.7, 2.5, 0, 1.25, { lift: 0.34, eave: 0.5, nx: 32, nz: 20 }), M.tile, -0.6, 3.25, 0, 0, [0, 0, 0]);
266
+ // 后舱楼(高)
267
+ G(boxGeo(5.2, 3.3, 3.9), M.plaster, 5.0, 2.25, 0);
268
+ G(roofGeo(3.3, 2.5, 0, 1.55, { lift: 0.40, eave: 0.5, nx: 28, nz: 18 }), M.tile, 5.0, 3.92, 0);
269
+ for (let i = 0; i < 3; i++) {
270
+ G(boxGeo(1.25, 1.9, 0.08), M.darkWood, 3.6 + i * 1.45, 2.35, 1.98, 2);
271
+ G(boxGeo(1.12, 1.75, 0.05), M.paper, 3.6 + i * 1.45, 2.35, 2.03, 2);
272
+ }
273
+ // 舷侧美人靠
274
+ for (const s of [-1, 1]) {
275
+ addRailing(B, M, {
276
+ x1: x + (-6.5) * cs + (s * 2.1) * sn, z1: z - (-6.5) * sn + (s * 2.1) * cs,
277
+ x2: x + (2.6) * cs + (s * 2.1) * sn, z2: z - (2.6) * sn + (s * 2.1) * cs,
278
+ y: 0.62, kind: 'mei',
279
+ });
280
+ }
281
+ plaque(ctx, o.name || '不系舟', [x + 0 * cs + 2.02 * sn, 2.9, z + 2.02 * cs], rot, 1.9, 0.55);
282
+ }
283
+
284
+ /** 廊:沿折线生成柱列、铺地、卷棚屋面、挂落与美人靠 */
285
+ function corridor(ctx, points, o = {}) {
286
+ const { B, M } = ctx;
287
+ const width = o.width ?? 2.5, colH = o.colH ?? 2.9, rise = o.rise ?? 0.85;
288
+ for (let s = 0; s < points.length - 1; s++) {
289
+ const [x1, z1] = points[s], [x2, z2] = points[s + 1];
290
+ const dx = x2 - x1, dz = z2 - z1, len = Math.hypot(dx, dz);
291
+ if (len < 0.5) continue;
292
+ const a = Math.atan2(dz, dx), rot = -a;
293
+ const mx = (x1 + x2) / 2, mz = (z1 + z2) / 2;
294
+ const y0 = o.y0 ?? 0.18;
295
+ P(ctx, boxGeo(len + 0.2, 0.14, width + 0.3, 0.45), M.paving, [mx, y0, mz], [0, rot, 0], 0, { noShadow: true });
296
+ P(ctx, boxGeo(len + 0.2, 0.22, width + 0.5), M.graybrick, [mx, y0 - 0.12, mz], [0, rot, 0]);
297
+ // 柱
298
+ const n = Math.max(2, Math.round(len / 2.8));
299
+ for (let i = 0; i <= n; i++) {
300
+ const t = i / n;
301
+ const px = x1 + dx * t, pz = z1 + dz * t;
302
+ for (const side of [-1, 1]) {
303
+ const wx = px - Math.sin(a) * side * width / 2, wz = pz + Math.cos(a) * side * width / 2;
304
+ P(ctx, new THREE.CylinderGeometry(0.11, 0.12, colH, 8), M.wood, [wx, y0 + colH / 2, wz]);
305
+ P(ctx, new THREE.CylinderGeometry(0.19, 0.21, 0.10, 8), M.stone, [wx, y0 + 0.05, wz]);
306
+ }
307
+ }
308
+ P(ctx, boxGeo(len, 0.20, 0.16), M.wood, [mx, y0 + colH - 0.14, mz - Math.cos(a) * width / 2], [0, rot, 0]);
309
+ P(ctx, boxGeo(len, 0.20, 0.16), M.wood, [mx, y0 + colH - 0.14, mz + Math.cos(a) * width / 2], [0, rot, 0]);
310
+ // 美人靠(单侧或双侧)
311
+ const sideList = o.bothRails === false ? [1] : [-1, 1];
312
+ for (const side of sideList) {
313
+ addRailing(B, M, {
314
+ x1: x1 - Math.sin(a) * side * width / 2, z1: z1 + Math.cos(a) * side * width / 2,
315
+ x2: x2 - Math.sin(a) * side * width / 2, z2: z2 + Math.cos(a) * side * width / 2,
316
+ y: y0, kind: 'mei',
317
+ });
318
+ }
319
+ // 挂落
320
+ for (const side of [-1, 1]) {
321
+ const wx = mx - Math.sin(a) * side * width / 2, wz = mz + Math.cos(a) * side * width / 2;
322
+ addGualuo(B, M, wx, y0 + colH - 0.48, wz, len - 0.2, rot, 1);
323
+ }
324
+ // 卷棚小屋顶
325
+ addHipRoof(B, M, {
326
+ cx: mx, cz: mz, w: len + 0.7, d: width + 0.8, eaveY: y0 + colH,
327
+ rise, lift: 0.22, eave: 0.45, type: 'juanpeng', rot,
328
+ nx: Math.max(12, Math.round(len * 1.4)), nz: 12,
329
+ });
330
+ }
331
+ }
332
+
333
+ /** 九折石桥 */
334
+ function zigzagBridge(ctx, points, o = {}) {
335
+ const { B, M } = ctx;
336
+ const y = o.y ?? 0.38, width = o.width ?? 1.9;
337
+ for (let s = 0; s < points.length - 1; s++) {
338
+ const [x1, z1] = points[s], [x2, z2] = points[s + 1];
339
+ const dx = x2 - x1, dz = z2 - z1, len = Math.hypot(dx, dz);
340
+ const a = Math.atan2(dz, dx), rot = -a;
341
+ const mx = (x1 + x2) / 2, mz = (z1 + z2) / 2;
342
+ P(ctx, boxGeo(len + 0.25, 0.20, width), M.stone, [mx, y, mz], [0, rot, 0]);
343
+ P(ctx, boxGeo(len + 0.25, 0.06, width - 0.16), M.stoneDark, [mx, y + 0.13, mz], [0, rot, 0], 1);
344
+ for (const side of [-1, 1]) {
345
+ addRailing(B, M, {
346
+ x1: x1 - Math.sin(a) * side * width / 2, z1: z1 + Math.cos(a) * side * width / 2,
347
+ x2: x2 - Math.sin(a) * side * width / 2, z2: z2 + Math.cos(a) * side * width / 2,
348
+ y: y + 0.10, kind: 'stone', segments: Math.max(2, Math.round(len / 1.6)),
349
+ });
350
+ }
351
+ // 桥墩
352
+ for (const t of [0.15, 0.85]) {
353
+ P(ctx, new THREE.CylinderGeometry(0.26, 0.32, y + 0.9, 8), M.stoneDark,
354
+ [x1 + dx * t, (y - 0.9) / 2, z1 + dz * t]);
355
+ }
356
+ }
357
+ }
358
+
359
+ /** 拱桥(半圆券 + 弧面桥身) */
360
+ function archBridge(ctx, o) {
361
+ const { B, M } = ctx;
362
+ const { x, z, len = 12, w = 2.8, rot = 0, rise = 2.0 } = o;
363
+ const cs = Math.cos(rot), sn = Math.sin(rot);
364
+ const G = (g, m, px, py, pz, L = 0, r2 = [0, 0, 0]) =>
365
+ P(ctx, g, m, [x + px * cs + pz * sn, py, z - px * sn + pz * cs], [r2[0], rot + r2[1], r2[2]], L);
366
+ // 桥券(半圆拱石)
367
+ const N = 16;
368
+ for (let i = 0; i < N; i++) {
369
+ const a0 = Math.PI * i / N, a1 = Math.PI * (i + 1) / N;
370
+ const px = ((a0 + a1) / 2 - Math.PI / 2) / (Math.PI / 2) * (len / 2);
371
+ const py = Math.sin((a0 + a1) / 2) * rise * 0.62;
372
+ G(boxGeo(len / N + 0.12, 0.34, w + 0.3), M.stoneDark, px, py - 0.3, 0, 0, [0, 0, -(a0 + a1) / 2 + Math.PI / 2]);
373
+ }
374
+ // 弧面桥面
375
+ const M2 = 14;
376
+ for (let i = 0; i < M2; i++) {
377
+ const t0 = i / M2, t1 = (i + 1) / M2;
378
+ const p0 = (t0 - 0.5) * len, p1 = (t1 - 0.5) * len;
379
+ const y0 = 0.42 + (1 - Math.pow((t0 - 0.5) * 2, 2)) * rise * 0.55;
380
+ const y1 = 0.42 + (1 - Math.pow((t1 - 0.5) * 2, 2)) * rise * 0.55;
381
+ const seg = boxGeo(Math.hypot(p1 - p0, y1 - y0), 0.20, w);
382
+ G(seg, M.stone, (p0 + p1) / 2, (y0 + y1) / 2, 0, 0, [0, 0, Math.atan2(y1 - y0, p1 - p0)]);
383
+ }
384
+ // 栏杆沿弧线
385
+ for (const side of [-1, 1]) {
386
+ const pts = [];
387
+ for (let i = 0; i <= 8; i++) {
388
+ const t = i / 8;
389
+ pts.push([x + ((t - 0.5) * len) * cs + (side * w / 2) * sn,
390
+ 0.55 + (1 - Math.pow((t - 0.5) * 2, 2)) * rise * 0.55,
391
+ z - ((t - 0.5) * len) * sn + (side * w / 2) * cs]);
392
+ }
393
+ P(ctx, tube(pts, 0.075, 20, 6), M.marble, [0, 0, 0], [0, 0, 0], 1);
394
+ for (let i = 0; i <= 6; i++) {
395
+ const t = i / 6;
396
+ G(boxGeo(0.10, 0.72, 0.10), M.marble, (t - 0.5) * len, 0.9 + (1 - Math.pow((t - 0.5) * 2, 2)) * rise * 0.55, side * w / 2, 1);
397
+ }
398
+ }
399
+ }
400
+
401
+ /* ------------------------------------------------------------------ *
402
+ * 园外借景:北寺塔(八角九层,76 m)与远村(LOD 三档)
403
+ * ------------------------------------------------------------------ */
404
+ function buildPagoda(ctx) {
405
+ const { M } = ctx;
406
+ const [tx, tz] = WORLD.borrowPagoda;
407
+ const levels = [new THREE.Group(), new THREE.Group(), new THREE.Group()];
408
+ levels.forEach((g, i) => { g.name = 'borrowPagoda_L' + i; ctx.scene.add(g); });
409
+
410
+ const B0 = [], B1 = [];
411
+ const add = (arr, geo, mat, pos, rot = [0, 0, 0]) =>
412
+ arr.push({ geo, mat, matrix: transform([tx + pos[0], pos[1], tz + pos[2]], rot) });
413
+ const R0 = 7.2, floors = 9, floorH = 7.1;
414
+ // 台基
415
+ for (const arr of [B0, B1]) {
416
+ add(arr, new THREE.CylinderGeometry(R0 + 1.6, R0 + 2.0, 1.2, 8), M.stone, [0, 0.6, 0]);
417
+ add(arr, new THREE.CylinderGeometry(R0 + 1.0, R0 + 1.4, 0.7, 8), M.graybrick, [0, 1.55, 0]);
418
+ }
419
+ for (let f = 0; f < floors; f++) {
420
+ const y = 2.0 + f * floorH;
421
+ const r = R0 - f * 0.50;
422
+ const h = 4.9;
423
+ for (const arr of [B0, B1]) {
424
+ add(arr, new THREE.CylinderGeometry(r, r * 1.03, h, 8), M.plasterWarm, [0, y + h / 2, 0], [0, Math.PI / 8, 0]);
425
+ add(arr, new THREE.CylinderGeometry(r + 0.28, r + 0.28, 0.36, 8), M.wood, [0, y + h - 0.1, 0], [0, Math.PI / 8, 0]);
426
+ // 平座与腰檐
427
+ add(arr, new THREE.CylinderGeometry(r + 1.05, r + 0.8, 0.32, 8), M.graybrick, [0, y + h + 0.12, 0], [0, Math.PI / 8, 0]);
428
+ const roof = require_pyramid(r + 1.5, 1.5, 8);
429
+ add(arr, roof, M.tile, [0, y + h + 0.28, 0]);
430
+ }
431
+ // L0 细节:门窗、平座栏杆、角铃、瓦当
432
+ for (let k = 0; k < 8; k++) {
433
+ const a = Math.PI / 8 + k * Math.PI / 4;
434
+ add(B0, boxGeo(1.05, 2.5, 0.14), M.darkWood, [Math.cos(a) * (r + 0.03), y + 2.7, Math.sin(a) * (r + 0.03)], [0, -a + Math.PI / 2, 0]);
435
+ add(B0, boxGeo(0.9, 2.3, 0.08), M.paper, [Math.cos(a) * (r + 0.12), y + 2.7, Math.sin(a) * (r + 0.12)], [0, -a + Math.PI / 2, 0]);
436
+ add(B0, boxGeo(0.10, 0.95, 0.10), M.marble, [Math.cos(a) * (r + 0.9), y + h + 0.62, Math.sin(a) * (r + 0.9)]);
437
+ add(B0, new THREE.SphereGeometry(0.11, 6, 5), M.gold, [Math.cos(a) * (r + 1.42), y + h + 0.38, Math.sin(a) * (r + 1.42)]);
438
+ }
439
+ add(B0, boxGeo((r + 1.0) * 1.7, 0.09, 0.10), M.marble, [0, y + h + 0.82, 0]);
440
+ }
441
+ // 塔刹
442
+ const topY = 2.0 + floors * floorH;
443
+ for (const arr of [B0, B1]) {
444
+ add(arr, new THREE.CylinderGeometry(1.5, 2.4, 1.1, 8), M.graybrick, [0, topY + 0.5, 0]);
445
+ add(arr, lathe([[0.55, 0], [0.85, 1.0], [0.55, 2.0], [0.95, 3.0], [0.4, 4.0], [0.22, 5.4], [0.05, 6.2]], 12), M.gold, [0, topY + 1.1, 0]);
446
+ }
447
+ // L3 剪影
448
+ const B2 = [];
449
+ add(B2, new THREE.CylinderGeometry(4.6, 7.0, topY, 8), M.plasterWarm, [0, topY / 2, 0]);
450
+ for (let f = 0; f < floors; f++) {
451
+ const r = R0 + 1.4 - f * 0.52;
452
+ add(B2, new THREE.ConeGeometry(r, 1.9, 8), M.tile, [0, 2.0 + f * floorH + 5.5, 0], [0, Math.PI / 8, 0]);
453
+ }
454
+ add(B2, lathe([[0.5, 0], [0.8, 1.0], [0.3, 3.0], [0.05, 6.0]], 10), M.gold, [0, topY + 1.0, 0]);
455
+
456
+ [B0, B1, B2].forEach((arr, i) => {
457
+ const batch = new (ctx.BatchClass)(64);
458
+ arr.forEach(e => batch.add(e.geo, e.mat, e.matrix, { noZone: true }));
459
+ const st = batch.build(levels[i]);
460
+ levels[i].userData.stats = st;
461
+ });
462
+ // 塔是核心借景:距离按 0.16 权重折算,使园内 300–420 m 视距仍落在 L2(九层中模)
463
+ if (ctx.lod) ctx.lod.addLevels(levels, [tx, 30, tz], 10, { distanceScale: 0.16 });
464
+ return { levels, height: topY + 7.2 };
465
+ }
466
+ /* 轻量攒尖几何(避免重复 import 造成循环) */
467
+ function require_pyramid(r, rise, sides) {
468
+ return new THREE.CylinderGeometry(0.15, r, rise, sides, 1, false);
469
+ }
470
+
471
+ /** 园外村落剪影(借景层,LOD L2/L3) */
472
+ function buildVillage(ctx) {
473
+ const { M } = ctx;
474
+ const houses = [
475
+ [-170, -210, 12, 7], [-148, -224, 9, 6], [-196, -232, 14, 8],
476
+ [-120, -196, 10, 6], [-215, -258, 11, 7], [-88, -188, 8, 5],
477
+ [128, -206, 12, 6], [152, -224, 9, 6],
478
+ ];
479
+ const B = new (ctx.BatchClass)(80);
480
+ houses.forEach(([hx, hz, w, d], i) => {
481
+ const y = terrainHeight(hx, hz);
482
+ B.add(boxGeo(w, 4.2, d, 0.35), M.plasterWarm, transform([hx, y + 2.1, hz]));
483
+ const rg = roofGeo(w / 2 + 0.5, d / 2 + 0.5, 0, 1.5, { lift: 0.25, eave: 0.4, nx: 14, nz: 10 });
484
+ B.add(rg, M.tile, transform([hx, y + 4.2, hz]));
485
+ B.add(boxGeo(1.1, 2.0, 0.10), M.darkWood, transform([hx, y + 1.0, hz + d / 2 + 0.02]), { lod: 2 });
486
+ });
487
+ const g = new THREE.Group(); g.name = 'borrowVillage'; ctx.scene.add(g);
488
+ B.build(g);
489
+ if (ctx.lod) ctx.lod.addDetail(g, [-160, 4, -220], 45, 3);
490
+ }
491
+
492
+ /* ------------------------------------------------------------------ *
493
+ * 景区总装
494
+ * ------------------------------------------------------------------ */
495
+ export function buildBuildings(ctx) {
496
+ const { B, M } = ctx;
497
+ const prog = ctx.onProgress || (() => {});
498
+
499
+ /* —— 景区 1:澄观门庭(前朝礼序中轴,Z 95 → 40) —— */
500
+ prog(0.05, '入口礼序中轴与照壁');
501
+ addPavingPatch(B, M, 0, 104, 30, 18, 0.06);
502
+ // 八字影壁:中轴留通廊,仅以矮石屏作前景障景,保证宫门与礼序纵深可见
503
+ addWall(B, M, { x1: -14, z1: 108, x2: -9, z2: 105, h: 3.8, t: 0.6, mat: M.graybrick });
504
+ addWall(B, M, { x1: 9, z1: 105, x2: 14, z2: 108, h: 3.8, t: 0.6, mat: M.graybrick });
505
+ addWall(B, M, { x1: -4.5, z1: 104, x2: 4.5, z2: 104, h: 0.82, t: 0.7, mat: M.stoneDark });
506
+ P(ctx, boxGeo(7.6, 0.16, 1.1), M.stone, [0, 0.92, 104]);
507
+ for (const s of [-1, 1]) P(ctx, lathe([[0.32, 0], [0.42, 0.22], [0.20, 0.72], [0.06, 1.02]], 12),
508
+ M.stoneDark, [s * 3.0, 0.98, 104], [0, 0, 0], 1);
509
+ addBrickGate(B, M, { x: 0, y: 0, z: 92, w: 14, h: 6.4 });
510
+ plaque(ctx, '吴苑', [0, 5.55, 92.6], 0, 2.2, 0.62);
511
+ addPavingPatch(B, M, 0, 84, 22, 12, 0.06);
512
+ // 轿厅
513
+ hall(ctx, { x: 0, z: 80, w: 20, d: 8, base: 0.6, colH: 4.6, rise: 2.4, bays: 5, face: 1, rot: 0, dougong: false, windows: false, nx: 34, nz: 20 });
514
+ // 前庭
515
+ addPavingPatch(B, M, 0, 68, 30, 16, 0.05);
516
+ for (const s of [-1, 1]) {
517
+ addStoneLantern(B, M, s * 9, 0.1, 68);
518
+ P(ctx, boxGeo(3.2, 0.36, 3.2), M.stoneDark, [s * 9, 0.18, 68]);
519
+ }
520
+ // 东西廊庑
521
+ corridor(ctx, [[-24, 72], [-24, 58]], { width: 2.2, colH: 2.8, bothRails: false });
522
+ corridor(ctx, [[24, 72], [24, 58]], { width: 2.2, colH: 2.8, bothRails: false });
523
+ // 澄观堂(前朝主殿)
524
+ hall(ctx, {
525
+ x: 0, z: 58, w: 28, d: 12, base: 1.12, colH: 6.4, rise: 3.9, lift: 0.85,
526
+ bays: 5, face: 1, name: '澄观堂', plaqueW: 3.4, stairW: 6.4,
527
+ type: 'xieshan', nx: 48, nz: 30,
528
+ });
529
+ addPavingPatch(B, M, 0, 46, 26, 10, 0.05);
530
+ prog(0.20, '远香堂与南岸堂榭');
531
+
532
+ /* —— 景区 2:涵碧堂榭(南岸主体建筑群) —— */
533
+ // 远香堂(全园主体厅堂,正面朝北临水)
534
+ hall(ctx, {
535
+ x: 0, z: 30, w: 24, d: 10.5, base: 0.92, colH: 5.8, rise: 3.5, lift: 0.78,
536
+ bays: 5, face: -1, name: '远香堂', plaqueW: 3.2, type: 'xieshan',
537
+ terrace: { d: 4.2, rail: 'stone' }, nx: 48, nz: 30,
538
+ });
539
+ // 南岸水廊分东西两段,中段 X ∈ [−18, 18] 留空,
540
+ // 保证远香堂临水正面与「一池三山」定点视角的视线通廊不被廊屋遮挡
541
+ corridor(ctx, [[-56, 25], [-34, 24], [-18, 24]],
542
+ { width: 2.5, colH: 3.0, rise: 0.9, bothRails: false });
543
+ corridor(ctx, [[18, 24], [30, 23], [52, 21]],
544
+ { width: 2.5, colH: 3.0, rise: 0.9, bothRails: false });
545
+ // 涵碧榭(西南临水水榭)
546
+ watersideXie(ctx, { x: -30, z: 18, w: 11, d: 6, face: -1, name: '涵碧榭' });
547
+ // 东岸小轩
548
+ hall(ctx, { x: 58, z: 26, w: 9, d: 6, base: 0.5, colH: 3.9, rise: 2.0, bays: 3, face: -1, rot: 0, dougong: false, name: '听松轩', nx: 28, nz: 18 });
549
+ prog(0.34, '一池三山:岛屿、曲桥与石舫');
550
+
551
+ /* —— 景区 3:一池三山(核心水景) —— */
552
+ // 三岛岸壁与登岛平台
553
+ const isles = [
554
+ { x: -8, z: -12, r: 11.0, name: '蓬莱' },
555
+ { x: -34, z: -24, r: 6.8, name: '方丈' },
556
+ { x: 28, z: -18, r: 7.0, name: '瀛洲' },
557
+ ];
558
+ isles.forEach((is, k) => {
559
+ P(ctx, new THREE.CylinderGeometry(is.r, is.r + 0.5, 1.15, 20), M.huangshi, [is.x, -0.35, is.z]);
560
+ P(ctx, new THREE.CylinderGeometry(is.r - 0.5, is.r - 0.2, 0.25, 20), M.ground, [is.x, 0.30, is.z], [0, 0, 0], 0, {});
561
+ const N = 22;
562
+ for (let i = 0; i < N; i++) {
563
+ const a = i * Math.PI * 2 / N;
564
+ P(ctx, boxGeo(2.1, 0.42 + (i % 3) * 0.07, 0.9), M.stoneDark,
565
+ [is.x + Math.cos(a) * (is.r + 0.15), 0.12, is.z + Math.sin(a) * (is.r + 0.15)], [0, -a, 0]);
566
+ }
567
+ });
568
+ // 蓬莱 · 雪香云蔚亭(六角,对景焦点)
569
+ pavilion(ctx, { x: -8, z: -12, r: 3.5, sides: 6, base: 0.55, colH: 3.7, rise: 3.0, name: '雪香云蔚', lift: 0.62 });
570
+ // 方丈 · 小四角亭
571
+ pavilion(ctx, { x: -34, z: -24, r: 2.3, sides: 4, base: 0.42, colH: 2.9, rise: 2.2, name: '方丈' });
572
+ // 瀛洲 · 石峰与梅(由 rockery/nature 补石与花木)
573
+ // 九曲桥(南岸 → 荷风四面亭)
574
+ zigzagBridge(ctx, [[28, 22], [33, 19], [36, 21], [39, 17], [42, 18], [44, 14], [46, 12], [44, 9]], { y: 0.34, width: 1.8 });
575
+ // 拱桥(蓬莱 → 北岸)
576
+ archBridge(ctx, { x: -8, z: -30, len: 15, w: 2.6, rot: Math.PI / 2, rise: 2.4 });
577
+ // 平桥(南岸 → 蓬莱):略偏东,避免正对水景定点机位形成遮挡
578
+ zigzagBridge(ctx, [[4, 20], [1, 15], [-3, 7], [-8, -2]], { y: 0.40, width: 2.1 });
579
+ // 不系舟石舫
580
+ stoneBoat(ctx, { x: 38, z: -34, rot: -0.22, name: '不系舟' });
581
+ prog(0.48, '北岸见山楼与东北秋色景区');
582
+
583
+ /* —— 景区 9:见山楼(北岸制高点) —— */
584
+ twoStorey(ctx, { x: 20, z: -60, w: 18, d: 10.5, h1: 5.4, h2: 4.2, rise: 3.1, face: -1, name: '见山楼' });
585
+ addPavingPatch(B, M, 20, -52, 24, 8, 0.06);
586
+ // 北岸石栏
587
+ addRailing(B, M, { x1: 4, z1: -49.5, x2: 36, z2: -49.5, y: 0.3, kind: 'stone' });
588
+ // 爬山廊(东北)
589
+ corridor(ctx, [[44, -44], [52, -48], [58, -52], [64, -54]], { width: 2.2, colH: 2.8, rise: 0.8, bothRails: true });
590
+
591
+ /* —— 景区 7:小山丛桂(东北秋色) —— */
592
+ pavilion(ctx, { x: 68, z: -54, r: 3.0, sides: 4, rot: Math.PI / 6, base: 0.5, colH: 3.3, rise: 2.4, name: '与谁同坐' });
593
+ addPavingPatch(B, M, 68, -54, 10, 10, 0.08);
594
+ addWall(B, M, { x1: 52, z1: -74, x2: 92, z2: -74, h: 2.7, wave: { count: 3, amp: 0.35, phase: 0.4 } });
595
+
596
+ /* —— 景区 4/8:云根叠翠(西北假山)与漱石枕流(西南水院) —— */
597
+ prog(0.62, '云墙、漏窗、月洞门与小飞虹廊桥');
598
+ // 山顶壑云亭
599
+ pavilion(ctx, { x: -64, z: -40, r: 2.5, sides: 4, rot: 0.4, base: 0.4, colH: 2.8, rise: 2.1, name: '壑云' });
600
+ // 小飞虹廊桥(跨西水湾)
601
+ zigzagBridge(ctx, [[-56, 16], [-52, 13], [-48, 10], [-44, 6], [-40, 2]], { y: 0.42, width: 2.6 });
602
+ corridor(ctx, [[-56, 16], [-52, 13], [-48, 10], [-44, 6], [-40, 2]], {
603
+ width: 2.5, colH: 3.1, rise: 1.05, y0: 0.52, bothRails: true,
604
+ });
605
+ plaque(ctx, '小飞虹', [-48, 3.42, 11.0], 0, 1.9, 0.52);
606
+ // 西南水院矮墙与石矶
607
+ addWall(B, M, { x1: -98, z1: 16, x2: -70, z2: 16, h: 2.6, wave: { count: 2, amp: 0.4, phase: 1.0 } });
608
+ addStoneLantern(B, M, -70, 0.1, 4);
609
+
610
+ /* —— 景区 5/12:竹里馆(西南竹径院) —— */
611
+ prog(0.74, '竹里馆框景院与园墙');
612
+ // 院墙(带月洞门与漏窗)
613
+ addMoonGate(B, M, { x: -80, z: 44, rot: 0, r: 1.5, h: 3.5, width: 12 });
614
+ plaque(ctx, '延月', [-80, 3.28, 44.35], 0, 1.5, 0.46);
615
+ // 两侧漏窗(在云墙上开窗:用带洞墙段)
616
+ addWall(B, M, {
617
+ x1: -96, z1: 44, x2: -87, z2: 44, h: 3.2,
618
+ holes: [{ type: 'hex', x: 0, y: 1.05, r: 0.85 }],
619
+ });
620
+ addWall(B, M, {
621
+ x1: -73, z1: 44, x2: -64, z2: 44, h: 3.2,
622
+ holes: [{ type: 'rect', x: 0, y: 0.9, w: 1.5, h: 1.5 }],
623
+ });
624
+ addLeakWindowCore(B, M, { x: -91.5, y: 1.9, z: 44, w: 1.5, h: 1.5, kind: 'hex' });
625
+ addLeakWindowCore(B, M, { x: -68.5, y: 1.65, z: 44, w: 1.5, h: 1.5, kind: 'binglie' });
626
+ // 竹径铺地
627
+ addPavingPatch(B, M, -84, 58, 4.2, 34, 0.05);
628
+ for (let i = 0; i < 10; i++) {
629
+ addPavingPatch(B, M, -84 + (i % 2 ? 0.5 : -0.5), 46 + i * 2.6, 3.2, 0.9, 0.055);
630
+ }
631
+ pavilion(ctx, { x: -82, z: 34, r: 2.8, sides: 6, base: 0.4, colH: 3.2, rise: 2.6, name: '听雨' });
632
+ addWall(B, M, { x1: -100, z1: 30, x2: -100, z2: 66, h: 3.0, wave: { count: 2, amp: 0.3, phase: 0 } });
633
+ // 北侧院墙中部留口,保证「延月洞门 → 云根叠翠主峰」的框景视线贯通
634
+ addWall(B, M, { x1: -100, z1: 30, x2: -86, z2: 30, h: 2.8 });
635
+ addWall(B, M, { x1: -72, z1: 30, x2: -66, z2: 30, h: 2.8 });
636
+
637
+ /* —— 景区 6:荷风四面(东南荷池) —— */
638
+ prog(0.84, '荷风四面亭与园墙闭合');
639
+ pavilion(ctx, { x: 44, z: 6, r: 3.4, sides: 4, rot: Math.PI / 4, base: 0.5, colH: 3.5, rise: 2.7, name: '荷风四面' });
640
+ P(ctx, new THREE.CylinderGeometry(4.2, 4.6, 0.95, 12), M.stone, [44, 0.05, 6]);
641
+ // 东南曲墙
642
+ addWall(B, M, { x1: 70, z1: 22, x2: 96, z2: 22, h: 2.8, wave: { count: 2, amp: 0.42, phase: 0.6 } });
643
+ addWall(B, M, {
644
+ x1: 84, z1: -6, x2: 84, z2: 22, h: 3.0,
645
+ holes: [{ type: 'rect', x: 0, y: 0.9, w: 1.6, h: 1.5 }, { type: 'rect', x: 6, y: 0.9, w: 1.6, h: 1.5 }],
646
+ });
647
+ addLeakWindowCore(B, M, { x: 84, y: 1.65, z: 8, w: 1.6, h: 1.5, rot: Math.PI / 2, kind: 'wanzi' });
648
+ addLeakWindowCore(B, M, { x: 84, y: 1.65, z: 14, w: 1.6, h: 1.5, rot: Math.PI / 2, kind: 'haitang' });
649
+
650
+ /* —— 园墙闭合(云墙随地形起伏) —— */
651
+ const wallSeg = (x1, z1, x2, z2, wave) => addWall(B, M, { x1, z1, x2, z2, h: 3.3, wave });
652
+ wallSeg(-110, 95, -18, 95, { count: 2, amp: 0.32, phase: 0 });
653
+ wallSeg(18, 95, 110, 95, { count: 2, amp: 0.32, phase: 1.2 });
654
+ wallSeg(-110, -95, -30, -95, { count: 2, amp: 0.38, phase: 0.5 });
655
+ wallSeg(-30, -95, 110, -95, { count: 3, amp: 0.38, phase: 1.7 });
656
+ wallSeg(-110, -95, -110, 95, { count: 4, amp: 0.30, phase: 0.9 });
657
+ wallSeg(110, -95, 110, 95, { count: 4, amp: 0.30, phase: 2.1 });
658
+ // 园墙漏窗(临园外,形成框景序列)
659
+ for (let i = 0; i < 6; i++) {
660
+ const z = -72 + i * 24;
661
+ addLeakWindowCore(B, M, { x: -110, y: 1.8, z, w: 1.4, h: 1.4, rot: Math.PI / 2, kind: ['binglie', 'wanzi', 'hex', 'haitang'][i % 4] });
662
+ }
663
+
664
+ /* —— 园外借景层:北寺塔与村落 —— */
665
+ prog(0.94, '园外借景:北寺塔与远村');
666
+ buildPagoda(ctx);
667
+ buildVillage(ctx);
668
+
669
+ prog(1.0, '建筑群构建完成');
670
+ }