agentscape3d 1.0.0-beta.1 → 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 -21
- package/README.md +23 -48
- package/dist/core.d.ts +68 -0
- package/dist/core.js +209 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +10 -229
- package/dist/index.js +192 -15462
- package/dist/index.js.map +1 -1
- package/package.json +16 -40
- package/cli.mjs +0 -27
- package/dist/AssetCompiler-CDFiElji.js +0 -2451
- package/dist/AssetCompiler-CDFiElji.js.map +0 -1
- package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
- package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
- package/dist/AssetRecipe-DmFpzxr-.js +0 -55
- package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
- package/dist/BrowserCodeWorker.js +0 -53615
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
- package/dist/SceneSerializer-DPVOyeRk.js +0 -353
- package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
- package/dist/StylePack-DNrdLeGI.js +0 -6314
- package/dist/StylePack-DNrdLeGI.js.map +0 -1
- package/dist/WorldArchive-pSBIGxLa.js +0 -420
- package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
- package/dist/WorldIO-wsDfZGM4.js +0 -150
- package/dist/WorldIO-wsDfZGM4.js.map +0 -1
- package/dist/blankWorld-CBWbwJGj.js +0 -76
- package/dist/blankWorld-CBWbwJGj.js.map +0 -1
- package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
- package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
- package/dist/environments-DgH66NqV.js +0 -4220
- package/dist/environments-DgH66NqV.js.map +0 -1
- package/dist/gltfIO-B87nJaat.js +0 -10
- package/dist/gltfIO-B87nJaat.js.map +0 -1
- package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
- package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
- package/dist/magicCabin-D64fD1E2.js +0 -11024
- package/dist/magicCabin-D64fD1E2.js.map +0 -1
- package/dist/mcp.d.ts +0 -2
- package/dist/mcp.js +0 -1
- package/dist/monumentHall-BKbs0UOQ.js +0 -404
- package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
- package/dist/node.d.ts +0 -16
- package/dist/node.js +0 -25
- package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
- package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
- package/dist/runtime/application/AgentTools.js +0 -25
- package/dist/runtime/application/README.md +0 -14
- package/dist/runtime/application/buildTaskObservation.js +0 -117
- package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
- package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
- package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
- package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
- package/dist/runtime/application/createSession.js +0 -66
- package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
- package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
- package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
- package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
- package/dist/runtime/application/native-scene/CodeProject.js +0 -119
- package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
- package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
- package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
- package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
- package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
- package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
- package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
- package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
- package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
- package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
- package/dist/runtime/application/scene/RequestWindow.js +0 -54
- package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
- package/dist/runtime/application/scene/SceneContracts.js +0 -45
- package/dist/runtime/application/scene/SceneEditService.js +0 -144
- package/dist/runtime/application/scene/SceneFacade.js +0 -267
- package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
- package/dist/runtime/application/scene/SceneJobController.js +0 -229
- package/dist/runtime/application/scene/ScenePackage.js +0 -162
- package/dist/runtime/application/scene/ScenePersistence.js +0 -50
- package/dist/runtime/application/scene/SceneProject.js +0 -95
- package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
- package/dist/runtime/application/scene/StarterScene.js +0 -56
- package/dist/runtime/application/scene/WorldArchive.js +0 -87
- package/dist/runtime/application/scene/WorldDirectory.js +0 -20
- package/dist/runtime/application/scene/WorldDocument.js +0 -74
- package/dist/runtime/application/scene/WorldIO.js +0 -103
- package/dist/runtime/application/scene/WorldStorage.js +0 -137
- package/dist/runtime/application/skills/SkillRegistry.js +0 -163
- package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
- package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
- package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
- package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
- package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
- package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
- package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
- package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
- package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
- package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
- package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
- package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
- package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
- package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
- package/dist/runtime/application/skills/skillPrimitives.js +0 -4
- package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
- package/dist/runtime/application/tasks.jsonl +0 -67
- package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
- package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
- package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
- package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
- package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
- package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
- package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
- package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
- package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
- package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
- package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
- package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
- package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
- package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
- package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
- package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
- package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
- package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
- package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
- package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
- package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
- package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
- package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
- package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
- package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
- package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
- package/dist/runtime/apps/mcp-server/README.md +0 -150
- package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
- package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
- package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
- package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
- package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
- package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
- package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
- package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
- package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
- package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
- package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
- package/dist/runtime/apps/mcp-server/main.mjs +0 -56
- package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
- package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
- package/dist/runtime/apps/mcp-server/security.js +0 -21
- package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
- package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
- package/dist/runtime/apps/server/README.md +0 -7
- package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
- package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
- package/dist/runtime/apps/server/tasks.jsonl +0 -10
- package/dist/runtime/foundation/EventBus.js +0 -18
- package/dist/runtime/foundation/JsonGateway.js +0 -47
- package/dist/runtime/foundation/PolicyEngine.js +0 -21
- package/dist/runtime/foundation/README.md +0 -7
- package/dist/runtime/foundation/TraceRecorder.js +0 -76
- package/dist/runtime/foundation/errors.js +0 -8
- package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
- package/dist/runtime/foundation/version.js +0 -2
- package/dist/runtime/modules/agent/README.md +0 -11
- package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
- package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
- package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
- package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
- package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
- package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
- package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
- package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
- package/dist/runtime/modules/agent/prompt/index.js +0 -46
- package/dist/runtime/modules/agent/tasks.jsonl +0 -94
- package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
- package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
- package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
- package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
- package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
- package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
- package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
- package/dist/runtime/modules/artifact/README.md +0 -7
- package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
- package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
- package/dist/runtime/modules/asset/AssetModule.js +0 -399
- package/dist/runtime/modules/asset/README.md +0 -54
- package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
- package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
- package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
- package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
- package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
- package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
- package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
- package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
- package/dist/runtime/modules/asset/model/admission.js +0 -117
- package/dist/runtime/modules/asset/model/errors.js +0 -6
- package/dist/runtime/modules/asset/model/parts.js +0 -27
- package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
- package/dist/runtime/modules/asset/model/schema.js +0 -150
- package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
- package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
- package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
- package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
- package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
- package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
- package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
- package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
- package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
- package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
- package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
- package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
- package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
- package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
- package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
- package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
- package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
- package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
- package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
- package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
- package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
- package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
- package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
- package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
- package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
- package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
- package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
- package/dist/runtime/modules/asset/tasks.jsonl +0 -87
- package/dist/runtime/modules/generation/README.md +0 -9
- package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
- package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
- package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
- package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
- package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
- package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
- package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
- package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
- package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
- package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
- package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
- package/dist/runtime/modules/generation/tasks.jsonl +0 -35
- package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
- package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
- package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
- package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
- package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
- package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
- package/dist/runtime/modules/rendering/README.md +0 -7
- package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
- package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
- package/dist/runtime/modules/rendering/createRenderer.js +0 -76
- package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
- package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
- package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
- package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
- package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
- package/dist/runtime/modules/world/README.md +0 -13
- package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
- package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
- package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
- package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
- package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
- package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
- package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
- package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
- package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
- package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
- package/dist/runtime/modules/world/content/blankWorld.js +0 -35
- package/dist/runtime/modules/world/content/environments.js +0 -84
- package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
- package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
- package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
- package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
- package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
- package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
- package/dist/runtime/modules/world/content/magicCabin.js +0 -190
- package/dist/runtime/modules/world/content/monumentHall.js +0 -154
- package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
- package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
- package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
- package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
- package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
- package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
- package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
- package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
- package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
- package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
- package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
- package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
- package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
- package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
- package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
- package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
- package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
- package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
- package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
- package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
- package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
- package/dist/runtime/modules/world/errors.js +0 -9
- package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
- package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
- package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
- package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
- package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
- package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
- package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
- package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
- package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
- package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
- package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
- package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
- package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
- package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
- package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
- package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
- package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
- package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
- package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
- package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
- package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
- package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
- package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
- package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
- package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
- package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
- package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
- package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
- package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
- package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
- package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
- package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
- package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
- package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
- package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
- package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
- package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
- package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
- package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
- package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
- package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
- package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
- package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
- package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
- package/dist/runtime/modules/world/tasks.jsonl +0 -530
- package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
- package/dist/runtime/modules/world/verification/Finding.js +0 -105
- package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
- package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
- package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
- package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
- package/dist/runtime/package-lock.json +0 -6245
- package/dist/runtime/package.json +0 -91
- package/dist/runtime/public/assets/cabinet.glb +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
- package/dist/schema-Dudvovhu.js +0 -364
- package/dist/schema-Dudvovhu.js.map +0 -1
- package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
- package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
- package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
- package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
- package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
- package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import { Errors } from '../../errors.js';
|
|
3
|
-
import { inferCarryCapability } from './CarryCapability.js';
|
|
4
|
-
|
|
5
|
-
export class CarryRuntime {
|
|
6
|
-
constructor({ store, physics, spatial, events, assertSupports }) {
|
|
7
|
-
this.store = store;
|
|
8
|
-
this.physics = physics;
|
|
9
|
-
this.spatial = spatial;
|
|
10
|
-
this.events = events;
|
|
11
|
-
this.assertSupports = assertSupports;
|
|
12
|
-
this.humanHeldId = null;
|
|
13
|
-
this.agentHeld = new Map();
|
|
14
|
-
this.humanViewPosition = new THREE.Vector3();
|
|
15
|
-
this.humanViewRotation = new THREE.Quaternion();
|
|
16
|
-
this.humanViewValid = false;
|
|
17
|
-
this.humanHeldTarget = new THREE.Vector3();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
setHumanViewPose(viewPose = null) {
|
|
21
|
-
if (viewPose?.position?.length === 3 && viewPose?.rotation?.length === 4) {
|
|
22
|
-
this.humanViewPosition.fromArray(viewPose.position);
|
|
23
|
-
this.humanViewRotation.fromArray(viewPose.rotation).normalize();
|
|
24
|
-
this.humanViewValid = true;
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
this.humanViewValid = false;
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
isHeld(id) { return Boolean(this.store.has(id) && this.store.get(id).state?.heldBy); }
|
|
32
|
-
|
|
33
|
-
heldByAgent(actorId) { return this.agentHeld.get(actorId) || null; }
|
|
34
|
-
|
|
35
|
-
holdAnchor(actorId) {
|
|
36
|
-
const record = this.store.get(actorId);
|
|
37
|
-
if (record.manifest.type !== 'agent') throw Errors.carryUnavailable(actorId, actorId, 'ACTOR_NOT_AGENT');
|
|
38
|
-
const anchor = record.manifest.embodiment?.holdAnchor;
|
|
39
|
-
if (!anchor?.translation) throw Errors.carryUnavailable(actorId, actorId, 'HOLD_ANCHOR_UNAVAILABLE');
|
|
40
|
-
return anchor;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
carryStandOff(actorId, heldId, anchor = this.holdAnchor(actorId)) {
|
|
44
|
-
const colliders = this.store.get(heldId).manifest.physics?.colliders || [];
|
|
45
|
-
const radius = Math.max(0, ...colliders.map((collider) =>
|
|
46
|
-
(collider.shape === 'box' ? Math.hypot(collider.halfExtents[0],collider.halfExtents[2]) : Number(collider.radius) || 0)
|
|
47
|
-
+ Math.hypot(collider.translation?.[0] || 0,collider.translation?.[2] || 0)));
|
|
48
|
-
return Math.hypot(anchor.translation[0], anchor.translation[2]) + radius;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
holdPoseAt(actorPosition, yaw, anchor) {
|
|
52
|
-
const rotation = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0,1,0),yaw);
|
|
53
|
-
const position = new THREE.Vector3(...actorPosition).add(new THREE.Vector3(...anchor.translation).applyQuaternion(rotation));
|
|
54
|
-
const localRotation = new THREE.Quaternion(...(anchor.rotation || [0,0,0,1]));
|
|
55
|
-
return { position:position.toArray(), rotation:rotation.multiply(localRotation).normalize().toArray() };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
reorientHeldToward(actorId, heldId, point, { maxStep = Math.PI / 12 } = {}) {
|
|
59
|
-
const actorPosition = this.physics.getPosition(actorId);
|
|
60
|
-
const actorRotation = this.physics.getRotation(actorId);
|
|
61
|
-
const heldPosition = this.physics.getPosition(heldId);
|
|
62
|
-
const heldRotation = this.physics.getRotation(heldId);
|
|
63
|
-
if (!actorPosition || !actorRotation || !heldPosition || !heldRotation) return { clear:false, reason:'POSE_UNAVAILABLE' };
|
|
64
|
-
const dx = point[0]-actorPosition[0], dz = point[2]-actorPosition[2];
|
|
65
|
-
if (Math.hypot(dx,dz) < 1e-8) return { clear:true, steps:0, yaw:null };
|
|
66
|
-
const current = new THREE.Euler().setFromQuaternion(new THREE.Quaternion(...actorRotation),'YXZ').y;
|
|
67
|
-
const target = Math.atan2(-dx,-dz);
|
|
68
|
-
const delta = Math.atan2(Math.sin(target-current),Math.cos(target-current));
|
|
69
|
-
const steps = Math.max(1,Math.ceil(Math.abs(delta)/maxStep));
|
|
70
|
-
const anchor = this.holdAnchor(actorId);
|
|
71
|
-
const checks = [];
|
|
72
|
-
for(let i=1;i<=steps;i++) {
|
|
73
|
-
const yaw = current + delta*(i/steps);
|
|
74
|
-
const pose = this.holdPoseAt(actorPosition,yaw,anchor);
|
|
75
|
-
const check = this.physics.checkBodyMotion(heldId,pose.position,pose.rotation,{excludeIds:[actorId]});
|
|
76
|
-
checks.push({yaw,clear:check.clear,...(!check.clear?{code:check.code,blockedBy:check.blockedBy || []}:{})});
|
|
77
|
-
if(!check.clear) {
|
|
78
|
-
this.physics.setCharacterYaw(actorId,current);
|
|
79
|
-
this.physics.setHeldPose(heldId,heldPosition,heldRotation);
|
|
80
|
-
return { clear:false, reason:'CARRY_REORIENT_BLOCKED', step:i, steps, checks };
|
|
81
|
-
}
|
|
82
|
-
this.physics.setCharacterYaw(actorId,yaw);
|
|
83
|
-
this.physics.setHeldPose(heldId,pose.position,pose.rotation);
|
|
84
|
-
}
|
|
85
|
-
return { clear:true, steps, yaw:target, checks };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
assertAgentCarryable(actorId, targetId) {
|
|
89
|
-
this.holdAnchor(actorId);
|
|
90
|
-
const target = this.store.get(targetId);
|
|
91
|
-
const assessment = inferCarryCapability(target.manifest, { scale:target.physicsScale ?? target.object?.scale?.x ?? 1,
|
|
92
|
-
allowProvisional:target.state?.authoringPromotion?.usage === 'movable' });
|
|
93
|
-
if (!assessment.eligible) throw Errors.carryUnavailable(actorId, targetId, assessment.reason);
|
|
94
|
-
this.assertSupports(targetId, 'pickup');
|
|
95
|
-
this.assertSupports(targetId, 'drop');
|
|
96
|
-
const colliders = target.manifest.physics.colliders;
|
|
97
|
-
const anchorRotation = target.id && (this.store.get(actorId).manifest.embodiment?.holdAnchor?.rotation || [0,0,0,1]);
|
|
98
|
-
if (Math.abs(anchorRotation[0]) > 1e-6 || Math.abs(anchorRotation[2]) > 1e-6) throw Errors.carryUnavailable(actorId,targetId,'HOLD_ANCHOR_ROTATION_UNSUPPORTED');
|
|
99
|
-
if (colliders.some((collider) => collider.rotation && (Math.abs(collider.rotation[0]) > 1e-6 || Math.abs(collider.rotation[2]) > 1e-6))) {
|
|
100
|
-
throw Errors.carryUnavailable(actorId,targetId,'CARRY_COLLIDER_ROTATION_UNSUPPORTED');
|
|
101
|
-
}
|
|
102
|
-
const existing = target.state?.heldBy;
|
|
103
|
-
if (existing && !(existing.kind === 'agent' && existing.id === actorId)) throw Errors.carryUnavailable(actorId, targetId, 'OBJECT_ALREADY_HELD', { heldBy:existing });
|
|
104
|
-
const held = this.heldByAgent(actorId);
|
|
105
|
-
if (held && held !== targetId) throw Errors.carryUnavailable(actorId, targetId, 'HANDS_FULL', { heldId:held });
|
|
106
|
-
return target;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
releaseHeld(id, reason = null, {silent=false} = {}) {
|
|
110
|
-
if (!this.store.has(id)) return { released:false, heldBy:null };
|
|
111
|
-
const record = this.store.get(id);
|
|
112
|
-
const heldBy = record.state?.heldBy;
|
|
113
|
-
if (!heldBy) return { released:false, heldBy:null };
|
|
114
|
-
if (heldBy.kind === 'human' && this.humanHeldId === id) this.humanHeldId = null;
|
|
115
|
-
if (heldBy.kind === 'agent' && this.agentHeld.get(heldBy.id) === id) this.agentHeld.delete(heldBy.id);
|
|
116
|
-
delete record.state.heldBy;
|
|
117
|
-
this.physics.setHeld(id, false);
|
|
118
|
-
if(!silent) this.events.emit('interaction', { action:'drop', id, heldBy, ...(reason ? {reason} : {}) });
|
|
119
|
-
return { released:true, heldBy };
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
rebuildHeldOwnership() {
|
|
123
|
-
this.humanHeldId = null;
|
|
124
|
-
this.agentHeld.clear();
|
|
125
|
-
for (const [id, record] of this.store.list()) {
|
|
126
|
-
const heldBy = record.state?.heldBy;
|
|
127
|
-
if (!heldBy) continue;
|
|
128
|
-
if (heldBy.kind === 'human') {
|
|
129
|
-
if (this.humanHeldId) throw new Error('Scene contains multiple human-held objects');
|
|
130
|
-
this.humanHeldId = id;
|
|
131
|
-
this.physics.setHeld(id, true);
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
if (heldBy.kind !== 'agent' || !heldBy.id || !this.store.has(heldBy.id)) throw new Error(`${id}: invalid heldBy state`);
|
|
135
|
-
if (this.agentHeld.has(heldBy.id)) throw new Error(`${heldBy.id}: multiple held objects are not supported`);
|
|
136
|
-
this.assertAgentCarryable(heldBy.id, id);
|
|
137
|
-
this.agentHeld.set(heldBy.id, id);
|
|
138
|
-
this.physics.setHeld(id, true);
|
|
139
|
-
const pose = this.physics.anchorPose(heldBy.id, this.holdAnchor(heldBy.id));
|
|
140
|
-
if (!pose) throw new Error(`${id}: hold anchor pose unavailable`);
|
|
141
|
-
this.physics.setHeldPose(id, pose.position, pose.rotation);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
transferPickupToAnchor(actorId,targetId,anchorPose,supportIds = []) {
|
|
146
|
-
const originalPosition=this.physics.getPosition(targetId);
|
|
147
|
-
const originalRotation=this.physics.getRotation(targetId);
|
|
148
|
-
if (!originalPosition || !originalRotation) return {clear:false,reason:'CARRY_BODY_UNAVAILABLE',phases:[]};
|
|
149
|
-
const size=this.spatial.getBounds(targetId).size;
|
|
150
|
-
const liftY=originalPosition[1]+Math.max(.12,Math.min(.28,(size[1] || .32)*.55));
|
|
151
|
-
const phases=[];
|
|
152
|
-
const rollback=(reason)=>{
|
|
153
|
-
this.physics.setHeldPose(targetId,originalPosition,originalRotation);
|
|
154
|
-
this.physics.setHeld(targetId,false);
|
|
155
|
-
return {clear:false,reason,phases,originalPosition:[...originalPosition]};
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
this.physics.setHeld(targetId,true);
|
|
159
|
-
const lift=[originalPosition[0],liftY,originalPosition[2]];
|
|
160
|
-
const liftSweep=this.physics.checkBodyMotion(targetId,lift,originalRotation,{excludeIds:[actorId,...supportIds]});
|
|
161
|
-
const liftPose=liftSweep.clear ? this.physics.checkBodyPose(targetId,lift,originalRotation,{excludeIds:[actorId]}) : liftSweep;
|
|
162
|
-
phases.push({phase:'lift',point:[...lift],clear:Boolean(liftSweep.clear && liftPose.clear),sweep:liftSweep,pose:liftPose});
|
|
163
|
-
if (!liftSweep.clear || !liftPose.clear) return rollback('PICKUP_LIFT_BLOCKED');
|
|
164
|
-
this.physics.setHeldPose(targetId,lift,originalRotation);
|
|
165
|
-
|
|
166
|
-
const horizontal=[anchorPose.position[0],liftY,anchorPose.position[2]];
|
|
167
|
-
const horizontalCheck=this.physics.checkBodyMotion(targetId,horizontal,anchorPose.rotation,{excludeIds:[actorId]});
|
|
168
|
-
phases.push({phase:'horizontal',point:[...horizontal],...horizontalCheck});
|
|
169
|
-
if (!horizontalCheck.clear) return rollback('PICKUP_HORIZONTAL_BLOCKED');
|
|
170
|
-
this.physics.setHeldPose(targetId,horizontal,anchorPose.rotation);
|
|
171
|
-
|
|
172
|
-
const anchorCheck=this.physics.checkBodyMotion(targetId,anchorPose.position,anchorPose.rotation,{excludeIds:[actorId]});
|
|
173
|
-
phases.push({phase:'anchor',point:[...anchorPose.position],...anchorCheck});
|
|
174
|
-
if (!anchorCheck.clear) return rollback('PICKUP_ANCHOR_BLOCKED');
|
|
175
|
-
this.physics.setHeldPose(targetId,anchorPose.position,anchorPose.rotation);
|
|
176
|
-
return {clear:true,mode:'lift-horizontal-anchor',supportIds:[...supportIds],phases};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
transferHeldToRelease(actorId, heldId, release) {
|
|
180
|
-
const originalPosition=this.physics.getPosition(heldId);
|
|
181
|
-
const rotation=this.physics.getRotation(heldId);
|
|
182
|
-
if (!originalPosition || !rotation) return {clear:false,reason:'HELD_BODY_UNAVAILABLE',transfer:[]};
|
|
183
|
-
const point=Array.isArray(release) ? release : release.toArray();
|
|
184
|
-
const size=this.spatial.getBounds(heldId).size;
|
|
185
|
-
const liftY=Math.max(originalPosition[1],point[1]+size[1]+.08);
|
|
186
|
-
const transferPoints=[
|
|
187
|
-
[originalPosition[0],liftY,originalPosition[2]],
|
|
188
|
-
[point[0],liftY,point[2]],
|
|
189
|
-
[...point]
|
|
190
|
-
];
|
|
191
|
-
const transfer=[];
|
|
192
|
-
for (const target of transferPoints) {
|
|
193
|
-
const check=this.physics.checkBodyMotion(heldId,target,rotation,{excludeIds:[actorId]});
|
|
194
|
-
transfer.push({point:[...target],...check});
|
|
195
|
-
if (!check.clear) {
|
|
196
|
-
this.physics.setHeldPose(heldId,originalPosition,rotation);
|
|
197
|
-
return {clear:false,reason:'TRANSFER_BLOCKED',originalPosition,rotation,transfer};
|
|
198
|
-
}
|
|
199
|
-
this.physics.setHeldPose(heldId,target,rotation);
|
|
200
|
-
}
|
|
201
|
-
return {clear:true,originalPosition,rotation,transfer,release:[...point]};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
carryStatus(actorId) {
|
|
205
|
-
const id = this.heldByAgent(actorId);
|
|
206
|
-
if (!id) return { status:'empty', actorId };
|
|
207
|
-
const record = this.store.get(id);
|
|
208
|
-
return { status:'held', actorId, targetId:id, heldBy:structuredClone(record.state.heldBy), position:this.physics.getPosition(id), attachment:'kinematic-anchor', graspVerified:false };
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
update() {
|
|
212
|
-
if (this.humanHeldId && this.humanViewValid) {
|
|
213
|
-
this.humanHeldTarget.set(0,0,-1.6).applyQuaternion(this.humanViewRotation).add(this.humanViewPosition);
|
|
214
|
-
this.physics.setHeldTarget(this.humanHeldId, this.humanHeldTarget);
|
|
215
|
-
}
|
|
216
|
-
for (const [actorId, targetId] of this.agentHeld) {
|
|
217
|
-
if (!this.store.has(actorId) || !this.store.has(targetId)) continue;
|
|
218
|
-
const pose = this.physics.anchorPose(actorId, this.holdAnchor(actorId));
|
|
219
|
-
if (pose) this.physics.setHeldTarget(targetId, pose.position, pose.rotation);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import { Errors } from '../../errors.js';
|
|
3
|
-
|
|
4
|
-
export const DEFAULT_INTERACTION_DISTANCE = 1.5;
|
|
5
|
-
export const INTERACTION_APPROACH_MARGIN = 0.18;
|
|
6
|
-
export const ACTION_INTERACTION_CORRECTION_TOLERANCE = 0.05;
|
|
7
|
-
|
|
8
|
-
export class InteractionApproach {
|
|
9
|
-
constructor({ store, physics, spatial, navigation = null, locomotion = null, actionSweepBounds }) {
|
|
10
|
-
this.store = store;
|
|
11
|
-
this.physics = physics;
|
|
12
|
-
this.spatial = spatial;
|
|
13
|
-
this.navigation = navigation;
|
|
14
|
-
this.locomotion = locomotion;
|
|
15
|
-
this.resolveActionSweep = actionSweepBounds;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
setNavigation(navigation) { this.navigation = navigation; }
|
|
19
|
-
setLocomotion(locomotion) { this.locomotion = locomotion; }
|
|
20
|
-
|
|
21
|
-
actionSweepBounds(...args) {
|
|
22
|
-
return this.resolveActionSweep?.(...args) || { checked:false, reason:'ACTION_SWEEP_UNAVAILABLE' };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
actorBoxAt(actorId, position) {
|
|
26
|
-
const record = this.store.get(actorId);
|
|
27
|
-
const collider = record.manifest.physics?.colliders?.find((value) => value.shape === 'capsule');
|
|
28
|
-
if (collider) {
|
|
29
|
-
const center = new THREE.Vector3(...position).add(new THREE.Vector3(...(collider.translation || [0,0,0])));
|
|
30
|
-
const half = new THREE.Vector3(collider.radius, collider.halfHeight + collider.radius, collider.radius);
|
|
31
|
-
return new THREE.Box3(center.clone().sub(half), center.clone().add(half));
|
|
32
|
-
}
|
|
33
|
-
const current = this.physics.getPosition(actorId);
|
|
34
|
-
if (!current) return null;
|
|
35
|
-
const bounds = this.spatial.getBounds(actorId);
|
|
36
|
-
const center = new THREE.Vector3(...bounds.center).sub(new THREE.Vector3(...current)).add(new THREE.Vector3(...position));
|
|
37
|
-
const half = new THREE.Vector3(...bounds.size).multiplyScalar(.5);
|
|
38
|
-
return new THREE.Box3(center.clone().sub(half), center.clone().add(half));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
actorMetrics(actorId) {
|
|
42
|
-
const record = this.store.get(actorId);
|
|
43
|
-
if (record.manifest.type !== 'agent') throw Errors.interactionUnavailable(actorId, actorId, 'ACTOR_NOT_AGENT');
|
|
44
|
-
const bounds = this.spatial.getBounds(actorId);
|
|
45
|
-
const capsule = record.manifest.physics?.colliders?.find((collider) => collider.shape === 'capsule');
|
|
46
|
-
return {
|
|
47
|
-
radius:capsule?.radius ?? Math.max(0.2, Math.min(bounds.size[0], bounds.size[2]) / 2),
|
|
48
|
-
eyeHeight:Math.max(0.9, bounds.size[1] * 0.82)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
interactionStatusAt(actorId, targetId, position, { maxDistance = DEFAULT_INTERACTION_DISTANCE, ignoreIds = [], aimPoint = null, allowClearEndpoint = false } = {}) {
|
|
53
|
-
const metrics = this.actorMetrics(actorId);
|
|
54
|
-
const bounds = this.spatial.getBounds(targetId);
|
|
55
|
-
const dx = Math.max(bounds.min[0] - position[0], 0, position[0] - bounds.max[0]);
|
|
56
|
-
const dz = Math.max(bounds.min[2] - position[2], 0, position[2] - bounds.max[2]);
|
|
57
|
-
const distance = Math.hypot(dx, dz);
|
|
58
|
-
const eye = [position[0], position[1] + metrics.eyeHeight, position[2]];
|
|
59
|
-
const aim = aimPoint ? [...aimPoint] : [...bounds.center];
|
|
60
|
-
const hit = this.physics.raycast(eye, aim, { excludeId:actorId, excludeIds:ignoreIds });
|
|
61
|
-
const visible = hit?.id === targetId || (allowClearEndpoint && !hit);
|
|
62
|
-
return {
|
|
63
|
-
actorId,
|
|
64
|
-
targetId,
|
|
65
|
-
position:[...position],
|
|
66
|
-
distance:Number(distance.toFixed(3)),
|
|
67
|
-
maxDistance,
|
|
68
|
-
inRange:distance <= maxDistance,
|
|
69
|
-
visible,
|
|
70
|
-
interactable:distance <= maxDistance && visible,
|
|
71
|
-
lineOfSight:{ eye, aim, hit:hit ? { id:hit.id, part:hit.part, environment:hit.environment, distance:Number(hit.distance.toFixed(3)) } : null }
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
interactionStatus(actorId, targetId, options = {}) {
|
|
76
|
-
const position = this.physics.getPosition(actorId);
|
|
77
|
-
if (!position) throw Errors.interactionUnavailable(actorId, targetId, 'ACTOR_PHYSICS_UNAVAILABLE');
|
|
78
|
-
return this.interactionStatusAt(actorId, targetId, position, options);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async findInteractionPose(actorId, targetId, { maxDistance = DEFAULT_INTERACTION_DISTANCE, clearance = 0.12, action = null, partName = null, ignoreIds = [], standOff = 0, stanceBounds = null, candidateFilter = null, aimPoint = null, allowClearEndpoint = false } = {}) {
|
|
82
|
-
if (!this.navigation) throw Errors.interactionUnavailable(actorId, targetId, 'NAVIGATION_UNAVAILABLE');
|
|
83
|
-
const current = this.physics.getPosition(actorId);
|
|
84
|
-
if (!current) throw Errors.interactionUnavailable(actorId, targetId, 'ACTOR_PHYSICS_UNAVAILABLE');
|
|
85
|
-
const sweep = action ? this.actionSweepBounds(targetId, action, partName) : null;
|
|
86
|
-
if (action && !sweep.checked) throw Errors.interactionUnavailable(actorId, targetId, 'ACTION_SWEEP_UNAVAILABLE', { sweep:{ checked:false, reason:sweep.reason, partName:sweep.partName } });
|
|
87
|
-
const clearOfSweep = (position) => !sweep || !sweep.box.intersectsBox(this.actorBoxAt(actorId, position));
|
|
88
|
-
const now = this.interactionStatusAt(actorId, targetId, current, { maxDistance, ignoreIds, aimPoint, allowClearEndpoint });
|
|
89
|
-
if (now.interactable && clearOfSweep(current) && (!candidateFilter || candidateFilter(current))) return { status:'current-pose', position:[...current], routeCost:0, distance:now.distance, lineOfSight:now.lineOfSight, ...(sweep ? { actionSweep:{checked:true,clear:true,partName:sweep.partName} } : {}) };
|
|
90
|
-
|
|
91
|
-
const metrics = this.actorMetrics(actorId);
|
|
92
|
-
const bounds = stanceBounds || this.spatial.getBounds(targetId);
|
|
93
|
-
const offset = Math.max(metrics.radius,standOff) + clearance;
|
|
94
|
-
const [cx,,cz] = bounds.center;
|
|
95
|
-
const y = current[1];
|
|
96
|
-
const candidates = [
|
|
97
|
-
[bounds.min[0] - offset, y, cz], [bounds.max[0] + offset, y, cz],
|
|
98
|
-
[cx, y, bounds.min[2] - offset], [cx, y, bounds.max[2] + offset],
|
|
99
|
-
[bounds.min[0] - offset, y, bounds.min[2] - offset],
|
|
100
|
-
[bounds.max[0] + offset, y, bounds.min[2] - offset],
|
|
101
|
-
[bounds.min[0] - offset, y, bounds.max[2] + offset],
|
|
102
|
-
[bounds.max[0] + offset, y, bounds.max[2] + offset]
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
const valid = [];
|
|
106
|
-
for (const candidate of candidates) {
|
|
107
|
-
const route = await this.navigation.findPath(current, candidate);
|
|
108
|
-
if (!route.reachable || !route.end?.snapped) continue;
|
|
109
|
-
const position = route.end.snapped;
|
|
110
|
-
const status = this.interactionStatusAt(actorId, targetId, position, { maxDistance, ignoreIds, aimPoint, allowClearEndpoint });
|
|
111
|
-
if (!status.interactable || !clearOfSweep(position) || (candidateFilter && !candidateFilter(position))) continue;
|
|
112
|
-
valid.push({ status:'approach-pose', position, routeCost:route.cost, distance:status.distance, waypointCount:route.path.length, lineOfSight:status.lineOfSight, ...(sweep ? { actionSweep:{checked:true,clear:true,partName:sweep.partName} } : {}) });
|
|
113
|
-
}
|
|
114
|
-
valid.sort((a, b) => (a.routeCost ?? Infinity) - (b.routeCost ?? Infinity));
|
|
115
|
-
return valid[0] || null;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async navigateToPose(actorId, pose, { speed } = {}) {
|
|
119
|
-
if (pose.status === 'current-pose') return null;
|
|
120
|
-
return this.locomotion.navigate(actorId, pose.position, { speed });
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async correctToPose(actorId, pose, { speed, force = false } = {}) {
|
|
124
|
-
if (pose.status === 'current-pose') return null;
|
|
125
|
-
const actual = this.physics.getPosition(actorId);
|
|
126
|
-
const remaining = actual ? Math.hypot(actual[0]-pose.position[0], actual[2]-pose.position[2]) : Infinity;
|
|
127
|
-
if (!force && remaining <= ACTION_INTERACTION_CORRECTION_TOLERANCE) return null;
|
|
128
|
-
return this.locomotion.navigate(actorId, pose.position, { speed, waypointTolerance:ACTION_INTERACTION_CORRECTION_TOLERANCE });
|
|
129
|
-
}
|
|
130
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export const INTERACTION_CONTRACT_SCHEMA='agentscape.interaction-contract';
|
|
2
|
-
export const INTERACTION_CONTRACT_VERSION=1;
|
|
3
|
-
|
|
4
|
-
const clean=v=>typeof v==='string'?v.trim():'';
|
|
5
|
-
const plain=v=>Boolean(v&&typeof v==='object'&&!Array.isArray(v));
|
|
6
|
-
const assertObject=(v,label)=>{if(!plain(v)) throw new TypeError(`${label} must be an object`);return v;};
|
|
7
|
-
const assertFinite=v=>{if(!Number.isFinite(v)) throw new TypeError('Interaction target must be finite');return Number(v);};
|
|
8
|
-
|
|
9
|
-
// Preserve the historical error for malformed open/close manifests; other
|
|
10
|
-
// semantic operations are executable when a part declares a numeric target.
|
|
11
|
-
const requiredPartTargets=new Set(['open','close']);
|
|
12
|
-
|
|
13
|
-
export function compileInteractionContract(manifest){
|
|
14
|
-
assertObject(manifest,'Manifest');
|
|
15
|
-
const entityId=clean(manifest.id)||'$anonymous';
|
|
16
|
-
const contracts=[];
|
|
17
|
-
const parts=manifest.parts||{};
|
|
18
|
-
for(const action of manifest.actions||[]){
|
|
19
|
-
const candidates=Object.entries(parts).filter(([partName,part])=>part?.actions?.includes(action)&&Number.isFinite(part?.targets?.[action]));
|
|
20
|
-
if(requiredPartTargets.has(action)&&!candidates.length) throw new TypeError(`Action ${action} has no executable part target`);
|
|
21
|
-
for(const [partName,part] of candidates){
|
|
22
|
-
const target=assertFinite(part.targets[action]);
|
|
23
|
-
contracts.push({
|
|
24
|
-
id:`${entityId}:${partName}:${action}`,
|
|
25
|
-
capability:action.toUpperCase(),
|
|
26
|
-
action,
|
|
27
|
-
target:{entityId,partName},
|
|
28
|
-
preconditions:[
|
|
29
|
-
{kind:'supports-action',action},
|
|
30
|
-
{kind:'runtime-authorized',capability:action.toUpperCase()}
|
|
31
|
-
],
|
|
32
|
-
effects:[{kind:'set-articulation-target',target}],
|
|
33
|
-
stateTransition:{kind:'articulation-completion',from:['unknown','open','closed','moving'],to:action},
|
|
34
|
-
verifierTarget:{type:'articulation-state',entityId:manifest.id,partName,target,settledRequired:true}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return {schema:INTERACTION_CONTRACT_SCHEMA,schemaVersion:INTERACTION_CONTRACT_VERSION,entityId,contracts};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function getInteractionContract(manifest,partName,action){
|
|
42
|
-
const contract=compileInteractionContract(manifest).contracts.find(item=>item.target.partName===partName&&item.action===action);
|
|
43
|
-
if(!contract) throw new Error(`Interaction contract not found: ${manifest.id}:${partName}:${action}`);
|
|
44
|
-
return structuredClone(contract);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function verifyInteractionResult(contract,result){
|
|
48
|
-
const verifier=contract?.verifierTarget;
|
|
49
|
-
if(!verifier) return {verified:false,reason:'VERIFIER_TARGET_MISSING'};
|
|
50
|
-
const verified=result?.status==='action-completed'
|
|
51
|
-
&& result?.targetReached===true
|
|
52
|
-
&& result?.settled===true
|
|
53
|
-
&& result?.part===verifier.partName
|
|
54
|
-
&& Number.isFinite(result?.target)
|
|
55
|
-
&& Math.abs(result.target-verifier.target)<=.08;
|
|
56
|
-
return verified?{verified:true}:{verified:false,reason:'POST_CONDITION_NOT_VERIFIED'};
|
|
57
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
|
|
3
|
-
export class RecoveryRuntime {
|
|
4
|
-
constructor({ store, physics, spatial, navigation = null, locomotion = null, approach, carry, articulation, interactionDistance = 1.5, waypointTolerance = .18 }) {
|
|
5
|
-
this.store = store;
|
|
6
|
-
this.physics = physics;
|
|
7
|
-
this.spatial = spatial;
|
|
8
|
-
this.navigation = navigation;
|
|
9
|
-
this.locomotion = locomotion;
|
|
10
|
-
this.approach = approach;
|
|
11
|
-
this.carry = carry;
|
|
12
|
-
this.articulation = articulation;
|
|
13
|
-
this.interactionDistance = interactionDistance;
|
|
14
|
-
this.waypointTolerance = waypointTolerance;
|
|
15
|
-
this.held = new Map();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
markHeld(actorId, { blockerId, targetId, partName, action }) {
|
|
19
|
-
if (this.carry.heldByAgent(actorId)!==blockerId) return false;
|
|
20
|
-
this.held.set(actorId,{blockerId,targetId,partName:partName || null,action:action || null});
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
status(actorId) {
|
|
25
|
-
const value=this.held.get(actorId);
|
|
26
|
-
return value ? structuredClone(value) : null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
clear(actorId) { return this.held.delete(actorId); }
|
|
30
|
-
clearAll() { this.held.clear(); }
|
|
31
|
-
|
|
32
|
-
clearRelated(id) {
|
|
33
|
-
for (const [actorId,recovery] of [...this.held]) {
|
|
34
|
-
if (actorId===id || recovery.blockerId===id || recovery.targetId===id) this.held.delete(actorId);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
cleanupReleaseCandidates(actorId,targetId,partName,action,heldId,{clearance=.05,sweepMargin=.35}={}) {
|
|
39
|
-
const sweep=this.articulation.actionSweepBounds(targetId,action,partName);
|
|
40
|
-
if (!sweep.checked) return {sweep,candidates:[]};
|
|
41
|
-
const bounds=this.spatial.getBounds(heldId);
|
|
42
|
-
const bodyPosition=this.physics.getPosition(heldId);
|
|
43
|
-
if (!bodyPosition) return {sweep,candidates:[]};
|
|
44
|
-
const halfX=bounds.size[0]/2,halfZ=bounds.size[2]/2;
|
|
45
|
-
const centerOffset=[bounds.center[0]-bodyPosition[0],bounds.center[1]-bodyPosition[1],bounds.center[2]-bodyPosition[2]];
|
|
46
|
-
const rootToBottom=bodyPosition[1]-bounds.min[1];
|
|
47
|
-
const center=sweep.box.getCenter(new THREE.Vector3());
|
|
48
|
-
const left=sweep.box.min.x-sweepMargin-halfX,right=sweep.box.max.x+sweepMargin+halfX;
|
|
49
|
-
const back=sweep.box.min.z-sweepMargin-halfZ,front=sweep.box.max.z+sweepMargin+halfZ;
|
|
50
|
-
const centers=[
|
|
51
|
-
[left,center.z],[right,center.z],[center.x,back],[center.x,front],
|
|
52
|
-
[left,back],[right,back],[left,front],[right,front]
|
|
53
|
-
];
|
|
54
|
-
const topY=Math.max(sweep.box.max.y,bounds.max[1])+4;
|
|
55
|
-
const lowY=Math.min(sweep.box.min.y,bounds.min[1])-24;
|
|
56
|
-
const sweepGuard=sweep.box.clone().expandByScalar(sweepMargin*.5);
|
|
57
|
-
const candidates=[];
|
|
58
|
-
for (const [cx,cz] of centers) {
|
|
59
|
-
const rootX=cx-centerOffset[0], rootZ=cz-centerOffset[2];
|
|
60
|
-
const hit=this.physics.raycast([rootX,topY,rootZ],[rootX,lowY,rootZ],{excludeIds:[actorId,heldId,targetId]});
|
|
61
|
-
if (!hit?.environment) continue;
|
|
62
|
-
const release=[rootX,hit.point[1]+rootToBottom+clearance,rootZ];
|
|
63
|
-
const min=new THREE.Vector3(bounds.min[0]-bodyPosition[0]+release[0],bounds.min[1]-bodyPosition[1]+release[1],bounds.min[2]-bodyPosition[2]+release[2]);
|
|
64
|
-
const max=new THREE.Vector3(bounds.max[0]-bodyPosition[0]+release[0],bounds.max[1]-bodyPosition[1]+release[1],bounds.max[2]-bodyPosition[2]+release[2]);
|
|
65
|
-
const box=new THREE.Box3(min,max);
|
|
66
|
-
if (sweepGuard.intersectsBox(box)) continue;
|
|
67
|
-
candidates.push({release,support:{environment:true,point:[...hit.point],distance:hit.distance},box});
|
|
68
|
-
}
|
|
69
|
-
return {sweep,candidates};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async findCleanupPlan(actorId,targetId,{partName=null,action=null,blockerId=null,clearance=.05,sweepMargin=.35}={}) {
|
|
73
|
-
const provenance=this.getProvenance ? this.getProvenance(actorId) : this.status(actorId);
|
|
74
|
-
const heldId=this.carry.heldByAgent(actorId);
|
|
75
|
-
if (!provenance || !heldId || provenance.blockerId!==heldId || (blockerId && blockerId!==heldId)) return {status:'cleanup-unavailable',reason:'NO_RECOVERY_HELD_BLOCKER',actorId,targetId,blockerId:blockerId || heldId || null};
|
|
76
|
-
if (provenance.targetId!==targetId || (partName && provenance.partName && provenance.partName!==partName)) return {status:'cleanup-unavailable',reason:'RECOVERY_CONTEXT_MISMATCH',actorId,targetId,blockerId:heldId};
|
|
77
|
-
const resolvedAction=action || provenance.action;
|
|
78
|
-
const resolvedPart=partName || provenance.partName;
|
|
79
|
-
if (!resolvedAction) return {status:'cleanup-unavailable',reason:'ORIGINAL_ACTION_UNAVAILABLE',actorId,targetId,blockerId:heldId};
|
|
80
|
-
if (!this.navigation || !this.locomotion) return {status:'cleanup-unavailable',reason:'NAVIGATION_UNAVAILABLE',actorId,targetId,blockerId:heldId};
|
|
81
|
-
const source=this.cleanupReleaseCandidates(actorId,targetId,resolvedPart,resolvedAction,heldId,{clearance,sweepMargin});
|
|
82
|
-
if (!source.sweep.checked) return {status:'cleanup-unavailable',reason:'ACTION_SWEEP_UNAVAILABLE',actorId,targetId,blockerId:heldId,sweep:{checked:false,reason:source.sweep.reason,partName:source.sweep.partName}};
|
|
83
|
-
const actorPosition=this.physics.getPosition(actorId);
|
|
84
|
-
if (!actorPosition) return {status:'cleanup-unavailable',reason:'ACTOR_PHYSICS_UNAVAILABLE',actorId,targetId,partName:source.sweep.partName,action:resolvedAction,blockerId:heldId};
|
|
85
|
-
const anchor=this.carry.holdAnchor(actorId);
|
|
86
|
-
const metrics=this.approach.actorMetrics(actorId);
|
|
87
|
-
const standOff=Math.max(metrics.radius+.18,this.carry.carryStandOff(actorId,heldId)+.12);
|
|
88
|
-
const plans=[];
|
|
89
|
-
for (const candidate of source.candidates) {
|
|
90
|
-
const release=new THREE.Vector3(...candidate.release);
|
|
91
|
-
const stancePositions=[[...actorPosition]];
|
|
92
|
-
for (let i=0;i<8;i++) {
|
|
93
|
-
const angle=i*Math.PI/4;
|
|
94
|
-
stancePositions.push([release.x+Math.cos(angle)*standOff,actorPosition[1],release.z+Math.sin(angle)*standOff]);
|
|
95
|
-
}
|
|
96
|
-
for (let index=0;index<stancePositions.length;index++) {
|
|
97
|
-
let position=stancePositions[index],routeCost=0,route=null,status='current-pose';
|
|
98
|
-
if (index>0) {
|
|
99
|
-
route=await this.navigation.findPath(actorPosition,position);
|
|
100
|
-
if (!route.reachable || !route.end?.snapped) continue;
|
|
101
|
-
position=route.end.snapped; routeCost=route.cost; status='approach-pose';
|
|
102
|
-
}
|
|
103
|
-
if (source.sweep.box.intersectsBox(this.approach.actorBoxAt(actorId,position))) continue;
|
|
104
|
-
const dx=release.x-position[0],dz=release.z-position[2];
|
|
105
|
-
const yaw=Math.hypot(dx,dz)<1e-8?0:Math.atan2(-dx,-dz);
|
|
106
|
-
const predicted=this.carry.holdPoseAt(position,yaw,anchor);
|
|
107
|
-
const releaseDistance=new THREE.Vector3(...predicted.position).distanceTo(release);
|
|
108
|
-
if (releaseDistance>this.interactionDistance-this.waypointTolerance) continue;
|
|
109
|
-
const endpointClear=this.physics.checkBodyPose(heldId,candidate.release,predicted.rotation,{excludeIds:[actorId]});
|
|
110
|
-
if (!endpointClear.clear) continue;
|
|
111
|
-
plans.push({
|
|
112
|
-
status:'cleanup-proposed',actorId,targetId,partName:source.sweep.partName,action:resolvedAction,blockerId:heldId,
|
|
113
|
-
pose:{status,position:[...position],routeCost,waypointCount:route?.path?.length || 1},
|
|
114
|
-
release:candidate.release.map((value)=>Number(value.toFixed(4))),support:candidate.support,
|
|
115
|
-
actionSweep:{checked:true,partName:source.sweep.partName,bounds:source.sweep.bounds},
|
|
116
|
-
preflight:{sweepClear:true,endpointClear:true,releaseDistance:Number(releaseDistance.toFixed(4))}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
plans.sort((a,b)=>(a.pose.routeCost??Infinity)-(b.pose.routeCost??Infinity) || a.preflight.releaseDistance-b.preflight.releaseDistance || a.release.join(',').localeCompare(b.release.join(',')));
|
|
121
|
-
return plans[0] || {status:'cleanup-unavailable',reason:'NO_SAFE_CLEANUP_SPACE',actorId,targetId,partName:source.sweep.partName,action:resolvedAction,blockerId:heldId};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import { Errors } from '../../errors.js';
|
|
3
|
-
|
|
4
|
-
export class SettleRuntime {
|
|
5
|
-
constructor({ store, physics, spatial, events, carry, articulation }) {
|
|
6
|
-
this.store = store;
|
|
7
|
-
this.physics = physics;
|
|
8
|
-
this.spatial = spatial;
|
|
9
|
-
this.events = events;
|
|
10
|
-
this.carry = carry;
|
|
11
|
-
this.articulation = articulation;
|
|
12
|
-
this.tasks = new Map();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
wait(objectId, { kind='place', targetId=null, surfaceId=null, actorId=null, partName=null, action=null, timeout=4, stableDuration=.35, linearSpeed=.04, angularSpeed=.12 } = {}) {
|
|
16
|
-
if (this.tasks.has(objectId)) throw Errors.placeUnavailable(actorId || 'runtime', targetId || objectId, 'SETTLE_ALREADY_ACTIVE', { objectId });
|
|
17
|
-
return new Promise((resolve) => this.tasks.set(objectId, { kind, objectId, targetId, surfaceId, actorId, partName, action, timeout, stableDuration, linearSpeed, angularSpeed, elapsed:0, stable:0, resolve }));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
waitForPlacement(objectId, targetId, surfaceId, { timeout = 4, stableDuration = 0.35, linearSpeed = 0.04, angularSpeed = 0.12 } = {}) {
|
|
21
|
-
return this.wait(objectId,{kind:'place',targetId,surfaceId,timeout,stableDuration,linearSpeed,angularSpeed});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
waitForRecoveryCleanup(actorId, objectId, targetId, partName, action, options = {}) {
|
|
25
|
-
return this.wait(objectId,{kind:'recovery-cleanup',actorId,targetId,partName,action,...options});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
placementResult(task,motion,{settled,reason=null}={}) {
|
|
29
|
-
const support=this.spatial.supportGeometry(task.objectId,task.targetId,{surfaceId:task.surfaceId});
|
|
30
|
-
if (!settled) return {
|
|
31
|
-
status:'place-unverified',reason:reason || 'SETTLE_TIMEOUT',supportVerified:false,support,settled:false,
|
|
32
|
-
elapsed:Number(task.elapsed.toFixed(3)),motion
|
|
33
|
-
};
|
|
34
|
-
return {
|
|
35
|
-
status:support.supported?'placed':'place-failed',...(support.supported?{}:{reason:'SUPPORT_NOT_REACHED'}),
|
|
36
|
-
supportVerified:support.supported,support,settled:true,elapsed:Number(task.elapsed.toFixed(3)),motion
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
dropResult(task,motion,{settled,reason=null}={}) {
|
|
41
|
-
const held=this.store.has(task.objectId) ? this.store.get(task.objectId).state?.heldBy : null;
|
|
42
|
-
const released=!held && this.carry.heldByAgent(task.actorId)!==task.objectId;
|
|
43
|
-
const position=this.physics.getPosition(task.objectId);
|
|
44
|
-
if (!settled) return {
|
|
45
|
-
status:reason==='BODY_UNAVAILABLE'?'drop-failed':'drop-unverified',reason:reason || 'SETTLE_TIMEOUT',
|
|
46
|
-
actorId:task.actorId,targetId:task.objectId,released,settled:false,stillHeld:!released,
|
|
47
|
-
position:position ? [...position] : null,elapsed:Number(task.elapsed.toFixed(3)),motion
|
|
48
|
-
};
|
|
49
|
-
if (!released) return {
|
|
50
|
-
status:'drop-failed',reason:'STILL_HELD',actorId:task.actorId,targetId:task.objectId,
|
|
51
|
-
released:false,settled:true,stillHeld:true,position:position ? [...position] : null,
|
|
52
|
-
elapsed:Number(task.elapsed.toFixed(3)),motion
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
status:'dropped',actorId:task.actorId,targetId:task.objectId,released:true,settled:true,stillHeld:false,
|
|
56
|
-
position:position ? [...position] : null,elapsed:Number(task.elapsed.toFixed(3)),motion
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
recoveryCleanupResult(task,motion,{settled,reason=null}={}) {
|
|
61
|
-
const held=this.store.has(task.objectId) ? this.store.get(task.objectId).state?.heldBy : null;
|
|
62
|
-
const sweep=this.store.has(task.targetId) ? this.articulation.actionSweepBounds(task.targetId,task.action,task.partName) : {checked:false,reason:'TARGET_UNAVAILABLE'};
|
|
63
|
-
const bounds=this.store.has(task.objectId) ? this.spatial.getBounds(task.objectId) : null;
|
|
64
|
-
const box=bounds ? new THREE.Box3(new THREE.Vector3(...bounds.min),new THREE.Vector3(...bounds.max)) : null;
|
|
65
|
-
const sweepClear=Boolean(sweep.checked && box && !sweep.box.intersectsBox(box));
|
|
66
|
-
const contacts=sweep.checked ? (this.physics.articulationContacts?.(task.targetId,sweep.partName) || []) : [];
|
|
67
|
-
const contactClear=!contacts.some((contact)=>contact.external && contact.target?.kind==='object' && contact.target.objectId===task.objectId);
|
|
68
|
-
const released=!held && this.carry.heldByAgent(task.actorId)!==task.objectId;
|
|
69
|
-
const verified=Boolean(settled && released && sweepClear && contactClear);
|
|
70
|
-
let failureReason=reason;
|
|
71
|
-
if (!failureReason && !released) failureReason='STILL_HELD';
|
|
72
|
-
else if (!failureReason && !sweep.checked) failureReason='ACTION_SWEEP_UNAVAILABLE';
|
|
73
|
-
else if (!failureReason && !sweepClear) failureReason='ACTION_SWEEP_OCCUPIED';
|
|
74
|
-
else if (!failureReason && !contactClear) failureReason='CONTACT_STILL_ACTIVE';
|
|
75
|
-
return {
|
|
76
|
-
status:verified?'recovery-cleaned':(settled?'recovery-cleanup-failed':'recovery-cleanup-unverified'),
|
|
77
|
-
...(verified?{}:{reason:failureReason || 'RECOVERY_CLEANUP_UNVERIFIED'}),
|
|
78
|
-
actorId:task.actorId,targetId:task.targetId,blockerId:task.objectId,partName:sweep.partName || task.partName,action:task.action,
|
|
79
|
-
released,settled:Boolean(settled),sweepClear,contactClear,
|
|
80
|
-
actionSweep:sweep.checked?{checked:true,partName:sweep.partName,bounds:sweep.bounds}:{checked:false,reason:sweep.reason,partName:sweep.partName || task.partName},
|
|
81
|
-
elapsed:Number(task.elapsed.toFixed(3)),motion
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
finish(task, result) {
|
|
86
|
-
if (!this.tasks.has(task.objectId)) return;
|
|
87
|
-
this.tasks.delete(task.objectId);
|
|
88
|
-
const eventAction = task.kind === 'recovery-cleanup' ? 'recovery-cleanup' : task.kind === 'drop' ? 'drop' : 'place';
|
|
89
|
-
this.events.emit('interaction', { action:eventAction, id:task.objectId, targetId:task.targetId, ...result });
|
|
90
|
-
task.resolve(result);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
evaluate(task, motion, state) {
|
|
94
|
-
if (task.kind === 'recovery-cleanup') return this.recoveryCleanupResult(task,motion,state);
|
|
95
|
-
if (task.kind === 'drop') return this.dropResult(task,motion,state);
|
|
96
|
-
return this.placementResult(task,motion,state);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
update(dt) {
|
|
100
|
-
for (const task of [...this.tasks.values()]) {
|
|
101
|
-
task.elapsed += dt;
|
|
102
|
-
const motionState = this.physics.getMotion(task.objectId);
|
|
103
|
-
if (!motionState) {
|
|
104
|
-
const result = task.kind === 'place'
|
|
105
|
-
? { status:'place-failed', reason:'BODY_UNAVAILABLE', supportVerified:false, elapsed:Number(task.elapsed.toFixed(3)) }
|
|
106
|
-
: this.evaluate(task,null,{settled:false,reason:'BODY_UNAVAILABLE'});
|
|
107
|
-
this.finish(task,result);
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
const motion = { sleeping:motionState.sleeping, linearSpeed:Number(motionState.linearSpeed.toFixed(4)), angularSpeed:Number(motionState.angularSpeed.toFixed(4)) };
|
|
111
|
-
const slow = motionState.sleeping || (motionState.linearSpeed <= task.linearSpeed && motionState.angularSpeed <= task.angularSpeed);
|
|
112
|
-
task.stable = slow ? task.stable + dt : 0;
|
|
113
|
-
if (task.stable >= task.stableDuration) {
|
|
114
|
-
this.finish(task,this.evaluate(task,motion,{settled:true}));
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
if (task.elapsed >= task.timeout) this.finish(task,this.evaluate(task,motion,{settled:false,reason:'SETTLE_TIMEOUT'}));
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|