agentscape3d-engine 0.0.0-stage → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +19 -2
- package/cli.mjs +53 -0
- package/dist/ArticulationVerifier-BfGxXY8V.js +337 -0
- package/dist/ArticulationVerifier-BfGxXY8V.js.map +1 -0
- package/dist/AssetCompiler-BLj09iu1.js +2424 -0
- package/dist/AssetCompiler-BLj09iu1.js.map +1 -0
- package/dist/AssetModule-DME-XaFS.js +2637 -0
- package/dist/AssetModule-DME-XaFS.js.map +1 -0
- package/dist/AssetRecipe-g8dZBhgJ.js +298 -0
- package/dist/AssetRecipe-g8dZBhgJ.js.map +1 -0
- package/dist/BrowserCodeWorker.js +53856 -0
- package/dist/BrowserCodeWorker.js.map +1 -0
- package/dist/CarryCapability-CXwHU5ay.js +104 -0
- package/dist/CarryCapability-CXwHU5ay.js.map +1 -0
- package/dist/KinematicHypothesisScreen-C3TKiuYR.js +241 -0
- package/dist/KinematicHypothesisScreen-C3TKiuYR.js.map +1 -0
- package/dist/ObjectTransform-BlQUNK7c.js +61 -0
- package/dist/ObjectTransform-BlQUNK7c.js.map +1 -0
- package/dist/RapierPhysicsBackend-B2wQe_Vl.js +3259 -0
- package/dist/RapierPhysicsBackend-B2wQe_Vl.js.map +1 -0
- package/dist/RenderingSystem-WIr1ZuGu.js +1042 -0
- package/dist/RenderingSystem-WIr1ZuGu.js.map +1 -0
- package/dist/ScenePresentation-LsYiDxbm.js +152 -0
- package/dist/ScenePresentation-LsYiDxbm.js.map +1 -0
- package/dist/SceneProject-K7HH1s8o.js +2687 -0
- package/dist/SceneProject-K7HH1s8o.js.map +1 -0
- package/dist/SceneSerializer-zOzbX4jZ.js +932 -0
- package/dist/SceneSerializer-zOzbX4jZ.js.map +1 -0
- package/dist/SimulationProfile-DSYZbBLQ.js +165 -0
- package/dist/SimulationProfile-DSYZbBLQ.js.map +1 -0
- package/dist/StylePack-DcRa_kU0.js +88 -0
- package/dist/StylePack-DcRa_kU0.js.map +1 -0
- package/dist/WorldArchive-BiFGLt--.js +451 -0
- package/dist/WorldArchive-BiFGLt--.js.map +1 -0
- package/dist/WorldCommands-Debj7V4L.js +2207 -0
- package/dist/WorldCommands-Debj7V4L.js.map +1 -0
- package/dist/WorldIO-Ch8QBfKY.js +151 -0
- package/dist/WorldIO-Ch8QBfKY.js.map +1 -0
- package/dist/admission-CVEvsrdz.js +121 -0
- package/dist/admission-CVEvsrdz.js.map +1 -0
- package/dist/blankWorld-B0MW6g7q.js +75 -0
- package/dist/blankWorld-B0MW6g7q.js.map +1 -0
- package/dist/core.d.ts +68 -0
- package/dist/core.js +209 -0
- package/dist/core.js.map +1 -0
- package/dist/disposeObject3D-DIMzy0FA.js +128 -0
- package/dist/disposeObject3D-DIMzy0FA.js.map +1 -0
- package/dist/environments-HOe3sJXH.js +567 -0
- package/dist/environments-HOe3sJXH.js.map +1 -0
- package/dist/gltfIO-BzVKLyaL.js +339 -0
- package/dist/gltfIO-BzVKLyaL.js.map +1 -0
- package/dist/grandUrbanBlock-DRndRZjF.js +515 -0
- package/dist/grandUrbanBlock-DRndRZjF.js.map +1 -0
- package/dist/index.d.ts +345 -0
- package/dist/index.js +16952 -0
- package/dist/index.js.map +1 -0
- package/dist/magicCabin-CfBZjx2Q.js +11019 -0
- package/dist/magicCabin-CfBZjx2Q.js.map +1 -0
- package/dist/manifests-D0LwbJ36.js +866 -0
- package/dist/manifests-D0LwbJ36.js.map +1 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +1 -0
- package/dist/monumentHall-awZiGtda.js +403 -0
- package/dist/monumentHall-awZiGtda.js.map +1 -0
- package/dist/node.d.ts +16 -0
- package/dist/node.js +26 -0
- package/dist/parts-DrEcfJRl.js +37 -0
- package/dist/parts-DrEcfJRl.js.map +1 -0
- package/dist/rolldown-runtime-D3KUYPsf.js +12 -0
- package/dist/ruinedCourtyard-DuF7NmUU.js +696 -0
- package/dist/ruinedCourtyard-DuF7NmUU.js.map +1 -0
- package/dist/runtime/application/AgentTools.js +28 -0
- package/dist/runtime/application/README.md +14 -0
- package/dist/runtime/application/agent/ProgressiveAgentTools.js +92 -0
- package/dist/runtime/application/agent/StudioMcpAllowlist.js +10 -0
- package/dist/runtime/application/agent/StudioProjectTools.js +18 -0
- package/dist/runtime/application/agent/TaskEvidence.js +199 -0
- package/dist/runtime/application/buildTaskObservation.js +117 -0
- package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +50 -0
- package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +35 -0
- package/dist/runtime/application/code-execution/BrowserCodeWorker.js +17 -0
- package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +82 -0
- package/dist/runtime/application/createSession.js +66 -0
- package/dist/runtime/application/createWorldAuthoringContext.js +400 -0
- package/dist/runtime/application/generation/GenerationOrchestrator.js +630 -0
- package/dist/runtime/application/generation/GenerationRuntime.js +215 -0
- package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +289 -0
- package/dist/runtime/application/native-scene/CodeProject.js +215 -0
- package/dist/runtime/application/native-scene/CodeProjectModules.js +143 -0
- package/dist/runtime/application/native-scene/ExampleWorldCatalog.js +35 -0
- package/dist/runtime/application/native-scene/NativeArticulation.js +53 -0
- package/dist/runtime/application/native-scene/NativeEditableRegistry.js +150 -0
- package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +85 -0
- package/dist/runtime/application/native-scene/NativeLightingInspection.js +33 -0
- package/dist/runtime/application/native-scene/NativeMaterialInspection.js +52 -0
- package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +127 -0
- package/dist/runtime/application/native-scene/NativePhysicsGeometry.js +64 -0
- package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +51 -0
- package/dist/runtime/application/native-scene/NativeSceneHost.js +406 -0
- package/dist/runtime/application/native-scene/NativeSceneInspection.js +203 -0
- package/dist/runtime/application/native-scene/NativeSceneOverlay.js +116 -0
- package/dist/runtime/application/native-scene/NativeSceneQuery.js +123 -0
- package/dist/runtime/application/native-scene/NativeSceneReview.js +132 -0
- package/dist/runtime/application/native-scene/NativeThreeModule.js +16 -0
- package/dist/runtime/application/native-scene/SceneObserver.js +97 -0
- package/dist/runtime/application/native-scene/VisualCapturePolicy.js +4 -0
- package/dist/runtime/application/object-forge/SceneObjectForge.js +263 -0
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +59 -0
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +22 -0
- package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +40 -0
- package/dist/runtime/application/scene/CapabilityResolver.js +90 -0
- package/dist/runtime/application/scene/NativeEditableContracts.js +18 -0
- package/dist/runtime/application/scene/RequestWindow.js +54 -0
- package/dist/runtime/application/scene/SceneAgentTools.js +21 -0
- package/dist/runtime/application/scene/SceneContracts.js +49 -0
- package/dist/runtime/application/scene/SceneEditService.js +154 -0
- package/dist/runtime/application/scene/SceneFacade.js +356 -0
- package/dist/runtime/application/scene/SceneInteractionAdapters.js +41 -0
- package/dist/runtime/application/scene/SceneJobController.js +320 -0
- package/dist/runtime/application/scene/SceneLifecycle.js +57 -0
- package/dist/runtime/application/scene/ScenePackage.js +173 -0
- package/dist/runtime/application/scene/ScenePersistence.js +50 -0
- package/dist/runtime/application/scene/SceneProject.js +95 -0
- package/dist/runtime/application/scene/SceneSkillNames.js +5 -0
- package/dist/runtime/application/scene/StarterScene.js +56 -0
- package/dist/runtime/application/scene/WorldArchive.js +89 -0
- package/dist/runtime/application/scene/WorldDirectory.js +20 -0
- package/dist/runtime/application/scene/WorldDocument.js +76 -0
- package/dist/runtime/application/scene/WorldIO.js +103 -0
- package/dist/runtime/application/scene/WorldStorage.js +155 -0
- package/dist/runtime/application/skills/SkillRegistry.js +193 -0
- package/dist/runtime/application/skills/packs/acceptanceSkills.js +32 -0
- package/dist/runtime/application/skills/packs/affordanceSkills.js +36 -0
- package/dist/runtime/application/skills/packs/assetSkills.js +46 -0
- package/dist/runtime/application/skills/packs/authoringSkills.js +16 -0
- package/dist/runtime/application/skills/packs/batchSkills.js +22 -0
- package/dist/runtime/application/skills/packs/codeSkills.js +106 -0
- package/dist/runtime/application/skills/packs/generationSkills.js +45 -0
- package/dist/runtime/application/skills/packs/interactionSkills.js +46 -0
- package/dist/runtime/application/skills/packs/recoverySkills.js +80 -0
- package/dist/runtime/application/skills/packs/sceneSkills.js +24 -0
- package/dist/runtime/application/skills/packs/spatialSkills.js +35 -0
- package/dist/runtime/application/skills/packs/verificationSkills.js +14 -0
- package/dist/runtime/application/skills/packs/worldSkills.js +45 -0
- package/dist/runtime/application/skills/registerCoreSkills.js +31 -0
- package/dist/runtime/application/skills/skillPrimitives.js +4 -0
- package/dist/runtime/application/tasks/CabinetCupTask.js +76 -0
- package/dist/runtime/application/tasks.jsonl +67 -0
- package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +42 -0
- package/dist/runtime/application/world-authoring/AuthoringDiff.js +149 -0
- package/dist/runtime/application/world-authoring/AuthoringDocument.js +825 -0
- package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +109 -0
- package/dist/runtime/application/world-authoring/AuthoringIdentity.js +17 -0
- package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +29 -0
- package/dist/runtime/application/world-authoring/AuthoringPatch.js +118 -0
- package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +334 -0
- package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +126 -0
- package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +144 -0
- package/dist/runtime/application/world-authoring/HeadlessImageExport.js +92 -0
- package/dist/runtime/application/world-authoring/ModelRef.js +62 -0
- package/dist/runtime/application/world-authoring/SceneGLBExport.js +88 -0
- package/dist/runtime/apps/mcp-server/AUTHORING.md +71 -0
- package/dist/runtime/apps/mcp-server/AgentMcpCompat.js +68 -0
- package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +1 -0
- package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +30 -0
- package/dist/runtime/apps/mcp-server/BuildEnvironment.js +17 -0
- package/dist/runtime/apps/mcp-server/CodeExecutor.js +71 -0
- package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +42 -0
- package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +66 -0
- package/dist/runtime/apps/mcp-server/FileAssetRepository.js +159 -0
- package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +8 -0
- package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +47 -0
- package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +157 -0
- package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +6 -0
- package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +116 -0
- package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +60 -0
- package/dist/runtime/apps/mcp-server/README.md +269 -0
- package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +1 -0
- package/dist/runtime/apps/mcp-server/SandboxBundle.js +13 -0
- package/dist/runtime/apps/mcp-server/SessionManager.js +148 -0
- package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +75 -0
- package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +246 -0
- package/dist/runtime/apps/mcp-server/StudioProjectToolContracts.js +58 -0
- package/dist/runtime/apps/mcp-server/TransferHttp.js +47 -0
- package/dist/runtime/apps/mcp-server/TransferLimits.js +6 -0
- package/dist/runtime/apps/mcp-server/TransferStore.js +134 -0
- package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +16 -0
- package/dist/runtime/apps/mcp-server/VALIDATION.md +45 -0
- package/dist/runtime/apps/mcp-server/acceptance-evidence.json +332 -0
- package/dist/runtime/apps/mcp-server/errorDiagnostics.js +32 -0
- package/dist/runtime/apps/mcp-server/examples/code-house.js +24 -0
- package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +85 -0
- package/dist/runtime/apps/mcp-server/main.mjs +82 -0
- package/dist/runtime/apps/mcp-server/registerTools.js +274 -0
- package/dist/runtime/apps/mcp-server/sandbox/run.mjs +23 -0
- package/dist/runtime/apps/mcp-server/security.js +23 -0
- package/dist/runtime/apps/mcp-server/tasks.jsonl +9 -0
- package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +157 -0
- package/dist/runtime/apps/server/README.md +7 -0
- package/dist/runtime/apps/server/WorldRepository.js +338 -0
- package/dist/runtime/apps/server/WorldRepositoryHttp.js +96 -0
- package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +278 -0
- package/dist/runtime/apps/server/tasks.jsonl +10 -0
- package/dist/runtime/apps/shared/node/WorldDiskStorage.js +62 -0
- package/dist/runtime/foundation/EventBus.js +26 -0
- package/dist/runtime/foundation/JsonGateway.js +47 -0
- package/dist/runtime/foundation/PngRgba.js +99 -0
- package/dist/runtime/foundation/PolicyEngine.js +21 -0
- package/dist/runtime/foundation/README.md +7 -0
- package/dist/runtime/foundation/TraceRecorder.js +76 -0
- package/dist/runtime/foundation/errors.js +8 -0
- package/dist/runtime/foundation/simulation/SimulationProfile.js +143 -0
- package/dist/runtime/foundation/version.js +2 -0
- package/dist/runtime/modules/agent/README.md +11 -0
- package/dist/runtime/modules/agent/ToolCallingAgent.js +19 -0
- package/dist/runtime/modules/agent/bootstrapWorld.js +10 -0
- package/dist/runtime/modules/agent/buildRecoveryProposals.js +533 -0
- package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +128 -0
- package/dist/runtime/modules/agent/execution/AgentRunResults.js +55 -0
- package/dist/runtime/modules/agent/execution/AgentRunSession.js +393 -0
- package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +40 -0
- package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +19 -0
- package/dist/runtime/modules/agent/prompt/index.js +52 -0
- package/dist/runtime/modules/agent/tasks.jsonl +94 -0
- package/dist/runtime/modules/artifact/ArtifactContentGate.js +144 -0
- package/dist/runtime/modules/artifact/ArtifactDescriptor.js +280 -0
- package/dist/runtime/modules/artifact/ArtifactImporter.js +185 -0
- package/dist/runtime/modules/artifact/ArtifactModule.js +111 -0
- package/dist/runtime/modules/artifact/ArtifactRegistry.js +197 -0
- package/dist/runtime/modules/artifact/IncrementalSha256.js +129 -0
- package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +115 -0
- package/dist/runtime/modules/artifact/README.md +7 -0
- package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +67 -0
- package/dist/runtime/modules/artifact/tasks.jsonl +31 -0
- package/dist/runtime/modules/asset/AssetModule.js +416 -0
- package/dist/runtime/modules/asset/README.md +67 -0
- package/dist/runtime/modules/asset/loading/AssetLoader.js +157 -0
- package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +61 -0
- package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +95 -0
- package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +33 -0
- package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +103 -0
- package/dist/runtime/modules/asset/model/AssetInputContracts.js +139 -0
- package/dist/runtime/modules/asset/model/AssetRef.js +12 -0
- package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +172 -0
- package/dist/runtime/modules/asset/model/ProceduralTextureContract.js +24 -0
- package/dist/runtime/modules/asset/model/admission.js +117 -0
- package/dist/runtime/modules/asset/model/errors.js +6 -0
- package/dist/runtime/modules/asset/model/parts.js +27 -0
- package/dist/runtime/modules/asset/model/resourceBudget.js +10 -0
- package/dist/runtime/modules/asset/model/schema.js +150 -0
- package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +78 -0
- package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +84 -0
- package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +86 -0
- package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +81 -0
- package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +272 -0
- package/dist/runtime/modules/asset/production/AssetRecipe.js +91 -0
- package/dist/runtime/modules/asset/production/ProceduralTexture.js +85 -0
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +45 -0
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +590 -0
- package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +173 -0
- package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +124 -0
- package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +56 -0
- package/dist/runtime/modules/asset/production/compiler/gltfIO.js +6 -0
- package/dist/runtime/modules/asset/production/compiler/partGeometry.js +74 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +63 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +48 -0
- package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +16 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +30 -0
- package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +75 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +20 -0
- package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +34 -0
- package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +32 -0
- package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +116 -0
- package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +84 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +63 -0
- package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +16 -0
- package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +23 -0
- package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +50 -0
- package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +60 -0
- package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +93 -0
- package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +32 -0
- package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +55 -0
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +203 -0
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +43 -0
- package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +33 -0
- package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +60 -0
- package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +23 -0
- package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +198 -0
- package/dist/runtime/modules/asset/registry/AssetCatalog.js +72 -0
- package/dist/runtime/modules/asset/registry/AssetRegistry.js +51 -0
- package/dist/runtime/modules/asset/registry/manifests/index.js +173 -0
- package/dist/runtime/modules/asset/tasks.jsonl +87 -0
- package/dist/runtime/modules/generation/README.md +9 -0
- package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +45 -0
- package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +169 -0
- package/dist/runtime/modules/generation/connector/ConnectorClient.js +192 -0
- package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +167 -0
- package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +179 -0
- package/dist/runtime/modules/generation/connector/ConnectorSession.js +202 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +239 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +99 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +91 -0
- package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +50 -0
- package/dist/runtime/modules/generation/providers/ProviderRegistry.js +304 -0
- package/dist/runtime/modules/generation/tasks.jsonl +35 -0
- package/dist/runtime/modules/navigation/NavigationBackend.js +17 -0
- package/dist/runtime/modules/navigation/RecastNavigationBackend.js +263 -0
- package/dist/runtime/modules/physics/JoltPhysicsBackend.js +850 -0
- package/dist/runtime/modules/physics/PhysicsApiSurface.js +660 -0
- package/dist/runtime/modules/physics/PhysicsBackend.js +88 -0
- package/dist/runtime/modules/physics/RapierPhysicsBackend.js +414 -0
- package/dist/runtime/modules/rendering/README.md +7 -0
- package/dist/runtime/modules/rendering/RendererProbe.js +153 -0
- package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +140 -0
- package/dist/runtime/modules/rendering/captureStill.js +54 -0
- package/dist/runtime/modules/rendering/createRenderer.js +76 -0
- package/dist/runtime/modules/rendering/disposeObject3D.js +37 -0
- package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +74 -0
- package/dist/runtime/modules/rendering/spatial/ThreeBvhRuntime.js +107 -0
- package/dist/runtime/modules/rendering/style/StylePack.js +34 -0
- package/dist/runtime/modules/rendering/style/StyleSystem.js +173 -0
- package/dist/runtime/modules/rendering/tasks.jsonl +7 -0
- package/dist/runtime/modules/world/README.md +13 -0
- package/dist/runtime/modules/world/build/WorldBuilder.js +170 -0
- package/dist/runtime/modules/world/compiler/PipelineEngine.js +32 -0
- package/dist/runtime/modules/world/compiler/WorldAdmission.js +43 -0
- package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +68 -0
- package/dist/runtime/modules/world/compiler/WorldCompilation.js +157 -0
- package/dist/runtime/modules/world/compiler/WorldComposer.js +201 -0
- package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +76 -0
- package/dist/runtime/modules/world/compiler/WorldRecompiler.js +356 -0
- package/dist/runtime/modules/world/compiler/WorldRetry.js +75 -0
- package/dist/runtime/modules/world/compiler/createWorldPipeline.js +379 -0
- package/dist/runtime/modules/world/content/blankWorld.js +35 -0
- package/dist/runtime/modules/world/content/environments.js +84 -0
- package/dist/runtime/modules/world/content/grandUrbanBlock.js +189 -0
- package/dist/runtime/modules/world/content/magic-cabin/README.md +28 -0
- package/dist/runtime/modules/world/content/magic-cabin/affordances.js +64 -0
- package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +7078 -0
- package/dist/runtime/modules/world/content/magic-cabin/lighting.js +26 -0
- package/dist/runtime/modules/world/content/magic-cabin/materials.js +20 -0
- package/dist/runtime/modules/world/content/magicCabin.js +190 -0
- package/dist/runtime/modules/world/content/monumentHall.js +154 -0
- package/dist/runtime/modules/world/content/ruinedCourtyard.js +196 -0
- package/dist/runtime/modules/world/content/suzhouGarden/README.md +141 -0
- package/dist/runtime/modules/world/content/suzhouGarden/index.js +137 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +491 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +670 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +578 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +127 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +642 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +650 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +280 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +242 -0
- package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +215 -0
- package/dist/runtime/modules/world/content/woodlandWorkshop.js +192 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/README.md +36 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +351 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +490 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/core.js +505 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/index.js +101 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +435 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +169 -0
- package/dist/runtime/modules/world/content/yuanmingyuan/water.js +245 -0
- package/dist/runtime/modules/world/errors.js +9 -0
- package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +50 -0
- package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +297 -0
- package/dist/runtime/modules/world/runtime/CommandHistory.js +111 -0
- package/dist/runtime/modules/world/runtime/EntityCapabilityRegistry.js +165 -0
- package/dist/runtime/modules/world/runtime/NativeNavigationGeometry.js +84 -0
- package/dist/runtime/modules/world/runtime/NativePhysicsSnapshot.js +245 -0
- package/dist/runtime/modules/world/runtime/ObjectStore.js +31 -0
- package/dist/runtime/modules/world/runtime/ObjectTransform.js +62 -0
- package/dist/runtime/modules/world/runtime/ObservedEntity.js +37 -0
- package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +240 -0
- package/dist/runtime/modules/world/runtime/SceneExtensions.js +36 -0
- package/dist/runtime/modules/world/runtime/ScenePresentation.js +101 -0
- package/dist/runtime/modules/world/runtime/SceneSerializer.js +281 -0
- package/dist/runtime/modules/world/runtime/WorldAuthority.js +41 -0
- package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +14 -0
- package/dist/runtime/modules/world/runtime/WorldCommands.js +503 -0
- package/dist/runtime/modules/world/runtime/WorldObservation.js +71 -0
- package/dist/runtime/modules/world/runtime/WorldQueries.js +340 -0
- package/dist/runtime/modules/world/runtime/WorldRecovery.js +78 -0
- package/dist/runtime/modules/world/runtime/WorldRuntime.js +806 -0
- package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +110 -0
- package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +130 -0
- package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +79 -0
- package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +195 -0
- package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +70 -0
- package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +115 -0
- package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +390 -0
- package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +214 -0
- package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +65 -0
- package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +244 -0
- package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +147 -0
- package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +57 -0
- package/dist/runtime/modules/world/runtime/interaction/ManipulationActions.js +7 -0
- package/dist/runtime/modules/world/runtime/interaction/NativePhysicalTarget.js +31 -0
- package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +123 -0
- package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +134 -0
- package/dist/runtime/modules/world/runtime/semantic/NativePhysicsState.js +89 -0
- package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +129 -0
- package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +89 -0
- package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +104 -0
- package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +269 -0
- package/dist/runtime/modules/world/runtime/simulation/WorldTimeline.js +110 -0
- package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +56 -0
- package/dist/runtime/modules/world/runtime/spatial/VisualMeshBounds.js +41 -0
- package/dist/runtime/modules/world/runtime/systems/AudioSystem.js +306 -0
- package/dist/runtime/modules/world/runtime/systems/Instrument.js +39 -0
- package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +806 -0
- package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +281 -0
- package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +561 -0
- package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +1752 -0
- package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +527 -0
- package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +402 -0
- package/dist/runtime/modules/world/spec/WorldIR.js +165 -0
- package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +86 -0
- package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +51 -0
- package/dist/runtime/modules/world/spec/WorldRevision.js +231 -0
- package/dist/runtime/modules/world/spec/WorldSpec.js +86 -0
- package/dist/runtime/modules/world/tasks.jsonl +530 -0
- package/dist/runtime/modules/world/verification/ArticulationVerifier.js +254 -0
- package/dist/runtime/modules/world/verification/Finding.js +105 -0
- package/dist/runtime/modules/world/verification/InteractionEvidence.js +73 -0
- package/dist/runtime/modules/world/verification/RepairEngine.js +49 -0
- package/dist/runtime/modules/world/verification/VisualLayoutAcceptance.js +58 -0
- package/dist/runtime/modules/world/verification/WorldAcceptance.js +176 -0
- package/dist/runtime/modules/world/verification/WorldValidator.js +67 -0
- package/dist/runtime/package-lock.json +16071 -0
- package/dist/runtime/package.json +106 -0
- package/dist/runtime/public/assets/cabinet.glb +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
- package/dist/schema-DT7K9NjP.js +165 -0
- package/dist/schema-DT7K9NjP.js.map +1 -0
- package/dist/suzhouGarden-Y3hny8j6.js +6150 -0
- package/dist/suzhouGarden-Y3hny8j6.js.map +1 -0
- package/dist/version-CHc-i8ch.js +5 -0
- package/dist/version-CHc-i8ch.js.map +1 -0
- package/dist/woodlandWorkshop-DsScU-cx.js +483 -0
- package/dist/woodlandWorkshop-DsScU-cx.js.map +1 -0
- package/dist/yuanmingyuan-DsFnPzzR.js +4955 -0
- package/dist/yuanmingyuan-DsFnPzzR.js.map +1 -0
- package/package.json +75 -4
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# 资产(Asset)
|
|
2
|
+
|
|
3
|
+
## v2 声明式输入
|
|
4
|
+
|
|
5
|
+
`importRecipe(json)` 接收严格的 Asset Recipe v1:最多 64 个节点、4 层分组、box/sphere/cylinder、有限变换和标准材质(color、roughness、metalness,可选 opacity、emissive、doubleSided)。默认只请求 Visual;Physical/Interactive 必须显式声明物理与行为,声明经过现有 AssetCompiler 和 admission,不替代真实动作验证。复杂关节和高级源码继续走既有隔离构建入口。
|
|
6
|
+
|
|
7
|
+
`importGLB({bytes, level:'visual'})` 在加载前检查自包含 GLB,拒绝外部资源 URI、过多节点和非法层级,再执行现有编译器的几何与资源预算检查。该路径不依赖 Docker。请求 Physical 时明确拒绝,不推断碰撞或降级。Visual Manifest 无 physics/actions,WorldRuntime 不为其创建物理实体。
|
|
8
|
+
|
|
9
|
+
返回 `asset://sha256/<摘要>`、Manifest 和 admission。Recipe 摘要包含规范化定义与编译版本;修改定义产生新资产,已有实例不自动升级。`AssetInputContracts.js` 同时定义严格 Asset Package v1 数据结构,完整包依赖与跨设备迁移由保存阶段验收。
|
|
10
|
+
|
|
11
|
+
`modules/asset` 负责把"已验证的 Artifact"变成 AgentScape Asset,并在之后把 Asset 实例化为 World 运行时对象。入口:`AssetModule.js`。
|
|
12
|
+
|
|
13
|
+
它不调度生成任务,也不拥有 World 实例状态。
|
|
14
|
+
|
|
15
|
+
## 结构
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
asset/
|
|
19
|
+
├─ AssetModule.js composition root
|
|
20
|
+
├─ model/ Asset 定义与有效性
|
|
21
|
+
├─ production/ Artifact → Asset 生产
|
|
22
|
+
├─ registry/ 已知 Asset 元数据与查询
|
|
23
|
+
├─ loading/ Asset → 运行时对象
|
|
24
|
+
└─ persistence/ 持久化本地 Asset 状态
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 边界
|
|
28
|
+
|
|
29
|
+
- `model/`:`AssetRef`、schema、parts、admission、资源预算、Asset 错误。无外部 I/O。
|
|
30
|
+
- `production/`:`AssetProductionPipeline`、compiler、compiler passes/providers、外部 payload adapters。这是唯一的 Artifact → Asset 路径。
|
|
31
|
+
- `registry/`:`AssetRegistry` 是 manifest 身份/注册真相;`AssetCatalog` 是其搜索/读取视图;内置 manifests 在此。
|
|
32
|
+
- `loading/`:`AssetLoader` 把已注册 Asset 解析为 Three.js 运行时对象;`GltfAssetLoader` 与内置 factories 是加载细节。
|
|
33
|
+
- `persistence/`:编译后的字节、持久化 manifests、以及用户批准的 `LocalAssetLibrary`。
|
|
34
|
+
|
|
35
|
+
## 生命周期
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
Artifact
|
|
39
|
+
↓
|
|
40
|
+
production
|
|
41
|
+
↓
|
|
42
|
+
model validation / admission
|
|
43
|
+
↓
|
|
44
|
+
registry
|
|
45
|
+
├─→ persistence
|
|
46
|
+
↓
|
|
47
|
+
loading
|
|
48
|
+
↓
|
|
49
|
+
World Object
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`AssetModule` 是 composition root,拥有 `AssetRegistry`、`AssetLoader`、persistence stores 与 Asset 生产配置。重型几何服务仍在 `services/asset-compiler`。
|
|
53
|
+
|
|
54
|
+
验证:`npm run test:asset`、`npm run assets:validate`、`npm run architecture:validate`。
|
|
55
|
+
|
|
56
|
+
### Recipe 程序化纹理
|
|
57
|
+
|
|
58
|
+
`parts[].material.texture` 是有界的声明式 UV 纹理,不接受任意 Shader、URL 或外部文件。
|
|
59
|
+
支持 `wood`、`stone`、`fabric`、`brushed-metal`,例如:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{"color":"#ffffff","roughness":0.75,"metalness":0,
|
|
63
|
+
"texture":{"pattern":"wood","seed":42,"resolution":128,"frequency":1,
|
|
64
|
+
"contrast":0.7,"normalStrength":0.25,"darkColor":"#775030","lightColor":"#cba06e"}}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
生成的 Base Color PNG 与可选切线空间 Normal PNG 嵌入 GLB,支持现有资产编译器与标准 glTF 读取器;`normalStrength:0` 关闭法线图。`color` 仍是乘色因子,使用白色保留纹理原色。金属感、透明度等仍由现有 PBR 参数声明,不自动从纹理预设推导。分辨率仅允许 64、128、256;单个 Recipe 的唯一纹理声明累计最多 262144 像素(每组最多两张图)。相同规范化声明在一次编译内复用图片。纹理随已编译资产持久化,恢复时无需重新生成;这是近似程序纹理,不是实测材料或真实位移。
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { GltfAssetLoader } from './GltfAssetLoader.js';
|
|
2
|
+
import { Errors } from '../model/errors.js';
|
|
3
|
+
import { disposeObject3D, RELEASE_RESOURCE } from '../../rendering/disposeObject3D.js';
|
|
4
|
+
import { clone as cloneSkeleton } from 'three/examples/jsm/utils/SkeletonUtils.js';
|
|
5
|
+
import { builtinAssetFactories } from './builtins/BuiltinAssets.js';
|
|
6
|
+
|
|
7
|
+
export class AssetLoader {
|
|
8
|
+
constructor({ registry, compiledStore = null, gltfLoader = new GltfAssetLoader(), factories = builtinAssetFactories, maxResidentBytes = 256 * 1024 * 1024 } = {}) {
|
|
9
|
+
if (!registry?.getManifest || !registry?.has) throw new TypeError('AssetLoader requires an AssetRegistry');
|
|
10
|
+
if (!gltfLoader || typeof gltfLoader.loadScene !== 'function') throw new TypeError('AssetLoader requires a glTF asset loader');
|
|
11
|
+
this.registry = registry;
|
|
12
|
+
this.compiledStore = compiledStore;
|
|
13
|
+
this.gltfLoader = gltfLoader;
|
|
14
|
+
this.factories = new Map(Object.entries(factories || {}));
|
|
15
|
+
this.shared = new Map();
|
|
16
|
+
this.residentBytes = 0;
|
|
17
|
+
this.maxResidentBytes = maxResidentBytes;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
registerFactory(assetId, factory) {
|
|
21
|
+
if (typeof factory !== 'function') throw new TypeError(`Asset factory for ${assetId} must be a function`);
|
|
22
|
+
this.factories.set(assetId, factory);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
configureRenderer(renderer) {
|
|
26
|
+
return this.gltfLoader.configureRenderer?.(renderer) ?? false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async instantiate(assetId, { signal } = {}) {
|
|
30
|
+
const manifest = this.registry.getManifest(assetId);
|
|
31
|
+
let object;
|
|
32
|
+
if (['glb', 'compiled'].includes(manifest.source?.kind)) object = await this.instantiateShared(manifest, signal);
|
|
33
|
+
else {
|
|
34
|
+
const factory = this.factories.get(assetId);
|
|
35
|
+
if (!factory) throw Errors.assetNotFound(assetId);
|
|
36
|
+
object = await factory();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
this.validateNodes(object, manifest);
|
|
41
|
+
object.name ||= assetId;
|
|
42
|
+
object.userData.assetId = assetId;
|
|
43
|
+
object.userData.manifest = manifest;
|
|
44
|
+
return { object, manifest };
|
|
45
|
+
} catch (error) {
|
|
46
|
+
disposeObject3D(object);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
stats() {
|
|
52
|
+
return { resources: this.shared.size, references: [...this.shared.values()].reduce((sum, entry) => sum + entry.users, 0),
|
|
53
|
+
estimatedResidentBytes: this.residentBytes, maxResidentBytes: this.maxResidentBytes };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async instantiateShared(manifest, signal) {
|
|
57
|
+
if (signal?.aborted) throw Object.assign(new Error('ASSET_CANCELLED'), { code: 'ASSET_CANCELLED' });
|
|
58
|
+
const source = manifest.source;
|
|
59
|
+
const key = source.kind === 'compiled' ? `compiled:${source.key}` : `glb:${source.url}`;
|
|
60
|
+
let entry = this.shared.get(key);
|
|
61
|
+
if (!entry) {
|
|
62
|
+
entry = { users: 0, bytes: 0, root: null, promise: null };
|
|
63
|
+
this.shared.set(key, entry);
|
|
64
|
+
entry.promise = (async () => {
|
|
65
|
+
const root = source.kind === 'compiled' ? await this.loadCompiled(source) : await this.loadGLB(source.url);
|
|
66
|
+
const bytes = estimateResourceBytes(root);
|
|
67
|
+
if (this.residentBytes + bytes > this.maxResidentBytes) {
|
|
68
|
+
disposeObject3D(root); throw Object.assign(new Error('ASSET_RESIDENT_BUDGET'), { code: 'ASSET_RESIDENT_BUDGET' });
|
|
69
|
+
}
|
|
70
|
+
entry.root = root; entry.bytes = bytes; this.residentBytes += bytes;
|
|
71
|
+
return root;
|
|
72
|
+
})();
|
|
73
|
+
}
|
|
74
|
+
entry.users++;
|
|
75
|
+
const release = () => {
|
|
76
|
+
entry.users--;
|
|
77
|
+
if (!entry.users) {
|
|
78
|
+
this.shared.delete(key);
|
|
79
|
+
this.residentBytes -= entry.bytes;
|
|
80
|
+
if (entry.root) disposeObject3D(entry.root);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
try {
|
|
84
|
+
const root = await entry.promise;
|
|
85
|
+
if (signal?.aborted) throw Object.assign(new Error('ASSET_CANCELLED'), { code: 'ASSET_CANCELLED' });
|
|
86
|
+
this.validateNodes(root, manifest);
|
|
87
|
+
const object = cloneSkeleton(root), materials = new Map();
|
|
88
|
+
object.traverse(node => {
|
|
89
|
+
if (!node.material) return;
|
|
90
|
+
const copy = material => { if (!materials.has(material)) materials.set(material, material.clone()); return materials.get(material); };
|
|
91
|
+
node.material = Array.isArray(node.material) ? node.material.map(copy) : copy(node.material);
|
|
92
|
+
});
|
|
93
|
+
let released = false;
|
|
94
|
+
object[RELEASE_RESOURCE] = () => {
|
|
95
|
+
if (!released) { released = true; for (const material of materials.values()) material.dispose(); release(); }
|
|
96
|
+
return { geometries: 0, materials: materials.size, textures: 0 };
|
|
97
|
+
};
|
|
98
|
+
return object;
|
|
99
|
+
} catch (error) { release(); throw error; }
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
validateNodes(object, manifest) {
|
|
103
|
+
const missing = (manifest.requiredNodes || []).filter((name) => !object.getObjectByName(name));
|
|
104
|
+
if (missing.length) {
|
|
105
|
+
throw Errors.invalidManifest(
|
|
106
|
+
`Asset ${manifest.id} is missing required GLB nodes: ${missing.join(', ')}`,
|
|
107
|
+
{ id:manifest.id, missing }
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async loadCompiled(source) {
|
|
113
|
+
const stored = await this.compiledStore?.get(source.key);
|
|
114
|
+
if (!stored?.bytes) {
|
|
115
|
+
if (source.fallbackUrl) return this.loadGLB(source.fallbackUrl);
|
|
116
|
+
throw new Error(`Compiled asset binary missing: ${source.key}`);
|
|
117
|
+
}
|
|
118
|
+
if (this.gltfLoader.loadBytes) {
|
|
119
|
+
const object = await this.gltfLoader.loadBytes(stored.bytes);
|
|
120
|
+
object.traverse(node => { if (node.isMesh) { node.castShadow = true; node.receiveShadow = true; } });
|
|
121
|
+
return object;
|
|
122
|
+
}
|
|
123
|
+
const blob = new Blob([stored.bytes], { type:'model/gltf-binary' });
|
|
124
|
+
const url = URL.createObjectURL(blob);
|
|
125
|
+
try {
|
|
126
|
+
return await this.loadGLB(url);
|
|
127
|
+
} finally {
|
|
128
|
+
URL.revokeObjectURL(url);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async loadGLB(url) {
|
|
133
|
+
const scene = await this.gltfLoader.loadScene(url);
|
|
134
|
+
scene.traverse((node) => {
|
|
135
|
+
if (!node.isMesh) return;
|
|
136
|
+
node.castShadow = true;
|
|
137
|
+
node.receiveShadow = true;
|
|
138
|
+
});
|
|
139
|
+
return scene;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function estimateResourceBytes(root) {
|
|
144
|
+
const buffers = new Set(), textures = new Set(); let total = 0;
|
|
145
|
+
root.traverse(node => {
|
|
146
|
+
for (const attribute of [...Object.values(node.geometry?.attributes || {}), node.geometry?.index].filter(Boolean)) {
|
|
147
|
+
const buffer = attribute.array?.buffer || attribute.data?.array?.buffer;
|
|
148
|
+
if (buffer && !buffers.has(buffer)) { buffers.add(buffer); total += buffer.byteLength; }
|
|
149
|
+
}
|
|
150
|
+
for (const material of (Array.isArray(node.material) ? node.material : [node.material]).filter(Boolean)) {
|
|
151
|
+
for (const value of Object.values(material)) if (value?.isTexture && !textures.has(value)) {
|
|
152
|
+
textures.add(value); total += (value.image?.width || 0) * (value.image?.height || 0) * 4;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return total;
|
|
157
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
2
|
+
import { KTX2Loader } from 'three/examples/jsm/loaders/KTX2Loader.js';
|
|
3
|
+
import { MeshoptDecoder } from 'three/examples/jsm/libs/meshopt_decoder.module.js';
|
|
4
|
+
import { assertEmbeddedGLB } from '../model/AssetInputContracts.js';
|
|
5
|
+
|
|
6
|
+
export class GltfAssetLoader {
|
|
7
|
+
constructor({
|
|
8
|
+
loader = new GLTFLoader(),
|
|
9
|
+
meshoptDecoder = MeshoptDecoder,
|
|
10
|
+
ktx2TranscoderPath = '/basis/',
|
|
11
|
+
ktx2LoaderFactory = () => new KTX2Loader()
|
|
12
|
+
} = {}) {
|
|
13
|
+
if (!loader || typeof loader.loadAsync !== 'function') {
|
|
14
|
+
throw new TypeError('GltfAssetLoader requires a GLTF-compatible loader');
|
|
15
|
+
}
|
|
16
|
+
if (typeof ktx2LoaderFactory !== 'function') throw new TypeError('GltfAssetLoader ktx2LoaderFactory must be a function');
|
|
17
|
+
this.loader = loader;
|
|
18
|
+
this.ktx2TranscoderPath = ktx2TranscoderPath;
|
|
19
|
+
this.ktx2LoaderFactory = ktx2LoaderFactory;
|
|
20
|
+
this.ktx2Loader = null;
|
|
21
|
+
this.loader.setMeshoptDecoder?.(meshoptDecoder);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
configureRenderer(renderer) {
|
|
26
|
+
if (!renderer) throw new TypeError('GltfAssetLoader.configureRenderer requires a renderer');
|
|
27
|
+
if (typeof this.loader.setKTX2Loader !== 'function' || !this.ktx2TranscoderPath) return false;
|
|
28
|
+
this.ktx2Loader?.dispose?.();
|
|
29
|
+
this.ktx2Loader = this.ktx2LoaderFactory()
|
|
30
|
+
.setTranscoderPath(this.ktx2TranscoderPath)
|
|
31
|
+
.detectSupport(renderer);
|
|
32
|
+
this.loader.setKTX2Loader(this.ktx2Loader);
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async load(url) {
|
|
37
|
+
const gltf = await this.loader.loadAsync(url);
|
|
38
|
+
if (!gltf?.scene) throw new Error(`GLTF has no default scene: ${url}`);
|
|
39
|
+
return gltf;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async loadScene(url) {
|
|
43
|
+
const gltf = await this.load(url);
|
|
44
|
+
gltf.scene.animations = [...(gltf.animations || [])];
|
|
45
|
+
return gltf.scene;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async loadBytes(bytes) {
|
|
49
|
+
if (!globalThis.document && !globalThis.createImageBitmap && assertEmbeddedGLB(bytes).images?.length) throw Object.assign(new Error('Headless texture decoder unavailable'), { code: 'HEADLESS_TEXTURE_DECODER_UNAVAILABLE' });
|
|
50
|
+
const buffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
51
|
+
const gltf = await this.loader.parseAsync(buffer, '');
|
|
52
|
+
if (!gltf?.scene) throw new Error('GLTF has no default scene');
|
|
53
|
+
gltf.scene.animations = [...(gltf.animations || [])];
|
|
54
|
+
return gltf.scene;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
dispose() {
|
|
58
|
+
this.ktx2Loader?.dispose?.();
|
|
59
|
+
this.ktx2Loader = null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createHouseDoor } from './HouseDoor.js';
|
|
2
|
+
import { createIndustrialCabinet } from './IndustrialCabinet.js';
|
|
3
|
+
import * as THREE from 'three';
|
|
4
|
+
|
|
5
|
+
const createAgent = async () => {
|
|
6
|
+
const group = new THREE.Group();
|
|
7
|
+
const body = new THREE.Mesh(
|
|
8
|
+
new THREE.CapsuleGeometry(0.32, 1.06, 8, 16),
|
|
9
|
+
new THREE.MeshStandardMaterial({ color:0x567fbd, roughness:0.28, metalness:0.48 })
|
|
10
|
+
);
|
|
11
|
+
body.position.y = 0.85;
|
|
12
|
+
body.castShadow = body.receiveShadow = true;
|
|
13
|
+
group.add(body);
|
|
14
|
+
|
|
15
|
+
const visor = new THREE.Mesh(
|
|
16
|
+
new THREE.BoxGeometry(0.34, 0.12, 0.06),
|
|
17
|
+
new THREE.MeshBasicMaterial({ color:0xa9d5ff, toneMapped:false })
|
|
18
|
+
);
|
|
19
|
+
visor.position.set(0, 1.12, -0.29);
|
|
20
|
+
group.add(visor);
|
|
21
|
+
|
|
22
|
+
const ring = new THREE.Mesh(
|
|
23
|
+
new THREE.TorusGeometry(0.42, 0.025, 8, 32),
|
|
24
|
+
new THREE.MeshBasicMaterial({ color:0x7db4ff, toneMapped:false })
|
|
25
|
+
);
|
|
26
|
+
ring.position.y = 0.08;
|
|
27
|
+
ring.rotation.x = Math.PI / 2;
|
|
28
|
+
group.add(ring);
|
|
29
|
+
|
|
30
|
+
const hold = new THREE.Group();
|
|
31
|
+
hold.name = 'HoldAnchor';
|
|
32
|
+
hold.position.set(0, 0.95, -0.62);
|
|
33
|
+
group.add(hold);
|
|
34
|
+
return group;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const createChair = async () => {
|
|
38
|
+
const group = new THREE.Group();
|
|
39
|
+
const material = new THREE.MeshStandardMaterial({ color:0x71806a, roughness:0.75 });
|
|
40
|
+
const seat = new THREE.Mesh(new THREE.BoxGeometry(0.76, 0.1, 0.76), material);
|
|
41
|
+
seat.position.y = 0.72;
|
|
42
|
+
seat.castShadow = seat.receiveShadow = true;
|
|
43
|
+
group.add(seat);
|
|
44
|
+
|
|
45
|
+
const back = new THREE.Mesh(new THREE.BoxGeometry(0.76, 0.9, 0.1), material);
|
|
46
|
+
back.position.set(0, 1.16, -0.33);
|
|
47
|
+
back.castShadow = back.receiveShadow = true;
|
|
48
|
+
group.add(back);
|
|
49
|
+
|
|
50
|
+
for (const x of [-0.3, 0.3]) for (const z of [-0.3, 0.3]) {
|
|
51
|
+
const leg = new THREE.Mesh(new THREE.BoxGeometry(0.08, 0.68, 0.08), material);
|
|
52
|
+
leg.position.set(x, 0.34, z);
|
|
53
|
+
leg.castShadow = leg.receiveShadow = true;
|
|
54
|
+
group.add(leg);
|
|
55
|
+
}
|
|
56
|
+
return group;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const createCup = async () => {
|
|
60
|
+
const group = new THREE.Group();
|
|
61
|
+
const body = new THREE.Mesh(
|
|
62
|
+
new THREE.CylinderGeometry(0.16, 0.13, 0.32, 28),
|
|
63
|
+
new THREE.MeshStandardMaterial({ color:0xe9edf5, roughness:0.35 })
|
|
64
|
+
);
|
|
65
|
+
body.position.y = 0.16;
|
|
66
|
+
body.castShadow = body.receiveShadow = true;
|
|
67
|
+
group.add(body);
|
|
68
|
+
return group;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const createTable = async () => {
|
|
72
|
+
const group = new THREE.Group();
|
|
73
|
+
const material = new THREE.MeshStandardMaterial({ color:0x9a6a43, roughness:0.72 });
|
|
74
|
+
const top = new THREE.Mesh(new THREE.BoxGeometry(2.4, 0.16, 1.25), material);
|
|
75
|
+
top.position.y = 1;
|
|
76
|
+
top.castShadow = top.receiveShadow = true;
|
|
77
|
+
group.add(top);
|
|
78
|
+
|
|
79
|
+
for (const x of [-1.02, 1.02]) for (const z of [-0.46, 0.46]) {
|
|
80
|
+
const leg = new THREE.Mesh(new THREE.BoxGeometry(0.14, 0.94, 0.14), material);
|
|
81
|
+
leg.position.set(x, 0.47, z);
|
|
82
|
+
leg.castShadow = leg.receiveShadow = true;
|
|
83
|
+
group.add(leg);
|
|
84
|
+
}
|
|
85
|
+
return group;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const builtinAssetFactories = Object.freeze({
|
|
89
|
+
agent: createAgent,
|
|
90
|
+
chair: createChair,
|
|
91
|
+
cup: createCup,
|
|
92
|
+
table: createTable,
|
|
93
|
+
house_door: createHouseDoor,
|
|
94
|
+
industrial_cabinet: createIndustrialCabinet
|
|
95
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
|
|
3
|
+
// Standalone hinged door, authored from primitive geometry.
|
|
4
|
+
// The hinge pivot is the left edge of the leaf, not its center.
|
|
5
|
+
export async function createHouseDoor() {
|
|
6
|
+
const root = new THREE.Group();
|
|
7
|
+
root.name = 'HouseDoor';
|
|
8
|
+
const hinge = new THREE.Group();
|
|
9
|
+
hinge.name = 'doorHinge';
|
|
10
|
+
hinge.position.set(-0.6, 0.62, 0);
|
|
11
|
+
root.add(hinge);
|
|
12
|
+
|
|
13
|
+
const wood = new THREE.MeshStandardMaterial({color:0x81563b,roughness:0.64});
|
|
14
|
+
const trim = new THREE.MeshStandardMaterial({color:0x5b3927,roughness:0.72});
|
|
15
|
+
const metal = new THREE.MeshStandardMaterial({color:0xc8ae74,metalness:0.65,roughness:0.3});
|
|
16
|
+
const leaf = new THREE.Mesh(new THREE.BoxGeometry(1.18,2.02,0.075), wood);
|
|
17
|
+
leaf.name = 'Door';
|
|
18
|
+
leaf.position.set(0.59,1.01,0);
|
|
19
|
+
leaf.castShadow = leaf.receiveShadow = true;
|
|
20
|
+
hinge.add(leaf);
|
|
21
|
+
for(const y of [0.37,1.64]) {
|
|
22
|
+
const panel=new THREE.Mesh(new THREE.BoxGeometry(0.92,0.48,0.017),trim);
|
|
23
|
+
panel.position.set(0.59,y,0.046);
|
|
24
|
+
panel.castShadow = true;
|
|
25
|
+
hinge.add(panel);
|
|
26
|
+
}
|
|
27
|
+
for(const side of [-1,1]) {
|
|
28
|
+
const knob=new THREE.Mesh(new THREE.SphereGeometry(0.057,12,8),metal);
|
|
29
|
+
knob.position.set(1.04,1.03,side*0.12);
|
|
30
|
+
hinge.add(knob);
|
|
31
|
+
}
|
|
32
|
+
return root;
|
|
33
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
|
|
3
|
+
// Built-in mechanical fixture: two independent hinged doors and two sliding drawers.
|
|
4
|
+
// The named pivot groups are the physics anchors referenced by the Asset Manifest.
|
|
5
|
+
const box = (parent, name, size, position, material) => {
|
|
6
|
+
const mesh = new THREE.Mesh(new THREE.BoxGeometry(...size), material);
|
|
7
|
+
mesh.name = name;
|
|
8
|
+
mesh.position.set(...position);
|
|
9
|
+
mesh.castShadow = true;
|
|
10
|
+
mesh.receiveShadow = true;
|
|
11
|
+
parent.add(mesh);
|
|
12
|
+
return mesh;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const cylinder = (parent, name, radius, height, position, material) => {
|
|
16
|
+
const mesh = new THREE.Mesh(new THREE.CylinderGeometry(radius, radius, height, 12), material);
|
|
17
|
+
mesh.name = name;
|
|
18
|
+
mesh.position.set(...position);
|
|
19
|
+
mesh.castShadow = true;
|
|
20
|
+
parent.add(mesh);
|
|
21
|
+
return mesh;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export async function createIndustrialCabinet() {
|
|
25
|
+
const root = new THREE.Group();
|
|
26
|
+
root.name = 'IndustrialCabinet';
|
|
27
|
+
|
|
28
|
+
const shell = new THREE.MeshStandardMaterial({ color: '#344451', metalness: 0.7, roughness: 0.4 });
|
|
29
|
+
const frame = new THREE.MeshStandardMaterial({ color: '#1a2833', metalness: 0.78, roughness: 0.36 });
|
|
30
|
+
const doorFinish = new THREE.MeshStandardMaterial({ color: '#526e82', metalness: 0.63, roughness: 0.42 });
|
|
31
|
+
const drawerFinish = new THREE.MeshStandardMaterial({ color: '#667d8c', metalness: 0.68, roughness: 0.4 });
|
|
32
|
+
const inset = new THREE.MeshStandardMaterial({ color: '#2b4050', metalness: 0.46, roughness: 0.53 });
|
|
33
|
+
const steel = new THREE.MeshStandardMaterial({ color: '#b5c2ca', metalness: 0.9, roughness: 0.27 });
|
|
34
|
+
const dark = new THREE.MeshStandardMaterial({ color: '#101c26', metalness: 0.23, roughness: 0.7 });
|
|
35
|
+
const accent = new THREE.MeshStandardMaterial({ color: '#e2a84b', metalness: 0.55, roughness: 0.33 });
|
|
36
|
+
|
|
37
|
+
// Hollow fixed carcass: colliders deliberately leave room for the moving parts.
|
|
38
|
+
box(root, 'Body', [1.84, 0.08, 0.73], [0, 0.18, 0], shell);
|
|
39
|
+
box(root, 'Roof', [1.84, 0.08, 0.73], [0, 2.09, 0], shell);
|
|
40
|
+
box(root, 'LeftWall', [0.08, 1.88, 0.73], [-0.88, 1.12, 0], shell);
|
|
41
|
+
box(root, 'RightWall', [0.08, 1.88, 0.73], [0.88, 1.12, 0], shell);
|
|
42
|
+
box(root, 'RearWall', [1.76, 1.88, 0.056], [0, 1.12, -0.35], frame);
|
|
43
|
+
box(root, 'CabinetDivider', [1.72, 0.08, 0.68], [0, 1.12, 0], frame);
|
|
44
|
+
box(root, 'UpperShelf', [1.72, 0.045, 0.66], [0, 1.61, -0.01], shell);
|
|
45
|
+
|
|
46
|
+
for (const x of [-0.74, 0.74]) {
|
|
47
|
+
for (const z of [-0.25, 0.25]) {
|
|
48
|
+
box(root, 'AdjustableFoot', [0.16, 0.13, 0.16], [x, 0.065, z], dark);
|
|
49
|
+
box(root, 'FootTrim', [0.17, 0.025, 0.17], [x, 0.14, z], steel);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
box(root, 'UpperFrontTrim', [1.80, 0.045, 0.035], [0, 2.04, 0.345], frame);
|
|
54
|
+
box(root, 'MiddleFrontTrim', [1.80, 0.042, 0.035], [0, 1.105, 0.345], frame);
|
|
55
|
+
box(root, 'LowerFrontTrim', [1.80, 0.038, 0.035], [0, 0.225, 0.345], frame);
|
|
56
|
+
box(root, 'BrandPlate', [0.38, 0.065, 0.008], [0, 2.14, 0.365], accent);
|
|
57
|
+
|
|
58
|
+
for (const [side, name] of [[-1, 'LeftDoorHinge'], [1, 'RightDoorHinge']]) {
|
|
59
|
+
const door = new THREE.Group();
|
|
60
|
+
door.name = name;
|
|
61
|
+
door.position.set(side * 0.81, 1.59, 0.393);
|
|
62
|
+
root.add(door);
|
|
63
|
+
const direction = -side;
|
|
64
|
+
|
|
65
|
+
box(door, side === -1 ? 'LeftDoor' : 'RightDoor', [0.774, 0.86, 0.056], [direction * 0.395, 0, 0], doorFinish);
|
|
66
|
+
box(door, 'DoorInset', [0.67, 0.67, 0.011], [direction * 0.395, 0, 0.034], inset);
|
|
67
|
+
box(door, 'InsetHeader', [0.59, 0.015, 0.012], [direction * 0.395, 0.26, 0.044], steel);
|
|
68
|
+
for (let n = 0; n < 5; n++) {
|
|
69
|
+
box(door, 'VentSlot', [0.40, 0.019, 0.012], [direction * 0.395, -0.12 + n * 0.048, 0.044], dark);
|
|
70
|
+
}
|
|
71
|
+
const handleX = direction * 0.694;
|
|
72
|
+
box(door, 'DoorHandle', [0.027, 0.23, 0.032], [handleX, -0.02, 0.10], steel);
|
|
73
|
+
for (const y of [-0.135, 0.095]) {
|
|
74
|
+
box(door, 'HandleMount', [0.045, 0.038, 0.065], [handleX, y, 0.067], frame);
|
|
75
|
+
}
|
|
76
|
+
for (const y of [1.27, 1.91]) {
|
|
77
|
+
cylinder(root, 'HingePin', 0.029, 0.15, [side * 0.81, y, 0.407], steel);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
for (const [name, y] of [['UpperDrawerSlide', 0.81], ['LowerDrawerSlide', 0.41]]) {
|
|
82
|
+
const drawer = new THREE.Group();
|
|
83
|
+
drawer.name = name;
|
|
84
|
+
drawer.position.set(0, y, 0);
|
|
85
|
+
root.add(drawer);
|
|
86
|
+
|
|
87
|
+
box(drawer, 'DrawerFloor', [1.45, 0.035, 0.62], [0, -0.137, 0.065], steel);
|
|
88
|
+
box(drawer, 'DrawerRear', [1.45, 0.25, 0.035], [0, -0.002, -0.245], frame);
|
|
89
|
+
for (const side of [-1, 1]) {
|
|
90
|
+
box(drawer, 'DrawerSide', [0.036, 0.25, 0.61], [side * 0.716, -0.002, 0.065], frame);
|
|
91
|
+
}
|
|
92
|
+
box(drawer, 'DrawerFront', [1.55, 0.32, 0.054], [0, 0, 0.393], drawerFinish);
|
|
93
|
+
box(drawer, 'DrawerInset', [1.37, 0.226, 0.012], [0, 0, 0.427], inset);
|
|
94
|
+
box(drawer, 'DrawerPull', [0.35, 0.033, 0.035], [0, 0.013, 0.485], steel);
|
|
95
|
+
for (const x of [-0.15, 0.15]) {
|
|
96
|
+
box(drawer, 'PullMount', [0.04, 0.058, 0.070], [x, 0.013, 0.453], steel);
|
|
97
|
+
}
|
|
98
|
+
box(drawer, 'DrawerLabel', [0.19, 0.035, 0.013], [0.46, 0.095, 0.438], accent);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
root.updateMatrixWorld(true);
|
|
102
|
+
return root;
|
|
103
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { proceduralTextureSchema, MAX_PROCEDURAL_TEXTURE_PIXELS } from './ProceduralTextureContract.js';
|
|
2
|
+
import * as z from 'zod/v4';
|
|
3
|
+
|
|
4
|
+
export const portableAssetDefinition = manifest => Object.fromEntries(['type', 'label', 'actions', 'physics', 'parts', 'surfaces', 'receptacles', 'requiredNodes', 'interactionContract', 'simulation', 'capabilityLevel'].filter(key => manifest[key] != null).map(key => [key, structuredClone(manifest[key])]));
|
|
5
|
+
|
|
6
|
+
export const threeCodeInputSchema = z.object({ kind:z.literal('three-code'), source:z.string().min(1).max(32768), definition:z.record(z.string(),z.unknown()).optional() }).strict();
|
|
7
|
+
export const compiledCodeInputSchema = z.object({kind:z.literal('compiled-code'),id:z.string().regex(/^(pa_|asset_)[a-f0-9]{64}$/),bytes:z.instanceof(Uint8Array).refine(bytes=>bytes.byteLength<=4194304),definition:z.record(z.string(),z.unknown())}).strict();
|
|
8
|
+
|
|
9
|
+
const number = z.number().finite().min(-100).max(100);
|
|
10
|
+
const size = z.number().finite().positive().max(100);
|
|
11
|
+
const vector = z.tuple([number, number, number]);
|
|
12
|
+
const sizes = z.tuple([size, size, size]);
|
|
13
|
+
const nonnegativeSize = z.number().finite().min(0).max(100);
|
|
14
|
+
// Round through-holes along local Y, centered on the XZ face.
|
|
15
|
+
const MAX_RECIPE_HOLES=256;
|
|
16
|
+
const holeSchema=z.object({center:z.tuple([number,number]),radius:z.number().finite().min(.001).max(50)}).strict();
|
|
17
|
+
const perforatedBox=z.object({
|
|
18
|
+
type:z.literal('perforated-box'),size:sizes,holes:z.array(holeSchema).min(1).max(128)
|
|
19
|
+
}).strict().superRefine(({size:[width,height,depth],holes},ctx)=>{
|
|
20
|
+
const clearance=1e-4;
|
|
21
|
+
const issue=(message,index)=>ctx.addIssue({code:'custom',path:['holes',index],message});
|
|
22
|
+
if(height<clearance)ctx.addIssue({code:'custom',path:['size',1],message:'Plate thickness too small'});
|
|
23
|
+
for(let i=0;i<holes.length;i++){
|
|
24
|
+
const {center:[x,z],radius}=holes[i];
|
|
25
|
+
if(Math.abs(x)+radius+clearance>width/2||Math.abs(z)+radius+clearance>depth/2)
|
|
26
|
+
issue('Through-hole must lie inside the plate with positive clearance',i);
|
|
27
|
+
for(let j=0;j<i;j++){
|
|
28
|
+
const other=holes[j];
|
|
29
|
+
if(Math.hypot(x-other.center[0],z-other.center[1])<radius+other.radius+clearance)
|
|
30
|
+
issue('Through-holes must not overlap or touch',i);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const id = z.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/);
|
|
35
|
+
export const packagePath = z.string().max(240).refine(value => value.startsWith('./') && value.slice(2).split('/').every(p => /^[A-Za-z0-9_-][A-Za-z0-9_.-]*$/.test(p) && !p.endsWith('.') && !/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(p)));
|
|
36
|
+
const boxCollider = z.object({ shape: z.literal('box'), halfExtents: sizes, translation: vector.default(() => [0, 0, 0]) }).strict();
|
|
37
|
+
export const assetPhysicsSchema = z.object({ body: z.enum(['fixed', 'dynamic']), mass: size.default(1), friction: z.number().min(0).max(2).default(0.5), carryable:z.boolean().optional(), colliders: z.array(boxCollider).min(1).max(64) }).strict();
|
|
38
|
+
const reviewedPhysics = z.object({ body:z.enum(['fixed','dynamic']), mass:size, friction:z.number().min(0).max(2),
|
|
39
|
+
colliders:z.array(boxCollider).max(64).optional() }).strict();
|
|
40
|
+
export const interactionReviewSchema = z.object({
|
|
41
|
+
proposalId:z.string().regex(/^[a-f0-9]{64}$/), confirmed:z.literal(true), physics:reviewedPhysics,
|
|
42
|
+
parts:z.array(z.object({ id, node:z.string().min(1).max(128), parent:z.string().min(1).max(64).default('$root'),
|
|
43
|
+
physics:reviewedPhysics.refine(value=>value.body==='dynamic','Moving parts require dynamic bodies'),
|
|
44
|
+
joint:z.object({ type:z.enum(['prismatic','revolute']), axis:vector.refine(value=>Math.hypot(...value)>1e-6),
|
|
45
|
+
parentAnchor:vector, childAnchor:vector, limits:z.tuple([number,number]).refine(([a,b])=>a<b && a<=0 && b>=0,'Limits must contain the GLB rest-zero pose'),
|
|
46
|
+
motor:z.object({stiffness:z.number().positive().max(1000),damping:z.number().positive().max(100)}).strict().default(()=>({stiffness:80,damping:12}))
|
|
47
|
+
}).strict()
|
|
48
|
+
}).strict()).max(32).default([])
|
|
49
|
+
}).strict().refine(value=>new Set(value.parts.map(part=>part.id)).size===value.parts.length && new Set(value.parts.map(part=>part.node)).size===value.parts.length,'Duplicate part id or node');
|
|
50
|
+
export const glbInputSchema = z.object({kind:z.literal('glb'),bytes:z.instanceof(Uint8Array),name:z.string().min(1).max(128).optional(),urdfBytes:z.instanceof(Uint8Array).optional(),review:interactionReviewSchema.optional()}).strict();
|
|
51
|
+
export const recipeSchema = z.object({
|
|
52
|
+
schema: z.literal('agentscape.asset-recipe'), schemaVersion: z.literal(1),
|
|
53
|
+
id: z.string().regex(/^[A-Za-z][A-Za-z0-9_-]*(\/[A-Za-z][A-Za-z0-9_-]*)?$/).max(100),
|
|
54
|
+
parts: z.array(z.object({ id, parent: id.optional(), geometry: z.discriminatedUnion('type', [
|
|
55
|
+
z.object({ type: z.literal('box'), size: sizes }).strict(),
|
|
56
|
+
perforatedBox,
|
|
57
|
+
z.object({ type: z.literal('sphere'), radius: size }).strict(),
|
|
58
|
+
z.object({ type: z.literal('ellipsoid'), radii: sizes }).strict(),
|
|
59
|
+
z.object({ type: z.literal('cylinder'), radius: size, height: size }).strict(),
|
|
60
|
+
z.object({ type: z.literal('tapered-cylinder'), radiusTop: nonnegativeSize, radiusBottom: size, height: size }).strict(),
|
|
61
|
+
z.object({ type: z.literal('segment'), from: vector, to: vector, radiusStart: size, radiusEnd: nonnegativeSize })
|
|
62
|
+
.strict().refine(({from, to}) => Math.hypot(...from.map((v, i) => to[i] - v)) > 1e-6, 'Segment endpoints must differ')
|
|
63
|
+
]).optional(), position: vector.default(() => [0, 0, 0]),
|
|
64
|
+
quaternion: z.tuple([number, number, number, number]).refine(q => Math.abs(Math.hypot(...q) - 1) < 0.0001).default(() => [0, 0, 0, 1]),
|
|
65
|
+
scale: z.number().min(0.05).max(20).default(1),
|
|
66
|
+
material: z.object({ color: z.string().regex(/^#[a-fA-F0-9]{6}$/).default('#aaaaaa'), roughness: z.number().min(0).max(1).default(0.7), metalness: z.number().min(0).max(1).default(0), opacity: z.number().min(0).max(1).optional(), emissive: z.string().regex(/^#[a-fA-F0-9]{6}$/).optional(), doubleSided: z.boolean().optional(),
|
|
67
|
+
clearcoat: z.number().min(0).max(1).optional(), clearcoatRoughness: z.number().min(0).max(1).optional(),
|
|
68
|
+
transmission: z.number().min(0).max(1).optional(), ior: z.number().min(1).max(2.5).optional(),
|
|
69
|
+
emissiveIntensity: z.number().min(0).max(100).optional(), texture:proceduralTextureSchema.optional() }).strict().optional()
|
|
70
|
+
}).strict()).min(1).max(64),
|
|
71
|
+
capabilities: z.object({ level: z.enum(['visual', 'physical', 'interactive']), physics: assetPhysicsSchema.optional(),
|
|
72
|
+
actions: z.array(z.enum(['move', 'pickup', 'place'])).max(3).default([]),
|
|
73
|
+
surfaces: z.array(z.object({ id, localPosition: vector, size: z.tuple([size, size]) }).strict()).max(16).default([])
|
|
74
|
+
}).strict().default(() => ({ level: 'visual', actions: [], surfaces: [] }))
|
|
75
|
+
}).strict().superRefine((recipe, ctx) => {
|
|
76
|
+
const issue = message => ctx.addIssue({ code: 'custom', message });
|
|
77
|
+
const parts = new Map(recipe.parts.map(p => [p.id, p]));
|
|
78
|
+
if (parts.size !== recipe.parts.length) issue('Duplicate part ID');
|
|
79
|
+
for (const part of recipe.parts) {
|
|
80
|
+
const seen = new Set([part.id]); let parent = part.parent;
|
|
81
|
+
while (parent) {
|
|
82
|
+
if (!parts.has(parent) || seen.has(parent) || seen.size >= 4) { issue('Invalid parent, cycle or hierarchy depth'); break; }
|
|
83
|
+
seen.add(parent); parent = parts.get(parent).parent;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if(recipe.parts.reduce((total,part)=>total+(part.geometry?.type==='perforated-box'?part.geometry.holes.length:0),0)>MAX_RECIPE_HOLES)
|
|
87
|
+
issue('Recipe through-hole budget exceeded');
|
|
88
|
+
const textures=new Map();
|
|
89
|
+
for(const part of recipe.parts){
|
|
90
|
+
if(part.material?.texture){
|
|
91
|
+
if(!part.geometry)issue('A procedural texture requires geometry');
|
|
92
|
+
const texture=part.material.texture;
|
|
93
|
+
textures.set(JSON.stringify(texture),texture.resolution**2);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if([...textures.values()].reduce((total,pixels)=>total+pixels,0)>MAX_PROCEDURAL_TEXTURE_PIXELS)
|
|
97
|
+
issue('Procedural texture pixel budget exceeded');
|
|
98
|
+
const c = recipe.capabilities;
|
|
99
|
+
if (c.level === 'visual' && (c.physics || c.actions.length || c.surfaces.length)) issue('Visual cannot declare physical behavior');
|
|
100
|
+
if (c.level !== 'visual' && !c.physics) issue('Physical capabilities require explicit physics');
|
|
101
|
+
if (c.level === 'interactive' && !c.actions.length) issue('Interactive requires declared actions');
|
|
102
|
+
if (c.actions.includes('pickup') && c.physics?.body !== 'dynamic') issue('Pickup requires a dynamic body');
|
|
103
|
+
if (new Set(c.actions).size !== c.actions.length || new Set(c.surfaces.map(s => s.id)).size !== c.surfaces.length) issue('Duplicate capability ID');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export const assetPackageSchema = z.object({
|
|
107
|
+
schema: z.literal('agentscape.asset-package'), schemaVersion: z.literal(1),
|
|
108
|
+
id: z.string().min(1).max(100), version: z.string().regex(/^\d+\.\d+\.\d+$/),
|
|
109
|
+
entry: z.object({ kind: z.enum(['glb', 'recipe', 'procedural']), path: packagePath }).strict(),
|
|
110
|
+
level: z.enum(['visual', 'physical', 'interactive']),
|
|
111
|
+
dependencies: z.array(z.object({ path: packagePath, sha256: z.string().regex(/^[a-f0-9]{64}$/) }).strict()).max(128).default([])
|
|
112
|
+
}).strict().refine(p => new Set(p.dependencies.map(d => d.path.toLowerCase())).size === p.dependencies.length, 'Duplicate dependency path');
|
|
113
|
+
|
|
114
|
+
export const canonicalAssetJson = value => value === null || typeof value !== 'object' ? JSON.stringify(value) : Array.isArray(value) ? `[${value.map(canonicalAssetJson).join(',')}]` : `{${Object.keys(value).sort().map(k => `${JSON.stringify(k)}:${canonicalAssetJson(value[k])}`).join(',')}}`;
|
|
115
|
+
export async function assetDigest(bytes) { return Array.from(new Uint8Array(await crypto.subtle.digest('SHA-256', bytes)), b => b.toString(16).padStart(2, '0')).join(''); }
|
|
116
|
+
|
|
117
|
+
/** Reject external glTF resources before any loader or compiler can fetch them. */
|
|
118
|
+
export function assertEmbeddedGLB(bytes) {
|
|
119
|
+
if (!(bytes instanceof Uint8Array) || bytes.length < 20 || bytes.length > 32 * 1024 * 1024) throw new Error('ASSET_INPUT_INVALID');
|
|
120
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
121
|
+
if (view.getUint32(0, true) !== 0x46546c67 || view.getUint32(4, true) !== 2 || view.getUint32(8, true) !== bytes.length || view.getUint32(16, true) !== 0x4e4f534a) throw new Error('INVALID_GLB');
|
|
122
|
+
const length = view.getUint32(12, true);
|
|
123
|
+
if (length > bytes.length - 20) throw new Error('INVALID_GLB');
|
|
124
|
+
const document = JSON.parse(new TextDecoder().decode(bytes.subarray(20, 20 + length)).trim());
|
|
125
|
+
if ([...(document.buffers || []), ...(document.images || [])].some(item => item.uri != null)) throw new Error('EXTERNAL_RESOURCE_FORBIDDEN');
|
|
126
|
+
if ((document.nodes?.length || 0) > 256) throw new Error('ASSET_NODE_LIMIT');
|
|
127
|
+
const parents = new Set();
|
|
128
|
+
for (const node of document.nodes || []) for (const child of node.children || []) {
|
|
129
|
+
if (!Number.isInteger(child) || child < 0 || parents.has(child)) throw new Error('INVALID_NODE_HIERARCHY');
|
|
130
|
+
parents.add(child);
|
|
131
|
+
}
|
|
132
|
+
const visit = (index, ancestors = new Set()) => {
|
|
133
|
+
if (ancestors.has(index) || ancestors.size > 16 || !document.nodes?.[index]) throw new Error('INVALID_NODE_HIERARCHY');
|
|
134
|
+
const next = new Set(ancestors).add(index);
|
|
135
|
+
for (const child of document.nodes[index].children || []) visit(child, next);
|
|
136
|
+
};
|
|
137
|
+
for (let i = 0; i < (document.nodes?.length || 0); i++) visit(i);
|
|
138
|
+
return document;
|
|
139
|
+
}
|