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,75 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
// ../../modules/world/content/blankWorld.js
|
|
3
|
+
function createBlankWorld({ id = "blank-world" } = {}) {
|
|
4
|
+
const root = new THREE.Group();
|
|
5
|
+
root.name = "BlankWorld";
|
|
6
|
+
root.userData.environment = id;
|
|
7
|
+
const floor = new THREE.Mesh(new THREE.BoxGeometry(24, .24, 24), new THREE.MeshStandardMaterial({
|
|
8
|
+
color: 9018764,
|
|
9
|
+
roughness: .92
|
|
10
|
+
}));
|
|
11
|
+
floor.name = "Ground";
|
|
12
|
+
floor.position.y = -.12;
|
|
13
|
+
floor.receiveShadow = true;
|
|
14
|
+
root.add(floor);
|
|
15
|
+
root.add(new THREE.HemisphereLight(16777215, 6450038, 2));
|
|
16
|
+
const sun = new THREE.DirectionalLight(16777215, 2.4);
|
|
17
|
+
sun.position.set(-6, 12, 8);
|
|
18
|
+
sun.castShadow = true;
|
|
19
|
+
sun.shadow.mapSize.set(1024, 1024);
|
|
20
|
+
Object.assign(sun.shadow.camera, {
|
|
21
|
+
left: -14,
|
|
22
|
+
right: 14,
|
|
23
|
+
top: 14,
|
|
24
|
+
bottom: -14,
|
|
25
|
+
near: .5,
|
|
26
|
+
far: 32
|
|
27
|
+
});
|
|
28
|
+
root.add(sun);
|
|
29
|
+
return {
|
|
30
|
+
id,
|
|
31
|
+
root,
|
|
32
|
+
floor,
|
|
33
|
+
colliders: [{
|
|
34
|
+
shape: "box",
|
|
35
|
+
halfExtents: [
|
|
36
|
+
12,
|
|
37
|
+
.12,
|
|
38
|
+
12
|
|
39
|
+
],
|
|
40
|
+
translation: [
|
|
41
|
+
0,
|
|
42
|
+
-.12,
|
|
43
|
+
0
|
|
44
|
+
]
|
|
45
|
+
}],
|
|
46
|
+
layout: {
|
|
47
|
+
bounds: {
|
|
48
|
+
min: [-11, -11],
|
|
49
|
+
max: [11, 11]
|
|
50
|
+
},
|
|
51
|
+
groundY: 0,
|
|
52
|
+
margin: 1
|
|
53
|
+
},
|
|
54
|
+
camera: {
|
|
55
|
+
position: [
|
|
56
|
+
7,
|
|
57
|
+
5.5,
|
|
58
|
+
9
|
|
59
|
+
],
|
|
60
|
+
target: [
|
|
61
|
+
0,
|
|
62
|
+
0,
|
|
63
|
+
-1
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
rendering: {
|
|
67
|
+
background: 11126230,
|
|
68
|
+
exposure: 1.05
|
|
69
|
+
},
|
|
70
|
+
dispose() {}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export { createBlankWorld };
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=blankWorld-OoOvN_IK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blankWorld-OoOvN_IK.js","names":[],"sources":["../../../modules/world/content/blankWorld.js"],"sourcesContent":["import * as THREE from 'three';\r\n\r\n// A minimal physical environment: no architecture or pre-existing furniture.\r\n// Furniture and the Agent are spawned separately through the world bootstrap API.\r\nexport function createBlankWorld({ id = 'blank-world' } = {}) {\r\n const root = new THREE.Group();\r\n root.name = 'BlankWorld';\r\n root.userData.environment = id;\r\n\r\n const floor = new THREE.Mesh(\r\n new THREE.BoxGeometry(24, 0.24, 24),\r\n new THREE.MeshStandardMaterial({ color:0x899d8c, roughness:0.92 })\r\n );\r\n floor.name = 'Ground';\r\n floor.position.y = -0.12;\r\n floor.receiveShadow = true;\r\n root.add(floor);\r\n\r\n root.add(new THREE.HemisphereLight(0xffffff, 0x626b76, 2));\r\n const sun = new THREE.DirectionalLight(0xffffff, 2.4);\r\n sun.position.set(-6, 12, 8);\r\n sun.castShadow = true;\r\n sun.shadow.mapSize.set(1024, 1024);\r\n Object.assign(sun.shadow.camera, { left:-14, right:14, top:14, bottom:-14, near:0.5, far:32 });\r\n root.add(sun);\r\n\r\n return {\r\n id, root, floor,\r\n colliders:[{ shape:'box', halfExtents:[12,0.12,12], translation:[0,-0.12,0] }],\r\n layout:{ bounds:{min:[-11,-11],max:[11,11]}, groundY:0, margin:1 },\r\n camera:{ position:[7,5.5,9], target:[0,0,-1] },\r\n rendering:{ background:0xa9c5d6, exposure:1.05 },\r\n dispose() {}\r\n };\r\n}\r\n"],"mappings":";;AAIA,SAAgB,iBAAiB,EAAE,KAAK,kBAAkB,CAAC,GAAG;CAC5D,MAAM,OAAO,IAAI,MAAM,MAAM;CAC7B,KAAK,OAAO;CACZ,KAAK,SAAS,cAAc;CAE5B,MAAM,QAAQ,IAAI,MAAM,KACtB,IAAI,MAAM,YAAY,IAAI,KAAM,EAAE,GAClC,IAAI,MAAM,qBAAqB;EAAE,OAAM;EAAU,WAAU;CAAK,CAAC,CACnE;CACA,MAAM,OAAO;CACb,MAAM,SAAS,IAAI;CACnB,MAAM,gBAAgB;CACtB,KAAK,IAAI,KAAK;CAEd,KAAK,IAAI,IAAI,MAAM,gBAAgB,UAAU,SAAU,CAAC,CAAC;CACzD,MAAM,MAAM,IAAI,MAAM,iBAAiB,UAAU,GAAG;CACpD,IAAI,SAAS,IAAI,IAAI,IAAI,CAAC;CAC1B,IAAI,aAAa;CACjB,IAAI,OAAO,QAAQ,IAAI,MAAM,IAAI;CACjC,OAAO,OAAO,IAAI,OAAO,QAAQ;EAAE,MAAK;EAAK,OAAM;EAAI,KAAI;EAAI,QAAO;EAAK,MAAK;EAAK,KAAI;CAAG,CAAC;CAC7F,KAAK,IAAI,GAAG;CAEZ,OAAO;EACL;EAAI;EAAM;EACV,WAAU,CAAC;GAAE,OAAM;GAAO,aAAY;IAAC;IAAG;IAAK;GAAE;GAAG,aAAY;IAAC;IAAE;IAAM;GAAC;EAAE,CAAC;EAC7E,QAAO;GAAE,QAAO;IAAC,KAAI,CAAC,KAAI,GAAG;IAAE,KAAI,CAAC,IAAG,EAAE;GAAC;GAAG,SAAQ;GAAG,QAAO;EAAE;EACjE,QAAO;GAAE,UAAS;IAAC;IAAE;IAAI;GAAC;GAAG,QAAO;IAAC;IAAE;IAAE;GAAE;EAAE;EAC7C,WAAU;GAAE,YAAW;GAAU,UAAS;EAAK;EAC/C,UAAU,CAAC;CACb;AACF"}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-independent Three.js semantics. The scene and Object3D remain
|
|
3
|
+
* owned and rendered by the host application.
|
|
4
|
+
*/
|
|
5
|
+
export interface SemanticObject3D {
|
|
6
|
+
readonly isObject3D: boolean;
|
|
7
|
+
readonly uuid?: string;
|
|
8
|
+
readonly name?: string;
|
|
9
|
+
readonly parent?: SemanticObject3D | null;
|
|
10
|
+
}
|
|
11
|
+
export interface SemanticScene extends SemanticObject3D {
|
|
12
|
+
readonly isScene: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type SemanticTarget = string | SemanticObject3D;
|
|
15
|
+
export interface SemanticActionContext {
|
|
16
|
+
readonly object: SemanticObject3D;
|
|
17
|
+
readonly world: SemanticWorld;
|
|
18
|
+
readonly signal?: AbortSignal;
|
|
19
|
+
}
|
|
20
|
+
export type SemanticActionFn = (args: unknown, context: SemanticActionContext) => unknown | Promise<unknown>;
|
|
21
|
+
export type SemanticAction = SemanticActionFn | {
|
|
22
|
+
execute: SemanticActionFn;
|
|
23
|
+
description?: string;
|
|
24
|
+
available?: (context: SemanticActionContext) => boolean;
|
|
25
|
+
};
|
|
26
|
+
export interface SemanticDefinition {
|
|
27
|
+
id?: string;
|
|
28
|
+
type?: string;
|
|
29
|
+
label?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
properties?: unknown;
|
|
32
|
+
read?: () => unknown;
|
|
33
|
+
actions?: Record<string, SemanticAction>;
|
|
34
|
+
}
|
|
35
|
+
export interface SemanticEntity {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
type: string;
|
|
39
|
+
label: string;
|
|
40
|
+
description: string;
|
|
41
|
+
properties: unknown;
|
|
42
|
+
attached: boolean;
|
|
43
|
+
state: unknown;
|
|
44
|
+
actions: Array<{ name: string; description: string; available: boolean }>;
|
|
45
|
+
}
|
|
46
|
+
export interface SemanticEvent {
|
|
47
|
+
type: 'entity.registered' | 'entity.unregistered' | 'action.registered' | 'action.unregistered' | 'action.invoked' | 'disposed';
|
|
48
|
+
id: string | null;
|
|
49
|
+
world: SemanticWorld;
|
|
50
|
+
}
|
|
51
|
+
export interface SemanticPlugin {
|
|
52
|
+
install(world: SemanticWorld, options?: unknown): void | (() => void) | { dispose(): void };
|
|
53
|
+
}
|
|
54
|
+
export interface SemanticWorld {
|
|
55
|
+
readonly scene: SemanticScene;
|
|
56
|
+
register(object: SemanticObject3D, definition?: SemanticDefinition): () => boolean;
|
|
57
|
+
unregister(target: SemanticTarget): boolean;
|
|
58
|
+
registerAction(target: SemanticTarget, name: string, action: SemanticAction): () => boolean;
|
|
59
|
+
getObject(target: SemanticTarget): SemanticObject3D | null;
|
|
60
|
+
inspect(target: SemanticTarget): SemanticEntity | null;
|
|
61
|
+
list(options?: { attachedOnly?: boolean }): SemanticEntity[];
|
|
62
|
+
invoke(target: SemanticTarget, name: string, args?: unknown, options?: { signal?: AbortSignal }): Promise<unknown>;
|
|
63
|
+
subscribe(listener: (event: SemanticEvent) => void): () => boolean;
|
|
64
|
+
use(plugin: SemanticPlugin | ((world: SemanticWorld, options?: unknown) => ReturnType<SemanticPlugin['install']>), options?: unknown): () => boolean;
|
|
65
|
+
dispose(): void;
|
|
66
|
+
}
|
|
67
|
+
/** Attach without renderer takeover, Studio, task compiler, MCP, permissions or sandbox. */
|
|
68
|
+
export declare function attach(scene: SemanticScene): SemanticWorld;
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// ../typescript/src/core.js
|
|
2
|
+
/**
|
|
3
|
+
* A framework-agnostic semantic extension for a user-owned Three.js scene.
|
|
4
|
+
* It never creates a renderer, starts a loop, rewrites Object3D or executes code.
|
|
5
|
+
* Policies, transports, persistence, physics and agent tooling belong to plugins.
|
|
6
|
+
*/
|
|
7
|
+
const isObject = (object) => object?.isObject3D === true;
|
|
8
|
+
const fail = (message) => {
|
|
9
|
+
throw new TypeError(message);
|
|
10
|
+
};
|
|
11
|
+
function actionOf(value) {
|
|
12
|
+
if (typeof value === "function") return {
|
|
13
|
+
execute: value,
|
|
14
|
+
description: "",
|
|
15
|
+
available: null
|
|
16
|
+
};
|
|
17
|
+
if (!value || typeof value.execute !== "function") fail("Action requires a function or { execute }");
|
|
18
|
+
if (value.available != null && typeof value.available !== "function") fail("Action available must be a function");
|
|
19
|
+
return {
|
|
20
|
+
execute: value.execute,
|
|
21
|
+
description: value.description || "",
|
|
22
|
+
available: value.available || null
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function parseActions(actions) {
|
|
26
|
+
if (actions == null) return /* @__PURE__ */ new Map();
|
|
27
|
+
if (typeof actions !== "object" || Array.isArray(actions)) fail("Actions must be a name-to-handler object");
|
|
28
|
+
const result = /* @__PURE__ */ new Map();
|
|
29
|
+
for (const [name, action] of Object.entries(actions)) {
|
|
30
|
+
if (!name.trim()) fail("Action name must be non-empty");
|
|
31
|
+
result.set(name, actionOf(action));
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
function inside(root, object) {
|
|
36
|
+
for (let current = object; current; current = current.parent) if (current === root) return true;
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Attach semantic metadata and callable actions to an existing THREE.Scene.
|
|
41
|
+
* Native Three.js behavior and ownership remain entirely with the caller.
|
|
42
|
+
*
|
|
43
|
+
* @param {import('./core.d.ts').SemanticScene} scene
|
|
44
|
+
* @returns {import('./core.d.ts').SemanticWorld}
|
|
45
|
+
*/
|
|
46
|
+
function attach(scene) {
|
|
47
|
+
if (!isObject(scene) || scene.isScene !== true) fail("attach(scene) requires a THREE.Scene");
|
|
48
|
+
const entries = /* @__PURE__ */ new Map();
|
|
49
|
+
const objects = /* @__PURE__ */ new WeakMap();
|
|
50
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
51
|
+
const plugins = [];
|
|
52
|
+
let disposed = false;
|
|
53
|
+
const ensureOpen = () => {
|
|
54
|
+
if (disposed) throw new Error("SEMANTIC_WORLD_DISPOSED");
|
|
55
|
+
};
|
|
56
|
+
let world;
|
|
57
|
+
const find = (value) => typeof value === "string" ? entries.get(value) : objects.get(value);
|
|
58
|
+
const emit = (type, id) => {
|
|
59
|
+
for (const listener of [...listeners]) try {
|
|
60
|
+
listener({
|
|
61
|
+
type,
|
|
62
|
+
id,
|
|
63
|
+
world
|
|
64
|
+
});
|
|
65
|
+
} catch {}
|
|
66
|
+
};
|
|
67
|
+
const describe = (entry) => ({
|
|
68
|
+
id: entry.id,
|
|
69
|
+
name: entry.object.name || "",
|
|
70
|
+
type: entry.type,
|
|
71
|
+
label: entry.label,
|
|
72
|
+
description: entry.description,
|
|
73
|
+
properties: entry.properties,
|
|
74
|
+
attached: inside(scene, entry.object),
|
|
75
|
+
state: entry.read ? entry.read() : {},
|
|
76
|
+
actions: [...entry.actions].map(([name, action]) => ({
|
|
77
|
+
name,
|
|
78
|
+
description: action.description,
|
|
79
|
+
available: action.available ? Boolean(action.available({
|
|
80
|
+
object: entry.object,
|
|
81
|
+
world
|
|
82
|
+
})) : true
|
|
83
|
+
}))
|
|
84
|
+
});
|
|
85
|
+
function unregister(target) {
|
|
86
|
+
ensureOpen();
|
|
87
|
+
const entry = find(target);
|
|
88
|
+
if (!entry) return false;
|
|
89
|
+
entries.delete(entry.id);
|
|
90
|
+
objects.delete(entry.object);
|
|
91
|
+
emit("entity.unregistered", entry.id);
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
function register(object, definition = {}) {
|
|
95
|
+
ensureOpen();
|
|
96
|
+
if (!isObject(object)) fail("register(object) requires a THREE.Object3D");
|
|
97
|
+
if (!definition || typeof definition !== "object" || Array.isArray(definition)) fail("Invalid semantic definition");
|
|
98
|
+
const id = definition.id ?? object.uuid;
|
|
99
|
+
if (typeof id !== "string" || !id.trim()) fail("Entity id must be a non-empty string");
|
|
100
|
+
if (entries.has(id) || objects.has(object)) fail("SEMANTIC_ENTITY_CONFLICT");
|
|
101
|
+
if (definition.read != null && typeof definition.read !== "function") fail("Entity read must be a function");
|
|
102
|
+
const actions = parseActions(definition.actions);
|
|
103
|
+
const entry = {
|
|
104
|
+
id,
|
|
105
|
+
object,
|
|
106
|
+
type: definition.type || "",
|
|
107
|
+
label: definition.label || object.name || id,
|
|
108
|
+
description: definition.description || "",
|
|
109
|
+
properties: definition.properties ?? {},
|
|
110
|
+
read: definition.read || null,
|
|
111
|
+
actions
|
|
112
|
+
};
|
|
113
|
+
entries.set(id, entry);
|
|
114
|
+
objects.set(object, entry);
|
|
115
|
+
emit("entity.registered", id);
|
|
116
|
+
return () => entries.get(id) === entry && unregister(id);
|
|
117
|
+
}
|
|
118
|
+
function registerAction(target, name, value) {
|
|
119
|
+
ensureOpen();
|
|
120
|
+
const entry = find(target);
|
|
121
|
+
if (!entry) fail("SEMANTIC_ENTITY_NOT_FOUND");
|
|
122
|
+
if (typeof name !== "string" || !name.trim()) fail("Action name must be non-empty");
|
|
123
|
+
if (entry.actions.has(name)) fail("SEMANTIC_ACTION_CONFLICT");
|
|
124
|
+
const action = actionOf(value);
|
|
125
|
+
entry.actions.set(name, action);
|
|
126
|
+
emit("action.registered", entry.id);
|
|
127
|
+
return () => {
|
|
128
|
+
if (entries.get(entry.id) !== entry || entry.actions.get(name) !== action) return false;
|
|
129
|
+
entry.actions.delete(name);
|
|
130
|
+
emit("action.unregistered", entry.id);
|
|
131
|
+
return true;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
async function invoke(target, name, args = {}, options = {}) {
|
|
135
|
+
ensureOpen();
|
|
136
|
+
const entry = find(target);
|
|
137
|
+
if (!entry) fail("SEMANTIC_ENTITY_NOT_FOUND");
|
|
138
|
+
const action = entry.actions.get(name);
|
|
139
|
+
if (!action) fail("SEMANTIC_ACTION_NOT_FOUND");
|
|
140
|
+
const context = {
|
|
141
|
+
object: entry.object,
|
|
142
|
+
world,
|
|
143
|
+
signal: options.signal
|
|
144
|
+
};
|
|
145
|
+
if (action.available && !action.available(context)) fail("SEMANTIC_ACTION_UNAVAILABLE");
|
|
146
|
+
const value = await action.execute(args, context);
|
|
147
|
+
emit("action.invoked", entry.id);
|
|
148
|
+
return value;
|
|
149
|
+
}
|
|
150
|
+
function uninstall(pluginEntry) {
|
|
151
|
+
if (!pluginEntry.active) return false;
|
|
152
|
+
pluginEntry.active = false;
|
|
153
|
+
plugins.splice(plugins.indexOf(pluginEntry), 1);
|
|
154
|
+
pluginEntry.teardown?.();
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
world = {
|
|
158
|
+
scene,
|
|
159
|
+
register,
|
|
160
|
+
unregister,
|
|
161
|
+
registerAction,
|
|
162
|
+
getObject(target) {
|
|
163
|
+
ensureOpen();
|
|
164
|
+
return find(target)?.object || null;
|
|
165
|
+
},
|
|
166
|
+
inspect(target) {
|
|
167
|
+
ensureOpen();
|
|
168
|
+
const entry = find(target);
|
|
169
|
+
return entry ? describe(entry) : null;
|
|
170
|
+
},
|
|
171
|
+
list({ attachedOnly = false } = {}) {
|
|
172
|
+
ensureOpen();
|
|
173
|
+
return [...entries.values()].filter((entry) => !attachedOnly || inside(scene, entry.object)).map(describe);
|
|
174
|
+
},
|
|
175
|
+
invoke,
|
|
176
|
+
subscribe(listener) {
|
|
177
|
+
ensureOpen();
|
|
178
|
+
if (typeof listener !== "function") fail("Listener must be a function");
|
|
179
|
+
listeners.add(listener);
|
|
180
|
+
return () => listeners.delete(listener);
|
|
181
|
+
},
|
|
182
|
+
use(plugin, options) {
|
|
183
|
+
ensureOpen();
|
|
184
|
+
const install = typeof plugin === "function" ? plugin : plugin?.install?.bind(plugin);
|
|
185
|
+
if (typeof install !== "function") fail("Plugin requires an install(world, options) function");
|
|
186
|
+
const result = install(world, options);
|
|
187
|
+
const entry = {
|
|
188
|
+
active: true,
|
|
189
|
+
teardown: typeof result === "function" ? result : result?.dispose?.bind(result)
|
|
190
|
+
};
|
|
191
|
+
plugins.push(entry);
|
|
192
|
+
return () => uninstall(entry);
|
|
193
|
+
},
|
|
194
|
+
dispose() {
|
|
195
|
+
if (disposed) return;
|
|
196
|
+
for (const entry of [...plugins].reverse()) try {
|
|
197
|
+
uninstall(entry);
|
|
198
|
+
} catch {}
|
|
199
|
+
for (const id of [...entries.keys()]) unregister(id);
|
|
200
|
+
disposed = true;
|
|
201
|
+
emit("disposed", null);
|
|
202
|
+
listeners.clear();
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
return world;
|
|
206
|
+
}
|
|
207
|
+
export { attach };
|
|
208
|
+
|
|
209
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","names":[],"sources":["../../typescript/src/core.js"],"sourcesContent":["/**\n * A framework-agnostic semantic extension for a user-owned Three.js scene.\n * It never creates a renderer, starts a loop, rewrites Object3D or executes code.\n * Policies, transports, persistence, physics and agent tooling belong to plugins.\n */\nconst isObject = object => object?.isObject3D === true;\nconst fail = message => { throw new TypeError(message); };\n\nfunction actionOf(value) {\n if (typeof value === 'function') return { execute: value, description: '', available: null };\n if (!value || typeof value.execute !== 'function') fail('Action requires a function or { execute }');\n if (value.available != null && typeof value.available !== 'function') fail('Action available must be a function');\n return { execute: value.execute, description: value.description || '', available: value.available || null };\n}\n\nfunction parseActions(actions) {\n if (actions == null) return new Map();\n if (typeof actions !== 'object' || Array.isArray(actions)) fail('Actions must be a name-to-handler object');\n const result = new Map();\n for (const [name, action] of Object.entries(actions)) {\n if (!name.trim()) fail('Action name must be non-empty');\n result.set(name, actionOf(action));\n }\n return result;\n}\n\nfunction inside(root, object) {\n for (let current = object; current; current = current.parent) {\n if (current === root) return true;\n }\n return false;\n}\n\n/**\n * Attach semantic metadata and callable actions to an existing THREE.Scene.\n * Native Three.js behavior and ownership remain entirely with the caller.\n *\n * @param {import('./core.d.ts').SemanticScene} scene\n * @returns {import('./core.d.ts').SemanticWorld}\n */\nexport function attach(scene) {\n if (!isObject(scene) || scene.isScene !== true) fail('attach(scene) requires a THREE.Scene');\n const entries = new Map();\n const objects = new WeakMap();\n const listeners = new Set();\n const plugins = [];\n let disposed = false;\n const ensureOpen = () => { if (disposed) throw new Error('SEMANTIC_WORLD_DISPOSED'); };\n let world;\n\n const find = value => typeof value === 'string' ? entries.get(value) : objects.get(value);\n const emit = (type, id) => {\n for (const listener of [...listeners]) {\n try { listener({ type, id, world }); }\n catch { /* A plugin must not break its host scene. */ }\n }\n };\n const describe = entry => ({\n id: entry.id,\n name: entry.object.name || '',\n type: entry.type,\n label: entry.label,\n description: entry.description,\n properties: entry.properties,\n attached: inside(scene, entry.object),\n state: entry.read ? entry.read() : {},\n actions: [...entry.actions].map(([name, action]) => ({\n name,\n description: action.description,\n available: action.available ? Boolean(action.available({ object: entry.object, world })) : true\n }))\n });\n\n function unregister(target) {\n ensureOpen();\n const entry = find(target);\n if (!entry) return false;\n entries.delete(entry.id);\n objects.delete(entry.object);\n emit('entity.unregistered', entry.id);\n return true;\n }\n\n function register(object, definition = {}) {\n ensureOpen();\n if (!isObject(object)) fail('register(object) requires a THREE.Object3D');\n if (!definition || typeof definition !== 'object' || Array.isArray(definition)) fail('Invalid semantic definition');\n const id = definition.id ?? object.uuid;\n if (typeof id !== 'string' || !id.trim()) fail('Entity id must be a non-empty string');\n if (entries.has(id) || objects.has(object)) fail('SEMANTIC_ENTITY_CONFLICT');\n if (definition.read != null && typeof definition.read !== 'function') fail('Entity read must be a function');\n const actions = parseActions(definition.actions);\n const entry = {\n id, object,\n type: definition.type || '',\n label: definition.label || object.name || id,\n description: definition.description || '',\n properties: definition.properties ?? {},\n read: definition.read || null,\n actions\n };\n entries.set(id, entry);\n objects.set(object, entry);\n emit('entity.registered', id);\n return () => entries.get(id) === entry && unregister(id);\n }\n\n function registerAction(target, name, value) {\n ensureOpen();\n const entry = find(target);\n if (!entry) fail('SEMANTIC_ENTITY_NOT_FOUND');\n if (typeof name !== 'string' || !name.trim()) fail('Action name must be non-empty');\n if (entry.actions.has(name)) fail('SEMANTIC_ACTION_CONFLICT');\n const action = actionOf(value);\n entry.actions.set(name, action);\n emit('action.registered', entry.id);\n return () => {\n if (entries.get(entry.id) !== entry || entry.actions.get(name) !== action) return false;\n entry.actions.delete(name);\n emit('action.unregistered', entry.id);\n return true;\n };\n }\n\n async function invoke(target, name, args = {}, options = {}) {\n ensureOpen();\n const entry = find(target);\n if (!entry) fail('SEMANTIC_ENTITY_NOT_FOUND');\n const action = entry.actions.get(name);\n if (!action) fail('SEMANTIC_ACTION_NOT_FOUND');\n const context = { object: entry.object, world, signal: options.signal };\n if (action.available && !action.available(context)) fail('SEMANTIC_ACTION_UNAVAILABLE');\n const value = await action.execute(args, context);\n emit('action.invoked', entry.id);\n return value;\n }\n\n function uninstall(pluginEntry) {\n if (!pluginEntry.active) return false;\n pluginEntry.active = false;\n plugins.splice(plugins.indexOf(pluginEntry), 1);\n pluginEntry.teardown?.();\n return true;\n }\n\n world = {\n scene,\n register,\n unregister,\n registerAction,\n getObject(target) {\n ensureOpen();\n return find(target)?.object || null;\n },\n inspect(target) {\n ensureOpen();\n const entry = find(target);\n return entry ? describe(entry) : null;\n },\n list({ attachedOnly = false } = {}) {\n ensureOpen();\n return [...entries.values()].filter(entry => !attachedOnly || inside(scene, entry.object)).map(describe);\n },\n invoke,\n subscribe(listener) {\n ensureOpen();\n if (typeof listener !== 'function') fail('Listener must be a function');\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n use(plugin, options) {\n ensureOpen();\n const install = typeof plugin === 'function' ? plugin : plugin?.install?.bind(plugin);\n if (typeof install !== 'function') fail('Plugin requires an install(world, options) function');\n const result = install(world, options);\n const teardown = typeof result === 'function' ? result : result?.dispose?.bind(result);\n const entry = { active: true, teardown };\n plugins.push(entry);\n return () => uninstall(entry);\n },\n dispose() {\n if (disposed) return;\n for (const entry of [...plugins].reverse()) {\n try { uninstall(entry); } catch { /* Host scene disposal must remain reliable. */ }\n }\n for (const id of [...entries.keys()]) unregister(id);\n disposed = true;\n emit('disposed', null);\n listeners.clear();\n }\n };\n return world;\n}\n"],"mappings":";;;;;;AAKA,MAAM,YAAW,WAAU,QAAQ,eAAe;AAClD,MAAM,QAAO,YAAW;CAAE,MAAM,IAAI,UAAU,OAAO;AAAG;AAExD,SAAS,SAAS,OAAO;CACvB,IAAI,OAAO,UAAU,YAAY,OAAO;EAAE,SAAS;EAAO,aAAa;EAAI,WAAW;CAAK;CAC3F,IAAI,CAAC,SAAS,OAAO,MAAM,YAAY,YAAY,KAAK,2CAA2C;CACnG,IAAI,MAAM,aAAa,QAAQ,OAAO,MAAM,cAAc,YAAY,KAAK,qCAAqC;CAChH,OAAO;EAAE,SAAS,MAAM;EAAS,aAAa,MAAM,eAAe;EAAI,WAAW,MAAM,aAAa;CAAK;AAC5G;AAEA,SAAS,aAAa,SAAS;CAC7B,IAAI,WAAW,MAAM,uBAAO,IAAI,IAAI;CACpC,IAAI,OAAO,YAAY,YAAY,MAAM,QAAQ,OAAO,GAAG,KAAK,0CAA0C;CAC1G,MAAM,yBAAS,IAAI,IAAI;CACvB,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,OAAO,GAAG;EACpD,IAAI,CAAC,KAAK,KAAK,GAAG,KAAK,+BAA+B;EACtD,OAAO,IAAI,MAAM,SAAS,MAAM,CAAC;CACnC;CACA,OAAO;AACT;AAEA,SAAS,OAAO,MAAM,QAAQ;CAC5B,KAAK,IAAI,UAAU,QAAQ,SAAS,UAAU,QAAQ,QACpD,IAAI,YAAY,MAAM,OAAO;CAE/B,OAAO;AACT;;;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;GACtE,UAAU,IAAI,QAAQ;GACtB,aAAa,UAAU,OAAO,QAAQ;EACxC;EACA,IAAI,QAAQ,SAAS;GACnB,WAAW;GACX,MAAM,UAAU,OAAO,WAAW,aAAa,SAAS,QAAQ,SAAS,KAAK,MAAM;GACpF,IAAI,OAAO,YAAY,YAAY,KAAK,qDAAqD;GAC7F,MAAM,SAAS,QAAQ,OAAO,OAAO;GAErC,MAAM,QAAQ;IAAE,QAAQ;IAAM,UADb,OAAO,WAAW,aAAa,SAAS,QAAQ,SAAS,KAAK,MAAM;GAC9C;GACvC,QAAQ,KAAK,KAAK;GAClB,aAAa,UAAU,KAAK;EAC9B;EACA,UAAU;GACR,IAAI,UAAU;GACd,KAAK,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,QAAQ,GACvC,IAAI;IAAE,UAAU,KAAK;GAAG,QAAQ,CAAkD;GAEpF,KAAK,MAAM,MAAM,CAAC,GAAG,QAAQ,KAAK,CAAC,GAAG,WAAW,EAAE;GACnD,WAAW;GACX,KAAK,YAAY,IAAI;GACrB,UAAU,MAAM;EAClB;CACF;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.js";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import { acceleratedRaycast, computeBoundsTree, disposeBoundsTree } from "three-mesh-bvh";
|
|
4
|
+
// ../../modules/rendering/spatial/ThreeBvhRuntime.js
|
|
5
|
+
const acceleratedObjects = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const registeredGeometryByObject = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
const geometryReferenceCounts = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
const ownedBoundsTrees = /* @__PURE__ */ new WeakSet();
|
|
9
|
+
let acceleratedObjectCount = 0;
|
|
10
|
+
function canAccelerateMesh(node) {
|
|
11
|
+
return node?.isMesh && node.geometry && !Object.prototype.hasOwnProperty.call(node, "raycast") && node.raycast === THREE.Mesh.prototype.raycast;
|
|
12
|
+
}
|
|
13
|
+
function enableAcceleratedRaycast(node) {
|
|
14
|
+
if (!canAccelerateMesh(node) || acceleratedObjects.has(node)) return false;
|
|
15
|
+
acceleratedObjects.set(node, true);
|
|
16
|
+
node.raycast = acceleratedRaycast;
|
|
17
|
+
acceleratedObjectCount += 1;
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
function restoreAcceleratedRaycast(node) {
|
|
21
|
+
if (!acceleratedObjects.has(node)) return false;
|
|
22
|
+
if (node.raycast === acceleratedRaycast) delete node.raycast;
|
|
23
|
+
acceleratedObjects.delete(node);
|
|
24
|
+
acceleratedObjectCount = Math.max(0, acceleratedObjectCount - 1);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
function releaseGeometry(geometry) {
|
|
28
|
+
if (!geometry) return false;
|
|
29
|
+
const referenceCount = geometryReferenceCounts.get(geometry) || 0;
|
|
30
|
+
if (referenceCount > 1) {
|
|
31
|
+
geometryReferenceCounts.set(geometry, referenceCount - 1);
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
geometryReferenceCounts.delete(geometry);
|
|
35
|
+
return disposeBoundsTreeForGeometry(geometry);
|
|
36
|
+
}
|
|
37
|
+
function computeBoundsTreeForGeometry(geometry, options) {
|
|
38
|
+
if (!geometry || geometry.boundsTree) return false;
|
|
39
|
+
computeBoundsTree.call(geometry, options);
|
|
40
|
+
if (!geometry.boundsTree) return false;
|
|
41
|
+
ownedBoundsTrees.add(geometry);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
function disposeBoundsTreeForGeometry(geometry) {
|
|
45
|
+
if (!geometry?.boundsTree || !ownedBoundsTrees.has(geometry)) return false;
|
|
46
|
+
disposeBoundsTree.call(geometry);
|
|
47
|
+
ownedBoundsTrees.delete(geometry);
|
|
48
|
+
geometryReferenceCounts.delete(geometry);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
function ensureBoundsTrees(root, { accelerateRaycast = true } = {}) {
|
|
52
|
+
let meshCount = 0;
|
|
53
|
+
let builtCount = 0;
|
|
54
|
+
let acceleratedCount = 0;
|
|
55
|
+
root?.traverse?.((node) => {
|
|
56
|
+
if (!node.isMesh || !node.geometry) return;
|
|
57
|
+
meshCount += 1;
|
|
58
|
+
const previousGeometry = registeredGeometryByObject.get(node);
|
|
59
|
+
if (previousGeometry !== node.geometry) {
|
|
60
|
+
releaseGeometry(previousGeometry);
|
|
61
|
+
registeredGeometryByObject.set(node, node.geometry);
|
|
62
|
+
geometryReferenceCounts.set(node.geometry, (geometryReferenceCounts.get(node.geometry) || 0) + 1);
|
|
63
|
+
}
|
|
64
|
+
if (!node.geometry.boundsTree && computeBoundsTreeForGeometry(node.geometry)) builtCount += 1;
|
|
65
|
+
if (accelerateRaycast && enableAcceleratedRaycast(node)) acceleratedCount += 1;
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
meshCount,
|
|
69
|
+
builtCount,
|
|
70
|
+
acceleratedCount
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function disposeBoundsTrees(root) {
|
|
74
|
+
let disposedCount = 0;
|
|
75
|
+
let restoredCount = 0;
|
|
76
|
+
root?.traverse?.((node) => {
|
|
77
|
+
if (!node.isMesh || !node.geometry) return;
|
|
78
|
+
const geometry = registeredGeometryByObject.get(node);
|
|
79
|
+
if (geometry) {
|
|
80
|
+
registeredGeometryByObject.delete(node);
|
|
81
|
+
if (releaseGeometry(geometry)) disposedCount += 1;
|
|
82
|
+
}
|
|
83
|
+
if (restoreAcceleratedRaycast(node)) restoredCount += 1;
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
disposedCount,
|
|
87
|
+
restoredCount
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// ../../modules/rendering/disposeObject3D.js
|
|
91
|
+
var disposeObject3D_exports = /* @__PURE__ */ __exportAll({ disposeObject3D: () => disposeObject3D });
|
|
92
|
+
const disposeTextureValue = (value, textures) => {
|
|
93
|
+
if (value?.isTexture && !textures.has(value)) {
|
|
94
|
+
textures.add(value);
|
|
95
|
+
value.dispose();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const RELEASE_RESOURCE = Symbol("agentscape.release-resource");
|
|
99
|
+
function disposeObject3D(root) {
|
|
100
|
+
if (root?.[RELEASE_RESOURCE]) return root[RELEASE_RESOURCE]();
|
|
101
|
+
disposeBoundsTrees(root);
|
|
102
|
+
const geometries = /* @__PURE__ */ new Set();
|
|
103
|
+
const materials = /* @__PURE__ */ new Set();
|
|
104
|
+
const textures = /* @__PURE__ */ new Set();
|
|
105
|
+
root?.traverse?.((node) => {
|
|
106
|
+
const geometry = node.geometry;
|
|
107
|
+
if (geometry && !geometries.has(geometry)) {
|
|
108
|
+
geometries.add(geometry);
|
|
109
|
+
geometry.disposeBoundsTree?.();
|
|
110
|
+
geometry.dispose?.();
|
|
111
|
+
}
|
|
112
|
+
const list = Array.isArray(node.material) ? node.material : [node.material];
|
|
113
|
+
for (const material of list) {
|
|
114
|
+
if (!material || materials.has(material)) continue;
|
|
115
|
+
materials.add(material);
|
|
116
|
+
for (const value of Object.values(material)) disposeTextureValue(value, textures);
|
|
117
|
+
material.dispose?.();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
geometries: geometries.size,
|
|
122
|
+
materials: materials.size,
|
|
123
|
+
textures: textures.size
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export { ensureBoundsTrees as i, disposeObject3D as n, disposeObject3D_exports as r, RELEASE_RESOURCE as t };
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=disposeObject3D-B3HCflvO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disposeObject3D-B3HCflvO.js","names":[],"sources":["../../../modules/rendering/spatial/ThreeBvhRuntime.js","../../../modules/rendering/disposeObject3D.js"],"sourcesContent":["import * as THREE from \"three\";\nimport { acceleratedRaycast, computeBoundsTree, disposeBoundsTree } from \"three-mesh-bvh\";\n\nconst acceleratedObjects = new WeakMap();\nconst registeredGeometryByObject = new WeakMap();\nconst geometryReferenceCounts = new WeakMap();\nconst ownedBoundsTrees = new WeakSet();\nlet acceleratedObjectCount = 0;\n\nfunction canAccelerateMesh(node) {\n return node?.isMesh\n && node.geometry\n && !Object.prototype.hasOwnProperty.call(node, \"raycast\")\n && node.raycast === THREE.Mesh.prototype.raycast;\n}\n\nfunction enableAcceleratedRaycast(node) {\n if (!canAccelerateMesh(node) || acceleratedObjects.has(node)) return false;\n acceleratedObjects.set(node, true);\n node.raycast = acceleratedRaycast;\n acceleratedObjectCount += 1;\n return true;\n}\n\nfunction restoreAcceleratedRaycast(node) {\n if (!acceleratedObjects.has(node)) return false;\n if (node.raycast === acceleratedRaycast) delete node.raycast;\n acceleratedObjects.delete(node);\n acceleratedObjectCount = Math.max(0, acceleratedObjectCount - 1);\n return true;\n}\n\nfunction releaseGeometry(geometry) {\n if (!geometry) return false;\n const referenceCount = geometryReferenceCounts.get(geometry) || 0;\n if (referenceCount > 1) {\n geometryReferenceCounts.set(geometry, referenceCount - 1);\n return false;\n }\n geometryReferenceCounts.delete(geometry);\n return disposeBoundsTreeForGeometry(geometry);\n}\n\nexport function installThreeBvhRuntime() {\n return bvhRuntimeStatus();\n}\n\nexport function bvhRuntimeStatus() {\n return {\n installed: false,\n scope: \"object-instance\",\n acceleratedObjectCount,\n raycast: acceleratedObjectCount > 0 ? \"three-mesh-bvh\" : \"three-default\"\n };\n}\n\nexport function computeBoundsTreeForGeometry(geometry, options) {\n if (!geometry || geometry.boundsTree) return false;\n computeBoundsTree.call(geometry, options);\n if (!geometry.boundsTree) return false;\n ownedBoundsTrees.add(geometry);\n return true;\n}\n\nexport function disposeBoundsTreeForGeometry(geometry) {\n if (!geometry?.boundsTree || !ownedBoundsTrees.has(geometry)) return false;\n disposeBoundsTree.call(geometry);\n ownedBoundsTrees.delete(geometry);\n geometryReferenceCounts.delete(geometry);\n return true;\n}\n\nexport function ensureBoundsTrees(root, { accelerateRaycast = true } = {}) {\n let meshCount = 0;\n let builtCount = 0;\n let acceleratedCount = 0;\n root?.traverse?.((node) => {\n if (!node.isMesh || !node.geometry) return;\n meshCount += 1;\n\n const previousGeometry = registeredGeometryByObject.get(node);\n if (previousGeometry !== node.geometry) {\n releaseGeometry(previousGeometry);\n registeredGeometryByObject.set(node, node.geometry);\n geometryReferenceCounts.set(node.geometry, (geometryReferenceCounts.get(node.geometry) || 0) + 1);\n }\n\n if (!node.geometry.boundsTree && computeBoundsTreeForGeometry(node.geometry)) builtCount += 1;\n if (accelerateRaycast && enableAcceleratedRaycast(node)) acceleratedCount += 1;\n });\n return { meshCount, builtCount, acceleratedCount };\n}\n\nexport function disposeBoundsTrees(root) {\n let disposedCount = 0;\n let restoredCount = 0;\n root?.traverse?.((node) => {\n if (!node.isMesh || !node.geometry) return;\n const geometry = registeredGeometryByObject.get(node);\n if (geometry) {\n registeredGeometryByObject.delete(node);\n if (releaseGeometry(geometry)) disposedCount += 1;\n }\n if (restoreAcceleratedRaycast(node)) restoredCount += 1;\n });\n return { disposedCount, restoredCount };\n}","import { disposeBoundsTrees } from './spatial/ThreeBvhRuntime.js';\r\n\r\nconst disposeTextureValue = (value, textures) => {\r\n if (value?.isTexture && !textures.has(value)) {\r\n textures.add(value);\r\n value.dispose();\r\n }\r\n};\r\n\r\nexport const RELEASE_RESOURCE = Symbol('agentscape.release-resource');\r\n\r\nexport function disposeObject3D(root) {\r\n if (root?.[RELEASE_RESOURCE]) return root[RELEASE_RESOURCE]();\r\n disposeBoundsTrees(root);\r\n const geometries = new Set();\r\n const materials = new Set();\r\n const textures = new Set();\r\n\r\n root?.traverse?.((node) => {\r\n const geometry = node.geometry;\r\n if (geometry && !geometries.has(geometry)) {\r\n geometries.add(geometry);\r\n geometry.disposeBoundsTree?.();\r\n geometry.dispose?.();\r\n }\r\n\r\n const list = Array.isArray(node.material) ? node.material : [node.material];\r\n for (const material of list) {\r\n if (!material || materials.has(material)) continue;\r\n materials.add(material);\r\n for (const value of Object.values(material)) disposeTextureValue(value, textures);\r\n material.dispose?.();\r\n }\r\n });\r\n\r\n return { geometries: geometries.size, materials: materials.size, textures: textures.size };\r\n}\r\n"],"mappings":";;;;AAGA,MAAM,qCAAqB,IAAI,QAAQ;AACvC,MAAM,6CAA6B,IAAI,QAAQ;AAC/C,MAAM,0CAA0B,IAAI,QAAQ;AAC5C,MAAM,mCAAmB,IAAI,QAAQ;AACrC,IAAI,yBAAyB;AAE7B,SAAS,kBAAkB,MAAM;CAC/B,OAAO,MAAM,UACR,KAAK,YACL,CAAC,OAAO,UAAU,eAAe,KAAK,MAAM,SAAS,KACrD,KAAK,YAAY,MAAM,KAAK,UAAU;AAC7C;AAEA,SAAS,yBAAyB,MAAM;CACtC,IAAI,CAAC,kBAAkB,IAAI,KAAK,mBAAmB,IAAI,IAAI,GAAG,OAAO;CACrE,mBAAmB,IAAI,MAAM,IAAI;CACjC,KAAK,UAAU;CACf,0BAA0B;CAC1B,OAAO;AACT;AAEA,SAAS,0BAA0B,MAAM;CACvC,IAAI,CAAC,mBAAmB,IAAI,IAAI,GAAG,OAAO;CAC1C,IAAI,KAAK,YAAY,oBAAoB,OAAO,KAAK;CACrD,mBAAmB,OAAO,IAAI;CAC9B,yBAAyB,KAAK,IAAI,GAAG,yBAAyB,CAAC;CAC/D,OAAO;AACT;AAEA,SAAS,gBAAgB,UAAU;CACjC,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,iBAAiB,wBAAwB,IAAI,QAAQ,KAAK;CAChE,IAAI,iBAAiB,GAAG;EACtB,wBAAwB,IAAI,UAAU,iBAAiB,CAAC;EACxD,OAAO;CACT;CACA,wBAAwB,OAAO,QAAQ;CACvC,OAAO,6BAA6B,QAAQ;AAC9C;AAeA,SAAgB,6BAA6B,UAAU,SAAS;CAC9D,IAAI,CAAC,YAAY,SAAS,YAAY,OAAO;CAC7C,kBAAkB,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