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,109 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
3
|
+
import { markAuthoringModelRef } from './ModelRef.js';
|
|
4
|
+
|
|
5
|
+
function createThreeNamespace(GLTFLoaderClass) {
|
|
6
|
+
class AuthoringGLTFLoader extends GLTFLoaderClass {
|
|
7
|
+
async loadAsync(url, onProgress) {
|
|
8
|
+
const gltf = await super.loadAsync(url, onProgress);
|
|
9
|
+
if (gltf?.scene) markAuthoringModelRef(gltf.scene, { uri:String(url) });
|
|
10
|
+
return gltf;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
load(url, onLoad, onProgress, onError) {
|
|
14
|
+
return super.load(url, (gltf) => {
|
|
15
|
+
if (gltf?.scene) markAuthoringModelRef(gltf.scene, { uri:String(url) });
|
|
16
|
+
onLoad?.(gltf);
|
|
17
|
+
}, onProgress, onError);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return Object.freeze({
|
|
22
|
+
...THREE,
|
|
23
|
+
GLTFLoader:AuthoringGLTFLoader
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function createAuthoringExecutionHost({
|
|
28
|
+
gltfLoaderClass = GLTFLoader,
|
|
29
|
+
requestFrame = globalThis.requestAnimationFrame?.bind(globalThis),
|
|
30
|
+
cancelFrame = globalThis.cancelAnimationFrame?.bind(globalThis),
|
|
31
|
+
setTimeoutImpl = globalThis.setTimeout?.bind(globalThis),
|
|
32
|
+
clearTimeoutImpl = globalThis.clearTimeout?.bind(globalThis),
|
|
33
|
+
setIntervalImpl = globalThis.setInterval?.bind(globalThis),
|
|
34
|
+
clearIntervalImpl = globalThis.clearInterval?.bind(globalThis)
|
|
35
|
+
} = {}) {
|
|
36
|
+
const frames = new Set();
|
|
37
|
+
const timeouts = new Set();
|
|
38
|
+
const intervals = new Set();
|
|
39
|
+
const authoringThree = createThreeNamespace(gltfLoaderClass);
|
|
40
|
+
|
|
41
|
+
const requestAnimationFrame = (callback) => {
|
|
42
|
+
if (typeof requestFrame !== 'function') throw new TypeError('requestAnimationFrame is unavailable');
|
|
43
|
+
let id = null;
|
|
44
|
+
id = requestFrame((time) => {
|
|
45
|
+
frames.delete(id);
|
|
46
|
+
callback(time);
|
|
47
|
+
});
|
|
48
|
+
frames.add(id);
|
|
49
|
+
return id;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const cancelAnimationFrame = (id) => {
|
|
53
|
+
frames.delete(id);
|
|
54
|
+
cancelFrame?.(id);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const setTimeout = (callback, delay = 0, ...args) => {
|
|
58
|
+
if (typeof setTimeoutImpl !== 'function') throw new TypeError('setTimeout is unavailable');
|
|
59
|
+
let id = null;
|
|
60
|
+
id = setTimeoutImpl((...values) => {
|
|
61
|
+
timeouts.delete(id);
|
|
62
|
+
callback(...values);
|
|
63
|
+
}, delay, ...args);
|
|
64
|
+
timeouts.add(id);
|
|
65
|
+
return id;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const clearTimeout = (id) => {
|
|
69
|
+
timeouts.delete(id);
|
|
70
|
+
clearTimeoutImpl?.(id);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const setInterval = (callback, delay = 0, ...args) => {
|
|
74
|
+
if (typeof setIntervalImpl !== 'function') throw new TypeError('setInterval is unavailable');
|
|
75
|
+
const id = setIntervalImpl(callback, delay, ...args);
|
|
76
|
+
intervals.add(id);
|
|
77
|
+
return id;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const clearInterval = (id) => {
|
|
81
|
+
intervals.delete(id);
|
|
82
|
+
clearIntervalImpl?.(id);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const clear = () => {
|
|
86
|
+
for (const id of frames) cancelFrame?.(id);
|
|
87
|
+
for (const id of timeouts) clearTimeoutImpl?.(id);
|
|
88
|
+
for (const id of intervals) clearIntervalImpl?.(id);
|
|
89
|
+
frames.clear();
|
|
90
|
+
timeouts.clear();
|
|
91
|
+
intervals.clear();
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
THREE:authoringThree,
|
|
96
|
+
requestAnimationFrame,
|
|
97
|
+
cancelAnimationFrame,
|
|
98
|
+
setTimeout,
|
|
99
|
+
clearTimeout,
|
|
100
|
+
setInterval,
|
|
101
|
+
clearInterval,
|
|
102
|
+
clear,
|
|
103
|
+
diagnostics:()=>({
|
|
104
|
+
frames:frames.size,
|
|
105
|
+
timeouts:timeouts.size,
|
|
106
|
+
intervals:intervals.size
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const objectIds = new WeakMap();
|
|
2
|
+
|
|
3
|
+
export function getAuthoringObjectId(object) {
|
|
4
|
+
if (!object?.isObject3D) return null;
|
|
5
|
+
const sidecarId = objectIds.get(object);
|
|
6
|
+
if (sidecarId) return sidecarId;
|
|
7
|
+
const legacyId = object.userData?.authoringId;
|
|
8
|
+
return typeof legacyId === 'string' && legacyId.trim() ? legacyId : null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function setAuthoringObjectId(object, id) {
|
|
12
|
+
if (!object?.isObject3D) throw new TypeError('World Authoring identity target must be an Object3D');
|
|
13
|
+
const value = String(id || '').trim();
|
|
14
|
+
if (!value) throw new TypeError('World Authoring identity requires a non-empty id');
|
|
15
|
+
objectIds.set(object, value);
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { normalizeAuthoringModelRef } from './ModelRef.js';
|
|
2
|
+
|
|
3
|
+
export function createAuthoringModelResolver({
|
|
4
|
+
assetLoader = null,
|
|
5
|
+
gltfLoader = null
|
|
6
|
+
} = {}) {
|
|
7
|
+
return async function resolveAuthoringModel(reference) {
|
|
8
|
+
const normalized = normalizeAuthoringModelRef(reference);
|
|
9
|
+
const source = normalized.source;
|
|
10
|
+
|
|
11
|
+
if (source.type === 'url') {
|
|
12
|
+
if (!gltfLoader || typeof gltfLoader.loadScene !== 'function') {
|
|
13
|
+
throw new TypeError('World Authoring URL ModelRef resolution requires a GLTF scene loader');
|
|
14
|
+
}
|
|
15
|
+
return gltfLoader.loadScene(source.uri);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!assetLoader || typeof assetLoader.instantiate !== 'function') {
|
|
19
|
+
throw new TypeError('World Authoring AssetRef resolution requires AssetLoader');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const assetId = source.assetRef.assetId;
|
|
23
|
+
const result = await assetLoader.instantiate(assetId);
|
|
24
|
+
if (!result?.object?.isObject3D) {
|
|
25
|
+
throw new TypeError(`World Authoring AssetRef resolver returned no Object3D: ${assetId}`);
|
|
26
|
+
}
|
|
27
|
+
return result.object;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
exportAuthoringDocument,
|
|
3
|
+
parseAuthoringDocument
|
|
4
|
+
} from './AuthoringDocument.js';
|
|
5
|
+
|
|
6
|
+
function clone(value) {
|
|
7
|
+
return JSON.parse(JSON.stringify(value));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function mergeObject(base, patch) {
|
|
11
|
+
if (!patch || typeof patch !== 'object' || Array.isArray(patch)) return clone(patch);
|
|
12
|
+
const result = { ...(base || {}) };
|
|
13
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
14
|
+
if (value === undefined) continue;
|
|
15
|
+
if (
|
|
16
|
+
value
|
|
17
|
+
&& typeof value === 'object'
|
|
18
|
+
&& !Array.isArray(value)
|
|
19
|
+
&& result[key]
|
|
20
|
+
&& typeof result[key] === 'object'
|
|
21
|
+
&& !Array.isArray(result[key])
|
|
22
|
+
) {
|
|
23
|
+
result[key] = mergeObject(result[key], value);
|
|
24
|
+
} else {
|
|
25
|
+
result[key] = clone(value);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function removeSubtree(state, id) {
|
|
32
|
+
if (id === state.rootId) throw new TypeError('World Authoring patch cannot remove the root');
|
|
33
|
+
const node = state.nodesById[id];
|
|
34
|
+
if (!node) throw new TypeError(`World Authoring patch node not found: ${id}`);
|
|
35
|
+
|
|
36
|
+
for (const childId of [...(state.childIdsById[id] || [])]) {
|
|
37
|
+
removeSubtree(state, childId);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const parentId = state.parentIdById[id];
|
|
41
|
+
if (parentId && state.childIdsById[parentId]) {
|
|
42
|
+
state.childIdsById[parentId] = state.childIdsById[parentId].filter(childId => childId !== id);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
delete state.nodesById[id];
|
|
46
|
+
delete state.childIdsById[id];
|
|
47
|
+
delete state.parentIdById[id];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function insertNode(state, node, parentId, index) {
|
|
51
|
+
if (!state.nodesById[parentId]) {
|
|
52
|
+
throw new TypeError(`World Authoring patch parent not found: ${parentId}`);
|
|
53
|
+
}
|
|
54
|
+
if (state.nodesById[parentId].components?.modelRef) {
|
|
55
|
+
throw new TypeError('World Authoring patch cannot add authored children to ModelRef');
|
|
56
|
+
}
|
|
57
|
+
if (!node || typeof node.id !== 'string' || !node.id) {
|
|
58
|
+
throw new TypeError('World Authoring patch added node requires an id');
|
|
59
|
+
}
|
|
60
|
+
if (state.nodesById[node.id]) {
|
|
61
|
+
throw new TypeError(`World Authoring patch duplicate node id: ${node.id}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const { children = [], ...record } = clone(node);
|
|
65
|
+
state.nodesById[node.id] = record;
|
|
66
|
+
state.parentIdById[node.id] = parentId;
|
|
67
|
+
state.childIdsById[node.id] = [];
|
|
68
|
+
|
|
69
|
+
const siblings = state.childIdsById[parentId];
|
|
70
|
+
const insertAt = Number.isInteger(index) ? Math.max(0, Math.min(index, siblings.length)) : siblings.length;
|
|
71
|
+
siblings.splice(insertAt, 0, node.id);
|
|
72
|
+
|
|
73
|
+
for (const child of children) {
|
|
74
|
+
insertNode(state, child, node.id);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function mergeResources(target, additions, label) {
|
|
79
|
+
for (const [id, definition] of Object.entries(additions || {})) {
|
|
80
|
+
if (target[id] && JSON.stringify(target[id]) !== JSON.stringify(definition)) {
|
|
81
|
+
throw new TypeError(`World Authoring patch ${label} id conflict: ${id}`);
|
|
82
|
+
}
|
|
83
|
+
target[id] = clone(definition);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function patchAuthoringDocument(document, patch = {}) {
|
|
88
|
+
const state = parseAuthoringDocument(document);
|
|
89
|
+
|
|
90
|
+
mergeResources(state.geometries, patch.geometries, 'geometry');
|
|
91
|
+
mergeResources(state.materials, patch.materials, 'material');
|
|
92
|
+
mergeResources(state.textures, patch.textures, 'texture');
|
|
93
|
+
|
|
94
|
+
for (const change of patch.update || []) {
|
|
95
|
+
if (!change || typeof change.id !== 'string') {
|
|
96
|
+
throw new TypeError('World Authoring patch update requires an id');
|
|
97
|
+
}
|
|
98
|
+
const node = state.nodesById[change.id];
|
|
99
|
+
if (!node) throw new TypeError(`World Authoring patch node not found: ${change.id}`);
|
|
100
|
+
|
|
101
|
+
const { id, ...updates } = change;
|
|
102
|
+
state.nodesById[id] = mergeObject(node, updates);
|
|
103
|
+
state.nodesById[id].id = id;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
for (const id of patch.remove || []) {
|
|
107
|
+
removeSubtree(state, id);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
for (const addition of patch.add || []) {
|
|
111
|
+
if (!addition || typeof addition.parentId !== 'string' || !addition.node) {
|
|
112
|
+
throw new TypeError('World Authoring patch add requires parentId and node');
|
|
113
|
+
}
|
|
114
|
+
insertNode(state, addition.node, addition.parentId, addition.index);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return exportAuthoringDocument(state);
|
|
118
|
+
}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { assetAdmission } from '../../modules/asset/model/admission.js';
|
|
2
|
+
import { physicsManifestForUniformScale, uniformScaleValue } from '../../modules/world/runtime/ObjectTransform.js';
|
|
3
|
+
import { capturePromotionSource, promotionError } from './AuthoringPromotionSource.js';
|
|
4
|
+
|
|
5
|
+
const clone = value => structuredClone(value);
|
|
6
|
+
const uid = prefix => `${prefix}_${globalThis.crypto.randomUUID()}`;
|
|
7
|
+
const USAGES = ['static', 'movable', 'interactive'];
|
|
8
|
+
const ACTIONS = ['pickup', 'open', 'close', 'read', 'write', 'toggle', 'turn_on', 'turn_off', 'push', 'pull'];
|
|
9
|
+
const portableState = state => {
|
|
10
|
+
const result = clone(state);
|
|
11
|
+
delete result.heldBy;
|
|
12
|
+
delete result.navigation;
|
|
13
|
+
return result;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export class AuthoringPromotionController {
|
|
17
|
+
constructor({ authoring, world, produceAsset, verify = null, verifyBehavior = null }) {
|
|
18
|
+
if (!authoring?.export || !world?.mutate || !world?.commands) throw new TypeError('Promotion requires Authoring and WorldRuntime');
|
|
19
|
+
Object.assign(this, { authoring, world, produceAsset, verify, verifyBehavior });
|
|
20
|
+
this.documentId = uid('authoring');
|
|
21
|
+
this.entries = new Map();
|
|
22
|
+
this.busy = false;
|
|
23
|
+
this.stops = [
|
|
24
|
+
world.events.on('object.removed', () => this.reconcile()),
|
|
25
|
+
world.events.on('scene.restored', () => { this.invalidateVerification(); this.reconcile(); }),
|
|
26
|
+
world.events.on('environment.replaced', () => { this.invalidateVerification(); this.reconcile(); }),
|
|
27
|
+
world.events.on('history.changed', () => this.reconcile()),
|
|
28
|
+
world.events.on('object.transformed', ({ id } = {}) => {
|
|
29
|
+
this.invalidateVerification(entry => entry.entityId === id);
|
|
30
|
+
this.reconcile();
|
|
31
|
+
})
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
invalidateVerification(predicate = null) {
|
|
36
|
+
for (const entry of this.entries.values()) {
|
|
37
|
+
if (entry.verification && (!predicate || predicate(entry))) entry.verification = null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
exportState() {
|
|
42
|
+
// Store only our instances, and keep their latest runtime pose/state for reopening.
|
|
43
|
+
const entries = [...this.entries.values()].map(entry => {
|
|
44
|
+
const saved = clone(entry);
|
|
45
|
+
const record = this.linkedRecord(entry);
|
|
46
|
+
if (record) saved.instance = {
|
|
47
|
+
position:record.object.position.toArray(), quaternion:record.object.quaternion.toArray(),
|
|
48
|
+
scale:record.physicsScale || 1,
|
|
49
|
+
// Held ownership and running navigation cannot be transferred into a partial world file.
|
|
50
|
+
initialState:portableState(record.state)
|
|
51
|
+
};
|
|
52
|
+
return saved;
|
|
53
|
+
});
|
|
54
|
+
return { version:1, documentId:this.documentId, entries };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
validateState(state) {
|
|
58
|
+
if (state == null) return;
|
|
59
|
+
if (state.version !== 1 || typeof state.documentId !== 'string' || !Array.isArray(state.entries)) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '晋升记录格式无效');
|
|
60
|
+
const nodes = new Set(), entities = new Set();
|
|
61
|
+
for (const entry of state.entries) {
|
|
62
|
+
if (!entry.nodeId || nodes.has(entry.nodeId) || !USAGES.includes(entry.usage) || !entry.assetId || !entry.sourceHash || !entry.contentHash) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '晋升记录缺少身份或存在重复节点');
|
|
63
|
+
nodes.add(entry.nodeId);
|
|
64
|
+
if (entry.entityId) {
|
|
65
|
+
if (entities.has(entry.entityId) || !entry.linkId || !entry.instance) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '晋升实体记录无效');
|
|
66
|
+
entities.add(entry.entityId);
|
|
67
|
+
const transform = entry.instance;
|
|
68
|
+
const finite = (value, size) => Array.isArray(value) && value.length === size && value.every(Number.isFinite);
|
|
69
|
+
if (!finite(transform.position, 3) || !finite(transform.quaternion, 4) || Math.hypot(...transform.quaternion) < 1e-6) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '晋升实体变换无效');
|
|
70
|
+
uniformScaleValue(transform.scale);
|
|
71
|
+
const link = transform.initialState?.authoringPromotion;
|
|
72
|
+
if (link?.documentId !== state.documentId || link?.nodeId !== entry.nodeId || link?.linkId !== entry.linkId) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '晋升实体来源关联无效');
|
|
73
|
+
if ('heldBy' in transform.initialState || 'navigation' in transform.initialState) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '创作存档不能恢复持有关系或运行中的导航');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
loadState(state = null) {
|
|
79
|
+
if (this.busy) throw promotionError('AUTHORING_PROMOTION_BUSY', '晋升操作尚未完成');
|
|
80
|
+
this.validateState(state);
|
|
81
|
+
this.documentId = state?.documentId || uid('authoring');
|
|
82
|
+
this.entries = new Map((state?.entries || []).map(entry => [entry.nodeId, clone(entry)]));
|
|
83
|
+
this.reconcile();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
linkedRecord(entry) {
|
|
87
|
+
if (!entry?.entityId || entry.worldId !== (this.world.environment?.id || null) || !this.world.store.has(entry.entityId)) return null;
|
|
88
|
+
const record = this.world.store.get(entry.entityId);
|
|
89
|
+
const link = record.state?.authoringPromotion;
|
|
90
|
+
return record.assetId === entry.assetId && link?.documentId === this.documentId && link?.linkId === entry.linkId ? record : null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
reconcile() {
|
|
94
|
+
// World undo/redo can restore an older installed revision. Adopt its provenance,
|
|
95
|
+
// not the latest editor record, without issuing another World command.
|
|
96
|
+
for (const [, record] of this.world.store.list()) {
|
|
97
|
+
const link = record.state?.authoringPromotion;
|
|
98
|
+
const entry = link && this.entries.get(link.nodeId);
|
|
99
|
+
if (entry?.entityId === record.id && link.documentId === this.documentId
|
|
100
|
+
&& entry.worldId === (this.world.environment?.id || null) && link.contentHash) {
|
|
101
|
+
if (entry.linkId !== link.linkId) entry.verification = null;
|
|
102
|
+
Object.assign(entry, { assetId:record.assetId, linkId:link.linkId, sourceHash:link.sourceHash,
|
|
103
|
+
contentHash:link.contentHash, usage:link.usage, revisionId:link.revisionId });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
this.authoring.setPromotedNodes([...this.entries.values()].filter(entry => this.linkedRecord(entry)).map(entry => entry.nodeId));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
list() {
|
|
110
|
+
this.reconcile();
|
|
111
|
+
const document = this.authoring.export();
|
|
112
|
+
const nodes = [];
|
|
113
|
+
const visit = (node, depth = 0) => {
|
|
114
|
+
if (node.id !== document.root.id) {
|
|
115
|
+
const entry = this.entries.get(node.id);
|
|
116
|
+
let source = null, reason = null;
|
|
117
|
+
try { source = capturePromotionSource(this.authoring, node.id); } catch (error) { reason = error.message; }
|
|
118
|
+
const linked = this.linkedRecord(entry);
|
|
119
|
+
let status = entry ? (entry.entityId ? (linked ? 'promoted' : 'missing') : 'prepared') : 'draft';
|
|
120
|
+
if (entry && source && source.sourceHash !== entry.sourceHash) status = linked ? 'outdated' : 'changed';
|
|
121
|
+
const admission = entry && this.world.assetModule.hasAsset(entry.assetId) ? assetAdmission(this.world.assetModule.getManifest(entry.assetId)) : null;
|
|
122
|
+
if (status === 'promoted' && admission?.status !== 'ready') status = 'editing';
|
|
123
|
+
nodes.push({ nodeId:node.id, name:node.name || node.id, depth, status, reason, usage:entry?.usage || 'static',
|
|
124
|
+
assetId:entry?.assetId || null, entityId:entry?.entityId || null,
|
|
125
|
+
admission,
|
|
126
|
+
verification:entry?.verification || null });
|
|
127
|
+
}
|
|
128
|
+
for (const child of node.children || []) visit(child, depth + 1);
|
|
129
|
+
};
|
|
130
|
+
visit(document.root, -1);
|
|
131
|
+
return nodes;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async runExclusive(operation) {
|
|
135
|
+
if (this.busy || this.fileBusy) throw promotionError('AUTHORING_PROMOTION_BUSY', '创作存档或晋升操作尚未完成');
|
|
136
|
+
this.busy = true;
|
|
137
|
+
try { return await operation(); }
|
|
138
|
+
finally { this.busy = false; this.reconcile(); this.world.events.emit('authoring.promotion.changed', {}); }
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
assertSource(source, worldId) {
|
|
142
|
+
if (worldId !== (this.world.environment?.id || null)
|
|
143
|
+
|| capturePromotionSource(this.authoring, source.nodeId).sourceHash !== source.sourceHash) {
|
|
144
|
+
throw promotionError('AUTHORING_PROMOTION_STALE', '创作对象或当前世界已改变,请重新准备');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
checkSelection(source) {
|
|
149
|
+
for (const entry of this.entries.values()) {
|
|
150
|
+
if (entry.nodeId === source.nodeId || !entry.entityId) continue;
|
|
151
|
+
const other = this.authoring.get(entry.nodeId);
|
|
152
|
+
if (!other) continue;
|
|
153
|
+
let node = source.object;
|
|
154
|
+
while (node) {
|
|
155
|
+
if (node === other) throw promotionError('AUTHORING_PROMOTION_OVERLAP', '该对象属于已晋升分组,请更新该分组');
|
|
156
|
+
node = node.parent;
|
|
157
|
+
}
|
|
158
|
+
if (source.ids.includes(entry.nodeId)) throw promotionError('AUTHORING_PROMOTION_OVERLAP', '该分组包含已晋升对象,请先解除已有晋升关联');
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async prepare(nodeId, { usage = 'static' } = {}) {
|
|
163
|
+
return this.runExclusive(async () => {
|
|
164
|
+
const source = capturePromotionSource(this.authoring, nodeId);
|
|
165
|
+
const worldId = this.world.environment?.id || null;
|
|
166
|
+
const prepared = await this.prepareSource(source, usage);
|
|
167
|
+
this.assertSource(source, worldId);
|
|
168
|
+
// Preparing a changed source must not overwrite the currently installed version.
|
|
169
|
+
const previous = this.entries.get(nodeId);
|
|
170
|
+
if (previous?.entityId) this.entries.set(nodeId, { ...previous, pending:prepared });
|
|
171
|
+
else this.entries.set(nodeId, prepared);
|
|
172
|
+
return { status:'authoring-prepared', ...clone(prepared) };
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async prepareSource(source, usage) {
|
|
177
|
+
if (!USAGES.includes(usage)) throw promotionError('AUTHORING_USAGE_INVALID', '未知的对象用途');
|
|
178
|
+
this.checkSelection(source);
|
|
179
|
+
const existing = this.entries.get(source.nodeId);
|
|
180
|
+
const cached = existing?.pending || existing;
|
|
181
|
+
let assetId;
|
|
182
|
+
if (source.reference?.source?.type === 'asset') assetId = source.reference.source.assetRef.assetId;
|
|
183
|
+
else if (cached?.contentHash === source.contentHash && cached.usage === usage) assetId = cached.assetId;
|
|
184
|
+
else {
|
|
185
|
+
if (!this.produceAsset) throw promotionError('AUTHORING_PRODUCTION_UNAVAILABLE', '创作资产生产尚未配置');
|
|
186
|
+
const produced = await this.produceAsset(source, { usage });
|
|
187
|
+
if (produced.status === 'asset-rejected') throw promotionError('AUTHORING_ASSET_REJECTED', `资产被拒绝:${produced.admission?.reasons?.join(', ') || '编译失败'}`);
|
|
188
|
+
assetId = produced.assetId;
|
|
189
|
+
}
|
|
190
|
+
if (!this.world.assetModule.hasAsset(assetId)) throw promotionError('AUTHORING_ASSET_MISSING', '正式资产不存在,请重新准备');
|
|
191
|
+
const manifest = this.world.assetModule.getManifest(assetId);
|
|
192
|
+
const admission = assetAdmission(manifest);
|
|
193
|
+
if (admission.status === 'rejected') throw promotionError('AUTHORING_ASSET_REJECTED', admission.reasons.join(', '));
|
|
194
|
+
if (usage === 'static' && manifest.physics?.body !== 'fixed') throw promotionError('AUTHORING_USAGE_MISMATCH', '该资产不是静态物件,请选择匹配的用途');
|
|
195
|
+
if (usage === 'movable' && (manifest.physics?.body !== 'dynamic' || !manifest.actions?.includes('pickup'))) throw promotionError('AUTHORING_USAGE_MISMATCH', '该资产没有动态刚体和拾取能力');
|
|
196
|
+
if (usage === 'interactive' && !manifest.actions?.some(action => ACTIONS.includes(action))) throw promotionError('AUTHORING_USAGE_MISMATCH', '该资产尚未具备可执行交互,请先完善资产能力');
|
|
197
|
+
physicsManifestForUniformScale(manifest, source.transform.scale);
|
|
198
|
+
return { nodeId:source.nodeId, name:source.name, assetId, usage, sourceHash:source.sourceHash,
|
|
199
|
+
contentHash:source.contentHash, revisionId:source.revisionId, transform:source.transform, admission };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async promote(nodeId, { usage = null, allowProvisional = false, update = false } = {}) {
|
|
203
|
+
return this.runExclusive(async () => {
|
|
204
|
+
const source = capturePromotionSource(this.authoring, nodeId);
|
|
205
|
+
const worldId = this.world.environment?.id || null;
|
|
206
|
+
const previous = this.entries.get(nodeId);
|
|
207
|
+
const linked = this.linkedRecord(previous);
|
|
208
|
+
if (linked && source.sourceHash === previous.sourceHash && (!usage || usage === previous.usage)) return {
|
|
209
|
+
status:assetAdmission(this.world.assetModule.getManifest(previous.assetId)).status === 'ready' ? 'authoring-promoted' : 'authoring-provisional', reused:true, ...clone(previous)
|
|
210
|
+
};
|
|
211
|
+
if (previous?.entityId && !update) throw promotionError('AUTHORING_UPDATE_REQUIRED', '该对象已有晋升记录,请使用更新或恢复操作');
|
|
212
|
+
if (previous?.entityId && previous.worldId !== worldId) throw promotionError('AUTHORING_WORLD_MISMATCH', '请在原目标世界中更新此对象');
|
|
213
|
+
const prepared = await this.prepareSource(source, usage || previous?.usage || 'static');
|
|
214
|
+
this.assertSource(source, worldId);
|
|
215
|
+
if (prepared.admission.status !== 'ready' && !allowProvisional) throw promotionError('AUTHORING_ASSET_PROVISIONAL', `资产仅可用于编辑态:${prepared.admission.reasons.join(', ')}`);
|
|
216
|
+
const entry = { ...prepared, worldId, entityId:previous?.entityId || uid('entity'),
|
|
217
|
+
linkId:uid('promotion'), instance:{ ...prepared.transform } };
|
|
218
|
+
entry.instance.initialState = { authoringPromotion:{ documentId:this.documentId, nodeId, linkId:entry.linkId,
|
|
219
|
+
sourceHash:source.sourceHash, contentHash:source.contentHash, usage:entry.usage, revisionId:source.revisionId } };
|
|
220
|
+
if (linked?.assetId === entry.assetId) entry.instance.initialState = {
|
|
221
|
+
...portableState(linked.state), ...entry.instance.initialState
|
|
222
|
+
};
|
|
223
|
+
const result = await this.install(entry, { previous, source, allowProvisional });
|
|
224
|
+
this.entries.set(nodeId, entry);
|
|
225
|
+
return result;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async install(entry, { previous = null, source = null, allowProvisional = false } = {}) {
|
|
230
|
+
const manifest = this.world.assetModule.getManifest(entry.assetId);
|
|
231
|
+
if (!manifest) throw promotionError('AUTHORING_ASSET_MISSING', '恢复所需的资产不存在');
|
|
232
|
+
const admission = assetAdmission(manifest);
|
|
233
|
+
if (admission.status === 'rejected' || (admission.status !== 'ready' && !allowProvisional)) throw promotionError('AUTHORING_ASSET_NOT_READY', '资产当前未通过正式准入');
|
|
234
|
+
const old = previous && this.linkedRecord(previous);
|
|
235
|
+
if (this.world.store.has(entry.entityId) && !old) throw promotionError('AUTHORING_ENTITY_CONFLICT', '目标实体 ID 已被其他对象占用');
|
|
236
|
+
if (old?.state?.heldBy) throw promotionError('AUTHORING_ENTITY_HELD', '请先放下正在持有的对象');
|
|
237
|
+
return this.world.mutate('authoring:promote', async () => {
|
|
238
|
+
if (entry.worldId !== (this.world.environment?.id || null)) throw promotionError('AUTHORING_WORLD_MISMATCH', '晋升的目标世界不匹配');
|
|
239
|
+
if (source) this.assertSource(source, entry.worldId);
|
|
240
|
+
const scaled = physicsManifestForUniformScale(manifest, entry.instance.scale);
|
|
241
|
+
let pose = this.world.physics.checkManifestPose(scaled, entry.instance.position, {
|
|
242
|
+
quaternion:entry.instance.quaternion, excludeIds:old ? [entry.entityId] : []
|
|
243
|
+
});
|
|
244
|
+
// A dynamic body authored flush with the ground is routinely reported
|
|
245
|
+
// as blocked by the environment collider alone (touching counts as a
|
|
246
|
+
// collision, and built-in objects spawn slightly above the floor).
|
|
247
|
+
// Retry once with a small lift; physics settles the body onto the
|
|
248
|
+
// ground. Static placements keep the strict check.
|
|
249
|
+
let groundLift = 0;
|
|
250
|
+
if (pose.checked && !pose.clear && entry.usage === 'movable'
|
|
251
|
+
&& pose.blockedBy?.length && pose.blockedBy.every(id => String(id).startsWith('environment:'))) {
|
|
252
|
+
const lifted = [entry.instance.position[0], entry.instance.position[1] + 0.05, entry.instance.position[2]];
|
|
253
|
+
const retry = this.world.physics.checkManifestPose(scaled, lifted, {
|
|
254
|
+
quaternion:entry.instance.quaternion, excludeIds:old ? [entry.entityId] : []
|
|
255
|
+
});
|
|
256
|
+
if (retry.checked && retry.clear) { pose = retry; groundLift = 0.05; entry.instance.position = lifted; }
|
|
257
|
+
}
|
|
258
|
+
if (pose.checked && !pose.clear) {
|
|
259
|
+
const error = promotionError('AUTHORING_PLACEMENT_BLOCKED', `放置位置发生碰撞:${pose.blockedBy?.join(', ')}`);
|
|
260
|
+
error.details = { blockedBy:(pose.blockedBy || []).slice(0, 8).map(id => String(id).slice(0, 64)) };
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
if (!pose.checked && !allowProvisional) throw promotionError('AUTHORING_PLACEMENT_UNVERIFIED', '当前物理后端无法验证该位置');
|
|
264
|
+
if (old) this.world.commands.remove(entry.entityId);
|
|
265
|
+
const spawned = await this.world.commands.spawn(entry.assetId, { id:entry.entityId, ...entry.instance });
|
|
266
|
+
if (spawned?.status === 'asset-rejected') throw promotionError('AUTHORING_ASSET_REJECTED', '资产在实例化时被拒绝');
|
|
267
|
+
if (!this.world.store.has(entry.entityId)) throw promotionError('AUTHORING_SPAWN_FAILED', '世界没有创建目标实体');
|
|
268
|
+
const physicsPosition = this.world.physics.getPosition(entry.entityId);
|
|
269
|
+
if (!physicsPosition) throw promotionError('AUTHORING_PHYSICS_FAILED', '世界实体没有物理刚体');
|
|
270
|
+
const navigation = this.world.navigation?.ensureCurrent
|
|
271
|
+
? await this.world.navigation.ensureCurrent() : { success:false, code:'NAVIGATION_UNAVAILABLE' };
|
|
272
|
+
entry.verification = { physics:{ registered:true, placement:{ ...clone(pose), ...(groundLift ? { groundLift } : {}) } },
|
|
273
|
+
navigation:clone(navigation), interaction:{ status:'not-exercised', actions:manifest.actions.filter(action => ACTIONS.includes(action)) },
|
|
274
|
+
admission:clone(admission), checkedAt:new Date().toISOString() };
|
|
275
|
+
if (this.verify) {
|
|
276
|
+
const verification = await this.verify(entry, this.world);
|
|
277
|
+
if (verification?.ok === false) throw promotionError('AUTHORING_VERIFICATION_FAILED', verification.reason || '世界行为验证失败');
|
|
278
|
+
entry.verification.behavior = clone(verification);
|
|
279
|
+
}
|
|
280
|
+
if (source) this.assertSource(source, entry.worldId);
|
|
281
|
+
return { status:admission.status === 'ready' ? 'authoring-promoted' : 'authoring-provisional', ...clone(entry) };
|
|
282
|
+
}, { source:'authoring', nodeId:entry.nodeId, documentId:this.documentId });
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async restore({ allowProvisional = false } = {}) {
|
|
286
|
+
return this.runExclusive(async () => {
|
|
287
|
+
const results = [];
|
|
288
|
+
for (const entry of this.entries.values()) {
|
|
289
|
+
if (!entry.entityId || this.linkedRecord(entry)) continue;
|
|
290
|
+
try {
|
|
291
|
+
const result = await this.install(entry, { allowProvisional });
|
|
292
|
+
results.push({ nodeId:entry.nodeId, ...result });
|
|
293
|
+
} catch (error) { results.push({ nodeId:entry.nodeId, status:'authoring-restore-failed', code:error.code, reason:error.message }); }
|
|
294
|
+
}
|
|
295
|
+
return { status:results.some(result => result.status === 'authoring-restore-failed') ? 'authoring-restore-failed' : 'authoring-restored', results };
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
async detach(nodeId) {
|
|
300
|
+
return this.runExclusive(async () => {
|
|
301
|
+
// Detaching leaves the formal entity intact; it explicitly makes the draft independent again.
|
|
302
|
+
const entry = this.entries.get(nodeId);
|
|
303
|
+
this.entries.delete(nodeId);
|
|
304
|
+
return { status:'authoring-detached', nodeId, entityId:entry?.entityId || null };
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
async verifyEntity(nodeId, { exerciseInteraction = false } = {}) {
|
|
309
|
+
return this.runExclusive(async () => {
|
|
310
|
+
const entry = this.entries.get(nodeId);
|
|
311
|
+
const record = this.linkedRecord(entry);
|
|
312
|
+
if (!record) throw promotionError('AUTHORING_ENTITY_MISSING', '请先恢复或晋升该对象');
|
|
313
|
+
const manifest = this.world.assetModule.getManifest(entry.assetId);
|
|
314
|
+
const actions = manifest.actions.filter(action => ACTIONS.includes(action));
|
|
315
|
+
let interaction = { status:actions.length ? 'not-exercised' : 'not-applicable', actions };
|
|
316
|
+
if (exerciseInteraction && actions.length) {
|
|
317
|
+
if (!this.verifyBehavior) throw promotionError('AUTHORING_VERIFIER_UNAVAILABLE', '当前宿主没有配置行为验证器');
|
|
318
|
+
try { interaction = { ...interaction, ...await this.verifyBehavior(entry, this.world) }; }
|
|
319
|
+
catch (error) { interaction = { ...interaction, status:'failed', reason:error.code || error.message }; }
|
|
320
|
+
}
|
|
321
|
+
if (!this.linkedRecord(entry)) throw promotionError('AUTHORING_VERIFICATION_STALE', '验证过程中目标实体发生变化');
|
|
322
|
+
const pose = this.world.physics.checkManifestPose(physicsManifestForUniformScale(manifest, record.physicsScale || 1), record.object.position.toArray(), {
|
|
323
|
+
quaternion:record.object.quaternion.toArray(), excludeIds:[entry.entityId]
|
|
324
|
+
});
|
|
325
|
+
const navigation = await this.world.navigation?.ensureCurrent?.() || { success:false, code:'NAVIGATION_UNAVAILABLE' };
|
|
326
|
+
entry.verification = { physics:{ registered:Boolean(this.world.physics.getPosition(entry.entityId)), placement:pose },
|
|
327
|
+
navigation:clone(navigation), interaction:clone(interaction), admission:assetAdmission(manifest), checkedAt:new Date().toISOString() };
|
|
328
|
+
const verified = pose.checked && pose.clear && navigation.success && ['verified', 'not-applicable'].includes(interaction.status);
|
|
329
|
+
return { status:verified ? 'authoring-verified' : 'authoring-unverified', nodeId, entityId:entry.entityId, verification:clone(entry.verification) };
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
dispose() { for (const stop of this.stops) stop(); this.authoring.setPromotedNodes([]); }
|
|
334
|
+
}
|