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,4955 @@
1
+ import * as THREE from "three";
2
+ import { mergeGeometries } from "three/addons/utils/BufferGeometryUtils.js";
3
+ // modules/world/content/yuanmingyuan/core.js
4
+ const WORLD = {
5
+ unit: 1,
6
+ core: {
7
+ minX: -165,
8
+ maxX: 165,
9
+ minZ: -95,
10
+ maxZ: 112
11
+ },
12
+ bounds: {
13
+ minX: -240,
14
+ maxX: 240,
15
+ minZ: -180,
16
+ maxZ: 190
17
+ },
18
+ groundSize: [560, 440],
19
+ lakeY: -.62,
20
+ sunDefaultHour: 16.4
21
+ };
22
+ const QUALITY = {
23
+ high: {
24
+ label: "高",
25
+ dpr: 2,
26
+ shadow: 4096,
27
+ grass: 9e3,
28
+ trees: 1,
29
+ bloom: true,
30
+ grade: true,
31
+ waterSeg: 64,
32
+ aniso: 8,
33
+ texScale: 1,
34
+ detailDist: 175,
35
+ fadeFar: 145
36
+ },
37
+ medium: {
38
+ label: "中",
39
+ dpr: 1.5,
40
+ shadow: 2048,
41
+ grass: 4200,
42
+ trees: .72,
43
+ bloom: true,
44
+ grade: true,
45
+ waterSeg: 40,
46
+ aniso: 4,
47
+ texScale: .5,
48
+ detailDist: 130,
49
+ fadeFar: 110
50
+ },
51
+ low: {
52
+ label: "低",
53
+ dpr: 1,
54
+ shadow: 1024,
55
+ grass: 900,
56
+ trees: .45,
57
+ bloom: false,
58
+ grade: false,
59
+ waterSeg: 24,
60
+ aniso: 1,
61
+ texScale: .25,
62
+ detailDist: 95,
63
+ fadeFar: 80
64
+ }
65
+ };
66
+ const POIS = [
67
+ {
68
+ id: "overview",
69
+ name: "全景鸟瞰",
70
+ pos: [
71
+ 86,
72
+ 21,
73
+ 106
74
+ ],
75
+ target: [
76
+ 26,
77
+ 7,
78
+ 2
79
+ ],
80
+ desc: "自东南方向眺望西洋楼景区:右侧为大水法石龛与远瀛观,左侧为海晏堂与生肖喷水钟,南侧园湖与垂柳环绕。"
81
+ },
82
+ {
83
+ id: "dashuifa",
84
+ name: "大水法",
85
+ pos: [
86
+ 56,
87
+ 7.5,
88
+ 48
89
+ ],
90
+ target: [
91
+ 40,
92
+ 7,
93
+ -8
94
+ ],
95
+ desc: "西洋楼最大的一组喷泉。石龛式巴洛克屏风、椭圆水池、石狮吐水与前方观水法宝座构成南北轴线。"
96
+ },
97
+ {
98
+ id: "haiyantang",
99
+ name: "海晏堂",
100
+ pos: [
101
+ -64,
102
+ 13,
103
+ 72
104
+ ],
105
+ target: [
106
+ -72,
107
+ 7,
108
+ 6
109
+ ],
110
+ desc: "西洋楼中体量最大的建筑,正面十一间,汉白玉番花柱、粉红灰墙与孔雀绿琉璃瓦顶;前设十二生肖喷水钟。"
111
+ },
112
+ {
113
+ id: "zodiac",
114
+ name: "生肖喷水钟",
115
+ pos: [
116
+ -55,
117
+ 5,
118
+ 60
119
+ ],
120
+ target: [
121
+ -62,
122
+ 2.5,
123
+ 30
124
+ ],
125
+ desc: "十二尊兽首铜像分列扇形石阶两侧,按时辰轮流喷水,正午齐喷,是以水力驱动的报时装置。"
126
+ },
127
+ {
128
+ id: "yuanyingguan",
129
+ name: "远瀛观",
130
+ pos: [
131
+ 78,
132
+ 11,
133
+ -14
134
+ ],
135
+ target: [
136
+ 40,
137
+ 6,
138
+ -34
139
+ ],
140
+ desc: "坐落于高台之上的汉白玉建筑,三座巨型拱门与精雕柱础为今日遗址中最具辨识度的遗存。"
141
+ },
142
+ {
143
+ id: "guanshuifa",
144
+ name: "观水法",
145
+ pos: [
146
+ 12,
147
+ 5,
148
+ 74
149
+ ],
150
+ target: [
151
+ 40,
152
+ 4,
153
+ 34
154
+ ],
155
+ desc: "皇帝观赏大水法喷泉的宝座,后列五扇西洋石屏风,雕刻军阵、甲胄与西洋纹样。"
156
+ },
157
+ {
158
+ id: "maze",
159
+ name: "黄花阵",
160
+ pos: [
161
+ -152,
162
+ 24,
163
+ 44
164
+ ],
165
+ target: [
166
+ -152,
167
+ 1,
168
+ 0
169
+ ],
170
+ desc: "仿欧洲迷宫的砖砌矮墙花园,中央设八角亭,中秋时宫女持莲花灯竞走其中。"
171
+ },
172
+ {
173
+ id: "lake",
174
+ name: "园湖夕照",
175
+ pos: [
176
+ -6,
177
+ 4,
178
+ 132
179
+ ],
180
+ target: [
181
+ 22,
182
+ 2,
183
+ 62
184
+ ],
185
+ desc: "园内水系以自然式湖岸、垂柳、荷丛与石桥衔接建筑群,呼应圆明园「因水成景」的造园逻辑。"
186
+ }
187
+ ];
188
+ function mulberry32(a) {
189
+ return function() {
190
+ a |= 0;
191
+ a = a + 1831565813 | 0;
192
+ let t = Math.imul(a ^ a >>> 15, 1 | a);
193
+ t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
194
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
195
+ };
196
+ }
197
+ let R = mulberry32(18601018);
198
+ function resetWorldSeed(seed = 18601018) {
199
+ R = mulberry32(seed);
200
+ }
201
+ function h2(x, y, s) {
202
+ let n = Math.imul(x | 0, 374761393) + Math.imul(y | 0, 668265263) + Math.imul(s | 0, 1442695041);
203
+ n = Math.imul(n ^ n >>> 13, 1274126177);
204
+ return ((n ^ n >>> 16) >>> 0) / 4294967295;
205
+ }
206
+ function vn(x, y, s, P) {
207
+ const xi = Math.floor(x), yi = Math.floor(y);
208
+ const xf = x - xi, yf = y - yi;
209
+ const u = xf * xf * (3 - 2 * xf), v = yf * yf * (3 - 2 * yf);
210
+ const X0 = (xi % P + P) % P, Y0 = (yi % P + P) % P;
211
+ const X1 = (X0 + 1) % P, Y1 = (Y0 + 1) % P;
212
+ const a = h2(X0, Y0, s), b = h2(X1, Y0, s), c = h2(X0, Y1, s), d = h2(X1, Y1, s);
213
+ return (a + (b - a) * u) * (1 - v) + (c + (d - c) * u) * v;
214
+ }
215
+ function fbm(x, y, s, oct = 4, P = 8) {
216
+ let amp = .55, f = 1, sum = 0, norm = 0;
217
+ for (let i = 0; i < oct; i++) {
218
+ sum += amp * vn(x * f * P, y * f * P, s + i * 31, P * f);
219
+ norm += amp;
220
+ amp *= .5;
221
+ f *= 2;
222
+ }
223
+ return sum / norm;
224
+ }
225
+ const clamp$1 = (v, a, b) => v < a ? a : v > b ? b : v;
226
+ const smooth = (a, b, v) => {
227
+ const t = clamp$1((v - a) / (b - a), 0, 1);
228
+ return t * t * (3 - 2 * t);
229
+ };
230
+ function makeMaps(size, shade) {
231
+ const n = size * size;
232
+ const col = new Uint8Array(n * 4);
233
+ const nrm = new Uint8Array(n * 4);
234
+ const rgh = new Uint8Array(n * 4);
235
+ const H = new Float32Array(n);
236
+ for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) {
237
+ const i = y * size + x;
238
+ const o = shade(x / size, y / size, x, y, size);
239
+ col[i * 4] = o[0];
240
+ col[i * 4 + 1] = o[1];
241
+ col[i * 4 + 2] = o[2];
242
+ col[i * 4 + 3] = 255;
243
+ H[i] = o[3];
244
+ const rv = clamp$1(o[4] * 255, 0, 255);
245
+ rgh[i * 4] = rv;
246
+ rgh[i * 4 + 1] = rv;
247
+ rgh[i * 4 + 2] = rv;
248
+ rgh[i * 4 + 3] = 255;
249
+ }
250
+ const strength = 2.2;
251
+ for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) {
252
+ const o = (y * size + x) * 4;
253
+ const l = H[y * size + (x - 1 + size) % size], r = H[y * size + (x + 1) % size];
254
+ const t = H[(y - 1 + size) % size * size + x], b = H[(y + 1) % size * size + x];
255
+ const nx = (l - r) * strength, ny = (t - b) * strength, nz = 1;
256
+ const inv = 1 / Math.sqrt(nx * nx + ny * ny + 1);
257
+ nrm[o] = (nx * inv * .5 + .5) * 255;
258
+ nrm[o + 1] = (ny * inv * .5 + .5) * 255;
259
+ nrm[o + 2] = (nz * inv * .5 + .5) * 255;
260
+ nrm[o + 3] = 255;
261
+ }
262
+ const tex = (data, srgb) => {
263
+ const t = new THREE.DataTexture(data, size, size, THREE.RGBAFormat);
264
+ t.wrapS = t.wrapT = THREE.RepeatWrapping;
265
+ t.magFilter = THREE.LinearFilter;
266
+ t.minFilter = THREE.LinearMipmapLinearFilter;
267
+ t.generateMipmaps = true;
268
+ if (srgb) t.colorSpace = THREE.SRGBColorSpace;
269
+ t.anisotropy = 8;
270
+ t.needsUpdate = true;
271
+ return t;
272
+ };
273
+ return {
274
+ map: tex(col, true),
275
+ normalMap: tex(nrm, false),
276
+ roughnessMap: tex(rgh, false)
277
+ };
278
+ }
279
+ const TEXDEF = {
280
+ stone: {
281
+ size: 512,
282
+ rep: [1, 1],
283
+ fn: (u, v, x, y, S) => {
284
+ const g = fbm(u, v, 11, 5), fine = fbm(u, v, 47, 3, 32), stain = fbm(u * 1.7, v * .35, 71, 3);
285
+ const vein = Math.abs(Math.sin((u * 13 + v * 6 + g * 5.5) * Math.PI));
286
+ const vline = smooth(.82, .99, 1 - vein) * .16;
287
+ const moss = smooth(.63, .82, fbm(u, v, 97, 3)) * .42;
288
+ const pit = smooth(.74, .9, fine) * .25;
289
+ const base = 188 + g * 30 - vline * 120 - stain * 26 - pit * 60;
290
+ return [
291
+ clamp$1(base + moss * -18, 0, 255),
292
+ clamp$1(base * .985 + moss * 16 - vline * 100, 0, 255),
293
+ clamp$1(base * .93 + moss * -6 - vline * 80, 0, 255),
294
+ g * .55 + fine * .3 - vline * 1.2 - pit * .8,
295
+ .72 + fine * .22 + moss * .1
296
+ ];
297
+ }
298
+ },
299
+ marble: {
300
+ size: 512,
301
+ rep: [1, 1],
302
+ fn: (u, v) => {
303
+ const g = fbm(u, v, 23, 4), warp = fbm(u, v, 61, 3);
304
+ const vein = Math.pow(1 - Math.abs(Math.sin((u * 6.2 + v * 3.1 + warp * 3.4) * Math.PI)), 9);
305
+ const fine = fbm(u, v, 89, 3, 32);
306
+ const base = 218 + g * 20 - vein * 42;
307
+ return [
308
+ base,
309
+ base * .99 - vein * 30,
310
+ base * .955 - vein * 22,
311
+ g * .35 + fine * .25 - vein * .5,
312
+ .38 + fine * .2 + vein * .2
313
+ ];
314
+ }
315
+ },
316
+ plaster: {
317
+ size: 512,
318
+ rep: [1, 1],
319
+ fn: (u, v) => {
320
+ const g = fbm(u, v, 31, 4), fine = fbm(u, v, 113, 3, 32), dirt = fbm(u, v * .4, 137, 3);
321
+ const crack = smooth(.87, .98, 1 - Math.abs(Math.sin((u * 9 + v * 11 + g * 6) * Math.PI))) * .35;
322
+ const b = 1 - dirt * .22 - crack * .3;
323
+ return [
324
+ 206 * b + g * 12,
325
+ 166 * b + g * 12,
326
+ 154 * b + g * 10,
327
+ g * .5 + fine * .35 - crack,
328
+ .78 + fine * .15
329
+ ];
330
+ }
331
+ },
332
+ brick: {
333
+ size: 512,
334
+ rep: [1, 1],
335
+ fn: (u, v, x, y) => {
336
+ const rows = 12, cols = 5;
337
+ const ry = v * rows, rx = u * cols + Math.floor(ry) % 2 * .5;
338
+ const my = Math.abs(ry % 1 - .5), mx = Math.abs(rx % 1 - .5);
339
+ const joint = smooth(.42, .5, Math.max(my, mx));
340
+ const g = fbm(u, v, 151, 4), fine = fbm(u, v, 179, 3, 32);
341
+ const k = 1 - joint * .55;
342
+ return [
343
+ (158 + g * 26) * k,
344
+ (104 + g * 20) * k,
345
+ (88 + g * 18) * k,
346
+ -joint * .85 + g * .35 + fine * .22,
347
+ .78 + fine * .16 + joint * .1
348
+ ];
349
+ }
350
+ },
351
+ graybrick: {
352
+ size: 512,
353
+ rep: [1, 1],
354
+ fn: (u, v) => {
355
+ const rows = 14, cols = 6;
356
+ const ry = v * rows, rx = u * cols + Math.floor(ry) % 2 * .5;
357
+ const joint = smooth(.4, .5, Math.max(Math.abs(ry % 1 - .5), Math.abs(rx % 1 - .5)));
358
+ const g = fbm(u, v, 191, 4), f = fbm(u, v, 211, 3, 32);
359
+ const k = 1 - joint * .42;
360
+ return [
361
+ (132 + g * 30) * k,
362
+ (130 + g * 28) * k,
363
+ (120 + g * 24) * k,
364
+ -joint * .8 + g * .4 + f * .2,
365
+ .82 + f * .12
366
+ ];
367
+ }
368
+ },
369
+ roof: {
370
+ size: 256,
371
+ rep: [1, 1],
372
+ fn: (u, v) => {
373
+ const ribs = Math.abs(Math.sin(u * Math.PI * 18));
374
+ const course = Math.abs(Math.sin(v * Math.PI * 12));
375
+ const g = fbm(u, v, 233, 3);
376
+ const hi = Math.pow(ribs, .6), lo = smooth(.85, 1, course);
377
+ const k = .62 + hi * .52 - lo * .22 + g * .14;
378
+ return [
379
+ 46 * k + g * 12,
380
+ 148 * k + g * 18,
381
+ 106 * k + g * 14,
382
+ hi * .9 - lo * .5 + g * .2,
383
+ .26 + g * .16 + lo * .1
384
+ ];
385
+ }
386
+ },
387
+ bronze: {
388
+ size: 256,
389
+ rep: [1, 1],
390
+ fn: (u, v) => {
391
+ const g = fbm(u, v, 251, 4), pat = smooth(.52, .75, fbm(u, v, 277, 3));
392
+ const f = fbm(u, v, 293, 3, 32);
393
+ return [
394
+ 112 + g * 34 - pat * 68,
395
+ 78 + g * 26 + pat * 24,
396
+ 46 + g * 16 + pat * 18,
397
+ g * .5 + f * .3 - pat * .25,
398
+ .44 + g * .28 + pat * .25
399
+ ];
400
+ }
401
+ },
402
+ wood: {
403
+ size: 256,
404
+ rep: [1, 1],
405
+ fn: (u, v) => {
406
+ const grain = Math.abs(Math.sin((u * 26 + fbm(u, v, 307, 3) * 5) * Math.PI));
407
+ const g = fbm(u, v, 311, 3);
408
+ return [
409
+ 96 + grain * 26 + g * 12,
410
+ 44 + grain * 14 + g * 8,
411
+ 36 + grain * 10 + g * 8,
412
+ grain * .4 + g * .3,
413
+ .48 + g * .2
414
+ ];
415
+ }
416
+ },
417
+ ground: {
418
+ size: 512,
419
+ rep: [1, 1],
420
+ fn: (u, v) => {
421
+ const g = fbm(u, v, 331, 5), f = fbm(u, v, 347, 3, 32), patch = fbm(u, v, 359, 3);
422
+ const dry = smooth(.52, .78, patch);
423
+ return [
424
+ 126 + g * 46 + dry * 52,
425
+ 138 + g * 42 + dry * 30,
426
+ 82 + g * 28 + dry * 14,
427
+ g * .55 + f * .4,
428
+ .9 + f * .1
429
+ ];
430
+ }
431
+ },
432
+ hedge: {
433
+ size: 256,
434
+ rep: [1, 1],
435
+ fn: (u, v) => {
436
+ const g = fbm(u, v, 379, 4), f = fbm(u, v, 383, 4, 16);
437
+ return [
438
+ 44 + g * 34 + f * 16,
439
+ 70 + g * 46 + f * 20,
440
+ 36 + g * 22 + f * 10,
441
+ g * .6 + f * .5,
442
+ .86 + g * .12
443
+ ];
444
+ }
445
+ }
446
+ };
447
+ function buildTextures(onProgress, texScale = 1) {
448
+ const out = {};
449
+ const keys = Object.keys(TEXDEF);
450
+ keys.forEach((k, i) => {
451
+ const def = TEXDEF[k];
452
+ const size = Math.max(128, Math.pow(2, Math.round(Math.log2(def.size * texScale))));
453
+ out[k] = makeMaps(size, def.fn);
454
+ if (onProgress) onProgress((i + 1) / keys.length, k);
455
+ });
456
+ return out;
457
+ }
458
+ function buildMaterials(T) {
459
+ const std = (name, key, opts = {}) => {
460
+ const t = T[key];
461
+ const m = new THREE.MeshStandardMaterial({
462
+ map: t.map,
463
+ normalMap: t.normalMap,
464
+ roughnessMap: t.roughnessMap,
465
+ normalScale: new THREE.Vector2(opts.ns ?? .55, opts.ns ?? .55),
466
+ roughness: opts.roughness ?? .9,
467
+ metalness: opts.metalness ?? 0,
468
+ color: opts.color ?? 16777215,
469
+ side: opts.side ?? THREE.FrontSide,
470
+ transparent: opts.transparent ?? false,
471
+ opacity: opts.opacity ?? 1,
472
+ vertexColors: opts.vertexColors ?? false
473
+ });
474
+ m.name = name;
475
+ return m;
476
+ };
477
+ const M = {
478
+ stone: std("stone", "stone", {
479
+ roughness: .92,
480
+ ns: .65
481
+ }),
482
+ stone2: std("stone2", "stone", {
483
+ roughness: .92,
484
+ ns: .5,
485
+ color: 15064262
486
+ }),
487
+ marble: std("marble", "marble", {
488
+ roughness: .62,
489
+ ns: .35
490
+ }),
491
+ marbleD: std("marbleD", "marble", {
492
+ roughness: .72,
493
+ ns: .4,
494
+ color: 13221289
495
+ }),
496
+ plaster: std("plaster", "plaster", {
497
+ roughness: .9,
498
+ ns: .35
499
+ }),
500
+ brick: std("brick", "brick", {
501
+ roughness: .95,
502
+ ns: .7
503
+ }),
504
+ graybrick: std("graybrick", "graybrick", {
505
+ roughness: .94,
506
+ ns: .7
507
+ }),
508
+ roof: std("roof", "roof", {
509
+ roughness: .38,
510
+ ns: .85,
511
+ metalness: .12,
512
+ color: 14282973
513
+ }),
514
+ bronze: std("bronze", "bronze", {
515
+ roughness: .55,
516
+ ns: .5,
517
+ metalness: .72
518
+ }),
519
+ bronzeD: std("bronzeD", "bronze", {
520
+ roughness: .7,
521
+ ns: .5,
522
+ metalness: .62,
523
+ color: 9149042
524
+ }),
525
+ wood: std("wood", "wood", {
526
+ roughness: .6,
527
+ ns: .4
528
+ }),
529
+ ground: std("ground", "ground", {
530
+ roughness: 1,
531
+ ns: .35,
532
+ vertexColors: true
533
+ }),
534
+ hedge: std("hedge", "hedge", {
535
+ roughness: 1,
536
+ ns: .6
537
+ })
538
+ };
539
+ M.ridge = new THREE.MeshStandardMaterial({
540
+ color: 3629644,
541
+ roughness: .36,
542
+ metalness: .16
543
+ });
544
+ M.ridge.name = "ridge";
545
+ M.glass = new THREE.MeshPhysicalMaterial({
546
+ color: 7310240,
547
+ roughness: .18,
548
+ metalness: .15,
549
+ transparent: true,
550
+ opacity: .42,
551
+ side: THREE.DoubleSide
552
+ });
553
+ M.glass.name = "glass";
554
+ M.dark = new THREE.MeshStandardMaterial({
555
+ color: 3814960,
556
+ roughness: .95
557
+ });
558
+ M.dark.name = "dark";
559
+ M.gold = new THREE.MeshStandardMaterial({
560
+ color: 13083228,
561
+ roughness: .34,
562
+ metalness: .82
563
+ });
564
+ M.gold.name = "gold";
565
+ M.leaf = new THREE.MeshStandardMaterial({
566
+ color: 7043646,
567
+ roughness: .95,
568
+ side: THREE.DoubleSide,
569
+ vertexColors: true
570
+ });
571
+ M.leaf.name = "leaf";
572
+ M.waterFoam = new THREE.MeshBasicMaterial({
573
+ color: 14674672,
574
+ transparent: true,
575
+ opacity: .42,
576
+ depthWrite: false,
577
+ side: THREE.DoubleSide
578
+ });
579
+ M.waterFoam.name = "waterFoam";
580
+ return M;
581
+ }
582
+ function boxGeo(w, h, d, uvPerMeter = .55) {
583
+ const g = new THREE.BoxGeometry(w, h, d);
584
+ const uv = g.getAttribute("uv");
585
+ const dims = [
586
+ [d, h],
587
+ [d, h],
588
+ [w, d],
589
+ [w, d],
590
+ [w, h],
591
+ [w, h]
592
+ ];
593
+ for (let f = 0; f < 6; f++) for (let i = 0; i < 4; i++) {
594
+ const k = f * 4 + i;
595
+ uv.setXY(k, uv.getX(k) * dims[f][0] * uvPerMeter, uv.getY(k) * dims[f][1] * uvPerMeter);
596
+ }
597
+ uv.needsUpdate = true;
598
+ return g;
599
+ }
600
+ function chamferBoxGeo(w, h, d, bevel = .035, uvPerMeter = .5) {
601
+ const s = new THREE.Shape();
602
+ const hw = w / 2 - bevel, hh = h / 2 - bevel;
603
+ s.moveTo(-hw, -hh);
604
+ s.lineTo(hw, -hh);
605
+ s.lineTo(hw, hh);
606
+ s.lineTo(-hw, hh);
607
+ s.closePath();
608
+ const g = new THREE.ExtrudeGeometry(s, {
609
+ depth: Math.max(.01, d - bevel * 2),
610
+ bevelEnabled: true,
611
+ bevelThickness: bevel,
612
+ bevelSize: bevel,
613
+ bevelSegments: 1,
614
+ curveSegments: 1,
615
+ steps: 1
616
+ });
617
+ g.translate(0, 0, -(d - bevel * 2) / 2);
618
+ const uv = g.getAttribute("uv");
619
+ for (let i = 0; i < uv.count; i++) uv.setXY(i, uv.getX(i) * w * uvPerMeter, uv.getY(i) * h * uvPerMeter);
620
+ return g;
621
+ }
622
+ function archWallGeo(w, h, d, holes = [], bevel = .04) {
623
+ const s = new THREE.Shape();
624
+ s.moveTo(-w / 2, 0);
625
+ s.lineTo(w / 2, 0);
626
+ s.lineTo(w / 2, h);
627
+ s.lineTo(-w / 2, h);
628
+ s.closePath();
629
+ holes.forEach((o) => {
630
+ const p = new THREE.Path();
631
+ const hw = o.w / 2;
632
+ if (o.arch) {
633
+ const spring = o.h - hw;
634
+ p.moveTo(o.x - hw, 0);
635
+ p.lineTo(o.x - hw, spring);
636
+ p.absarc(o.x, spring, hw, Math.PI, 0, true);
637
+ p.lineTo(o.x + hw, 0);
638
+ p.closePath();
639
+ } else {
640
+ p.moveTo(o.x - hw, 0);
641
+ p.lineTo(o.x - hw, o.h);
642
+ p.lineTo(o.x + hw, o.h);
643
+ p.lineTo(o.x + hw, 0);
644
+ p.closePath();
645
+ }
646
+ s.holes.push(p);
647
+ });
648
+ const g = new THREE.ExtrudeGeometry(s, {
649
+ depth: Math.max(.05, d - bevel * 2),
650
+ bevelEnabled: bevel > 0,
651
+ bevelThickness: bevel,
652
+ bevelSize: bevel,
653
+ bevelSegments: 1,
654
+ curveSegments: 16,
655
+ steps: 1
656
+ });
657
+ g.translate(0, 0, -(d - bevel * 2) / 2);
658
+ return g;
659
+ }
660
+ function brokenWallGeo(w, h, d, seed = 1, jagged = 1) {
661
+ const r = mulberry32(seed * 7919 + 13);
662
+ const s = new THREE.Shape();
663
+ s.moveTo(-w / 2, 0);
664
+ s.lineTo(w / 2, 0);
665
+ const N = Math.max(6, Math.round(w / 1.1));
666
+ for (let i = N; i >= 0; i--) {
667
+ const x = -w / 2 + i / N * w;
668
+ const base = h - (.12 + r() * .55 * jagged) * h;
669
+ const dent = Math.sin(i * 1.7 + seed) * .07 * h;
670
+ s.lineTo(x, Math.max(.35 * h, base + dent));
671
+ }
672
+ s.closePath();
673
+ const g = new THREE.ExtrudeGeometry(s, {
674
+ depth: d,
675
+ bevelEnabled: false,
676
+ curveSegments: 1
677
+ });
678
+ g.translate(0, 0, -d / 2);
679
+ return g;
680
+ }
681
+ function flutedShaftGeo(height, rBottom, rTop, flutes = 20, depth = .045, rings = 10, seg = 72) {
682
+ const pos = [], nrm = [], uv = [], idx = [];
683
+ for (let i = 0; i <= rings; i++) {
684
+ const t = i / rings;
685
+ const y = t * height;
686
+ const entasis = Math.sin(t * Math.PI) * .025;
687
+ const r = rBottom + (rTop - rBottom) * t + entasis;
688
+ for (let j = 0; j <= seg; j++) {
689
+ const a = j / seg * Math.PI * 2;
690
+ const rad = r - depth * (.5 - .5 * Math.cos(a * flutes));
691
+ const x = Math.cos(a) * rad, z = Math.sin(a) * rad;
692
+ pos.push(x, y, z);
693
+ const dr = -depth * .5 * flutes * Math.sin(a * flutes);
694
+ const nx = Math.cos(a) * rad + Math.sin(a) * dr, nz = Math.sin(a) * rad - Math.cos(a) * dr;
695
+ const l = Math.hypot(nx, nz) || 1;
696
+ nrm.push(nx / l, .06, nz / l);
697
+ uv.push(j / seg * 3, t * height * .5);
698
+ }
699
+ }
700
+ for (let i = 0; i < rings; i++) for (let j = 0; j < seg; j++) {
701
+ const a = i * (seg + 1) + j, b = a + seg + 1;
702
+ idx.push(a, b, a + 1, b, b + 1, a + 1);
703
+ }
704
+ const g = new THREE.BufferGeometry();
705
+ g.setAttribute("position", new THREE.Float32BufferAttribute(pos, 3));
706
+ g.setAttribute("normal", new THREE.Float32BufferAttribute(nrm, 3));
707
+ g.setAttribute("uv", new THREE.Float32BufferAttribute(uv, 2));
708
+ g.setIndex(idx);
709
+ return g;
710
+ }
711
+ function shellGeo(radius, ribs = 13, seg = 40, rings = 12) {
712
+ const pos = [], nrm = [], uv = [], idx = [];
713
+ for (let i = 0; i <= rings; i++) {
714
+ const t = i / rings;
715
+ for (let j = 0; j <= seg; j++) {
716
+ const a = j / seg * Math.PI;
717
+ const ripple = Math.cos(a * ribs) * .045 * t;
718
+ const R2 = radius * t;
719
+ const x = Math.cos(a) * R2 * (1 + ripple);
720
+ const y = Math.sin(a) * R2 * (1 + ripple) * .72;
721
+ const z = -Math.pow(t, 2) * radius * .62;
722
+ pos.push(x, y, z);
723
+ nrm.push(0, .25, 1);
724
+ uv.push(j / seg, t);
725
+ }
726
+ }
727
+ for (let i = 0; i < rings; i++) for (let j = 0; j < seg; j++) {
728
+ const a = i * (seg + 1) + j, b = a + seg + 1;
729
+ idx.push(a, b, a + 1, b, b + 1, a + 1);
730
+ }
731
+ const g = new THREE.BufferGeometry();
732
+ g.setAttribute("position", new THREE.Float32BufferAttribute(pos, 3));
733
+ g.setAttribute("normal", new THREE.Float32BufferAttribute(nrm, 3));
734
+ g.setAttribute("uv", new THREE.Float32BufferAttribute(uv, 2));
735
+ g.setIndex(idx);
736
+ g.computeVertexNormals();
737
+ return g;
738
+ }
739
+ function tube(points, radius, seg = 24, radial = 6) {
740
+ const curve = new THREE.CatmullRomCurve3(points.map((p) => new THREE.Vector3(...p)));
741
+ return new THREE.TubeGeometry(curve, seg, radius, radial, false);
742
+ }
743
+ function leafGeo(len = 1, wide = .34, thick = .045) {
744
+ const s = new THREE.Shape();
745
+ s.moveTo(0, 0);
746
+ s.bezierCurveTo(wide * .8, len * .18, wide, len * .55, wide * .18, len);
747
+ s.bezierCurveTo(-wide * .18, len, -wide, len * .55, -wide * .8, len * .18);
748
+ s.closePath();
749
+ return new THREE.ExtrudeGeometry(s, {
750
+ depth: thick,
751
+ bevelEnabled: true,
752
+ bevelSize: thick * .4,
753
+ bevelThickness: thick * .4,
754
+ bevelSegments: 1,
755
+ curveSegments: 5
756
+ });
757
+ }
758
+ function transform(pos = [
759
+ 0,
760
+ 0,
761
+ 0
762
+ ], rot = [
763
+ 0,
764
+ 0,
765
+ 0
766
+ ], scale = [
767
+ 1,
768
+ 1,
769
+ 1
770
+ ]) {
771
+ const m = new THREE.Matrix4();
772
+ const q = new THREE.Quaternion().setFromEuler(new THREE.Euler(rot[0], rot[1], rot[2]));
773
+ m.compose(new THREE.Vector3(pos[0], pos[1], pos[2]), q, new THREE.Vector3(scale[0], scale[1], scale[2]));
774
+ return m;
775
+ }
776
+ function normalizeGeo(g) {
777
+ const src = g.index ? g.toNonIndexed() : g.clone();
778
+ const out = new THREE.BufferGeometry();
779
+ const p = src.getAttribute("position");
780
+ out.setAttribute("position", p.clone());
781
+ out.setAttribute("normal", src.getAttribute("normal") ? src.getAttribute("normal").clone() : new THREE.Float32BufferAttribute(new Float32Array(p.count * 3), 3));
782
+ const uv = src.getAttribute("uv");
783
+ out.setAttribute("uv", uv ? uv.clone() : new THREE.Float32BufferAttribute(new Float32Array(p.count * 2), 2));
784
+ if (src !== g) src.dispose();
785
+ return out;
786
+ }
787
+ const DETAIL_MATERIALS = /* @__PURE__ */ new Set([
788
+ "gold",
789
+ "bronze",
790
+ "bronzeD",
791
+ "wood",
792
+ "glass",
793
+ "ridge",
794
+ "dark",
795
+ "hedge",
796
+ "waterFoam",
797
+ "leaf"
798
+ ]);
799
+ var Batch = class {
800
+ constructor(zone = 40) {
801
+ this.groups = /* @__PURE__ */ new Map();
802
+ this.zone = zone;
803
+ }
804
+ add(geo, mat, matrix, opts = {}) {
805
+ const g = normalizeGeo(geo);
806
+ g.applyMatrix4(matrix);
807
+ const e = matrix.elements;
808
+ const zx = Math.floor(e[12] / this.zone), zz = Math.floor(e[14] / this.zone);
809
+ const key = (opts.noZone ? "all" : `${zx}_${zz}`) + "|" + mat.name;
810
+ if (!this.groups.has(key)) this.groups.set(key, {
811
+ mat,
812
+ list: [],
813
+ noShadow: false
814
+ });
815
+ const grp = this.groups.get(key);
816
+ grp.list.push(g);
817
+ if (opts.noShadow) grp.noShadow = true;
818
+ geo.dispose && opts.dispose !== false && geo.dispose();
819
+ }
820
+ build(parent) {
821
+ let meshes = 0, tris = 0;
822
+ this.groups.forEach((grp) => {
823
+ if (!grp.list.length) return;
824
+ const merged = grp.list.length === 1 ? grp.list[0] : mergeGeometries(grp.list, false);
825
+ if (!merged) return;
826
+ const mesh = new THREE.Mesh(merged, grp.mat);
827
+ mesh.castShadow = !grp.noShadow;
828
+ mesh.receiveShadow = true;
829
+ mesh.matrixAutoUpdate = false;
830
+ mesh.name = "batch_" + grp.mat.name;
831
+ merged.computeBoundingSphere();
832
+ const sph = merged.boundingSphere;
833
+ mesh.userData.center = sph.center.clone();
834
+ mesh.userData.radius = sph.radius;
835
+ mesh.userData.detail = DETAIL_MATERIALS.has(grp.mat.name);
836
+ parent.add(mesh);
837
+ meshes++;
838
+ tris += merged.getAttribute("position").count / 3;
839
+ grp.list.forEach((g, i) => {
840
+ if (g !== merged) g.dispose();
841
+ });
842
+ });
843
+ this.groups.clear();
844
+ return {
845
+ meshes,
846
+ tris
847
+ };
848
+ }
849
+ };
850
+ function B(batch, mat, geo, pos, rot = [
851
+ 0,
852
+ 0,
853
+ 0
854
+ ], scale = [
855
+ 1,
856
+ 1,
857
+ 1
858
+ ], opts) {
859
+ batch.add(geo, mat, transform(pos, rot, scale), opts);
860
+ }
861
+ function box(batch, mat, w, h, d, pos, rot, opts) {
862
+ B(batch, mat, boxGeo(w, h, d, opts?.uv ?? .5), pos, rot, [
863
+ 1,
864
+ 1,
865
+ 1
866
+ ], opts);
867
+ }
868
+ function cbox(batch, mat, w, h, d, pos, rot, bevel = .04, opts) {
869
+ B(batch, mat, chamferBoxGeo(w, h, d, bevel, opts?.uv ?? .5), pos, rot, [
870
+ 1,
871
+ 1,
872
+ 1
873
+ ], opts);
874
+ }
875
+ function cyl(batch, mat, r1, r2, h, pos, seg = 16, rot, opts) {
876
+ B(batch, mat, new THREE.CylinderGeometry(r2, r1, h, seg, 1), pos, rot, [
877
+ 1,
878
+ 1,
879
+ 1
880
+ ], opts);
881
+ }
882
+ function torus(batch, mat, r, tubeR, pos, arc = Math.PI * 2, rot, opts) {
883
+ B(batch, mat, new THREE.TorusGeometry(r, tubeR, 6, Math.max(12, Math.round(arc * 10)), arc), pos, rot, [
884
+ 1,
885
+ 1,
886
+ 1
887
+ ], opts);
888
+ }
889
+ function sphere(batch, mat, r, pos, scale, wseg = 10, hseg = 7, opts) {
890
+ B(batch, mat, new THREE.SphereGeometry(r, wseg, hseg), pos, [
891
+ 0,
892
+ 0,
893
+ 0
894
+ ], scale || [
895
+ 1,
896
+ 1,
897
+ 1
898
+ ], opts);
899
+ }
900
+ // modules/world/content/yuanmingyuan/arch.js
901
+ function column(batch, M, o = {}) {
902
+ const { x = 0, y = 0, z = 0, h = 6, r = .48, mat = M.marble, ruin = 0, seed = 1 } = o;
903
+ const rnd = mulberry32(seed * 977 + 7);
904
+ const baseH = h * .055;
905
+ cbox(batch, mat, r * 2.75, baseH * .55, r * 2.75, [
906
+ x,
907
+ y + baseH * .275,
908
+ z
909
+ ], [
910
+ 0,
911
+ 0,
912
+ 0
913
+ ], .025);
914
+ cyl(batch, mat, r * 1.28, r * 1.16, baseH * .45, [
915
+ x,
916
+ y + baseH * .78,
917
+ z
918
+ ], 20);
919
+ torus(batch, mat, r * 1.12, r * .075, [
920
+ x,
921
+ y + baseH,
922
+ z
923
+ ], Math.PI * 2, [
924
+ Math.PI / 2,
925
+ 0,
926
+ 0
927
+ ]);
928
+ const capH = h * .135;
929
+ const shaftH = h - baseH - capH;
930
+ const cut = ruin > 0 ? .35 + rnd() * .45 : 1;
931
+ const sh = shaftH * cut;
932
+ B(batch, mat, flutedShaftGeo(sh, r, r * .87, 20, r * .09, 8, 48), [
933
+ x,
934
+ y + baseH,
935
+ z
936
+ ]);
937
+ if (ruin > 0 && cut < .98) {
938
+ for (let i = 0; i < 5; i++) {
939
+ const a = rnd() * Math.PI * 2;
940
+ cbox(batch, M.stone, r * (.35 + rnd() * .5), .12 + rnd() * .2, r * .5, [
941
+ x + Math.cos(a) * r * .6,
942
+ y + baseH + sh + rnd() * .1,
943
+ z + Math.sin(a) * r * .6
944
+ ], [
945
+ 0,
946
+ a,
947
+ rnd() * .3
948
+ ], .02);
949
+ }
950
+ return;
951
+ }
952
+ const cy = y + baseH + shaftH;
953
+ cyl(batch, mat, r * .9, r * 1.18, capH * .62, [
954
+ x,
955
+ cy + capH * .31,
956
+ z
957
+ ], 18);
958
+ for (let i = 0; i < 8; i++) {
959
+ const a = i / 8 * Math.PI * 2;
960
+ B(batch, mat, leafGeo(capH * .72, r * .3, .028), [
961
+ x + Math.cos(a) * r * .98,
962
+ cy + capH * .06,
963
+ z + Math.sin(a) * r * .98
964
+ ], [
965
+ 0,
966
+ -a + Math.PI / 2,
967
+ .14
968
+ ]);
969
+ }
970
+ for (let i = 0; i < 4; i++) {
971
+ const a = Math.PI / 4 + i / 4 * Math.PI * 2;
972
+ torus(batch, mat, r * .23, r * .055, [
973
+ x + Math.cos(a) * r * .8,
974
+ cy + capH * .7,
975
+ z + Math.sin(a) * r * .8
976
+ ], Math.PI * 1.45, [
977
+ 0,
978
+ -a,
979
+ Math.PI / 2
980
+ ]);
981
+ }
982
+ cbox(batch, mat, r * 2.5, capH * .17, r * 2.5, [
983
+ x,
984
+ cy + capH * .92,
985
+ z
986
+ ], [
987
+ 0,
988
+ Math.PI / 4,
989
+ 0
990
+ ], .02);
991
+ cbox(batch, mat, r * 2.2, capH * .1, r * 2.2, [
992
+ x,
993
+ cy + capH * 1.02,
994
+ z
995
+ ], [
996
+ 0,
997
+ 0,
998
+ 0
999
+ ], .015);
1000
+ }
1001
+ function cornice(batch, M, o) {
1002
+ const { x, y, z, w, d, mat = M.stone, dentils = true, layers = 3 } = o;
1003
+ for (let i = 0; i < layers; i++) {
1004
+ const e = .06 * i;
1005
+ cbox(batch, mat, w + e * 2, .13, d + e * 2, [
1006
+ x,
1007
+ y + i * .17,
1008
+ z
1009
+ ], [
1010
+ 0,
1011
+ 0,
1012
+ 0
1013
+ ], .022);
1014
+ }
1015
+ if (dentils) {
1016
+ const n = Math.floor(w / .52);
1017
+ for (let i = 0; i < n; i++) {
1018
+ const px = x - w / 2 + (i + .5) * (w / n);
1019
+ box(batch, mat, .19, .2, .15, [
1020
+ px,
1021
+ y + layers * .17 - .02,
1022
+ z + d / 2 + .03
1023
+ ]);
1024
+ box(batch, mat, .19, .2, .15, [
1025
+ px,
1026
+ y + layers * .17 - .02,
1027
+ z - d / 2 - .03
1028
+ ]);
1029
+ }
1030
+ }
1031
+ }
1032
+ function balustrade(batch, M, o) {
1033
+ const { x1, z1, x2, z2, y = 0, mat = M.marble, h = 1.05, spacing = 1.15 } = o;
1034
+ const len = Math.hypot(x2 - x1, z2 - z1);
1035
+ const ang = Math.atan2(z2 - z1, x2 - x1);
1036
+ const cx = (x1 + x2) / 2, cz = (z1 + z2) / 2;
1037
+ const rot = [
1038
+ 0,
1039
+ -ang,
1040
+ 0
1041
+ ];
1042
+ cbox(batch, mat, len, .16, .42, [
1043
+ cx,
1044
+ y + .08,
1045
+ cz
1046
+ ], rot, .025);
1047
+ cbox(batch, mat, len, .13, .36, [
1048
+ cx,
1049
+ y + h,
1050
+ cz
1051
+ ], rot, .025);
1052
+ const n = Math.max(2, Math.floor(len / spacing));
1053
+ for (let i = 0; i <= n; i++) {
1054
+ const t = i / n;
1055
+ const px = x1 + (x2 - x1) * t, pz = z1 + (z2 - z1) * t;
1056
+ if (i % 4 === 0) {
1057
+ cbox(batch, mat, .28, h + .2, .28, [
1058
+ px,
1059
+ y + (h + .2) / 2,
1060
+ pz
1061
+ ], rot, .025);
1062
+ sphere(batch, mat, .13, [
1063
+ px,
1064
+ y + h + .28,
1065
+ pz
1066
+ ], [
1067
+ 1,
1068
+ 1.2,
1069
+ 1
1070
+ ], 8, 6);
1071
+ } else B(batch, mat, new THREE.LatheGeometry([
1072
+ new THREE.Vector2(.1, 0),
1073
+ new THREE.Vector2(.15, .12),
1074
+ new THREE.Vector2(.095, .28),
1075
+ new THREE.Vector2(.17, .48),
1076
+ new THREE.Vector2(.1, .68),
1077
+ new THREE.Vector2(.13, .82)
1078
+ ], 9), [
1079
+ px,
1080
+ y + .16,
1081
+ pz
1082
+ ]);
1083
+ }
1084
+ }
1085
+ function archedNiche(batch, M, o) {
1086
+ const { x, y, z, w = 2.2, h = 4.2, d = .5, mat = M.stone, shell = true, ry = 0 } = o;
1087
+ const co = Math.cos(ry), si = Math.sin(ry);
1088
+ const P = (dx, dy, dz = 0) => [
1089
+ x + dx * co + dz * si,
1090
+ y + dy,
1091
+ z - dx * si + dz * co
1092
+ ];
1093
+ const spring = h - w * .5;
1094
+ for (const s of [-1, 1]) {
1095
+ cbox(batch, mat, .28, spring, d * .55, P(s * w * .5, spring / 2, d * .1), [
1096
+ 0,
1097
+ ry,
1098
+ 0
1099
+ ], .03);
1100
+ cbox(batch, mat, .4, .22, d * .7, P(s * w * .5, .11, d * .1), [
1101
+ 0,
1102
+ ry,
1103
+ 0
1104
+ ], .03);
1105
+ }
1106
+ torus(batch, mat, w * .5, .15, P(0, spring, d * .12), Math.PI, [
1107
+ 0,
1108
+ ry,
1109
+ 0
1110
+ ]);
1111
+ torus(batch, mat, w * .5 - .24, .055, P(0, spring, d * .16), Math.PI, [
1112
+ 0,
1113
+ ry,
1114
+ 0
1115
+ ]);
1116
+ cbox(batch, M.marble, .42, .62, d * .62, P(0, h - .12, d * .18), [
1117
+ 0,
1118
+ ry,
1119
+ 0
1120
+ ], .035);
1121
+ box(batch, M.marbleD, w * .78, h * .86, .12, P(0, h * .43, -d * .12), [
1122
+ 0,
1123
+ ry,
1124
+ 0
1125
+ ]);
1126
+ if (shell) {
1127
+ const g = shellGeo(w * .38, 13, 32, 9);
1128
+ B(batch, M.marbleD, g, P(0, spring + w * .32, -d * .05), [
1129
+ 0,
1130
+ ry,
1131
+ 0
1132
+ ]);
1133
+ for (let i = 0; i <= 12; i++) {
1134
+ const a = i / 12 * Math.PI;
1135
+ const r = w * .36;
1136
+ B(batch, M.marble, tube([
1137
+ [
1138
+ 0,
1139
+ 0,
1140
+ 0
1141
+ ],
1142
+ [
1143
+ Math.cos(a) * r * .5,
1144
+ Math.sin(a) * r * .36,
1145
+ -r * .2
1146
+ ],
1147
+ [
1148
+ Math.cos(a) * r,
1149
+ Math.sin(a) * r * .72,
1150
+ -r * .52
1151
+ ]
1152
+ ], .022, 6, 4), P(0, spring + w * .32, -d * .05), [
1153
+ 0,
1154
+ ry,
1155
+ 0
1156
+ ]);
1157
+ }
1158
+ }
1159
+ cbox(batch, mat, w * 1.05, .34, d * .8, P(0, .17, d * .16), [
1160
+ 0,
1161
+ ry,
1162
+ 0
1163
+ ], .035);
1164
+ for (const s of [-1, 1]) B(batch, M.marble, leafGeo(.8, .22, .04), P(s * w * .36, .4, d * .2), [
1165
+ 0,
1166
+ ry,
1167
+ s * .5
1168
+ ]);
1169
+ }
1170
+ function hipRoof(batch, M, o) {
1171
+ const { x, y, z, w, d, h = 3.2, mat = M.roof, ridgeMat = M.ridge, ornaments = true } = o;
1172
+ const NX = 26, NZ = 16;
1173
+ const pos = [], uv = [], idx = [];
1174
+ const ridgeHalf = Math.max(1, w / 2 - d / 2);
1175
+ for (let i = 0; i <= NZ; i++) for (let j = 0; j <= NX; j++) {
1176
+ const px = (j / NX - .5) * w, pz = (i / NZ - .5) * d;
1177
+ const tz = Math.abs(pz) / (d / 2);
1178
+ const tx = Math.max(0, (Math.abs(px) - ridgeHalf) / (d / 2));
1179
+ const t = Math.max(0, 1 - Math.max(tz, tx));
1180
+ let py = h * Math.pow(t, 1.75);
1181
+ py += .6 * Math.pow(Math.abs(px) / (w / 2), 4) * Math.pow(Math.abs(pz) / (d / 2), 3) * (1 - t);
1182
+ pos.push(px, py, pz);
1183
+ uv.push(j / NX * w * .32, i / NZ * d * .45);
1184
+ }
1185
+ for (let i = 0; i < NZ; i++) for (let j = 0; j < NX; j++) {
1186
+ const a = i * 27 + j, b = a + NX + 1;
1187
+ idx.push(a, a + 1, b, b, a + 1, b + 1);
1188
+ }
1189
+ const g = new THREE.BufferGeometry();
1190
+ g.setAttribute("position", new THREE.Float32BufferAttribute(pos, 3));
1191
+ g.setAttribute("uv", new THREE.Float32BufferAttribute(uv, 2));
1192
+ g.setIndex(idx);
1193
+ g.computeVertexNormals();
1194
+ B(batch, mat, g, [
1195
+ x,
1196
+ y,
1197
+ z
1198
+ ], [
1199
+ 0,
1200
+ 0,
1201
+ 0
1202
+ ], [
1203
+ 1,
1204
+ 1,
1205
+ 1
1206
+ ], { noZone: true });
1207
+ cbox(batch, M.wood, w + .5, .28, d + .5, [
1208
+ x,
1209
+ y - .06,
1210
+ z
1211
+ ], [
1212
+ 0,
1213
+ 0,
1214
+ 0
1215
+ ], .04, { noZone: true });
1216
+ B(batch, ridgeMat, new THREE.CylinderGeometry(.19, .19, ridgeHalf * 2 + .6, 8), [
1217
+ x,
1218
+ y + h + .1,
1219
+ z
1220
+ ], [
1221
+ 0,
1222
+ 0,
1223
+ Math.PI / 2
1224
+ ], [
1225
+ 1,
1226
+ 1,
1227
+ 1
1228
+ ], { noZone: true });
1229
+ for (const sx of [-1, 1]) for (const sz of [-1, 1]) {
1230
+ B(batch, ridgeMat, tube([
1231
+ [
1232
+ x + sx * ridgeHalf,
1233
+ y + h + .1,
1234
+ z
1235
+ ],
1236
+ [
1237
+ x + sx * (ridgeHalf + (d / 2 - ridgeHalf) * .45),
1238
+ y + h * .62,
1239
+ z + sz * d * .24
1240
+ ],
1241
+ [
1242
+ x + sx * w / 2,
1243
+ y + .42,
1244
+ z + sz * d / 2
1245
+ ]
1246
+ ], .105, 12, 6), [
1247
+ 0,
1248
+ 0,
1249
+ 0
1250
+ ], [
1251
+ 0,
1252
+ 0,
1253
+ 0
1254
+ ], [
1255
+ 1,
1256
+ 1,
1257
+ 1
1258
+ ], { noZone: true });
1259
+ if (ornaments) {
1260
+ B(batch, M.stone2, tube([
1261
+ [
1262
+ x + sx * w / 2,
1263
+ y + .5,
1264
+ z + sz * d / 2
1265
+ ],
1266
+ [
1267
+ x + sx * (w / 2 + .5),
1268
+ y + .85,
1269
+ z + sz * (d / 2 + .42)
1270
+ ],
1271
+ [
1272
+ x + sx * (w / 2 + .75),
1273
+ y + 1.55,
1274
+ z + sz * (d / 2 + .3)
1275
+ ]
1276
+ ], .11, 10, 6), [
1277
+ 0,
1278
+ 0,
1279
+ 0
1280
+ ], [
1281
+ 0,
1282
+ 0,
1283
+ 0
1284
+ ], [
1285
+ 1,
1286
+ 1,
1287
+ 1
1288
+ ], { noZone: true });
1289
+ sphere(batch, M.stone2, .19, [
1290
+ x + sx * (w / 2 + .75),
1291
+ y + 1.55,
1292
+ z + sz * (d / 2 + .3)
1293
+ ], [
1294
+ 1,
1295
+ .7,
1296
+ 1.3
1297
+ ], 8, 6, { noZone: true });
1298
+ }
1299
+ }
1300
+ }
1301
+ function baroqueGable(batch, M, o) {
1302
+ const { x, y, z, w, h, d = .9, mat = M.stone, broken = true } = o;
1303
+ const s = new THREE.Shape();
1304
+ const hw = w / 2;
1305
+ s.moveTo(-hw, 0);
1306
+ s.lineTo(hw, 0);
1307
+ s.lineTo(hw, h * .18);
1308
+ s.bezierCurveTo(hw * .78, h * .5, hw * .55, h * .62, hw * (broken ? .16 : .1), h * .95);
1309
+ s.bezierCurveTo(hw * .06, h * 1.02, -hw * .06, h * 1.02, -hw * (broken ? .16 : .1), h * .95);
1310
+ s.bezierCurveTo(-hw * .55, h * .62, -hw * .78, h * .5, -hw, h * .18);
1311
+ s.closePath();
1312
+ const g = new THREE.ExtrudeGeometry(s, {
1313
+ depth: d,
1314
+ bevelEnabled: true,
1315
+ bevelSize: .06,
1316
+ bevelThickness: .06,
1317
+ bevelSegments: 1,
1318
+ curveSegments: 12
1319
+ });
1320
+ g.translate(0, 0, -d / 2);
1321
+ B(batch, mat, g, [
1322
+ x,
1323
+ y,
1324
+ z
1325
+ ]);
1326
+ for (const sx of [-1, 1]) {
1327
+ torus(batch, M.marble, .48, .14, [
1328
+ x + sx * hw * .72,
1329
+ y + h * .42,
1330
+ z + d / 2 + .06
1331
+ ], Math.PI * 1.6, [
1332
+ 0,
1333
+ 0,
1334
+ sx > 0 ? 0 : Math.PI
1335
+ ]);
1336
+ B(batch, M.marble, leafGeo(1.15, .35, .06), [
1337
+ x + sx * hw * .42,
1338
+ y + h * .38,
1339
+ z + d / 2 + .08
1340
+ ], [
1341
+ 0,
1342
+ 0,
1343
+ sx * -.7
1344
+ ]);
1345
+ }
1346
+ rosette(batch, M, x, y + h * .52, z + d / 2 + .12, .42);
1347
+ }
1348
+ function rosette(batch, M, x, y, z, r = .4, mat = M.marble) {
1349
+ sphere(batch, mat, r * .42, [
1350
+ x,
1351
+ y,
1352
+ z + r * .18
1353
+ ], [
1354
+ 1,
1355
+ 1,
1356
+ .55
1357
+ ], 10, 7);
1358
+ for (let i = 0; i < 10; i++) {
1359
+ const a = i / 10 * Math.PI * 2;
1360
+ B(batch, mat, leafGeo(r * .75, r * .24, .035), [
1361
+ x + Math.cos(a) * r * .36,
1362
+ y + Math.sin(a) * r * .36,
1363
+ z
1364
+ ], [
1365
+ 0,
1366
+ 0,
1367
+ a - Math.PI / 2
1368
+ ]);
1369
+ }
1370
+ }
1371
+ function reliefPanel(batch, M, o) {
1372
+ const { x, y, z, w = 2.4, h = 3.4, d = .42, ry = 0, mat = M.stone } = o;
1373
+ const co = Math.cos(ry), si = Math.sin(ry);
1374
+ const P = (dx, dy, dz = 0) => [
1375
+ x + dx * co + dz * si,
1376
+ y + dy,
1377
+ z - dx * si + dz * co
1378
+ ];
1379
+ cbox(batch, mat, w, h, d, P(0, h / 2, 0), [
1380
+ 0,
1381
+ ry,
1382
+ 0
1383
+ ], .055);
1384
+ cbox(batch, M.marble, w - .34, h - .5, .1, P(0, h / 2, d / 2 + .04), [
1385
+ 0,
1386
+ ry,
1387
+ 0
1388
+ ], .03);
1389
+ const fz = d / 2 + .12;
1390
+ rosette(batch, M, ...P(0, h * .62, fz), w * .17);
1391
+ for (const s of [-1, 1]) {
1392
+ B(batch, M.marble, tube([
1393
+ [
1394
+ 0,
1395
+ -h * .28,
1396
+ 0
1397
+ ],
1398
+ [
1399
+ s * w * .16,
1400
+ -h * .05,
1401
+ .05
1402
+ ],
1403
+ [
1404
+ s * w * .3,
1405
+ h * .16,
1406
+ .08
1407
+ ],
1408
+ [
1409
+ s * w * .2,
1410
+ h * .36,
1411
+ .05
1412
+ ],
1413
+ [
1414
+ s * w * .08,
1415
+ h * .3,
1416
+ .02
1417
+ ]
1418
+ ], .075, 12, 5), P(0, h * .45, fz), [
1419
+ 0,
1420
+ ry,
1421
+ 0
1422
+ ]);
1423
+ for (let i = 0; i < 5; i++) B(batch, M.marble, leafGeo(.5, .16, .035), P(s * (w * .13 + i * w * .045), h * (.22 + i % 2 * .18), fz + .02), [
1424
+ 0,
1425
+ ry,
1426
+ s * (.5 + i * .22)
1427
+ ]);
1428
+ }
1429
+ for (let i = 0; i < 9; i++) cbox(batch, M.marbleD, w / 11, .09, .09, P(-w * .4 + i * (w * .1), h * .1, fz), [
1430
+ 0,
1431
+ ry,
1432
+ 0
1433
+ ], .015);
1434
+ }
1435
+ function stair(batch, M, o) {
1436
+ const { x, y, z, w, steps = 6, rise = .19, run = .42, mat = M.stone, ry = 0 } = o;
1437
+ const co = Math.cos(ry), si = Math.sin(ry);
1438
+ for (let i = 0; i < steps; i++) {
1439
+ const h = rise * (steps - i);
1440
+ cbox(batch, mat, w, h, run * 1.04, [
1441
+ x + si * ((i + .5) * run),
1442
+ y + h / 2,
1443
+ z + co * ((i + .5) * run)
1444
+ ], [
1445
+ 0,
1446
+ ry,
1447
+ 0
1448
+ ], .02);
1449
+ }
1450
+ }
1451
+ function archWindow(batch, M, o) {
1452
+ const { x, y, z, w = 1.5, h = 2.8, ry = 0, mat = M.marble, pediment = true } = o;
1453
+ const co = Math.cos(ry), si = Math.sin(ry);
1454
+ const P = (dx, dy, dz = 0) => [
1455
+ x + dx * co + dz * si,
1456
+ y + dy,
1457
+ z - dx * si + dz * co
1458
+ ];
1459
+ const spring = h - w / 2;
1460
+ box(batch, M.dark, w * .92, h * .94, .1, P(0, h / 2, .06), [
1461
+ 0,
1462
+ ry,
1463
+ 0
1464
+ ]);
1465
+ box(batch, M.glass, w * .86, h * .9, .06, P(0, h / 2, .14), [
1466
+ 0,
1467
+ ry,
1468
+ 0
1469
+ ], { noShadow: true });
1470
+ for (const s of [-1, 1]) cbox(batch, mat, .16, spring, .24, P(s * w * .5, spring / 2, .18), [
1471
+ 0,
1472
+ ry,
1473
+ 0
1474
+ ], .025);
1475
+ torus(batch, mat, w * .5, .12, P(0, spring, .2), Math.PI, [
1476
+ 0,
1477
+ ry,
1478
+ 0
1479
+ ]);
1480
+ for (let i = 1; i < 3; i++) box(batch, mat, .055, spring, .08, P(-w / 2 + i * w / 3, spring / 2, .21), [
1481
+ 0,
1482
+ ry,
1483
+ 0
1484
+ ]);
1485
+ box(batch, mat, w * .96, .07, .08, P(0, spring * .56, .21), [
1486
+ 0,
1487
+ ry,
1488
+ 0
1489
+ ]);
1490
+ cbox(batch, mat, w * 1.16, .22, .36, P(0, .11, .2), [
1491
+ 0,
1492
+ ry,
1493
+ 0
1494
+ ], .03);
1495
+ if (pediment) {
1496
+ const sh = new THREE.Shape();
1497
+ sh.moveTo(-w * .7, 0);
1498
+ sh.lineTo(w * .7, 0);
1499
+ sh.lineTo(0, h * .22);
1500
+ sh.closePath();
1501
+ B(batch, mat, new THREE.ExtrudeGeometry(sh, {
1502
+ depth: .22,
1503
+ bevelEnabled: false
1504
+ }), P(0, h + .16, .14), [
1505
+ 0,
1506
+ ry,
1507
+ 0
1508
+ ]);
1509
+ rosette(batch, M, ...P(0, h + .25, .36), .14);
1510
+ }
1511
+ }
1512
+ function basinCurb(batch, M, o) {
1513
+ const { x, z, rx, rz, y = 0, h = .62, mat = M.stone, seg = 48, gap = 0 } = o;
1514
+ for (let i = 0; i < seg; i++) {
1515
+ if (gap && i % seg < gap) continue;
1516
+ const a = i / seg * Math.PI * 2;
1517
+ const a2 = (i + 1) / seg * Math.PI * 2;
1518
+ const len = Math.hypot((Math.cos(a2) - Math.cos(a)) * rx, (Math.sin(a2) - Math.sin(a)) * rz) * 1.06;
1519
+ const px = x + Math.cos((a + a2) / 2) * rx, pz = z + Math.sin((a + a2) / 2) * rz;
1520
+ cbox(batch, mat, len, h, .62, [
1521
+ px,
1522
+ y + h / 2,
1523
+ pz
1524
+ ], [
1525
+ 0,
1526
+ -((a + a2) / 2) + Math.PI / 2,
1527
+ 0
1528
+ ], .035);
1529
+ cbox(batch, M.marbleD, len * .94, .1, .72, [
1530
+ px,
1531
+ y + h + .05,
1532
+ pz
1533
+ ], [
1534
+ 0,
1535
+ -((a + a2) / 2) + Math.PI / 2,
1536
+ 0
1537
+ ], .02);
1538
+ }
1539
+ B(batch, M.stone2, new THREE.CircleGeometry(Math.min(rx, rz) * .98, seg), [
1540
+ x,
1541
+ y - .22,
1542
+ z
1543
+ ], [
1544
+ -Math.PI / 2,
1545
+ 0,
1546
+ 0
1547
+ ], [
1548
+ rx / Math.min(rx, rz),
1549
+ rz / Math.min(rx, rz),
1550
+ 1
1551
+ ]);
1552
+ }
1553
+ function lionHead(batch, M, o) {
1554
+ const { x, y, z, ry = 0, s = 1, mat = M.stone } = o;
1555
+ sphere(batch, mat, .42 * s, [
1556
+ x,
1557
+ y,
1558
+ z
1559
+ ], [
1560
+ 1,
1561
+ .95,
1562
+ .72
1563
+ ], 12, 9);
1564
+ sphere(batch, mat, .24 * s, [
1565
+ x,
1566
+ y - .12 * s,
1567
+ z + .32 * s
1568
+ ], [
1569
+ 1,
1570
+ .7,
1571
+ 1
1572
+ ], 10, 7);
1573
+ sphere(batch, M.dark, .11 * s, [
1574
+ x,
1575
+ y - .14 * s,
1576
+ z + .5 * s
1577
+ ], [
1578
+ 1,
1579
+ .8,
1580
+ .5
1581
+ ], 8, 6);
1582
+ for (let i = 0; i < 12; i++) {
1583
+ const a = i / 12 * Math.PI * 2;
1584
+ sphere(batch, mat, .15 * s, [
1585
+ x + Math.cos(a) * .38 * s,
1586
+ y + Math.sin(a) * .38 * s,
1587
+ z - .1 * s
1588
+ ], [
1589
+ 1,
1590
+ 1,
1591
+ .65
1592
+ ], 7, 5);
1593
+ }
1594
+ for (const sx of [-1, 1]) sphere(batch, mat, .11 * s, [
1595
+ x + sx * .24 * s,
1596
+ y + .24 * s,
1597
+ z + .08 * s
1598
+ ], [
1599
+ 1,
1600
+ .7,
1601
+ 1
1602
+ ], 7, 5);
1603
+ }
1604
+ function zodiacHead(batch, M, o) {
1605
+ const { x, y, z, kind = 0, ry = 0, s = 1 } = o;
1606
+ const mat = M.bronze;
1607
+ const co = Math.cos(ry), si = Math.sin(ry);
1608
+ const P = (dx, dy, dz) => [
1609
+ x + dx * co + dz * si,
1610
+ y + dy,
1611
+ z - dx * si + dz * co
1612
+ ];
1613
+ sphere(batch, mat, .36 * s, P(0, 0, 0), [
1614
+ 1,
1615
+ 1.1,
1616
+ .95
1617
+ ], 12, 9);
1618
+ sphere(batch, M.bronzeD, .075 * s, P(-.17, .1, .29), [
1619
+ 1,
1620
+ 1,
1621
+ 1
1622
+ ], 8, 6);
1623
+ sphere(batch, M.bronzeD, .075 * s, P(.17, .1, .29), [
1624
+ 1,
1625
+ 1,
1626
+ 1
1627
+ ], 8, 6);
1628
+ const snout = (len, wide, drop = -.1) => {
1629
+ sphere(batch, mat, wide * s, P(0, drop * s, (.3 + len * .35) * s), [
1630
+ 1.05,
1631
+ .72,
1632
+ 1 + len * .6
1633
+ ], 10, 7);
1634
+ };
1635
+ switch (kind) {
1636
+ case 0:
1637
+ snout(.7, .16, -.14);
1638
+ for (const sx of [-1, 1]) sphere(batch, mat, .16 * s, P(sx * .32, .3, -.02), [
1639
+ 1,
1640
+ 1,
1641
+ .5
1642
+ ], 9, 6);
1643
+ break;
1644
+ case 1:
1645
+ snout(.8, .24, -.16);
1646
+ for (const sx of [-1, 1]) B(batch, mat, tube([
1647
+ [
1648
+ 0,
1649
+ 0,
1650
+ 0
1651
+ ],
1652
+ [
1653
+ sx * .4,
1654
+ .25,
1655
+ 0
1656
+ ],
1657
+ [
1658
+ sx * .62,
1659
+ .5,
1660
+ .05
1661
+ ]
1662
+ ], .075 * s, 8, 5), P(sx * .26, .25, -.02));
1663
+ break;
1664
+ case 2:
1665
+ snout(.6, .23, -.15);
1666
+ for (const sx of [-1, 1]) sphere(batch, mat, .16 * s, P(sx * .28, .34, -.02), [
1667
+ 1,
1668
+ 1,
1669
+ .55
1670
+ ], 8, 6);
1671
+ for (let i = 0; i < 5; i++) cbox(batch, M.bronzeD, .05 * s, .12 * s, .04 * s, P((i - 2) * .13, .42, .26), [
1672
+ 0,
1673
+ ry,
1674
+ 0
1675
+ ], .01);
1676
+ break;
1677
+ case 3:
1678
+ snout(.4, .17, -.12);
1679
+ for (const sx of [-1, 1]) sphere(batch, mat, .1 * s, P(sx * .19, .62, -.05), [
1680
+ .7,
1681
+ 2.6,
1682
+ .65
1683
+ ], 8, 7);
1684
+ break;
1685
+ case 4:
1686
+ snout(.85, .2, -.13);
1687
+ for (const sx of [-1, 1]) B(batch, mat, tube([
1688
+ [
1689
+ 0,
1690
+ 0,
1691
+ 0
1692
+ ],
1693
+ [
1694
+ sx * .3,
1695
+ .42,
1696
+ -.1
1697
+ ],
1698
+ [
1699
+ sx * .5,
1700
+ .66,
1701
+ -.22
1702
+ ]
1703
+ ], .06 * s, 8, 5), P(sx * .16, .3, -.08));
1704
+ for (let i = 0; i < 4; i++) B(batch, M.bronzeD, leafGeo(.28 * s, .09 * s, .03 * s), P((i - 1.5) * .16, .36, -.22), [
1705
+ .4,
1706
+ ry,
1707
+ 0
1708
+ ]);
1709
+ break;
1710
+ case 5:
1711
+ snout(.6, .14, -.16);
1712
+ B(batch, mat, tube([
1713
+ [
1714
+ 0,
1715
+ 0,
1716
+ 0
1717
+ ],
1718
+ [
1719
+ 0,
1720
+ .5,
1721
+ -.1
1722
+ ],
1723
+ [
1724
+ .16,
1725
+ .78,
1726
+ .02
1727
+ ]
1728
+ ], .1 * s, 10, 6), P(0, .18, -.1));
1729
+ break;
1730
+ case 6:
1731
+ snout(1, .2, -.22);
1732
+ for (let i = 0; i < 6; i++) B(batch, M.bronzeD, leafGeo(.3 * s, .1 * s, .03 * s), P((i - 2.5) * .12, .4, -.2 - i * .02), [
1733
+ .8,
1734
+ ry,
1735
+ 0
1736
+ ]);
1737
+ for (const sx of [-1, 1]) sphere(batch, mat, .09 * s, P(sx * .22, .48, -.06), [
1738
+ .6,
1739
+ 1.5,
1740
+ .6
1741
+ ], 7, 6);
1742
+ break;
1743
+ case 7:
1744
+ snout(.7, .19, -.16);
1745
+ for (const sx of [-1, 1]) torus(batch, mat, .2 * s, .06 * s, P(sx * .32, .32, -.04), Math.PI * 1.35, [
1746
+ 0,
1747
+ ry,
1748
+ sx * .5
1749
+ ]);
1750
+ break;
1751
+ case 8:
1752
+ snout(.4, .2, -.16);
1753
+ for (const sx of [-1, 1]) sphere(batch, mat, .17 * s, P(sx * .36, .08, 0), [
1754
+ 1,
1755
+ 1,
1756
+ .55
1757
+ ], 9, 6);
1758
+ sphere(batch, M.bronzeD, .25 * s, P(0, -.05, .32), [
1759
+ 1.1,
1760
+ .75,
1761
+ .6
1762
+ ], 10, 7);
1763
+ break;
1764
+ case 9:
1765
+ snout(.35, .13, -.06);
1766
+ for (let i = 0; i < 5; i++) B(batch, M.bronzeD, leafGeo(.26 * s, .1 * s, .03 * s), P((i - 2) * .1, .4, -.05), [
1767
+ .3,
1768
+ ry,
1769
+ (i - 2) * .22
1770
+ ]);
1771
+ sphere(batch, M.bronzeD, .1 * s, P(0, -.28, .3), [
1772
+ 1,
1773
+ 1.2,
1774
+ .7
1775
+ ], 8, 6);
1776
+ break;
1777
+ case 10:
1778
+ snout(.85, .18, -.18);
1779
+ for (const sx of [-1, 1]) sphere(batch, mat, .13 * s, P(sx * .32, .14, -.05), [
1780
+ .7,
1781
+ 1.5,
1782
+ .7
1783
+ ], 8, 6);
1784
+ break;
1785
+ default:
1786
+ snout(.7, .26, -.2);
1787
+ for (const sx of [-1, 1]) B(batch, mat, leafGeo(.3 * s, .13 * s, .04 * s), P(sx * .3, .32, -.04), [
1788
+ 0,
1789
+ ry,
1790
+ sx * .6
1791
+ ]);
1792
+ cyl(batch, M.bronzeD, .12 * s, .12 * s, .06 * s, P(0, -.2, .52), 10);
1793
+ }
1794
+ }
1795
+ // modules/world/content/yuanmingyuan/buildings.js
1796
+ function terrace(b, M, o) {
1797
+ const { x, z, w, d, h = 1.2, steps = true } = o;
1798
+ cbox(b, M.stone2, w, h, d, [
1799
+ x,
1800
+ h / 2 - .12,
1801
+ z
1802
+ ], [
1803
+ 0,
1804
+ 0,
1805
+ 0
1806
+ ], .06);
1807
+ cbox(b, M.marbleD, w + 1.1, .28, d + 1.1, [
1808
+ x,
1809
+ h - .04,
1810
+ z
1811
+ ], [
1812
+ 0,
1813
+ 0,
1814
+ 0
1815
+ ], .04);
1816
+ const jy = h + .104;
1817
+ const nx = Math.min(40, Math.max(4, Math.floor(w / 2.6)));
1818
+ const nz = Math.min(30, Math.max(3, Math.floor(d / 2.6)));
1819
+ for (let i = 0; i <= nx; i++) box(b, M.stone, .045, .012, d + 1, [
1820
+ x - w / 2 + i * w / nx,
1821
+ jy,
1822
+ z
1823
+ ], [
1824
+ 0,
1825
+ 0,
1826
+ 0
1827
+ ], { noShadow: true });
1828
+ for (let j = 0; j <= nz; j++) box(b, M.stone, w + 1, .012, .045, [
1829
+ x,
1830
+ jy + .002,
1831
+ z - d / 2 + j * d / nz
1832
+ ], [
1833
+ 0,
1834
+ 0,
1835
+ 0
1836
+ ], { noShadow: true });
1837
+ if (steps) stair(b, M, {
1838
+ x,
1839
+ y: 0,
1840
+ z: z + d / 2 + .6,
1841
+ w: w * .42,
1842
+ steps: Math.max(3, Math.round(h / .19)),
1843
+ rise: h / Math.max(3, Math.round(h / .19)),
1844
+ run: .44
1845
+ });
1846
+ }
1847
+ function dashuifa(ctx) {
1848
+ const { ruin, rest, M, jets, waters, rubble } = ctx;
1849
+ const b = ruin, X = 40;
1850
+ terrace(b, M, {
1851
+ x: X,
1852
+ z: -2,
1853
+ w: 62,
1854
+ d: 46,
1855
+ h: .55,
1856
+ steps: false
1857
+ });
1858
+ cbox(b, M.stone, 34, 5.6, 2.3, [
1859
+ X,
1860
+ 3.35,
1861
+ -10
1862
+ ], [
1863
+ 0,
1864
+ 0,
1865
+ 0
1866
+ ], .06);
1867
+ [
1868
+ -13.5,
1869
+ -7,
1870
+ 0,
1871
+ 7,
1872
+ 13.5
1873
+ ].forEach((dx, i) => {
1874
+ const w = i === 2 ? 4.6 : 3;
1875
+ archedNiche(b, M, {
1876
+ x: X + dx,
1877
+ y: .55,
1878
+ z: -8.78,
1879
+ w,
1880
+ h: i === 2 ? 4.6 : 3.9,
1881
+ d: .42,
1882
+ ry: 0
1883
+ });
1884
+ });
1885
+ for (let i = 0; i < 6; i++) column(b, M, {
1886
+ x: X + (-16.6 + i * 6.64),
1887
+ y: .55,
1888
+ z: -8.5,
1889
+ h: 5,
1890
+ r: .34,
1891
+ mat: M.marbleD,
1892
+ seed: i + 3
1893
+ });
1894
+ cornice(b, M, {
1895
+ x: X,
1896
+ y: 6.1,
1897
+ z: -10,
1898
+ w: 35,
1899
+ d: 2.8
1900
+ });
1901
+ B(b, M.stone, archWallGeo(13.4, 6.2, 2, [{
1902
+ x: 0,
1903
+ w: 7.6,
1904
+ h: 5.6,
1905
+ arch: true
1906
+ }], .05), [
1907
+ X,
1908
+ 6.55,
1909
+ -10.3
1910
+ ]);
1911
+ torus(b, M.marble, 3.8, .24, [
1912
+ X,
1913
+ 9.35,
1914
+ -9.2
1915
+ ], Math.PI, [
1916
+ 0,
1917
+ 0,
1918
+ 0
1919
+ ]);
1920
+ cbox(b, M.marble, .6, .85, .5, [
1921
+ X,
1922
+ 12.85,
1923
+ -9.2
1924
+ ], [
1925
+ 0,
1926
+ 0,
1927
+ 0
1928
+ ], .04);
1929
+ B(b, M.marbleD, shellGeo(3.5, 15, 40, 12), [
1930
+ X,
1931
+ 9.7,
1932
+ -11.1
1933
+ ]);
1934
+ for (const sx of [-1, 1]) {
1935
+ cbox(b, M.stone, 8.6, 8.4, 2.6, [
1936
+ X + sx * 11.2,
1937
+ 10.75,
1938
+ -10.3
1939
+ ], [
1940
+ 0,
1941
+ 0,
1942
+ 0
1943
+ ], .06);
1944
+ archedNiche(b, M, {
1945
+ x: X + sx * 11.2,
1946
+ y: 7.4,
1947
+ z: -8.95,
1948
+ w: 3.3,
1949
+ h: 4.3,
1950
+ d: .4,
1951
+ ry: 0
1952
+ });
1953
+ rosette(b, M, X + sx * 11.2, 12.8, -8.92, .62);
1954
+ column(b, M, {
1955
+ x: X + sx * 15.6,
1956
+ y: 6.55,
1957
+ z: -8.8,
1958
+ h: 6.5,
1959
+ r: .42,
1960
+ mat: M.marble,
1961
+ ruin: sx > 0 ? 1 : 0,
1962
+ seed: 20 + sx
1963
+ });
1964
+ cornice(b, M, {
1965
+ x: X + sx * 11.2,
1966
+ y: 14.95,
1967
+ z: -10.3,
1968
+ w: 9.2,
1969
+ d: 2.9,
1970
+ dentils: false
1971
+ });
1972
+ cbox(b, M.stone, 5, 9.6, 4.4, [
1973
+ X + sx * 20.5,
1974
+ 5.35,
1975
+ -10.5
1976
+ ], [
1977
+ 0,
1978
+ 0,
1979
+ 0
1980
+ ], .06);
1981
+ archedNiche(b, M, {
1982
+ x: X + sx * 20.5,
1983
+ y: 2,
1984
+ z: -8.25,
1985
+ w: 2.6,
1986
+ h: 4.4,
1987
+ d: .4
1988
+ });
1989
+ cbox(b, M.stone2, 5.3, 1.1 + (sx > 0 ? 0 : 1.8), 4.7, [
1990
+ X + sx * 20.5,
1991
+ 10.6,
1992
+ -10.5
1993
+ ], [
1994
+ 0,
1995
+ 0,
1996
+ 0
1997
+ ], .05);
1998
+ for (let i = 0; i < 4; i++) rosette(b, M, X + sx * (18.8 + i * 1.1), 8.9, -8.2, .22);
1999
+ }
2000
+ baroqueGable(b, M, {
2001
+ x: X,
2002
+ y: 12.75,
2003
+ z: -10.4,
2004
+ w: 15.4,
2005
+ h: 3.3,
2006
+ d: 1.3,
2007
+ broken: true
2008
+ });
2009
+ B(b, M.stone, brokenWallGeo(8, 1.5, 1.9, 41, .9), [
2010
+ 29.3,
2011
+ 15.1,
2012
+ -10.4
2013
+ ]);
2014
+ B(b, M.stone, brokenWallGeo(6, 1.1, 1.9, 43, .9), [
2015
+ 51.6,
2016
+ 15.1,
2017
+ -10.4
2018
+ ]);
2019
+ for (let i = 0; i < 9; i++) {
2020
+ const lx = 26 + i * 3.5;
2021
+ lionHead(b, M, {
2022
+ x: lx,
2023
+ y: 1.5,
2024
+ z: -8.5,
2025
+ s: .82
2026
+ });
2027
+ jets.push({
2028
+ pos: [
2029
+ lx,
2030
+ 1.4,
2031
+ -8
2032
+ ],
2033
+ vel: [
2034
+ 0,
2035
+ .4,
2036
+ 5.6
2037
+ ],
2038
+ n: 8,
2039
+ size: .11,
2040
+ seed: i
2041
+ });
2042
+ }
2043
+ for (let l = 0; l < 3; l++) {
2044
+ const z = -5.4 + l * 2.4, y = .72 - l * .14, w = 26 - l * 1.2;
2045
+ cbox(b, M.marbleD, w, .34, 2.3, [
2046
+ X,
2047
+ y,
2048
+ z
2049
+ ], [
2050
+ 0,
2051
+ 0,
2052
+ 0
2053
+ ], .03);
2054
+ for (let i = 0; i < 9; i++) {
2055
+ const lx = X - w / 2 + 1.2 + i * (w - 2.4) / 8;
2056
+ cbox(b, M.stone2, .55, .18, .4, [
2057
+ lx,
2058
+ y + .24,
2059
+ z + 1
2060
+ ], [
2061
+ 0,
2062
+ 0,
2063
+ 0
2064
+ ], .02);
2065
+ }
2066
+ }
2067
+ basinCurb(b, M, {
2068
+ x: X,
2069
+ z: 12,
2070
+ rx: 15.2,
2071
+ rz: 9.4,
2072
+ y: .62,
2073
+ h: .72,
2074
+ seg: 64
2075
+ });
2076
+ waters.push({
2077
+ x: X,
2078
+ z: 12,
2079
+ rx: 14.7,
2080
+ rz: 8.9,
2081
+ y: .82,
2082
+ kind: "ellipse"
2083
+ });
2084
+ cyl(b, M.stone2, 2.1, 1.8, 1, [
2085
+ X,
2086
+ .65,
2087
+ 12
2088
+ ], 20);
2089
+ cyl(b, M.marble, 1.5, 1.3, .6, [
2090
+ X,
2091
+ 1.45,
2092
+ 12
2093
+ ], 18);
2094
+ for (let i = 0; i < 8; i++) {
2095
+ const a = i / 8 * Math.PI * 2;
2096
+ B(b, M.stone2, tube([
2097
+ [
2098
+ 0,
2099
+ 0,
2100
+ 0
2101
+ ],
2102
+ [
2103
+ Math.cos(a) * .9,
2104
+ .5,
2105
+ Math.sin(a) * .9
2106
+ ],
2107
+ [
2108
+ Math.cos(a) * 1.5,
2109
+ .2,
2110
+ Math.sin(a) * 1.5
2111
+ ]
2112
+ ], .2, 8, 5), [
2113
+ X,
2114
+ 1.7,
2115
+ 12
2116
+ ]);
2117
+ }
2118
+ const deer = (dx, dz, s, ry) => {
2119
+ sphere(b, M.bronze, .66 * s, [
2120
+ X + dx,
2121
+ 2.5 * s + .6,
2122
+ 12 + dz
2123
+ ], [
2124
+ 1.5,
2125
+ .8,
2126
+ .75
2127
+ ], 12, 9);
2128
+ sphere(b, M.bronze, .3 * s, [
2129
+ X + dx,
2130
+ 3 * s + .6,
2131
+ 12 + dz + .75 * s
2132
+ ], [
2133
+ .8,
2134
+ 1,
2135
+ 1.2
2136
+ ], 10, 8);
2137
+ for (const sx of [-1, 1]) for (const sz of [-1, 1]) cyl(b, M.bronze, .08 * s, .045 * s, 1.6 * s, [
2138
+ X + dx + sx * .45 * s,
2139
+ 1.6 * s + .6,
2140
+ 12 + dz + sz * .48 * s
2141
+ ], 7);
2142
+ for (let i = 0; i < 5; i++) B(b, M.bronzeD, tube([
2143
+ [
2144
+ 0,
2145
+ 0,
2146
+ 0
2147
+ ],
2148
+ [
2149
+ Math.sin(i) * .3,
2150
+ .4,
2151
+ 0
2152
+ ],
2153
+ [
2154
+ Math.sin(i) * .62,
2155
+ .82,
2156
+ .1
2157
+ ]
2158
+ ], .05 * s, 7, 4), [
2159
+ X + dx + (i - 2) * .13 * s,
2160
+ 3.25 * s + .6,
2161
+ 12 + dz + .7 * s
2162
+ ]);
2163
+ };
2164
+ deer(-.3, 0, 1, 0);
2165
+ for (const sx of [-1, 1]) {
2166
+ sphere(b, M.bronzeD, .34, [
2167
+ X + sx * 2.6,
2168
+ 2.15,
2169
+ 13.1
2170
+ ], [
2171
+ 1.3,
2172
+ .7,
2173
+ .7
2174
+ ], 10, 8);
2175
+ sphere(b, M.bronzeD, .2, [
2176
+ X + sx * 2.6,
2177
+ 2.4,
2178
+ 13.7
2179
+ ], [
2180
+ .8,
2181
+ .8,
2182
+ 1.2
2183
+ ], 8, 6);
2184
+ for (const s2 of [-1, 1]) for (const s3 of [-1, 1]) cyl(b, M.bronzeD, .055, .04, .9, [
2185
+ X + sx * 2.6 + s2 * .22,
2186
+ 1.65,
2187
+ 13.1 + s3 * .35
2188
+ ], 6);
2189
+ }
2190
+ for (let i = 0; i < 12; i++) {
2191
+ const a = i / 12 * Math.PI * 2;
2192
+ jets.push({
2193
+ pos: [
2194
+ X + Math.cos(a) * 1.4,
2195
+ 2.4,
2196
+ 12 + Math.sin(a) * 1.4
2197
+ ],
2198
+ vel: [
2199
+ Math.cos(a) * 3.2,
2200
+ 5.2,
2201
+ Math.sin(a) * 3.2
2202
+ ],
2203
+ n: 10,
2204
+ size: .1,
2205
+ seed: 40 + i
2206
+ });
2207
+ }
2208
+ for (const sx of [-1, 1]) {
2209
+ const bx = X + sx * 23.5;
2210
+ basinCurb(b, M, {
2211
+ x: bx,
2212
+ z: 12,
2213
+ rx: 5.4,
2214
+ rz: 5.4,
2215
+ y: .62,
2216
+ h: .58,
2217
+ seg: 32
2218
+ });
2219
+ waters.push({
2220
+ x: bx,
2221
+ z: 12,
2222
+ rx: 5.1,
2223
+ rz: 5.1,
2224
+ y: .78,
2225
+ kind: "ellipse"
2226
+ });
2227
+ cyl(b, M.marble, .75, .55, 1.5, [
2228
+ bx,
2229
+ .9,
2230
+ 12
2231
+ ], 14);
2232
+ B(b, M.marbleD, shellGeo(1.4, 13, 28, 8), [
2233
+ bx,
2234
+ 2,
2235
+ 12
2236
+ ], [
2237
+ 0,
2238
+ Math.PI,
2239
+ 0
2240
+ ]);
2241
+ jets.push({
2242
+ pos: [
2243
+ bx,
2244
+ 2.1,
2245
+ 12
2246
+ ],
2247
+ vel: [
2248
+ 0,
2249
+ 6,
2250
+ 0
2251
+ ],
2252
+ n: 14,
2253
+ size: .1,
2254
+ seed: 60 + sx
2255
+ });
2256
+ }
2257
+ balustrade(rest, M, {
2258
+ x1: 10,
2259
+ z1: 20,
2260
+ x2: 70,
2261
+ z2: 20,
2262
+ y: .55,
2263
+ h: 1
2264
+ });
2265
+ for (const sx of [-1, 1]) for (let i = 0; i < 5; i++) column(rest, M, {
2266
+ x: X + sx * (17 + i * 2.2),
2267
+ y: .55,
2268
+ z: 20,
2269
+ h: 3.4,
2270
+ r: .25,
2271
+ mat: M.marble,
2272
+ seed: 80 + i
2273
+ });
2274
+ for (let i = 0; i < 46; i++) {
2275
+ const a = R() * Math.PI * 2, rad = 16 + R() * 22;
2276
+ rubble.push({
2277
+ pos: [
2278
+ X + Math.cos(a) * rad,
2279
+ .3,
2280
+ -2 + Math.sin(a) * rad * .75
2281
+ ],
2282
+ s: .5 + R() * 1.5,
2283
+ rot: R() * 6.28
2284
+ });
2285
+ }
2286
+ }
2287
+ function yuanyingguan(ctx) {
2288
+ const { ruin, rest, ruinOnly, M, rubble } = ctx;
2289
+ const b = ruin, X = 40, Z = -34;
2290
+ terrace(b, M, {
2291
+ x: X,
2292
+ z: Z,
2293
+ w: 40,
2294
+ d: 20,
2295
+ h: 2.1,
2296
+ steps: true
2297
+ });
2298
+ balustrade(b, M, {
2299
+ x1: 21,
2300
+ z1: -24.4,
2301
+ x2: 32,
2302
+ z2: -24.4,
2303
+ y: 2.1,
2304
+ h: .95
2305
+ });
2306
+ balustrade(b, M, {
2307
+ x1: 48,
2308
+ z1: -24.4,
2309
+ x2: 59,
2310
+ z2: -24.4,
2311
+ y: 2.1,
2312
+ h: .95
2313
+ });
2314
+ B(b, M.marble, archWallGeo(27, 8.4, 2.4, [
2315
+ {
2316
+ x: -8.7,
2317
+ w: 5.6,
2318
+ h: 6.6,
2319
+ arch: true
2320
+ },
2321
+ {
2322
+ x: 0,
2323
+ w: 6.6,
2324
+ h: 7.6,
2325
+ arch: true
2326
+ },
2327
+ {
2328
+ x: 8.7,
2329
+ w: 5.6,
2330
+ h: 6.6,
2331
+ arch: true
2332
+ }
2333
+ ], .06), [
2334
+ X,
2335
+ 2.1,
2336
+ Z
2337
+ ]);
2338
+ for (const dx of [
2339
+ -8.7,
2340
+ 0,
2341
+ 8.7
2342
+ ]) {
2343
+ torus(b, M.stone2, Math.abs(dx) < 1 ? 3.3 : 2.8, .28, [
2344
+ X + dx,
2345
+ 2.1 + (Math.abs(dx) < 1 ? 4.3 : 3.8),
2346
+ -32.7
2347
+ ], Math.PI, [
2348
+ 0,
2349
+ 0,
2350
+ 0
2351
+ ]);
2352
+ cbox(b, M.marble, .62, .9, .5, [
2353
+ X + dx,
2354
+ 2.1 + (Math.abs(dx) < 1 ? 7.9 : 6.9),
2355
+ -32.65
2356
+ ], [
2357
+ 0,
2358
+ 0,
2359
+ 0
2360
+ ], .04);
2361
+ for (const s of [-1, 1]) {
2362
+ const off = Math.abs(dx) < 1 ? 3.3 : 2.8;
2363
+ column(b, M, {
2364
+ x: X + dx + s * off,
2365
+ y: 2.1,
2366
+ z: -32.45,
2367
+ h: 6.5,
2368
+ r: .48,
2369
+ mat: M.marble,
2370
+ seed: 120 + dx + s
2371
+ });
2372
+ }
2373
+ reliefPanel(b, M, {
2374
+ x: X + dx,
2375
+ y: 2.4,
2376
+ z: -32.72,
2377
+ w: 2,
2378
+ h: 2.5,
2379
+ d: .28
2380
+ });
2381
+ }
2382
+ cornice(b, M, {
2383
+ x: X,
2384
+ y: 10.5,
2385
+ z: Z,
2386
+ w: 29,
2387
+ d: 3.2
2388
+ });
2389
+ B(ruinOnly, M.marbleD, brokenWallGeo(27, 2.4, 2, 71, .7), [
2390
+ X,
2391
+ 11.2,
2392
+ Z
2393
+ ]);
2394
+ for (const sx of [-1, 1]) {
2395
+ B(b, M.stone, brokenWallGeo(9, 6.4, 1.8, 73 + sx, .75), [
2396
+ X + sx * 18,
2397
+ 2.1,
2398
+ -37
2399
+ ]);
2400
+ for (let i = 0; i < 7; i++) rosette(b, M, X + sx * (14.5 + i * 1.15), 4 + i % 3 * .6, -36.05, .24);
2401
+ }
2402
+ cbox(rest, M.plaster, 29.5, 8.6, 3, [
2403
+ X,
2404
+ 6.4,
2405
+ -35.1
2406
+ ], [
2407
+ 0,
2408
+ 0,
2409
+ 0
2410
+ ], .05);
2411
+ for (let i = 0; i < 7; i++) archWindow(rest, M, {
2412
+ x: 28 + i * 4,
2413
+ y: 3,
2414
+ z: -33.45,
2415
+ w: 1.9,
2416
+ h: 3.6,
2417
+ mat: M.marble
2418
+ });
2419
+ for (let i = 0; i < 5; i++) archWindow(rest, M, {
2420
+ x: 30 + i * 5,
2421
+ y: 3,
2422
+ z: -36.72,
2423
+ w: 1.9,
2424
+ h: 3.4,
2425
+ mat: M.marbleD,
2426
+ ry: Math.PI,
2427
+ pediment: false
2428
+ });
2429
+ cbox(rest, M.marbleD, 30.4, .42, 3.6, [
2430
+ X,
2431
+ 10.85,
2432
+ -35.1
2433
+ ], [
2434
+ 0,
2435
+ 0,
2436
+ 0
2437
+ ], .04);
2438
+ hipRoof(rest, M, {
2439
+ x: X,
2440
+ y: 11.3,
2441
+ z: -35,
2442
+ w: 34,
2443
+ d: 14,
2444
+ h: 4.4,
2445
+ mat: M.roof
2446
+ });
2447
+ balustrade(rest, M, {
2448
+ x1: 25,
2449
+ z1: -29,
2450
+ x2: 55,
2451
+ z2: -29,
2452
+ y: 11.3,
2453
+ h: .9
2454
+ });
2455
+ for (let i = 0; i < 30; i++) {
2456
+ const a = R() * Math.PI * 2, rad = 12 + R() * 16;
2457
+ rubble.push({
2458
+ pos: [
2459
+ X + Math.cos(a) * rad,
2460
+ .3,
2461
+ -30 + Math.sin(a) * rad * .6
2462
+ ],
2463
+ s: .4 + R() * 1.2,
2464
+ rot: R() * 6.28
2465
+ });
2466
+ }
2467
+ }
2468
+ function guanshuifa(ctx) {
2469
+ const { ruin, rest, M } = ctx;
2470
+ const b = ruin, X = 40;
2471
+ terrace(b, M, {
2472
+ x: X,
2473
+ z: 36,
2474
+ w: 26,
2475
+ d: 13,
2476
+ h: .7,
2477
+ steps: true
2478
+ });
2479
+ for (let i = 0; i < 5; i++) {
2480
+ const a = (i - 2) * .34;
2481
+ const px = X + Math.sin(a) * 12.2, pz = 39.5 + Math.cos(a) * 3.4 - 3.4;
2482
+ reliefPanel(b, M, {
2483
+ x: px,
2484
+ y: .7,
2485
+ z: pz,
2486
+ w: 3.3,
2487
+ h: 4.4,
2488
+ d: .48,
2489
+ ry: -a
2490
+ });
2491
+ cbox(b, M.stone2, 3.9, .5, .85, [
2492
+ px,
2493
+ .9,
2494
+ pz + .15
2495
+ ], [
2496
+ 0,
2497
+ -a,
2498
+ 0
2499
+ ], .05);
2500
+ cbox(b, M.marbleD, 3.9, .35, .9, [
2501
+ px,
2502
+ 5.35,
2503
+ pz + .15
2504
+ ], [
2505
+ 0,
2506
+ -a,
2507
+ 0
2508
+ ], .04);
2509
+ rosette(b, M, px, 5.65, pz + .62, .3);
2510
+ if (i === 2) B(b, M.marbleD, brokenWallGeo(3.3, 1.2, .5, 91, .8), [
2511
+ px,
2512
+ 5.6,
2513
+ pz + .15
2514
+ ], [
2515
+ 0,
2516
+ -a,
2517
+ 0
2518
+ ]);
2519
+ }
2520
+ cbox(b, M.marble, 4.4, .5, 3.2, [
2521
+ X,
2522
+ .95,
2523
+ 32.5
2524
+ ], [
2525
+ 0,
2526
+ 0,
2527
+ 0
2528
+ ], .05);
2529
+ cbox(b, M.marble, 2.2, .55, 1.2, [
2530
+ X,
2531
+ 1.45,
2532
+ 32.4
2533
+ ], [
2534
+ 0,
2535
+ 0,
2536
+ 0
2537
+ ], .05);
2538
+ cbox(b, M.marble, 2.2, 1.25, .35, [
2539
+ X,
2540
+ 2.1,
2541
+ 31.9
2542
+ ], [
2543
+ 0,
2544
+ 0,
2545
+ 0
2546
+ ], .05);
2547
+ for (const s of [-1, 1]) {
2548
+ cbox(b, M.marble, .45, 1, 1.4, [
2549
+ X + s * 1.2,
2550
+ 1.6,
2551
+ 32.4
2552
+ ], [
2553
+ 0,
2554
+ 0,
2555
+ 0
2556
+ ], .04);
2557
+ cyl(b, M.bronze, .35, .28, 1.2, [
2558
+ X + s * 3.2,
2559
+ 1.3,
2560
+ 32.2
2561
+ ], 12);
2562
+ sphere(b, M.bronze, .28, [
2563
+ X + s * 3.2,
2564
+ 2.05,
2565
+ 32.2
2566
+ ], [
2567
+ 1,
2568
+ 1.2,
2569
+ 1
2570
+ ], 10, 8);
2571
+ B(b, M.bronze, tube([
2572
+ [
2573
+ 0,
2574
+ 0,
2575
+ 0
2576
+ ],
2577
+ [
2578
+ 0,
2579
+ .6,
2580
+ .2
2581
+ ],
2582
+ [
2583
+ .25,
2584
+ .95,
2585
+ .45
2586
+ ]
2587
+ ], .06, 8, 5), [
2588
+ X + s * 3.2,
2589
+ 2.1,
2590
+ 32.2
2591
+ ]);
2592
+ }
2593
+ balustrade(b, M, {
2594
+ x1: 29,
2595
+ z1: 30.5,
2596
+ x2: 37,
2597
+ z2: 30.5,
2598
+ y: .7,
2599
+ h: .85
2600
+ });
2601
+ balustrade(b, M, {
2602
+ x1: 43,
2603
+ z1: 30.5,
2604
+ x2: 51,
2605
+ z2: 30.5,
2606
+ y: .7,
2607
+ h: .85
2608
+ });
2609
+ rest && balustrade(rest, M, {
2610
+ x1: 27,
2611
+ z1: 42,
2612
+ x2: 53,
2613
+ z2: 42,
2614
+ y: .7,
2615
+ h: 1
2616
+ });
2617
+ }
2618
+ function haiyantang(ctx) {
2619
+ const { ruin, rest, M, jets, waters, rubble } = ctx;
2620
+ const b = ruin, X = -72;
2621
+ terrace(b, M, {
2622
+ x: X,
2623
+ z: 0,
2624
+ w: 66,
2625
+ d: 22,
2626
+ h: 1.5,
2627
+ steps: false
2628
+ });
2629
+ cbox(b, M.plaster, 60, 9.4, 14, [
2630
+ X,
2631
+ 6.2,
2632
+ -2
2633
+ ], [
2634
+ 0,
2635
+ 0,
2636
+ 0
2637
+ ], .07);
2638
+ cbox(b, M.stone2, 61.4, .65, 15.4, [
2639
+ X,
2640
+ 1.8,
2641
+ -2
2642
+ ], [
2643
+ 0,
2644
+ 0,
2645
+ 0
2646
+ ], .05);
2647
+ cbox(b, M.marbleD, 61.6, .55, 15.6, [
2648
+ X,
2649
+ 10.85,
2650
+ -2
2651
+ ], [
2652
+ 0,
2653
+ 0,
2654
+ 0
2655
+ ], .05);
2656
+ cornice(b, M, {
2657
+ x: X,
2658
+ y: 11.2,
2659
+ z: -2,
2660
+ w: 62,
2661
+ d: 15.6,
2662
+ mat: M.marbleD
2663
+ });
2664
+ for (let i = 0; i < 12; i++) column(b, M, {
2665
+ x: X + (-27.5 + i * 5),
2666
+ y: 2.2,
2667
+ z: 5.2,
2668
+ h: 8.2,
2669
+ r: .42,
2670
+ mat: M.marble,
2671
+ ruin: i === 9 || i === 10 ? 1 : 0,
2672
+ seed: 200 + i
2673
+ });
2674
+ for (let i = 0; i < 11; i++) {
2675
+ const dx = -25 + i * 5;
2676
+ if (i === 9 || i === 10) {
2677
+ B(b, M.stone, brokenWallGeo(4.2, 5.6, .8, 210 + i, .65), [
2678
+ X + dx,
2679
+ 2.2,
2680
+ 5.1
2681
+ ]);
2682
+ continue;
2683
+ }
2684
+ archWindow(b, M, {
2685
+ x: X + dx,
2686
+ y: 3.5,
2687
+ z: 5.12,
2688
+ w: 2.3,
2689
+ h: 4.6,
2690
+ mat: M.marble
2691
+ });
2692
+ cbox(b, M.marbleD, 2.9, .35, .4, [
2693
+ X + dx,
2694
+ 2.9,
2695
+ 5.3
2696
+ ], [
2697
+ 0,
2698
+ 0,
2699
+ 0
2700
+ ], .03);
2701
+ rosette(b, M, X + dx, 9.4, 5.35, .26);
2702
+ }
2703
+ cbox(b, M.marbleD, 10.5, 9.6, 2.2, [
2704
+ X,
2705
+ 6.2,
2706
+ 5.8
2707
+ ], [
2708
+ 0,
2709
+ 0,
2710
+ 0
2711
+ ], .06);
2712
+ for (const s of [-1, 1]) for (const t of [-1, 1]) column(b, M, {
2713
+ x: X + s * (2.1 + t * 1.5),
2714
+ y: 2.2,
2715
+ z: 7.1,
2716
+ h: 8.6,
2717
+ r: .5,
2718
+ mat: M.marble,
2719
+ seed: 230 + s + t
2720
+ });
2721
+ baroqueGable(b, M, {
2722
+ x: X,
2723
+ y: 11.7,
2724
+ z: 6.1,
2725
+ w: 12.5,
2726
+ h: 2.6,
2727
+ d: 1.2,
2728
+ broken: false
2729
+ });
2730
+ cbox(b, M.wood, 3.2, 5.2, .25, [
2731
+ X,
2732
+ 4.8,
2733
+ 7
2734
+ ], [
2735
+ 0,
2736
+ 0,
2737
+ 0
2738
+ ], .04);
2739
+ for (let i = 0; i < 6; i++) cbox(b, M.gold, .12, .35, .06, [
2740
+ -73.1 + i * .44,
2741
+ 5.6,
2742
+ 7.16
2743
+ ], [
2744
+ 0,
2745
+ 0,
2746
+ 0
2747
+ ], .01);
2748
+ for (const s of [-1, 1]) {
2749
+ for (let l = 0; l < 8; l++) cbox(b, M.marble, 5.4, .19, .62, [
2750
+ X + s * 8.2,
2751
+ .19 * (8 - l) + .1,
2752
+ 11.6 + l * .62
2753
+ ], [
2754
+ 0,
2755
+ 0,
2756
+ 0
2757
+ ], .02);
2758
+ balustrade(b, M, {
2759
+ x1: X + s * 5.6,
2760
+ z1: 11.2,
2761
+ x2: X + s * 5.6,
2762
+ z2: 16.6,
2763
+ y: 1.5,
2764
+ h: .8,
2765
+ spacing: .9
2766
+ });
2767
+ }
2768
+ basinCurb(b, M, {
2769
+ x: X,
2770
+ z: 14.2,
2771
+ rx: 5.2,
2772
+ rz: 3.4,
2773
+ y: .1,
2774
+ h: .55,
2775
+ seg: 32
2776
+ });
2777
+ waters.push({
2778
+ x: X,
2779
+ z: 14.2,
2780
+ rx: 4.9,
2781
+ rz: 3.1,
2782
+ y: .26,
2783
+ kind: "ellipse"
2784
+ });
2785
+ B(b, M.marbleD, shellGeo(1.9, 13, 26, 8), [
2786
+ X,
2787
+ 1,
2788
+ 14.2
2789
+ ], [
2790
+ 0,
2791
+ Math.PI,
2792
+ 0
2793
+ ]);
2794
+ jets.push({
2795
+ pos: [
2796
+ X,
2797
+ 1.5,
2798
+ 14.2
2799
+ ],
2800
+ vel: [
2801
+ 0,
2802
+ 5.6,
2803
+ 0
2804
+ ],
2805
+ n: 14,
2806
+ size: .09,
2807
+ seed: 250
2808
+ });
2809
+ hipRoof(rest, M, {
2810
+ x: X,
2811
+ y: 11.9,
2812
+ z: -2,
2813
+ w: 64,
2814
+ d: 17,
2815
+ h: 4.6,
2816
+ mat: M.roof
2817
+ });
2818
+ cbox(rest, M.marbleD, 61, .5, 15.2, [
2819
+ X,
2820
+ 11.65,
2821
+ -2
2822
+ ], [
2823
+ 0,
2824
+ 0,
2825
+ 0
2826
+ ], .04);
2827
+ for (const s of [-1, 1]) balustrade(rest, M, {
2828
+ x1: X + s * 29,
2829
+ z1: 5.4,
2830
+ x2: X + s * 29,
2831
+ z2: -9.4,
2832
+ y: 11.9,
2833
+ h: .8
2834
+ });
2835
+ for (let i = 0; i < 11; i++) cbox(rest, M.marble, 4.3, .12, .12, [
2836
+ -97 + i * 5,
2837
+ 12.1,
2838
+ 5.5
2839
+ ], [
2840
+ 0,
2841
+ 0,
2842
+ 0
2843
+ ], .01);
2844
+ const BX = -68, BZ = -26;
2845
+ cbox(b, M.graybrick, 30, 7.6, 12, [
2846
+ BX,
2847
+ 4,
2848
+ BZ
2849
+ ], [
2850
+ 0,
2851
+ 0,
2852
+ 0
2853
+ ], .06);
2854
+ for (let i = 0; i < 7; i++) B(b, M.graybrick, archWallGeo(3.2, 3.2, .6, [{
2855
+ x: 0,
2856
+ w: 2,
2857
+ h: 2.6,
2858
+ arch: true
2859
+ }], .03), [
2860
+ -80 + i * 4,
2861
+ .4,
2862
+ -19.8
2863
+ ], [
2864
+ 0,
2865
+ Math.PI,
2866
+ 0
2867
+ ]);
2868
+ cbox(b, M.stone2, 31, .5, 13, [
2869
+ BX,
2870
+ 8,
2871
+ BZ
2872
+ ], [
2873
+ 0,
2874
+ 0,
2875
+ 0
2876
+ ], .05);
2877
+ cbox(b, M.bronzeD, 26, 1.2, 9, [
2878
+ BX,
2879
+ 8.8,
2880
+ BZ
2881
+ ], [
2882
+ 0,
2883
+ 0,
2884
+ 0
2885
+ ], .05);
2886
+ for (let i = 0; i < 6; i++) archWindow(b, M, {
2887
+ x: -79 + i * 4.4,
2888
+ y: 4.6,
2889
+ z: -19.85,
2890
+ w: 1.6,
2891
+ h: 2.6,
2892
+ mat: M.marbleD,
2893
+ pediment: false
2894
+ });
2895
+ for (const s of [-1, 1]) {
2896
+ const ex = BX + s * 15.05;
2897
+ for (let i = 0; i < 2; i++) archWindow(b, M, {
2898
+ x: ex,
2899
+ y: 4.4,
2900
+ z: -28.7 + i * 5.4,
2901
+ w: 1.9,
2902
+ h: 2.9,
2903
+ ry: s * Math.PI / 2,
2904
+ mat: M.marbleD,
2905
+ pediment: false
2906
+ });
2907
+ for (const zz of [
2908
+ -5.4,
2909
+ 0,
2910
+ 5.4
2911
+ ]) cbox(b, M.stone2, .34, 6.8, .45, [
2912
+ ex + s * .02,
2913
+ 3.6,
2914
+ BZ + zz
2915
+ ], [
2916
+ 0,
2917
+ 0,
2918
+ 0
2919
+ ], .03);
2920
+ cbox(b, M.marbleD, .42, .34, 12.2, [
2921
+ ex,
2922
+ 7.2,
2923
+ BZ
2924
+ ], [
2925
+ 0,
2926
+ 0,
2927
+ 0
2928
+ ], .03);
2929
+ sphere(b, M.marble, .34, [
2930
+ ex + s * .22,
2931
+ 5.9,
2932
+ BZ
2933
+ ], [
2934
+ 1,
2935
+ 1,
2936
+ .45
2937
+ ], 10, 7);
2938
+ }
2939
+ const FZ = 34;
2940
+ for (let l = 0; l < 4; l++) {
2941
+ const r0 = 8.5 + l * 2.7;
2942
+ const seg = 40;
2943
+ for (let i = -20; i < seg / 2; i++) {
2944
+ const a = i / seg * Math.PI * 1.1;
2945
+ const px = X + Math.sin(a) * r0, pz = FZ - Math.cos(a) * r0 * .66 + 5;
2946
+ cbox(b, M.marbleD, 1.9, .3 + l * .18, 1.5, [
2947
+ px,
2948
+ .2 + l * .32,
2949
+ pz
2950
+ ], [
2951
+ 0,
2952
+ -a,
2953
+ 0
2954
+ ], .025);
2955
+ }
2956
+ }
2957
+ const names = [
2958
+ "子鼠",
2959
+ "丑牛",
2960
+ "寅虎",
2961
+ "卯兔",
2962
+ "辰龙",
2963
+ "巳蛇",
2964
+ "午马",
2965
+ "未羊",
2966
+ "申猴",
2967
+ "酉鸡",
2968
+ "戌狗",
2969
+ "亥猪"
2970
+ ];
2971
+ for (let i = 0; i < 12; i++) {
2972
+ const a = -.98 + i * (1.96 / 11);
2973
+ const rad = 15.4;
2974
+ const px = X + Math.sin(a) * rad, pz = 39 - Math.cos(a) * rad * .66 + 3.2;
2975
+ const ry = -a;
2976
+ cbox(b, M.marble, 1.5, .45, 1.5, [
2977
+ px,
2978
+ .32,
2979
+ pz
2980
+ ], [
2981
+ 0,
2982
+ ry,
2983
+ 0
2984
+ ], .04);
2985
+ cyl(b, M.bronzeD, .55, .42, 1.35, [
2986
+ px,
2987
+ 1.2,
2988
+ pz
2989
+ ], 12);
2990
+ cbox(b, M.bronze, 1.15, .28, .9, [
2991
+ px,
2992
+ 1.9,
2993
+ pz
2994
+ ], [
2995
+ 0,
2996
+ ry,
2997
+ 0
2998
+ ], .05);
2999
+ zodiacHead(b, M, {
3000
+ x: px,
3001
+ y: 2.45,
3002
+ z: pz + .18,
3003
+ kind: i,
3004
+ ry,
3005
+ s: 1
3006
+ });
3007
+ cbox(b, M.marbleD, 1.7, .22, 1.7, [
3008
+ px,
3009
+ .1,
3010
+ pz
3011
+ ], [
3012
+ 0,
3013
+ ry,
3014
+ 0
3015
+ ], .02);
3016
+ jets.push({
3017
+ pos: [
3018
+ px,
3019
+ 2.35,
3020
+ pz + .62
3021
+ ],
3022
+ vel: [
3023
+ Math.sin(ry) * 1.2,
3024
+ 1.4,
3025
+ 3.4
3026
+ ],
3027
+ n: 7,
3028
+ size: .085,
3029
+ seed: 300 + i
3030
+ });
3031
+ (ctx.labels || []).push({
3032
+ name: names[i],
3033
+ pos: [
3034
+ px,
3035
+ 3.2,
3036
+ pz
3037
+ ]
3038
+ });
3039
+ }
3040
+ cyl(b, M.marble, 3.4, 2.9, .7, [
3041
+ X,
3042
+ .45,
3043
+ 39
3044
+ ], 24);
3045
+ for (let l = 0; l < 4; l++) {
3046
+ const r = 2.9 - l * .55;
3047
+ cyl(b, l % 2 ? M.marbleD : M.stone2, r, r - .15, 1.1, [
3048
+ X,
3049
+ .8 + l * 1.1,
3050
+ 39
3051
+ ], 20);
3052
+ basinCurb(b, M, {
3053
+ x: X,
3054
+ z: 39,
3055
+ rx: r + .25,
3056
+ rz: r + .25,
3057
+ y: 1.2 + l * 1.1,
3058
+ h: .2,
3059
+ seg: 24
3060
+ });
3061
+ waters.push({
3062
+ x: X,
3063
+ z: 39,
3064
+ rx: r + .1,
3065
+ rz: r + .1,
3066
+ y: 1.42 + l * 1.1,
3067
+ kind: "ellipse",
3068
+ tiny: true
3069
+ });
3070
+ }
3071
+ B(b, M.marbleD, shellGeo(1.55, 13, 30, 9), [
3072
+ X,
3073
+ 5.3,
3074
+ 39
3075
+ ], [
3076
+ 0,
3077
+ Math.PI,
3078
+ 0
3079
+ ]);
3080
+ sphere(b, M.gold, .42, [
3081
+ X,
3082
+ 5.9,
3083
+ 39
3084
+ ], [
3085
+ 1,
3086
+ 1.2,
3087
+ 1
3088
+ ], 12, 9);
3089
+ jets.push({
3090
+ pos: [
3091
+ X,
3092
+ 5.9,
3093
+ 39
3094
+ ],
3095
+ vel: [
3096
+ 0,
3097
+ 6.2,
3098
+ 0
3099
+ ],
3100
+ n: 16,
3101
+ size: .1,
3102
+ seed: 320
3103
+ });
3104
+ for (let i = 0; i < 28; i++) {
3105
+ const a = R() * Math.PI * 2, rad = 12 + R() * 18;
3106
+ rubble.push({
3107
+ pos: [
3108
+ X + Math.cos(a) * rad,
3109
+ .3,
3110
+ 8 + Math.sin(a) * rad * .55
3111
+ ],
3112
+ s: .4 + R() * 1.4,
3113
+ rot: R() * 6.28
3114
+ });
3115
+ }
3116
+ }
3117
+ function xieqiqu(ctx) {
3118
+ const { ruin, rest, M, jets, waters } = ctx;
3119
+ const b = ruin, X = -138;
3120
+ terrace(b, M, {
3121
+ x: X,
3122
+ z: 4,
3123
+ w: 44,
3124
+ d: 20,
3125
+ h: .9,
3126
+ steps: true
3127
+ });
3128
+ cbox(b, M.plaster, 20, 12.4, 12, [
3129
+ X,
3130
+ 7.1,
3131
+ 2
3132
+ ], [
3133
+ 0,
3134
+ 0,
3135
+ 0
3136
+ ], .06);
3137
+ for (let l = 0; l < 3; l++) {
3138
+ const y = 1.2 + l * 4;
3139
+ cbox(b, M.marbleD, 22, .4, 13.4, [
3140
+ X,
3141
+ y + 3.75,
3142
+ 2
3143
+ ], [
3144
+ 0,
3145
+ 0,
3146
+ 0
3147
+ ], .04);
3148
+ for (let i = 0; i < 7; i++) {
3149
+ const dx = -9 + i * 3;
3150
+ column(b, M, {
3151
+ x: X + dx,
3152
+ y,
3153
+ z: 8.2,
3154
+ h: 3.6,
3155
+ r: .3,
3156
+ mat: M.marble,
3157
+ seed: 400 + l * 10 + i
3158
+ });
3159
+ if (l === 2) archWindow(b, M, {
3160
+ x: X + dx + 1.5,
3161
+ y: y + .5,
3162
+ z: 8.05,
3163
+ w: 1.7,
3164
+ h: 2.6,
3165
+ mat: M.marbleD,
3166
+ pediment: false
3167
+ });
3168
+ }
3169
+ }
3170
+ balustrade(b, M, {
3171
+ x1: -148,
3172
+ z1: 8.4,
3173
+ x2: -128,
3174
+ z2: 8.4,
3175
+ y: 5.1,
3176
+ h: .72,
3177
+ spacing: .85
3178
+ });
3179
+ for (const s of [-1, 1]) {
3180
+ for (let i = 0; i < 6; i++) {
3181
+ const a = i / 5 * Math.PI * .42;
3182
+ const px = X + s * (10 + Math.sin(a) * 8.5), pz = 8 - Math.cos(a) * 2 + 2;
3183
+ column(b, M, {
3184
+ x: px,
3185
+ y: .9,
3186
+ z: pz,
3187
+ h: 3.3,
3188
+ r: .24,
3189
+ mat: M.marbleD,
3190
+ seed: 440 + i + s
3191
+ });
3192
+ cbox(b, M.marbleD, 3, .28, 1.5, [
3193
+ px,
3194
+ 4.3,
3195
+ pz
3196
+ ], [
3197
+ 0,
3198
+ s * a,
3199
+ 0
3200
+ ], .02);
3201
+ }
3202
+ const kx = X + s * 20, kz = 12;
3203
+ for (let i = 0; i < 8; i++) {
3204
+ const a = i / 8 * Math.PI * 2;
3205
+ column(b, M, {
3206
+ x: kx + Math.cos(a) * 3,
3207
+ y: .9,
3208
+ z: kz + Math.sin(a) * 3,
3209
+ h: 3.6,
3210
+ r: .22,
3211
+ mat: M.marble,
3212
+ seed: 460 + i
3213
+ });
3214
+ }
3215
+ cbox(b, M.stone2, 7.2, .4, 7.2, [
3216
+ kx,
3217
+ .9,
3218
+ kz
3219
+ ], [
3220
+ 0,
3221
+ Math.PI / 8,
3222
+ 0
3223
+ ], .04);
3224
+ hipRoof(rest, M, {
3225
+ x: kx,
3226
+ y: 4.6,
3227
+ z: kz,
3228
+ w: 8,
3229
+ d: 8,
3230
+ h: 2.4,
3231
+ mat: M.roof
3232
+ });
3233
+ rosette(b, M, kx, 4.7, 15, .3);
3234
+ }
3235
+ hipRoof(rest, M, {
3236
+ x: X,
3237
+ y: 13.4,
3238
+ z: 2,
3239
+ w: 23,
3240
+ d: 14,
3241
+ h: 3.2,
3242
+ mat: M.roof
3243
+ });
3244
+ basinCurb(b, M, {
3245
+ x: X,
3246
+ z: 22,
3247
+ rx: 9.5,
3248
+ rz: 7,
3249
+ y: .05,
3250
+ h: .55,
3251
+ seg: 48
3252
+ });
3253
+ waters.push({
3254
+ x: X,
3255
+ z: 22,
3256
+ rx: 9.1,
3257
+ rz: 6.6,
3258
+ y: .24,
3259
+ kind: "ellipse"
3260
+ });
3261
+ cyl(b, M.marble, 1.1, .8, 1.8, [
3262
+ X,
3263
+ .95,
3264
+ 22
3265
+ ], 16);
3266
+ B(b, M.marbleD, shellGeo(1.8, 13, 28, 8), [
3267
+ X,
3268
+ 2,
3269
+ 22
3270
+ ], [
3271
+ 0,
3272
+ Math.PI,
3273
+ 0
3274
+ ]);
3275
+ jets.push({
3276
+ pos: [
3277
+ X,
3278
+ 2.2,
3279
+ 22
3280
+ ],
3281
+ vel: [
3282
+ 0,
3283
+ 5.8,
3284
+ 0
3285
+ ],
3286
+ n: 12,
3287
+ size: .09,
3288
+ seed: 480
3289
+ });
3290
+ for (let i = 0; i < 8; i++) {
3291
+ const a = i / 8 * Math.PI * 2;
3292
+ lionHead(b, M, {
3293
+ x: X + Math.cos(a) * 8.6,
3294
+ y: .75,
3295
+ z: 22 + Math.sin(a) * 6.3,
3296
+ ry: -a + Math.PI / 2,
3297
+ s: .6
3298
+ });
3299
+ }
3300
+ }
3301
+ function fangwaiguan(ctx) {
3302
+ const { ruin, rest, M } = ctx;
3303
+ const b = ruin, X = -118, Z = -40;
3304
+ terrace(b, M, {
3305
+ x: X,
3306
+ z: Z,
3307
+ w: 22,
3308
+ d: 16,
3309
+ h: .9,
3310
+ steps: true
3311
+ });
3312
+ cbox(b, M.marbleD, 15, 8.6, 10, [
3313
+ X,
3314
+ 5.2,
3315
+ Z
3316
+ ], [
3317
+ 0,
3318
+ 0,
3319
+ 0
3320
+ ], .06);
3321
+ for (let l = 0; l < 2; l++) for (let i = 0; i < 5; i++) archWindow(b, M, {
3322
+ x: -124 + i * 3,
3323
+ y: 1.4 + l * 4.1,
3324
+ z: -34.9,
3325
+ w: 1.7,
3326
+ h: 2.9,
3327
+ mat: M.marble,
3328
+ pediment: false
3329
+ });
3330
+ for (let i = 0; i < 6; i++) {
3331
+ column(b, M, {
3332
+ x: -125.5 + i * 3,
3333
+ y: .9,
3334
+ z: -34.7,
3335
+ h: 4,
3336
+ r: .28,
3337
+ mat: M.marble,
3338
+ seed: 500 + i
3339
+ });
3340
+ rosette(b, M, -125.5 + i * 3, 9.3, -34.8, .28);
3341
+ }
3342
+ cbox(b, M.stone2, 16.5, .5, 11.5, [
3343
+ X,
3344
+ 9.7,
3345
+ Z
3346
+ ], [
3347
+ 0,
3348
+ 0,
3349
+ 0
3350
+ ], .04);
3351
+ hipRoof(rest, M, {
3352
+ x: X,
3353
+ y: 10,
3354
+ z: Z,
3355
+ w: 18,
3356
+ d: 13,
3357
+ h: 3.4,
3358
+ mat: M.roof
3359
+ });
3360
+ const kx = -132, kz = -36;
3361
+ for (let i = 0; i < 8; i++) {
3362
+ const a = i / 8 * Math.PI * 2;
3363
+ column(b, M, {
3364
+ x: kx + Math.cos(a) * 2.7,
3365
+ y: .9,
3366
+ z: kz + Math.sin(a) * 2.7,
3367
+ h: 3.3,
3368
+ r: .2,
3369
+ mat: M.marbleD,
3370
+ seed: 520 + i
3371
+ });
3372
+ }
3373
+ hipRoof(rest, M, {
3374
+ x: kx,
3375
+ y: 4.3,
3376
+ z: kz,
3377
+ w: 7,
3378
+ d: 7,
3379
+ h: 2,
3380
+ mat: M.roof
3381
+ });
3382
+ for (let i = 0; i < 5; i++) {
3383
+ const px = -106 + i % 3 * 6, pz = -20 + Math.floor(i / 3) * 6;
3384
+ for (let k = 0; k < 4; k++) cyl(b, M.wood, .13, .11, 3, [
3385
+ px + (k % 2 ? 1.7 : -1.7),
3386
+ 1.6,
3387
+ pz + (k < 2 ? -1.7 : 1.7)
3388
+ ], 7);
3389
+ hipRoof(rest, M, {
3390
+ x: px,
3391
+ y: 3.2,
3392
+ z: pz,
3393
+ w: 5,
3394
+ d: 5,
3395
+ h: 1.6,
3396
+ mat: M.roof
3397
+ });
3398
+ cbox(b, M.wood, 4.2, .2, 4.2, [
3399
+ px,
3400
+ .35,
3401
+ pz
3402
+ ], [
3403
+ 0,
3404
+ 0,
3405
+ 0
3406
+ ], .02);
3407
+ }
3408
+ }
3409
+ function maze(ctx) {
3410
+ const { ruin, rest, M } = ctx;
3411
+ const b = ruin, X = -152, Z = 0, half = 22, wallH = 1.35;
3412
+ cbox(b, M.ground, 48, .15, 48, [
3413
+ X,
3414
+ .02,
3415
+ Z
3416
+ ], [
3417
+ 0,
3418
+ 0,
3419
+ 0
3420
+ ], .02);
3421
+ const rnd = mulberry32(7777);
3422
+ for (let ring = 0; ring < 6; ring++) {
3423
+ const s = half - ring * 3.4;
3424
+ if (s < 4) break;
3425
+ const gapSide = Math.floor(rnd() * 4);
3426
+ const gapOff = (rnd() - .5) * s * .9;
3427
+ [
3428
+ (t) => [
3429
+ X - s + t * 2 * s,
3430
+ Z - s,
3431
+ 0
3432
+ ],
3433
+ (t) => [
3434
+ X + s,
3435
+ Z - s + t * 2 * s,
3436
+ Math.PI / 2
3437
+ ],
3438
+ (t) => [
3439
+ X + s - t * 2 * s,
3440
+ Z + s,
3441
+ 0
3442
+ ],
3443
+ (t) => [
3444
+ X - s,
3445
+ Z + s - t * 2 * s,
3446
+ Math.PI / 2
3447
+ ]
3448
+ ].forEach((fn, si) => {
3449
+ const n = Math.max(4, Math.round(s / 1.15));
3450
+ for (let i = 0; i < n; i++) {
3451
+ const t = (i + .5) / n;
3452
+ if (si === gapSide && Math.abs(t - .5 - gapOff / (2 * s)) < .075) continue;
3453
+ const [px, pz, ry] = fn(t);
3454
+ cbox(b, M.graybrick, 2 * s / n * 1.02, wallH, .62, [
3455
+ px,
3456
+ wallH / 2,
3457
+ pz
3458
+ ], [
3459
+ 0,
3460
+ ry,
3461
+ 0
3462
+ ], .025);
3463
+ cbox(b, M.stone2, 2 * s / n * 1.06, .12, .78, [
3464
+ px,
3465
+ 1.4100000000000001,
3466
+ pz
3467
+ ], [
3468
+ 0,
3469
+ ry,
3470
+ 0
3471
+ ], .02);
3472
+ cbox(rest, M.hedge, 2 * s / n * .96, .32, .5, [
3473
+ px,
3474
+ 1.6300000000000001,
3475
+ pz
3476
+ ], [
3477
+ 0,
3478
+ ry,
3479
+ 0
3480
+ ], .06);
3481
+ }
3482
+ });
3483
+ }
3484
+ for (let i = 0; i < 8; i++) {
3485
+ const a = i / 8 * Math.PI * 2;
3486
+ column(b, M, {
3487
+ x: X + Math.cos(a) * 3.1,
3488
+ y: .15,
3489
+ z: Z + Math.sin(a) * 3.1,
3490
+ h: 3.6,
3491
+ r: .22,
3492
+ mat: M.marble,
3493
+ seed: 600 + i
3494
+ });
3495
+ }
3496
+ cbox(b, M.marbleD, 8, .4, 8, [
3497
+ X,
3498
+ .2,
3499
+ Z
3500
+ ], [
3501
+ 0,
3502
+ Math.PI / 8,
3503
+ 0
3504
+ ], .04);
3505
+ hipRoof(rest, M, {
3506
+ x: X,
3507
+ y: 3.9,
3508
+ z: Z,
3509
+ w: 8.4,
3510
+ d: 8.4,
3511
+ h: 2.6,
3512
+ mat: M.roof
3513
+ });
3514
+ sphere(rest, M.gold, .45, [
3515
+ X,
3516
+ 6.7,
3517
+ Z
3518
+ ], [
3519
+ 1,
3520
+ 1.3,
3521
+ 1
3522
+ ], 10, 8);
3523
+ }
3524
+ function peripheral(ctx) {
3525
+ const { ruin, rest, M, waters } = ctx;
3526
+ const b = ruin;
3527
+ const X = 140, Z = -12;
3528
+ cbox(b, M.stone2, 34, .7, 3, [
3529
+ X,
3530
+ .35,
3531
+ Z
3532
+ ], [
3533
+ 0,
3534
+ 0,
3535
+ 0
3536
+ ], .04);
3537
+ for (let i = 0; i < 7; i++) {
3538
+ const px = 125 + i * 5;
3539
+ cbox(b, M.plaster, 4.4, 6.2, .5, [
3540
+ px,
3541
+ 3.6,
3542
+ Z
3543
+ ], [
3544
+ 0,
3545
+ 0,
3546
+ 0
3547
+ ], .04);
3548
+ reliefPanel(b, M, {
3549
+ x: px,
3550
+ y: 1.1,
3551
+ z: -11.68,
3552
+ w: 3.4,
3553
+ h: 3.2,
3554
+ d: .25
3555
+ });
3556
+ rosette(b, M, px, 6.2, -11.7, .3);
3557
+ }
3558
+ B(b, M.stone, brokenWallGeo(34, 1.4, .7, 701, .55), [
3559
+ X,
3560
+ 6.8,
3561
+ Z
3562
+ ]);
3563
+ for (const s of [-1, 1]) column(b, M, {
3564
+ x: X + s * 17.5,
3565
+ y: 0,
3566
+ z: Z,
3567
+ h: 7.6,
3568
+ r: .42,
3569
+ mat: M.marble,
3570
+ ruin: s > 0 ? 1 : 0,
3571
+ seed: 710 + s
3572
+ });
3573
+ for (let i = 0; i < 46; i++) {
3574
+ const px = -168 + i * 7.4;
3575
+ cbox(b, M.graybrick, 7.5, 2.7, .9, [
3576
+ px,
3577
+ 1.35,
3578
+ -92
3579
+ ], [
3580
+ 0,
3581
+ 0,
3582
+ 0
3583
+ ], .03);
3584
+ cbox(b, M.roof, 7.8, .24, 1.3, [
3585
+ px,
3586
+ 2.82,
3587
+ -92
3588
+ ], [
3589
+ 0,
3590
+ 0,
3591
+ 0
3592
+ ], .03);
3593
+ cbox(b, M.stone2, .55, 3.05, 1.1, [
3594
+ px - 3.7,
3595
+ 1.52,
3596
+ -92
3597
+ ], [
3598
+ 0,
3599
+ 0,
3600
+ 0
3601
+ ], .03);
3602
+ }
3603
+ for (const sx of [-1, 1]) for (let i = 0; i < 22; i++) {
3604
+ const pz = -92 + i * 9.2;
3605
+ cbox(b, M.graybrick, .9, 2.2, 9.3, [
3606
+ sx * 170,
3607
+ 1.1,
3608
+ pz
3609
+ ], [
3610
+ 0,
3611
+ 0,
3612
+ 0
3613
+ ], .03);
3614
+ cbox(b, M.roof, 1.3, .2, 9.5, [
3615
+ sx * 170,
3616
+ 2.3,
3617
+ pz
3618
+ ], [
3619
+ 0,
3620
+ 0,
3621
+ 0
3622
+ ], .03);
3623
+ }
3624
+ const GX = -106, GZ = 14;
3625
+ B(b, M.marbleD, archWallGeo(9, 6.2, 1.6, [{
3626
+ x: 0,
3627
+ w: 4.4,
3628
+ h: 5.2,
3629
+ arch: true
3630
+ }], .05), [
3631
+ GX,
3632
+ 0,
3633
+ GZ
3634
+ ]);
3635
+ for (const s of [-1, 1]) column(b, M, {
3636
+ x: GX + s * 2.6,
3637
+ y: 0,
3638
+ z: 14.9,
3639
+ h: 5.6,
3640
+ r: .36,
3641
+ mat: M.marble,
3642
+ seed: 730 + s
3643
+ });
3644
+ cornice(b, M, {
3645
+ x: GX,
3646
+ y: 6.2,
3647
+ z: GZ,
3648
+ w: 10.4,
3649
+ d: 1.9
3650
+ });
3651
+ rosette(b, M, GX, 7, 14.9, .45);
3652
+ }
3653
+ function buildBuildings(ctx) {
3654
+ const steps = [
3655
+ ["大水法石龛与喷池", dashuifa],
3656
+ ["远瀛观三拱门", yuanyingguan],
3657
+ ["观水法石屏风", guanshuifa],
3658
+ ["海晏堂与生肖钟", haiyantang],
3659
+ ["谐奇趣与曲廊", xieqiqu],
3660
+ ["方外观与五竹亭", fangwaiguan],
3661
+ ["黄花阵迷宫", maze],
3662
+ ["线法山与园墙", peripheral]
3663
+ ];
3664
+ steps.forEach(([name, fn], i) => {
3665
+ fn(ctx);
3666
+ if (ctx.onProgress) ctx.onProgress((i + 1) / steps.length, name);
3667
+ });
3668
+ }
3669
+ // modules/world/content/yuanmingyuan/nature.js
3670
+ const clamp = (v, a, b) => v < a ? a : v > b ? b : v;
3671
+ const smoothstep = (a, b, v) => {
3672
+ const t = clamp((v - a) / (b - a), 0, 1);
3673
+ return t * t * (3 - 2 * t);
3674
+ };
3675
+ const LAKE_C = [18, 112];
3676
+ const LAKE_R = [128, 42];
3677
+ function lakeShoreAngle(a) {
3678
+ return 1 + .1 * Math.sin(a * 3 + 1.3) + .06 * Math.sin(a * 7 + .4) + .025 * Math.sin(a * 13 + 2.1);
3679
+ }
3680
+ function lakeDepthFactor(x, z) {
3681
+ const qx = (x - LAKE_C[0]) / LAKE_R[0], qz = (z - LAKE_C[1]) / LAKE_R[1];
3682
+ const a = Math.atan2(qz, qx), d = Math.hypot(qx, qz);
3683
+ return 1 - smoothstep(lakeShoreAngle(a) - .06, lakeShoreAngle(a) + .22, d);
3684
+ }
3685
+ function terrainHeight(x, z) {
3686
+ const n = (fbm(x / 105 + 2.3, z / 105 + 4.1, 5, 4, 8) - .5) * 3.4;
3687
+ const hillNW = 12 * Math.exp(-(((x + 205) / 88) ** 2 + ((z + 135) / 74) ** 2));
3688
+ const hillE = 7 * Math.exp(-(((x - 228) / 74) ** 2 + ((z + 78) / 95) ** 2));
3689
+ const xianfa = 6.5 * Math.exp(-(((x - 140) / 27) ** 2 + ((z + 36) / 24) ** 2));
3690
+ const soft = (fbm(x / 36 + 8.2, z / 36 + 1.7, 23, 3, 8) - .5) * .5;
3691
+ const flat = (1 - smoothstep(165, 215, Math.abs(x))) * (1 - smoothstep(95, 145, Math.abs(z + 2)));
3692
+ let h = (n + hillNW + hillE + xianfa + soft) * (1 - flat * .96);
3693
+ h += flat * soft * .12;
3694
+ h -= lakeDepthFactor(x, z) * 2.6;
3695
+ return h;
3696
+ }
3697
+ const PATHS = [
3698
+ [
3699
+ [-175, 22],
3700
+ [-120, 20],
3701
+ [-60, 22],
3702
+ [10, 20],
3703
+ [70, 20],
3704
+ [165, 16]
3705
+ ],
3706
+ [
3707
+ [40, -70],
3708
+ [40, -20],
3709
+ [40, 20],
3710
+ [40, 60],
3711
+ [40, 92]
3712
+ ],
3713
+ [
3714
+ [-72, -30],
3715
+ [-72, 10],
3716
+ [-70, 40],
3717
+ [-62, 62]
3718
+ ],
3719
+ [
3720
+ [-152, -30],
3721
+ [-152, 20],
3722
+ [-138, 30],
3723
+ [-110, 22]
3724
+ ],
3725
+ [
3726
+ [-20, 40],
3727
+ [0, 66],
3728
+ [18, 92],
3729
+ [50, 104],
3730
+ [100, 100]
3731
+ ],
3732
+ [
3733
+ [-118, -40],
3734
+ [-106, -10],
3735
+ [-100, 14]
3736
+ ],
3737
+ [
3738
+ [100, 20],
3739
+ [130, 6],
3740
+ [160, -12]
3741
+ ]
3742
+ ];
3743
+ function pathDist(x, z) {
3744
+ let best = 1e9;
3745
+ for (const seg of PATHS) for (let i = 0; i < seg.length - 1; i++) {
3746
+ const [ax, az] = seg[i], [bx, bz] = seg[i + 1];
3747
+ const dx = bx - ax, dz = bz - az;
3748
+ const t = clamp(((x - ax) * dx + (z - az) * dz) / (dx * dx + dz * dz), 0, 1);
3749
+ best = Math.min(best, Math.hypot(x - (ax + t * dx), z - (az + t * dz)));
3750
+ }
3751
+ return best;
3752
+ }
3753
+ const EXCLUDE = [
3754
+ [
3755
+ -110,
3756
+ 110,
3757
+ -25,
3758
+ 25
3759
+ ],
3760
+ [
3761
+ 10,
3762
+ 70,
3763
+ -48,
3764
+ 24
3765
+ ],
3766
+ [
3767
+ -110,
3768
+ -34,
3769
+ -14,
3770
+ 16
3771
+ ],
3772
+ [
3773
+ -105,
3774
+ -40,
3775
+ 30,
3776
+ 48
3777
+ ],
3778
+ [
3779
+ -165,
3780
+ -115,
3781
+ -14,
3782
+ 24
3783
+ ],
3784
+ [
3785
+ -132,
3786
+ -104,
3787
+ -50,
3788
+ -30
3789
+ ],
3790
+ [
3791
+ -180,
3792
+ -124,
3793
+ -26,
3794
+ 26
3795
+ ],
3796
+ [
3797
+ 122,
3798
+ 160,
3799
+ -24,
3800
+ 4
3801
+ ]
3802
+ ];
3803
+ const SIGHTLINES = POIS.map((p) => [
3804
+ p.pos[0],
3805
+ p.pos[2],
3806
+ p.target[0],
3807
+ p.target[2]
3808
+ ]);
3809
+ function sightDist(x, z) {
3810
+ let best = 1e9;
3811
+ for (const [ax, az, bx, bz] of SIGHTLINES) {
3812
+ const dx = bx - ax, dz = bz - az;
3813
+ const t = clamp(((x - ax) * dx + (z - az) * dz) / (dx * dx + dz * dz), 0, 1);
3814
+ best = Math.min(best, Math.hypot(x - (ax + t * dx), z - (az + t * dz)));
3815
+ }
3816
+ return best;
3817
+ }
3818
+ function blocked(x, z, pad = 0) {
3819
+ for (const [x1, x2, z1, z2] of EXCLUDE) if (x > x1 - pad && x < x2 + pad && z > z1 - pad && z < z2 + pad) return true;
3820
+ if (lakeDepthFactor(x, z) > .12) return true;
3821
+ if (pathDist(x, z) < 2.6) return true;
3822
+ if (sightDist(x, z) < 8.5) return true;
3823
+ for (const p of POIS) if (Math.hypot(x - p.pos[0], z - p.pos[2]) < 15) return true;
3824
+ return false;
3825
+ }
3826
+ function withColor(g, col) {
3827
+ const geo = g.index ? g.toNonIndexed() : g;
3828
+ const n = geo.getAttribute("position").count;
3829
+ const arr = new Float32Array(n * 3);
3830
+ for (let i = 0; i < n; i++) {
3831
+ arr[i * 3] = col[0];
3832
+ arr[i * 3 + 1] = col[1];
3833
+ arr[i * 3 + 2] = col[2];
3834
+ }
3835
+ geo.setAttribute("color", new THREE.Float32BufferAttribute(arr, 3));
3836
+ return geo;
3837
+ }
3838
+ function treeGeometry(kind) {
3839
+ const parts = [];
3840
+ const trunk = new THREE.CylinderGeometry(.19, .31, 3.6, 7, 1);
3841
+ trunk.translate(0, 1.8, 0);
3842
+ parts.push(withColor(trunk, [
3843
+ .3,
3844
+ .22,
3845
+ .16
3846
+ ]));
3847
+ if (kind === 0) {
3848
+ [
3849
+ [
3850
+ 0,
3851
+ 4.8,
3852
+ 0,
3853
+ 2.15
3854
+ ],
3855
+ [
3856
+ 1.5,
3857
+ 4.3,
3858
+ .5,
3859
+ 1.55
3860
+ ],
3861
+ [
3862
+ -1.4,
3863
+ 4.6,
3864
+ -.5,
3865
+ 1.6
3866
+ ],
3867
+ [
3868
+ .5,
3869
+ 6,
3870
+ -1,
3871
+ 1.5
3872
+ ],
3873
+ [
3874
+ -.6,
3875
+ 5.8,
3876
+ 1.2,
3877
+ 1.45
3878
+ ],
3879
+ [
3880
+ 1,
3881
+ 5.5,
3882
+ 1.4,
3883
+ 1.2
3884
+ ]
3885
+ ].forEach(([x, y, z, r], i) => {
3886
+ const g = new THREE.IcosahedronGeometry(r, 1);
3887
+ g.scale(1, .86, 1);
3888
+ g.translate(x, y, z);
3889
+ parts.push(withColor(g, [
3890
+ .26 + i % 3 * .035,
3891
+ .42 + i % 4 * .035,
3892
+ .2 + i % 2 * .02
3893
+ ]));
3894
+ });
3895
+ for (let i = 0; i < 4; i++) {
3896
+ const a = i / 4 * Math.PI * 2;
3897
+ const g = new THREE.CylinderGeometry(.06, .11, 1.7, 5);
3898
+ g.rotateZ(Math.sin(a) * .6);
3899
+ g.rotateX(Math.cos(a) * .6);
3900
+ g.translate(Math.cos(a) * .7, 3.2, Math.sin(a) * .7);
3901
+ parts.push(withColor(g, [
3902
+ .3,
3903
+ .22,
3904
+ .16
3905
+ ]));
3906
+ }
3907
+ } else if (kind === 1) for (let i = 0; i < 3; i++) {
3908
+ const g = new THREE.ConeGeometry(2.3 - i * .5, 2.6, 9, 1);
3909
+ g.translate(0, 3 + i * 1.5, 0);
3910
+ parts.push(withColor(g, [
3911
+ .15 + i * .02,
3912
+ .29 + i * .03,
3913
+ .17
3914
+ ]));
3915
+ }
3916
+ else {
3917
+ const top = new THREE.IcosahedronGeometry(2.4, 1);
3918
+ top.scale(1.3, .62, 1.3);
3919
+ top.translate(0, 4.9, 0);
3920
+ parts.push(withColor(top, [
3921
+ .31,
3922
+ .47,
3923
+ .23
3924
+ ]));
3925
+ for (let i = 0; i < 14; i++) {
3926
+ const a = i / 14 * Math.PI * 2, r = 1.5 + i % 3 * .35;
3927
+ const g = new THREE.CylinderGeometry(.035, .07, 3.3 + i % 4 * .5, 4, 1);
3928
+ g.translate(Math.cos(a) * r, 3.2, Math.sin(a) * r);
3929
+ parts.push(withColor(g, [
3930
+ .3,
3931
+ .46,
3932
+ .22
3933
+ ]));
3934
+ }
3935
+ }
3936
+ const merged = mergeGeometries(parts, false);
3937
+ parts.forEach((p) => p.dispose());
3938
+ return merged;
3939
+ }
3940
+ function beltGeometry() {
3941
+ const parts = [];
3942
+ const trunk = new THREE.CylinderGeometry(.18, .28, 3.4, 5, 1);
3943
+ trunk.translate(0, 1.7, 0);
3944
+ parts.push(withColor(trunk, [
3945
+ .3,
3946
+ .22,
3947
+ .16
3948
+ ]));
3949
+ for (let i = 0; i < 2; i++) {
3950
+ const g = new THREE.IcosahedronGeometry(i ? 1.6 : 2, 0);
3951
+ g.scale(1, .9, 1);
3952
+ g.translate(0, 3.7 + i * 1.5, 0);
3953
+ parts.push(withColor(g, [
3954
+ .22 + i * .04,
3955
+ .36 + i * .05,
3956
+ .21
3957
+ ]));
3958
+ }
3959
+ const merged = mergeGeometries(parts, false);
3960
+ parts.forEach((p) => p.dispose());
3961
+ return merged;
3962
+ }
3963
+ function grassTexture() {
3964
+ if (typeof document === "undefined") {
3965
+ const texture = new THREE.DataTexture(new Uint8Array([
3966
+ 135,
3967
+ 159,
3968
+ 88,
3969
+ 255
3970
+ ]), 1, 1);
3971
+ texture.colorSpace = THREE.SRGBColorSpace;
3972
+ texture.needsUpdate = true;
3973
+ return texture;
3974
+ }
3975
+ const cv = document.createElement("canvas");
3976
+ cv.width = cv.height = 64;
3977
+ const c = cv.getContext("2d");
3978
+ c.clearRect(0, 0, 64, 64);
3979
+ for (let i = 0; i < 9; i++) {
3980
+ const x = 6 + i * 6.5 + R() * 3, h = 26 + R() * 26;
3981
+ const g = c.createLinearGradient(x, 64, x, 64 - h);
3982
+ g.addColorStop(0, "#5c7138");
3983
+ g.addColorStop(.55, "#8ea354");
3984
+ g.addColorStop(1, "#c8cd84");
3985
+ c.fillStyle = g;
3986
+ c.beginPath();
3987
+ c.moveTo(x - 2.2, 64);
3988
+ c.quadraticCurveTo(x - 2, 64 - h * .6, x + (R() - .5) * 8, 64 - h);
3989
+ c.quadraticCurveTo(x + 2.4, 64 - h * .55, x + 2.2, 64);
3990
+ c.closePath();
3991
+ c.fill();
3992
+ }
3993
+ const t = new THREE.CanvasTexture(cv);
3994
+ t.colorSpace = THREE.SRGBColorSpace;
3995
+ return t;
3996
+ }
3997
+ function createNature(scene, M, ctx) {
3998
+ const group = new THREE.Group();
3999
+ group.name = "nature";
4000
+ scene.add(group);
4001
+ const [GW, GD] = WORLD.groundSize;
4002
+ const tg = new THREE.PlaneGeometry(GW, GD, 168, 132);
4003
+ tg.rotateX(-Math.PI / 2);
4004
+ const pos = tg.getAttribute("position");
4005
+ const colors = new Float32Array(pos.count * 3);
4006
+ const cGrass = new THREE.Color().setRGB(.76, .85, .52);
4007
+ const cDry = new THREE.Color().setRGB(.98, .88, .64);
4008
+ const cPath = new THREE.Color().setRGB(1.1, 1.02, .86);
4009
+ const cWet = new THREE.Color().setRGB(.52, .6, .44);
4010
+ const tmp = new THREE.Color();
4011
+ for (let i = 0; i < pos.count; i++) {
4012
+ const x = pos.getX(i), z = pos.getZ(i);
4013
+ const h = terrainHeight(x, z);
4014
+ pos.setY(i, h);
4015
+ const n = fbm(x / 28 + 3.1, z / 28 + 7.4, 61, 4, 8);
4016
+ tmp.copy(cGrass).lerp(cDry, clamp((n - .4) * 1.5, 0, 1));
4017
+ const pd = pathDist(x, z);
4018
+ tmp.lerp(cPath, (1 - smoothstep(2.2, 4, pd)) * .9);
4019
+ const wet = lakeDepthFactor(x, z);
4020
+ tmp.lerp(cWet, wet * .7);
4021
+ tmp.multiplyScalar(.94 + n * .22);
4022
+ colors[i * 3] = tmp.r;
4023
+ colors[i * 3 + 1] = tmp.g;
4024
+ colors[i * 3 + 2] = tmp.b;
4025
+ }
4026
+ tg.setAttribute("color", new THREE.Float32BufferAttribute(colors, 3));
4027
+ tg.computeVertexNormals();
4028
+ const groundMat = M.ground.clone();
4029
+ groundMat.vertexColors = true;
4030
+ groundMat.map.wrapS = groundMat.map.wrapT = THREE.RepeatWrapping;
4031
+ groundMat.map.repeat.set(1, 1);
4032
+ const ground = new THREE.Mesh(tg, groundMat);
4033
+ ground.receiveShadow = true;
4034
+ ground.name = "terrain";
4035
+ group.add(ground);
4036
+ const pebbleGeo = new THREE.IcosahedronGeometry(.24, 0);
4037
+ const pebbleMat = new THREE.MeshStandardMaterial({
4038
+ color: 10984582,
4039
+ roughness: 1
4040
+ });
4041
+ const pebbles = new THREE.InstancedMesh(pebbleGeo, pebbleMat, 900);
4042
+ const dummy = new THREE.Object3D();
4043
+ for (let i = 0; i < 900; i++) {
4044
+ let x, z, tries = 0;
4045
+ do {
4046
+ x = (R() - .5) * 340;
4047
+ z = (R() - .5) * 200 + 8;
4048
+ tries++;
4049
+ } while (blocked(x, z, -1.5) && tries < 12);
4050
+ dummy.position.set(x, terrainHeight(x, z) + .06, z);
4051
+ dummy.rotation.set(R() * 3, R() * 6, R() * 3);
4052
+ dummy.scale.setScalar(.4 + R() * 1.1);
4053
+ dummy.updateMatrix();
4054
+ pebbles.setMatrixAt(i, dummy.matrix);
4055
+ }
4056
+ pebbles.castShadow = false;
4057
+ pebbles.receiveShadow = true;
4058
+ group.add(pebbles);
4059
+ const treeGeos = [
4060
+ treeGeometry(0),
4061
+ treeGeometry(1),
4062
+ treeGeometry(2)
4063
+ ];
4064
+ const treeMat = new THREE.MeshStandardMaterial({
4065
+ vertexColors: true,
4066
+ roughness: .95,
4067
+ side: THREE.FrontSide
4068
+ });
4069
+ const positions = [
4070
+ [],
4071
+ [],
4072
+ []
4073
+ ];
4074
+ const rnd = mulberry32(990011);
4075
+ for (let i = 0; i < 1350; i++) {
4076
+ const x = (rnd() - .5) * 460, z = (rnd() - .5) * 350;
4077
+ const dist = Math.hypot(x, z);
4078
+ if (dist < 18 || dist > 250) continue;
4079
+ if (blocked(x, z, 3)) continue;
4080
+ if (rnd() < smoothstep(0, 90, dist) * .34) continue;
4081
+ positions[(lakeDepthFactor(x + 7, z - 7) > .02 || Math.abs(z - 100) < 26) && rnd() < .62 ? 2 : rnd() < .26 ? 1 : 0].push({
4082
+ x,
4083
+ y: terrainHeight(x, z),
4084
+ z,
4085
+ s: .62 + rnd() * .55,
4086
+ rot: rnd() * 6.28,
4087
+ tint: .82 + rnd() * .36
4088
+ });
4089
+ }
4090
+ const treeMeshes = [];
4091
+ positions.forEach((list, k) => {
4092
+ if (!list.length) return;
4093
+ const mesh = new THREE.InstancedMesh(treeGeos[k], treeMat, list.length);
4094
+ mesh.castShadow = true;
4095
+ mesh.receiveShadow = true;
4096
+ list.sort(() => R() - .5);
4097
+ list.forEach((p, i) => {
4098
+ dummy.position.set(p.x, p.y, p.z);
4099
+ dummy.rotation.set(0, p.rot, 0);
4100
+ dummy.scale.setScalar(p.s);
4101
+ dummy.updateMatrix();
4102
+ mesh.setMatrixAt(i, dummy.matrix);
4103
+ const tc = new THREE.Color().setRGB(p.tint, p.tint * (.94 + R() * .12), p.tint * .93);
4104
+ mesh.setColorAt(i, tc);
4105
+ });
4106
+ mesh.instanceMatrix.needsUpdate = true;
4107
+ if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
4108
+ mesh.userData.fullCount = list.length;
4109
+ mesh.userData.maxCount = list.length;
4110
+ group.add(mesh);
4111
+ treeMeshes.push(mesh);
4112
+ });
4113
+ const beltGeo = beltGeometry();
4114
+ const belt = new THREE.InstancedMesh(beltGeo, treeMat, 300);
4115
+ for (let i = 0; i < 300; i++) {
4116
+ const a = i / 300 * Math.PI * 2;
4117
+ const rad = 238 + rnd() * 34;
4118
+ const x = Math.cos(a) * rad, z = Math.sin(a) * rad * .78;
4119
+ dummy.position.set(x, terrainHeight(x, z) - .3, z);
4120
+ dummy.rotation.set(0, rnd() * 6.28, 0);
4121
+ dummy.scale.setScalar(.72 + rnd() * .62);
4122
+ dummy.updateMatrix();
4123
+ belt.setMatrixAt(i, dummy.matrix);
4124
+ belt.setColorAt(i, new THREE.Color().setRGB(.62 + rnd() * .25, .68 + rnd() * .22, .56 + rnd() * .2));
4125
+ }
4126
+ belt.castShadow = false;
4127
+ belt.receiveShadow = false;
4128
+ belt.userData.fullCount = 300;
4129
+ belt.userData.maxCount = 300;
4130
+ belt.instanceMatrix.needsUpdate = true;
4131
+ group.add(belt);
4132
+ treeMeshes.push(belt);
4133
+ const blade = new THREE.PlaneGeometry(.72, .82);
4134
+ blade.translate(0, .41, 0);
4135
+ const blade2 = blade.clone();
4136
+ blade2.rotateY(Math.PI / 2);
4137
+ const grassGeo = mergeGeometries([blade.toNonIndexed(), blade2.toNonIndexed()], false);
4138
+ const grassMat = new THREE.MeshStandardMaterial({
4139
+ map: grassTexture(),
4140
+ alphaTest: .42,
4141
+ side: THREE.DoubleSide,
4142
+ roughness: 1,
4143
+ transparent: false,
4144
+ depthWrite: true,
4145
+ color: 16777215
4146
+ });
4147
+ grassMat.onBeforeCompile = (shader) => {
4148
+ shader.uniforms.uFadeNear = { value: 62 };
4149
+ shader.uniforms.uFadeFar = { value: 145 };
4150
+ shader.vertexShader = shader.vertexShader.replace("#include <common>", "#include <common>\nuniform float uFadeNear;\nuniform float uFadeFar;").replace("#include <begin_vertex>", `#include <begin_vertex>
4151
+ #ifdef USE_INSTANCING
4152
+ vec4 grassWorld = modelMatrix * instanceMatrix * vec4(transformed, 1.0);
4153
+ #else
4154
+ vec4 grassWorld = modelMatrix * vec4(transformed, 1.0);
4155
+ #endif
4156
+ float grassD = distance(grassWorld.xz, cameraPosition.xz);
4157
+ transformed *= 1.0 - smoothstep(uFadeNear, uFadeFar, grassD);`);
4158
+ grassMat.userData.shader = shader;
4159
+ };
4160
+ const grassCount = 9e3;
4161
+ const grass = new THREE.InstancedMesh(grassGeo, grassMat, grassCount);
4162
+ let placed = 0, guard = 0;
4163
+ while (placed < grassCount && guard < grassCount * 6) {
4164
+ guard++;
4165
+ const x = (R() - .5) * 340, z = (R() - .5) * 220 + 4;
4166
+ if (blocked(x, z, 1)) continue;
4167
+ const h = terrainHeight(x, z);
4168
+ if (h < -.4) continue;
4169
+ dummy.position.set(x, h + .01, z);
4170
+ dummy.rotation.set(0, R() * 6.28, 0);
4171
+ dummy.scale.setScalar(.55 + R() * .9);
4172
+ dummy.updateMatrix();
4173
+ grass.setMatrixAt(placed, dummy.matrix);
4174
+ const g = .72 + R() * .5;
4175
+ grass.setColorAt(placed, new THREE.Color().setRGB(g * .9, g, g * .68));
4176
+ placed++;
4177
+ }
4178
+ grass.count = placed;
4179
+ grass.castShadow = false;
4180
+ grass.receiveShadow = false;
4181
+ grass.userData.fullCount = placed;
4182
+ grass.userData.maxCount = placed;
4183
+ grass.instanceMatrix.needsUpdate = true;
4184
+ group.add(grass);
4185
+ const reedGeo = mergeGeometries([new THREE.CylinderGeometry(.025, .045, 2, 4).translate(0, 1, 0).toNonIndexed(), new THREE.CylinderGeometry(.09, .07, .42, 6).translate(0, 2.1, 0).toNonIndexed()], false);
4186
+ const reedMat = new THREE.MeshStandardMaterial({
4187
+ color: 8096330,
4188
+ roughness: 1
4189
+ });
4190
+ const reeds = new THREE.InstancedMesh(reedGeo, reedMat, 420);
4191
+ const lilyMat = new THREE.MeshStandardMaterial({
4192
+ color: 5009472,
4193
+ roughness: .9,
4194
+ side: THREE.DoubleSide
4195
+ });
4196
+ const lily = new THREE.InstancedMesh(new THREE.CircleGeometry(.62, 10), lilyMat, 220);
4197
+ const flowerMat = new THREE.MeshStandardMaterial({
4198
+ color: 15251394,
4199
+ roughness: .75
4200
+ });
4201
+ const flowers = new THREE.InstancedMesh(new THREE.IcosahedronGeometry(.24, 0), flowerMat, 90);
4202
+ let ri = 0, li = 0, fi = 0, rg = 0;
4203
+ while ((ri < 420 || li < 220) && rg < 9e3) {
4204
+ rg++;
4205
+ const a = R() * Math.PI * 2;
4206
+ const edge = lakeShoreAngle(a) * (.72 + R() * .32);
4207
+ const x = LAKE_C[0] + Math.cos(a) * LAKE_R[0] * edge;
4208
+ const z = LAKE_C[1] + Math.sin(a) * LAKE_R[1] * edge;
4209
+ if (R() < .55 && ri < 420) {
4210
+ dummy.position.set(x, -.5, z);
4211
+ dummy.rotation.set((R() - .5) * .2, R() * 6.28, (R() - .5) * .2);
4212
+ dummy.scale.setScalar(.6 + R() * .75);
4213
+ dummy.updateMatrix();
4214
+ reeds.setMatrixAt(ri++, dummy.matrix);
4215
+ } else if (li < 220) {
4216
+ dummy.position.set(x + (R() - .5) * 5, -.52 + R() * .04, z + (R() - .5) * 4);
4217
+ dummy.rotation.set(-Math.PI / 2, 0, R() * 6.28);
4218
+ dummy.scale.setScalar(.6 + R() * .7);
4219
+ dummy.updateMatrix();
4220
+ lily.setMatrixAt(li++, dummy.matrix);
4221
+ if (fi < 90 && R() < .42) {
4222
+ dummy.position.y += .18;
4223
+ dummy.rotation.set(0, R() * 6.28, 0);
4224
+ dummy.scale.setScalar(.7 + R() * .8);
4225
+ dummy.updateMatrix();
4226
+ flowers.setMatrixAt(fi++, dummy.matrix);
4227
+ }
4228
+ }
4229
+ }
4230
+ reeds.count = ri;
4231
+ lily.count = li;
4232
+ flowers.count = fi;
4233
+ [
4234
+ reeds,
4235
+ lily,
4236
+ flowers
4237
+ ].forEach((m) => {
4238
+ m.instanceMatrix.needsUpdate = true;
4239
+ m.castShadow = false;
4240
+ group.add(m);
4241
+ });
4242
+ const rub = ctx.rubble;
4243
+ const rubble = new THREE.InstancedMesh(chamferBoxGeo(1, 1, 1, .06), M.stone, rub.length);
4244
+ rub.forEach((p, i) => {
4245
+ dummy.position.set(p.pos[0], terrainHeight(p.pos[0], p.pos[2]) + p.s * .28, p.pos[2]);
4246
+ dummy.rotation.set((R() - .5) * .7, p.rot, (R() - .5) * .7);
4247
+ dummy.scale.set(p.s * (1 + R() * .7), p.s * (.4 + R() * .5), p.s * (.7 + R() * .6));
4248
+ dummy.updateMatrix();
4249
+ rubble.setMatrixAt(i, dummy.matrix);
4250
+ });
4251
+ rubble.castShadow = true;
4252
+ rubble.receiveShadow = true;
4253
+ rubble.instanceMatrix.needsUpdate = true;
4254
+ group.add(rubble);
4255
+ const drums = new THREE.InstancedMesh(new THREE.CylinderGeometry(.52, .52, 1.5, 14), M.marbleD, 26);
4256
+ for (let i = 0; i < 26; i++) {
4257
+ const nearHai = i < 13;
4258
+ const a = R() * 6.28, rad = 12 + R() * 18;
4259
+ const x = (nearHai ? -72 : 40) + Math.cos(a) * rad;
4260
+ const z = (nearHai ? 8 : -2) + Math.sin(a) * rad * .6;
4261
+ dummy.position.set(x, terrainHeight(x, z) + .5, z);
4262
+ dummy.rotation.set(Math.PI / 2 + (R() - .5) * .35, R() * 6.28, R() * .5);
4263
+ dummy.scale.setScalar(.75 + R() * .5);
4264
+ dummy.updateMatrix();
4265
+ drums.setMatrixAt(i, dummy.matrix);
4266
+ }
4267
+ drums.castShadow = true;
4268
+ drums.receiveShadow = true;
4269
+ drums.instanceMatrix.needsUpdate = true;
4270
+ group.add(drums);
4271
+ const bridge = new THREE.Group();
4272
+ const stone = M.marbleD;
4273
+ for (let i = 0; i < 9; i++) {
4274
+ const bx = 62 + i * 3.1;
4275
+ const arch = Math.sin(i / 8 * Math.PI) * 1.4;
4276
+ const seg = new THREE.Mesh(boxGeoProxy(3.2, .32, 3.4), stone);
4277
+ seg.position.set(bx, -.1 + arch, 92);
4278
+ seg.castShadow = true;
4279
+ seg.receiveShadow = true;
4280
+ bridge.add(seg);
4281
+ }
4282
+ for (const s of [-1, 1]) for (let i = 0; i < 9; i++) {
4283
+ const rail = new THREE.Mesh(boxGeoProxy(3.2, .12, .18), stone);
4284
+ rail.position.set(62 + i * 3.1, .65 + Math.sin(i / 8 * Math.PI) * 1.4, 92 + s * 1.7);
4285
+ bridge.add(rail);
4286
+ const post = new THREE.Mesh(boxGeoProxy(.22, .72, .22), stone);
4287
+ post.position.set(62 + i * 3.1, .5 + Math.sin(i / 8 * Math.PI) * 1.4, 92 + s * 1.7);
4288
+ bridge.add(post);
4289
+ }
4290
+ group.add(bridge);
4291
+ return {
4292
+ group,
4293
+ ground,
4294
+ treeMeshes,
4295
+ grass,
4296
+ reeds,
4297
+ lily,
4298
+ flowers,
4299
+ pebbles,
4300
+ applyQuality(q) {
4301
+ treeMeshes.forEach((m) => {
4302
+ m.count = Math.max(1, Math.floor(m.userData.maxCount * q.trees));
4303
+ });
4304
+ grass.count = Math.min(grass.userData.maxCount, q.grass);
4305
+ const sh = grassMat.userData.shader;
4306
+ if (sh) {
4307
+ sh.uniforms.uFadeNear.value = q.fadeFar * .42;
4308
+ sh.uniforms.uFadeFar.value = q.fadeFar;
4309
+ }
4310
+ groundMat.map.anisotropy = q.aniso;
4311
+ groundMat.map.needsUpdate = true;
4312
+ }
4313
+ };
4314
+ }
4315
+ function boxGeoProxy(w, h, d) {
4316
+ return new THREE.BoxGeometry(w, h, d);
4317
+ }
4318
+ // modules/world/content/yuanmingyuan/sky.js
4319
+ const SKY_VERT = `
4320
+ varying vec3 vDir;
4321
+ void main() {
4322
+ vDir = normalize(position);
4323
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
4324
+ }`;
4325
+ const SKY_FRAG = `
4326
+ precision highp float;
4327
+ varying vec3 vDir;
4328
+ uniform vec3 uSunDir;
4329
+ uniform vec3 uSunColor;
4330
+ uniform vec3 uZenith;
4331
+ uniform vec3 uHorizon;
4332
+ uniform float uTime;
4333
+ uniform float uHaze;
4334
+
4335
+ float hash(vec2 p){ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123); }
4336
+ float noise(vec2 p){
4337
+ vec2 i = floor(p), f = fract(p);
4338
+ vec2 u = f*f*(3.0-2.0*f);
4339
+ return mix(mix(hash(i), hash(i+vec2(1.0,0.0)), u.x),
4340
+ mix(hash(i+vec2(0.0,1.0)), hash(i+vec2(1.0,1.0)), u.x), u.y);
4341
+ }
4342
+ float fbm(vec2 p){
4343
+ float v = 0.0, a = 0.5;
4344
+ for(int i=0;i<5;i++){ v += a*noise(p); p *= 2.03; a *= 0.5; }
4345
+ return v;
4346
+ }
4347
+ void main() {
4348
+ vec3 d = normalize(vDir);
4349
+ float h = max(d.y, 0.0);
4350
+ vec3 col = mix(uHorizon, uZenith, pow(h, 0.62));
4351
+ // 地平线暖色带与大气散射
4352
+ float glowBand = exp(-h * 9.0);
4353
+ col = mix(col, uHorizon * 1.06, glowBand * 0.55);
4354
+ float sd = max(dot(d, normalize(uSunDir)), 0.0);
4355
+ col += uSunColor * pow(sd, 7.0) * 0.22 * uHaze;
4356
+ col += uSunColor * pow(sd, 130.0) * 0.85;
4357
+ col += uSunColor * pow(sd, 2600.0) * 7.0;
4358
+ // 卷积云:以方向投影到云层平面
4359
+ vec2 cp = d.xz / max(d.y + 0.14, 0.05);
4360
+ float n = fbm(cp * 0.20 + vec2(uTime * 0.0025, uTime * 0.0012));
4361
+ float n2 = fbm(cp * 0.62 + vec2(-uTime * 0.003, 0.0));
4362
+ float cloud = smoothstep(0.48, 0.68, n * 0.78 + n2 * 0.22) * smoothstep(-0.01, 0.10, h);
4363
+ vec3 cloudCol = mix(uHorizon * 1.02, vec3(1.0, 0.97, 0.92), 0.35 + pow(sd, 4.0) * 0.5);
4364
+ col = mix(col, cloudCol, cloud * 0.55);
4365
+ // 贴地薄雾
4366
+ col = mix(col, uHorizon, exp(-max(d.y, -0.05) * 22.0) * 0.32);
4367
+ gl_FragColor = vec4(col, 1.0);
4368
+ #include <tonemapping_fragment>
4369
+ #include <colorspace_fragment>
4370
+ }`;
4371
+ const KEYS = [
4372
+ {
4373
+ h: 5.5,
4374
+ zen: "#3c5480",
4375
+ hor: "#d99a76",
4376
+ sun: "#ff9a5e",
4377
+ inten: .5,
4378
+ expo: .78,
4379
+ hemi: .35
4380
+ },
4381
+ {
4382
+ h: 8,
4383
+ zen: "#4a7db5",
4384
+ hor: "#ddc6a6",
4385
+ sun: "#ffd9a3",
4386
+ inten: 2.7,
4387
+ expo: 1.02,
4388
+ hemi: .56
4389
+ },
4390
+ {
4391
+ h: 12,
4392
+ zen: "#3974bb",
4393
+ hor: "#c6dbe9",
4394
+ sun: "#fff4e2",
4395
+ inten: 3.8,
4396
+ expo: 1.08,
4397
+ hemi: .7
4398
+ },
4399
+ {
4400
+ h: 16.4,
4401
+ zen: "#4d79ab",
4402
+ hor: "#d7b18c",
4403
+ sun: "#ffcf94",
4404
+ inten: 3.5,
4405
+ expo: 1.16,
4406
+ hemi: .6
4407
+ },
4408
+ {
4409
+ h: 18.3,
4410
+ zen: "#3f5482",
4411
+ hor: "#d98b69",
4412
+ sun: "#ff945c",
4413
+ inten: 1.15,
4414
+ expo: .98,
4415
+ hemi: .42
4416
+ },
4417
+ {
4418
+ h: 19.6,
4419
+ zen: "#222f55",
4420
+ hor: "#7d5a68",
4421
+ sun: "#ff7b52",
4422
+ inten: .22,
4423
+ expo: .85,
4424
+ hemi: .28
4425
+ }
4426
+ ];
4427
+ const c = (hex) => new THREE.Color(hex);
4428
+ function createSky(scene, renderer) {
4429
+ const uniforms = {
4430
+ uSunDir: { value: new THREE.Vector3(-.6, .4, .5) },
4431
+ uSunColor: { value: c("#ffc78a") },
4432
+ uZenith: { value: c("#6287b4") },
4433
+ uHorizon: { value: c("#e9bd8b") },
4434
+ uTime: { value: 0 },
4435
+ uHaze: { value: 1 }
4436
+ };
4437
+ const sky = new THREE.Mesh(new THREE.SphereGeometry(1400, 40, 22), new THREE.ShaderMaterial({
4438
+ uniforms,
4439
+ vertexShader: SKY_VERT,
4440
+ fragmentShader: SKY_FRAG,
4441
+ side: THREE.BackSide,
4442
+ depthWrite: false,
4443
+ fog: false
4444
+ }));
4445
+ sky.renderOrder = -1e3;
4446
+ sky.frustumCulled = false;
4447
+ scene.add(sky);
4448
+ const sun = new THREE.DirectionalLight(16762762, 3.05);
4449
+ sun.castShadow = true;
4450
+ sun.shadow.mapSize.set(4096, 4096);
4451
+ const sc = sun.shadow.camera;
4452
+ sc.left = -125;
4453
+ sc.right = 125;
4454
+ sc.top = 125;
4455
+ sc.bottom = -125;
4456
+ sc.near = 1;
4457
+ sc.far = 520;
4458
+ sun.shadow.bias = -35e-5;
4459
+ sun.shadow.normalBias = .035;
4460
+ sun.shadow.radius = 2.2;
4461
+ sun.target.position.set(-10, 0, 0);
4462
+ scene.add(sun, sun.target);
4463
+ const hemi = new THREE.HemisphereLight(12441322, 10125664, .66);
4464
+ scene.add(hemi);
4465
+ const ambient = new THREE.AmbientLight(13227229, .42);
4466
+ scene.add(ambient);
4467
+ const fill = new THREE.DirectionalLight(10337496, .55);
4468
+ fill.position.set(90, 70, -100);
4469
+ scene.add(fill);
4470
+ const fog = new THREE.FogExp2(14206124, .00155);
4471
+ scene.fog = fog;
4472
+ const lamps = [];
4473
+ [
4474
+ [
4475
+ -72,
4476
+ 6,
4477
+ 12
4478
+ ],
4479
+ [
4480
+ 40,
4481
+ 4,
4482
+ 6
4483
+ ],
4484
+ [
4485
+ 40,
4486
+ 6,
4487
+ -28
4488
+ ],
4489
+ [
4490
+ -138,
4491
+ 5,
4492
+ 12
4493
+ ]
4494
+ ].forEach(([x, y, z]) => {
4495
+ const p = new THREE.PointLight(16758123, 0, 26, 2);
4496
+ p.position.set(x, y, z);
4497
+ scene.add(p);
4498
+ lamps.push(p);
4499
+ });
4500
+ const api = {
4501
+ uniforms,
4502
+ sun,
4503
+ hemi,
4504
+ fill,
4505
+ fog,
4506
+ sky,
4507
+ lamps,
4508
+ sunDir: new THREE.Vector3(),
4509
+ setHour(hour) {
4510
+ const t = Math.min(Math.max(hour, KEYS[0].h), KEYS[KEYS.length - 1].h);
4511
+ let i = 0;
4512
+ while (i < KEYS.length - 2 && t > KEYS[i + 1].h) i++;
4513
+ const a = KEYS[i], b = KEYS[i + 1];
4514
+ const k = (t - a.h) / (b.h - a.h);
4515
+ const lerpC = (ca, cb) => c(ca).lerp(c(cb), k);
4516
+ const zen = lerpC(a.zen, b.zen), hor = lerpC(a.hor, b.hor), sunC = lerpC(a.sun, b.sun);
4517
+ uniforms.uZenith.value.copy(zen);
4518
+ uniforms.uHorizon.value.copy(hor);
4519
+ uniforms.uSunColor.value.copy(sunC);
4520
+ const p = (t - 6) / 12;
4521
+ const elev = Math.sin(Math.max(0, Math.min(1, p)) * Math.PI) * .86 + .045;
4522
+ const az = Math.PI * (.12 + Math.max(0, Math.min(1, p)) * .74);
4523
+ const dir = new THREE.Vector3(Math.cos(az), elev, Math.sin(az) * .72).normalize();
4524
+ api.sunDir.copy(dir);
4525
+ uniforms.uSunDir.value.copy(dir);
4526
+ sun.position.copy(dir).multiplyScalar(210);
4527
+ sun.target.position.set(-10, 0, 0);
4528
+ sun.color.copy(sunC);
4529
+ sun.intensity = THREE.MathUtils.lerp(a.inten, b.inten, k);
4530
+ hemi.intensity = THREE.MathUtils.lerp(a.hemi, b.hemi, k);
4531
+ hemi.color.copy(zen).lerp(c("#dce9f2"), .45);
4532
+ fill.intensity = .46 + (1 - elev) * .38;
4533
+ renderer.toneMappingExposure = THREE.MathUtils.lerp(a.expo, b.expo, k);
4534
+ fog.color.copy(hor).lerp(zen, .24);
4535
+ fog.density = 92e-5 + (1 - elev) * 48e-5;
4536
+ uniforms.uHaze.value = .55 + (1 - elev) * .85;
4537
+ const dusk = THREE.MathUtils.clamp((18.1 - t) / 2.2, 0, 1) * THREE.MathUtils.clamp((t - 16.8) / 1.6, 0, 1);
4538
+ lamps.forEach((l) => {
4539
+ l.intensity = dusk * 16;
4540
+ });
4541
+ api.dusk = dusk;
4542
+ renderer.shadowMap.needsUpdate = true;
4543
+ },
4544
+ setShadowSize(size) {
4545
+ if (sun.shadow.mapSize.x === size) return;
4546
+ sun.shadow.mapSize.set(size, size);
4547
+ if (sun.shadow.map) {
4548
+ sun.shadow.map.dispose();
4549
+ sun.shadow.map = null;
4550
+ }
4551
+ renderer.shadowMap.needsUpdate = true;
4552
+ },
4553
+ update(dt, camera) {
4554
+ uniforms.uTime.value += dt;
4555
+ sky.position.copy(camera.position);
4556
+ }
4557
+ };
4558
+ return api;
4559
+ }
4560
+ // modules/world/content/yuanmingyuan/water.js
4561
+ const WATER_VERT = `
4562
+ uniform float uTime;
4563
+ uniform float uWave;
4564
+ varying vec3 vWorld;
4565
+ varying vec2 vUv;
4566
+ void main() {
4567
+ vec3 p = position;
4568
+ p.y += (sin(p.x * 0.75 + uTime * 1.35) * 0.038 + sin(p.z * 1.05 - uTime * 1.75) * 0.026) * uWave;
4569
+ vec4 wp = modelMatrix * vec4(p, 1.0);
4570
+ vWorld = wp.xyz;
4571
+ vUv = uv;
4572
+ gl_Position = projectionMatrix * viewMatrix * wp;
4573
+ }`;
4574
+ const WATER_FRAG = `
4575
+ precision highp float;
4576
+ uniform float uTime;
4577
+ uniform float uMode;
4578
+ uniform vec3 uSunDir;
4579
+ uniform vec3 uSunColor;
4580
+ uniform vec3 uZenith;
4581
+ uniform vec3 uHorizon;
4582
+ uniform vec3 uDeep;
4583
+ uniform vec3 uFogColor;
4584
+ uniform float uFogDensity;
4585
+ uniform vec2 uLakeCenter;
4586
+ uniform vec2 uLakeRadii;
4587
+ varying vec3 vWorld;
4588
+ varying vec2 vUv;
4589
+
4590
+ void main() {
4591
+ vec2 p = vWorld.xz;
4592
+ float t = uTime;
4593
+ vec3 n = normalize(vec3(
4594
+ sin(p.x * 1.15 + t * 1.35) * 0.052 + sin(p.y * 2.1 - t * 1.1) * 0.028,
4595
+ 1.0,
4596
+ cos(p.y * 1.35 + t * 1.2) * 0.052 + cos(p.x * 2.4 + t * 0.85) * 0.024));
4597
+ vec3 V = normalize(cameraPosition - vWorld);
4598
+ float fres = pow(1.0 - clamp(dot(n, V), 0.0, 1.0), 3.0);
4599
+ vec3 R = reflect(-V, n);
4600
+ vec3 sky = mix(mix(uHorizon, uZenith, 0.48), uZenith, pow(clamp(R.y, 0.0, 1.0), 0.6));
4601
+ vec3 col = mix(uDeep, sky, clamp(0.06 + fres * 0.48, 0.0, 1.0));
4602
+ // 稀疏的高频波光,避免大面积规则棋盘状高光
4603
+ float micro = sin(p.x * 21.0 + t * 2.7) * sin(p.y * 17.0 - t * 2.1);
4604
+ float glint = pow(max(dot(reflect(-normalize(uSunDir), n), V), 0.0), 820.0);
4605
+ col += uSunColor * (pow(max(micro, 0.0), 14.0) * 0.055 + glint * 0.45);
4606
+
4607
+ if (uMode < 0.5) {
4608
+ vec2 q = (vWorld.xz - uLakeCenter) / uLakeRadii;
4609
+ float a = atan(q.y, q.x);
4610
+ float edge = 1.0 + 0.10 * sin(a * 3.0 + 1.3) + 0.06 * sin(a * 7.0 + 0.4)
4611
+ + 0.025 * sin(a * 13.0 + 2.1);
4612
+ float d = length(q);
4613
+ if (d > edge) discard;
4614
+ float foam = smoothstep(edge - 0.028, edge, d);
4615
+ col = mix(col, vec3(0.74, 0.80, 0.78), foam * 0.30);
4616
+ col = mix(col, uDeep * 1.05, smoothstep(0.0, 0.7, d) * 0.25);
4617
+ } else {
4618
+ float d = length(vUv - 0.5) * 2.0;
4619
+ float rings = sin(d * 26.0 - t * 3.4) * 0.5 + 0.5;
4620
+ col += vec3(0.10, 0.14, 0.15) * rings * (1.0 - d) * 0.35;
4621
+ float rim = smoothstep(0.86, 1.0, d);
4622
+ col = mix(col, vec3(0.84, 0.90, 0.90), rim * 0.3);
4623
+ }
4624
+ float dist = length(cameraPosition - vWorld);
4625
+ float f = 1.0 - exp(-uFogDensity * uFogDensity * dist * dist);
4626
+ col = mix(col, uFogColor, clamp(f, 0.0, 1.0));
4627
+ gl_FragColor = vec4(col, 1.0);
4628
+ #include <tonemapping_fragment>
4629
+ #include <colorspace_fragment>
4630
+ }`;
4631
+ const DROP_VERT = `
4632
+ attribute vec3 aOrigin;
4633
+ attribute vec3 aVel;
4634
+ attribute float aSeed;
4635
+ attribute float aSize;
4636
+ attribute float aLife;
4637
+ uniform float uTime;
4638
+ uniform float uPixelRatio;
4639
+ varying float vAlpha;
4640
+ void main() {
4641
+ float t = mod(uTime * 0.82 + aSeed, aLife);
4642
+ vec3 p = aOrigin + aVel * t - vec3(0.0, 2.45 * t * t, 0.0);
4643
+ vec4 mv = modelViewMatrix * vec4(p, 1.0);
4644
+ gl_Position = projectionMatrix * mv;
4645
+ gl_PointSize = aSize * uPixelRatio * (330.0 / max(-mv.z, 1.0));
4646
+ vAlpha = (1.0 - t / aLife) * smoothstep(0.0, 0.10, t);
4647
+ }`;
4648
+ const DROP_FRAG = `
4649
+ precision mediump float;
4650
+ varying float vAlpha;
4651
+ void main() {
4652
+ vec2 q = gl_PointCoord - 0.5;
4653
+ float d = length(q);
4654
+ float a = smoothstep(0.5, 0.04, d) * vAlpha * 0.8;
4655
+ if (a < 0.01) discard;
4656
+ gl_FragColor = vec4(mix(vec3(0.66, 0.83, 0.94), vec3(1.0), 1.0 - d * 1.8), a);
4657
+ }`;
4658
+ const FLOW_VERT = `
4659
+ varying vec2 vUvF;
4660
+ void main(){ vUvF = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); }`;
4661
+ const FLOW_FRAG = `
4662
+ precision mediump float;
4663
+ uniform float uTime;
4664
+ uniform float uOpacity;
4665
+ varying vec2 vUvF;
4666
+ void main() {
4667
+ float band = sin(vUvF.y * 42.0 - uTime * 9.0) * 0.5 + 0.5;
4668
+ float streak = sin(vUvF.x * 26.0 + uTime * 1.4) * 0.5 + 0.5;
4669
+ float a = (0.12 + band * 0.28 + streak * 0.12) * uOpacity;
4670
+ gl_FragColor = vec4(vec3(0.78, 0.90, 0.97), a);
4671
+ }`;
4672
+ function createWater(scene, skyApi, ctx) {
4673
+ const shared = {
4674
+ uTime: { value: 0 },
4675
+ uSunDir: skyApi.uniforms.uSunDir,
4676
+ uSunColor: skyApi.uniforms.uSunColor,
4677
+ uZenith: skyApi.uniforms.uZenith,
4678
+ uHorizon: skyApi.uniforms.uHorizon,
4679
+ uFogColor: { value: new THREE.Color() },
4680
+ uFogDensity: { value: .0015 },
4681
+ uLakeCenter: { value: new THREE.Vector2(18, 112) },
4682
+ uLakeRadii: { value: new THREE.Vector2(128, 42) }
4683
+ };
4684
+ const makeMat = (mode, wave, deep) => new THREE.ShaderMaterial({
4685
+ uniforms: Object.assign({}, shared, {
4686
+ uMode: { value: mode },
4687
+ uWave: { value: wave },
4688
+ uDeep: { value: new THREE.Color(deep) }
4689
+ }),
4690
+ vertexShader: WATER_VERT,
4691
+ fragmentShader: WATER_FRAG,
4692
+ side: THREE.DoubleSide,
4693
+ transparent: false,
4694
+ depthWrite: true
4695
+ });
4696
+ const lakeMat = makeMat(0, 1, "#274145");
4697
+ const basinMat = makeMat(1, .45, "#315451");
4698
+ const lake = new THREE.Mesh(new THREE.PlaneGeometry(330, 150, 72, 36), lakeMat);
4699
+ lake.rotation.x = -Math.PI / 2;
4700
+ lake.position.set(18, -.58, 112);
4701
+ lake.receiveShadow = false;
4702
+ scene.add(lake);
4703
+ const circle = new THREE.CircleGeometry(1, 56);
4704
+ ctx.waters.forEach((w) => {
4705
+ const m = new THREE.Mesh(circle, basinMat);
4706
+ m.rotation.x = -Math.PI / 2;
4707
+ m.position.set(w.x, w.y, w.z);
4708
+ m.scale.set(w.rx, w.rz, 1);
4709
+ m.renderOrder = 1;
4710
+ scene.add(m);
4711
+ });
4712
+ const origins = [], vels = [], seeds = [], sizes = [], lifes = [];
4713
+ const ribbonGeos = [];
4714
+ ctx.jets.forEach((j) => {
4715
+ const life = 1.05 + R() * .45;
4716
+ const count = j.n * 7;
4717
+ for (let i = 0; i < count; i++) {
4718
+ origins.push(j.pos[0], j.pos[1], j.pos[2]);
4719
+ const spread = .2;
4720
+ vels.push(j.vel[0] + (R() - .5) * spread * (Math.abs(j.vel[0]) + 1), j.vel[1] + (R() - .5) * spread * 2, j.vel[2] + (R() - .5) * spread * (Math.abs(j.vel[2]) + 1));
4721
+ seeds.push(R() * 12);
4722
+ sizes.push(j.size * (.55 + R() * .9) * 10);
4723
+ lifes.push(life);
4724
+ }
4725
+ const pts = [];
4726
+ for (let i = 0; i <= 12; i++) {
4727
+ const t = i / 12 * life;
4728
+ pts.push(new THREE.Vector3(j.pos[0] + j.vel[0] * t, j.pos[1] + j.vel[1] * t - 2.45 * t * t, j.pos[2] + j.vel[2] * t));
4729
+ }
4730
+ const curve = new THREE.CatmullRomCurve3(pts);
4731
+ ribbonGeos.push(new THREE.TubeGeometry(curve, 16, j.size * .62, 5, false));
4732
+ });
4733
+ const pg = new THREE.BufferGeometry();
4734
+ pg.setAttribute("position", new THREE.Float32BufferAttribute(origins.map(() => 0), 3));
4735
+ pg.setAttribute("aOrigin", new THREE.Float32BufferAttribute(origins, 3));
4736
+ pg.setAttribute("aVel", new THREE.Float32BufferAttribute(vels, 3));
4737
+ pg.setAttribute("aSeed", new THREE.Float32BufferAttribute(seeds, 1));
4738
+ pg.setAttribute("aSize", new THREE.Float32BufferAttribute(sizes, 1));
4739
+ pg.setAttribute("aLife", new THREE.Float32BufferAttribute(lifes, 1));
4740
+ const dropUniforms = {
4741
+ uTime: { value: 0 },
4742
+ uPixelRatio: { value: 1 }
4743
+ };
4744
+ const drops = new THREE.Points(pg, new THREE.ShaderMaterial({
4745
+ uniforms: dropUniforms,
4746
+ vertexShader: DROP_VERT,
4747
+ fragmentShader: DROP_FRAG,
4748
+ transparent: true,
4749
+ depthWrite: false,
4750
+ blending: THREE.AdditiveBlending
4751
+ }));
4752
+ drops.frustumCulled = false;
4753
+ drops.renderOrder = 6;
4754
+ scene.add(drops);
4755
+ const flowUniforms = {
4756
+ uTime: { value: 0 },
4757
+ uOpacity: { value: 1 }
4758
+ };
4759
+ const flowMat = new THREE.ShaderMaterial({
4760
+ uniforms: flowUniforms,
4761
+ vertexShader: FLOW_VERT,
4762
+ fragmentShader: FLOW_FRAG,
4763
+ transparent: true,
4764
+ depthWrite: false,
4765
+ blending: THREE.AdditiveBlending,
4766
+ side: THREE.DoubleSide
4767
+ });
4768
+ const ribbons = new THREE.Mesh(mergeGeometries(ribbonGeos.map((g) => g.toNonIndexed()), false), flowMat);
4769
+ ribbons.frustumCulled = false;
4770
+ ribbons.renderOrder = 5;
4771
+ scene.add(ribbons);
4772
+ ribbonGeos.forEach((g) => g.dispose());
4773
+ const curtains = [];
4774
+ for (let l = 0; l < 3; l++) curtains.push({
4775
+ x: 40,
4776
+ y: .72 - l * .14,
4777
+ z: -4.25 + l * 2.4,
4778
+ w: 24 - l * 1.2,
4779
+ h: .75
4780
+ });
4781
+ const curtainMeshes = [];
4782
+ curtains.forEach((c) => {
4783
+ const m = new THREE.Mesh(new THREE.PlaneGeometry(c.w, c.h, 12, 2), flowMat);
4784
+ m.position.set(c.x, c.y + c.h / 2, c.z + 1.15);
4785
+ m.renderOrder = 5;
4786
+ scene.add(m);
4787
+ curtainMeshes.push(m);
4788
+ });
4789
+ return {
4790
+ lake,
4791
+ basinMat,
4792
+ lakeMat,
4793
+ drops,
4794
+ ribbons,
4795
+ flowMat,
4796
+ curtains: curtainMeshes,
4797
+ uniforms: shared,
4798
+ dropUniforms,
4799
+ flowUniforms,
4800
+ setPixelRatio(p) {
4801
+ dropUniforms.uPixelRatio.value = p;
4802
+ },
4803
+ update(dt, sky) {
4804
+ shared.uTime.value += dt;
4805
+ dropUniforms.uTime.value = shared.uTime.value;
4806
+ flowUniforms.uTime.value = shared.uTime.value;
4807
+ shared.uFogColor.value.copy(sky.fog.color);
4808
+ shared.uFogDensity.value = sky.fog.density;
4809
+ }
4810
+ };
4811
+ }
4812
+ // modules/world/content/yuanmingyuan/index.js
4813
+ const ID = "yuanmingyuan-western-mansions";
4814
+ function makeGroundProxy() {
4815
+ const geometry = new THREE.PlaneGeometry(WORLD.groundSize[0], WORLD.groundSize[1], 48, 36);
4816
+ geometry.rotateX(-Math.PI / 2);
4817
+ const position = geometry.getAttribute("position");
4818
+ for (let index = 0; index < position.count; index++) position.setY(index, terrainHeight(position.getX(index), position.getZ(index)));
4819
+ position.needsUpdate = true;
4820
+ geometry.computeVertexNormals();
4821
+ const mesh = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial({ visible: false }));
4822
+ mesh.name = "YuanmingyuanGroundProxy";
4823
+ mesh.userData.navigationIgnore = false;
4824
+ return {
4825
+ mesh,
4826
+ collider: {
4827
+ shape: "trimesh",
4828
+ vertices: Array.from(geometry.getAttribute("position").array),
4829
+ indices: Array.from(geometry.getIndex().array)
4830
+ }
4831
+ };
4832
+ }
4833
+ function createYuanmingyuanEnvironment({ renderer = null, quality = "medium", seed = 18601018 } = {}) {
4834
+ resetWorldSeed(seed);
4835
+ const preset = QUALITY[quality] || QUALITY.medium;
4836
+ const root = new THREE.Group();
4837
+ root.name = "YuanmingyuanWesternMansions";
4838
+ root.userData.environment = ID;
4839
+ const materials = buildMaterials(buildTextures(void 0, preset.texScale));
4840
+ const sky = createSky(root, renderer || {
4841
+ toneMappingExposure: 1.16,
4842
+ shadowMap: { needsUpdate: false }
4843
+ });
4844
+ sky.setHour(WORLD.sunDefaultHour);
4845
+ const ruin = new THREE.Group();
4846
+ ruin.name = "遗址本体";
4847
+ const restored = new THREE.Group();
4848
+ restored.name = "复原构件";
4849
+ const ruinOnly = new THREE.Group();
4850
+ ruinOnly.name = "仅遗址态残墙";
4851
+ ruinOnly.visible = false;
4852
+ root.add(ruin, restored, ruinOnly);
4853
+ const ctx = {
4854
+ ruin: new Batch(38),
4855
+ rest: new Batch(38),
4856
+ ruinOnly: new Batch(38),
4857
+ M: materials,
4858
+ jets: [],
4859
+ waters: [],
4860
+ rubble: [],
4861
+ labels: []
4862
+ };
4863
+ buildBuildings(ctx);
4864
+ ctx.ruin.build(ruin);
4865
+ ctx.rest.build(restored);
4866
+ ctx.ruinOnly.build(ruinOnly);
4867
+ createNature(root, materials, ctx).applyQuality(preset);
4868
+ const water = createWater(root, sky, ctx);
4869
+ water.setPixelRatio(renderer?.getPixelRatio?.() || 1);
4870
+ sky.sky.onBeforeRender = (_renderer, _scene, camera) => sky.sky.position.copy(camera.position);
4871
+ root.traverse((node) => {
4872
+ if (node.isMesh) node.userData.navigationIgnore = true;
4873
+ });
4874
+ const ground = makeGroundProxy();
4875
+ ground.mesh.userData.navigationIgnore = false;
4876
+ const navigationRoot = new THREE.Group();
4877
+ navigationRoot.name = "YuanmingyuanNavigation";
4878
+ navigationRoot.add(ground.mesh);
4879
+ root.add(navigationRoot);
4880
+ let currentHour = WORLD.sunDefaultHour;
4881
+ let isRestored = true;
4882
+ return {
4883
+ id: ID,
4884
+ root,
4885
+ floor: ground.mesh,
4886
+ navigationRoot,
4887
+ colliders: [ground.collider],
4888
+ layout: {
4889
+ bounds: {
4890
+ min: [WORLD.bounds.minX, WORLD.bounds.minZ],
4891
+ max: [WORLD.bounds.maxX, WORLD.bounds.maxZ]
4892
+ },
4893
+ groundY: 0,
4894
+ margin: 2
4895
+ },
4896
+ camera: {
4897
+ position: POIS[0].pos,
4898
+ target: POIS[0].target,
4899
+ far: 3e3
4900
+ },
4901
+ rendering: {
4902
+ background: 9546179,
4903
+ exposure: 1.16,
4904
+ fog: sky.fog
4905
+ },
4906
+ navigation: {
4907
+ agentRadius: .3,
4908
+ agentHeight: 1.7,
4909
+ maxSlope: 45,
4910
+ maxClimb: .4
4911
+ },
4912
+ views: POIS.map((item) => ({
4913
+ id: item.id,
4914
+ label: item.name,
4915
+ position: item.pos,
4916
+ target: item.target
4917
+ })),
4918
+ setHour(hour) {
4919
+ currentHour = hour;
4920
+ sky.setHour(hour);
4921
+ },
4922
+ setRestore(value) {
4923
+ isRestored = Boolean(value);
4924
+ restored.visible = isRestored;
4925
+ ruinOnly.visible = !isRestored;
4926
+ water.drops.visible = isRestored;
4927
+ water.ribbons.visible = isRestored;
4928
+ water.curtains.forEach((mesh) => {
4929
+ mesh.visible = isRestored;
4930
+ });
4931
+ },
4932
+ snapshot() {
4933
+ return {
4934
+ schemaVersion: 1,
4935
+ hour: currentHour,
4936
+ restored: isRestored,
4937
+ seed
4938
+ };
4939
+ },
4940
+ restore(state) {
4941
+ if (state?.schemaVersion !== 1) return false;
4942
+ if (Number.isFinite(state.hour)) this.setHour(state.hour);
4943
+ if (typeof state.restored === "boolean") this.setRestore(state.restored);
4944
+ return true;
4945
+ },
4946
+ step(dt) {
4947
+ sky.uniforms.uTime.value += dt;
4948
+ water.update(dt, sky);
4949
+ },
4950
+ dispose() {}
4951
+ };
4952
+ }
4953
+ export { createYuanmingyuanEnvironment };
4954
+
4955
+ //# sourceMappingURL=yuanmingyuan-DsFnPzzR.js.map