agentscape3d 1.0.0-beta.1 → 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 (387) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +23 -48
  3. package/dist/core.d.ts +68 -0
  4. package/dist/core.js +209 -0
  5. package/dist/core.js.map +1 -0
  6. package/dist/index.d.ts +10 -229
  7. package/dist/index.js +192 -15462
  8. package/dist/index.js.map +1 -1
  9. package/package.json +16 -40
  10. package/cli.mjs +0 -27
  11. package/dist/AssetCompiler-CDFiElji.js +0 -2451
  12. package/dist/AssetCompiler-CDFiElji.js.map +0 -1
  13. package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
  14. package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
  15. package/dist/AssetRecipe-DmFpzxr-.js +0 -55
  16. package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
  17. package/dist/BrowserCodeWorker.js +0 -53615
  18. package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
  19. package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
  20. package/dist/SceneSerializer-DPVOyeRk.js +0 -353
  21. package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
  22. package/dist/StylePack-DNrdLeGI.js +0 -6314
  23. package/dist/StylePack-DNrdLeGI.js.map +0 -1
  24. package/dist/WorldArchive-pSBIGxLa.js +0 -420
  25. package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
  26. package/dist/WorldIO-wsDfZGM4.js +0 -150
  27. package/dist/WorldIO-wsDfZGM4.js.map +0 -1
  28. package/dist/blankWorld-CBWbwJGj.js +0 -76
  29. package/dist/blankWorld-CBWbwJGj.js.map +0 -1
  30. package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
  31. package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
  32. package/dist/environments-DgH66NqV.js +0 -4220
  33. package/dist/environments-DgH66NqV.js.map +0 -1
  34. package/dist/gltfIO-B87nJaat.js +0 -10
  35. package/dist/gltfIO-B87nJaat.js.map +0 -1
  36. package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
  37. package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
  38. package/dist/magicCabin-D64fD1E2.js +0 -11024
  39. package/dist/magicCabin-D64fD1E2.js.map +0 -1
  40. package/dist/mcp.d.ts +0 -2
  41. package/dist/mcp.js +0 -1
  42. package/dist/monumentHall-BKbs0UOQ.js +0 -404
  43. package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
  44. package/dist/node.d.ts +0 -16
  45. package/dist/node.js +0 -25
  46. package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
  47. package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
  48. package/dist/runtime/application/AgentTools.js +0 -25
  49. package/dist/runtime/application/README.md +0 -14
  50. package/dist/runtime/application/buildTaskObservation.js +0 -117
  51. package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
  52. package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
  53. package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
  54. package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
  55. package/dist/runtime/application/createSession.js +0 -66
  56. package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
  57. package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
  58. package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
  59. package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
  60. package/dist/runtime/application/native-scene/CodeProject.js +0 -119
  61. package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
  62. package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
  63. package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
  64. package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
  65. package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
  66. package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
  67. package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
  68. package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
  69. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
  70. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
  71. package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
  72. package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
  73. package/dist/runtime/application/scene/RequestWindow.js +0 -54
  74. package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
  75. package/dist/runtime/application/scene/SceneContracts.js +0 -45
  76. package/dist/runtime/application/scene/SceneEditService.js +0 -144
  77. package/dist/runtime/application/scene/SceneFacade.js +0 -267
  78. package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
  79. package/dist/runtime/application/scene/SceneJobController.js +0 -229
  80. package/dist/runtime/application/scene/ScenePackage.js +0 -162
  81. package/dist/runtime/application/scene/ScenePersistence.js +0 -50
  82. package/dist/runtime/application/scene/SceneProject.js +0 -95
  83. package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
  84. package/dist/runtime/application/scene/StarterScene.js +0 -56
  85. package/dist/runtime/application/scene/WorldArchive.js +0 -87
  86. package/dist/runtime/application/scene/WorldDirectory.js +0 -20
  87. package/dist/runtime/application/scene/WorldDocument.js +0 -74
  88. package/dist/runtime/application/scene/WorldIO.js +0 -103
  89. package/dist/runtime/application/scene/WorldStorage.js +0 -137
  90. package/dist/runtime/application/skills/SkillRegistry.js +0 -163
  91. package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
  92. package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
  93. package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
  94. package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
  95. package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
  96. package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
  97. package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
  98. package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
  99. package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
  100. package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
  101. package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
  102. package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
  103. package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
  104. package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
  105. package/dist/runtime/application/skills/skillPrimitives.js +0 -4
  106. package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
  107. package/dist/runtime/application/tasks.jsonl +0 -67
  108. package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
  109. package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
  110. package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
  111. package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
  112. package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
  113. package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
  114. package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
  115. package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
  116. package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
  117. package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
  118. package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
  119. package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
  120. package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
  121. package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
  122. package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
  123. package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
  124. package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
  125. package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
  126. package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
  127. package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
  128. package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
  129. package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
  130. package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
  131. package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
  132. package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
  133. package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
  134. package/dist/runtime/apps/mcp-server/README.md +0 -150
  135. package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
  136. package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
  137. package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
  138. package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
  139. package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
  140. package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
  141. package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
  142. package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
  143. package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
  144. package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
  145. package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
  146. package/dist/runtime/apps/mcp-server/main.mjs +0 -56
  147. package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
  148. package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
  149. package/dist/runtime/apps/mcp-server/security.js +0 -21
  150. package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
  151. package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
  152. package/dist/runtime/apps/server/README.md +0 -7
  153. package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
  154. package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
  155. package/dist/runtime/apps/server/tasks.jsonl +0 -10
  156. package/dist/runtime/foundation/EventBus.js +0 -18
  157. package/dist/runtime/foundation/JsonGateway.js +0 -47
  158. package/dist/runtime/foundation/PolicyEngine.js +0 -21
  159. package/dist/runtime/foundation/README.md +0 -7
  160. package/dist/runtime/foundation/TraceRecorder.js +0 -76
  161. package/dist/runtime/foundation/errors.js +0 -8
  162. package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
  163. package/dist/runtime/foundation/version.js +0 -2
  164. package/dist/runtime/modules/agent/README.md +0 -11
  165. package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
  166. package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
  167. package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
  168. package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
  169. package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
  170. package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
  171. package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
  172. package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
  173. package/dist/runtime/modules/agent/prompt/index.js +0 -46
  174. package/dist/runtime/modules/agent/tasks.jsonl +0 -94
  175. package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
  176. package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
  177. package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
  178. package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
  179. package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
  180. package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
  181. package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
  182. package/dist/runtime/modules/artifact/README.md +0 -7
  183. package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
  184. package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
  185. package/dist/runtime/modules/asset/AssetModule.js +0 -399
  186. package/dist/runtime/modules/asset/README.md +0 -54
  187. package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
  188. package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
  189. package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
  190. package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
  191. package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
  192. package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
  193. package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
  194. package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
  195. package/dist/runtime/modules/asset/model/admission.js +0 -117
  196. package/dist/runtime/modules/asset/model/errors.js +0 -6
  197. package/dist/runtime/modules/asset/model/parts.js +0 -27
  198. package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
  199. package/dist/runtime/modules/asset/model/schema.js +0 -150
  200. package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
  201. package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
  202. package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
  203. package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
  204. package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
  205. package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
  206. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
  207. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
  208. package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
  209. package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
  210. package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
  211. package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
  212. package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
  213. package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
  214. package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
  215. package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
  216. package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
  217. package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
  218. package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
  219. package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
  220. package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
  221. package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
  222. package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
  223. package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
  224. package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
  225. package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
  226. package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
  227. package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
  228. package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
  229. package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
  230. package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
  231. package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
  232. package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
  233. package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
  234. package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
  235. package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
  236. package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
  237. package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
  238. package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
  239. package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
  240. package/dist/runtime/modules/asset/tasks.jsonl +0 -87
  241. package/dist/runtime/modules/generation/README.md +0 -9
  242. package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
  243. package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
  244. package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
  245. package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
  246. package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
  247. package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
  248. package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
  249. package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
  250. package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
  251. package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
  252. package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
  253. package/dist/runtime/modules/generation/tasks.jsonl +0 -35
  254. package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
  255. package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
  256. package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
  257. package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
  258. package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
  259. package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
  260. package/dist/runtime/modules/rendering/README.md +0 -7
  261. package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
  262. package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
  263. package/dist/runtime/modules/rendering/createRenderer.js +0 -76
  264. package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
  265. package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
  266. package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
  267. package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
  268. package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
  269. package/dist/runtime/modules/world/README.md +0 -13
  270. package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
  271. package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
  272. package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
  273. package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
  274. package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
  275. package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
  276. package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
  277. package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
  278. package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
  279. package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
  280. package/dist/runtime/modules/world/content/blankWorld.js +0 -35
  281. package/dist/runtime/modules/world/content/environments.js +0 -84
  282. package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
  283. package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
  284. package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
  285. package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
  286. package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
  287. package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
  288. package/dist/runtime/modules/world/content/magicCabin.js +0 -190
  289. package/dist/runtime/modules/world/content/monumentHall.js +0 -154
  290. package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
  291. package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
  292. package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
  293. package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
  294. package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
  295. package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
  296. package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
  297. package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
  298. package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
  299. package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
  300. package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
  301. package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
  302. package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
  303. package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
  304. package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
  305. package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
  306. package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
  307. package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
  308. package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
  309. package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
  310. package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
  311. package/dist/runtime/modules/world/errors.js +0 -9
  312. package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
  313. package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
  314. package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
  315. package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
  316. package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
  317. package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
  318. package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
  319. package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
  320. package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
  321. package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
  322. package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
  323. package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
  324. package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
  325. package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
  326. package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
  327. package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
  328. package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
  329. package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
  330. package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
  331. package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
  332. package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
  333. package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
  334. package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
  335. package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
  336. package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
  337. package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
  338. package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
  339. package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
  340. package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
  341. package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
  342. package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
  343. package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
  344. package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
  345. package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
  346. package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
  347. package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
  348. package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
  349. package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
  350. package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
  351. package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
  352. package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
  353. package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
  354. package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
  355. package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
  356. package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
  357. package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
  358. package/dist/runtime/modules/world/tasks.jsonl +0 -530
  359. package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
  360. package/dist/runtime/modules/world/verification/Finding.js +0 -105
  361. package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
  362. package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
  363. package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
  364. package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
  365. package/dist/runtime/package-lock.json +0 -6245
  366. package/dist/runtime/package.json +0 -91
  367. package/dist/runtime/public/assets/cabinet.glb +0 -0
  368. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
  369. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
  370. package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
  371. package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
  372. package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
  373. package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
  374. package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
  375. package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
  376. package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
  377. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
  378. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
  379. package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
  380. package/dist/schema-Dudvovhu.js +0 -364
  381. package/dist/schema-Dudvovhu.js.map +0 -1
  382. package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
  383. package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
  384. package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
  385. package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
  386. package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
  387. package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
@@ -1,578 +0,0 @@
1
- /* 吴苑澄观 · 核心层
2
- * 世界尺度与交付指标常量、LOD 分级标准、定点观察视角、
3
- * 确定性噪声、程序化 PBR 贴图集、材质库、几何工具、静态网格合批、地形与水系场函数。
4
- * 1 场景单位 = 1 米;+X 向东,-Z 向北,+Y 向上。
5
- */
6
- import * as THREE from 'three';
7
- import { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js';
8
-
9
- /* ================================================================== *
10
- * 1. 场景规模、边界、画质档位与 LOD 分级标准
11
- * ================================================================== */
12
- export const WORLD = {
13
- unit: 1,
14
- garden: { minX: -110, maxX: 110, minZ: -95, maxZ: 95, area: 220 * 190 }, // 围墙内 4.18 ha
15
- core: { minX: -110, maxX: 110, minZ: -95, maxZ: 95 }, // 高精度核心区
16
- bounds: { minX: -150, maxX: 150, minZ: -140, maxZ: 160 }, // 可浏览范围
17
- total: [640, 560], // 场景总尺寸(含园外借景地形、远山、林带、佛塔)
18
- ground: [640, 560],
19
- waterY: -0.42,
20
- sunDefaultHour: 15.67, // 北京时间 15:40 江南午后
21
- borrowPagoda: [-255, -262], // 园外借景:北寺塔(八角九层,76 m,距园内观景点约 400 m)
22
- };
23
-
24
- export const QUALITY = {
25
- high: { label: '高', dpr: 2.0, shadow: 4096, texScale: 1, aniso: 8, grass: 11000, trees: 1.00,
26
- leaves: 1.00, bloom: true, grade: true, lodScale: 1.00, waterSeg: 1.00, rain: 2600, detailBias: 1.00 },
27
- medium: { label: '中', dpr: 1.5, shadow: 2048, texScale: 0.5, aniso: 4, grass: 5200, trees: 0.74,
28
- leaves: 0.72, bloom: true, grade: true, lodScale: 0.80, waterSeg: 0.70, rain: 1400, detailBias: 0.86 },
29
- low: { label: '低', dpr: 1.0, shadow: 1024, texScale: 0.25, aniso: 1, grass: 1200, trees: 0.46,
30
- leaves: 0.45, bloom: false, grade: false, lodScale: 0.62, waterSeg: 0.48, rain: 600, detailBias: 0.72 },
31
- };
32
-
33
- /* LOD 分级标准:距离以「相机 → 对象包围球近缘」计,随画质档 lodScale 缩放。
34
- * level 0 全细节几何 + 512² 贴图;level 1 轮廓细节;level 2 简化体量;level 3 剪影 + 大气雾。 */
35
- export const LOD_LEVELS = [
36
- { id: 0, tag: 'L0', name: '极近景全细节', near: 0, far: 18, color: 0xe86a5c,
37
- scope: '核心区建筑/假山/池岸/近景花木;筒瓦垄、瓦当滴水、斗拱、棂条、挂落、砖雕、太湖石孔洞、逐叶草簇;投射高分辨率阴影' },
38
- { id: 1, tag: 'L1', name: '近景轮廓细节', near: 18, far: 55, color: 0xe9b34a,
39
- scope: '同院落 / 对岸建筑山石;保留飞檐翘角、屋脊、棂格、山石主孔与枝干轮廓,剔除微型雕饰' },
40
- { id: 2, tag: 'L2', name: '中景简化体量', near: 55, far: 140, color: 0x5fbf8e,
41
- scope: '相邻景区、园墙、园外村落;简化体量 + 屋顶剪影,树叶改交叉面片,山石改低模轮廓,关闭阴影投射' },
42
- { id: 3, tag: 'L3', name: '远景剪影', near: 140, far: 640, color: 0x5b8fc7,
43
- scope: '园外借景层:远山、林带、北寺塔;仅轮廓与剪影 + 高度雾消隐(塔在 140–420 m 保留中模以维持借景可辨)' },
44
- ];
45
-
46
- /* 定点观察关键视角:pos 相机、target 注视点、fov 等效焦距、dir 朝向说明、desc 取景内容 */
47
- export const POIS = [
48
- { id: 'overview', key: '1', name: '全园鸟瞰', pos: [122, 92, 152], target: [-4, 1, -10], fov: 42,
49
- dir: '朝西北 · 方位角约 322° · 垂直视场角 42°(广角)',
50
- desc: '自东南上空俯视全园:南部 190 m 礼序中轴、中部一池三山、九个园中园景区、四周云墙与园外借景层同时入画,用于检验整体格局与边界闭合。' },
51
- { id: 'gate', key: '2', name: '主入口 · 宫门', pos: [0, 2.6, 108], target: [0, 4.6, 72], fov: 39,
52
- dir: '正北 · 方位角 0° · 垂直视场角 39°',
53
- desc: '立于照壁前石广场朝北:八字照壁、砖雕门楼、宫门三间、轿厅与层层递进的中轴门洞构成礼序序列;照壁同时起障景作用,园内山水不一览无余。' },
54
- { id: 'axis', key: '3', name: '中轴前庭', pos: [0, 2.5, 72], target: [0, 5.0, 52], fov: 39,
55
- dir: '正北 · 方位角 0° · 垂直视场角 39°',
56
- desc: '前庭北望澄观堂:五开间歇山顶、月台踏跺、左右廊庑与对植玉兰,检验前朝中轴的对称关系与建筑比例。' },
57
- { id: 'hall', key: '4', name: '主体建筑 · 远香堂', pos: [-6, 2.3, 2], target: [0, 5.4, 30], fov: 39,
58
- dir: '朝南偏东 · 方位角约 168° · 垂直视场角 39°',
59
- desc: '自池中平桥回望南岸主体厅堂:歇山反宇屋面、飞檐翘角、整面格扇长窗、台基与美人靠,以及檐下斗拱在水中的倒影。' },
60
- { id: 'water', key: '5', name: '核心水景 · 一池三山', pos: [0, 2.4, 18], target: [-2, 1.2, -24], fov: 39,
61
- dir: '正北偏西 · 方位角约 357° · 垂直视场角 39°',
62
- desc: '南岸临水石平台正北:澄碧池大水面约占画面 45%,蓬莱、方丈、瀛洲三岛呈一池三山格局,曲桥、不系舟石舫、北岸雪香云蔚亭与主峰依次展开。' },
63
- { id: 'rockery', key: '6', name: '假山叠石 · 云根叠翠', pos: [-44, 2.2, -14], target: [-64, 5.6, -40], fov: 39,
64
- dir: '朝西北 · 方位角约 322° · 垂直视场角 39°',
65
- desc: '西山蹬道口近观太湖石:皴纹、涡孔与「皱漏瘦透」的孔洞透光、峡谷蹬道、跌水水帘与峰顶小亭;石面苔痕与湿痕在近景可辨。' },
66
- { id: 'summit', key: '7', name: '制高点俯瞰 · 见山楼', pos: [20, 11.2, -56], target: [0, 0.5, 14], fov: 42,
67
- dir: '朝南偏西 · 方位角约 196° · 垂直视场角 42°(广角)',
68
- desc: '见山楼二层外廊俯瞰:全园水系走向、屋顶群的高低节奏、九个景区的分隔与连通、南侧中轴纵深尽收眼底。' },
69
- { id: 'borrow', key: '8', name: '借景 · 北寺塔', pos: [40, 2.4, 13], target: [-95, 10, -137], fov: 39,
70
- dir: '朝西北 · 方位角约 318° · 垂直视场角 39°',
71
- desc: '荷风四面亭外临水处向西北远眺:荷叶与垂柳为前景、云墙为框,把园外约 400 m 处的九层北寺塔与灵岩山山脊「借」入园中,是借景关系的核心机位。' },
72
- { id: 'facing', key: '9', name: '对景 · 堂亭轴线', pos: [0, 2.4, 22], target: [-8, 5.2, -14], fov: 39,
73
- dir: '朝北偏西 · 方位角约 347° · 垂直视场角 39°',
74
- desc: '远香堂北檐下正对雪香云蔚亭:堂—水面—蓬莱岛—六角亭—假山主峰四点一线,两侧廊与竹丛形成夹景,构成全园最主要的对景轴线。' },
75
- { id: 'frame', key: '0', name: '框景 · 延月洞门', pos: [-81.3, 2.0, 51], target: [-64, 5.0, -40], fov: 39,
76
- dir: '朝北偏东 · 方位角约 11° · 垂直视场角 39°',
77
- desc: '竹里馆云墙之前:延月月洞门以圆形门洞框取西北假山主峰,旁列冰裂纹、海棠式、万字式漏窗,随脚步移动形成连续变化的框景画面。' },
78
- { id: 'bridge', key: '-', name: '九曲桥 · 荷风四面', pos: [42, 1.7, 18], target: [62, 2.8, 32], fov: 39,
79
- dir: '朝东南 · 方位角约 125° · 垂直视场角 39°',
80
- desc: '九曲桥中段贴水低视高:荷叶、睡莲与曲桥折线为前景,东南云墙、垂柳与荷风四面亭层层叠加,检验水面反射与近景植被密度。' },
81
- { id: 'bamboo', key: '=', name: '竹径幽居 · 竹里馆', pos: [-86, 2.0, 64], target: [-82, 3.6, 32], fov: 39,
82
- dir: '正北偏东 · 方位角约 7° · 垂直视场角 39°',
83
- desc: '竹径南端北望:白粉墙、竹影斑驳、碎石花街铺地与六角「听雨亭」,墙隅芭蕉与书带草构成夹景,检验斑驳光影与植被细节。' },
84
- ];
85
-
86
- export const HOTSPOTS = [
87
- { name: '照壁与宫门', pos: [0, 4.2, 96], desc: '入园礼序起点,八字砖雕照壁起障景作用。' },
88
- { name: '澄观堂', pos: [0, 7.6, 58], desc: '前朝主殿,五开间歇山顶,中轴对称。' },
89
- { name: '远香堂', pos: [0, 6.8, 30], desc: '全园主体厅堂,四面厅式,北临澄碧池。' },
90
- { name: '见山楼', pos: [20, 12.4, -60], desc: '两层楼阁,园内制高点,二层可俯瞰全园并远借山塔。' },
91
- { name: '雪香云蔚亭', pos: [-8, 7.2, -12], desc: '蓬莱岛上的六角攒尖亭,与远香堂互为对景。' },
92
- { name: '云根叠翠', pos: [-62, 8.4, -40], desc: '太湖石假山主峰,高 9.6 m,内含洞壑与蹬道。' },
93
- { name: '荷风四面亭', pos: [44, 4.6, 6], desc: '东南荷池中的四角亭,借景北寺塔的主要观景点。' },
94
- { name: '延月洞门', pos: [-80, 3.0, 44], desc: '月洞门框取假山主峰,两侧设冰裂、海棠、万字漏窗。' },
95
- { name: '小飞虹', pos: [-48, 3.4, 10], desc: '跨西水湾的廊桥,朱栏映水如虹。' },
96
- { name: '不系舟', pos: [38, 3.0, -34], desc: '石舫,船首朝东南,与见山楼互为对景。' },
97
- { name: '九曲桥', pos: [46, 1.4, 12], desc: '贴水九折石桥,连接南岸与荷风四面亭。' },
98
- { name: '竹里馆', pos: [-82, 3.2, 34], desc: '竹径深处的六角听雨亭与粉墙漏窗院。' },
99
- { name: '小山丛桂', pos: [66, 4.4, -52], desc: '东北秋色景区,扇面亭与爬山廊。' },
100
- { name: '北寺塔(借景)', pos: [-255, 62, -262], desc: '园外八角九层砖塔,高 76 m,为全园最重要的远处借景。' },
101
- ];
102
-
103
- /* ================================================================== *
104
- * 2. 确定性随机与可平铺噪声
105
- * ================================================================== */
106
- export function mulberry32(a) {
107
- return function () {
108
- a |= 0; a = (a + 0x6D2B79F5) | 0;
109
- let t = Math.imul(a ^ (a >>> 15), 1 | a);
110
- t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
111
- return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
112
- };
113
- }
114
- export const R = mulberry32(17451747);
115
- export const rr = (a, b) => a + (b - a) * R();
116
-
117
- function h2(x, y, s) {
118
- let n = Math.imul(x | 0, 374761393) + Math.imul(y | 0, 668265263) + Math.imul(s | 0, 1442695041);
119
- n = Math.imul(n ^ (n >>> 13), 1274126177);
120
- return ((n ^ (n >>> 16)) >>> 0) / 4294967295;
121
- }
122
- function vn(x, y, s, P) {
123
- const xi = Math.floor(x), yi = Math.floor(y);
124
- const xf = x - xi, yf = y - yi;
125
- const u = xf * xf * (3 - 2 * xf), v = yf * yf * (3 - 2 * yf);
126
- const X0 = ((xi % P) + P) % P, Y0 = ((yi % P) + P) % P;
127
- const X1 = (X0 + 1) % P, Y1 = (Y0 + 1) % P;
128
- const a = h2(X0, Y0, s), b = h2(X1, Y0, s), c = h2(X0, Y1, s), d = h2(X1, Y1, s);
129
- return (a + (b - a) * u) * (1 - v) + (c + (d - c) * u) * v;
130
- }
131
- export function fbm(x, y, s, oct = 4, P = 8) {
132
- let amp = 0.55, f = 1, sum = 0, norm = 0;
133
- for (let i = 0; i < oct; i++) {
134
- sum += amp * vn(x * f * P, y * f * P, s + i * 31, P * f);
135
- norm += amp; amp *= 0.5; f *= 2;
136
- }
137
- return sum / norm;
138
- }
139
- export const clamp = (v, a, b) => v < a ? a : v > b ? b : v;
140
- export const smooth = (a, b, v) => { const t = clamp((v - a) / (b - a), 0, 1); return t * t * (3 - 2 * t); };
141
- export const lerp = (a, b, t) => a + (b - a) * t;
142
-
143
- /* ================================================================== *
144
- * 3. 程序化 PBR 贴图集(颜色 / 法线 / 粗糙度,DataTexture,无外部文件)
145
- * ================================================================== */
146
- function makeMaps(size, shade) {
147
- const n = size * size;
148
- const col = new Uint8Array(n * 4), nrm = new Uint8Array(n * 4), rgh = new Uint8Array(n * 4);
149
- const H = new Float32Array(n);
150
- for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) {
151
- const i = y * size + x, o = shade(x / size, y / size, x, y, size);
152
- col[i * 4] = clamp(o[0], 0, 255); col[i * 4 + 1] = clamp(o[1], 0, 255);
153
- col[i * 4 + 2] = clamp(o[2], 0, 255); col[i * 4 + 3] = 255;
154
- H[i] = o[3];
155
- const rv = clamp(o[4] * 255, 0, 255);
156
- rgh[i * 4] = rv; rgh[i * 4 + 1] = rv; rgh[i * 4 + 2] = rv; rgh[i * 4 + 3] = 255;
157
- }
158
- const strength = 2.6;
159
- for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) {
160
- const i = y * size + x, o = i * 4;
161
- const l = H[y * size + ((x - 1 + size) % size)], r = H[y * size + ((x + 1) % size)];
162
- const t = H[((y - 1 + size) % size) * size + x], b = H[((y + 1) % size) * size + x];
163
- const nx = (l - r) * strength, ny = (t - b) * strength, nz = 1;
164
- const inv = 1 / Math.sqrt(nx * nx + ny * ny + nz * nz);
165
- nrm[o] = (nx * inv * 0.5 + 0.5) * 255;
166
- nrm[o + 1] = (ny * inv * 0.5 + 0.5) * 255;
167
- nrm[o + 2] = (nz * inv * 0.5 + 0.5) * 255; nrm[o + 3] = 255;
168
- }
169
- const tex = (data, srgb) => {
170
- const t = new THREE.DataTexture(data, size, size, THREE.RGBAFormat);
171
- t.wrapS = t.wrapT = THREE.RepeatWrapping;
172
- t.magFilter = THREE.LinearFilter; t.minFilter = THREE.LinearMipmapLinearFilter;
173
- t.generateMipmaps = true;
174
- if (srgb) t.colorSpace = THREE.SRGBColorSpace;
175
- t.anisotropy = 8; t.needsUpdate = true;
176
- return t;
177
- };
178
- return { map: tex(col, true), normalMap: tex(nrm, false), roughnessMap: tex(rgh, false) };
179
- }
180
-
181
- const TEXDEF = {
182
- /* 白粉墙:微裂、雨渍、墙脚苔痕 */
183
- plaster: { size: 512, fn: (u, v) => {
184
- const g = fbm(u, v, 11, 4), f = fbm(u, v, 47, 3, 32), stain = fbm(u * 1.6, v * 0.35, 71, 3);
185
- const crack = smooth(0.90, 0.995, 1 - Math.abs(Math.sin((u * 7 + v * 9 + g * 5) * Math.PI))) * 0.30;
186
- const moss = smooth(0.52, 0.86, fbm(u, v, 97, 3)) * smooth(0.55, 1.0, v) * 0.35;
187
- const b = 226 - stain * 26 - crack * 34 - moss * 52 + g * 10;
188
- return [b, b * 0.988 - moss * 12 + moss * 8, b * 0.955 - stain * 8,
189
- g * 0.32 + f * 0.28 - crack * 0.9 + moss * 0.2, 0.87 + f * 0.10 + moss * 0.05];
190
- } },
191
- /* 青砖:错缝灰缝、砖面斑驳 */
192
- graybrick: { size: 512, fn: (u, v) => {
193
- const rows = 14, cols = 6;
194
- const ry = v * rows, rx = u * cols + (Math.floor(ry) % 2) * 0.5;
195
- const joint = smooth(0.40, 0.5, Math.max(Math.abs((ry % 1) - 0.5), Math.abs((rx % 1) - 0.5)));
196
- const g = fbm(u, v, 191, 4), f = fbm(u, v, 211, 3, 32);
197
- const k = 1 - joint * 0.44;
198
- return [(126 + g * 32) * k, (130 + g * 30) * k, (124 + g * 26) * k,
199
- -joint * 0.9 + g * 0.36 + f * 0.2, 0.84 + f * 0.12];
200
- } },
201
- /* 黛瓦:筒瓦垄、瓦当横线、釉面微光 */
202
- tile: { size: 512, fn: (u, v) => {
203
- const ribs = Math.abs(Math.sin(u * Math.PI * 22));
204
- const course = Math.abs(Math.sin(v * Math.PI * 14));
205
- const g = fbm(u, v, 233, 4), f = fbm(u, v, 241, 3, 32);
206
- const hi = Math.pow(ribs, 0.52), lo = smooth(0.86, 1.0, course);
207
- const k = 0.66 + hi * 0.46 - lo * 0.24 + g * 0.16;
208
- return [(54 + g * 16) * k, (64 + g * 16) * k, (66 + g * 16) * k,
209
- hi * 1.0 - lo * 0.55 + g * 0.22 + f * 0.18, 0.44 + g * 0.18 + lo * 0.12];
210
- } },
211
- /* 栗色漆木 */
212
- wood: { size: 256, fn: (u, v) => {
213
- const grain = Math.abs(Math.sin((u * 24 + fbm(u, v, 307, 3) * 5) * Math.PI));
214
- const g = fbm(u, v, 311, 3), f = fbm(u, v, 317, 3, 32);
215
- return [92 + grain * 24 + g * 12, 52 + grain * 14 + g * 8, 36 + grain * 9 + g * 6,
216
- grain * 0.42 + g * 0.28 + f * 0.14, 0.52 + g * 0.18];
217
- } },
218
- /* 楠木(浅色) */
219
- woodPale: { size: 256, fn: (u, v) => {
220
- const grain = Math.abs(Math.sin((u * 19 + fbm(u, v, 331, 3) * 4) * Math.PI));
221
- const g = fbm(u, v, 337, 3);
222
- return [150 + grain * 22 + g * 14, 108 + grain * 18 + g * 10, 68 + grain * 12 + g * 8,
223
- grain * 0.34 + g * 0.28, 0.58 + g * 0.16];
224
- } },
225
- /* 条石 / 花岗岩 */
226
- stone: { size: 512, fn: (u, v) => {
227
- const g = fbm(u, v, 11, 5), fine = fbm(u, v, 47, 3, 32), stain = fbm(u * 1.7, v * 0.35, 71, 3);
228
- const vein = Math.abs(Math.sin((u * 11 + v * 5 + g * 4.5) * Math.PI));
229
- const vline = smooth(0.84, 0.99, 1 - vein) * 0.13;
230
- const moss = smooth(0.64, 0.84, fbm(u, v, 97, 3)) * 0.34;
231
- const base = 172 + g * 28 - vline * 108 - stain * 20 - fine * 12;
232
- return [base - moss * 18, base * 0.99 + moss * 12 - vline * 92, base * 0.96 - moss * 6 - vline * 76,
233
- g * 0.5 + fine * 0.32 - vline * 1.1, 0.78 + fine * 0.18 + moss * 0.08];
234
- } },
235
- /* 太湖石:皴纹 + 涡孔阴影,灰白偏青 */
236
- taihu: { size: 512, fn: (u, v) => {
237
- const w = fbm(u, v, 401, 4), g = fbm(u, v, 409, 5), f = fbm(u, v, 419, 3, 32);
238
- const wrinkle = Math.abs(Math.sin((u * 17 + v * 11 + w * 9) * Math.PI));
239
- const pit = smooth(0.58, 0.82, Math.pow(wrinkle, 0.6) * g);
240
- const moss = smooth(0.60, 0.82, fbm(u, v, 431, 3)) * 0.35;
241
- const base = 168 + g * 32 - pit * 62 - moss * 26;
242
- return [base - moss * 12, base * 1.005 + moss * 8, base * 0.98 - moss * 4,
243
- g * 0.55 + f * 0.35 - pit * 1.3, 0.82 + f * 0.14 + moss * 0.06];
244
- } },
245
- /* 黄石:层理与砂岩颗粒 */
246
- huangshi: { size: 512, fn: (u, v) => {
247
- const g = fbm(u, v, 443, 4), f = fbm(u, v, 449, 3, 32);
248
- const layer = Math.abs(Math.sin((v * 12 + g * 3.2) * Math.PI));
249
- const seam = smooth(0.80, 0.98, 1 - layer) * 0.35;
250
- const base = 176 + g * 26 - seam * 66;
251
- return [base, base * 0.82 + f * 8 - seam * 46, base * 0.56 + f * 8 - seam * 34,
252
- g * 0.42 + f * 0.28 - seam * 1.0, 0.86 + f * 0.12];
253
- } },
254
- /* 汉白玉 */
255
- marble: { size: 256, fn: (u, v) => {
256
- const g = fbm(u, v, 23, 4), warp = fbm(u, v, 61, 3);
257
- const vein = Math.pow(1 - Math.abs(Math.sin((u * 5.2 + v * 3.1 + warp * 3.4) * Math.PI)), 9);
258
- const f = fbm(u, v, 89, 3, 32);
259
- const base = 224 + g * 18 - vein * 38;
260
- return [base, base * 0.99 - vein * 26, base * 0.96 - vein * 20,
261
- g * 0.3 + f * 0.22 - vein * 0.45, 0.52 + f * 0.18 + vein * 0.16];
262
- } },
263
- /* 花街铺地:碎卵石 / 冰裂嵌石 */
264
- paving: { size: 512, fn: (u, v) => {
265
- const g = fbm(u, v, 461, 4), f = fbm(u, v, 467, 3, 32);
266
- const cx = u * 14, cy = v * 14;
267
- const jx = cx - Math.floor(cx) - 0.5, jy = cy - Math.floor(cy) - 0.5;
268
- const jitter = fbm(u, v, 479, 2, 16) * 0.34;
269
- const pebble = smooth(0.30 + jitter, 0.46 + jitter, Math.hypot(jx, jy));
270
- const k = 1 - pebble * 0.40;
271
- return [(146 + g * 30) * k, (140 + g * 28) * k, (124 + g * 24) * k,
272
- g * 0.36 + f * 0.28 - pebble * 0.7, 0.88 + f * 0.10];
273
- } },
274
- /* 地面:草土干湿、苔斑 */
275
- ground: { size: 512, fn: (u, v) => {
276
- const g = fbm(u, v, 331, 5), f = fbm(u, v, 347, 3, 32), patch = fbm(u, v, 359, 3);
277
- const dry = smooth(0.50, 0.78, patch), moss = smooth(0.62, 0.82, fbm(u, v, 367, 3));
278
- return [112 + g * 44 + dry * 48 - moss * 20, 126 + g * 42 + dry * 26 + moss * 14, 78 + g * 26 + dry * 12 - moss * 8,
279
- g * 0.52 + f * 0.38, 0.92 + f * 0.08];
280
- } },
281
- /* 树皮 */
282
- bark: { size: 256, fn: (u, v) => {
283
- const g = fbm(u, v, 487, 4), f = fbm(u, v, 491, 3, 32);
284
- const ridge = Math.abs(Math.sin((u * 17 + g * 5) * Math.PI));
285
- const crack = smooth(0.68, 0.96, ridge);
286
- const b = 92 + g * 34 - crack * 34;
287
- return [b, b * 0.87 + f * 8, b * 0.72 + f * 6, ridge * 0.6 + g * 0.3 - crack * 0.5, 0.9 + f * 0.1];
288
- } },
289
- /* 叶簇:叶脉与色斑 */
290
- leaf: { size: 256, fn: (u, v) => {
291
- const g = fbm(u, v, 499, 4), f = fbm(u, v, 503, 3, 32);
292
- const vein = Math.abs(Math.sin((u * 9 + v * 3 + g * 3) * Math.PI));
293
- return [72 + g * 66 - vein * 16, 104 + g * 68 - vein * 10, 52 + g * 40 - vein * 16,
294
- g * 0.42 + f * 0.30 + vein * 0.2, 0.86 + f * 0.12];
295
- } },
296
- /* 苔藓 */
297
- moss: { size: 256, fn: (u, v) => {
298
- const g = fbm(u, v, 509, 5), f = fbm(u, v, 521, 3, 32);
299
- return [56 + g * 46, 88 + g * 52, 44 + g * 30, g * 0.6 + f * 0.4, 0.96];
300
- } },
301
- /* 窗纸 / 明瓦 */
302
- paper: { size: 256, fn: (u, v) => {
303
- const g = fbm(u, v, 541, 3), fiber = Math.abs(Math.sin((u * 34 + v * 7 + g * 4) * Math.PI));
304
- return [222 + g * 14 - fiber * 6, 210 + g * 14 - fiber * 6, 184 + g * 14 - fiber * 5,
305
- g * 0.2 + fiber * 0.12, 0.94];
306
- } },
307
- };
308
-
309
- export function buildTextures(onProgress, texScale = 1) {
310
- const out = {}, keys = Object.keys(TEXDEF);
311
- keys.forEach((k, i) => {
312
- const def = TEXDEF[k];
313
- const size = Math.max(128, Math.pow(2, Math.round(Math.log2(def.size * texScale))));
314
- out[k] = makeMaps(size, def.fn);
315
- if (onProgress) onProgress((i + 1) / keys.length, k);
316
- });
317
- return out;
318
- }
319
-
320
- /* ================================================================== *
321
- * 4. 材质库
322
- * ================================================================== */
323
- export function buildMaterials(T) {
324
- const std = (name, key, o = {}) => {
325
- const t = T[key];
326
- const m = new THREE.MeshStandardMaterial({
327
- map: t.map, normalMap: t.normalMap, roughnessMap: t.roughnessMap,
328
- normalScale: new THREE.Vector2(o.ns ?? 0.55, o.ns ?? 0.55),
329
- roughness: o.roughness ?? 0.9, metalness: o.metalness ?? 0.0,
330
- color: o.color ?? 0xffffff, side: o.side ?? THREE.FrontSide,
331
- transparent: o.transparent ?? false, opacity: o.opacity ?? 1,
332
- vertexColors: o.vertexColors ?? false, flatShading: o.flat ?? false,
333
- });
334
- m.name = name; return m;
335
- };
336
- const M = {
337
- plaster: std('plaster', 'plaster', { roughness: 0.94, ns: 0.36 }),
338
- plasterWarm: std('plasterWarm', 'plaster', { roughness: 0.94, ns: 0.36, color: 0xf1e6cc }),
339
- graybrick: std('graybrick', 'graybrick', { roughness: 0.95, ns: 0.72 }),
340
- tile: std('tile', 'tile', { roughness: 0.52, ns: 0.85, metalness: 0.08 }),
341
- tileLight: std('tileLight', 'tile', { roughness: 0.54, ns: 0.8, color: 0xb9c4c2 }),
342
- wood: std('wood', 'wood', { roughness: 0.62, ns: 0.4 }),
343
- woodPale: std('woodPale', 'woodPale', { roughness: 0.66, ns: 0.38 }),
344
- stone: std('stone', 'stone', { roughness: 0.9, ns: 0.62 }),
345
- stoneDark: std('stoneDark', 'stone', { roughness: 0.92, ns: 0.6, color: 0xb4b6ac }),
346
- taihu: std('taihu', 'taihu', { roughness: 0.88, ns: 0.85 }),
347
- taihuDark: std('taihuDark', 'taihu', { roughness: 0.9, ns: 0.8, color: 0xb9c0bb }),
348
- huangshi: std('huangshi', 'huangshi', { roughness: 0.94, ns: 0.7 }),
349
- marble: std('marble', 'marble', { roughness: 0.62, ns: 0.32 }),
350
- paving: std('paving', 'paving', { roughness: 0.96, ns: 0.55 }),
351
- ground: std('ground', 'ground', { roughness: 1.0, ns: 0.34, vertexColors: true }),
352
- bark: std('bark', 'bark', { roughness: 0.96, ns: 0.7 }),
353
- leaf: std('leaf', 'leaf', { roughness: 0.9, ns: 0.35, side: THREE.DoubleSide, vertexColors: true }),
354
- moss: std('moss', 'moss', { roughness: 1.0, ns: 0.6 }),
355
- paper: std('paper', 'paper', { roughness: 0.96, ns: 0.15, transparent: true, opacity: 0.88, side: THREE.DoubleSide }),
356
- };
357
- const solid = (name, color, roughness = 0.8, metalness = 0) => {
358
- const m = new THREE.MeshStandardMaterial({ color, roughness, metalness }); m.name = name; return m;
359
- };
360
- M.ridge = solid('ridge', 0x353f40, 0.52, 0.12);
361
- M.darkWood = solid('darkWood', 0x3a2a20, 0.72);
362
- M.lacquer = solid('lacquer', 0x7a3226, 0.46);
363
- M.gold = solid('gold', 0xc9a75e, 0.34, 0.78);
364
- M.bronze = solid('bronze', 0x7c7658, 0.52, 0.55);
365
- M.white = solid('white', 0xeae6d8, 0.9);
366
- M.ink = solid('ink', 0x252d2b, 0.86);
367
- M.lantern = new THREE.MeshStandardMaterial({ color: 0xffb765, emissive: 0xff9a3c, emissiveIntensity: 1.1, roughness: 0.7 });
368
- M.lantern.name = 'lantern';
369
- M.glass = new THREE.MeshPhysicalMaterial({ color: 0x9fb6b2, roughness: 0.2, metalness: 0.1, transparent: true, opacity: 0.30, side: THREE.DoubleSide });
370
- M.glass.name = 'glass';
371
- M.petal = new THREE.MeshStandardMaterial({ color: 0xf2d4d8, roughness: 0.82, side: THREE.DoubleSide, vertexColors: true });
372
- M.petal.name = 'petal';
373
- M.lotus = new THREE.MeshStandardMaterial({ color: 0x4e8248, roughness: 0.86, side: THREE.DoubleSide, vertexColors: true });
374
- M.lotus.name = 'lotus';
375
- return M;
376
- }
377
-
378
- /* ================================================================== *
379
- * 5. 几何工具
380
- * ================================================================== */
381
- export function boxGeo(w, h, d, uvPerMeter = 0.5) {
382
- const g = new THREE.BoxGeometry(w, h, d);
383
- const uv = g.getAttribute('uv');
384
- const dims = [[d, h], [d, h], [w, d], [w, d], [w, h], [w, h]];
385
- for (let f = 0; f < 6; f++) for (let i = 0; i < 4; i++) {
386
- const k = f * 4 + i;
387
- uv.setXY(k, uv.getX(k) * dims[f][0] * uvPerMeter, uv.getY(k) * dims[f][1] * uvPerMeter);
388
- }
389
- uv.needsUpdate = true; return g;
390
- }
391
- export function transform(pos = [0, 0, 0], rot = [0, 0, 0], scale = [1, 1, 1]) {
392
- const m = new THREE.Matrix4();
393
- m.compose(new THREE.Vector3(pos[0], pos[1], pos[2]),
394
- new THREE.Quaternion().setFromEuler(new THREE.Euler(rot[0], rot[1], rot[2])),
395
- new THREE.Vector3(scale[0], scale[1], scale[2]));
396
- return m;
397
- }
398
- export function tube(points, radius, seg = 24, radial = 6) {
399
- const curve = new THREE.CatmullRomCurve3(points.map(p => new THREE.Vector3(...p)));
400
- return new THREE.TubeGeometry(curve, seg, radius, radial, false);
401
- }
402
- export function lathe(points, seg = 24) {
403
- return new THREE.LatheGeometry(points.map(p => new THREE.Vector2(p[0], p[1])), seg);
404
- }
405
- /** 带窗洞的墙(Shape + holes),用于月洞门、漏窗、格扇框 */
406
- export function wallWithHoles(w, h, d, holes) {
407
- const s = new THREE.Shape();
408
- s.moveTo(-w / 2, 0); s.lineTo(w / 2, 0); s.lineTo(w / 2, h); s.lineTo(-w / 2, h); s.closePath();
409
- (holes || []).forEach(o => {
410
- const p = new THREE.Path();
411
- if (o.type === 'circle') {
412
- const r = o.r || 1;
413
- p.absarc(o.x, o.y + r, r, 0, Math.PI * 2, true);
414
- } else if (o.type === 'rect') {
415
- const hw = o.w / 2;
416
- if (o.arch) {
417
- const spring = o.h - hw;
418
- p.moveTo(o.x - hw, o.y); p.lineTo(o.x - hw, o.y + spring);
419
- p.absarc(o.x, o.y + spring, hw, Math.PI, 0, true);
420
- p.lineTo(o.x + hw, o.y); p.closePath();
421
- } else {
422
- p.moveTo(o.x - hw, o.y); p.lineTo(o.x - hw, o.y + o.h);
423
- p.lineTo(o.x + hw, o.y + o.h); p.lineTo(o.x + hw, o.y); p.closePath();
424
- }
425
- } else if (o.type === 'hex') {
426
- const r = o.r || 1;
427
- for (let i = 0; i < 6; i++) {
428
- const a = Math.PI / 6 + i * Math.PI / 3;
429
- const x = o.x + Math.cos(a) * r, y = o.y + Math.sin(a) * r;
430
- if (i === 0) p.moveTo(x, y); else p.lineTo(x, y);
431
- }
432
- p.closePath();
433
- }
434
- s.holes.push(p);
435
- });
436
- const g = new THREE.ExtrudeGeometry(s, { depth: d, bevelEnabled: false, curveSegments: 20, steps: 1 });
437
- g.translate(0, 0, -d / 2);
438
- const uv = g.getAttribute('uv');
439
- for (let i = 0; i < uv.count; i++) uv.setXY(i, uv.getX(i) * 0.35, uv.getY(i) * 0.35);
440
- return g;
441
- }
442
- /** 不规则多边形挤出(用于台基、池岸条石、云墙顶) */
443
- export function extrudePolygon(points, depth, bevel = 0) {
444
- const s = new THREE.Shape();
445
- points.forEach((p, i) => i === 0 ? s.moveTo(p[0], p[1]) : s.lineTo(p[0], p[1]));
446
- s.closePath();
447
- const g = new THREE.ExtrudeGeometry(s, { depth, bevelEnabled: bevel > 0, bevelSize: bevel, bevelThickness: bevel, bevelSegments: 1, curveSegments: 8 });
448
- g.translate(0, 0, -depth / 2);
449
- return g;
450
- }
451
-
452
- /* ================================================================== *
453
- * 6. 静态几何合批:材质 + 32 m 空间格 + LOD 细节层
454
- * 每个 add 可指定 lod(0 核心体量 / 1 L0 专属细节 / 2 L1 专属细节 / 3 L2 专属细节)
455
- * ================================================================== */
456
- function normalizeGeo(g) {
457
- const src = g.index ? g.toNonIndexed() : g.clone();
458
- const out = new THREE.BufferGeometry();
459
- const p = src.getAttribute('position');
460
- out.setAttribute('position', p.clone());
461
- out.setAttribute('normal', src.getAttribute('normal') ? src.getAttribute('normal').clone()
462
- : new THREE.Float32BufferAttribute(new Float32Array(p.count * 3), 3));
463
- const uv = src.getAttribute('uv');
464
- out.setAttribute('uv', uv ? uv.clone() : new THREE.Float32BufferAttribute(new Float32Array(p.count * 2), 2));
465
- if (src !== g) src.dispose();
466
- return out;
467
- }
468
- export class Batch {
469
- constructor(zone = 32) { this.groups = new Map(); this.zone = zone; }
470
- add(geo, mat, matrix, opts = {}) {
471
- if (!geo || !geo.getAttribute('position')) return;
472
- const g = normalizeGeo(geo);
473
- g.applyMatrix4(matrix);
474
- const e = matrix.elements;
475
- const zx = Math.floor(e[12] / this.zone), zz = Math.floor(e[14] / this.zone);
476
- const lod = opts.lod ?? 0;
477
- const key = (opts.noZone ? 'all' : `${zx}_${zz}`) + '|' + mat.name + '|L' + lod;
478
- if (!this.groups.has(key)) this.groups.set(key, { mat, lod, list: [], noShadow: false });
479
- const grp = this.groups.get(key);
480
- grp.list.push(g);
481
- if (opts.noShadow) grp.noShadow = true;
482
- if (opts.dispose !== false && geo.dispose) geo.dispose();
483
- }
484
- build(parent) {
485
- let meshes = 0, tris = 0;
486
- this.groups.forEach(grp => {
487
- if (!grp.list.length) return;
488
- const merged = grp.list.length === 1 ? grp.list[0] : mergeGeometries(grp.list, false);
489
- if (!merged) return;
490
- const mesh = new THREE.Mesh(merged, grp.mat);
491
- mesh.castShadow = !grp.noShadow;
492
- mesh.receiveShadow = true;
493
- mesh.matrixAutoUpdate = false;
494
- mesh.name = 'batch_' + grp.mat.name + '_L' + grp.lod;
495
- merged.computeBoundingSphere();
496
- const sph = merged.boundingSphere;
497
- mesh.userData.center = sph.center.clone();
498
- mesh.userData.radius = sph.radius;
499
- mesh.userData.lodTag = grp.lod;
500
- mesh.userData.baseMat = grp.mat;
501
- parent.add(mesh);
502
- meshes++; tris += merged.getAttribute('position').count / 3;
503
- if (grp.list.length > 1) grp.list.forEach(g => g.dispose());
504
- });
505
- this.groups.clear();
506
- return { meshes, tris };
507
- }
508
- }
509
-
510
- /* ================================================================== *
511
- * 7. 水系与地形场函数(供水面 shader、地形、植被、建筑布点共用)
512
- * ================================================================== */
513
- const POOLS = [
514
- { x: 0, z: -12, rx: 62, rz: 35 }, // 澄碧池主湖
515
- { x: -52, z: 6, rx: 22, rz: 20 }, // 西水湾(小飞虹跨其上)
516
- { x: 46, z: 8, rx: 21, rz: 16 }, // 东南荷花池
517
- { x: 16, z: -42, rx: 27, rz: 14 }, // 北溪(见山楼前)
518
- { x: -28, z: -46, rx: 19, rz: 12 }, // 西山脚水湾
519
- ];
520
- const ISLES = [
521
- { x: -8, z: -12, rx: 11.5, rz: 8.2 }, // 蓬莱(雪香云蔚亭)
522
- { x: -34, z: -24, rx: 7.2, rz: 5.0 }, // 方丈
523
- { x: 28, z: -18, rx: 7.4, rz: 5.2 }, // 瀛洲
524
- { x: 44, z: 6, rx: 4.0, rz: 3.6 }, // 荷风四面亭台基
525
- ];
526
- export { POOLS, ISLES };
527
- const ellDist = (x, z, e) => {
528
- const q = Math.hypot((x - e.x) / e.rx, (z - e.z) / e.rz);
529
- return (q - 1) * Math.min(e.rx, e.rz);
530
- };
531
- /** 水岸有符号距离:<0 位于水中;>0 位于陆地 */
532
- export function waterSDF(x, z) {
533
- let d = 1e5;
534
- for (let i = 0; i < POOLS.length; i++) d = Math.min(d, ellDist(x, z, POOLS[i]));
535
- for (let i = 0; i < ISLES.length; i++) d = Math.max(d, -ellDist(x, z, ISLES[i]));
536
- return d;
537
- }
538
- export const inWater = (x, z) => waterSDF(x, z) < 0;
539
- export const onIsle = (x, z) => ISLES.some(e => ellDist(x, z, e) < -0.4);
540
-
541
- /** 地形高度:微起伏 + 西北山地基底抬升 + 池底下挖,水岸平滑过渡 */
542
- export function terrainHeight(x, z) {
543
- const base = (fbm(x * 0.0042 + 3.1, z * 0.0042 + 7.7, 13, 4) - 0.5) * 1.5
544
- + (fbm(x * 0.012 + 1.3, z * 0.012 + 2.9, 17, 3) - 0.5) * 0.32;
545
- // 西北假山区域缓丘(最高约 +3.4 m)
546
- const hill = Math.exp(-((x + 66) ** 2 / 1900 + (z + 40) ** 2 / 1500)) * 3.1;
547
- // 东北桂花坡
548
- const hill2 = Math.exp(-((x - 68) ** 2 / 1500 + (z + 56) ** 2 / 1200)) * 1.35;
549
- // 园外北侧远山基底(仅在园墙外生效)
550
- let outer = 0;
551
- const oz = -z - 110;
552
- if (oz > 0) outer = Math.min(1, oz / 150) * (5 + Math.sin(x * 0.019) * 2.4 + Math.sin(x * 0.047 + 2) * 1.2);
553
- // 池底下挖
554
- const w = waterSDF(x, z);
555
- const dig = -2.15 * (1 - smooth(-1.2, 3.2, w));
556
- // 园墙内整体压平至 ±0.4 m,便于建筑布点
557
- const inside = (Math.abs(x) < 112 && Math.abs(z) < 97) ? 0.28 : 1;
558
- return (base + hill + hill2 + outer) * inside + dig + 0.10;
559
- }
560
-
561
- /** 生成水面/岸线裁剪 mask 纹理(RGBA,R 通道 = 水域覆盖率 0..255) */
562
- export function buildWaterMask(size = 512) {
563
- const data = new Uint8Array(size * size * 4);
564
- const half = WORLD.total[0] / 2, halfZ = WORLD.total[1] / 2;
565
- for (let j = 0; j < size; j++) for (let i = 0; i < size; i++) {
566
- const x = (i / (size - 1) - 0.5) * WORLD.total[0];
567
- const z = (j / (size - 1) - 0.5) * WORLD.total[1];
568
- const d = waterSDF(x, z);
569
- const a = clamp(0.5 - d / 2.6, 0, 1);
570
- const k = j * size + i;
571
- data[k * 4] = a * 255; data[k * 4 + 1] = a * 255; data[k * 4 + 2] = a * 255; data[k * 4 + 3] = 255;
572
- }
573
- const t = new THREE.DataTexture(data, size, size, THREE.RGBAFormat);
574
- t.magFilter = THREE.LinearFilter; t.minFilter = THREE.LinearFilter;
575
- t.wrapS = t.wrapT = THREE.ClampToEdgeWrapping;
576
- t.needsUpdate = true;
577
- return t;
578
- }