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,1042 @@
|
|
|
1
|
+
import { n as disposeObject3D } from "./disposeObject3D-DIMzy0FA.js";
|
|
2
|
+
import { t as PRESENTATION_HDRI_PRESETS } from "./ScenePresentation-LsYiDxbm.js";
|
|
3
|
+
import { n as resolveStylePack } from "./StylePack-DcRa_kU0.js";
|
|
4
|
+
import * as THREE from "three";
|
|
5
|
+
import { WebGLRenderer } from "three";
|
|
6
|
+
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
7
|
+
import { HDRLoader } from "three/examples/jsm/loaders/HDRLoader.js";
|
|
8
|
+
import { RenderPipeline, WebGPURenderer } from "three/webgpu";
|
|
9
|
+
import { mrt, normalView, output, pass, renderOutput, vec3, vec4 } from "three/tsl";
|
|
10
|
+
import { bloom } from "three/examples/jsm/tsl/display/BloomNode.js";
|
|
11
|
+
import { fxaa } from "three/examples/jsm/tsl/display/FXAANode.js";
|
|
12
|
+
import { ao } from "three/examples/jsm/tsl/display/GTAONode.js";
|
|
13
|
+
// modules/rendering/captureStill.js
|
|
14
|
+
/** A bounded raster still rendered in an isolated WebGL context, not a
|
|
15
|
+
* viewport screenshot. The scene's authoritative camera and shadow maps stay
|
|
16
|
+
* owned by the live renderer. This is not a path tracer. */
|
|
17
|
+
async function captureStill({ scene, camera, decoration, excludedRoot, exposure = 1, longEdge = 1920 }) {
|
|
18
|
+
if (![1920, 3840].includes(longEdge) || !camera?.isPerspectiveCamera) throw new Error("STILL_OPTIONS_INVALID");
|
|
19
|
+
const aspect = camera.aspect;
|
|
20
|
+
if (!Number.isFinite(aspect) || aspect <= 0 || aspect > 10) throw new Error("STILL_CAMERA_ASPECT_INVALID");
|
|
21
|
+
const width = Math.max(1, Math.round(aspect >= 1 ? longEdge : longEdge * aspect));
|
|
22
|
+
const height = Math.max(1, Math.round(aspect >= 1 ? longEdge / aspect : longEdge));
|
|
23
|
+
if (width * height > 16e6) throw new Error("STILL_PIXEL_LIMIT");
|
|
24
|
+
const shadows = [];
|
|
25
|
+
scene.traverse((node) => {
|
|
26
|
+
if ([].concat(node.material || []).some((material) => material?.isNodeMaterial)) throw new Error("STILL_NODE_MATERIAL_UNSUPPORTED");
|
|
27
|
+
if (node.isLight && node.shadow) shadows.push([node, node.shadow]);
|
|
28
|
+
});
|
|
29
|
+
const shadowWeight = shadows.reduce((sum, [light]) => sum + (light.castShadow ? light.isPointLight ? 8 : 1 : 0), 0);
|
|
30
|
+
const shadowSize = shadowWeight > 8 ? 512 : shadowWeight > 2 ? 1024 : 2048;
|
|
31
|
+
const renderer = new THREE.WebGLRenderer({
|
|
32
|
+
antialias: true,
|
|
33
|
+
preserveDrawingBuffer: true
|
|
34
|
+
});
|
|
35
|
+
const shot = camera.clone();
|
|
36
|
+
shot.aspect = width / height;
|
|
37
|
+
shot.updateProjectionMatrix();
|
|
38
|
+
const visible = decoration?.visible;
|
|
39
|
+
const excludedVisible = excludedRoot?.visible;
|
|
40
|
+
let restoreNeeded = false;
|
|
41
|
+
const restore = () => {
|
|
42
|
+
if (!restoreNeeded) return;
|
|
43
|
+
restoreNeeded = false;
|
|
44
|
+
if (decoration) decoration.visible = visible;
|
|
45
|
+
if (excludedRoot) excludedRoot.visible = excludedVisible;
|
|
46
|
+
for (const [light, shadow] of shadows) {
|
|
47
|
+
if (light.shadow !== shadow) light.shadow.dispose();
|
|
48
|
+
light.shadow = shadow;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
try {
|
|
52
|
+
renderer.setPixelRatio(1);
|
|
53
|
+
renderer.setSize(width, height, false);
|
|
54
|
+
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
55
|
+
renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
|
56
|
+
renderer.toneMappingExposure = exposure;
|
|
57
|
+
renderer.shadowMap.enabled = true;
|
|
58
|
+
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
|
59
|
+
if (width > renderer.capabilities.maxTextureSize || height > renderer.capabilities.maxTextureSize) throw new Error("STILL_GPU_LIMIT");
|
|
60
|
+
restoreNeeded = true;
|
|
61
|
+
if (decoration) decoration.visible = false;
|
|
62
|
+
if (excludedRoot) excludedRoot.visible = false;
|
|
63
|
+
for (const [light, shadow] of shadows) {
|
|
64
|
+
light.shadow = shadow.clone();
|
|
65
|
+
if (light.castShadow) {
|
|
66
|
+
const size = light.isPointLight ? Math.min(512, shadowSize) : shadowSize;
|
|
67
|
+
light.shadow.mapSize.set(size, size);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
renderer.render(scene, shot);
|
|
72
|
+
} finally {
|
|
73
|
+
restore();
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
blob: await new Promise((resolve, reject) => renderer.domElement.toBlob((value) => value ? resolve(value) : reject(/* @__PURE__ */ new Error("STILL_ENCODE_FAILED")), "image/png")),
|
|
77
|
+
width,
|
|
78
|
+
height
|
|
79
|
+
};
|
|
80
|
+
} finally {
|
|
81
|
+
restore();
|
|
82
|
+
renderer.dispose();
|
|
83
|
+
renderer.forceContextLoss();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// modules/rendering/createRenderer.js
|
|
87
|
+
const RENDERER_MODE = Object.freeze({
|
|
88
|
+
AUTO: "auto",
|
|
89
|
+
WEBGPU: "webgpu",
|
|
90
|
+
WEBGL2: "webgl2",
|
|
91
|
+
WEBGL_LEGACY: "webgl-legacy"
|
|
92
|
+
});
|
|
93
|
+
const VALID_MODES = new Set(Object.values(RENDERER_MODE));
|
|
94
|
+
function normalizeRendererMode(value = RENDERER_MODE.AUTO) {
|
|
95
|
+
const text = String(value ?? "").trim().toLowerCase();
|
|
96
|
+
const mode = text === "" ? RENDERER_MODE.AUTO : text === "webgl" ? RENDERER_MODE.WEBGL2 : text;
|
|
97
|
+
if (!VALID_MODES.has(mode)) {
|
|
98
|
+
const error = /* @__PURE__ */ new RangeError(`Unsupported renderer mode: ${value}`);
|
|
99
|
+
error.code = "RENDERER_MODE_INVALID";
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
return mode;
|
|
103
|
+
}
|
|
104
|
+
function rendererBackend(renderer) {
|
|
105
|
+
if (renderer?.backend?.isWebGPUBackend === true) return RENDERER_MODE.WEBGPU;
|
|
106
|
+
if (renderer?.backend?.isWebGLBackend === true || renderer?.isWebGLRenderer === true) return RENDERER_MODE.WEBGL2;
|
|
107
|
+
return "unknown";
|
|
108
|
+
}
|
|
109
|
+
function rendererDiagnostics(renderer, requestedMode = RENDERER_MODE.AUTO) {
|
|
110
|
+
const mode = normalizeRendererMode(requestedMode);
|
|
111
|
+
const backend = rendererBackend(renderer);
|
|
112
|
+
return Object.freeze({
|
|
113
|
+
renderer: renderer?.isWebGPURenderer === true ? "WebGPURenderer" : renderer?.constructor?.name || "unknown",
|
|
114
|
+
requestedMode: mode,
|
|
115
|
+
backend,
|
|
116
|
+
fallback: mode === RENDERER_MODE.AUTO && backend === RENDERER_MODE.WEBGL2
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async function createRenderer({ mode = RENDERER_MODE.AUTO, antialias = true, alpha = false, trackTimestamp = false, RendererClass = WebGPURenderer } = {}) {
|
|
120
|
+
const requestedMode = normalizeRendererMode(mode);
|
|
121
|
+
const renderer = new (requestedMode === RENDERER_MODE.WEBGL_LEGACY ? WebGLRenderer : RendererClass)({
|
|
122
|
+
antialias: Boolean(antialias),
|
|
123
|
+
alpha: Boolean(alpha),
|
|
124
|
+
trackTimestamp: Boolean(trackTimestamp),
|
|
125
|
+
forceWebGL: requestedMode === RENDERER_MODE.WEBGL2
|
|
126
|
+
});
|
|
127
|
+
await renderer.init?.();
|
|
128
|
+
const info = rendererDiagnostics(renderer, requestedMode);
|
|
129
|
+
if (info.backend === "unknown") {
|
|
130
|
+
renderer.dispose?.();
|
|
131
|
+
const error = /* @__PURE__ */ new Error("Renderer initialized without a recognized WebGPU/WebGL2 backend");
|
|
132
|
+
error.code = "RENDERER_BACKEND_UNKNOWN";
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
if (requestedMode === RENDERER_MODE.WEBGPU && info.backend !== RENDERER_MODE.WEBGPU) {
|
|
136
|
+
renderer.dispose?.();
|
|
137
|
+
const error = /* @__PURE__ */ new Error("WebGPU renderer mode was required but Three.js fell back to WebGL2");
|
|
138
|
+
error.code = "RENDERER_WEBGPU_REQUIRED";
|
|
139
|
+
error.backend = info.backend;
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
renderer,
|
|
144
|
+
info
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// modules/rendering/RendererProbe.js
|
|
148
|
+
const WEBGPU_LIMIT_KEYS = Object.freeze([
|
|
149
|
+
"maxTextureDimension2D",
|
|
150
|
+
"maxBindGroups",
|
|
151
|
+
"maxBufferSize",
|
|
152
|
+
"maxUniformBufferBindingSize",
|
|
153
|
+
"maxStorageBufferBindingSize",
|
|
154
|
+
"maxComputeWorkgroupStorageSize",
|
|
155
|
+
"maxComputeInvocationsPerWorkgroup",
|
|
156
|
+
"maxStorageBuffersPerShaderStage",
|
|
157
|
+
"maxComputeWorkgroupSizeX",
|
|
158
|
+
"maxComputeWorkgroupSizeY",
|
|
159
|
+
"maxComputeWorkgroupSizeZ",
|
|
160
|
+
"maxComputeWorkgroupsPerDimension"
|
|
161
|
+
]);
|
|
162
|
+
const scalar = (value) => typeof value === "bigint" ? value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : value.toString() : value;
|
|
163
|
+
function deviceDiagnostics(renderer) {
|
|
164
|
+
const backend = renderer?.backend;
|
|
165
|
+
if (backend?.isWebGPUBackend !== true) return {
|
|
166
|
+
compatibilityMode: null,
|
|
167
|
+
timestampSupported: Boolean(backend?.disjoint),
|
|
168
|
+
features: [],
|
|
169
|
+
limits: {}
|
|
170
|
+
};
|
|
171
|
+
const device = backend.device;
|
|
172
|
+
const limits = {};
|
|
173
|
+
for (const key of WEBGPU_LIMIT_KEYS) {
|
|
174
|
+
const value = device?.limits?.[key];
|
|
175
|
+
if (value != null) limits[key] = scalar(value);
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
compatibilityMode: backend.compatibilityMode === true,
|
|
179
|
+
timestampSupported: Boolean(device?.features?.has?.("timestamp-query")),
|
|
180
|
+
features: device?.features ? [...device.features].map(String).sort() : [],
|
|
181
|
+
limits
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
var RendererProbe = class {
|
|
185
|
+
constructor(renderer, { requestedMode = "auto", timingIntervalMs = 1e3, onDeviceLost = null, onError = null } = {}) {
|
|
186
|
+
if (!renderer) throw new TypeError("RendererProbe requires a renderer");
|
|
187
|
+
this.renderer = renderer;
|
|
188
|
+
this.info = rendererDiagnostics(renderer, requestedMode);
|
|
189
|
+
this.device = deviceDiagnostics(renderer);
|
|
190
|
+
this.health = "ready";
|
|
191
|
+
this.lastError = null;
|
|
192
|
+
this.gpuTimeMs = null;
|
|
193
|
+
this.frameIntervals = [];
|
|
194
|
+
this.lastFrameAt = null;
|
|
195
|
+
this.renderCpuMs = [];
|
|
196
|
+
this.timingIntervalMs = Math.max(250, Number(timingIntervalMs) || 1e3);
|
|
197
|
+
this.nextTimingAt = 0;
|
|
198
|
+
this.timingPromise = null;
|
|
199
|
+
this.onDeviceLost = typeof onDeviceLost === "function" ? onDeviceLost : null;
|
|
200
|
+
this.onError = typeof onError === "function" ? onError : null;
|
|
201
|
+
this.previousDeviceLost = renderer.onDeviceLost;
|
|
202
|
+
this.previousError = renderer.onError;
|
|
203
|
+
renderer.onDeviceLost = (detail) => {
|
|
204
|
+
this.previousDeviceLost?.call(renderer, detail);
|
|
205
|
+
this.health = "lost";
|
|
206
|
+
this.lastError = normalizeRendererError(detail, "device-lost");
|
|
207
|
+
this.onDeviceLost?.(this.lastError);
|
|
208
|
+
};
|
|
209
|
+
renderer.onError = (detail) => {
|
|
210
|
+
this.previousError?.call(renderer, detail);
|
|
211
|
+
if (this.health !== "lost") this.health = "degraded";
|
|
212
|
+
this.lastError = normalizeRendererError(detail, "backend-error");
|
|
213
|
+
this.onError?.(this.lastError);
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
afterRender(timestamp = 0, renderCpuMs = null) {
|
|
217
|
+
if (Number.isFinite(timestamp)) {
|
|
218
|
+
const interval = this.lastFrameAt == null ? null : timestamp - this.lastFrameAt;
|
|
219
|
+
if (interval > 1e3) {
|
|
220
|
+
this.frameIntervals.length = 0;
|
|
221
|
+
this.renderCpuMs.length = 0;
|
|
222
|
+
} else if (interval > 0) pushSample(this.frameIntervals, interval);
|
|
223
|
+
this.lastFrameAt = timestamp;
|
|
224
|
+
}
|
|
225
|
+
if (Number.isFinite(renderCpuMs) && renderCpuMs >= 0) pushSample(this.renderCpuMs, renderCpuMs);
|
|
226
|
+
if (!this.renderer?.backend?.trackTimestamp || this.health === "lost") return;
|
|
227
|
+
if (this.timingPromise || timestamp < this.nextTimingAt) return;
|
|
228
|
+
this.nextTimingAt = timestamp + this.timingIntervalMs;
|
|
229
|
+
this.timingPromise = Promise.resolve(this.renderer.resolveTimestampsAsync?.("render")).then((value) => {
|
|
230
|
+
if (Number.isFinite(value)) this.gpuTimeMs = value;
|
|
231
|
+
}).catch((error) => {
|
|
232
|
+
this.lastError = normalizeRendererError(error, "timestamp-error");
|
|
233
|
+
}).finally(() => {
|
|
234
|
+
this.timingPromise = null;
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
snapshot() {
|
|
238
|
+
return Object.freeze({
|
|
239
|
+
...this.info,
|
|
240
|
+
health: this.health,
|
|
241
|
+
gpuTiming: Boolean(this.renderer?.backend?.trackTimestamp),
|
|
242
|
+
gpuTimeMs: this.gpuTimeMs,
|
|
243
|
+
frameIntervalMs: percentiles(this.frameIntervals),
|
|
244
|
+
renderCpuMs: percentiles(this.renderCpuMs),
|
|
245
|
+
workload: {
|
|
246
|
+
drawCalls: this.renderer?.info?.render?.drawCalls ?? this.renderer?.info?.render?.calls ?? null,
|
|
247
|
+
triangles: this.renderer?.info?.render?.triangles ?? null,
|
|
248
|
+
geometries: this.renderer?.info?.memory?.geometries ?? null,
|
|
249
|
+
textures: this.renderer?.info?.memory?.textures ?? null
|
|
250
|
+
},
|
|
251
|
+
compatibilityMode: this.device.compatibilityMode,
|
|
252
|
+
timestampSupported: this.device.timestampSupported,
|
|
253
|
+
features: [...this.device.features],
|
|
254
|
+
limits: { ...this.device.limits },
|
|
255
|
+
lastError: this.lastError ? { ...this.lastError } : null
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
dispose() {
|
|
259
|
+
if (!this.renderer) return;
|
|
260
|
+
this.renderer.onDeviceLost = this.previousDeviceLost;
|
|
261
|
+
this.renderer.onError = this.previousError;
|
|
262
|
+
this.renderer = null;
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
function pushSample(samples, value) {
|
|
266
|
+
if (samples.length === 240) samples.shift();
|
|
267
|
+
samples.push(value);
|
|
268
|
+
}
|
|
269
|
+
function percentiles(samples) {
|
|
270
|
+
if (!samples.length) return {
|
|
271
|
+
samples: 0,
|
|
272
|
+
p50: null,
|
|
273
|
+
p95: null
|
|
274
|
+
};
|
|
275
|
+
const sorted = [...samples].sort((a, b) => a - b);
|
|
276
|
+
return {
|
|
277
|
+
samples: sorted.length,
|
|
278
|
+
p50: sorted[Math.ceil(sorted.length * .5) - 1],
|
|
279
|
+
p95: sorted[Math.ceil(sorted.length * .95) - 1]
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function normalizeRendererError(detail, fallbackType) {
|
|
283
|
+
return Object.freeze({
|
|
284
|
+
type: String(detail?.type || fallbackType),
|
|
285
|
+
api: detail?.api ? String(detail.api) : null,
|
|
286
|
+
reason: detail?.reason ? String(detail.reason) : null,
|
|
287
|
+
message: String(detail?.message || detail?.error?.message || detail || "Unknown renderer error")
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
// modules/rendering/WebGpuPostFxPipeline.js
|
|
291
|
+
const DEFAULT_OPTIONS = Object.freeze({
|
|
292
|
+
ao: Object.freeze({
|
|
293
|
+
enabled: true,
|
|
294
|
+
resolutionScale: .5,
|
|
295
|
+
radius: .45,
|
|
296
|
+
thickness: 1,
|
|
297
|
+
distanceExponent: 1,
|
|
298
|
+
distanceFallOff: 1,
|
|
299
|
+
scale: 1,
|
|
300
|
+
samples: 12
|
|
301
|
+
}),
|
|
302
|
+
bloom: Object.freeze({
|
|
303
|
+
enabled: true,
|
|
304
|
+
strength: .18,
|
|
305
|
+
radius: .25,
|
|
306
|
+
threshold: 1.05
|
|
307
|
+
}),
|
|
308
|
+
fxaa: Object.freeze({ enabled: true })
|
|
309
|
+
});
|
|
310
|
+
const effectOptions = (defaults, value) => {
|
|
311
|
+
if (value === false) return {
|
|
312
|
+
...defaults,
|
|
313
|
+
enabled: false
|
|
314
|
+
};
|
|
315
|
+
if (value === true || value == null) return { ...defaults };
|
|
316
|
+
const merged = {
|
|
317
|
+
...defaults,
|
|
318
|
+
...value,
|
|
319
|
+
enabled: value.enabled !== false
|
|
320
|
+
};
|
|
321
|
+
for (const [key, fallback] of Object.entries(defaults)) if (typeof fallback === "number" && (typeof merged[key] !== "number" || !Number.isFinite(merged[key]))) merged[key] = fallback;
|
|
322
|
+
return merged;
|
|
323
|
+
};
|
|
324
|
+
function normalizeWebGpuPostFxOptions(options = {}) {
|
|
325
|
+
return {
|
|
326
|
+
ao: effectOptions(DEFAULT_OPTIONS.ao, options.ao),
|
|
327
|
+
bloom: effectOptions(DEFAULT_OPTIONS.bloom, options.bloom),
|
|
328
|
+
fxaa: effectOptions(DEFAULT_OPTIONS.fxaa, options.fxaa)
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function supportsWebGpuPostFx(renderer) {
|
|
332
|
+
return renderer?.backend?.isWebGPUBackend === true;
|
|
333
|
+
}
|
|
334
|
+
var WebGpuPostFxPipeline = class {
|
|
335
|
+
constructor({ renderer, scene, camera, options = {} } = {}) {
|
|
336
|
+
if (!renderer) throw new TypeError("WebGpuPostFxPipeline requires a renderer");
|
|
337
|
+
if (!scene) throw new TypeError("WebGpuPostFxPipeline requires a scene");
|
|
338
|
+
if (!camera) throw new TypeError("WebGpuPostFxPipeline requires a camera");
|
|
339
|
+
this.renderer = renderer;
|
|
340
|
+
this.scene = scene;
|
|
341
|
+
this.camera = camera;
|
|
342
|
+
this.options = normalizeWebGpuPostFxOptions(options);
|
|
343
|
+
this.enabled = supportsWebGpuPostFx(renderer);
|
|
344
|
+
this.pipeline = null;
|
|
345
|
+
this.scenePass = null;
|
|
346
|
+
this.aoNode = null;
|
|
347
|
+
this.bloomNode = null;
|
|
348
|
+
if (this.enabled) this.build();
|
|
349
|
+
}
|
|
350
|
+
build() {
|
|
351
|
+
const scenePass = pass(this.scene, this.camera, { samples: 0 });
|
|
352
|
+
scenePass.setMRT(mrt({
|
|
353
|
+
output,
|
|
354
|
+
normal: normalView
|
|
355
|
+
}));
|
|
356
|
+
const sceneColor = scenePass.getTextureNode("output");
|
|
357
|
+
const sceneNormal = scenePass.getTextureNode("normal");
|
|
358
|
+
const sceneDepth = scenePass.getTextureNode("depth");
|
|
359
|
+
let composite = sceneColor;
|
|
360
|
+
if (this.options.ao.enabled) {
|
|
361
|
+
const settings = this.options.ao;
|
|
362
|
+
const aoNode = ao(sceneDepth, sceneNormal, this.camera);
|
|
363
|
+
aoNode.resolutionScale = settings.resolutionScale;
|
|
364
|
+
aoNode.radius.value = settings.radius;
|
|
365
|
+
aoNode.thickness.value = settings.thickness;
|
|
366
|
+
aoNode.distanceExponent.value = settings.distanceExponent;
|
|
367
|
+
aoNode.distanceFallOff.value = settings.distanceFallOff;
|
|
368
|
+
aoNode.scale.value = settings.scale;
|
|
369
|
+
aoNode.samples.value = settings.samples;
|
|
370
|
+
const visibility = aoNode.getTextureNode().r;
|
|
371
|
+
composite = composite.mul(vec4(vec3(visibility), 1));
|
|
372
|
+
this.aoNode = aoNode;
|
|
373
|
+
}
|
|
374
|
+
if (this.options.bloom.enabled) {
|
|
375
|
+
const settings = this.options.bloom;
|
|
376
|
+
this.bloomNode = bloom(sceneColor, settings.strength, settings.radius, settings.threshold);
|
|
377
|
+
composite = composite.add(this.bloomNode);
|
|
378
|
+
}
|
|
379
|
+
const pipeline = new RenderPipeline(this.renderer);
|
|
380
|
+
if (this.options.fxaa.enabled) {
|
|
381
|
+
pipeline.outputColorTransform = false;
|
|
382
|
+
composite = fxaa(renderOutput(composite));
|
|
383
|
+
}
|
|
384
|
+
pipeline.outputNode = composite;
|
|
385
|
+
this.scenePass = scenePass;
|
|
386
|
+
this.pipeline = pipeline;
|
|
387
|
+
}
|
|
388
|
+
render() {
|
|
389
|
+
if (!this.enabled || !this.pipeline) return false;
|
|
390
|
+
this.pipeline.render();
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
diagnostics() {
|
|
394
|
+
return Object.freeze({
|
|
395
|
+
enabled: this.enabled,
|
|
396
|
+
backend: this.enabled ? "webgpu" : "unsupported",
|
|
397
|
+
effects: [
|
|
398
|
+
this.options.ao.enabled ? "gtao" : null,
|
|
399
|
+
this.options.bloom.enabled ? "bloom" : null,
|
|
400
|
+
this.options.fxaa.enabled ? "fxaa" : null
|
|
401
|
+
].filter(Boolean)
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
dispose() {
|
|
405
|
+
this.scenePass?.dispose?.();
|
|
406
|
+
this.scenePass = null;
|
|
407
|
+
this.aoNode?.dispose?.();
|
|
408
|
+
this.aoNode = null;
|
|
409
|
+
this.bloomNode?.dispose?.();
|
|
410
|
+
this.bloomNode = null;
|
|
411
|
+
this.pipeline?.dispose?.();
|
|
412
|
+
this.pipeline = null;
|
|
413
|
+
this.enabled = false;
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
// modules/rendering/loadGaussianSplatVisual.js
|
|
417
|
+
const asArrayBuffer = (bytes) => bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
418
|
+
const DEFAULT_RUNTIME_SPLAT_BUDGET = 5e5;
|
|
419
|
+
const sampleTypedArray = (input, stride, sourceCount, targetCount) => {
|
|
420
|
+
if (!input || targetCount >= sourceCount) return input;
|
|
421
|
+
const output = new input.constructor(targetCount * stride);
|
|
422
|
+
for (let index = 0; index < targetCount; index += 1) {
|
|
423
|
+
const sourceIndex = Math.min(sourceCount - 1, Math.floor(index * sourceCount / targetCount));
|
|
424
|
+
output.set(input.subarray(sourceIndex * stride, sourceIndex * stride + stride), index * stride);
|
|
425
|
+
}
|
|
426
|
+
return output;
|
|
427
|
+
};
|
|
428
|
+
function budgetGaussianData(data, maxSplats = DEFAULT_RUNTIME_SPLAT_BUDGET) {
|
|
429
|
+
const sourceSplatCount = Math.floor((data?.position?.length || 0) / 4);
|
|
430
|
+
if (!sourceSplatCount) return {
|
|
431
|
+
data,
|
|
432
|
+
sourceSplatCount: 0,
|
|
433
|
+
splatCount: 0,
|
|
434
|
+
sampled: false
|
|
435
|
+
};
|
|
436
|
+
const splatCount = Math.min(sourceSplatCount, Number.isFinite(maxSplats) && maxSplats > 0 ? Math.floor(maxSplats) : DEFAULT_RUNTIME_SPLAT_BUDGET);
|
|
437
|
+
if (splatCount === sourceSplatCount) return {
|
|
438
|
+
data,
|
|
439
|
+
sourceSplatCount,
|
|
440
|
+
splatCount,
|
|
441
|
+
sampled: false
|
|
442
|
+
};
|
|
443
|
+
const extra = data.extra || {};
|
|
444
|
+
return {
|
|
445
|
+
data: {
|
|
446
|
+
...data,
|
|
447
|
+
position: sampleTypedArray(data.position, 4, sourceSplatCount, splatCount),
|
|
448
|
+
color: sampleTypedArray(data.color, 4, sourceSplatCount, splatCount),
|
|
449
|
+
covariance: sampleTypedArray(data.covariance, 8, sourceSplatCount, splatCount),
|
|
450
|
+
extra: {
|
|
451
|
+
...extra,
|
|
452
|
+
...extra.sh1 ? { sh1: sampleTypedArray(extra.sh1, 2, sourceSplatCount, splatCount) } : {},
|
|
453
|
+
...extra.sh2 ? { sh2: sampleTypedArray(extra.sh2, 4, sourceSplatCount, splatCount) } : {},
|
|
454
|
+
...extra.sh3 ? { sh3: sampleTypedArray(extra.sh3, 4, sourceSplatCount, splatCount) } : {}
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
sourceSplatCount,
|
|
458
|
+
splatCount,
|
|
459
|
+
sampled: true
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
async function loadGaussianSplatVisual({ source, maxSplats = DEFAULT_RUNTIME_SPLAT_BUDGET } = {}) {
|
|
463
|
+
if (!source) throw new TypeError("Gaussian splat visual source is required");
|
|
464
|
+
const format = String(source.format || source.url?.split(/[?#]/, 1)[0]?.split(".").at(-1) || "").toLowerCase();
|
|
465
|
+
if (format !== "spz") throw new TypeError(`Unsupported generated visual format: ${format || "unknown"}`);
|
|
466
|
+
const bytes = source.data instanceof Uint8Array ? source.data : source.data instanceof ArrayBuffer ? new Uint8Array(source.data) : null;
|
|
467
|
+
let buffer;
|
|
468
|
+
if (bytes) buffer = asArrayBuffer(bytes);
|
|
469
|
+
else {
|
|
470
|
+
if (typeof source.url !== "string" || !source.url) throw new TypeError("Gaussian splat visual requires url or data");
|
|
471
|
+
const response = await fetch(source.url);
|
|
472
|
+
if (!response.ok) throw new Error(`Failed to load generated SPZ visual: ${response.status}`);
|
|
473
|
+
buffer = await response.arrayBuffer();
|
|
474
|
+
}
|
|
475
|
+
const { GSMesh, SpzLoader } = await import("three-gsmesh");
|
|
476
|
+
const budgeted = budgetGaussianData(await new SpzLoader({ includeSH: true }).parseData(buffer), maxSplats);
|
|
477
|
+
if (!budgeted.splatCount) throw new Error("Generated SPZ visual contains no splats");
|
|
478
|
+
const object = new GSMesh(budgeted.data, { sortIntervalFrames: 3 });
|
|
479
|
+
object.name = "GaussianSplatVisual";
|
|
480
|
+
return {
|
|
481
|
+
object,
|
|
482
|
+
format: "spz",
|
|
483
|
+
splatCount: budgeted.splatCount,
|
|
484
|
+
sourceSplatCount: budgeted.sourceSplatCount,
|
|
485
|
+
sampled: budgeted.sampled,
|
|
486
|
+
dispose() {
|
|
487
|
+
disposeObject3D(object);
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
// modules/world/generated/GeneratedWorldCoordinates.js
|
|
492
|
+
const SUPPORTED_GENERATED_WORLD_COORDINATES = /* @__PURE__ */ new Set(["y-up", "z-up"]);
|
|
493
|
+
function validateGeneratedWorldCoordinates(coordinateSystem = "y-up", metersPerUnit = 1) {
|
|
494
|
+
if (!SUPPORTED_GENERATED_WORLD_COORDINATES.has(coordinateSystem)) throw new TypeError("coordinateSystem must be y-up or z-up");
|
|
495
|
+
if (!Number.isFinite(metersPerUnit) || metersPerUnit <= 0) throw new TypeError("metersPerUnit must be a positive finite number");
|
|
496
|
+
return {
|
|
497
|
+
coordinateSystem,
|
|
498
|
+
metersPerUnit
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
function generatedWorldTransformMatrix(coordinateSystem = "y-up", metersPerUnit = 1) {
|
|
502
|
+
validateGeneratedWorldCoordinates(coordinateSystem, metersPerUnit);
|
|
503
|
+
const matrix = new THREE.Matrix4();
|
|
504
|
+
if (coordinateSystem === "z-up") matrix.makeRotationX(-Math.PI / 2);
|
|
505
|
+
if (metersPerUnit !== 1) matrix.premultiply(new THREE.Matrix4().makeScale(metersPerUnit, metersPerUnit, metersPerUnit));
|
|
506
|
+
return matrix;
|
|
507
|
+
}
|
|
508
|
+
function applyGeneratedWorldObjectTransform(object, coordinateSystem = "y-up", metersPerUnit = 1) {
|
|
509
|
+
if (!object?.applyMatrix4) throw new TypeError("Generated world visual must be an Object3D");
|
|
510
|
+
object.applyMatrix4(generatedWorldTransformMatrix(coordinateSystem, metersPerUnit));
|
|
511
|
+
object.updateMatrixWorld?.(true);
|
|
512
|
+
return object;
|
|
513
|
+
}
|
|
514
|
+
// modules/world/runtime/systems/RenderingSystem.js
|
|
515
|
+
var RenderingSystem = class {
|
|
516
|
+
attachStyleSystem(styles) {
|
|
517
|
+
this.styleSystem = styles;
|
|
518
|
+
}
|
|
519
|
+
serializeStyle() {
|
|
520
|
+
return this.styleSystem?.export() || null;
|
|
521
|
+
}
|
|
522
|
+
validateStyle(input) {
|
|
523
|
+
return input == null ? null : resolveStylePack(input);
|
|
524
|
+
}
|
|
525
|
+
async restoreStyle(input) {
|
|
526
|
+
if (!this.styleSystem) {
|
|
527
|
+
if (input) throw new Error("STYLE_UNAVAILABLE");
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
if (input) return this.styleSystem.set(input);
|
|
531
|
+
this.styleSystem.clear();
|
|
532
|
+
}
|
|
533
|
+
constructor({ container, scene, events = null, rendererFactory = createRenderer, rendererMode = "auto", rendererTiming = false, pixelRatioScale = 1, ResizeObserverClass = globalThis.ResizeObserver, controlsFactory = (camera, domElement) => new OrbitControls(camera, domElement), environmentLoader = new HDRLoader(), postFxFactory = (options) => new WebGpuPostFxPipeline(options), postFxOptions = {}, generatedVisualLoader = loadGaussianSplatVisual, onDeviceLost = null, onError = null, authoringStage = true } = {}) {
|
|
534
|
+
if (!container) throw new TypeError("RenderingSystem requires a container");
|
|
535
|
+
if (!scene) throw new TypeError("RenderingSystem requires a scene");
|
|
536
|
+
if (typeof rendererFactory !== "function") throw new TypeError("RenderingSystem rendererFactory must be a function");
|
|
537
|
+
if (typeof controlsFactory !== "function") throw new TypeError("RenderingSystem controlsFactory must be a function");
|
|
538
|
+
if (!environmentLoader || typeof environmentLoader.loadAsync !== "function") throw new TypeError("RenderingSystem requires an environment loader");
|
|
539
|
+
if (typeof postFxFactory !== "function") throw new TypeError("RenderingSystem postFxFactory must be a function");
|
|
540
|
+
if (typeof generatedVisualLoader !== "function") throw new TypeError("RenderingSystem generatedVisualLoader must be a function");
|
|
541
|
+
if (!Number.isFinite(pixelRatioScale) || pixelRatioScale < .5 || pixelRatioScale > 1) throw new RangeError("RenderingSystem pixelRatioScale must be between 0.5 and 1");
|
|
542
|
+
this.container = container;
|
|
543
|
+
this.scene = scene;
|
|
544
|
+
this.events = events;
|
|
545
|
+
this.rendererFactory = rendererFactory;
|
|
546
|
+
this.rendererMode = rendererMode;
|
|
547
|
+
this.rendererTiming = Boolean(rendererTiming);
|
|
548
|
+
this.pixelRatioScale = pixelRatioScale;
|
|
549
|
+
this.ResizeObserverClass = ResizeObserverClass;
|
|
550
|
+
this.controlsFactory = controlsFactory;
|
|
551
|
+
this.environmentLoader = environmentLoader;
|
|
552
|
+
this.postFxFactory = postFxFactory;
|
|
553
|
+
this.postFxOptions = postFxOptions;
|
|
554
|
+
this.generatedVisualLoader = generatedVisualLoader;
|
|
555
|
+
this.onDeviceLost = typeof onDeviceLost === "function" ? onDeviceLost : null;
|
|
556
|
+
this.onError = typeof onError === "function" ? onError : null;
|
|
557
|
+
this.camera = null;
|
|
558
|
+
this.renderer = null;
|
|
559
|
+
this.controls = null;
|
|
560
|
+
this.info = null;
|
|
561
|
+
this.probe = null;
|
|
562
|
+
this.environmentTexture = null;
|
|
563
|
+
this.environmentVersion = 0;
|
|
564
|
+
this.lightingVersion = 0;
|
|
565
|
+
this.baseLighting = null;
|
|
566
|
+
this.presentationLighting = null;
|
|
567
|
+
this.lightingStatus = "none";
|
|
568
|
+
this.creativeCamera = null;
|
|
569
|
+
this.creativeView = false;
|
|
570
|
+
this.environmentTask = Promise.resolve(false);
|
|
571
|
+
this.postFx = null;
|
|
572
|
+
this.generatedVisual = null;
|
|
573
|
+
this.generatedVisualState = {
|
|
574
|
+
status: "none",
|
|
575
|
+
format: null,
|
|
576
|
+
splatCount: 0
|
|
577
|
+
};
|
|
578
|
+
this.resizeObserver = null;
|
|
579
|
+
this.resizeWidth = 0;
|
|
580
|
+
this.resizeHeight = 0;
|
|
581
|
+
this.visualTask = Promise.resolve(false);
|
|
582
|
+
this.decorationRoot = new THREE.Group();
|
|
583
|
+
this.decorationRoot.name = "$visual-decorations";
|
|
584
|
+
this.decorationRoot.userData.visualDecorationRoot = true;
|
|
585
|
+
this.authoringScenes = /* @__PURE__ */ new Map();
|
|
586
|
+
this.authoringStageEnabled = authoringStage !== false;
|
|
587
|
+
this.authoringStage = null;
|
|
588
|
+
}
|
|
589
|
+
ensureAuthoringStage() {
|
|
590
|
+
if (this.authoringStage) return this.authoringStage;
|
|
591
|
+
const stage = new THREE.Scene();
|
|
592
|
+
stage.name = "$authoring-stage";
|
|
593
|
+
stage.add(new THREE.GridHelper(24, 24, 9343131, 3159110));
|
|
594
|
+
this.authoringStage = stage;
|
|
595
|
+
return stage;
|
|
596
|
+
}
|
|
597
|
+
addDecoration(object) {
|
|
598
|
+
if (!object?.isObject3D) throw new TypeError("Visual decoration must be an Object3D");
|
|
599
|
+
if (object.userData?.instanceId) {
|
|
600
|
+
const error = /* @__PURE__ */ new TypeError("World Entity cannot be attached as Visual Decoration");
|
|
601
|
+
error.code = "WORLD_ENTITY_AS_DECORATION";
|
|
602
|
+
throw error;
|
|
603
|
+
}
|
|
604
|
+
object.userData ||= {};
|
|
605
|
+
object.userData.visualDecoration = true;
|
|
606
|
+
if (this.decorationRoot.parent !== this.scene) this.scene.add(this.decorationRoot);
|
|
607
|
+
this.decorationRoot.add(object);
|
|
608
|
+
return object;
|
|
609
|
+
}
|
|
610
|
+
removeDecoration(object) {
|
|
611
|
+
if (!object?.isObject3D || object.parent !== this.decorationRoot) return false;
|
|
612
|
+
this.decorationRoot.remove(object);
|
|
613
|
+
return true;
|
|
614
|
+
}
|
|
615
|
+
addAuthoringScene(scene, { mode = "overlay" } = {}) {
|
|
616
|
+
if (!scene?.isScene) throw new TypeError("Authoring presentation requires a THREE.Scene");
|
|
617
|
+
if (![
|
|
618
|
+
"hidden",
|
|
619
|
+
"overlay",
|
|
620
|
+
"replace"
|
|
621
|
+
].includes(mode)) throw new TypeError(`Unsupported authoring scene mode: ${mode}`);
|
|
622
|
+
this.authoringScenes.set(scene, mode);
|
|
623
|
+
return scene;
|
|
624
|
+
}
|
|
625
|
+
setAuthoringSceneMode(scene, mode = "overlay") {
|
|
626
|
+
if (!this.authoringScenes.has(scene)) return false;
|
|
627
|
+
if (![
|
|
628
|
+
"hidden",
|
|
629
|
+
"overlay",
|
|
630
|
+
"replace"
|
|
631
|
+
].includes(mode)) throw new TypeError(`Unsupported authoring scene mode: ${mode}`);
|
|
632
|
+
this.authoringScenes.set(scene, mode);
|
|
633
|
+
return true;
|
|
634
|
+
}
|
|
635
|
+
removeAuthoringScene(scene) {
|
|
636
|
+
return this.authoringScenes.delete(scene);
|
|
637
|
+
}
|
|
638
|
+
async init() {
|
|
639
|
+
this.camera = new THREE.PerspectiveCamera(45, 1, .05, 120);
|
|
640
|
+
const result = await this.rendererFactory({
|
|
641
|
+
mode: this.rendererMode,
|
|
642
|
+
antialias: true,
|
|
643
|
+
alpha: false,
|
|
644
|
+
trackTimestamp: this.rendererTiming
|
|
645
|
+
});
|
|
646
|
+
this.renderer = result.renderer;
|
|
647
|
+
this.info = result.info;
|
|
648
|
+
this.probe = new RendererProbe(this.renderer, {
|
|
649
|
+
requestedMode: this.rendererMode,
|
|
650
|
+
onDeviceLost: (detail) => {
|
|
651
|
+
this.onDeviceLost?.(detail);
|
|
652
|
+
this.events?.emit?.("renderer.device-lost", detail);
|
|
653
|
+
},
|
|
654
|
+
onError: (detail) => {
|
|
655
|
+
this.onError?.(detail);
|
|
656
|
+
this.events?.emit?.("renderer.error", detail);
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
const pixelRatio = typeof devicePixelRatio === "number" ? devicePixelRatio : 1;
|
|
660
|
+
this.renderer.setPixelRatio(Math.min(pixelRatio, 2) * this.pixelRatioScale);
|
|
661
|
+
this.renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
662
|
+
this.renderer.toneMapping = THREE.ACESFilmicToneMapping;
|
|
663
|
+
this.renderer.toneMappingExposure = 1.15;
|
|
664
|
+
this.renderer.shadowMap.enabled = true;
|
|
665
|
+
this.renderer.shadowMap.type = THREE.PCFShadowMap;
|
|
666
|
+
this.container.appendChild(this.renderer.domElement);
|
|
667
|
+
this.postFx = this.postFxFactory({
|
|
668
|
+
renderer: this.renderer,
|
|
669
|
+
scene: this.scene,
|
|
670
|
+
camera: this.camera,
|
|
671
|
+
options: this.postFxOptions
|
|
672
|
+
});
|
|
673
|
+
this.controls = this.controlsFactory(this.camera, this.renderer.domElement);
|
|
674
|
+
this.controls.enableDamping = true;
|
|
675
|
+
this.resize();
|
|
676
|
+
if (typeof this.ResizeObserverClass === "function") {
|
|
677
|
+
this.resizeObserver = new this.ResizeObserverClass(() => this.resize());
|
|
678
|
+
this.resizeObserver.observe(this.container);
|
|
679
|
+
}
|
|
680
|
+
return this;
|
|
681
|
+
}
|
|
682
|
+
applyEnvironment(environment = {}) {
|
|
683
|
+
const version = ++this.environmentVersion;
|
|
684
|
+
this.releaseEnvironmentTexture();
|
|
685
|
+
this.releaseGeneratedVisual();
|
|
686
|
+
const rendering = environment.rendering || {};
|
|
687
|
+
const background = rendering.background ?? 527120;
|
|
688
|
+
this.scene.background = new THREE.Color(background);
|
|
689
|
+
const fog = rendering.fog || {
|
|
690
|
+
color: background,
|
|
691
|
+
near: 22,
|
|
692
|
+
far: 58
|
|
693
|
+
};
|
|
694
|
+
this.scene.fog = fog.isFogExp2 ? fog : fog.type === "exp2" ? new THREE.FogExp2(fog.color, fog.density) : new THREE.Fog(fog.color, fog.near, fog.far);
|
|
695
|
+
this.renderer.toneMappingExposure = rendering.exposure ?? 1.1;
|
|
696
|
+
const camera = environment.camera || {};
|
|
697
|
+
if (Number.isFinite(camera.far)) {
|
|
698
|
+
this.camera.far = camera.far;
|
|
699
|
+
this.camera.updateProjectionMatrix();
|
|
700
|
+
}
|
|
701
|
+
if (Array.isArray(camera.position)) this.camera.position.fromArray(camera.position);
|
|
702
|
+
if (Array.isArray(camera.target)) this.controls.target.fromArray(camera.target);
|
|
703
|
+
this.controls.update();
|
|
704
|
+
this.baseLighting = {
|
|
705
|
+
ibl: rendering.ibl,
|
|
706
|
+
background
|
|
707
|
+
};
|
|
708
|
+
this.refreshEnvironmentLighting();
|
|
709
|
+
this.visualTask = environment.generated?.visual ? this.loadGeneratedVisual(environment, version) : Promise.resolve(false);
|
|
710
|
+
return true;
|
|
711
|
+
}
|
|
712
|
+
async loadGeneratedVisual(environment, version) {
|
|
713
|
+
const visual = environment.generated?.visual;
|
|
714
|
+
if (!visual) return false;
|
|
715
|
+
const format = String(visual.format || visual.source?.format || "").toLowerCase();
|
|
716
|
+
if (format !== "spz") return false;
|
|
717
|
+
if (this.renderer?.backend?.isWebGPUBackend !== true) {
|
|
718
|
+
visual.status = "unsupported-backend";
|
|
719
|
+
this.generatedVisualState = {
|
|
720
|
+
status: "unsupported-backend",
|
|
721
|
+
format,
|
|
722
|
+
splatCount: 0
|
|
723
|
+
};
|
|
724
|
+
return false;
|
|
725
|
+
}
|
|
726
|
+
visual.status = "loading";
|
|
727
|
+
this.generatedVisualState = {
|
|
728
|
+
status: "loading",
|
|
729
|
+
format,
|
|
730
|
+
splatCount: 0
|
|
731
|
+
};
|
|
732
|
+
try {
|
|
733
|
+
const loaded = await this.generatedVisualLoader({ source: visual.source || visual });
|
|
734
|
+
if (version !== this.environmentVersion || !this.renderer) {
|
|
735
|
+
loaded?.dispose?.();
|
|
736
|
+
return false;
|
|
737
|
+
}
|
|
738
|
+
if (!loaded?.object?.isObject3D) throw new TypeError("Generated visual loader must return an Object3D");
|
|
739
|
+
applyGeneratedWorldObjectTransform(loaded.object, environment.generated.coordinateSystem || "y-up", environment.generated.metersPerUnit ?? 1);
|
|
740
|
+
environment.root?.add?.(loaded.object);
|
|
741
|
+
const fallbackMaterial = environment.floor?.material || null;
|
|
742
|
+
if (fallbackMaterial) fallbackMaterial.visible = false;
|
|
743
|
+
this.generatedVisual = {
|
|
744
|
+
...loaded,
|
|
745
|
+
root: environment.root || null,
|
|
746
|
+
fallbackMaterial
|
|
747
|
+
};
|
|
748
|
+
visual.status = "ready";
|
|
749
|
+
this.generatedVisualState = {
|
|
750
|
+
status: "ready",
|
|
751
|
+
format: loaded.format || format,
|
|
752
|
+
splatCount: loaded.splatCount || 0,
|
|
753
|
+
sourceSplatCount: loaded.sourceSplatCount || loaded.splatCount || 0,
|
|
754
|
+
sampled: Boolean(loaded.sampled)
|
|
755
|
+
};
|
|
756
|
+
this.events?.emit?.("renderer.generated-visual-ready", {
|
|
757
|
+
format: this.generatedVisualState.format,
|
|
758
|
+
splatCount: this.generatedVisualState.splatCount,
|
|
759
|
+
sourceSplatCount: this.generatedVisualState.sourceSplatCount,
|
|
760
|
+
sampled: this.generatedVisualState.sampled
|
|
761
|
+
});
|
|
762
|
+
return true;
|
|
763
|
+
} catch (error) {
|
|
764
|
+
if (version === this.environmentVersion && this.renderer) {
|
|
765
|
+
visual.status = "failed";
|
|
766
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
767
|
+
this.generatedVisualState = {
|
|
768
|
+
status: "failed",
|
|
769
|
+
format,
|
|
770
|
+
splatCount: 0,
|
|
771
|
+
message
|
|
772
|
+
};
|
|
773
|
+
this.events?.emit?.("renderer.generated-visual-error", {
|
|
774
|
+
format,
|
|
775
|
+
message
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
return false;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
releaseGeneratedVisual() {
|
|
782
|
+
const visual = this.generatedVisual;
|
|
783
|
+
if (visual?.object?.parent) visual.object.parent.remove(visual.object);
|
|
784
|
+
visual?.dispose?.();
|
|
785
|
+
if (visual?.fallbackMaterial) visual.fallbackMaterial.visible = true;
|
|
786
|
+
this.generatedVisual = null;
|
|
787
|
+
this.generatedVisualState = {
|
|
788
|
+
status: "none",
|
|
789
|
+
format: null,
|
|
790
|
+
splatCount: 0
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
setPresentation(state, camera) {
|
|
794
|
+
this.creativeCamera = camera;
|
|
795
|
+
this.previewCamera = camera?.clone() ?? null;
|
|
796
|
+
if (!camera) this.creativeView = false;
|
|
797
|
+
const next = state?.environment ?? null;
|
|
798
|
+
if (JSON.stringify(next) !== JSON.stringify(this.presentationLighting)) {
|
|
799
|
+
this.presentationLighting = next;
|
|
800
|
+
if (this.renderer && this.baseLighting) this.refreshEnvironmentLighting();
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
refreshEnvironmentLighting() {
|
|
804
|
+
const version = ++this.lightingVersion;
|
|
805
|
+
this.releaseEnvironmentTexture();
|
|
806
|
+
const base = this.baseLighting || {};
|
|
807
|
+
this.scene.background = new THREE.Color(base.background ?? 527120);
|
|
808
|
+
this.scene.backgroundIntensity = 1;
|
|
809
|
+
this.scene.environmentIntensity = 1;
|
|
810
|
+
const selected = this.presentationLighting;
|
|
811
|
+
const ibl = selected ? selected.preset === "none" ? null : {
|
|
812
|
+
url: PRESENTATION_HDRI_PRESETS[selected.preset],
|
|
813
|
+
intensity: selected.intensity,
|
|
814
|
+
background: selected.background
|
|
815
|
+
} : base.ibl;
|
|
816
|
+
this.setLightingStatus(ibl?.url ? "loading" : "none");
|
|
817
|
+
this.environmentTask = ibl?.url ? this.loadEnvironmentTexture(ibl, version) : Promise.resolve(false);
|
|
818
|
+
return this.environmentTask;
|
|
819
|
+
}
|
|
820
|
+
setLightingStatus(status) {
|
|
821
|
+
this.lightingStatus = status;
|
|
822
|
+
this.events?.emit?.("renderer.environment-status", { status });
|
|
823
|
+
}
|
|
824
|
+
setCreativeView(enabled) {
|
|
825
|
+
this.creativeView = Boolean(enabled && this.creativeCamera);
|
|
826
|
+
return this.creativeView;
|
|
827
|
+
}
|
|
828
|
+
async captureStill(longEdge = 1920, { excludedRoot } = {}) {
|
|
829
|
+
const version = this.lightingVersion;
|
|
830
|
+
await this.environmentTask;
|
|
831
|
+
if (version !== this.lightingVersion) throw new Error("STILL_LIGHTING_CHANGED");
|
|
832
|
+
if (this.lightingStatus === "failed" && this.presentationLighting) throw new Error("STILL_HDRI_LOAD_FAILED");
|
|
833
|
+
if (!this.renderer) throw new Error("RENDERER_UNAVAILABLE");
|
|
834
|
+
if (this.generatedVisual) throw new Error("STILL_GENERATED_VISUAL_UNSUPPORTED");
|
|
835
|
+
if ([...this.authoringScenes.values()].includes("replace") || [...this.authoringScenes].some(([scene, mode]) => mode === "overlay" && scene.children.length)) throw new Error("STILL_AUTHORING_SCENE_UNSUPPORTED");
|
|
836
|
+
return captureStill({
|
|
837
|
+
scene: this.scene,
|
|
838
|
+
camera: this.creativeCamera || this.camera,
|
|
839
|
+
decoration: this.decorationRoot,
|
|
840
|
+
excludedRoot,
|
|
841
|
+
exposure: this.renderer.toneMappingExposure,
|
|
842
|
+
longEdge
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
async loadEnvironmentTexture(ibl, version) {
|
|
846
|
+
try {
|
|
847
|
+
const texture = await this.environmentLoader.loadAsync(ibl.url);
|
|
848
|
+
if (version !== this.lightingVersion || !this.renderer) {
|
|
849
|
+
texture.dispose?.();
|
|
850
|
+
return false;
|
|
851
|
+
}
|
|
852
|
+
texture.mapping = THREE.EquirectangularReflectionMapping;
|
|
853
|
+
this.environmentTexture = texture;
|
|
854
|
+
this.scene.environment = texture;
|
|
855
|
+
this.scene.environmentIntensity = Number.isFinite(ibl.intensity) ? ibl.intensity : 1;
|
|
856
|
+
if (ibl.background === true) {
|
|
857
|
+
this.scene.background = texture;
|
|
858
|
+
if (Number.isFinite(ibl.backgroundIntensity)) this.scene.backgroundIntensity = ibl.backgroundIntensity;
|
|
859
|
+
}
|
|
860
|
+
this.setLightingStatus("ready");
|
|
861
|
+
return true;
|
|
862
|
+
} catch (error) {
|
|
863
|
+
if (version === this.lightingVersion && this.renderer) {
|
|
864
|
+
this.setLightingStatus("failed");
|
|
865
|
+
this.events?.emit?.("renderer.environment-error", {
|
|
866
|
+
url: ibl.url,
|
|
867
|
+
message: error instanceof Error ? error.message : String(error)
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
return false;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
releaseEnvironmentTexture() {
|
|
874
|
+
const texture = this.environmentTexture;
|
|
875
|
+
if (!texture) return;
|
|
876
|
+
if (this.scene.environment === texture) this.scene.environment = null;
|
|
877
|
+
if (this.scene.background === texture) this.scene.background = null;
|
|
878
|
+
texture.dispose?.();
|
|
879
|
+
this.environmentTexture = null;
|
|
880
|
+
}
|
|
881
|
+
viewport() {
|
|
882
|
+
if (!this.camera || !this.renderer || !this.controls) return null;
|
|
883
|
+
return {
|
|
884
|
+
camera: this.camera,
|
|
885
|
+
element: this.renderer.domElement,
|
|
886
|
+
controls: this.controls
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
viewPose() {
|
|
890
|
+
if (!this.camera) return null;
|
|
891
|
+
this.viewPoseState ||= {
|
|
892
|
+
position: [
|
|
893
|
+
0,
|
|
894
|
+
0,
|
|
895
|
+
0
|
|
896
|
+
],
|
|
897
|
+
rotation: [
|
|
898
|
+
0,
|
|
899
|
+
0,
|
|
900
|
+
0,
|
|
901
|
+
1
|
|
902
|
+
]
|
|
903
|
+
};
|
|
904
|
+
this.camera.position.toArray(this.viewPoseState.position);
|
|
905
|
+
this.camera.quaternion.toArray(this.viewPoseState.rotation);
|
|
906
|
+
return this.viewPoseState;
|
|
907
|
+
}
|
|
908
|
+
cameraState() {
|
|
909
|
+
if (!this.camera || !this.controls) return null;
|
|
910
|
+
return {
|
|
911
|
+
position: this.camera.position.toArray(),
|
|
912
|
+
target: this.controls.target.toArray()
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
applyCameraState(state = {}) {
|
|
916
|
+
if (!this.camera || !this.controls) return false;
|
|
917
|
+
if (Array.isArray(state.position) && state.position.length === 3) this.camera.position.fromArray(state.position);
|
|
918
|
+
if (Array.isArray(state.target) && state.target.length === 3) this.controls.target.fromArray(state.target);
|
|
919
|
+
this.controls.update();
|
|
920
|
+
return true;
|
|
921
|
+
}
|
|
922
|
+
update() {
|
|
923
|
+
if (this.controls?.enabled === false) return;
|
|
924
|
+
this.controls?.update();
|
|
925
|
+
}
|
|
926
|
+
render(timestamp = performance.now()) {
|
|
927
|
+
const started = performance.now();
|
|
928
|
+
if (this.creativeView && this.creativeCamera) {
|
|
929
|
+
const camera = this.previewCamera;
|
|
930
|
+
if (camera.aspect !== this.camera.aspect) {
|
|
931
|
+
camera.aspect = this.camera.aspect;
|
|
932
|
+
camera.updateProjectionMatrix();
|
|
933
|
+
}
|
|
934
|
+
const visible = this.decorationRoot.visible;
|
|
935
|
+
this.decorationRoot.visible = false;
|
|
936
|
+
try {
|
|
937
|
+
this.renderer.render(this.scene, camera);
|
|
938
|
+
} finally {
|
|
939
|
+
this.decorationRoot.visible = visible;
|
|
940
|
+
}
|
|
941
|
+
this.probe?.afterRender(timestamp, performance.now() - started);
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
const entries = [...this.authoringScenes.entries()];
|
|
945
|
+
const overlays = entries.filter(([scene, mode]) => mode === "overlay" && scene.children.length > 0);
|
|
946
|
+
const replacement = entries.findLast?.(([, mode]) => mode === "replace") || [...entries].reverse().find(([, mode]) => mode === "replace");
|
|
947
|
+
if (replacement) {
|
|
948
|
+
this.renderer.render(replacement[0], this.camera);
|
|
949
|
+
if (this.authoringStageEnabled && replacement[0].children.length === 0) {
|
|
950
|
+
const stageAutoClear = this.renderer.autoClear;
|
|
951
|
+
this.renderer.autoClear = false;
|
|
952
|
+
try {
|
|
953
|
+
this.renderer.render(this.ensureAuthoringStage(), this.camera);
|
|
954
|
+
} finally {
|
|
955
|
+
this.renderer.autoClear = stageAutoClear;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
} else if (this.postFx?.enabled && overlays.length === 0) try {
|
|
959
|
+
this.postFx.render();
|
|
960
|
+
} catch (error) {
|
|
961
|
+
this.disablePostFx(error);
|
|
962
|
+
this.renderer.render(this.scene, this.camera);
|
|
963
|
+
}
|
|
964
|
+
else this.renderer.render(this.scene, this.camera);
|
|
965
|
+
if (!replacement && overlays.length > 0) {
|
|
966
|
+
const autoClear = this.renderer.autoClear;
|
|
967
|
+
this.renderer.autoClear = false;
|
|
968
|
+
try {
|
|
969
|
+
for (const [scene] of overlays) this.renderer.render(scene, this.camera);
|
|
970
|
+
} finally {
|
|
971
|
+
this.renderer.autoClear = autoClear;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
this.probe?.afterRender(timestamp, performance.now() - started);
|
|
975
|
+
}
|
|
976
|
+
disablePostFx(error) {
|
|
977
|
+
const diagnostics = this.postFx?.diagnostics?.() || null;
|
|
978
|
+
this.postFx?.dispose?.();
|
|
979
|
+
this.postFx = null;
|
|
980
|
+
this.events?.emit?.("renderer.postfx-error", {
|
|
981
|
+
message: error instanceof Error ? error.message : String(error),
|
|
982
|
+
postfx: diagnostics
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
resize() {
|
|
986
|
+
const width = this.container.clientWidth;
|
|
987
|
+
const height = this.container.clientHeight;
|
|
988
|
+
if (!width || !height || !this.camera || !this.renderer) return false;
|
|
989
|
+
if (width === this.resizeWidth && height === this.resizeHeight) return false;
|
|
990
|
+
this.resizeWidth = width;
|
|
991
|
+
this.resizeHeight = height;
|
|
992
|
+
this.camera.aspect = width / height;
|
|
993
|
+
this.camera.updateProjectionMatrix();
|
|
994
|
+
this.renderer.setSize(width, height, false);
|
|
995
|
+
return true;
|
|
996
|
+
}
|
|
997
|
+
diagnostics() {
|
|
998
|
+
const base = this.probe?.snapshot?.() || this.info;
|
|
999
|
+
if (!base) return base;
|
|
1000
|
+
return {
|
|
1001
|
+
...base,
|
|
1002
|
+
postfx: this.postFx?.diagnostics?.() || {
|
|
1003
|
+
enabled: false,
|
|
1004
|
+
effects: []
|
|
1005
|
+
},
|
|
1006
|
+
generatedVisual: { ...this.generatedVisualState }
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
dispose() {
|
|
1010
|
+
this.styleSystem?.dispose();
|
|
1011
|
+
this.styleSystem = null;
|
|
1012
|
+
this.resizeObserver?.disconnect?.();
|
|
1013
|
+
this.resizeObserver = null;
|
|
1014
|
+
this.environmentVersion += 1;
|
|
1015
|
+
this.lightingVersion += 1;
|
|
1016
|
+
this.releaseEnvironmentTexture();
|
|
1017
|
+
this.releaseGeneratedVisual();
|
|
1018
|
+
this.postFx?.dispose?.();
|
|
1019
|
+
this.postFx = null;
|
|
1020
|
+
this.controls?.dispose?.();
|
|
1021
|
+
this.controls = null;
|
|
1022
|
+
if (this.authoringStage) {
|
|
1023
|
+
for (const child of this.authoringStage.children) child.geometry?.dispose?.();
|
|
1024
|
+
this.authoringStage = null;
|
|
1025
|
+
}
|
|
1026
|
+
this.probe?.dispose?.();
|
|
1027
|
+
this.probe = null;
|
|
1028
|
+
const context = this.renderer?.backend?.isWebGLBackend ? this.renderer.backend.gl : null;
|
|
1029
|
+
const disposal = this.renderer?.dispose?.();
|
|
1030
|
+
this.disposal = Promise.resolve(disposal).then(() => {
|
|
1031
|
+
context?.getExtension?.("WEBGL_lose_context")?.loseContext();
|
|
1032
|
+
}).catch((error) => this.onError?.(error));
|
|
1033
|
+
this.renderer?.domElement?.remove?.();
|
|
1034
|
+
this.renderer = null;
|
|
1035
|
+
this.camera = null;
|
|
1036
|
+
this.info = null;
|
|
1037
|
+
this.authoringScenes.clear();
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
export { RenderingSystem };
|
|
1041
|
+
|
|
1042
|
+
//# sourceMappingURL=RenderingSystem-WIr1ZuGu.js.map
|