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.
- package/LICENSE +21 -0
- package/README.md +19 -2
- package/cli.mjs +53 -0
- package/dist/ArticulationVerifier-BfGxXY8V.js +337 -0
- package/dist/ArticulationVerifier-BfGxXY8V.js.map +1 -0
- package/dist/AssetCompiler-BLj09iu1.js +2424 -0
- package/dist/AssetCompiler-BLj09iu1.js.map +1 -0
- package/dist/AssetModule-DME-XaFS.js +2637 -0
- package/dist/AssetModule-DME-XaFS.js.map +1 -0
- package/dist/AssetRecipe-g8dZBhgJ.js +298 -0
- package/dist/AssetRecipe-g8dZBhgJ.js.map +1 -0
- package/dist/BrowserCodeWorker.js +53856 -0
- package/dist/BrowserCodeWorker.js.map +1 -0
- package/dist/CarryCapability-CXwHU5ay.js +104 -0
- package/dist/CarryCapability-CXwHU5ay.js.map +1 -0
- package/dist/KinematicHypothesisScreen-C3TKiuYR.js +241 -0
- package/dist/KinematicHypothesisScreen-C3TKiuYR.js.map +1 -0
- package/dist/ObjectTransform-BlQUNK7c.js +61 -0
- package/dist/ObjectTransform-BlQUNK7c.js.map +1 -0
- package/dist/RapierPhysicsBackend-B2wQe_Vl.js +3259 -0
- package/dist/RapierPhysicsBackend-B2wQe_Vl.js.map +1 -0
- package/dist/RenderingSystem-WIr1ZuGu.js +1042 -0
- package/dist/RenderingSystem-WIr1ZuGu.js.map +1 -0
- package/dist/ScenePresentation-LsYiDxbm.js +152 -0
- package/dist/ScenePresentation-LsYiDxbm.js.map +1 -0
- package/dist/SceneProject-K7HH1s8o.js +2687 -0
- package/dist/SceneProject-K7HH1s8o.js.map +1 -0
- package/dist/SceneSerializer-zOzbX4jZ.js +932 -0
- package/dist/SceneSerializer-zOzbX4jZ.js.map +1 -0
- package/dist/SimulationProfile-DSYZbBLQ.js +165 -0
- package/dist/SimulationProfile-DSYZbBLQ.js.map +1 -0
- package/dist/StylePack-DcRa_kU0.js +88 -0
- package/dist/StylePack-DcRa_kU0.js.map +1 -0
- package/dist/WorldArchive-BiFGLt--.js +451 -0
- package/dist/WorldArchive-BiFGLt--.js.map +1 -0
- package/dist/WorldCommands-Debj7V4L.js +2207 -0
- package/dist/WorldCommands-Debj7V4L.js.map +1 -0
- package/dist/WorldIO-Ch8QBfKY.js +151 -0
- package/dist/WorldIO-Ch8QBfKY.js.map +1 -0
- package/dist/admission-CVEvsrdz.js +121 -0
- package/dist/admission-CVEvsrdz.js.map +1 -0
- package/dist/blankWorld-B0MW6g7q.js +75 -0
- package/dist/blankWorld-B0MW6g7q.js.map +1 -0
- package/dist/core.d.ts +68 -0
- package/dist/core.js +209 -0
- package/dist/core.js.map +1 -0
- package/dist/disposeObject3D-DIMzy0FA.js +128 -0
- package/dist/disposeObject3D-DIMzy0FA.js.map +1 -0
- package/dist/environments-HOe3sJXH.js +567 -0
- package/dist/environments-HOe3sJXH.js.map +1 -0
- package/dist/gltfIO-BzVKLyaL.js +339 -0
- package/dist/gltfIO-BzVKLyaL.js.map +1 -0
- package/dist/grandUrbanBlock-DRndRZjF.js +515 -0
- package/dist/grandUrbanBlock-DRndRZjF.js.map +1 -0
- package/dist/index.d.ts +345 -0
- package/dist/index.js +16952 -0
- package/dist/index.js.map +1 -0
- package/dist/magicCabin-CfBZjx2Q.js +11019 -0
- package/dist/magicCabin-CfBZjx2Q.js.map +1 -0
- package/dist/manifests-D0LwbJ36.js +866 -0
- package/dist/manifests-D0LwbJ36.js.map +1 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +1 -0
- package/dist/monumentHall-awZiGtda.js +403 -0
- package/dist/monumentHall-awZiGtda.js.map +1 -0
- package/dist/node.d.ts +16 -0
- package/dist/node.js +26 -0
- package/dist/parts-DrEcfJRl.js +37 -0
- package/dist/parts-DrEcfJRl.js.map +1 -0
- package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
- package/dist/ruinedCourtyard-DuF7NmUU.js +696 -0
- package/dist/ruinedCourtyard-DuF7NmUU.js.map +1 -0
- package/dist/runtime/application/AgentTools.js +28 -0
- package/dist/runtime/application/README.md +14 -0
- package/dist/runtime/application/agent/ProgressiveAgentTools.js +92 -0
- package/dist/runtime/application/agent/StudioMcpAllowlist.js +10 -0
- package/dist/runtime/application/agent/StudioProjectTools.js +18 -0
- package/dist/runtime/application/agent/TaskEvidence.js +199 -0
- package/dist/runtime/application/buildTaskObservation.js +117 -0
- package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +50 -0
- package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +35 -0
- package/dist/runtime/application/code-execution/BrowserCodeWorker.js +17 -0
- package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +82 -0
- package/dist/runtime/application/createSession.js +66 -0
- package/dist/runtime/application/createWorldAuthoringContext.js +400 -0
- package/dist/runtime/application/generation/GenerationOrchestrator.js +630 -0
- package/dist/runtime/application/generation/GenerationRuntime.js +215 -0
- package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +289 -0
- package/dist/runtime/application/native-scene/CodeProject.js +215 -0
- package/dist/runtime/application/native-scene/CodeProjectModules.js +143 -0
- package/dist/runtime/application/native-scene/ExampleWorldCatalog.js +35 -0
- package/dist/runtime/application/native-scene/NativeArticulation.js +53 -0
- package/dist/runtime/application/native-scene/NativeEditableRegistry.js +150 -0
- package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +85 -0
- package/dist/runtime/application/native-scene/NativeLightingInspection.js +33 -0
- package/dist/runtime/application/native-scene/NativeMaterialInspection.js +52 -0
- package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +127 -0
- package/dist/runtime/application/native-scene/NativePhysicsGeometry.js +64 -0
- package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +51 -0
- package/dist/runtime/application/native-scene/NativeSceneHost.js +406 -0
- package/dist/runtime/application/native-scene/NativeSceneInspection.js +203 -0
- package/dist/runtime/application/native-scene/NativeSceneOverlay.js +116 -0
- package/dist/runtime/application/native-scene/NativeSceneQuery.js +123 -0
- package/dist/runtime/application/native-scene/NativeSceneReview.js +132 -0
- package/dist/runtime/application/native-scene/NativeThreeModule.js +16 -0
- package/dist/runtime/application/native-scene/SceneObserver.js +97 -0
- package/dist/runtime/application/native-scene/VisualCapturePolicy.js +4 -0
- package/dist/runtime/application/object-forge/SceneObjectForge.js +263 -0
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +59 -0
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +22 -0
- package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +40 -0
- package/dist/runtime/application/scene/CapabilityResolver.js +90 -0
- package/dist/runtime/application/scene/NativeEditableContracts.js +18 -0
- package/dist/runtime/application/scene/RequestWindow.js +54 -0
- package/dist/runtime/application/scene/SceneAgentTools.js +21 -0
- package/dist/runtime/application/scene/SceneContracts.js +49 -0
- package/dist/runtime/application/scene/SceneEditService.js +154 -0
- package/dist/runtime/application/scene/SceneFacade.js +356 -0
- package/dist/runtime/application/scene/SceneInteractionAdapters.js +41 -0
- package/dist/runtime/application/scene/SceneJobController.js +320 -0
- package/dist/runtime/application/scene/SceneLifecycle.js +57 -0
- package/dist/runtime/application/scene/ScenePackage.js +173 -0
- package/dist/runtime/application/scene/ScenePersistence.js +50 -0
- package/dist/runtime/application/scene/SceneProject.js +95 -0
- package/dist/runtime/application/scene/SceneSkillNames.js +5 -0
- package/dist/runtime/application/scene/StarterScene.js +56 -0
- package/dist/runtime/application/scene/WorldArchive.js +89 -0
- package/dist/runtime/application/scene/WorldDirectory.js +20 -0
- package/dist/runtime/application/scene/WorldDocument.js +76 -0
- package/dist/runtime/application/scene/WorldIO.js +103 -0
- package/dist/runtime/application/scene/WorldStorage.js +155 -0
- package/dist/runtime/application/skills/SkillRegistry.js +193 -0
- package/dist/runtime/application/skills/packs/acceptanceSkills.js +32 -0
- package/dist/runtime/application/skills/packs/affordanceSkills.js +36 -0
- package/dist/runtime/application/skills/packs/assetSkills.js +46 -0
- package/dist/runtime/application/skills/packs/authoringSkills.js +16 -0
- package/dist/runtime/application/skills/packs/batchSkills.js +22 -0
- package/dist/runtime/application/skills/packs/codeSkills.js +106 -0
- package/dist/runtime/application/skills/packs/generationSkills.js +45 -0
- package/dist/runtime/application/skills/packs/interactionSkills.js +46 -0
- package/dist/runtime/application/skills/packs/recoverySkills.js +80 -0
- package/dist/runtime/application/skills/packs/sceneSkills.js +24 -0
- package/dist/runtime/application/skills/packs/spatialSkills.js +35 -0
- package/dist/runtime/application/skills/packs/verificationSkills.js +14 -0
- package/dist/runtime/application/skills/packs/worldSkills.js +45 -0
- package/dist/runtime/application/skills/registerCoreSkills.js +31 -0
- package/dist/runtime/application/skills/skillPrimitives.js +4 -0
- package/dist/runtime/application/tasks/CabinetCupTask.js +76 -0
- package/dist/runtime/application/tasks.jsonl +67 -0
- package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +42 -0
- package/dist/runtime/application/world-authoring/AuthoringDiff.js +149 -0
- package/dist/runtime/application/world-authoring/AuthoringDocument.js +825 -0
- package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +109 -0
- package/dist/runtime/application/world-authoring/AuthoringIdentity.js +17 -0
- package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +29 -0
- package/dist/runtime/application/world-authoring/AuthoringPatch.js +118 -0
- package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +334 -0
- package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +126 -0
- package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +144 -0
- package/dist/runtime/application/world-authoring/HeadlessImageExport.js +92 -0
- package/dist/runtime/application/world-authoring/ModelRef.js +62 -0
- package/dist/runtime/application/world-authoring/SceneGLBExport.js +88 -0
- package/dist/runtime/apps/mcp-server/AUTHORING.md +71 -0
- package/dist/runtime/apps/mcp-server/AgentMcpCompat.js +68 -0
- package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +1 -0
- package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +30 -0
- package/dist/runtime/apps/mcp-server/BuildEnvironment.js +17 -0
- package/dist/runtime/apps/mcp-server/CodeExecutor.js +71 -0
- package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +42 -0
- package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +66 -0
- package/dist/runtime/apps/mcp-server/FileAssetRepository.js +159 -0
- package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +8 -0
- package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +47 -0
- package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +157 -0
- package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +6 -0
- package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +116 -0
- package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +60 -0
- package/dist/runtime/apps/mcp-server/README.md +269 -0
- package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +1 -0
- package/dist/runtime/apps/mcp-server/SandboxBundle.js +13 -0
- package/dist/runtime/apps/mcp-server/SessionManager.js +148 -0
- package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +75 -0
- package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +246 -0
- package/dist/runtime/apps/mcp-server/StudioProjectToolContracts.js +58 -0
- package/dist/runtime/apps/mcp-server/TransferHttp.js +47 -0
- package/dist/runtime/apps/mcp-server/TransferLimits.js +6 -0
- package/dist/runtime/apps/mcp-server/TransferStore.js +134 -0
- package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +16 -0
- package/dist/runtime/apps/mcp-server/VALIDATION.md +45 -0
- package/dist/runtime/apps/mcp-server/acceptance-evidence.json +332 -0
- package/dist/runtime/apps/mcp-server/errorDiagnostics.js +32 -0
- package/dist/runtime/apps/mcp-server/examples/code-house.js +24 -0
- package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +85 -0
- package/dist/runtime/apps/mcp-server/main.mjs +82 -0
- package/dist/runtime/apps/mcp-server/registerTools.js +274 -0
- package/dist/runtime/apps/mcp-server/sandbox/run.mjs +23 -0
- package/dist/runtime/apps/mcp-server/security.js +23 -0
- package/dist/runtime/apps/mcp-server/tasks.jsonl +9 -0
- package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +157 -0
- package/dist/runtime/apps/server/README.md +7 -0
- package/dist/runtime/apps/server/WorldRepository.js +338 -0
- package/dist/runtime/apps/server/WorldRepositoryHttp.js +96 -0
- package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +278 -0
- package/dist/runtime/apps/server/tasks.jsonl +10 -0
- package/dist/runtime/apps/shared/node/WorldDiskStorage.js +62 -0
- package/dist/runtime/foundation/EventBus.js +26 -0
- package/dist/runtime/foundation/JsonGateway.js +47 -0
- package/dist/runtime/foundation/PngRgba.js +99 -0
- package/dist/runtime/foundation/PolicyEngine.js +21 -0
- package/dist/runtime/foundation/README.md +7 -0
- package/dist/runtime/foundation/TraceRecorder.js +76 -0
- package/dist/runtime/foundation/errors.js +8 -0
- package/dist/runtime/foundation/simulation/SimulationProfile.js +143 -0
- package/dist/runtime/foundation/version.js +2 -0
- package/dist/runtime/modules/agent/README.md +11 -0
- package/dist/runtime/modules/agent/ToolCallingAgent.js +19 -0
- package/dist/runtime/modules/agent/bootstrapWorld.js +10 -0
- package/dist/runtime/modules/agent/buildRecoveryProposals.js +533 -0
- package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +128 -0
- package/dist/runtime/modules/agent/execution/AgentRunResults.js +55 -0
- package/dist/runtime/modules/agent/execution/AgentRunSession.js +393 -0
- package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +40 -0
- package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +19 -0
- package/dist/runtime/modules/agent/prompt/index.js +52 -0
- package/dist/runtime/modules/agent/tasks.jsonl +94 -0
- package/dist/runtime/modules/artifact/ArtifactContentGate.js +144 -0
- package/dist/runtime/modules/artifact/ArtifactDescriptor.js +280 -0
- package/dist/runtime/modules/artifact/ArtifactImporter.js +185 -0
- package/dist/runtime/modules/artifact/ArtifactModule.js +111 -0
- package/dist/runtime/modules/artifact/ArtifactRegistry.js +197 -0
- package/dist/runtime/modules/artifact/IncrementalSha256.js +129 -0
- package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +115 -0
- package/dist/runtime/modules/artifact/README.md +7 -0
- package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +67 -0
- package/dist/runtime/modules/artifact/tasks.jsonl +31 -0
- package/dist/runtime/modules/asset/AssetModule.js +416 -0
- package/dist/runtime/modules/asset/README.md +67 -0
- package/dist/runtime/modules/asset/loading/AssetLoader.js +157 -0
- package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +61 -0
- package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +95 -0
- package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +33 -0
- package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +103 -0
- package/dist/runtime/modules/asset/model/AssetInputContracts.js +139 -0
- package/dist/runtime/modules/asset/model/AssetRef.js +12 -0
- package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +172 -0
- package/dist/runtime/modules/asset/model/ProceduralTextureContract.js +24 -0
- package/dist/runtime/modules/asset/model/admission.js +117 -0
- package/dist/runtime/modules/asset/model/errors.js +6 -0
- package/dist/runtime/modules/asset/model/parts.js +27 -0
- package/dist/runtime/modules/asset/model/resourceBudget.js +10 -0
- package/dist/runtime/modules/asset/model/schema.js +150 -0
- package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +78 -0
- package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +84 -0
- package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +86 -0
- package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +81 -0
- package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +272 -0
- package/dist/runtime/modules/asset/production/AssetRecipe.js +91 -0
- package/dist/runtime/modules/asset/production/ProceduralTexture.js +85 -0
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +45 -0
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +590 -0
- package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +173 -0
- package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +124 -0
- package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +56 -0
- package/dist/runtime/modules/asset/production/compiler/gltfIO.js +6 -0
- package/dist/runtime/modules/asset/production/compiler/partGeometry.js +74 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +63 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +48 -0
- package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +16 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +30 -0
- package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +75 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +20 -0
- package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +34 -0
- package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +32 -0
- package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +116 -0
- package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +84 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +63 -0
- package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +16 -0
- package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +23 -0
- package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +50 -0
- package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +60 -0
- package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +93 -0
- package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +32 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +55 -0
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +203 -0
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +43 -0
- package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +33 -0
- package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +60 -0
- package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +23 -0
- package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +198 -0
- package/dist/runtime/modules/asset/registry/AssetCatalog.js +72 -0
- package/dist/runtime/modules/asset/registry/AssetRegistry.js +51 -0
- package/dist/runtime/modules/asset/registry/manifests/index.js +173 -0
- package/dist/runtime/modules/asset/tasks.jsonl +87 -0
- package/dist/runtime/modules/generation/README.md +9 -0
- package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +45 -0
- package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +169 -0
- package/dist/runtime/modules/generation/connector/ConnectorClient.js +192 -0
- package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +167 -0
- package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +179 -0
- package/dist/runtime/modules/generation/connector/ConnectorSession.js +202 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +239 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +99 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +91 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +50 -0
- package/dist/runtime/modules/generation/providers/ProviderRegistry.js +304 -0
- package/dist/runtime/modules/generation/tasks.jsonl +35 -0
- package/dist/runtime/modules/navigation/NavigationBackend.js +17 -0
- package/dist/runtime/modules/navigation/RecastNavigationBackend.js +263 -0
- package/dist/runtime/modules/physics/JoltPhysicsBackend.js +850 -0
- package/dist/runtime/modules/physics/PhysicsApiSurface.js +660 -0
- package/dist/runtime/modules/physics/PhysicsBackend.js +88 -0
- package/dist/runtime/modules/physics/RapierPhysicsBackend.js +414 -0
- package/dist/runtime/modules/rendering/README.md +7 -0
- package/dist/runtime/modules/rendering/RendererProbe.js +153 -0
- package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +140 -0
- package/dist/runtime/modules/rendering/captureStill.js +54 -0
- package/dist/runtime/modules/rendering/createRenderer.js +76 -0
- package/dist/runtime/modules/rendering/disposeObject3D.js +37 -0
- package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +74 -0
- package/dist/runtime/modules/rendering/spatial/ThreeBvhRuntime.js +107 -0
- package/dist/runtime/modules/rendering/style/StylePack.js +34 -0
- package/dist/runtime/modules/rendering/style/StyleSystem.js +173 -0
- package/dist/runtime/modules/rendering/tasks.jsonl +7 -0
- package/dist/runtime/modules/world/README.md +13 -0
- package/dist/runtime/modules/world/build/WorldBuilder.js +170 -0
- package/dist/runtime/modules/world/compiler/PipelineEngine.js +32 -0
- package/dist/runtime/modules/world/compiler/WorldAdmission.js +43 -0
- package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +68 -0
- package/dist/runtime/modules/world/compiler/WorldCompilation.js +157 -0
- package/dist/runtime/modules/world/compiler/WorldComposer.js +201 -0
- package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +76 -0
- package/dist/runtime/modules/world/compiler/WorldRecompiler.js +356 -0
- package/dist/runtime/modules/world/compiler/WorldRetry.js +75 -0
- package/dist/runtime/modules/world/compiler/createWorldPipeline.js +379 -0
- package/dist/runtime/modules/world/content/blankWorld.js +35 -0
- package/dist/runtime/modules/world/content/environments.js +84 -0
- package/dist/runtime/modules/world/content/grandUrbanBlock.js +189 -0
- package/dist/runtime/modules/world/content/magic-cabin/README.md +28 -0
- package/dist/runtime/modules/world/content/magic-cabin/affordances.js +64 -0
- package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +7078 -0
- package/dist/runtime/modules/world/content/magic-cabin/lighting.js +26 -0
- package/dist/runtime/modules/world/content/magic-cabin/materials.js +20 -0
- package/dist/runtime/modules/world/content/magicCabin.js +190 -0
- package/dist/runtime/modules/world/content/monumentHall.js +154 -0
- package/dist/runtime/modules/world/content/ruinedCourtyard.js +196 -0
- package/dist/runtime/modules/world/content/suzhouGarden/README.md +141 -0
- package/dist/runtime/modules/world/content/suzhouGarden/index.js +137 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +491 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +670 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +578 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +127 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +642 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +650 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +280 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +242 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +215 -0
- package/dist/runtime/modules/world/content/woodlandWorkshop.js +192 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/README.md +36 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +351 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +490 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/core.js +505 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/index.js +101 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +435 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +169 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/water.js +245 -0
- package/dist/runtime/modules/world/errors.js +9 -0
- package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +50 -0
- package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +297 -0
- package/dist/runtime/modules/world/runtime/CommandHistory.js +111 -0
- package/dist/runtime/modules/world/runtime/EntityCapabilityRegistry.js +165 -0
- package/dist/runtime/modules/world/runtime/NativeNavigationGeometry.js +84 -0
- package/dist/runtime/modules/world/runtime/NativePhysicsSnapshot.js +245 -0
- package/dist/runtime/modules/world/runtime/ObjectStore.js +31 -0
- package/dist/runtime/modules/world/runtime/ObjectTransform.js +62 -0
- package/dist/runtime/modules/world/runtime/ObservedEntity.js +37 -0
- package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +240 -0
- package/dist/runtime/modules/world/runtime/SceneExtensions.js +36 -0
- package/dist/runtime/modules/world/runtime/ScenePresentation.js +101 -0
- package/dist/runtime/modules/world/runtime/SceneSerializer.js +281 -0
- package/dist/runtime/modules/world/runtime/WorldAuthority.js +41 -0
- package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +14 -0
- package/dist/runtime/modules/world/runtime/WorldCommands.js +503 -0
- package/dist/runtime/modules/world/runtime/WorldObservation.js +71 -0
- package/dist/runtime/modules/world/runtime/WorldQueries.js +340 -0
- package/dist/runtime/modules/world/runtime/WorldRecovery.js +78 -0
- package/dist/runtime/modules/world/runtime/WorldRuntime.js +806 -0
- package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +110 -0
- package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +130 -0
- package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +79 -0
- package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +195 -0
- package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +70 -0
- package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +115 -0
- package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +390 -0
- package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +214 -0
- package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +65 -0
- package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +244 -0
- package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +147 -0
- package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +57 -0
- package/dist/runtime/modules/world/runtime/interaction/ManipulationActions.js +7 -0
- package/dist/runtime/modules/world/runtime/interaction/NativePhysicalTarget.js +31 -0
- package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +123 -0
- package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +134 -0
- package/dist/runtime/modules/world/runtime/semantic/NativePhysicsState.js +89 -0
- package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +129 -0
- package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +89 -0
- package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +104 -0
- package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +269 -0
- package/dist/runtime/modules/world/runtime/simulation/WorldTimeline.js +110 -0
- package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +56 -0
- package/dist/runtime/modules/world/runtime/spatial/VisualMeshBounds.js +41 -0
- package/dist/runtime/modules/world/runtime/systems/AudioSystem.js +306 -0
- package/dist/runtime/modules/world/runtime/systems/Instrument.js +39 -0
- package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +806 -0
- package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +281 -0
- package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +561 -0
- package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +1752 -0
- package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +527 -0
- package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +402 -0
- package/dist/runtime/modules/world/spec/WorldIR.js +165 -0
- package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +86 -0
- package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +51 -0
- package/dist/runtime/modules/world/spec/WorldRevision.js +231 -0
- package/dist/runtime/modules/world/spec/WorldSpec.js +86 -0
- package/dist/runtime/modules/world/tasks.jsonl +530 -0
- package/dist/runtime/modules/world/verification/ArticulationVerifier.js +254 -0
- package/dist/runtime/modules/world/verification/Finding.js +105 -0
- package/dist/runtime/modules/world/verification/InteractionEvidence.js +73 -0
- package/dist/runtime/modules/world/verification/RepairEngine.js +49 -0
- package/dist/runtime/modules/world/verification/VisualLayoutAcceptance.js +58 -0
- package/dist/runtime/modules/world/verification/WorldAcceptance.js +176 -0
- package/dist/runtime/modules/world/verification/WorldValidator.js +67 -0
- package/dist/runtime/package-lock.json +16071 -0
- package/dist/runtime/package.json +106 -0
- package/dist/runtime/public/assets/cabinet.glb +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
- package/dist/schema-DT7K9NjP.js +165 -0
- package/dist/schema-DT7K9NjP.js.map +1 -0
- package/dist/suzhouGarden-Y3hny8j6.js +6150 -0
- package/dist/suzhouGarden-Y3hny8j6.js.map +1 -0
- package/dist/version-CHc-i8ch.js +5 -0
- package/dist/version-CHc-i8ch.js.map +1 -0
- package/dist/woodlandWorkshop-DsScU-cx.js +483 -0
- package/dist/woodlandWorkshop-DsScU-cx.js.map +1 -0
- package/dist/yuanmingyuan-DsFnPzzR.js +4955 -0
- package/dist/yuanmingyuan-DsFnPzzR.js.map +1 -0
- package/package.json +75 -4
|
@@ -0,0 +1,578 @@
|
|
|
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
|
+
}
|