agentscape3d 1.0.0-beta.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -48
- package/dist/core.d.ts +68 -0
- package/dist/core.js +209 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +10 -229
- package/dist/index.js +192 -15462
- package/dist/index.js.map +1 -1
- package/package.json +11 -40
- package/cli.mjs +0 -27
- package/dist/AssetCompiler-CDFiElji.js +0 -2451
- package/dist/AssetCompiler-CDFiElji.js.map +0 -1
- package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
- package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
- package/dist/AssetRecipe-DmFpzxr-.js +0 -55
- package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
- package/dist/BrowserCodeWorker.js +0 -53615
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
- package/dist/SceneSerializer-DPVOyeRk.js +0 -353
- package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
- package/dist/StylePack-DNrdLeGI.js +0 -6314
- package/dist/StylePack-DNrdLeGI.js.map +0 -1
- package/dist/WorldArchive-pSBIGxLa.js +0 -420
- package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
- package/dist/WorldIO-wsDfZGM4.js +0 -150
- package/dist/WorldIO-wsDfZGM4.js.map +0 -1
- package/dist/blankWorld-CBWbwJGj.js +0 -76
- package/dist/blankWorld-CBWbwJGj.js.map +0 -1
- package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
- package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
- package/dist/environments-DgH66NqV.js +0 -4220
- package/dist/environments-DgH66NqV.js.map +0 -1
- package/dist/gltfIO-B87nJaat.js +0 -10
- package/dist/gltfIO-B87nJaat.js.map +0 -1
- package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
- package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
- package/dist/magicCabin-D64fD1E2.js +0 -11024
- package/dist/magicCabin-D64fD1E2.js.map +0 -1
- package/dist/mcp.d.ts +0 -2
- package/dist/mcp.js +0 -1
- package/dist/monumentHall-BKbs0UOQ.js +0 -404
- package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
- package/dist/node.d.ts +0 -16
- package/dist/node.js +0 -25
- package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
- package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
- package/dist/runtime/application/AgentTools.js +0 -25
- package/dist/runtime/application/README.md +0 -14
- package/dist/runtime/application/buildTaskObservation.js +0 -117
- package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
- package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
- package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
- package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
- package/dist/runtime/application/createSession.js +0 -66
- package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
- package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
- package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
- package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
- package/dist/runtime/application/native-scene/CodeProject.js +0 -119
- package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
- package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
- package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
- package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
- package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
- package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
- package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
- package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
- package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
- package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
- package/dist/runtime/application/scene/RequestWindow.js +0 -54
- package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
- package/dist/runtime/application/scene/SceneContracts.js +0 -45
- package/dist/runtime/application/scene/SceneEditService.js +0 -144
- package/dist/runtime/application/scene/SceneFacade.js +0 -267
- package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
- package/dist/runtime/application/scene/SceneJobController.js +0 -229
- package/dist/runtime/application/scene/ScenePackage.js +0 -162
- package/dist/runtime/application/scene/ScenePersistence.js +0 -50
- package/dist/runtime/application/scene/SceneProject.js +0 -95
- package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
- package/dist/runtime/application/scene/StarterScene.js +0 -56
- package/dist/runtime/application/scene/WorldArchive.js +0 -87
- package/dist/runtime/application/scene/WorldDirectory.js +0 -20
- package/dist/runtime/application/scene/WorldDocument.js +0 -74
- package/dist/runtime/application/scene/WorldIO.js +0 -103
- package/dist/runtime/application/scene/WorldStorage.js +0 -137
- package/dist/runtime/application/skills/SkillRegistry.js +0 -163
- package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
- package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
- package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
- package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
- package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
- package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
- package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
- package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
- package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
- package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
- package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
- package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
- package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
- package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
- package/dist/runtime/application/skills/skillPrimitives.js +0 -4
- package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
- package/dist/runtime/application/tasks.jsonl +0 -67
- package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
- package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
- package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
- package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
- package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
- package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
- package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
- package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
- package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
- package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
- package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
- package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
- package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
- package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
- package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
- package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
- package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
- package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
- package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
- package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
- package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
- package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
- package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
- package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
- package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
- package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
- package/dist/runtime/apps/mcp-server/README.md +0 -150
- package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
- package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
- package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
- package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
- package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
- package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
- package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
- package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
- package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
- package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
- package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
- package/dist/runtime/apps/mcp-server/main.mjs +0 -56
- package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
- package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
- package/dist/runtime/apps/mcp-server/security.js +0 -21
- package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
- package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
- package/dist/runtime/apps/server/README.md +0 -7
- package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
- package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
- package/dist/runtime/apps/server/tasks.jsonl +0 -10
- package/dist/runtime/foundation/EventBus.js +0 -18
- package/dist/runtime/foundation/JsonGateway.js +0 -47
- package/dist/runtime/foundation/PolicyEngine.js +0 -21
- package/dist/runtime/foundation/README.md +0 -7
- package/dist/runtime/foundation/TraceRecorder.js +0 -76
- package/dist/runtime/foundation/errors.js +0 -8
- package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
- package/dist/runtime/foundation/version.js +0 -2
- package/dist/runtime/modules/agent/README.md +0 -11
- package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
- package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
- package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
- package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
- package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
- package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
- package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
- package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
- package/dist/runtime/modules/agent/prompt/index.js +0 -46
- package/dist/runtime/modules/agent/tasks.jsonl +0 -94
- package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
- package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
- package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
- package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
- package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
- package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
- package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
- package/dist/runtime/modules/artifact/README.md +0 -7
- package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
- package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
- package/dist/runtime/modules/asset/AssetModule.js +0 -399
- package/dist/runtime/modules/asset/README.md +0 -54
- package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
- package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
- package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
- package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
- package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
- package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
- package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
- package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
- package/dist/runtime/modules/asset/model/admission.js +0 -117
- package/dist/runtime/modules/asset/model/errors.js +0 -6
- package/dist/runtime/modules/asset/model/parts.js +0 -27
- package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
- package/dist/runtime/modules/asset/model/schema.js +0 -150
- package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
- package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
- package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
- package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
- package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
- package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
- package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
- package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
- package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
- package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
- package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
- package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
- package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
- package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
- package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
- package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
- package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
- package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
- package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
- package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
- package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
- package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
- package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
- package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
- package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
- package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
- package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
- package/dist/runtime/modules/asset/tasks.jsonl +0 -87
- package/dist/runtime/modules/generation/README.md +0 -9
- package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
- package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
- package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
- package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
- package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
- package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
- package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
- package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
- package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
- package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
- package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
- package/dist/runtime/modules/generation/tasks.jsonl +0 -35
- package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
- package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
- package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
- package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
- package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
- package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
- package/dist/runtime/modules/rendering/README.md +0 -7
- package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
- package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
- package/dist/runtime/modules/rendering/createRenderer.js +0 -76
- package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
- package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
- package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
- package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
- package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
- package/dist/runtime/modules/world/README.md +0 -13
- package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
- package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
- package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
- package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
- package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
- package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
- package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
- package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
- package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
- package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
- package/dist/runtime/modules/world/content/blankWorld.js +0 -35
- package/dist/runtime/modules/world/content/environments.js +0 -84
- package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
- package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
- package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
- package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
- package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
- package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
- package/dist/runtime/modules/world/content/magicCabin.js +0 -190
- package/dist/runtime/modules/world/content/monumentHall.js +0 -154
- package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
- package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
- package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
- package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
- package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
- package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
- package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
- package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
- package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
- package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
- package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
- package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
- package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
- package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
- package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
- package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
- package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
- package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
- package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
- package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
- package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
- package/dist/runtime/modules/world/errors.js +0 -9
- package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
- package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
- package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
- package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
- package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
- package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
- package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
- package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
- package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
- package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
- package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
- package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
- package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
- package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
- package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
- package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
- package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
- package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
- package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
- package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
- package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
- package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
- package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
- package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
- package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
- package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
- package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
- package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
- package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
- package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
- package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
- package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
- package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
- package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
- package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
- package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
- package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
- package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
- package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
- package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
- package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
- package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
- package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
- package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
- package/dist/runtime/modules/world/tasks.jsonl +0 -530
- package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
- package/dist/runtime/modules/world/verification/Finding.js +0 -105
- package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
- package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
- package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
- package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
- package/dist/runtime/package-lock.json +0 -6245
- package/dist/runtime/package.json +0 -91
- 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-Dudvovhu.js +0 -364
- package/dist/schema-Dudvovhu.js.map +0 -1
- package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
- package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
- package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
- package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
- package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
- package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
|
@@ -1,435 +0,0 @@
|
|
|
1
|
-
/* 地形、园路、植被、荷塘、残石与远景林带 */
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
import { mergeGeometries } from 'three/addons/utils/BufferGeometryUtils.js';
|
|
4
|
-
import { fbm, R, mulberry32, chamferBoxGeo, WORLD, POIS } from './core.js';
|
|
5
|
-
|
|
6
|
-
const clamp = (v, a, b) => v < a ? a : v > b ? b : v;
|
|
7
|
-
const smoothstep = (a, b, v) => { const t = clamp((v - a) / (b - a), 0, 1); return t * t * (3 - 2 * t); };
|
|
8
|
-
|
|
9
|
-
const LAKE_C = [18, 112], LAKE_R = [128, 42];
|
|
10
|
-
export function lakeShoreAngle(a) {
|
|
11
|
-
return 1 + 0.10 * Math.sin(a * 3 + 1.3) + 0.06 * Math.sin(a * 7 + 0.4)
|
|
12
|
-
+ 0.025 * Math.sin(a * 13 + 2.1);
|
|
13
|
-
}
|
|
14
|
-
export function lakeDepthFactor(x, z) {
|
|
15
|
-
const qx = (x - LAKE_C[0]) / LAKE_R[0], qz = (z - LAKE_C[1]) / LAKE_R[1];
|
|
16
|
-
const a = Math.atan2(qz, qx), d = Math.hypot(qx, qz);
|
|
17
|
-
return 1 - smoothstep(lakeShoreAngle(a) - 0.06, lakeShoreAngle(a) + 0.22, d);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function terrainHeight(x, z) {
|
|
21
|
-
const n = (fbm(x / 105 + 2.3, z / 105 + 4.1, 5, 4, 8) - 0.5) * 3.4;
|
|
22
|
-
const hillNW = 12 * Math.exp(-(((x + 205) / 88) ** 2 + ((z + 135) / 74) ** 2));
|
|
23
|
-
const hillE = 7 * Math.exp(-(((x - 228) / 74) ** 2 + ((z + 78) / 95) ** 2));
|
|
24
|
-
const xianfa = 6.5 * Math.exp(-(((x - 140) / 27) ** 2 + ((z + 36) / 24) ** 2));
|
|
25
|
-
const soft = (fbm(x / 36 + 8.2, z / 36 + 1.7, 23, 3, 8) - 0.5) * 0.5;
|
|
26
|
-
// 核心建筑区趋于平整
|
|
27
|
-
const fx = 1 - smoothstep(165, 215, Math.abs(x));
|
|
28
|
-
const fz = 1 - smoothstep(95, 145, Math.abs(z + 2));
|
|
29
|
-
const flat = fx * fz;
|
|
30
|
-
let h = (n + hillNW + hillE + xianfa + soft) * (1 - flat * 0.96);
|
|
31
|
-
h += flat * soft * 0.12;
|
|
32
|
-
h -= lakeDepthFactor(x, z) * 2.6;
|
|
33
|
-
return h;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const PATHS = [
|
|
37
|
-
[[-175, 22], [-120, 20], [-60, 22], [10, 20], [70, 20], [165, 16]],
|
|
38
|
-
[[40, -70], [40, -20], [40, 20], [40, 60], [40, 92]],
|
|
39
|
-
[[-72, -30], [-72, 10], [-70, 40], [-62, 62]],
|
|
40
|
-
[[-152, -30], [-152, 20], [-138, 30], [-110, 22]],
|
|
41
|
-
[[-20, 40], [0, 66], [18, 92], [50, 104], [100, 100]],
|
|
42
|
-
[[-118, -40], [-106, -10], [-100, 14]],
|
|
43
|
-
[[100, 20], [130, 6], [160, -12]],
|
|
44
|
-
];
|
|
45
|
-
function pathDist(x, z) {
|
|
46
|
-
let best = 1e9;
|
|
47
|
-
for (const seg of PATHS) {
|
|
48
|
-
for (let i = 0; i < seg.length - 1; i++) {
|
|
49
|
-
const [ax, az] = seg[i], [bx, bz] = seg[i + 1];
|
|
50
|
-
const dx = bx - ax, dz = bz - az;
|
|
51
|
-
const t = clamp(((x - ax) * dx + (z - az) * dz) / (dx * dx + dz * dz), 0, 1);
|
|
52
|
-
best = Math.min(best, Math.hypot(x - (ax + t * dx), z - (az + t * dz)));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return best;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const EXCLUDE = [
|
|
59
|
-
[-110, 110, -25, 25], // 大水法片区
|
|
60
|
-
[10, 70, -48, 24],
|
|
61
|
-
[-110, -34, -14, 16], // 海晏堂
|
|
62
|
-
[-105, -40, 30, 48], // 生肖钟
|
|
63
|
-
[-165, -115, -14, 24], // 谐奇趣
|
|
64
|
-
[-132, -104, -50, -30], // 方外观
|
|
65
|
-
[-180, -124, -26, 26], // 黄花阵
|
|
66
|
-
[122, 160, -24, 4], // 线法山
|
|
67
|
-
];
|
|
68
|
-
/* 预设机位与其视线走廊保持通透,避免树冠贴在镜头前 */
|
|
69
|
-
const SIGHTLINES = POIS.map(p => [p.pos[0], p.pos[2], p.target[0], p.target[2]]);
|
|
70
|
-
function sightDist(x, z) {
|
|
71
|
-
let best = 1e9;
|
|
72
|
-
for (const [ax, az, bx, bz] of SIGHTLINES) {
|
|
73
|
-
const dx = bx - ax, dz = bz - az;
|
|
74
|
-
const t = clamp(((x - ax) * dx + (z - az) * dz) / (dx * dx + dz * dz), 0, 1);
|
|
75
|
-
best = Math.min(best, Math.hypot(x - (ax + t * dx), z - (az + t * dz)));
|
|
76
|
-
}
|
|
77
|
-
return best;
|
|
78
|
-
}
|
|
79
|
-
function blocked(x, z, pad = 0) {
|
|
80
|
-
for (const [x1, x2, z1, z2] of EXCLUDE) if (x > x1 - pad && x < x2 + pad && z > z1 - pad && z < z2 + pad) return true;
|
|
81
|
-
if (lakeDepthFactor(x, z) > 0.12) return true;
|
|
82
|
-
if (pathDist(x, z) < 2.6) return true;
|
|
83
|
-
if (sightDist(x, z) < 8.5) return true;
|
|
84
|
-
for (const p of POIS) if (Math.hypot(x - p.pos[0], z - p.pos[2]) < 15) return true;
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function withColor(g, col) {
|
|
89
|
-
const geo = g.index ? g.toNonIndexed() : g;
|
|
90
|
-
const n = geo.getAttribute('position').count;
|
|
91
|
-
const arr = new Float32Array(n * 3);
|
|
92
|
-
for (let i = 0; i < n; i++) { arr[i * 3] = col[0]; arr[i * 3 + 1] = col[1]; arr[i * 3 + 2] = col[2]; }
|
|
93
|
-
geo.setAttribute('color', new THREE.Float32BufferAttribute(arr, 3));
|
|
94
|
-
return geo;
|
|
95
|
-
}
|
|
96
|
-
function treeGeometry(kind) {
|
|
97
|
-
const parts = [];
|
|
98
|
-
const trunk = new THREE.CylinderGeometry(0.19, 0.31, 3.6, 7, 1);
|
|
99
|
-
trunk.translate(0, 1.8, 0);
|
|
100
|
-
parts.push(withColor(trunk, [0.30, 0.22, 0.16]));
|
|
101
|
-
if (kind === 0) { // 国槐 / 银杏
|
|
102
|
-
const blobs = [
|
|
103
|
-
[0, 4.8, 0, 2.15], [1.5, 4.3, 0.5, 1.55], [-1.4, 4.6, -0.5, 1.6],
|
|
104
|
-
[0.5, 6.0, -1.0, 1.5], [-0.6, 5.8, 1.2, 1.45], [1.0, 5.5, 1.4, 1.2],
|
|
105
|
-
];
|
|
106
|
-
blobs.forEach(([x, y, z, r], i) => {
|
|
107
|
-
const g = new THREE.IcosahedronGeometry(r, 1);
|
|
108
|
-
g.scale(1, 0.86, 1); g.translate(x, y, z);
|
|
109
|
-
parts.push(withColor(g, [0.26 + (i % 3) * 0.035, 0.42 + (i % 4) * 0.035, 0.20 + (i % 2) * 0.02]));
|
|
110
|
-
});
|
|
111
|
-
for (let i = 0; i < 4; i++) {
|
|
112
|
-
const a = i / 4 * Math.PI * 2;
|
|
113
|
-
const g = new THREE.CylinderGeometry(0.06, 0.11, 1.7, 5);
|
|
114
|
-
g.rotateZ(Math.sin(a) * 0.6); g.rotateX(Math.cos(a) * 0.6);
|
|
115
|
-
g.translate(Math.cos(a) * 0.7, 3.2, Math.sin(a) * 0.7);
|
|
116
|
-
parts.push(withColor(g, [0.30, 0.22, 0.16]));
|
|
117
|
-
}
|
|
118
|
-
} else if (kind === 1) { // 松
|
|
119
|
-
for (let i = 0; i < 3; i++) {
|
|
120
|
-
const g = new THREE.ConeGeometry(2.3 - i * 0.5, 2.6, 9, 1);
|
|
121
|
-
g.translate(0, 3.0 + i * 1.5, 0);
|
|
122
|
-
parts.push(withColor(g, [0.15 + i * 0.02, 0.29 + i * 0.03, 0.17]));
|
|
123
|
-
}
|
|
124
|
-
} else { // 垂柳
|
|
125
|
-
const top = new THREE.IcosahedronGeometry(2.4, 1);
|
|
126
|
-
top.scale(1.3, 0.62, 1.3); top.translate(0, 4.9, 0);
|
|
127
|
-
parts.push(withColor(top, [0.31, 0.47, 0.23]));
|
|
128
|
-
for (let i = 0; i < 14; i++) {
|
|
129
|
-
const a = i / 14 * Math.PI * 2, r = 1.5 + (i % 3) * 0.35;
|
|
130
|
-
const g = new THREE.CylinderGeometry(0.035, 0.07, 3.3 + (i % 4) * 0.5, 4, 1);
|
|
131
|
-
g.translate(Math.cos(a) * r, 3.2, Math.sin(a) * r);
|
|
132
|
-
parts.push(withColor(g, [0.30, 0.46, 0.22]));
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
const merged = mergeGeometries(parts, false);
|
|
136
|
-
parts.forEach(p => p.dispose());
|
|
137
|
-
return merged;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/* 远景林带专用低模:仅主干 + 2 团树冠,约为近景树的 1/5 面数 */
|
|
141
|
-
function beltGeometry() {
|
|
142
|
-
const parts = [];
|
|
143
|
-
const trunk = new THREE.CylinderGeometry(0.18, 0.28, 3.4, 5, 1);
|
|
144
|
-
trunk.translate(0, 1.7, 0);
|
|
145
|
-
parts.push(withColor(trunk, [0.30, 0.22, 0.16]));
|
|
146
|
-
for (let i = 0; i < 2; i++) {
|
|
147
|
-
const g = new THREE.IcosahedronGeometry(i ? 1.6 : 2.0, 0);
|
|
148
|
-
g.scale(1, 0.9, 1);
|
|
149
|
-
g.translate(0, 3.7 + i * 1.5, 0);
|
|
150
|
-
parts.push(withColor(g, [0.22 + i * 0.04, 0.36 + i * 0.05, 0.21]));
|
|
151
|
-
}
|
|
152
|
-
const merged = mergeGeometries(parts, false);
|
|
153
|
-
parts.forEach(p => p.dispose());
|
|
154
|
-
return merged;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function grassTexture() {
|
|
158
|
-
// Server-side world initialization has no DOM. The actual grass blade
|
|
159
|
-
// texture is generated in the browser; physics/navigation only need geometry.
|
|
160
|
-
if (typeof document === 'undefined') {
|
|
161
|
-
const texture = new THREE.DataTexture(new Uint8Array([135, 159, 88, 255]), 1, 1);
|
|
162
|
-
texture.colorSpace = THREE.SRGBColorSpace;
|
|
163
|
-
texture.needsUpdate = true;
|
|
164
|
-
return texture;
|
|
165
|
-
}
|
|
166
|
-
const cv = document.createElement('canvas'); cv.width = cv.height = 64;
|
|
167
|
-
const c = cv.getContext('2d');
|
|
168
|
-
c.clearRect(0, 0, 64, 64);
|
|
169
|
-
for (let i = 0; i < 9; i++) {
|
|
170
|
-
const x = 6 + i * 6.5 + R() * 3, h = 26 + R() * 26;
|
|
171
|
-
const g = c.createLinearGradient(x, 64, x, 64 - h);
|
|
172
|
-
g.addColorStop(0, '#5c7138'); g.addColorStop(0.55, '#8ea354'); g.addColorStop(1, '#c8cd84');
|
|
173
|
-
c.fillStyle = g;
|
|
174
|
-
c.beginPath(); c.moveTo(x - 2.2, 64); c.quadraticCurveTo(x - 2, 64 - h * 0.6, x + (R() - 0.5) * 8, 64 - h);
|
|
175
|
-
c.quadraticCurveTo(x + 2.4, 64 - h * 0.55, x + 2.2, 64); c.closePath(); c.fill();
|
|
176
|
-
}
|
|
177
|
-
const t = new THREE.CanvasTexture(cv);
|
|
178
|
-
t.colorSpace = THREE.SRGBColorSpace;
|
|
179
|
-
return t;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export function createNature(scene, M, ctx) {
|
|
183
|
-
const group = new THREE.Group(); group.name = 'nature'; scene.add(group);
|
|
184
|
-
|
|
185
|
-
/* --- 地形 --- */
|
|
186
|
-
const [GW, GD] = WORLD.groundSize;
|
|
187
|
-
const tg = new THREE.PlaneGeometry(GW, GD, 168, 132);
|
|
188
|
-
tg.rotateX(-Math.PI / 2);
|
|
189
|
-
const pos = tg.getAttribute('position');
|
|
190
|
-
const colors = new Float32Array(pos.count * 3);
|
|
191
|
-
const cGrass = new THREE.Color().setRGB(0.76, 0.85, 0.52);
|
|
192
|
-
const cDry = new THREE.Color().setRGB(0.98, 0.88, 0.64);
|
|
193
|
-
const cPath = new THREE.Color().setRGB(1.10, 1.02, 0.86);
|
|
194
|
-
const cWet = new THREE.Color().setRGB(0.52, 0.60, 0.44);
|
|
195
|
-
const tmp = new THREE.Color();
|
|
196
|
-
for (let i = 0; i < pos.count; i++) {
|
|
197
|
-
const x = pos.getX(i), z = pos.getZ(i);
|
|
198
|
-
const h = terrainHeight(x, z);
|
|
199
|
-
pos.setY(i, h);
|
|
200
|
-
const n = fbm(x / 28 + 3.1, z / 28 + 7.4, 61, 4, 8);
|
|
201
|
-
tmp.copy(cGrass).lerp(cDry, clamp((n - 0.4) * 1.5, 0, 1));
|
|
202
|
-
const pd = pathDist(x, z);
|
|
203
|
-
tmp.lerp(cPath, (1 - smoothstep(2.2, 4.0, pd)) * 0.9);
|
|
204
|
-
const wet = lakeDepthFactor(x, z);
|
|
205
|
-
tmp.lerp(cWet, wet * 0.7);
|
|
206
|
-
tmp.multiplyScalar(0.94 + n * 0.22);
|
|
207
|
-
colors[i * 3] = tmp.r; colors[i * 3 + 1] = tmp.g; colors[i * 3 + 2] = tmp.b;
|
|
208
|
-
}
|
|
209
|
-
tg.setAttribute('color', new THREE.Float32BufferAttribute(colors, 3));
|
|
210
|
-
tg.computeVertexNormals();
|
|
211
|
-
const groundMat = M.ground.clone();
|
|
212
|
-
groundMat.vertexColors = true;
|
|
213
|
-
groundMat.map.wrapS = groundMat.map.wrapT = THREE.RepeatWrapping;
|
|
214
|
-
groundMat.map.repeat.set(1, 1);
|
|
215
|
-
const ground = new THREE.Mesh(tg, groundMat);
|
|
216
|
-
ground.receiveShadow = true;
|
|
217
|
-
ground.name = 'terrain';
|
|
218
|
-
group.add(ground);
|
|
219
|
-
|
|
220
|
-
/* --- 园路碎石与路缘 --- */
|
|
221
|
-
const pebbleGeo = new THREE.IcosahedronGeometry(0.24, 0);
|
|
222
|
-
const pebbleMat = new THREE.MeshStandardMaterial({ color: 0xa79c86, roughness: 1 });
|
|
223
|
-
const pebbles = new THREE.InstancedMesh(pebbleGeo, pebbleMat, 900);
|
|
224
|
-
const dummy = new THREE.Object3D();
|
|
225
|
-
for (let i = 0; i < 900; i++) {
|
|
226
|
-
let x, z, tries = 0;
|
|
227
|
-
do { x = (R() - 0.5) * 340; z = (R() - 0.5) * 200 + 8; tries++; } while (blocked(x, z, -1.5) && tries < 12);
|
|
228
|
-
dummy.position.set(x, terrainHeight(x, z) + 0.06, z);
|
|
229
|
-
dummy.rotation.set(R() * 3, R() * 6, R() * 3);
|
|
230
|
-
dummy.scale.setScalar(0.4 + R() * 1.1);
|
|
231
|
-
dummy.updateMatrix(); pebbles.setMatrixAt(i, dummy.matrix);
|
|
232
|
-
}
|
|
233
|
-
pebbles.castShadow = false; pebbles.receiveShadow = true;
|
|
234
|
-
group.add(pebbles);
|
|
235
|
-
|
|
236
|
-
/* --- 树木 --- */
|
|
237
|
-
const treeGeos = [treeGeometry(0), treeGeometry(1), treeGeometry(2)];
|
|
238
|
-
const treeMat = new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.95, side: THREE.FrontSide });
|
|
239
|
-
const positions = [[], [], []];
|
|
240
|
-
const rnd = mulberry32(990011);
|
|
241
|
-
for (let i = 0; i < 1350; i++) {
|
|
242
|
-
const x = (rnd() - 0.5) * 460, z = (rnd() - 0.5) * 350;
|
|
243
|
-
const dist = Math.hypot(x, z);
|
|
244
|
-
if (dist < 18 || dist > 250) continue;
|
|
245
|
-
if (blocked(x, z, 3)) continue;
|
|
246
|
-
if (rnd() < smoothstep(0, 90, dist) * 0.34) continue;
|
|
247
|
-
const nearWater = lakeDepthFactor(x + 7, z - 7) > 0.02 || Math.abs(z - 100) < 26;
|
|
248
|
-
const kind = nearWater && rnd() < 0.62 ? 2 : (rnd() < 0.26 ? 1 : 0);
|
|
249
|
-
positions[kind].push({ x, y: terrainHeight(x, z), z, s: 0.62 + rnd() * 0.55, rot: rnd() * 6.28, tint: 0.82 + rnd() * 0.36 });
|
|
250
|
-
}
|
|
251
|
-
const treeMeshes = [];
|
|
252
|
-
positions.forEach((list, k) => {
|
|
253
|
-
if (!list.length) return;
|
|
254
|
-
const mesh = new THREE.InstancedMesh(treeGeos[k], treeMat, list.length);
|
|
255
|
-
mesh.castShadow = true; mesh.receiveShadow = true;
|
|
256
|
-
list.sort(() => R() - 0.5);
|
|
257
|
-
list.forEach((p, i) => {
|
|
258
|
-
dummy.position.set(p.x, p.y, p.z);
|
|
259
|
-
dummy.rotation.set(0, p.rot, 0);
|
|
260
|
-
dummy.scale.setScalar(p.s);
|
|
261
|
-
dummy.updateMatrix(); mesh.setMatrixAt(i, dummy.matrix);
|
|
262
|
-
const tc = new THREE.Color().setRGB(p.tint, p.tint * (0.94 + R() * 0.12), p.tint * 0.93);
|
|
263
|
-
mesh.setColorAt(i, tc);
|
|
264
|
-
});
|
|
265
|
-
mesh.instanceMatrix.needsUpdate = true;
|
|
266
|
-
if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
|
|
267
|
-
mesh.userData.fullCount = list.length;
|
|
268
|
-
mesh.userData.maxCount = list.length;
|
|
269
|
-
group.add(mesh);
|
|
270
|
-
treeMeshes.push(mesh);
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
/* --- 远景林带(不投影) --- */
|
|
274
|
-
const beltGeo = beltGeometry();
|
|
275
|
-
const belt = new THREE.InstancedMesh(beltGeo, treeMat, 300);
|
|
276
|
-
for (let i = 0; i < 300; i++) {
|
|
277
|
-
const a = (i / 300) * Math.PI * 2;
|
|
278
|
-
const rad = 238 + rnd() * 34;
|
|
279
|
-
const x = Math.cos(a) * rad, z = Math.sin(a) * rad * 0.78;
|
|
280
|
-
dummy.position.set(x, terrainHeight(x, z) - 0.3, z);
|
|
281
|
-
dummy.rotation.set(0, rnd() * 6.28, 0);
|
|
282
|
-
dummy.scale.setScalar(0.72 + rnd() * 0.62);
|
|
283
|
-
dummy.updateMatrix(); belt.setMatrixAt(i, dummy.matrix);
|
|
284
|
-
belt.setColorAt(i, new THREE.Color().setRGB(0.62 + rnd() * 0.25, 0.68 + rnd() * 0.22, 0.56 + rnd() * 0.2));
|
|
285
|
-
}
|
|
286
|
-
belt.castShadow = false; belt.receiveShadow = false;
|
|
287
|
-
belt.userData.fullCount = 300; belt.userData.maxCount = 300;
|
|
288
|
-
belt.instanceMatrix.needsUpdate = true;
|
|
289
|
-
group.add(belt);
|
|
290
|
-
treeMeshes.push(belt);
|
|
291
|
-
|
|
292
|
-
/* --- 草丛 --- */
|
|
293
|
-
const blade = new THREE.PlaneGeometry(0.72, 0.82);
|
|
294
|
-
blade.translate(0, 0.41, 0);
|
|
295
|
-
const blade2 = blade.clone(); blade2.rotateY(Math.PI / 2);
|
|
296
|
-
const grassGeo = mergeGeometries([blade.toNonIndexed(), blade2.toNonIndexed()], false);
|
|
297
|
-
const grassMat = new THREE.MeshStandardMaterial({
|
|
298
|
-
map: grassTexture(), alphaTest: 0.42, side: THREE.DoubleSide,
|
|
299
|
-
roughness: 1, transparent: false, depthWrite: true, color: 0xffffff,
|
|
300
|
-
});
|
|
301
|
-
// 顶点级距离 LOD:远处草簇收缩为零面积,免去无效 overdraw 与片元开销
|
|
302
|
-
grassMat.onBeforeCompile = shader => {
|
|
303
|
-
shader.uniforms.uFadeNear = { value: 62 };
|
|
304
|
-
shader.uniforms.uFadeFar = { value: 145 };
|
|
305
|
-
shader.vertexShader = shader.vertexShader
|
|
306
|
-
.replace('#include <common>', '#include <common>\nuniform float uFadeNear;\nuniform float uFadeFar;')
|
|
307
|
-
.replace('#include <begin_vertex>', `#include <begin_vertex>
|
|
308
|
-
#ifdef USE_INSTANCING
|
|
309
|
-
vec4 grassWorld = modelMatrix * instanceMatrix * vec4(transformed, 1.0);
|
|
310
|
-
#else
|
|
311
|
-
vec4 grassWorld = modelMatrix * vec4(transformed, 1.0);
|
|
312
|
-
#endif
|
|
313
|
-
float grassD = distance(grassWorld.xz, cameraPosition.xz);
|
|
314
|
-
transformed *= 1.0 - smoothstep(uFadeNear, uFadeFar, grassD);`);
|
|
315
|
-
grassMat.userData.shader = shader;
|
|
316
|
-
};
|
|
317
|
-
const grassCount = 9000;
|
|
318
|
-
const grass = new THREE.InstancedMesh(grassGeo, grassMat, grassCount);
|
|
319
|
-
let placed = 0, guard = 0;
|
|
320
|
-
while (placed < grassCount && guard < grassCount * 6) {
|
|
321
|
-
guard++;
|
|
322
|
-
const x = (R() - 0.5) * 340, z = (R() - 0.5) * 220 + 4;
|
|
323
|
-
if (blocked(x, z, 1)) continue;
|
|
324
|
-
const h = terrainHeight(x, z);
|
|
325
|
-
if (h < -0.4) continue;
|
|
326
|
-
dummy.position.set(x, h + 0.01, z);
|
|
327
|
-
dummy.rotation.set(0, R() * 6.28, 0);
|
|
328
|
-
dummy.scale.setScalar(0.55 + R() * 0.9);
|
|
329
|
-
dummy.updateMatrix(); grass.setMatrixAt(placed, dummy.matrix);
|
|
330
|
-
const g = 0.72 + R() * 0.5;
|
|
331
|
-
grass.setColorAt(placed, new THREE.Color().setRGB(g * 0.9, g, g * 0.68));
|
|
332
|
-
placed++;
|
|
333
|
-
}
|
|
334
|
-
grass.count = placed;
|
|
335
|
-
grass.castShadow = false; grass.receiveShadow = false;
|
|
336
|
-
grass.userData.fullCount = placed; grass.userData.maxCount = placed;
|
|
337
|
-
grass.instanceMatrix.needsUpdate = true;
|
|
338
|
-
group.add(grass);
|
|
339
|
-
|
|
340
|
-
/* --- 芦苇、荷叶、莲花 --- */
|
|
341
|
-
const reedGeo = mergeGeometries([
|
|
342
|
-
new THREE.CylinderGeometry(0.025, 0.045, 2.0, 4).translate(0, 1, 0).toNonIndexed(),
|
|
343
|
-
new THREE.CylinderGeometry(0.09, 0.07, 0.42, 6).translate(0, 2.1, 0).toNonIndexed(),
|
|
344
|
-
], false);
|
|
345
|
-
const reedMat = new THREE.MeshStandardMaterial({ color: 0x7b8a4a, roughness: 1 });
|
|
346
|
-
const reeds = new THREE.InstancedMesh(reedGeo, reedMat, 420);
|
|
347
|
-
const lilyMat = new THREE.MeshStandardMaterial({ color: 0x4c7040, roughness: 0.9, side: THREE.DoubleSide });
|
|
348
|
-
const lily = new THREE.InstancedMesh(new THREE.CircleGeometry(0.62, 10), lilyMat, 220);
|
|
349
|
-
const flowerMat = new THREE.MeshStandardMaterial({ color: 0xe8b7c2, roughness: 0.75 });
|
|
350
|
-
const flowers = new THREE.InstancedMesh(new THREE.IcosahedronGeometry(0.24, 0), flowerMat, 90);
|
|
351
|
-
let ri = 0, li = 0, fi = 0, rg = 0;
|
|
352
|
-
while ((ri < 420 || li < 220) && rg < 9000) {
|
|
353
|
-
rg++;
|
|
354
|
-
const a = R() * Math.PI * 2;
|
|
355
|
-
const edge = lakeShoreAngle(a) * (0.72 + R() * 0.32);
|
|
356
|
-
const x = LAKE_C[0] + Math.cos(a) * LAKE_R[0] * edge;
|
|
357
|
-
const z = LAKE_C[1] + Math.sin(a) * LAKE_R[1] * edge;
|
|
358
|
-
if (R() < 0.55 && ri < 420) {
|
|
359
|
-
dummy.position.set(x, -0.5, z); dummy.rotation.set((R() - 0.5) * 0.2, R() * 6.28, (R() - 0.5) * 0.2);
|
|
360
|
-
dummy.scale.setScalar(0.6 + R() * 0.75); dummy.updateMatrix(); reeds.setMatrixAt(ri++, dummy.matrix);
|
|
361
|
-
} else if (li < 220) {
|
|
362
|
-
dummy.position.set(x + (R() - 0.5) * 5, -0.52 + R() * 0.04, z + (R() - 0.5) * 4);
|
|
363
|
-
dummy.rotation.set(-Math.PI / 2, 0, R() * 6.28);
|
|
364
|
-
dummy.scale.setScalar(0.6 + R() * 0.7); dummy.updateMatrix(); lily.setMatrixAt(li++, dummy.matrix);
|
|
365
|
-
if (fi < 90 && R() < 0.42) {
|
|
366
|
-
dummy.position.y += 0.18; dummy.rotation.set(0, R() * 6.28, 0);
|
|
367
|
-
dummy.scale.setScalar(0.7 + R() * 0.8); dummy.updateMatrix(); flowers.setMatrixAt(fi++, dummy.matrix);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
reeds.count = ri; lily.count = li; flowers.count = fi;
|
|
372
|
-
[reeds, lily, flowers].forEach(m => { m.instanceMatrix.needsUpdate = true; m.castShadow = false; group.add(m); });
|
|
373
|
-
|
|
374
|
-
/* --- 散落残石与倾倒柱身 --- */
|
|
375
|
-
const rub = ctx.rubble;
|
|
376
|
-
const rubble = new THREE.InstancedMesh(chamferBoxGeo(1, 1, 1, 0.06), M.stone, rub.length);
|
|
377
|
-
rub.forEach((p, i) => {
|
|
378
|
-
dummy.position.set(p.pos[0], terrainHeight(p.pos[0], p.pos[2]) + p.s * 0.28, p.pos[2]);
|
|
379
|
-
dummy.rotation.set((R() - 0.5) * 0.7, p.rot, (R() - 0.5) * 0.7);
|
|
380
|
-
dummy.scale.set(p.s * (1 + R() * 0.7), p.s * (0.4 + R() * 0.5), p.s * (0.7 + R() * 0.6));
|
|
381
|
-
dummy.updateMatrix(); rubble.setMatrixAt(i, dummy.matrix);
|
|
382
|
-
});
|
|
383
|
-
rubble.castShadow = true; rubble.receiveShadow = true;
|
|
384
|
-
rubble.instanceMatrix.needsUpdate = true;
|
|
385
|
-
group.add(rubble);
|
|
386
|
-
const drums = new THREE.InstancedMesh(new THREE.CylinderGeometry(0.52, 0.52, 1.5, 14), M.marbleD, 26);
|
|
387
|
-
for (let i = 0; i < 26; i++) {
|
|
388
|
-
const nearHai = i < 13;
|
|
389
|
-
const a = R() * 6.28, rad = 12 + R() * 18;
|
|
390
|
-
const x = (nearHai ? -72 : 40) + Math.cos(a) * rad;
|
|
391
|
-
const z = (nearHai ? 8 : -2) + Math.sin(a) * rad * 0.6;
|
|
392
|
-
dummy.position.set(x, terrainHeight(x, z) + 0.5, z);
|
|
393
|
-
dummy.rotation.set(Math.PI / 2 + (R() - 0.5) * 0.35, R() * 6.28, R() * 0.5);
|
|
394
|
-
dummy.scale.setScalar(0.75 + R() * 0.5);
|
|
395
|
-
dummy.updateMatrix(); drums.setMatrixAt(i, dummy.matrix);
|
|
396
|
-
}
|
|
397
|
-
drums.castShadow = true; drums.receiveShadow = true;
|
|
398
|
-
drums.instanceMatrix.needsUpdate = true;
|
|
399
|
-
group.add(drums);
|
|
400
|
-
|
|
401
|
-
/* --- 湖畔石桥 --- */
|
|
402
|
-
const bridge = new THREE.Group();
|
|
403
|
-
const stone = M.marbleD;
|
|
404
|
-
for (let i = 0; i < 9; i++) {
|
|
405
|
-
const bx = 62 + i * 3.1;
|
|
406
|
-
const arch = Math.sin((i / 8) * Math.PI) * 1.4;
|
|
407
|
-
const seg = new THREE.Mesh(boxGeoProxy(3.2, 0.32, 3.4), stone);
|
|
408
|
-
seg.position.set(bx, -0.1 + arch, 92);
|
|
409
|
-
seg.castShadow = true; seg.receiveShadow = true;
|
|
410
|
-
bridge.add(seg);
|
|
411
|
-
}
|
|
412
|
-
for (const s of [-1, 1]) for (let i = 0; i < 9; i++) {
|
|
413
|
-
const rail = new THREE.Mesh(boxGeoProxy(3.2, 0.12, 0.18), stone);
|
|
414
|
-
rail.position.set(62 + i * 3.1, 0.65 + Math.sin((i / 8) * Math.PI) * 1.4, 92 + s * 1.7);
|
|
415
|
-
bridge.add(rail);
|
|
416
|
-
const post = new THREE.Mesh(boxGeoProxy(0.22, 0.72, 0.22), stone);
|
|
417
|
-
post.position.set(62 + i * 3.1, 0.5 + Math.sin((i / 8) * Math.PI) * 1.4, 92 + s * 1.7);
|
|
418
|
-
bridge.add(post);
|
|
419
|
-
}
|
|
420
|
-
group.add(bridge);
|
|
421
|
-
|
|
422
|
-
return {
|
|
423
|
-
group, ground, treeMeshes, grass, reeds, lily, flowers, pebbles,
|
|
424
|
-
applyQuality(q) {
|
|
425
|
-
treeMeshes.forEach(m => { m.count = Math.max(1, Math.floor(m.userData.maxCount * q.trees)); });
|
|
426
|
-
grass.count = Math.min(grass.userData.maxCount, q.grass);
|
|
427
|
-
const sh = grassMat.userData.shader;
|
|
428
|
-
if (sh) { sh.uniforms.uFadeNear.value = q.fadeFar * 0.42; sh.uniforms.uFadeFar.value = q.fadeFar; }
|
|
429
|
-
groundMat.map.anisotropy = q.aniso;
|
|
430
|
-
groundMat.map.needsUpdate = true;
|
|
431
|
-
},
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
function boxGeoProxy(w, h, d) { return new THREE.BoxGeometry(w, h, d); }
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/* 天空、云层、黄金时刻日照与大气雾 */
|
|
2
|
-
import * as THREE from 'three';
|
|
3
|
-
|
|
4
|
-
const SKY_VERT = `
|
|
5
|
-
varying vec3 vDir;
|
|
6
|
-
void main() {
|
|
7
|
-
vDir = normalize(position);
|
|
8
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
9
|
-
}`;
|
|
10
|
-
|
|
11
|
-
const SKY_FRAG = `
|
|
12
|
-
precision highp float;
|
|
13
|
-
varying vec3 vDir;
|
|
14
|
-
uniform vec3 uSunDir;
|
|
15
|
-
uniform vec3 uSunColor;
|
|
16
|
-
uniform vec3 uZenith;
|
|
17
|
-
uniform vec3 uHorizon;
|
|
18
|
-
uniform float uTime;
|
|
19
|
-
uniform float uHaze;
|
|
20
|
-
|
|
21
|
-
float hash(vec2 p){ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123); }
|
|
22
|
-
float noise(vec2 p){
|
|
23
|
-
vec2 i = floor(p), f = fract(p);
|
|
24
|
-
vec2 u = f*f*(3.0-2.0*f);
|
|
25
|
-
return mix(mix(hash(i), hash(i+vec2(1.0,0.0)), u.x),
|
|
26
|
-
mix(hash(i+vec2(0.0,1.0)), hash(i+vec2(1.0,1.0)), u.x), u.y);
|
|
27
|
-
}
|
|
28
|
-
float fbm(vec2 p){
|
|
29
|
-
float v = 0.0, a = 0.5;
|
|
30
|
-
for(int i=0;i<5;i++){ v += a*noise(p); p *= 2.03; a *= 0.5; }
|
|
31
|
-
return v;
|
|
32
|
-
}
|
|
33
|
-
void main() {
|
|
34
|
-
vec3 d = normalize(vDir);
|
|
35
|
-
float h = max(d.y, 0.0);
|
|
36
|
-
vec3 col = mix(uHorizon, uZenith, pow(h, 0.62));
|
|
37
|
-
// 地平线暖色带与大气散射
|
|
38
|
-
float glowBand = exp(-h * 9.0);
|
|
39
|
-
col = mix(col, uHorizon * 1.06, glowBand * 0.55);
|
|
40
|
-
float sd = max(dot(d, normalize(uSunDir)), 0.0);
|
|
41
|
-
col += uSunColor * pow(sd, 7.0) * 0.22 * uHaze;
|
|
42
|
-
col += uSunColor * pow(sd, 130.0) * 0.85;
|
|
43
|
-
col += uSunColor * pow(sd, 2600.0) * 7.0;
|
|
44
|
-
// 卷积云:以方向投影到云层平面
|
|
45
|
-
vec2 cp = d.xz / max(d.y + 0.14, 0.05);
|
|
46
|
-
float n = fbm(cp * 0.20 + vec2(uTime * 0.0025, uTime * 0.0012));
|
|
47
|
-
float n2 = fbm(cp * 0.62 + vec2(-uTime * 0.003, 0.0));
|
|
48
|
-
float cloud = smoothstep(0.48, 0.68, n * 0.78 + n2 * 0.22) * smoothstep(-0.01, 0.10, h);
|
|
49
|
-
vec3 cloudCol = mix(uHorizon * 1.02, vec3(1.0, 0.97, 0.92), 0.35 + pow(sd, 4.0) * 0.5);
|
|
50
|
-
col = mix(col, cloudCol, cloud * 0.55);
|
|
51
|
-
// 贴地薄雾
|
|
52
|
-
col = mix(col, uHorizon, exp(-max(d.y, -0.05) * 22.0) * 0.32);
|
|
53
|
-
gl_FragColor = vec4(col, 1.0);
|
|
54
|
-
#include <tonemapping_fragment>
|
|
55
|
-
#include <colorspace_fragment>
|
|
56
|
-
}`;
|
|
57
|
-
|
|
58
|
-
const KEYS = [
|
|
59
|
-
{ h: 5.5, zen: '#3c5480', hor: '#d99a76', sun: '#ff9a5e', inten: 0.5, expo: 0.78, hemi: 0.35 },
|
|
60
|
-
{ h: 8, zen: '#4a7db5', hor: '#ddc6a6', sun: '#ffd9a3', inten: 2.7, expo: 1.02, hemi: 0.56 },
|
|
61
|
-
{ h: 12, zen: '#3974bb', hor: '#c6dbe9', sun: '#fff4e2', inten: 3.8, expo: 1.08, hemi: 0.70 },
|
|
62
|
-
{ h: 16.4, zen: '#4d79ab', hor: '#d7b18c', sun: '#ffcf94', inten: 3.5, expo: 1.16, hemi: 0.60 },
|
|
63
|
-
{ h: 18.3, zen: '#3f5482', hor: '#d98b69', sun: '#ff945c', inten: 1.15, expo: 0.98, hemi: 0.42 },
|
|
64
|
-
{ h: 19.6, zen: '#222f55', hor: '#7d5a68', sun: '#ff7b52', inten: 0.22, expo: 0.85, hemi: 0.28 },
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
const c = hex => new THREE.Color(hex);
|
|
68
|
-
|
|
69
|
-
export function createSky(scene, renderer) {
|
|
70
|
-
const uniforms = {
|
|
71
|
-
uSunDir: { value: new THREE.Vector3(-0.6, 0.4, 0.5) },
|
|
72
|
-
uSunColor: { value: c('#ffc78a') },
|
|
73
|
-
uZenith: { value: c('#6287b4') },
|
|
74
|
-
uHorizon: { value: c('#e9bd8b') },
|
|
75
|
-
uTime: { value: 0 },
|
|
76
|
-
uHaze: { value: 1 },
|
|
77
|
-
};
|
|
78
|
-
const sky = new THREE.Mesh(
|
|
79
|
-
new THREE.SphereGeometry(1400, 40, 22),
|
|
80
|
-
new THREE.ShaderMaterial({
|
|
81
|
-
uniforms, vertexShader: SKY_VERT, fragmentShader: SKY_FRAG,
|
|
82
|
-
side: THREE.BackSide, depthWrite: false, fog: false,
|
|
83
|
-
})
|
|
84
|
-
);
|
|
85
|
-
sky.renderOrder = -1000;
|
|
86
|
-
sky.frustumCulled = false;
|
|
87
|
-
scene.add(sky);
|
|
88
|
-
|
|
89
|
-
const sun = new THREE.DirectionalLight(0xffc78a, 3.05);
|
|
90
|
-
sun.castShadow = true;
|
|
91
|
-
sun.shadow.mapSize.set(4096, 4096);
|
|
92
|
-
const sc = sun.shadow.camera;
|
|
93
|
-
sc.left = -125; sc.right = 125; sc.top = 125; sc.bottom = -125;
|
|
94
|
-
sc.near = 1; sc.far = 520;
|
|
95
|
-
sun.shadow.bias = -0.00035;
|
|
96
|
-
sun.shadow.normalBias = 0.035;
|
|
97
|
-
sun.shadow.radius = 2.2;
|
|
98
|
-
sun.target.position.set(-10, 0, 0);
|
|
99
|
-
scene.add(sun, sun.target);
|
|
100
|
-
|
|
101
|
-
const hemi = new THREE.HemisphereLight(0xbdd6ea, 0x9a8160, 0.66);
|
|
102
|
-
scene.add(hemi);
|
|
103
|
-
// 微弱环境光托起背光立面的暗部,避免深阴影形成纯黑块
|
|
104
|
-
const ambient = new THREE.AmbientLight(0xc9d4dd, 0.42);
|
|
105
|
-
scene.add(ambient);
|
|
106
|
-
const fill = new THREE.DirectionalLight(0x9dbcd8, 0.55);
|
|
107
|
-
fill.position.set(90, 70, -100);
|
|
108
|
-
scene.add(fill);
|
|
109
|
-
|
|
110
|
-
const fog = new THREE.FogExp2(0xd8c4ac, 0.00155);
|
|
111
|
-
scene.fog = fog;
|
|
112
|
-
|
|
113
|
-
const lamps = [];
|
|
114
|
-
[[-72, 6, 12], [40, 4, 6], [40, 6, -28], [-138, 5, 12]].forEach(([x, y, z]) => {
|
|
115
|
-
const p = new THREE.PointLight(0xffb56b, 0, 26, 2);
|
|
116
|
-
p.position.set(x, y, z);
|
|
117
|
-
scene.add(p);
|
|
118
|
-
lamps.push(p);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const api = {
|
|
122
|
-
uniforms, sun, hemi, fill, fog, sky, lamps,
|
|
123
|
-
sunDir: new THREE.Vector3(),
|
|
124
|
-
setHour(hour) {
|
|
125
|
-
const t = Math.min(Math.max(hour, KEYS[0].h), KEYS[KEYS.length - 1].h);
|
|
126
|
-
let i = 0;
|
|
127
|
-
while (i < KEYS.length - 2 && t > KEYS[i + 1].h) i++;
|
|
128
|
-
const a = KEYS[i], b = KEYS[i + 1];
|
|
129
|
-
const k = (t - a.h) / (b.h - a.h);
|
|
130
|
-
const lerpC = (ca, cb) => c(ca).lerp(c(cb), k);
|
|
131
|
-
const zen = lerpC(a.zen, b.zen), hor = lerpC(a.hor, b.hor), sunC = lerpC(a.sun, b.sun);
|
|
132
|
-
uniforms.uZenith.value.copy(zen);
|
|
133
|
-
uniforms.uHorizon.value.copy(hor);
|
|
134
|
-
uniforms.uSunColor.value.copy(sunC);
|
|
135
|
-
const p = (t - 6) / 12;
|
|
136
|
-
const elev = Math.sin(Math.max(0, Math.min(1, p)) * Math.PI) * 0.86 + 0.045;
|
|
137
|
-
const az = Math.PI * (0.12 + Math.max(0, Math.min(1, p)) * 0.74);
|
|
138
|
-
const dir = new THREE.Vector3(Math.cos(az), elev, Math.sin(az) * 0.72).normalize();
|
|
139
|
-
api.sunDir.copy(dir);
|
|
140
|
-
uniforms.uSunDir.value.copy(dir);
|
|
141
|
-
sun.position.copy(dir).multiplyScalar(210);
|
|
142
|
-
sun.target.position.set(-10, 0, 0);
|
|
143
|
-
sun.color.copy(sunC);
|
|
144
|
-
sun.intensity = THREE.MathUtils.lerp(a.inten, b.inten, k);
|
|
145
|
-
hemi.intensity = THREE.MathUtils.lerp(a.hemi, b.hemi, k);
|
|
146
|
-
hemi.color.copy(zen).lerp(c('#dce9f2'), 0.45);
|
|
147
|
-
fill.intensity = 0.46 + (1 - elev) * 0.38;
|
|
148
|
-
renderer.toneMappingExposure = THREE.MathUtils.lerp(a.expo, b.expo, k);
|
|
149
|
-
fog.color.copy(hor).lerp(zen, 0.24);
|
|
150
|
-
fog.density = 0.00092 + (1 - elev) * 0.00048;
|
|
151
|
-
uniforms.uHaze.value = 0.55 + (1 - elev) * 0.85;
|
|
152
|
-
const dusk = THREE.MathUtils.clamp((18.1 - t) / 2.2, 0, 1) * THREE.MathUtils.clamp((t - 16.8) / 1.6, 0, 1);
|
|
153
|
-
lamps.forEach(l => { l.intensity = dusk * 16; });
|
|
154
|
-
api.dusk = dusk;
|
|
155
|
-
renderer.shadowMap.needsUpdate = true;
|
|
156
|
-
},
|
|
157
|
-
setShadowSize(size) {
|
|
158
|
-
if (sun.shadow.mapSize.x === size) return;
|
|
159
|
-
sun.shadow.mapSize.set(size, size);
|
|
160
|
-
if (sun.shadow.map) { sun.shadow.map.dispose(); sun.shadow.map = null; }
|
|
161
|
-
renderer.shadowMap.needsUpdate = true;
|
|
162
|
-
},
|
|
163
|
-
update(dt, camera) {
|
|
164
|
-
uniforms.uTime.value += dt;
|
|
165
|
-
sky.position.copy(camera.position);
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
return api;
|
|
169
|
-
}
|