agentscape3d 1.0.0-beta.1 → 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/README.md +23 -48
- package/dist/core.d.ts +68 -0
- package/dist/core.js +209 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +10 -229
- package/dist/index.js +192 -15462
- package/dist/index.js.map +1 -1
- package/package.json +11 -40
- package/cli.mjs +0 -27
- package/dist/AssetCompiler-CDFiElji.js +0 -2451
- package/dist/AssetCompiler-CDFiElji.js.map +0 -1
- package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
- package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
- package/dist/AssetRecipe-DmFpzxr-.js +0 -55
- package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
- package/dist/BrowserCodeWorker.js +0 -53615
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
- package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
- package/dist/SceneSerializer-DPVOyeRk.js +0 -353
- package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
- package/dist/StylePack-DNrdLeGI.js +0 -6314
- package/dist/StylePack-DNrdLeGI.js.map +0 -1
- package/dist/WorldArchive-pSBIGxLa.js +0 -420
- package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
- package/dist/WorldIO-wsDfZGM4.js +0 -150
- package/dist/WorldIO-wsDfZGM4.js.map +0 -1
- package/dist/blankWorld-CBWbwJGj.js +0 -76
- package/dist/blankWorld-CBWbwJGj.js.map +0 -1
- package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
- package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
- package/dist/environments-DgH66NqV.js +0 -4220
- package/dist/environments-DgH66NqV.js.map +0 -1
- package/dist/gltfIO-B87nJaat.js +0 -10
- package/dist/gltfIO-B87nJaat.js.map +0 -1
- package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
- package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
- package/dist/magicCabin-D64fD1E2.js +0 -11024
- package/dist/magicCabin-D64fD1E2.js.map +0 -1
- package/dist/mcp.d.ts +0 -2
- package/dist/mcp.js +0 -1
- package/dist/monumentHall-BKbs0UOQ.js +0 -404
- package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
- package/dist/node.d.ts +0 -16
- package/dist/node.js +0 -25
- package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
- package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
- package/dist/runtime/application/AgentTools.js +0 -25
- package/dist/runtime/application/README.md +0 -14
- package/dist/runtime/application/buildTaskObservation.js +0 -117
- package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
- package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
- package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
- package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
- package/dist/runtime/application/createSession.js +0 -66
- package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
- package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
- package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
- package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
- package/dist/runtime/application/native-scene/CodeProject.js +0 -119
- package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
- package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
- package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
- package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
- package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
- package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
- package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
- package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
- package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
- package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
- package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
- package/dist/runtime/application/scene/RequestWindow.js +0 -54
- package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
- package/dist/runtime/application/scene/SceneContracts.js +0 -45
- package/dist/runtime/application/scene/SceneEditService.js +0 -144
- package/dist/runtime/application/scene/SceneFacade.js +0 -267
- package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
- package/dist/runtime/application/scene/SceneJobController.js +0 -229
- package/dist/runtime/application/scene/ScenePackage.js +0 -162
- package/dist/runtime/application/scene/ScenePersistence.js +0 -50
- package/dist/runtime/application/scene/SceneProject.js +0 -95
- package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
- package/dist/runtime/application/scene/StarterScene.js +0 -56
- package/dist/runtime/application/scene/WorldArchive.js +0 -87
- package/dist/runtime/application/scene/WorldDirectory.js +0 -20
- package/dist/runtime/application/scene/WorldDocument.js +0 -74
- package/dist/runtime/application/scene/WorldIO.js +0 -103
- package/dist/runtime/application/scene/WorldStorage.js +0 -137
- package/dist/runtime/application/skills/SkillRegistry.js +0 -163
- package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
- package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
- package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
- package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
- package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
- package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
- package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
- package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
- package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
- package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
- package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
- package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
- package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
- package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
- package/dist/runtime/application/skills/skillPrimitives.js +0 -4
- package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
- package/dist/runtime/application/tasks.jsonl +0 -67
- package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
- package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
- package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
- package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
- package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
- package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
- package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
- package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
- package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
- package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
- package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
- package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
- package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
- package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
- package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
- package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
- package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
- package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
- package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
- package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
- package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
- package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
- package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
- package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
- package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
- package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
- package/dist/runtime/apps/mcp-server/README.md +0 -150
- package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
- package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
- package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
- package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
- package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
- package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
- package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
- package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
- package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
- package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
- package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
- package/dist/runtime/apps/mcp-server/main.mjs +0 -56
- package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
- package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
- package/dist/runtime/apps/mcp-server/security.js +0 -21
- package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
- package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
- package/dist/runtime/apps/server/README.md +0 -7
- package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
- package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
- package/dist/runtime/apps/server/tasks.jsonl +0 -10
- package/dist/runtime/foundation/EventBus.js +0 -18
- package/dist/runtime/foundation/JsonGateway.js +0 -47
- package/dist/runtime/foundation/PolicyEngine.js +0 -21
- package/dist/runtime/foundation/README.md +0 -7
- package/dist/runtime/foundation/TraceRecorder.js +0 -76
- package/dist/runtime/foundation/errors.js +0 -8
- package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
- package/dist/runtime/foundation/version.js +0 -2
- package/dist/runtime/modules/agent/README.md +0 -11
- package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
- package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
- package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
- package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
- package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
- package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
- package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
- package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
- package/dist/runtime/modules/agent/prompt/index.js +0 -46
- package/dist/runtime/modules/agent/tasks.jsonl +0 -94
- package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
- package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
- package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
- package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
- package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
- package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
- package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
- package/dist/runtime/modules/artifact/README.md +0 -7
- package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
- package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
- package/dist/runtime/modules/asset/AssetModule.js +0 -399
- package/dist/runtime/modules/asset/README.md +0 -54
- package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
- package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
- package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
- package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
- package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
- package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
- package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
- package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
- package/dist/runtime/modules/asset/model/admission.js +0 -117
- package/dist/runtime/modules/asset/model/errors.js +0 -6
- package/dist/runtime/modules/asset/model/parts.js +0 -27
- package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
- package/dist/runtime/modules/asset/model/schema.js +0 -150
- package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
- package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
- package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
- package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
- package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
- package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
- package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
- package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
- package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
- package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
- package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
- package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
- package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
- package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
- package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
- package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
- package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
- package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
- package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
- package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
- package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
- package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
- package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
- package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
- package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
- package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
- package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
- package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
- package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
- package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
- package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
- package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
- package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
- package/dist/runtime/modules/asset/tasks.jsonl +0 -87
- package/dist/runtime/modules/generation/README.md +0 -9
- package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
- package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
- package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
- package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
- package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
- package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
- package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
- package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
- package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
- package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
- package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
- package/dist/runtime/modules/generation/tasks.jsonl +0 -35
- package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
- package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
- package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
- package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
- package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
- package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
- package/dist/runtime/modules/rendering/README.md +0 -7
- package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
- package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
- package/dist/runtime/modules/rendering/createRenderer.js +0 -76
- package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
- package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
- package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
- package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
- package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
- package/dist/runtime/modules/world/README.md +0 -13
- package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
- package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
- package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
- package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
- package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
- package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
- package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
- package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
- package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
- package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
- package/dist/runtime/modules/world/content/blankWorld.js +0 -35
- package/dist/runtime/modules/world/content/environments.js +0 -84
- package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
- package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
- package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
- package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
- package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
- package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
- package/dist/runtime/modules/world/content/magicCabin.js +0 -190
- package/dist/runtime/modules/world/content/monumentHall.js +0 -154
- package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
- package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
- package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
- package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
- package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
- package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
- package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
- package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
- package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
- package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
- package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
- package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
- package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
- package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
- package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
- package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
- package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
- package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
- package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
- package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
- package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
- package/dist/runtime/modules/world/errors.js +0 -9
- package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
- package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
- package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
- package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
- package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
- package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
- package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
- package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
- package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
- package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
- package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
- package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
- package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
- package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
- package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
- package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
- package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
- package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
- package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
- package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
- package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
- package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
- package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
- package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
- package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
- package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
- package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
- package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
- package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
- package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
- package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
- package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
- package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
- package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
- package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
- package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
- package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
- package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
- package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
- package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
- package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
- package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
- package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
- package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
- package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
- package/dist/runtime/modules/world/tasks.jsonl +0 -530
- package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
- package/dist/runtime/modules/world/verification/Finding.js +0 -105
- package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
- package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
- package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
- package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
- package/dist/runtime/package-lock.json +0 -6245
- package/dist/runtime/package.json +0 -91
- package/dist/runtime/public/assets/cabinet.glb +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
- package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
- package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
- package/dist/schema-Dudvovhu.js +0 -364
- package/dist/schema-Dudvovhu.js.map +0 -1
- package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
- package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
- package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
- package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
- package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
- package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# 资产(Asset)
|
|
2
|
-
|
|
3
|
-
## v2 声明式输入
|
|
4
|
-
|
|
5
|
-
`importRecipe(json)` 接收严格的 Asset Recipe v1:最多 64 个节点、4 层分组、box/sphere/cylinder、有限变换和标准材质。默认只请求 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`。
|
|
@@ -1,157 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod/v4';
|
|
2
|
-
|
|
3
|
-
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();
|
|
4
|
-
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();
|
|
5
|
-
|
|
6
|
-
const number = z.number().finite().min(-100).max(100);
|
|
7
|
-
const size = z.number().finite().positive().max(100);
|
|
8
|
-
const vector = z.tuple([number, number, number]);
|
|
9
|
-
const sizes = z.tuple([size, size, size]);
|
|
10
|
-
const id = z.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/);
|
|
11
|
-
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)));
|
|
12
|
-
const boxCollider = z.object({ shape: z.literal('box'), halfExtents: sizes, translation: vector.default(() => [0, 0, 0]) }).strict();
|
|
13
|
-
const physics = 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();
|
|
14
|
-
const reviewedPhysics = z.object({ body:z.enum(['fixed','dynamic']), mass:size, friction:z.number().min(0).max(2),
|
|
15
|
-
colliders:z.array(boxCollider).max(64).optional() }).strict();
|
|
16
|
-
export const interactionReviewSchema = z.object({
|
|
17
|
-
proposalId:z.string().regex(/^[a-f0-9]{64}$/), confirmed:z.literal(true), physics:reviewedPhysics,
|
|
18
|
-
parts:z.array(z.object({ id, node:z.string().min(1).max(128), parent:z.string().min(1).max(64).default('$root'),
|
|
19
|
-
physics:reviewedPhysics.refine(value=>value.body==='dynamic','Moving parts require dynamic bodies'),
|
|
20
|
-
joint:z.object({ type:z.enum(['prismatic','revolute']), axis:vector.refine(value=>Math.hypot(...value)>1e-6),
|
|
21
|
-
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'),
|
|
22
|
-
motor:z.object({stiffness:z.number().positive().max(1000),damping:z.number().positive().max(100)}).strict().default(()=>({stiffness:80,damping:12}))
|
|
23
|
-
}).strict()
|
|
24
|
-
}).strict()).max(32).default([])
|
|
25
|
-
}).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');
|
|
26
|
-
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();
|
|
27
|
-
export const recipeSchema = z.object({
|
|
28
|
-
schema: z.literal('agentscape.asset-recipe'), schemaVersion: z.literal(1),
|
|
29
|
-
id: z.string().regex(/^[A-Za-z][A-Za-z0-9_-]*(\/[A-Za-z][A-Za-z0-9_-]*)?$/).max(100),
|
|
30
|
-
parts: z.array(z.object({ id, parent: id.optional(), geometry: z.discriminatedUnion('type', [
|
|
31
|
-
z.object({ type: z.literal('box'), size: sizes }).strict(),
|
|
32
|
-
z.object({ type: z.literal('sphere'), radius: size }).strict(),
|
|
33
|
-
z.object({ type: z.literal('cylinder'), radius: size, height: size }).strict()
|
|
34
|
-
]).optional(), position: vector.default(() => [0, 0, 0]),
|
|
35
|
-
quaternion: z.tuple([number, number, number, number]).refine(q => Math.abs(Math.hypot(...q) - 1) < 0.0001).default(() => [0, 0, 0, 1]),
|
|
36
|
-
scale: z.number().min(0.05).max(20).default(1),
|
|
37
|
-
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) }).strict().optional()
|
|
38
|
-
}).strict()).min(1).max(64),
|
|
39
|
-
capabilities: z.object({ level: z.enum(['visual', 'physical', 'interactive']), physics: physics.optional(),
|
|
40
|
-
actions: z.array(z.enum(['move', 'pickup', 'place'])).max(3).default([]),
|
|
41
|
-
surfaces: z.array(z.object({ id, localPosition: vector, size: z.tuple([size, size]) }).strict()).max(16).default([])
|
|
42
|
-
}).strict().default(() => ({ level: 'visual', actions: [], surfaces: [] }))
|
|
43
|
-
}).strict().superRefine((recipe, ctx) => {
|
|
44
|
-
const issue = message => ctx.addIssue({ code: 'custom', message });
|
|
45
|
-
const parts = new Map(recipe.parts.map(p => [p.id, p]));
|
|
46
|
-
if (parts.size !== recipe.parts.length) issue('Duplicate part ID');
|
|
47
|
-
for (const part of recipe.parts) {
|
|
48
|
-
const seen = new Set([part.id]); let parent = part.parent;
|
|
49
|
-
while (parent) {
|
|
50
|
-
if (!parts.has(parent) || seen.has(parent) || seen.size >= 4) { issue('Invalid parent, cycle or hierarchy depth'); break; }
|
|
51
|
-
seen.add(parent); parent = parts.get(parent).parent;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const c = recipe.capabilities;
|
|
55
|
-
if (c.level === 'visual' && (c.physics || c.actions.length || c.surfaces.length)) issue('Visual cannot declare physical behavior');
|
|
56
|
-
if (c.level !== 'visual' && !c.physics) issue('Physical capabilities require explicit physics');
|
|
57
|
-
if (c.level === 'interactive' && !c.actions.length) issue('Interactive requires declared actions');
|
|
58
|
-
if (c.actions.includes('pickup') && c.physics?.body !== 'dynamic') issue('Pickup requires a dynamic body');
|
|
59
|
-
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');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export const assetPackageSchema = z.object({
|
|
63
|
-
schema: z.literal('agentscape.asset-package'), schemaVersion: z.literal(1),
|
|
64
|
-
id: z.string().min(1).max(100), version: z.string().regex(/^\d+\.\d+\.\d+$/),
|
|
65
|
-
entry: z.object({ kind: z.enum(['glb', 'recipe', 'procedural']), path: packagePath }).strict(),
|
|
66
|
-
level: z.enum(['visual', 'physical', 'interactive']),
|
|
67
|
-
dependencies: z.array(z.object({ path: packagePath, sha256: z.string().regex(/^[a-f0-9]{64}$/) }).strict()).max(128).default([])
|
|
68
|
-
}).strict().refine(p => new Set(p.dependencies.map(d => d.path.toLowerCase())).size === p.dependencies.length, 'Duplicate dependency path');
|
|
69
|
-
|
|
70
|
-
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(',')}}`;
|
|
71
|
-
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(''); }
|
|
72
|
-
|
|
73
|
-
/** Reject external glTF resources before any loader or compiler can fetch them. */
|
|
74
|
-
export function assertEmbeddedGLB(bytes) {
|
|
75
|
-
if (!(bytes instanceof Uint8Array) || bytes.length < 20 || bytes.length > 32 * 1024 * 1024) throw new Error('ASSET_INPUT_INVALID');
|
|
76
|
-
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
77
|
-
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');
|
|
78
|
-
const length = view.getUint32(12, true);
|
|
79
|
-
if (length > bytes.length - 20) throw new Error('INVALID_GLB');
|
|
80
|
-
const document = JSON.parse(new TextDecoder().decode(bytes.subarray(20, 20 + length)).trim());
|
|
81
|
-
if ([...(document.buffers || []), ...(document.images || [])].some(item => item.uri != null)) throw new Error('EXTERNAL_RESOURCE_FORBIDDEN');
|
|
82
|
-
if ((document.nodes?.length || 0) > 256) throw new Error('ASSET_NODE_LIMIT');
|
|
83
|
-
const parents = new Set();
|
|
84
|
-
for (const node of document.nodes || []) for (const child of node.children || []) {
|
|
85
|
-
if (!Number.isInteger(child) || child < 0 || parents.has(child)) throw new Error('INVALID_NODE_HIERARCHY');
|
|
86
|
-
parents.add(child);
|
|
87
|
-
}
|
|
88
|
-
const visit = (index, ancestors = new Set()) => {
|
|
89
|
-
if (ancestors.has(index) || ancestors.size > 16 || !document.nodes?.[index]) throw new Error('INVALID_NODE_HIERARCHY');
|
|
90
|
-
const next = new Set(ancestors).add(index);
|
|
91
|
-
for (const child of document.nodes[index].children || []) visit(child, next);
|
|
92
|
-
};
|
|
93
|
-
for (let i = 0; i < (document.nodes?.length || 0); i++) visit(i);
|
|
94
|
-
return document;
|
|
95
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const clean = (value) => String(value ?? '').trim();
|
|
2
|
-
|
|
3
|
-
export function createAssetRef(assetId) {
|
|
4
|
-
const id = clean(assetId);
|
|
5
|
-
if (!id) throw new TypeError('AssetRef requires assetId');
|
|
6
|
-
return { assetId: id };
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function assetIdFromRef(assetRef) {
|
|
10
|
-
const id = clean(assetRef?.assetId);
|
|
11
|
-
return id || null;
|
|
12
|
-
}
|