agentscape3d-engine 0.0.0-stage → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +19 -2
- package/cli.mjs +53 -0
- package/dist/AssetCompiler-A99wKf7H.js +2424 -0
- package/dist/AssetCompiler-A99wKf7H.js.map +1 -0
- package/dist/AssetInputContracts-uKYeQu-X.js +245 -0
- package/dist/AssetInputContracts-uKYeQu-X.js.map +1 -0
- package/dist/AssetRecipe-DCaLLXvG.js +67 -0
- package/dist/AssetRecipe-DCaLLXvG.js.map +1 -0
- package/dist/BrowserCodeWorker.js +53850 -0
- package/dist/BrowserCodeWorker.js.map +1 -0
- package/dist/KinematicHypothesisScreen-4v7GBwdv.js +241 -0
- package/dist/KinematicHypothesisScreen-4v7GBwdv.js.map +1 -0
- package/dist/SceneSerializer-CLCzQjL_.js +350 -0
- package/dist/SceneSerializer-CLCzQjL_.js.map +1 -0
- package/dist/StylePack-CD_BC-Mv.js +6317 -0
- package/dist/StylePack-CD_BC-Mv.js.map +1 -0
- package/dist/WorldArchive-dYf1OpSe.js +417 -0
- package/dist/WorldArchive-dYf1OpSe.js.map +1 -0
- package/dist/WorldIO-Dqz4MqTQ.js +149 -0
- package/dist/WorldIO-Dqz4MqTQ.js.map +1 -0
- package/dist/blankWorld-OoOvN_IK.js +75 -0
- package/dist/blankWorld-OoOvN_IK.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-B3HCflvO.js +128 -0
- package/dist/disposeObject3D-B3HCflvO.js.map +1 -0
- package/dist/environments-B1WaICAN.js +4197 -0
- package/dist/environments-B1WaICAN.js.map +1 -0
- package/dist/gltfIO-BMK1hc2D.js +9 -0
- package/dist/gltfIO-BMK1hc2D.js.map +1 -0
- package/dist/grandUrbanBlock-Bdjgc6ZT.js +515 -0
- package/dist/grandUrbanBlock-Bdjgc6ZT.js.map +1 -0
- package/dist/index.d.ts +275 -0
- package/dist/index.js +16239 -0
- package/dist/index.js.map +1 -0
- package/dist/magicCabin-DPQi_jh-.js +11019 -0
- package/dist/magicCabin-DPQi_jh-.js.map +1 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +1 -0
- package/dist/monumentHall-IOLbRZQC.js +403 -0
- package/dist/monumentHall-IOLbRZQC.js.map +1 -0
- package/dist/node.d.ts +16 -0
- package/dist/node.js +26 -0
- package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
- package/dist/ruinedCourtyard-BtaF_aOi.js +696 -0
- package/dist/ruinedCourtyard-BtaF_aOi.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 +8 -0
- package/dist/runtime/application/buildTaskObservation.js +117 -0
- package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +46 -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 +72 -0
- package/dist/runtime/application/createSession.js +66 -0
- package/dist/runtime/application/createWorldAuthoringContext.js +400 -0
- package/dist/runtime/application/generation/GenerationOrchestrator.js +629 -0
- package/dist/runtime/application/generation/GenerationRuntime.js +214 -0
- package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +285 -0
- package/dist/runtime/application/native-scene/CodeProject.js +119 -0
- package/dist/runtime/application/native-scene/CodeProjectModules.js +128 -0
- package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +62 -0
- package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +127 -0
- package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +51 -0
- package/dist/runtime/application/native-scene/NativeSceneHost.js +319 -0
- package/dist/runtime/application/native-scene/NativeSceneOverlay.js +116 -0
- package/dist/runtime/application/native-scene/NativeThreeModule.js +16 -0
- package/dist/runtime/application/object-forge/SceneObjectForge.js +232 -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 +79 -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 +45 -0
- package/dist/runtime/application/scene/SceneEditService.js +144 -0
- package/dist/runtime/application/scene/SceneFacade.js +261 -0
- package/dist/runtime/application/scene/SceneInteractionAdapters.js +40 -0
- package/dist/runtime/application/scene/SceneJobController.js +229 -0
- package/dist/runtime/application/scene/SceneLifecycle.js +57 -0
- package/dist/runtime/application/scene/ScenePackage.js +162 -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 +87 -0
- package/dist/runtime/application/scene/WorldDirectory.js +20 -0
- package/dist/runtime/application/scene/WorldDocument.js +74 -0
- package/dist/runtime/application/scene/WorldIO.js +103 -0
- package/dist/runtime/application/scene/WorldStorage.js +137 -0
- package/dist/runtime/application/skills/SkillRegistry.js +189 -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 +174 -0
- package/dist/runtime/application/world-authoring/ModelRef.js +62 -0
- package/dist/runtime/apps/mcp-server/AUTHORING.md +71 -0
- package/dist/runtime/apps/mcp-server/AgentMcpCompat.js +77 -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 +132 -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 +150 -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 +80 -0
- package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +58 -0
- package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +190 -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 +65 -0
- package/dist/runtime/apps/mcp-server/registerTools.js +225 -0
- package/dist/runtime/apps/mcp-server/sandbox/run.mjs +23 -0
- package/dist/runtime/apps/mcp-server/security.js +21 -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/WorldDiskStorage.js +51 -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/foundation/EventBus.js +18 -0
- package/dist/runtime/foundation/JsonGateway.js +47 -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 +399 -0
- package/dist/runtime/modules/asset/README.md +54 -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 +100 -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/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 +47 -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 +245 -0
- package/dist/runtime/modules/physics/JoltPhysicsBackend.js +850 -0
- package/dist/runtime/modules/physics/PhysicsApiSurface.js +651 -0
- package/dist/runtime/modules/physics/PhysicsBackend.js +88 -0
- package/dist/runtime/modules/physics/RapierPhysicsBackend.js +410 -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/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 +80 -0
- package/dist/runtime/modules/world/runtime/EntityCapabilityRegistry.js +150 -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 +207 -0
- package/dist/runtime/modules/world/runtime/SceneSerializer.js +246 -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 +502 -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 +665 -0
- package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +107 -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 +305 -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 +222 -0
- package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +130 -0
- package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +57 -0
- package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +123 -0
- package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +120 -0
- package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +102 -0
- package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +89 -0
- package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +99 -0
- package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +269 -0
- package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +56 -0
- package/dist/runtime/modules/world/runtime/systems/AudioSystem.js +125 -0
- package/dist/runtime/modules/world/runtime/systems/Instrument.js +38 -0
- package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +728 -0
- package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +269 -0
- package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +469 -0
- package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +1673 -0
- package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +457 -0
- package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +284 -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 +69 -0
- package/dist/runtime/modules/world/verification/RepairEngine.js +49 -0
- package/dist/runtime/modules/world/verification/WorldAcceptance.js +158 -0
- package/dist/runtime/modules/world/verification/WorldValidator.js +65 -0
- package/dist/runtime/package-lock.json +16048 -0
- package/dist/runtime/package.json +105 -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-BWpTl0Wj.js +359 -0
- package/dist/schema-BWpTl0Wj.js.map +1 -0
- package/dist/suzhouGarden-H9tiPgxq.js +6150 -0
- package/dist/suzhouGarden-H9tiPgxq.js.map +1 -0
- package/dist/woodlandWorkshop-D6zzSbHr.js +483 -0
- package/dist/woodlandWorkshop-D6zzSbHr.js.map +1 -0
- package/dist/yuanmingyuan-D6IHqjZ-.js +4955 -0
- package/dist/yuanmingyuan-D6IHqjZ-.js.map +1 -0
- package/package.json +70 -4
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// A read-only semantic projection. State and geometry remain owned by their providers.
|
|
2
|
+
const spatialPredicates = new Set(['ON', 'NEAR', 'INSIDE', 'CONTAINS', 'SUPPORTS']);
|
|
3
|
+
|
|
4
|
+
function recordFor(runtime, id) {
|
|
5
|
+
if (!runtime?.store?.get || runtime.store.has?.(id) === false) return null;
|
|
6
|
+
try { return runtime.store.get(id) || null; }
|
|
7
|
+
catch { return null; }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function unknown(base, reason) { return { ...base, status:'unknown', reason }; }
|
|
11
|
+
|
|
12
|
+
export class SemanticWorldView {
|
|
13
|
+
constructor(runtime) { this.runtime = runtime; }
|
|
14
|
+
|
|
15
|
+
entity(id) {
|
|
16
|
+
const runtime = this.runtime;
|
|
17
|
+
const physical = recordFor(runtime, id);
|
|
18
|
+
const project = Boolean(runtime?.projectCapabilities?.has?.(id));
|
|
19
|
+
if (physical) { const providers=['runtime',...(project?['project']:[]),...(runtime?.thermal?.has?.(id)?['simulation']:[])];
|
|
20
|
+
return { exists:true,source:'runtime',...(providers.length>1?{providers}:{}) }; }
|
|
21
|
+
if (runtime?.affordances?.get?.(id)) return { exists:true, source:'environment' };
|
|
22
|
+
if (project && runtime.projectCapabilities.attachmentOf?.(id) === 'runtime') {
|
|
23
|
+
return { exists:false, source:'none', reason:'PROJECT_ATTACHMENT_TARGET_MISSING' };
|
|
24
|
+
}
|
|
25
|
+
if (project) return { exists:true, source:'project' };
|
|
26
|
+
return { exists:false, source:'none', reason:'OBJECT_NOT_FOUND' };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
state(targetId, stateKey, {source = null} = {}) {
|
|
30
|
+
const owner = this.entity(targetId);
|
|
31
|
+
const base = { kind:'state', targetId, stateKey, source:source || owner.source };
|
|
32
|
+
if (!owner.exists) return unknown(base, owner.reason || 'OBJECT_NOT_FOUND');
|
|
33
|
+
|
|
34
|
+
const runtime = this.runtime;
|
|
35
|
+
const readers = [];
|
|
36
|
+
const record = recordFor(runtime, targetId);
|
|
37
|
+
if (record) readers.push(['runtime', () => record.state]);
|
|
38
|
+
const environment = runtime?.affordances?.get?.(targetId);
|
|
39
|
+
if (environment) readers.push(['environment', () => {
|
|
40
|
+
if (environment.kind === 'text') {
|
|
41
|
+
const error = new Error('ENVIRONMENT_TEXT_REQUIRES_ACTOR_READ');
|
|
42
|
+
error.code = 'ENVIRONMENT_TEXT_REQUIRES_ACTOR_READ'; throw error;
|
|
43
|
+
}
|
|
44
|
+
return environment.read?.();
|
|
45
|
+
}]);
|
|
46
|
+
if (runtime?.projectCapabilities?.has?.(targetId)) {
|
|
47
|
+
readers.push(['project', () => runtime.projectCapabilities.readState(targetId)]);
|
|
48
|
+
}
|
|
49
|
+
if (runtime?.thermal?.has?.(targetId)) readers.push(['simulation',()=>runtime.thermal.readState(targetId)]);
|
|
50
|
+
const selected = readers.filter(([provider]) => source == null || provider === source);
|
|
51
|
+
if (!selected.length) return unknown(base, 'STATE_PROVIDER_UNAVAILABLE');
|
|
52
|
+
|
|
53
|
+
const found = [];
|
|
54
|
+
for (const [provider, read] of selected) {
|
|
55
|
+
let state;
|
|
56
|
+
try { state = read(); }
|
|
57
|
+
catch (error) { return unknown({ ...base, source:provider }, error?.code === 'ENVIRONMENT_TEXT_REQUIRES_ACTOR_READ'
|
|
58
|
+
? error.code : 'STATE_READ_FAILED'); }
|
|
59
|
+
if (state && typeof state === 'object' && Object.hasOwn(state, stateKey) && state[stateKey] !== undefined) {
|
|
60
|
+
found.push({ provider, value:state[stateKey] });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (!found.length) return unknown(base, 'STATE_NOT_OBSERVED');
|
|
64
|
+
if (found.length > 1) return unknown({ ...base, source:'multiple',
|
|
65
|
+
providers:found.map(item => item.provider) }, 'STATE_PROVIDER_CONFLICT');
|
|
66
|
+
return { ...base, source:found[0].provider, status:'known',
|
|
67
|
+
value:structuredClone(found[0].value), evidenceKind:'owner-state' };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
relation({ subject, predicate, object, objectAnyOf, surfaceId } = {}) {
|
|
71
|
+
const targets = objectAnyOf || [object];
|
|
72
|
+
const base = { kind:'relation', subject, predicate, ...(objectAnyOf ? { objectAnyOf:[...objectAnyOf] } : { object }),
|
|
73
|
+
...(surfaceId ? { surfaceId } : {}) };
|
|
74
|
+
const graph = this.runtime?.sceneGraph;
|
|
75
|
+
if (!graph?.list) return { ...base, truth:'unknown', source:'none', reason:'RELATION_GRAPH_UNAVAILABLE' };
|
|
76
|
+
|
|
77
|
+
let unobservable = false;
|
|
78
|
+
try {
|
|
79
|
+
graph.update?.();
|
|
80
|
+
for (const target of targets) {
|
|
81
|
+
const edges = graph.list({ subject, predicate, object:target });
|
|
82
|
+
const matching = edges.find(edge => !surfaceId || edge.meta?.surfaceId === surfaceId);
|
|
83
|
+
if (matching) {
|
|
84
|
+
return { ...base, truth:'true', source:'scene-graph',
|
|
85
|
+
evidenceKind:matching.meta?.evidence || (spatialPredicates.has(predicate) ? 'spatial-relation' : 'declared-relation'),
|
|
86
|
+
evidence:structuredClone(matching) };
|
|
87
|
+
}
|
|
88
|
+
// Absence is a reliable negative only when both objects participate in
|
|
89
|
+
// the active spatial snapshot, or when a known edge has the wrong surface.
|
|
90
|
+
const source = recordFor(this.runtime, subject), destination = recordFor(this.runtime, target);
|
|
91
|
+
const measured = spatialPredicates.has(predicate) && typeof this.runtime?.spatial?.snapshot === 'function'
|
|
92
|
+
&& source?.active !== false && destination?.active !== false && Boolean(source && destination);
|
|
93
|
+
if (!measured && !(surfaceId && edges.length)) unobservable = true;
|
|
94
|
+
}
|
|
95
|
+
} catch {
|
|
96
|
+
return { ...base, truth:'unknown', source:'scene-graph', reason:'RELATION_READ_FAILED' };
|
|
97
|
+
}
|
|
98
|
+
return unobservable
|
|
99
|
+
? { ...base, truth:'unknown', source:'scene-graph', reason:'RELATION_NOT_OBSERVED' }
|
|
100
|
+
: { ...base, truth:'false', source:'scene-graph', reason:'RELATION_NOT_FOUND' };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const positiveFinite = (value) => Number.isFinite(value) && value > 0;
|
|
2
|
+
|
|
3
|
+
export class SimulationClock {
|
|
4
|
+
constructor({ fixedDt = 1 / 60, maxSubSteps = 8, maxFrameDelta = 0.25 } = {}) {
|
|
5
|
+
if (!positiveFinite(fixedDt)) throw new TypeError('fixedDt must be greater than zero');
|
|
6
|
+
if (!Number.isInteger(maxSubSteps) || maxSubSteps < 1) throw new TypeError('maxSubSteps must be a positive integer');
|
|
7
|
+
if (!positiveFinite(maxFrameDelta)) throw new TypeError('maxFrameDelta must be greater than zero');
|
|
8
|
+
this.fixedDt = fixedDt;
|
|
9
|
+
this.maxSubSteps = maxSubSteps;
|
|
10
|
+
this.maxFrameDelta = maxFrameDelta;
|
|
11
|
+
this.reset();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
reset() {
|
|
15
|
+
this.running = false;
|
|
16
|
+
this.tick = 0;
|
|
17
|
+
this.time = 0;
|
|
18
|
+
this.accumulator = 0;
|
|
19
|
+
this.lastTimestamp = null;
|
|
20
|
+
return this.snapshot();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
play() {
|
|
24
|
+
this.running = true;
|
|
25
|
+
this.lastTimestamp = null;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
pause() {
|
|
30
|
+
this.running = false;
|
|
31
|
+
this.lastTimestamp = null;
|
|
32
|
+
this.accumulator = 0;
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
consume(timestampMs) {
|
|
37
|
+
if (!this.running || !Number.isFinite(timestampMs)) return 0;
|
|
38
|
+
if (this.lastTimestamp == null) {
|
|
39
|
+
this.lastTimestamp = timestampMs;
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const elapsed = Math.min(Math.max((timestampMs - this.lastTimestamp) / 1000, 0), this.maxFrameDelta);
|
|
44
|
+
this.lastTimestamp = timestampMs;
|
|
45
|
+
this.accumulator += elapsed;
|
|
46
|
+
|
|
47
|
+
let steps = 0;
|
|
48
|
+
while (this.accumulator + Number.EPSILON >= this.fixedDt && steps < this.maxSubSteps) {
|
|
49
|
+
this.accumulator -= this.fixedDt;
|
|
50
|
+
steps += 1;
|
|
51
|
+
}
|
|
52
|
+
if (steps === this.maxSubSteps) this.accumulator = Math.min(this.accumulator, this.fixedDt);
|
|
53
|
+
return steps;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
advance() {
|
|
57
|
+
this.tick += 1;
|
|
58
|
+
this.time = this.tick * this.fixedDt;
|
|
59
|
+
return this.tick;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
snapshot() {
|
|
63
|
+
return {
|
|
64
|
+
fixedDt: this.fixedDt,
|
|
65
|
+
tick: this.tick,
|
|
66
|
+
time: this.time
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
validateSnapshot(snapshot = {}) {
|
|
71
|
+
if (!snapshot || typeof snapshot !== 'object') throw new TypeError('SimulationClock snapshot must be an object');
|
|
72
|
+
if (snapshot.fixedDt !== this.fixedDt) {
|
|
73
|
+
const error = new Error(`SimulationClock fixedDt mismatch: ${snapshot.fixedDt} != ${this.fixedDt}`);
|
|
74
|
+
error.code = 'SIMULATION_FIXED_DT_MISMATCH';
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
if (!Number.isInteger(snapshot.tick) || snapshot.tick < 0) throw new TypeError('SimulationClock snapshot tick must be a non-negative integer');
|
|
78
|
+
return snapshot;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
restore(snapshot = {}) {
|
|
82
|
+
this.validateSnapshot(snapshot);
|
|
83
|
+
this.tick = snapshot.tick;
|
|
84
|
+
this.time = this.tick * this.fixedDt;
|
|
85
|
+
this.accumulator = 0;
|
|
86
|
+
this.lastTimestamp = null;
|
|
87
|
+
return this.snapshot();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { SimulationClock } from './SimulationClock.js';
|
|
2
|
+
|
|
3
|
+
export const SIMULATION_SESSION_SCHEMA = 'agentscape.simulation-session';
|
|
4
|
+
export const SIMULATION_SESSION_VERSION = 1;
|
|
5
|
+
|
|
6
|
+
export class SimulationSession {
|
|
7
|
+
constructor({
|
|
8
|
+
fixedDt = 1 / 60,
|
|
9
|
+
maxSubSteps = 8,
|
|
10
|
+
executeStep,
|
|
11
|
+
snapshotWorld = null,
|
|
12
|
+
restoreWorld = null,
|
|
13
|
+
events = null
|
|
14
|
+
} = {}) {
|
|
15
|
+
if (typeof executeStep !== 'function') throw new TypeError('SimulationSession requires executeStep');
|
|
16
|
+
if (snapshotWorld !== null && typeof snapshotWorld !== 'function') throw new TypeError('snapshotWorld must be a function');
|
|
17
|
+
if (restoreWorld !== null && typeof restoreWorld !== 'function') throw new TypeError('restoreWorld must be a function');
|
|
18
|
+
this.clock = new SimulationClock({ fixedDt, maxSubSteps });
|
|
19
|
+
this.executeStep = executeStep;
|
|
20
|
+
this.snapshotWorld = snapshotWorld;
|
|
21
|
+
this.restoreWorld = restoreWorld;
|
|
22
|
+
this.events = events;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get fixedDt() { return this.clock.fixedDt; }
|
|
26
|
+
get tick() { return this.clock.tick; }
|
|
27
|
+
get time() { return this.clock.time; }
|
|
28
|
+
get running() { return this.clock.running; }
|
|
29
|
+
|
|
30
|
+
reset() {
|
|
31
|
+
const clock = this.clock.reset();
|
|
32
|
+
this.events?.emit?.('simulation.reset', { tick:clock.tick, time:clock.time, fixedDt:clock.fixedDt });
|
|
33
|
+
return clock;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
play() { return this.clock.play(); }
|
|
37
|
+
pause() { return this.clock.pause(); }
|
|
38
|
+
|
|
39
|
+
step() {
|
|
40
|
+
const tick = this.clock.tick + 1;
|
|
41
|
+
const time = tick * this.fixedDt;
|
|
42
|
+
if (this.executeStep(this.fixedDt, { tick, time }) === false) {
|
|
43
|
+
return { tick:this.tick, time:this.time, dt:0, skipped:true };
|
|
44
|
+
}
|
|
45
|
+
this.clock.advance();
|
|
46
|
+
return { tick:this.tick, time:this.time, dt:this.fixedDt };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
pump(timestampMs = performance.now()) {
|
|
50
|
+
const count = this.clock.consume(timestampMs);
|
|
51
|
+
for (let index = 0; index < count; index += 1) this.step();
|
|
52
|
+
return count;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
snapshot() {
|
|
56
|
+
if (!this.snapshotWorld) throw new Error('SimulationSession snapshotWorld is not configured');
|
|
57
|
+
return {
|
|
58
|
+
schema: SIMULATION_SESSION_SCHEMA,
|
|
59
|
+
schemaVersion: SIMULATION_SESSION_VERSION,
|
|
60
|
+
exact: false,
|
|
61
|
+
scope: 'canonical-world+clock',
|
|
62
|
+
clock: this.clock.snapshot(),
|
|
63
|
+
world: this.snapshotWorld()
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async restore(snapshot) {
|
|
68
|
+
this.validateSnapshot(snapshot);
|
|
69
|
+
if (!this.restoreWorld) throw new Error('SimulationSession restoreWorld is not configured');
|
|
70
|
+
const wasRunning = this.running;
|
|
71
|
+
this.pause();
|
|
72
|
+
try {
|
|
73
|
+
await this.restoreWorld(snapshot.world);
|
|
74
|
+
this.clock.restore(snapshot.clock);
|
|
75
|
+
} finally {
|
|
76
|
+
if (wasRunning) this.play();
|
|
77
|
+
}
|
|
78
|
+
this.events?.emit?.('simulation.restored', {
|
|
79
|
+
tick:this.tick,
|
|
80
|
+
time:this.time,
|
|
81
|
+
fixedDt:this.fixedDt,
|
|
82
|
+
exact:false
|
|
83
|
+
});
|
|
84
|
+
return snapshot;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
validateSnapshot(snapshot) {
|
|
88
|
+
if (!snapshot || typeof snapshot !== 'object') throw new TypeError('SimulationSession snapshot must be an object');
|
|
89
|
+
if (snapshot.schema !== SIMULATION_SESSION_SCHEMA || snapshot.schemaVersion !== SIMULATION_SESSION_VERSION) {
|
|
90
|
+
throw new Error('Unsupported SimulationSession snapshot');
|
|
91
|
+
}
|
|
92
|
+
if (snapshot.exact !== false || snapshot.scope !== 'canonical-world+clock') {
|
|
93
|
+
throw new Error('SimulationSession v1 only accepts canonical-world+clock snapshots');
|
|
94
|
+
}
|
|
95
|
+
this.clock.validateSnapshot(snapshot.clock);
|
|
96
|
+
if (!snapshot.world || typeof snapshot.world !== 'object') throw new TypeError('SimulationSession snapshot requires world state');
|
|
97
|
+
return snapshot;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import {
|
|
2
|
+
thermalDefinitions,validateThermalStateForProfile
|
|
3
|
+
} from '../../../../foundation/simulation/SimulationProfile.js';
|
|
4
|
+
|
|
5
|
+
const fail=(code)=>Object.assign(new Error(code),{code});
|
|
6
|
+
const MAX_POWER_W=1e9;
|
|
7
|
+
const ROOT='root';
|
|
8
|
+
const SAMPLE_INTERVAL=0.1;
|
|
9
|
+
const MAX_SAMPLES=600;
|
|
10
|
+
const clone=structuredClone;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* An instance owns one or more independent lumped temperature nodes.
|
|
14
|
+
* Declared internal links and solver-observed external body/part contacts
|
|
15
|
+
* exchange energy symmetrically; nothing here claims chemical or phase change.
|
|
16
|
+
*/
|
|
17
|
+
export class ThermalSystem {
|
|
18
|
+
constructor({physics=null,contactProvider=null,isActive=null}={}) {
|
|
19
|
+
this.physics=physics;
|
|
20
|
+
this.contactProvider=contactProvider;
|
|
21
|
+
this.isActive=isActive||(()=>true);
|
|
22
|
+
this.entries=new Map();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
register(id,definition,{scale=1}={}) {
|
|
26
|
+
if(!definition)return false;
|
|
27
|
+
if(this.entries.has(id))throw fail('THERMAL_ENTITY_CONFLICT');
|
|
28
|
+
const {profile,nodes,links}=thermalDefinitions(definition);
|
|
29
|
+
const entry={
|
|
30
|
+
profile,links,elapsedSec:0,samples:[],
|
|
31
|
+
nodes:new Map(nodes.map(node=>[node.id,{
|
|
32
|
+
...node,baseMassKg:node.massKg,
|
|
33
|
+
baseHeatCapacityJPerK:node.heatCapacityJPerK,
|
|
34
|
+
temperatureK:node.thermal.initialTemperatureK,
|
|
35
|
+
heatPowerW:node.thermal.heatPowerW
|
|
36
|
+
}]))
|
|
37
|
+
};
|
|
38
|
+
this.entries.set(id,entry);
|
|
39
|
+
try {this.setScale(id,scale);this._record(entry);}
|
|
40
|
+
catch(error){this.entries.delete(id);throw error;}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
has(id){return this.entries.has(id);}
|
|
45
|
+
list(){return [...this.entries].map(([id,entry])=>({
|
|
46
|
+
id,model:entry.profile.model,nodeCount:entry.nodes.size,
|
|
47
|
+
temperatureK:entry.nodes.get(ROOT).temperatureK
|
|
48
|
+
}));}
|
|
49
|
+
remove(id){return this.entries.delete(id);}
|
|
50
|
+
clear(){this.entries.clear();}
|
|
51
|
+
|
|
52
|
+
_node(id,nodeId=ROOT) {
|
|
53
|
+
const node=this.entries.get(id)?.nodes.get(nodeId);
|
|
54
|
+
if(!node)throw fail(this.entries.has(id)?'THERMAL_NODE_NOT_FOUND':'THERMAL_ENTITY_NOT_FOUND');
|
|
55
|
+
return node;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
assertScale(id,scale) {
|
|
59
|
+
const entry=this.entries.get(id);
|
|
60
|
+
if(!entry)return null;
|
|
61
|
+
const volumeFactor=scale**3;
|
|
62
|
+
const changes=[];
|
|
63
|
+
for(const node of entry.nodes.values()){
|
|
64
|
+
const massKg=node.baseMassKg*volumeFactor;
|
|
65
|
+
const heatCapacityJPerK=node.baseHeatCapacityJPerK*volumeFactor;
|
|
66
|
+
if(!Number.isFinite(massKg)||massKg<=0||!Number.isFinite(heatCapacityJPerK)
|
|
67
|
+
||heatCapacityJPerK<=0||heatCapacityJPerK>1e18)
|
|
68
|
+
throw fail('THERMAL_SCALE_INVALID');
|
|
69
|
+
changes.push({id:node.id,massKg,heatCapacityJPerK});
|
|
70
|
+
}
|
|
71
|
+
return changes;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setScale(id,scale) {
|
|
75
|
+
const changes=this.assertScale(id,scale);
|
|
76
|
+
if(!changes)return;
|
|
77
|
+
for(const next of changes)Object.assign(this._node(id,next.id),{
|
|
78
|
+
massKg:next.massKg,heatCapacityJPerK:next.heatCapacityJPerK
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
readState(id,nodeId=ROOT){
|
|
83
|
+
const node=this.entries.get(id)?.nodes.get(nodeId);
|
|
84
|
+
if(!node)return null;
|
|
85
|
+
return {
|
|
86
|
+
temperatureK:node.temperatureK,
|
|
87
|
+
internalEnergyJ:node.temperatureK*node.heatCapacityJPerK,
|
|
88
|
+
massKg:node.massKg,
|
|
89
|
+
heatCapacityJPerK:node.heatCapacityJPerK,
|
|
90
|
+
heatPowerW:node.heatPowerW
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
inspect(id){
|
|
95
|
+
const entry=this.entries.get(id);
|
|
96
|
+
if(!entry)return null;
|
|
97
|
+
return {
|
|
98
|
+
model:entry.profile.model,evidenceKind:'simulated-lumped-thermal',
|
|
99
|
+
material:clone(entry.nodes.get(ROOT).material),
|
|
100
|
+
state:this.readState(id),
|
|
101
|
+
...(entry.profile.schemaVersion===2 ? {nodes:[...entry.nodes.values()].map(node=>({
|
|
102
|
+
id:node.id,partName:node.partName,material:clone(node.material),
|
|
103
|
+
state:this.readState(id,node.id)
|
|
104
|
+
})),links:clone(entry.links)} : {})
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
setHeatPower(id,powerW,{nodeId=ROOT}={}){
|
|
109
|
+
if(!Number.isFinite(powerW)||Math.abs(powerW)>MAX_POWER_W)
|
|
110
|
+
throw fail('THERMAL_POWER_INVALID');
|
|
111
|
+
this._node(id,nodeId).heatPowerW=powerW;
|
|
112
|
+
this._record(this.entries.get(id));
|
|
113
|
+
return this.readState(id,nodeId);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
capture(id){
|
|
117
|
+
const entry=this.entries.get(id);
|
|
118
|
+
if(!entry)return null;
|
|
119
|
+
if(entry.profile.schemaVersion===1){
|
|
120
|
+
const node=entry.nodes.get(ROOT);
|
|
121
|
+
return {schema:'agentscape.thermal-state',schemaVersion:1,
|
|
122
|
+
temperatureK:node.temperatureK,heatPowerW:node.heatPowerW};
|
|
123
|
+
}
|
|
124
|
+
return {schema:'agentscape.thermal-state',schemaVersion:2,
|
|
125
|
+
nodes:[...entry.nodes.values()].map(node=>({
|
|
126
|
+
id:node.id,temperatureK:node.temperatureK,heatPowerW:node.heatPowerW
|
|
127
|
+
}))};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
validateState(id,state){
|
|
131
|
+
const entry=this.entries.get(id);
|
|
132
|
+
if(!entry)throw fail('THERMAL_ENTITY_NOT_FOUND');
|
|
133
|
+
try{return validateThermalStateForProfile(entry.profile,state);}
|
|
134
|
+
catch(error){throw fail(error.message==='THERMAL_STATE_NODE_MISMATCH'?'THERMAL_STATE_NODE_MISMATCH':'THERMAL_STATE_INVALID');}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
restore(id,state){
|
|
138
|
+
const validated=this.validateState(id,state);
|
|
139
|
+
const entry=this.entries.get(id);
|
|
140
|
+
if(validated.schemaVersion===1){
|
|
141
|
+
Object.assign(entry.nodes.get(ROOT),{
|
|
142
|
+
temperatureK:validated.temperatureK,heatPowerW:validated.heatPowerW
|
|
143
|
+
});
|
|
144
|
+
} else for(const node of validated.nodes){
|
|
145
|
+
Object.assign(entry.nodes.get(node.id),{
|
|
146
|
+
temperatureK:node.temperatureK,heatPowerW:node.heatPowerW
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
entry.elapsedSec=0;
|
|
150
|
+
entry.samples=[];
|
|
151
|
+
this._record(entry);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
_record(entry) {
|
|
155
|
+
const latest={
|
|
156
|
+
timeSec:entry.elapsedSec,
|
|
157
|
+
nodes:Object.fromEntries([...entry.nodes.values()].map(node=>[node.id,{
|
|
158
|
+
temperatureK:node.temperatureK,
|
|
159
|
+
internalEnergyJ:node.temperatureK*node.heatCapacityJPerK,
|
|
160
|
+
heatPowerW:node.heatPowerW
|
|
161
|
+
}]))
|
|
162
|
+
};
|
|
163
|
+
if(entry.samples.at(-1)?.timeSec===entry.elapsedSec)entry.samples[entry.samples.length-1]=latest;
|
|
164
|
+
else entry.samples.push(latest);
|
|
165
|
+
if(entry.samples.length>MAX_SAMPLES)entry.samples.shift();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
series(id,{limit=240,nodeId=null}={}){
|
|
169
|
+
const entry=this.entries.get(id);
|
|
170
|
+
if(!entry)throw fail('THERMAL_ENTITY_NOT_FOUND');
|
|
171
|
+
if(!Number.isInteger(limit)||limit<1||limit>MAX_SAMPLES)throw fail('THERMAL_SERIES_LIMIT_INVALID');
|
|
172
|
+
if(nodeId!=null)this._node(id,nodeId);
|
|
173
|
+
const nodes=[...entry.nodes.values()].filter(node=>nodeId==null||node.id===nodeId)
|
|
174
|
+
.map(node=>({id:node.id,partName:node.partName,material:clone(node.material)}));
|
|
175
|
+
const samples=[...entry.samples];
|
|
176
|
+
if(samples.length && samples.at(-1).timeSec<entry.elapsedSec){
|
|
177
|
+
samples.push({timeSec:entry.elapsedSec,
|
|
178
|
+
nodes:Object.fromEntries([...entry.nodes.values()].map(node=>[node.id,{
|
|
179
|
+
temperatureK:node.temperatureK,
|
|
180
|
+
internalEnergyJ:node.temperatureK*node.heatCapacityJPerK,
|
|
181
|
+
heatPowerW:node.heatPowerW
|
|
182
|
+
}]))});
|
|
183
|
+
}
|
|
184
|
+
return {schema:'agentscape.thermal-series',schemaVersion:1,targetId:id,
|
|
185
|
+
model:entry.profile.model,units:{timeSec:'s',temperatureK:'K',internalEnergyJ:'J',heatPowerW:'W'},
|
|
186
|
+
nodes,samples:samples.slice(-limit).map(sample=>({
|
|
187
|
+
timeSec:sample.timeSec,
|
|
188
|
+
nodes:Object.fromEntries(nodes.map(node=>[node.id,clone(sample.nodes[node.id])]))
|
|
189
|
+
}))
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
contactPairs(ids) {
|
|
194
|
+
if(this.contactProvider)return this.contactProvider(ids);
|
|
195
|
+
if(this.physics?.contactPartPairs)return this.physics.contactPartPairs(ids);
|
|
196
|
+
return this.physics?.contactObjectPairs?.(ids)||[];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
step(dt){
|
|
200
|
+
if(!Number.isFinite(dt)||dt<0)throw fail('THERMAL_STEP_INVALID');
|
|
201
|
+
if(dt===0||!this.entries.size)return;
|
|
202
|
+
const active=[...this.entries].filter(([id])=>this.isActive(id)).sort(([a],[b])=>a.localeCompare(b));
|
|
203
|
+
if(!active.length)return;
|
|
204
|
+
const values=[],index=new Map(),partIndex=new Map();
|
|
205
|
+
for(const [objectId,entry] of active){
|
|
206
|
+
for(const node of entry.nodes.values()){
|
|
207
|
+
const slot=values.length;
|
|
208
|
+
values.push({objectId,entry,node});
|
|
209
|
+
index.set(objectId+'\u0000'+node.id,slot);
|
|
210
|
+
partIndex.set(objectId+'\u0000'+node.partName,slot);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const edges=[];
|
|
215
|
+
for(const [objectId,entry] of active){
|
|
216
|
+
for(const link of entry.links)edges.push({
|
|
217
|
+
a:index.get(objectId+'\u0000'+link.from),
|
|
218
|
+
b:index.get(objectId+'\u0000'+link.to),
|
|
219
|
+
g:link.conductanceWPerK
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const contactOwners=new Set(values.filter(({node})=>node.thermal.contactConductanceWPerK>0)
|
|
224
|
+
.map(({objectId})=>objectId));
|
|
225
|
+
if(contactOwners.size>=2){
|
|
226
|
+
const seen=new Set();
|
|
227
|
+
for(const pair of this.contactPairs([...contactOwners])){
|
|
228
|
+
const a=partIndex.get((pair.sourceId||pair.source?.objectId)+'\u0000'+
|
|
229
|
+
(pair.sourcePartName||pair.source?.partName||'$root'));
|
|
230
|
+
const b=partIndex.get((pair.targetId||pair.target?.objectId)+'\u0000'+
|
|
231
|
+
(pair.targetPartName||pair.target?.partName||'$root'));
|
|
232
|
+
if(a==null||b==null||a===b||values[a].objectId===values[b].objectId)continue;
|
|
233
|
+
const key=[Math.min(a,b),Math.max(a,b)].join(':');
|
|
234
|
+
if(seen.has(key))continue;
|
|
235
|
+
seen.add(key);
|
|
236
|
+
const ga=values[a].node.thermal.contactConductanceWPerK;
|
|
237
|
+
const gb=values[b].node.thermal.contactConductanceWPerK;
|
|
238
|
+
if(ga>0&&gb>0)edges.push({a,b,g:ga*gb/(ga+gb)});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const rates=values.map(({node})=>node.thermal.ambientConductanceWPerK);
|
|
243
|
+
for(const {a,b,g} of edges){rates[a]+=g;rates[b]+=g;}
|
|
244
|
+
const substeps=Math.max(1,Math.ceil(dt*Math.max(...values.map(({node},i)=>
|
|
245
|
+
rates[i]/node.heatCapacityJPerK))/0.25));
|
|
246
|
+
if(substeps>1024)throw fail('THERMAL_STEP_TOO_STIFF');
|
|
247
|
+
const h=dt/substeps;
|
|
248
|
+
let temps=values.map(({node})=>node.temperatureK);
|
|
249
|
+
for(let n=0;n<substeps;n++){
|
|
250
|
+
const q=values.map(({node},i)=>{
|
|
251
|
+
const t=node.thermal;
|
|
252
|
+
return (node.heatPowerW+t.ambientConductanceWPerK*(t.ambientTemperatureK-temps[i]))*h;
|
|
253
|
+
});
|
|
254
|
+
for(const {a,b,g} of edges){
|
|
255
|
+
const dq=g*(temps[b]-temps[a])*h;
|
|
256
|
+
q[a]+=dq;q[b]-=dq;
|
|
257
|
+
}
|
|
258
|
+
const next=temps.map((t,i)=>t+q[i]/values[i].node.heatCapacityJPerK);
|
|
259
|
+
if(next.some(t=>!Number.isFinite(t)||t<0||t>1e6))throw fail('THERMAL_STATE_OUT_OF_RANGE');
|
|
260
|
+
temps=next;
|
|
261
|
+
}
|
|
262
|
+
for(let i=0;i<values.length;i++)values[i].node.temperatureK=temps[i];
|
|
263
|
+
for(const [,entry] of active){
|
|
264
|
+
entry.elapsedSec+=dt;
|
|
265
|
+
if(entry.elapsedSec-(entry.samples.at(-1)?.timeSec??0)>=SAMPLE_INTERVAL-1e-8)
|
|
266
|
+
this._record(entry);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|