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,503 @@
|
|
|
1
|
+
import { assetAdmission } from '../../asset/model/admission.js';
|
|
2
|
+
import { physicsManifestForUniformScale } from './ObjectTransform.js';
|
|
3
|
+
import { samePhysicalGeometry } from './WorldCollisionSignature.js';
|
|
4
|
+
|
|
5
|
+
const round3 = (value) => Number(value.toFixed(3));
|
|
6
|
+
const vec3Round = (value) => Array.isArray(value) ? value.map(round3) : value;
|
|
7
|
+
const yawFromQuat = ([x, y, z, w]) => Math.atan2(2 * (w * y + x * z), 1 - 2 * (y * y + z * z));
|
|
8
|
+
|
|
9
|
+
export class WorldCommands {
|
|
10
|
+
constructor(runtime) {
|
|
11
|
+
if (!runtime) throw new TypeError('WorldCommands requires a WorldRuntime');
|
|
12
|
+
this.runtime = runtime;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
assertReady(command, batch) {
|
|
16
|
+
this.runtime.assertWritable?.(batch);
|
|
17
|
+
if (this.runtime.ready !== false) return;
|
|
18
|
+
const assembled = this.runtime.sceneGraph
|
|
19
|
+
&& this.runtime.history
|
|
20
|
+
&& this.runtime.navigation
|
|
21
|
+
&& this.runtime.locomotion
|
|
22
|
+
&& this.runtime.interactions;
|
|
23
|
+
if (assembled) return;
|
|
24
|
+
const error = new Error(`World command requires an initialized WorldRuntime: ${command}`);
|
|
25
|
+
error.code = 'WORLD_COMMAND_NOT_READY';
|
|
26
|
+
error.command = command;
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async spawn(assetId, options = {}) {
|
|
31
|
+
this.assertReady('spawn');
|
|
32
|
+
const admission = assetAdmission(this.runtime.assetModule.getManifest(assetId));
|
|
33
|
+
if (admission.status === 'rejected') {
|
|
34
|
+
return { status:'asset-rejected', assetId, admission };
|
|
35
|
+
}
|
|
36
|
+
const id = await this.runtime.spawn(assetId, options);
|
|
37
|
+
return admission.status === 'ready'
|
|
38
|
+
? id
|
|
39
|
+
: { status:'asset-provisional', id, assetId, admission };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async replaceAsset(id, assetId, batch = null) {
|
|
43
|
+
this.assertReady('replaceAsset', batch);
|
|
44
|
+
const record=this.runtime.store.get(id);
|
|
45
|
+
if(record.state?.heldBy)throw Object.assign(new Error('Put down the object before upgrading its asset'),{code:'ASSET_INSTANCE_HELD'});
|
|
46
|
+
if(record.manifest.type==='agent')throw Object.assign(new Error('Agent embodiment upgrades are not supported'),{code:'ASSET_UPGRADE_AGENT_UNSUPPORTED'});
|
|
47
|
+
const manifest=this.runtime.assetModule.getManifest(assetId);
|
|
48
|
+
if(assetAdmission(manifest).status!=='ready')throw Object.assign(new Error('Asset is not ready'),{code:'ASSET_NOT_READY'});
|
|
49
|
+
const pose={id,position:record.object.position.toArray(),quaternion:record.object.quaternion.toArray(),scale:record.object.scale.x};
|
|
50
|
+
const previousAssetId=record.assetId;
|
|
51
|
+
return this.runtime.mutate('asset:replace',async()=>{
|
|
52
|
+
// An identical collider/joint layout preserves legitimate resting contacts; new physics is still registered.
|
|
53
|
+
const sameCollision=samePhysicalGeometry(manifest,record.manifest);
|
|
54
|
+
const check=sameCollision || manifest.capabilityLevel==='visual'?{checked:true,clear:true}:this.runtime.physics.checkManifestPose(physicsManifestForUniformScale(manifest,pose.scale),pose.position,{quaternion:pose.quaternion,excludeIds:[id]});
|
|
55
|
+
if(!check.checked||!check.clear)throw Object.assign(new Error('New asset does not fit at the current pose'),{code:'ASSET_UPGRADE_PLACEMENT_BLOCKED'});
|
|
56
|
+
this.remove(id,{replacing:true});await this.spawn(assetId,pose);
|
|
57
|
+
const navigation=await this.runtime.navigation.ensureCurrent();
|
|
58
|
+
if(!navigation.success || (manifest.capabilityLevel!=='visual' && !this.runtime.physics.getPosition(id)))throw Object.assign(new Error('New entity failed runtime registration'),{code:'ASSET_UPGRADE_FAILED'});
|
|
59
|
+
return {status:'asset-instance-updated',id,assetId,previousAssetId,stateReset:true};
|
|
60
|
+
}, {}, {batch});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
transform(id, transform = {}, options = {}) {
|
|
64
|
+
this.assertReady('transform');
|
|
65
|
+
if (this.runtime.store.get(id).state?.heldBy || this.runtime.interactions?.isHeld?.(id) || this.runtime.interactions?.carry?.agentHeld?.has(id)) throw Object.assign(new Error('Put down the object before editing'), { code: 'OBJECT_HELD' });
|
|
66
|
+
return this.runtime.applyObjectTransform(id, transform, options);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
beginTransform(id) {
|
|
70
|
+
this.assertReady('beginTransform');
|
|
71
|
+
if (this.runtime.store.get(id).state?.heldBy || this.runtime.interactions?.isHeld?.(id) || this.runtime.interactions?.carry?.agentHeld?.has(id)) throw Object.assign(new Error('Put down the object before editing'), { code: 'OBJECT_HELD' });
|
|
72
|
+
return this.runtime.physics.beginTransform(id);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
endTransform(id) {
|
|
76
|
+
this.assertReady('endTransform');
|
|
77
|
+
return this.runtime.physics.endTransform(id);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setHumanViewPose(pose) {
|
|
81
|
+
this.assertReady('setHumanViewPose');
|
|
82
|
+
return this.runtime.interactions.setHumanViewPose(pose);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async duplicate(id) {
|
|
86
|
+
this.assertReady('duplicate');
|
|
87
|
+
const source = this.runtime.store.get(id);
|
|
88
|
+
const assetId = source.assetId;
|
|
89
|
+
const admission = assetAdmission(this.runtime.assetModule.getManifest(assetId));
|
|
90
|
+
if (admission.status === 'rejected') {
|
|
91
|
+
return { status:'asset-rejected', assetId, sourceId:id, admission };
|
|
92
|
+
}
|
|
93
|
+
const duplicateId = await this.runtime.duplicate(id);
|
|
94
|
+
return admission.status === 'ready'
|
|
95
|
+
? duplicateId
|
|
96
|
+
: { status:'asset-provisional', id:duplicateId, assetId, sourceId:id, admission };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
remove(id, options = {}) {
|
|
100
|
+
this.assertReady('remove');
|
|
101
|
+
if (this.runtime.store.get(id).state?.heldBy || this.runtime.interactions?.isHeld?.(id) || this.runtime.interactions?.carry?.agentHeld?.has(id)) throw Object.assign(new Error('Put down the object before editing'), { code: 'OBJECT_HELD' });
|
|
102
|
+
return this.runtime.remove(id, options);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
navigate(id, end, options = {}) {
|
|
106
|
+
this.assertReady('navigate');
|
|
107
|
+
return this.runtime.locomotion.navigate(id, end, options);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async moveForward(id, { distance = 0.8, speed } = {}) {
|
|
111
|
+
this.assertReady('moveForward');
|
|
112
|
+
if (!this.runtime.store?.has?.(id)) {
|
|
113
|
+
const error = new Error(`Object not found: ${id}`);
|
|
114
|
+
error.code = 'OBJECT_NOT_FOUND';
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
if (!Number.isFinite(distance) || distance <= 0 || distance > 4) {
|
|
118
|
+
const error = new Error('moveForward distance must be within (0, 4]');
|
|
119
|
+
error.code = 'MOVE_FORWARD_DISTANCE_INVALID';
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
const record = this.runtime.store.get(id);
|
|
123
|
+
if (record.manifest?.type !== 'agent' || !record.manifest.actions?.includes('navigate')) {
|
|
124
|
+
const error = new Error(`Object is not a navigable agent: ${id}`);
|
|
125
|
+
error.code = 'NOT_NAVIGABLE_AGENT';
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
if (record.manifest.physics?.body !== 'kinematic') {
|
|
129
|
+
const error = new Error(`Navigable agent must use a kinematic body: ${id}`);
|
|
130
|
+
error.code = 'NAVIGABLE_BODY_INVALID';
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
const start = this.runtime.physics?.getPosition?.(id);
|
|
134
|
+
if (!start) {
|
|
135
|
+
const error = new Error(`Physics body not available: ${id}`);
|
|
136
|
+
error.code = 'PHYSICS_BODY_UNAVAILABLE';
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
const rotation = this.runtime.physics?.getRotation?.(id);
|
|
140
|
+
if (!Array.isArray(rotation) || rotation.length !== 4 || !rotation.every(Number.isFinite)) {
|
|
141
|
+
const error = new Error(`Agent rotation unavailable: ${id}`);
|
|
142
|
+
error.code = 'AGENT_ROTATION_UNAVAILABLE';
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
const yaw = yawFromQuat(rotation);
|
|
146
|
+
// 与 LocomotionSystem.steer 的 character facing 一致:[-sin(yaw), 0, -cos(yaw)]
|
|
147
|
+
const forward = [-Math.sin(yaw), 0, -Math.cos(yaw)];
|
|
148
|
+
const end = [
|
|
149
|
+
start[0] + forward[0] * distance,
|
|
150
|
+
start[1],
|
|
151
|
+
start[2] + forward[2] * distance
|
|
152
|
+
];
|
|
153
|
+
const result = await this.runtime.locomotion.navigate(id, end, { speed });
|
|
154
|
+
const position = Array.isArray(result?.position) ? result.position : null;
|
|
155
|
+
const moved = position
|
|
156
|
+
? Math.hypot(position[0] - start[0], position[2] - start[2])
|
|
157
|
+
: (result?.status === 'arrived' ? distance : 0);
|
|
158
|
+
const base = {
|
|
159
|
+
...result,
|
|
160
|
+
skill: 'moveForward',
|
|
161
|
+
start: vec3Round(start),
|
|
162
|
+
end: vec3Round(end),
|
|
163
|
+
distance,
|
|
164
|
+
yaw: round3(yaw),
|
|
165
|
+
forward: vec3Round(forward),
|
|
166
|
+
moved: round3(moved)
|
|
167
|
+
};
|
|
168
|
+
if (result?.status === 'arrived' && moved < Math.max(0.05, distance * 0.35)) {
|
|
169
|
+
return {
|
|
170
|
+
...base,
|
|
171
|
+
status: 'blocked',
|
|
172
|
+
reason: 'INSUFFICIENT_FORWARD_DISPLACEMENT'
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return base;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
activateEnvironmentInteraction(interactionId, { actorId = null, requireReach = true } = {}) {
|
|
179
|
+
this.assertReady('activateEnvironmentInteraction');
|
|
180
|
+
const runtime = this.runtime;
|
|
181
|
+
const interactions = runtime.environment?.interactions || [];
|
|
182
|
+
const item = interactions.find((entry) => entry.id === interactionId);
|
|
183
|
+
if (!item) {
|
|
184
|
+
return { status:'interaction-not-found', interactionId, environmentId:runtime.environment?.id || null };
|
|
185
|
+
}
|
|
186
|
+
if (typeof item.activate !== 'function') {
|
|
187
|
+
return { status:'interaction-not-executable', interactionId, label:item.label || null };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const position = (() => {
|
|
191
|
+
const object = item.object;
|
|
192
|
+
if (!object) return null;
|
|
193
|
+
if (object.isObject3D) {
|
|
194
|
+
object.updateWorldMatrix?.(true, false);
|
|
195
|
+
const elements = object.matrixWorld?.elements;
|
|
196
|
+
if (elements) return [elements[12], elements[13], elements[14]];
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
})();
|
|
200
|
+
|
|
201
|
+
// Formally declared actions use the contract's own reach and postcondition checks.
|
|
202
|
+
// Native object pivots are not authoritative interaction target positions.
|
|
203
|
+
if (item.contractId) {
|
|
204
|
+
const contract = runtime.affordances?.get?.(item.contractId);
|
|
205
|
+
if (contract) {
|
|
206
|
+
const state = contract.read?.() || {};
|
|
207
|
+
let action = null;
|
|
208
|
+
if (contract.kind === 'book') action = state.out ? 'return' : 'pull_out';
|
|
209
|
+
else if (contract.kind === 'switch') action = state.on ? 'turn_off' : 'turn_on';
|
|
210
|
+
else if (state.requestedOpen === true || state.out === true) action = 'close';
|
|
211
|
+
else if (state.requestedOpen === false || state.out === false) action = 'open';
|
|
212
|
+
if (action && contract.actions?.includes(action)) {
|
|
213
|
+
const response = runtime.affordances.execute({ targetId:item.contractId, action, actorId }, {});
|
|
214
|
+
const withNativeId = value => value?.status === 'world-action-blocked'
|
|
215
|
+
? { ...value, interactionId } : value;
|
|
216
|
+
return response?.then ? response.then(withNativeId) : withNativeId(response);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (requireReach && actorId) {
|
|
222
|
+
const feet = runtime.physics?.getPosition?.(actorId);
|
|
223
|
+
if (!feet) {
|
|
224
|
+
return { status:'world-action-blocked', interactionId, reason:'ACTOR_PHYSICS_UNAVAILABLE', actorId };
|
|
225
|
+
}
|
|
226
|
+
if (!position) {
|
|
227
|
+
return { status:'world-action-blocked', interactionId, reason:'INTERACTION_POSITION_UNAVAILABLE', actorId };
|
|
228
|
+
}
|
|
229
|
+
const distance = Math.hypot(position[0]-feet[0], position[1]-feet[1], position[2]-feet[2]);
|
|
230
|
+
if (distance > 1.5) {
|
|
231
|
+
return {
|
|
232
|
+
status:'world-action-blocked', interactionId, reason:'OUT_OF_REACH',
|
|
233
|
+
actorId, distance:round3(distance), maxDistance:1.5, position:vec3Round(position)
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
if (runtime.physics?.hasCapability?.('scene-query') && runtime.physics.raycast) {
|
|
237
|
+
const origin = [feet[0], feet[1] + 1.2, feet[2]];
|
|
238
|
+
const hit = runtime.physics.raycast(origin, position, { excludeId: actorId });
|
|
239
|
+
if (hit && hit.distance < distance - 0.12) {
|
|
240
|
+
return {
|
|
241
|
+
status:'world-action-blocked', interactionId, reason:'OCCLUDED',
|
|
242
|
+
actorId, blocker:hit.provenance || { id:hit.id }, distance:round3(distance)
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
item.activate();
|
|
249
|
+
return {
|
|
250
|
+
status:'environment-interaction-activated',
|
|
251
|
+
interactionId,
|
|
252
|
+
label:item.label || null,
|
|
253
|
+
contractId:item.contractId || null,
|
|
254
|
+
environmentId:runtime.environment?.id || null,
|
|
255
|
+
position:vec3Round(position),
|
|
256
|
+
via:'native-activate',
|
|
257
|
+
provisional:true,
|
|
258
|
+
verification:'native-provisional',
|
|
259
|
+
evidenceKind:'animated-transform',
|
|
260
|
+
physicsVerified:false,
|
|
261
|
+
note:'Native Three.js scene interaction; not force-verified articulated asset physics.'
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
async resolveEnvironmentApproach(target, start, { radii = [0.9, 1.2, 1.5, 1.8], samples = 16, maxSnapDistance = 0.75 } = {}) {
|
|
266
|
+
const runtime = this.runtime;
|
|
267
|
+
const navigation = runtime.navigation;
|
|
268
|
+
if (!navigation?.findPath || !Array.isArray(target) || !Array.isArray(start)) {
|
|
269
|
+
return { reachable:false, reason:'NAVIGATION_UNAVAILABLE', candidates:0 };
|
|
270
|
+
}
|
|
271
|
+
// 整圈采样,不按 agent 距离排序:门关着时「朝 agent」可能是屋内侧,会系统性打偏。
|
|
272
|
+
const candidates = [];
|
|
273
|
+
for (const radius of radii) {
|
|
274
|
+
for (let i = 0; i < samples; i += 1) {
|
|
275
|
+
const angle = (i / samples) * Math.PI * 2;
|
|
276
|
+
candidates.push([target[0] + Math.sin(angle)*radius, target[1], target[2] + Math.cos(angle)*radius]);
|
|
277
|
+
}
|
|
278
|
+
// 明确加轴向外点(门通常有一侧是可站立室外)
|
|
279
|
+
candidates.push([target[0] + radius, target[1], target[2]]);
|
|
280
|
+
candidates.push([target[0] - radius, target[1], target[2]]);
|
|
281
|
+
candidates.push([target[0], target[1], target[2] + radius]);
|
|
282
|
+
candidates.push([target[0], target[1], target[2] - radius]);
|
|
283
|
+
}
|
|
284
|
+
const tried = [];
|
|
285
|
+
const budget = Math.min(candidates.length, 28);
|
|
286
|
+
for (let index = 0; index < budget; index += 1) {
|
|
287
|
+
const end = candidates[index];
|
|
288
|
+
const route = await navigation.findPath(start, end, { maxSnapDistance, endTolerance: 0.6 });
|
|
289
|
+
tried.push({ end: vec3Round(end), reachable: route?.reachable === true, reason: route?.reason || null, cost: route?.cost ?? null });
|
|
290
|
+
if (route?.reachable) {
|
|
291
|
+
return { reachable:true, end, route, tried, candidates:candidates.length };
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return { reachable:false, reason:'NO_APPROACH_POSE', tried, candidates:candidates.length };
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async findEnvironmentInteractApproach(interactionId, { actorId = null } = {}) {
|
|
298
|
+
this.assertReady('findEnvironmentInteractApproach');
|
|
299
|
+
const runtime = this.runtime;
|
|
300
|
+
const item = (runtime.environment?.interactions || []).find((entry) => entry.id === interactionId);
|
|
301
|
+
if (!item) return { status:'interaction-not-found', interactionId };
|
|
302
|
+
const target = (() => {
|
|
303
|
+
const object = item.object;
|
|
304
|
+
if (!object?.isObject3D) return null;
|
|
305
|
+
object.updateWorldMatrix?.(true, false);
|
|
306
|
+
const elements = object.matrixWorld?.elements;
|
|
307
|
+
return elements ? [elements[12], elements[13], elements[14]] : null;
|
|
308
|
+
})();
|
|
309
|
+
if (!target) return { status:'interaction-position-unavailable', interactionId };
|
|
310
|
+
const start = actorId ? runtime.physics?.getPosition?.(actorId) : null;
|
|
311
|
+
if (!start) return { status:'actor-required-or-unavailable', interactionId, actorId };
|
|
312
|
+
const approach = await this.resolveEnvironmentApproach(target, start);
|
|
313
|
+
return {
|
|
314
|
+
status: approach.reachable ? 'approach-ready' : 'approach-unreachable',
|
|
315
|
+
interactionId,
|
|
316
|
+
label:item.label || null,
|
|
317
|
+
contractId:item.contractId || null,
|
|
318
|
+
actorId,
|
|
319
|
+
start:vec3Round(start),
|
|
320
|
+
target:vec3Round(target),
|
|
321
|
+
approach: approach.reachable ? vec3Round(approach.end) : null,
|
|
322
|
+
distance: round3(Math.hypot(target[0]-start[0], target[1]-start[1], target[2]-start[2])),
|
|
323
|
+
reason: approach.reachable ? null : (approach.reason || 'NO_APPROACH_POSE'),
|
|
324
|
+
tried: approach.tried || []
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
async approachAndActivateEnvironmentInteract(interactionId, { actorId = null, speed } = {}) {
|
|
329
|
+
this.assertReady('approachAndActivateEnvironmentInteract');
|
|
330
|
+
const runtime = this.runtime;
|
|
331
|
+
const skill = 'approachAndActivateEnvironmentInteract';
|
|
332
|
+
const item = (runtime.environment?.interactions || []).find((entry) => entry.id === interactionId);
|
|
333
|
+
if (!item) {
|
|
334
|
+
return { status:'interaction-not-found', skill, interactionId, environmentId:runtime.environment?.id || null };
|
|
335
|
+
}
|
|
336
|
+
if (typeof item.activate !== 'function') {
|
|
337
|
+
return { status:'interaction-not-executable', skill, interactionId, label:item.label || null };
|
|
338
|
+
}
|
|
339
|
+
if (!actorId) {
|
|
340
|
+
return { status:'actor-required', skill, interactionId };
|
|
341
|
+
}
|
|
342
|
+
const start = runtime.physics?.getPosition?.(actorId);
|
|
343
|
+
if (!start) {
|
|
344
|
+
return { status:'world-action-blocked', skill, interactionId, reason:'ACTOR_PHYSICS_UNAVAILABLE', actorId };
|
|
345
|
+
}
|
|
346
|
+
const target = (() => {
|
|
347
|
+
const object = item.object;
|
|
348
|
+
if (!object?.isObject3D) return null;
|
|
349
|
+
object.updateWorldMatrix?.(true, false);
|
|
350
|
+
const elements = object.matrixWorld?.elements;
|
|
351
|
+
return elements ? [elements[12], elements[13], elements[14]] : null;
|
|
352
|
+
})();
|
|
353
|
+
if (!target) {
|
|
354
|
+
return { status:'world-action-blocked', skill, interactionId, reason:'INTERACTION_POSITION_UNAVAILABLE', actorId };
|
|
355
|
+
}
|
|
356
|
+
const distanceToTarget = Math.hypot(target[0]-start[0], target[1]-start[1], target[2]-start[2]);
|
|
357
|
+
if (distanceToTarget <= 1.5) {
|
|
358
|
+
const activation = await this.activateEnvironmentInteraction(interactionId, { actorId });
|
|
359
|
+
runtime.navigation?.invalidate?.('environment-interaction-activated');
|
|
360
|
+
const navigationBuild = runtime.navigation?.ensureBuilt ? await runtime.navigation.ensureBuilt() : null;
|
|
361
|
+
return {
|
|
362
|
+
...activation,
|
|
363
|
+
skill, phase:'activated', start:vec3Round(start), target:vec3Round(target),
|
|
364
|
+
distance:round3(distanceToTarget), navigated:false,
|
|
365
|
+
navigationInvalidated:true,
|
|
366
|
+
navigationBuild: navigationBuild ? { success:navigationBuild.success === true, buildVersion:navigationBuild.buildVersion ?? null, code:navigationBuild.code || null } : null,
|
|
367
|
+
nextStepHint:item.contractId
|
|
368
|
+
? 'NavMesh rebuilt after door/path change; call navigateTo/findPath on a fresh planning round before entering or climbing.'
|
|
369
|
+
: 'Native activation does not rebuild NavMesh by itself.'
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
const approach = await this.resolveEnvironmentApproach(target, start);
|
|
373
|
+
if (!approach.reachable) {
|
|
374
|
+
return {
|
|
375
|
+
status:'unreachable',
|
|
376
|
+
skill,
|
|
377
|
+
interactionId,
|
|
378
|
+
label:item.label || null,
|
|
379
|
+
actorId,
|
|
380
|
+
start:vec3Round(start),
|
|
381
|
+
target:vec3Round(target),
|
|
382
|
+
distance:round3(distanceToTarget),
|
|
383
|
+
reason:approach.reason || 'NO_PATH_TO_ENVIRONMENT_INTERACTION',
|
|
384
|
+
tried:approach.tried || []
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
const end = approach.end;
|
|
388
|
+
const navResult = await runtime.locomotion.navigate(actorId, end, { speed });
|
|
389
|
+
if (navResult?.status !== 'arrived') {
|
|
390
|
+
return {
|
|
391
|
+
...navResult,
|
|
392
|
+
skill,
|
|
393
|
+
phase:'approach',
|
|
394
|
+
interactionId,
|
|
395
|
+
label:item.label || null,
|
|
396
|
+
target:vec3Round(target),
|
|
397
|
+
approach:vec3Round(end)
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
const activation = await this.activateEnvironmentInteraction(interactionId, { actorId });
|
|
401
|
+
runtime.navigation?.invalidate?.('environment-interaction-activated');
|
|
402
|
+
// 门/路径类原生交互后立刻重建 NavMesh,避免下一轮 navigateTo 仍打在关门烘焙结果上。
|
|
403
|
+
const navigationBuild = runtime.navigation?.ensureBuilt ? await runtime.navigation.ensureBuilt() : null;
|
|
404
|
+
return {
|
|
405
|
+
...activation,
|
|
406
|
+
skill,
|
|
407
|
+
phase:'activated',
|
|
408
|
+
start:vec3Round(start),
|
|
409
|
+
approach:vec3Round(end),
|
|
410
|
+
target:vec3Round(target),
|
|
411
|
+
navigated:true,
|
|
412
|
+
navigationInvalidated:true,
|
|
413
|
+
navigationBuild: navigationBuild ? { success:navigationBuild.success === true, buildVersion:navigationBuild.buildVersion ?? null, code:navigationBuild.code || null } : null,
|
|
414
|
+
nextStepHint:item.contractId
|
|
415
|
+
? 'NavMesh rebuilt after door/path change; fresh replan then navigateTo/findPath before entering or going upstairs.'
|
|
416
|
+
: 'Native activation does not rebuild NavMesh by itself.'
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
pickup(id) {
|
|
421
|
+
this.assertReady('pickup');
|
|
422
|
+
return this.runtime.interactions.pickup(id);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
drop(id) {
|
|
426
|
+
this.assertReady('drop');
|
|
427
|
+
return this.runtime.interactions.drop(id);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
place(id, targetId, options = {}) {
|
|
431
|
+
this.assertReady('place');
|
|
432
|
+
return this.runtime.interactions.place(id, targetId, options);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
setArticulationAction(id, action, options = {}) {
|
|
436
|
+
this.assertReady('setArticulationAction');
|
|
437
|
+
return this.runtime.interactions.setArticulationAction(id, action, options);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
approachAndInteract(actorId, targetId, action, options = {}) {
|
|
441
|
+
this.assertReady('approachAndInteract');
|
|
442
|
+
return this.runtime.interactions.approachAndInteract(actorId, targetId, action, options);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
approachAndPickup(actorId, targetId, options = {}) {
|
|
446
|
+
this.assertReady('approachAndPickup');
|
|
447
|
+
return this.runtime.interactions.approachAndPickup(actorId, targetId, options);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
approachAndPlace(actorId, supportId, options = {}) {
|
|
451
|
+
this.assertReady('approachAndPlace');
|
|
452
|
+
return this.runtime.interactions.approachAndPlace(actorId, supportId, options);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
dropHeld(actorId) {
|
|
456
|
+
this.assertReady('dropHeld');
|
|
457
|
+
return this.runtime.interactions.dropHeld(actorId);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
markRecoveryHeld(actorId, details) {
|
|
461
|
+
this.assertReady('markRecoveryHeld');
|
|
462
|
+
return this.runtime.interactions.markRecoveryHeld(actorId, details);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
cleanupRecoveryBlocker(actorId, targetId, options = {}) {
|
|
466
|
+
this.assertReady('cleanupRecoveryBlocker');
|
|
467
|
+
return this.runtime.interactions.cleanupRecoveryBlocker(actorId, targetId, options);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
applyStateTransition(id, stateKey, value, meta = {}) {
|
|
471
|
+
this.assertReady('applyStateTransition');
|
|
472
|
+
return this.runtime.applyStateTransition(id, stateKey, value, meta);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
executeAffordance(args = {}, options = {}) {
|
|
476
|
+
this.assertReady('executeAffordance');
|
|
477
|
+
return options.approach ? this.runtime.affordances.approachAndExecute(args) : this.runtime.affordances.execute(args, options);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
repair(report, options = {}) {
|
|
481
|
+
this.assertReady('repair');
|
|
482
|
+
return this.runtime.repair.repair(report, options);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
syncAssetVerification(assetId, manifest) {
|
|
486
|
+
let updated = 0;
|
|
487
|
+
for (const record of this.runtime.store?.values?.() || []) {
|
|
488
|
+
if (record.assetId !== assetId) continue;
|
|
489
|
+
record.manifest.verification = structuredClone(manifest.verification || {});
|
|
490
|
+
if (manifest.compiler?.quality && record.manifest.compiler) {
|
|
491
|
+
record.manifest.compiler.quality = structuredClone(manifest.compiler.quality);
|
|
492
|
+
}
|
|
493
|
+
if (record.object?.userData?.manifest) {
|
|
494
|
+
record.object.userData.manifest.verification = structuredClone(record.manifest.verification);
|
|
495
|
+
if (record.manifest.compiler?.quality && record.object.userData.manifest.compiler) {
|
|
496
|
+
record.object.userData.manifest.compiler.quality = structuredClone(record.manifest.compiler.quality);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
updated += 1;
|
|
500
|
+
}
|
|
501
|
+
return { status:'asset-verification-synced', assetId, instances:updated };
|
|
502
|
+
}
|
|
503
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const clone = (value) => value == null ? value : structuredClone(value);
|
|
2
|
+
|
|
3
|
+
export class WorldObservation {
|
|
4
|
+
constructor(runtime) {
|
|
5
|
+
this.runtime = runtime;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
hasObject(id) {
|
|
9
|
+
return Boolean(id && this.runtime.store?.has(id));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
object(id) {
|
|
13
|
+
if (!this.hasObject(id)) return null;
|
|
14
|
+
const record = this.runtime.store.get(id);
|
|
15
|
+
const position = this.runtime.physics?.getPosition?.(id) || record.object?.position?.toArray?.() || null;
|
|
16
|
+
return {
|
|
17
|
+
id,
|
|
18
|
+
asset: record.assetId,
|
|
19
|
+
type: record.manifest?.type,
|
|
20
|
+
position: Array.isArray(position) ? [...position] : null
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
relations(ids = [], { limit = 8 } = {}) {
|
|
25
|
+
if (!this.runtime.sceneGraph || !ids.length) return [];
|
|
26
|
+
this.runtime.sceneGraph.update();
|
|
27
|
+
const relevant = new Set(ids);
|
|
28
|
+
const edges = [];
|
|
29
|
+
for (const edge of this.runtime.sceneGraph.list()) {
|
|
30
|
+
if (!relevant.has(edge.subject) && !relevant.has(edge.object)) continue;
|
|
31
|
+
edges.push(clone(edge));
|
|
32
|
+
if (edges.length >= limit) break;
|
|
33
|
+
}
|
|
34
|
+
return edges;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
actor(id) {
|
|
38
|
+
const object = this.object(id);
|
|
39
|
+
if (!object) return null;
|
|
40
|
+
return {
|
|
41
|
+
id,
|
|
42
|
+
position: object.position,
|
|
43
|
+
navigation: this.runtime.locomotion?.status?.(id) || null,
|
|
44
|
+
carry: this.runtime.interactions?.carryStatus?.(id) || null
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
affordances(ids = [], { actorId = null } = {}) {
|
|
49
|
+
const runtimeAffordances = this.runtime.affordances;
|
|
50
|
+
if (!runtimeAffordances?.list) return null;
|
|
51
|
+
const listing = runtimeAffordances.list({ actorId, limit:1 });
|
|
52
|
+
if (!listing.total) return null;
|
|
53
|
+
return {
|
|
54
|
+
count: listing.total,
|
|
55
|
+
lastResult: clone(runtimeAffordances.lastResult || null),
|
|
56
|
+
focus: ids.map((id) => runtimeAffordances.inspect(id, { actorId })).filter(Boolean)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
articulation(id) {
|
|
61
|
+
if (!this.hasObject(id)) return null;
|
|
62
|
+
const parts = this.runtime.store.get(id).manifest?.parts || {};
|
|
63
|
+
const supported = Object.values(parts).some((part) => part?.joint && part?.physics && part.joint.type !== 'fixed');
|
|
64
|
+
if (!supported || !this.runtime.interactions?.articulationStatus) return null;
|
|
65
|
+
try {
|
|
66
|
+
return clone(this.runtime.interactions.articulationStatus(id));
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|