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.
Files changed (386) hide show
  1. package/README.md +23 -48
  2. package/dist/core.d.ts +68 -0
  3. package/dist/core.js +209 -0
  4. package/dist/core.js.map +1 -0
  5. package/dist/index.d.ts +10 -229
  6. package/dist/index.js +192 -15462
  7. package/dist/index.js.map +1 -1
  8. package/package.json +11 -40
  9. package/cli.mjs +0 -27
  10. package/dist/AssetCompiler-CDFiElji.js +0 -2451
  11. package/dist/AssetCompiler-CDFiElji.js.map +0 -1
  12. package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
  13. package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
  14. package/dist/AssetRecipe-DmFpzxr-.js +0 -55
  15. package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
  16. package/dist/BrowserCodeWorker.js +0 -53615
  17. package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
  18. package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
  19. package/dist/SceneSerializer-DPVOyeRk.js +0 -353
  20. package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
  21. package/dist/StylePack-DNrdLeGI.js +0 -6314
  22. package/dist/StylePack-DNrdLeGI.js.map +0 -1
  23. package/dist/WorldArchive-pSBIGxLa.js +0 -420
  24. package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
  25. package/dist/WorldIO-wsDfZGM4.js +0 -150
  26. package/dist/WorldIO-wsDfZGM4.js.map +0 -1
  27. package/dist/blankWorld-CBWbwJGj.js +0 -76
  28. package/dist/blankWorld-CBWbwJGj.js.map +0 -1
  29. package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
  30. package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
  31. package/dist/environments-DgH66NqV.js +0 -4220
  32. package/dist/environments-DgH66NqV.js.map +0 -1
  33. package/dist/gltfIO-B87nJaat.js +0 -10
  34. package/dist/gltfIO-B87nJaat.js.map +0 -1
  35. package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
  36. package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
  37. package/dist/magicCabin-D64fD1E2.js +0 -11024
  38. package/dist/magicCabin-D64fD1E2.js.map +0 -1
  39. package/dist/mcp.d.ts +0 -2
  40. package/dist/mcp.js +0 -1
  41. package/dist/monumentHall-BKbs0UOQ.js +0 -404
  42. package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
  43. package/dist/node.d.ts +0 -16
  44. package/dist/node.js +0 -25
  45. package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
  46. package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
  47. package/dist/runtime/application/AgentTools.js +0 -25
  48. package/dist/runtime/application/README.md +0 -14
  49. package/dist/runtime/application/buildTaskObservation.js +0 -117
  50. package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
  51. package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
  52. package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
  53. package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
  54. package/dist/runtime/application/createSession.js +0 -66
  55. package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
  56. package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
  57. package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
  58. package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
  59. package/dist/runtime/application/native-scene/CodeProject.js +0 -119
  60. package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
  61. package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
  62. package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
  63. package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
  64. package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
  65. package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
  66. package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
  67. package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
  68. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
  69. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
  70. package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
  71. package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
  72. package/dist/runtime/application/scene/RequestWindow.js +0 -54
  73. package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
  74. package/dist/runtime/application/scene/SceneContracts.js +0 -45
  75. package/dist/runtime/application/scene/SceneEditService.js +0 -144
  76. package/dist/runtime/application/scene/SceneFacade.js +0 -267
  77. package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
  78. package/dist/runtime/application/scene/SceneJobController.js +0 -229
  79. package/dist/runtime/application/scene/ScenePackage.js +0 -162
  80. package/dist/runtime/application/scene/ScenePersistence.js +0 -50
  81. package/dist/runtime/application/scene/SceneProject.js +0 -95
  82. package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
  83. package/dist/runtime/application/scene/StarterScene.js +0 -56
  84. package/dist/runtime/application/scene/WorldArchive.js +0 -87
  85. package/dist/runtime/application/scene/WorldDirectory.js +0 -20
  86. package/dist/runtime/application/scene/WorldDocument.js +0 -74
  87. package/dist/runtime/application/scene/WorldIO.js +0 -103
  88. package/dist/runtime/application/scene/WorldStorage.js +0 -137
  89. package/dist/runtime/application/skills/SkillRegistry.js +0 -163
  90. package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
  91. package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
  92. package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
  93. package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
  94. package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
  95. package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
  96. package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
  97. package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
  98. package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
  99. package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
  100. package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
  101. package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
  102. package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
  103. package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
  104. package/dist/runtime/application/skills/skillPrimitives.js +0 -4
  105. package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
  106. package/dist/runtime/application/tasks.jsonl +0 -67
  107. package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
  108. package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
  109. package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
  110. package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
  111. package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
  112. package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
  113. package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
  114. package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
  115. package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
  116. package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
  117. package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
  118. package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
  119. package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
  120. package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
  121. package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
  122. package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
  123. package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
  124. package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
  125. package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
  126. package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
  127. package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
  128. package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
  129. package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
  130. package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
  131. package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
  132. package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
  133. package/dist/runtime/apps/mcp-server/README.md +0 -150
  134. package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
  135. package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
  136. package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
  137. package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
  138. package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
  139. package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
  140. package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
  141. package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
  142. package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
  143. package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
  144. package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
  145. package/dist/runtime/apps/mcp-server/main.mjs +0 -56
  146. package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
  147. package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
  148. package/dist/runtime/apps/mcp-server/security.js +0 -21
  149. package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
  150. package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
  151. package/dist/runtime/apps/server/README.md +0 -7
  152. package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
  153. package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
  154. package/dist/runtime/apps/server/tasks.jsonl +0 -10
  155. package/dist/runtime/foundation/EventBus.js +0 -18
  156. package/dist/runtime/foundation/JsonGateway.js +0 -47
  157. package/dist/runtime/foundation/PolicyEngine.js +0 -21
  158. package/dist/runtime/foundation/README.md +0 -7
  159. package/dist/runtime/foundation/TraceRecorder.js +0 -76
  160. package/dist/runtime/foundation/errors.js +0 -8
  161. package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
  162. package/dist/runtime/foundation/version.js +0 -2
  163. package/dist/runtime/modules/agent/README.md +0 -11
  164. package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
  165. package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
  166. package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
  167. package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
  168. package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
  169. package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
  170. package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
  171. package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
  172. package/dist/runtime/modules/agent/prompt/index.js +0 -46
  173. package/dist/runtime/modules/agent/tasks.jsonl +0 -94
  174. package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
  175. package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
  176. package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
  177. package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
  178. package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
  179. package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
  180. package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
  181. package/dist/runtime/modules/artifact/README.md +0 -7
  182. package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
  183. package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
  184. package/dist/runtime/modules/asset/AssetModule.js +0 -399
  185. package/dist/runtime/modules/asset/README.md +0 -54
  186. package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
  187. package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
  188. package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
  189. package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
  190. package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
  191. package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
  192. package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
  193. package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
  194. package/dist/runtime/modules/asset/model/admission.js +0 -117
  195. package/dist/runtime/modules/asset/model/errors.js +0 -6
  196. package/dist/runtime/modules/asset/model/parts.js +0 -27
  197. package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
  198. package/dist/runtime/modules/asset/model/schema.js +0 -150
  199. package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
  200. package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
  201. package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
  202. package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
  203. package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
  204. package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
  205. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
  206. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
  207. package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
  208. package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
  209. package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
  210. package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
  211. package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
  212. package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
  213. package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
  214. package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
  215. package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
  216. package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
  217. package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
  218. package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
  219. package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
  220. package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
  221. package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
  222. package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
  223. package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
  224. package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
  225. package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
  226. package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
  227. package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
  228. package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
  229. package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
  230. package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
  231. package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
  232. package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
  233. package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
  234. package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
  235. package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
  236. package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
  237. package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
  238. package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
  239. package/dist/runtime/modules/asset/tasks.jsonl +0 -87
  240. package/dist/runtime/modules/generation/README.md +0 -9
  241. package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
  242. package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
  243. package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
  244. package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
  245. package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
  246. package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
  247. package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
  248. package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
  249. package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
  250. package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
  251. package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
  252. package/dist/runtime/modules/generation/tasks.jsonl +0 -35
  253. package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
  254. package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
  255. package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
  256. package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
  257. package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
  258. package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
  259. package/dist/runtime/modules/rendering/README.md +0 -7
  260. package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
  261. package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
  262. package/dist/runtime/modules/rendering/createRenderer.js +0 -76
  263. package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
  264. package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
  265. package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
  266. package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
  267. package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
  268. package/dist/runtime/modules/world/README.md +0 -13
  269. package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
  270. package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
  271. package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
  272. package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
  273. package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
  274. package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
  275. package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
  276. package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
  277. package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
  278. package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
  279. package/dist/runtime/modules/world/content/blankWorld.js +0 -35
  280. package/dist/runtime/modules/world/content/environments.js +0 -84
  281. package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
  282. package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
  283. package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
  284. package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
  285. package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
  286. package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
  287. package/dist/runtime/modules/world/content/magicCabin.js +0 -190
  288. package/dist/runtime/modules/world/content/monumentHall.js +0 -154
  289. package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
  290. package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
  291. package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
  292. package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
  293. package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
  294. package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
  295. package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
  296. package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
  297. package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
  298. package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
  299. package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
  300. package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
  301. package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
  302. package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
  303. package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
  304. package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
  305. package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
  306. package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
  307. package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
  308. package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
  309. package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
  310. package/dist/runtime/modules/world/errors.js +0 -9
  311. package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
  312. package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
  313. package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
  314. package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
  315. package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
  316. package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
  317. package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
  318. package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
  319. package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
  320. package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
  321. package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
  322. package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
  323. package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
  324. package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
  325. package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
  326. package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
  327. package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
  328. package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
  329. package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
  330. package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
  331. package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
  332. package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
  333. package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
  334. package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
  335. package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
  336. package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
  337. package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
  338. package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
  339. package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
  340. package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
  341. package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
  342. package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
  343. package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
  344. package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
  345. package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
  346. package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
  347. package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
  348. package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
  349. package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
  350. package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
  351. package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
  352. package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
  353. package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
  354. package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
  355. package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
  356. package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
  357. package/dist/runtime/modules/world/tasks.jsonl +0 -530
  358. package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
  359. package/dist/runtime/modules/world/verification/Finding.js +0 -105
  360. package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
  361. package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
  362. package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
  363. package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
  364. package/dist/runtime/package-lock.json +0 -6245
  365. package/dist/runtime/package.json +0 -91
  366. package/dist/runtime/public/assets/cabinet.glb +0 -0
  367. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
  368. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
  369. package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
  370. package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
  371. package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
  372. package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
  373. package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
  374. package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
  375. package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
  376. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
  377. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
  378. package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
  379. package/dist/schema-Dudvovhu.js +0 -364
  380. package/dist/schema-Dudvovhu.js.map +0 -1
  381. package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
  382. package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
  383. package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
  384. package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
  385. package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
  386. package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
@@ -1,2451 +0,0 @@
1
- import { i as canonicalAssetJson, n as assetDigest, s as interactionReviewSchema, t as assertEmbeddedGLB } from "./AssetInputContracts-Dy8iU4eT.js";
2
- import { i as orderParts, n as validatePhysics, t as validateAssetManifest } from "./schema-Dudvovhu.js";
3
- import { t as createAssetGLTFIO } from "./gltfIO-B87nJaat.js";
4
- import * as THREE from "three";
5
- import { Quaternion, Vector3 } from "three";
6
- import { Primitive, getBounds } from "@gltf-transform/core";
7
- import { center, dedup, inspect, prune, weld } from "@gltf-transform/functions";
8
- //#region ../../modules/asset/production/compiler/passes/GLTFInspectPass.js
9
- var GLTFInspectPass = class {
10
- constructor({ io = createAssetGLTFIO() } = {}) {
11
- this.io = io;
12
- }
13
- async run(context) {
14
- const document = await this.io.readBinary(context.bytes);
15
- const report = inspect(document);
16
- const nodes = document.getRoot().listNodes().map((node) => ({
17
- name: node.getName() || "",
18
- translation: node.getTranslation(),
19
- rotation: node.getRotation(),
20
- scale: node.getScale(),
21
- worldMatrix: [...node.getWorldMatrix()],
22
- parent: node.getParentNode()?.getName() || null,
23
- mesh: node.getMesh()?.getName() || null
24
- }));
25
- const meshes = report.meshes.properties;
26
- const stats = {
27
- scenes: report.scenes.properties.length,
28
- nodes: nodes.length,
29
- meshes: meshes.length,
30
- materials: report.materials.properties.length,
31
- textures: report.textures.properties.length,
32
- animations: report.animations.properties.length,
33
- renderVertices: report.scenes.properties.reduce((n, x) => n + (x.renderVertexCount || 0), 0),
34
- meshPrimitives: meshes.reduce((n, x) => n + (x.meshPrimitives || 0), 0),
35
- inputBytes: context.bytes.byteLength
36
- };
37
- return {
38
- ...context,
39
- document,
40
- inspection: {
41
- report,
42
- nodes,
43
- stats
44
- }
45
- };
46
- }
47
- };
48
- //#endregion
49
- //#region ../../modules/asset/production/compiler/partGeometry.js
50
- const ONE = new THREE.Vector3(1, 1, 1);
51
- function rigidInverse(node) {
52
- if (!node) return new THREE.Matrix4();
53
- const world = new THREE.Matrix4().fromArray(node.getWorldMatrix());
54
- const position = new THREE.Vector3();
55
- const rotation = new THREE.Quaternion();
56
- const scale = new THREE.Vector3();
57
- world.decompose(position, rotation, scale);
58
- return new THREE.Matrix4().compose(position, rotation, ONE).invert();
59
- }
60
- function expandMeshBounds(target, meshNode, ownerInverse) {
61
- const mesh = meshNode.getMesh();
62
- if (!mesh) return 0;
63
- const transform = ownerInverse.clone().multiply(new THREE.Matrix4().fromArray(meshNode.getWorldMatrix()));
64
- const point = new THREE.Vector3();
65
- const element = [
66
- 0,
67
- 0,
68
- 0
69
- ];
70
- let visited = 0;
71
- for (const primitive of mesh.listPrimitives()) {
72
- const position = primitive.getAttribute("POSITION");
73
- if (!position) continue;
74
- const indices = primitive.getIndices();
75
- const count = indices ? indices.getCount() : position.getCount();
76
- for (let i = 0; i < count; i++) {
77
- const index = indices ? indices.getScalar(i) : i;
78
- position.getElement(index, element);
79
- point.fromArray(element).applyMatrix4(transform);
80
- target.expandByPoint(point);
81
- visited += 1;
82
- }
83
- }
84
- return visited;
85
- }
86
- function boxCollidersForNodes(nodes, ownerNode = null) {
87
- const ownerInverse = rigidInverse(ownerNode);
88
- const colliders = [];
89
- for (const node of nodes) {
90
- if (!node.getMesh()) continue;
91
- const box = new THREE.Box3();
92
- if (!expandMeshBounds(box, node, ownerInverse) || box.isEmpty()) continue;
93
- const size = new THREE.Vector3();
94
- const center = new THREE.Vector3();
95
- box.getSize(size);
96
- box.getCenter(center);
97
- colliders.push({
98
- shape: "box",
99
- halfExtents: [
100
- Math.max(size.x / 2, .005),
101
- Math.max(size.y / 2, .005),
102
- Math.max(size.z / 2, .005)
103
- ],
104
- translation: center.toArray()
105
- });
106
- }
107
- return colliders;
108
- }
109
- function sceneMeshOwnership(scene, partNodes) {
110
- const owners = /* @__PURE__ */ new Map();
111
- const partByNode = new Map(Object.entries(partNodes).map(([id, node]) => [node, id]));
112
- for (const root of scene.listChildren()) root.traverse((node) => {
113
- if (!node.getMesh()) return;
114
- let owner = null;
115
- for (let current = node; current; current = current.getParentNode?.()) if (partByNode.has(current)) {
116
- owner = partByNode.get(current);
117
- break;
118
- }
119
- if (!owners.has(owner)) owners.set(owner, []);
120
- owners.get(owner).push(node);
121
- });
122
- return owners;
123
- }
124
- //#endregion
125
- //#region ../../modules/asset/production/compiler/passes/JointFramePass.js
126
- const EPS_POSITION = 1e-4;
127
- const EPS_ROTATION = 1e-4;
128
- const EPS_SCALE = 1e-4;
129
- const matrixFromRows = (rows) => {
130
- if (!Array.isArray(rows) || rows.length !== 4 || rows.some((row) => !Array.isArray(row) || row.length !== 4 || !row.every(Number.isFinite))) return null;
131
- return new THREE.Matrix4().set(...rows.flat());
132
- };
133
- const decompose = (matrix) => {
134
- const position = new THREE.Vector3();
135
- const rotation = new THREE.Quaternion();
136
- const scale = new THREE.Vector3();
137
- matrix.decompose(position, rotation, scale);
138
- return {
139
- position,
140
- rotation,
141
- scale
142
- };
143
- };
144
- const rotationDelta = (a, b) => 2 * Math.acos(Math.min(1, Math.abs(a.dot(b))));
145
- const unitScale = (scale) => Math.max(Math.abs(scale.x - 1), Math.abs(scale.y - 1), Math.abs(scale.z - 1)) <= EPS_SCALE;
146
- var JointFramePass = class {
147
- async run(context) {
148
- const proposal = context.partProposal;
149
- if (!proposal || proposal.frameConvention !== "urdf-link-local" || !Array.isArray(proposal.parts)) return context;
150
- const byName = /* @__PURE__ */ new Map();
151
- for (const node of context.inspection.nodes) {
152
- if (!node.name) continue;
153
- if (!byName.has(node.name)) byName.set(node.name, []);
154
- byName.get(node.name).push(node);
155
- }
156
- const byId = new Map(proposal.parts.map((part) => [String(part.id || ""), part]));
157
- const issues = [];
158
- const compiled = structuredClone(proposal);
159
- for (const part of compiled.parts) {
160
- const matrixRows = part.joint?.urdf?.parentToJointMatrix || part.joint?.urdf?.originMatrix;
161
- if (!matrixRows || part.joint?.parentAnchor || part.joint?.childAnchor) continue;
162
- const expectedMatrix = matrixFromRows(matrixRows);
163
- const childNodes = byName.get(part.node) || [];
164
- if (!expectedMatrix || childNodes.length !== 1) {
165
- issues.push({
166
- part: part.id,
167
- code: "JOINT_FRAME_NODE_UNRESOLVED"
168
- });
169
- continue;
170
- }
171
- const parentId = part.parent || "$root";
172
- let parentWorld = new THREE.Matrix4();
173
- if (parentId !== "$root") {
174
- const parentPart = byId.get(parentId);
175
- const parentNodes = byName.get(parentPart?.node) || [];
176
- if (parentNodes.length !== 1) {
177
- issues.push({
178
- part: part.id,
179
- code: "JOINT_FRAME_PARENT_UNRESOLVED"
180
- });
181
- continue;
182
- }
183
- parentWorld.fromArray(parentNodes[0].worldMatrix);
184
- }
185
- const childWorld = new THREE.Matrix4().fromArray(childNodes[0].worldMatrix);
186
- const actualMatrix = parentWorld.clone().invert().multiply(childWorld);
187
- const expected = decompose(expectedMatrix);
188
- const actual = decompose(actualMatrix);
189
- if (!unitScale(expected.scale) || !unitScale(actual.scale)) {
190
- issues.push({
191
- part: part.id,
192
- code: "JOINT_FRAME_SCALE_UNSUPPORTED"
193
- });
194
- continue;
195
- }
196
- if (actual.position.distanceTo(expected.position) > EPS_POSITION || rotationDelta(actual.rotation, expected.rotation) > EPS_ROTATION) {
197
- issues.push({
198
- part: part.id,
199
- code: "JOINT_FRAME_MISMATCH"
200
- });
201
- continue;
202
- }
203
- const currentNodes = context.document?.getRoot?.().listNodes?.().filter((node) => node.getName() === part.node) || [];
204
- if (currentNodes.length !== 1) {
205
- issues.push({
206
- part: part.id,
207
- code: "JOINT_FRAME_CURRENT_NODE_UNRESOLVED"
208
- });
209
- continue;
210
- }
211
- let currentParent = null;
212
- if (parentId !== "$root") {
213
- const parentPart = byId.get(parentId);
214
- const currentParents = context.document.getRoot().listNodes().filter((node) => node.getName() === parentPart?.node);
215
- if (currentParents.length !== 1) {
216
- issues.push({
217
- part: part.id,
218
- code: "JOINT_FRAME_CURRENT_PARENT_UNRESOLVED"
219
- });
220
- continue;
221
- }
222
- currentParent = currentParents[0];
223
- }
224
- const axis = new THREE.Vector3(...part.joint.axis || []);
225
- if (axis.lengthSq() < 1e-12) {
226
- issues.push({
227
- part: part.id,
228
- code: "JOINT_FRAME_AXIS_INVALID"
229
- });
230
- continue;
231
- }
232
- axis.normalize();
233
- if (axis.clone().applyQuaternion(expected.rotation).normalize().dot(axis) < .9999) {
234
- issues.push({
235
- part: part.id,
236
- code: "JOINT_FRAME_ROTATION_UNSUPPORTED"
237
- });
238
- continue;
239
- }
240
- const anchor = decompose(new THREE.Matrix4().fromArray(currentNodes[0].getWorldMatrix())).position.clone().applyMatrix4(rigidInverse(currentParent));
241
- part.joint.parentAnchor = anchor.toArray();
242
- part.joint.childAnchor = [
243
- 0,
244
- 0,
245
- 0
246
- ];
247
- part.joint.frame = {
248
- source: "urdf",
249
- compiled: true,
250
- positionError: actual.position.distanceTo(expected.position),
251
- rotationError: rotationDelta(actual.rotation, expected.rotation),
252
- normalizedParentAnchor: true
253
- };
254
- }
255
- return {
256
- ...context,
257
- partProposal: {
258
- ...compiled,
259
- jointFrame: {
260
- compiled: true,
261
- issues
262
- }
263
- }
264
- };
265
- }
266
- };
267
- //#endregion
268
- //#region ../../modules/asset/production/compiler/passes/SegmentMaterializePass.js
269
- const slug$1 = (value) => String(value).trim().replace(/[^a-zA-Z0-9_-]+/g, "_").replace(/^_+|_+$/g, "");
270
- const labelsArray = (value) => Array.isArray(value) || ArrayBuffer.isView(value) ? Array.from(value, (item) => String(item)) : null;
271
- const makeIndices = (document, sourcePrimitive, faceLabels, segmentId) => {
272
- const sourceIndices = sourcePrimitive.getIndices()?.getArray() || null;
273
- const vertexCount = sourcePrimitive.getAttribute("POSITION")?.getCount() || 0;
274
- const faceCount = sourceIndices ? sourceIndices.length / 3 : vertexCount / 3;
275
- if (!Number.isInteger(faceCount)) throw new Error("Primitive triangle count is not integral.");
276
- if (faceLabels.length !== faceCount) throw new Error(`Face label count ${faceLabels.length} does not match primitive face count ${faceCount}.`);
277
- const selected = [];
278
- for (let face = 0; face < faceCount; face++) {
279
- if (faceLabels[face] !== segmentId) continue;
280
- const offset = face * 3;
281
- selected.push(sourceIndices ? sourceIndices[offset] : offset, sourceIndices ? sourceIndices[offset + 1] : offset + 1, sourceIndices ? sourceIndices[offset + 2] : offset + 2);
282
- }
283
- if (!selected.length) return null;
284
- let max = 0;
285
- for (const index of selected) if (index > max) max = index;
286
- const array = max <= 65535 ? new Uint16Array(selected) : new Uint32Array(selected);
287
- return document.createAccessor().setType("SCALAR").setArray(array);
288
- };
289
- const clonePrimitiveView = (document, source, indices) => {
290
- const primitive = document.createPrimitive().setMode(source.getMode()).setIndices(indices).setMaterial(source.getMaterial());
291
- for (const semantic of source.listSemantics()) primitive.setAttribute(semantic, source.getAttribute(semantic));
292
- primitive.setExtras(structuredClone(source.getExtras()));
293
- return primitive;
294
- };
295
- var SegmentMaterializePass = class {
296
- async run(context) {
297
- const evidence = context.partSegmentation;
298
- const spec = evidence?.materialization;
299
- if (!spec) return context;
300
- const issues = [];
301
- const fail = (code, message, details = {}) => ({
302
- ...context,
303
- partSegmentation: {
304
- ...evidence,
305
- materialization: {
306
- status: "rejected",
307
- sourceNode: spec.sourceNode || null,
308
- issues: [...issues, {
309
- code,
310
- message,
311
- ...details
312
- }]
313
- }
314
- }
315
- });
316
- if (evidence.version !== 1 || !evidence.source || !Number.isInteger(evidence.faceCount) || evidence.faceCount <= 0 || !Array.isArray(evidence.segments)) return fail("MATERIALIZATION_EVIDENCE_INVALID", "Materialization requires valid Segmentation Evidence v1 metadata.");
317
- if (!spec.sourceNode || !Array.isArray(spec.primitives)) return fail("MATERIALIZATION_FORMAT", "Materialization requires sourceNode and primitives[].");
318
- const nodes = context.document.getRoot().listNodes().filter((node) => node.getName() === spec.sourceNode);
319
- if (nodes.length !== 1) return fail(nodes.length ? "MATERIALIZATION_NODE_AMBIGUOUS" : "MATERIALIZATION_NODE_MISSING", `Source node must resolve uniquely: ${spec.sourceNode}`);
320
- const sourceNode = nodes[0];
321
- const sourceMesh = sourceNode.getMesh();
322
- if (!sourceMesh) return fail("MATERIALIZATION_MESH_MISSING", `Source node has no mesh: ${spec.sourceNode}`);
323
- if (sourceNode.getSkin()) return fail("MATERIALIZATION_SKIN_UNSUPPORTED", "Skinned nodes are not materialized automatically.");
324
- if (sourceNode.getWeights().length || sourceMesh.getWeights().length) return fail("MATERIALIZATION_MORPH_UNSUPPORTED", "Morph-target meshes are not materialized automatically.");
325
- if (sourceNode.listExtensions().length || sourceMesh.listExtensions().length) return fail("MATERIALIZATION_EXTENSION_UNSUPPORTED", "Node or mesh extensions require provider-side materialization.");
326
- const primitives = sourceMesh.listPrimitives();
327
- if (spec.primitives.length !== primitives.length) return fail("MATERIALIZATION_PRIMITIVE_COVERAGE", "Every source primitive must have one face-label entry.");
328
- const byPrimitive = /* @__PURE__ */ new Map();
329
- for (const entry of spec.primitives) {
330
- if (!Number.isInteger(entry.primitive) || entry.primitive < 0 || entry.primitive >= primitives.length || byPrimitive.has(entry.primitive)) return fail("MATERIALIZATION_PRIMITIVE_INDEX", `Invalid or duplicate primitive index: ${entry.primitive}`);
331
- const labels = labelsArray(entry.faceLabels);
332
- if (!labels) return fail("MATERIALIZATION_LABELS_MISSING", `Primitive ${entry.primitive} requires faceLabels[].`);
333
- byPrimitive.set(entry.primitive, labels);
334
- }
335
- const segmentDefs = /* @__PURE__ */ new Map();
336
- const generatedNames = new Set(context.document.getRoot().listNodes().map((node) => node.getName()).filter(Boolean));
337
- for (const segment of evidence.segments || []) {
338
- const id = String(segment.id ?? "");
339
- if (!id || segmentDefs.has(id) || !Number.isInteger(segment.faceCount) || segment.faceCount <= 0) return fail("MATERIALIZATION_SEGMENT_INVALID", `Segment ids must be unique and faceCount must be positive: ${id || "<missing>"}`);
340
- const safe = slug$1(id);
341
- if (!safe) return fail("MATERIALIZATION_SEGMENT_ID", `Segment id cannot form a stable node name: ${id}`);
342
- const nodeName = `${spec.sourceNode}__part_${safe}`;
343
- if (generatedNames.has(nodeName)) return fail("MATERIALIZATION_NODE_COLLISION", `Generated node already exists: ${nodeName}`);
344
- if ([...segmentDefs.values()].some((item) => item.nodeName === nodeName)) return fail("MATERIALIZATION_SEGMENT_ID_COLLISION", `Segment ids collide after normalization: ${id}`);
345
- segmentDefs.set(id, {
346
- id,
347
- nodeName,
348
- segment
349
- });
350
- }
351
- if (!segmentDefs.size) return fail("MATERIALIZATION_SEGMENTS_MISSING", "No segmentation definitions are available.");
352
- const proposalParts = new Map((context.partProposal?.parts || []).map((part) => [String(part.id), part]));
353
- if (context.partProposal) {
354
- new Map([...segmentDefs.values()].map((def) => [def.id, def.nodeName]));
355
- for (const [id, def] of segmentDefs) {
356
- const part = proposalParts.get(id);
357
- if (!part) continue;
358
- if (part.node && part.node !== def.nodeName) return fail("MATERIALIZATION_PROPOSAL_NODE_CONFLICT", `Part Proposal node conflicts with materialized segment ${id}.`, {
359
- part: id,
360
- expected: def.nodeName,
361
- actual: part.node
362
- });
363
- const parent = part.parent || "$root";
364
- if (parent !== "$root" && !segmentDefs.has(String(parent))) return fail("MATERIALIZATION_EXTERNAL_PARENT_UNSUPPORTED", `Materialized Part ${id} references a parent outside this segmentation batch: ${parent}.`, {
365
- part: id,
366
- parent
367
- });
368
- }
369
- for (const id of segmentDefs.keys()) {
370
- const seen = /* @__PURE__ */ new Set([id]);
371
- for (let parent = proposalParts.get(id)?.parent; parent && parent !== "$root"; parent = proposalParts.get(String(parent))?.parent) {
372
- parent = String(parent);
373
- if (seen.has(parent)) return fail("MATERIALIZATION_PART_HIERARCHY_CYCLE", `Materialized Part hierarchy contains a cycle at ${parent}.`);
374
- seen.add(parent);
375
- }
376
- }
377
- }
378
- const actualCounts = new Map([...segmentDefs.keys()].map((id) => [id, 0]));
379
- let totalFaces = 0;
380
- for (let primitiveIndex = 0; primitiveIndex < primitives.length; primitiveIndex++) {
381
- const primitive = primitives[primitiveIndex];
382
- if (primitive.getMode() !== Primitive.Mode.TRIANGLES) return fail("MATERIALIZATION_MODE_UNSUPPORTED", `Primitive ${primitiveIndex} is not TRIANGLES.`);
383
- if (primitive.listTargets().length || primitive.listExtensions().length) return fail("MATERIALIZATION_PRIMITIVE_UNSUPPORTED", `Primitive ${primitiveIndex} has morph targets or extensions.`);
384
- const labels = byPrimitive.get(primitiveIndex);
385
- const indices = primitive.getIndices()?.getArray();
386
- const faceCount = indices ? indices.length / 3 : (primitive.getAttribute("POSITION")?.getCount() || 0) / 3;
387
- if (!Number.isInteger(faceCount) || labels.length !== faceCount) return fail("MATERIALIZATION_FACE_COUNT", `Primitive ${primitiveIndex} face labels do not exactly match its triangles.`);
388
- totalFaces += faceCount;
389
- for (const label of labels) {
390
- if (!segmentDefs.has(label)) return fail("MATERIALIZATION_UNKNOWN_SEGMENT", `Face label references unknown segment: ${label}`);
391
- actualCounts.set(label, actualCounts.get(label) + 1);
392
- }
393
- }
394
- if (Number.isInteger(evidence.faceCount) && evidence.faceCount !== totalFaces) return fail("MATERIALIZATION_SOURCE_FACE_COUNT_MISMATCH", `Evidence faceCount ${evidence.faceCount} does not match source mesh face count ${totalFaces}.`);
395
- for (const [id, def] of segmentDefs) {
396
- if (!actualCounts.get(id)) return fail("MATERIALIZATION_EMPTY_SEGMENT", `Segment has no faces: ${id}`);
397
- if (Number.isInteger(def.segment.faceCount) && def.segment.faceCount !== actualCounts.get(id)) return fail("MATERIALIZATION_SEGMENT_COUNT_MISMATCH", `Segment ${id} faceCount does not match labels.`);
398
- }
399
- const materializedParts = [];
400
- const materializedNodes = /* @__PURE__ */ new Map();
401
- for (const [id, def] of segmentDefs) {
402
- const mesh = context.document.createMesh(`${def.nodeName}Mesh`).setWeights(sourceMesh.getWeights()).setExtras(structuredClone(sourceMesh.getExtras()));
403
- for (let primitiveIndex = 0; primitiveIndex < primitives.length; primitiveIndex++) {
404
- const indices = makeIndices(context.document, primitives[primitiveIndex], byPrimitive.get(primitiveIndex), id);
405
- if (indices) mesh.addPrimitive(clonePrimitiveView(context.document, primitives[primitiveIndex], indices));
406
- }
407
- const node = context.document.createNode(def.nodeName).setMesh(mesh).setExtras({ agentscape: {
408
- segmentId: id,
409
- source: evidence.source
410
- } });
411
- sourceNode.addChild(node);
412
- materializedNodes.set(id, node);
413
- materializedParts.push({
414
- id,
415
- node: def.nodeName,
416
- ...def.segment.semantic ? { semantic: def.segment.semantic } : {},
417
- ...Number.isFinite(def.segment.confidence) ? { confidence: def.segment.confidence } : {}
418
- });
419
- }
420
- for (const [id, node] of materializedNodes) {
421
- const parentId = String(proposalParts.get(id)?.parent || "$root");
422
- if (parentId !== "$root") materializedNodes.get(parentId).addChild(node);
423
- }
424
- sourceNode.setMesh(null);
425
- let partProposal = context.partProposal;
426
- if (!partProposal) {
427
- const confidences = materializedParts.map((part) => part.confidence).filter(Number.isFinite);
428
- const confidence = Number.isFinite(evidence.confidence) ? evidence.confidence : confidences.length === materializedParts.length ? confidences.reduce((min, value) => Math.min(min, value), 1) : 0;
429
- partProposal = {
430
- version: 1,
431
- source: `segmentation/${evidence.source}`,
432
- confidence,
433
- parts: materializedParts
434
- };
435
- } else {
436
- const materializedById = new Map(materializedParts.map((part) => [part.id, part]));
437
- partProposal = structuredClone(partProposal);
438
- partProposal.parts ||= [];
439
- const existingIds = /* @__PURE__ */ new Set();
440
- for (const part of partProposal.parts) {
441
- const id = String(part.id);
442
- existingIds.add(id);
443
- const materialized = materializedById.get(id);
444
- if (materialized && !part.node) part.node = materialized.node;
445
- if (materialized?.semantic && !part.semantic) part.semantic = materialized.semantic;
446
- if (Number.isFinite(materialized?.confidence) && !Number.isFinite(part.confidence)) part.confidence = materialized.confidence;
447
- }
448
- for (const materialized of materializedParts) if (!existingIds.has(materialized.id)) partProposal.parts.push(structuredClone(materialized));
449
- }
450
- return {
451
- ...context,
452
- partProposal,
453
- partSegmentation: {
454
- ...evidence,
455
- materialization: {
456
- status: issues.length ? "partial" : "materialized",
457
- strategy: "shared-accessor-index-split",
458
- completeFacePartition: true,
459
- sourceNodeOriginPreserved: true,
460
- sourceNode: spec.sourceNode,
461
- nodes: materializedParts.map((part) => ({
462
- id: part.id,
463
- node: part.node
464
- })),
465
- issues
466
- }
467
- }
468
- };
469
- }
470
- };
471
- //#endregion
472
- //#region ../../modules/asset/production/compiler/passes/SegmentationEvidencePass.js
473
- const finiteBounds = (bounds) => bounds && ["min", "max"].every((key) => Array.isArray(bounds[key]) && bounds[key].length === 3 && bounds[key].every(Number.isFinite));
474
- var SegmentationEvidencePass = class {
475
- async run(context) {
476
- const evidence = context.partSegmentation;
477
- if (!evidence) return context;
478
- const issues = [];
479
- const faceCount = Number(evidence.faceCount);
480
- if (evidence.version !== 1 || !evidence.source || !Number.isInteger(faceCount) || faceCount <= 0 || !Array.isArray(evidence.segments)) issues.push({
481
- code: "SEGMENTATION_FORMAT",
482
- message: "Segmentation evidence requires version=1, source, faceCount and segments[]."
483
- });
484
- const ids = /* @__PURE__ */ new Set();
485
- let labeledFaces = 0;
486
- for (const segment of evidence.segments || []) {
487
- const id = String(segment.id ?? "");
488
- if (!id || ids.has(id)) {
489
- issues.push({
490
- code: "SEGMENTATION_ID_INVALID",
491
- segment: id || null
492
- });
493
- continue;
494
- }
495
- ids.add(id);
496
- if (!Number.isInteger(segment.faceCount) || segment.faceCount <= 0) issues.push({
497
- code: "SEGMENTATION_FACE_COUNT_INVALID",
498
- segment: id
499
- });
500
- else labeledFaces += segment.faceCount;
501
- if (segment.bounds && !finiteBounds(segment.bounds)) issues.push({
502
- code: "SEGMENTATION_BOUNDS_INVALID",
503
- segment: id
504
- });
505
- }
506
- if (Number.isFinite(faceCount) && labeledFaces > faceCount) issues.push({
507
- code: "SEGMENTATION_COVERAGE_INVALID",
508
- message: "Segment face counts exceed source face count."
509
- });
510
- const summary = {
511
- version: evidence.version,
512
- source: evidence.source,
513
- faceCount,
514
- labeledFaces,
515
- coverage: faceCount > 0 ? labeledFaces / faceCount : 0,
516
- segments: (evidence.segments || []).map((segment) => ({
517
- id: String(segment.id),
518
- faceCount: segment.faceCount,
519
- ...Number.isFinite(segment.confidence) ? { confidence: segment.confidence } : {},
520
- ...segment.semantic ? { semantic: segment.semantic } : {},
521
- ...segment.bounds ? { bounds: structuredClone(segment.bounds) } : {}
522
- })),
523
- ...evidence.artifact ? { artifact: structuredClone(evidence.artifact) } : {},
524
- ...evidence.materialization ? { materialization: structuredClone(evidence.materialization) } : {},
525
- issues
526
- };
527
- return {
528
- ...context,
529
- partSegmentation: summary
530
- };
531
- }
532
- };
533
- //#endregion
534
- //#region ../../modules/asset/production/compiler/passes/PartColliderPass.js
535
- var PartColliderPass = class {
536
- async run(context) {
537
- const proposal = context.partProposal;
538
- if (!proposal?.parts?.length || !context.document) return context;
539
- const root = context.document.getRoot();
540
- const scene = root.getDefaultScene() || root.listScenes()[0];
541
- if (!scene) return context;
542
- const nodesByName = /* @__PURE__ */ new Map();
543
- for (const node of root.listNodes()) {
544
- const name = node.getName();
545
- if (!name) continue;
546
- if (!nodesByName.has(name)) nodesByName.set(name, []);
547
- nodesByName.get(name).push(node);
548
- }
549
- const ids = /* @__PURE__ */ new Set();
550
- const partNodes = {};
551
- for (const part of proposal.parts) {
552
- const id = String(part.id || "").trim();
553
- const matches = nodesByName.get(part.node) || [];
554
- if (!id || ids.has(id) || matches.length !== 1) continue;
555
- ids.add(id);
556
- partNodes[id] = matches[0];
557
- }
558
- const ownership = sceneMeshOwnership(scene, partNodes);
559
- const next = structuredClone(proposal);
560
- const generated = [];
561
- const skipped = [];
562
- for (const part of next.parts) {
563
- const id = String(part.id || "").trim();
564
- if (part.physics?.colliders?.length) {
565
- skipped.push({
566
- part: id,
567
- reason: "provider-collider"
568
- });
569
- continue;
570
- }
571
- const node = partNodes[id];
572
- if (!node) {
573
- skipped.push({
574
- part: id,
575
- reason: "node-unresolved"
576
- });
577
- continue;
578
- }
579
- const meshNodes = ownership.get(id) || [];
580
- const colliders = boxCollidersForNodes(meshNodes, node);
581
- if (!colliders.length) {
582
- skipped.push({
583
- part: id,
584
- reason: "geometry-empty"
585
- });
586
- continue;
587
- }
588
- part.physics = {
589
- body: part.physics?.body || "dynamic",
590
- ...part.physics,
591
- colliders,
592
- collider: {
593
- strategy: "proposal-owned-mesh-aabb",
594
- quality: "coarse",
595
- generated: true
596
- }
597
- };
598
- generated.push({
599
- part: id,
600
- colliders: colliders.length,
601
- meshNodes: meshNodes.map((item) => item.getName())
602
- });
603
- }
604
- return {
605
- ...context,
606
- partProposal: next,
607
- partCollision: { provisional: {
608
- strategy: "nearest-proposal-part-ownership",
609
- generated,
610
- skipped
611
- } }
612
- };
613
- }
614
- };
615
- //#endregion
616
- //#region ../../modules/asset/production/compiler/passes/PartProposalPass.js
617
- const SUPPORTED_JOINTS = /* @__PURE__ */ new Set(["revolute", "prismatic"]);
618
- const finiteVec = (value, length) => Array.isArray(value) && value.length === length && value.every(Number.isFinite);
619
- function executableReason(part, reviewed = false) {
620
- if (!part.joint) return "missing-joint";
621
- if (!SUPPORTED_JOINTS.has(part.joint.type)) return "unsupported-joint";
622
- if (!finiteVec(part.joint.axis, 3) || Math.hypot(...part.joint.axis) < 1e-6) return "invalid-axis";
623
- if (!finiteVec(part.joint.parentAnchor, 3) || !finiteVec(part.joint.childAnchor, 3)) return "missing-anchor";
624
- if (!finiteVec(part.joint.limits, 2) || part.joint.limits[0] >= part.joint.limits[1]) return "invalid-limits";
625
- if (!part.physics?.colliders?.length) return "missing-collider";
626
- if (!part.actions?.length && !reviewed) return "missing-actions";
627
- if (!(part.actions || []).every((action) => Number.isFinite(part.targets?.[action]))) return "missing-target";
628
- return null;
629
- }
630
- var PartProposalPass = class {
631
- async run(context) {
632
- const proposal = context.partProposal;
633
- if (!proposal) return context;
634
- if (proposal.version !== 1 || !Array.isArray(proposal.parts)) return {
635
- ...context,
636
- partProposal: {
637
- ...proposal,
638
- accepted: false,
639
- promoted: [],
640
- unpromoted: [],
641
- issues: [{
642
- code: "PART_PROPOSAL_FORMAT",
643
- message: "Part proposal requires version=1 and parts[]."
644
- }]
645
- }
646
- };
647
- const issues = [];
648
- const parts = {};
649
- const currentNodes = context.document?.getRoot?.().listNodes?.() || [];
650
- const nodeNames = currentNodes.length ? currentNodes.map((node) => node.getName()) : context.inspection.nodes.map((node) => node.name);
651
- const nodeCounts = /* @__PURE__ */ new Map();
652
- for (const name of nodeNames) if (name) nodeCounts.set(name, (nodeCounts.get(name) || 0) + 1);
653
- for (const raw of proposal.parts) {
654
- const id = String(raw.id || "").trim();
655
- if (!id || parts[id]) {
656
- issues.push({
657
- code: "PART_ID_INVALID",
658
- part: id || null,
659
- message: "Part id must be unique and non-empty."
660
- });
661
- continue;
662
- }
663
- const matches = nodeCounts.get(raw.node) || 0;
664
- if (matches === 0) {
665
- issues.push({
666
- code: "PART_NODE_MISSING",
667
- part: id,
668
- node: raw.node,
669
- message: `GLB node not found: ${raw.node}`
670
- });
671
- continue;
672
- }
673
- if (matches > 1) {
674
- issues.push({
675
- code: "PART_NODE_AMBIGUOUS",
676
- part: id,
677
- node: raw.node,
678
- message: `GLB node name is not unique: ${raw.node}`
679
- });
680
- continue;
681
- }
682
- parts[id] = {
683
- node: raw.node,
684
- parent: raw.parent || "$root",
685
- ...raw.semantic ? { semantic: raw.semantic } : {},
686
- ...Array.isArray(raw.actions) ? { actions: [...new Set(raw.actions)] } : {},
687
- ...raw.targets ? { targets: { ...raw.targets } } : {},
688
- ...raw.physics ? { physics: structuredClone(raw.physics) } : {},
689
- ...raw.joint ? { joint: structuredClone(raw.joint) } : {},
690
- proposal: {
691
- source: proposal.source || "provider",
692
- confidence: Number(raw.confidence ?? proposal.confidence ?? 0)
693
- }
694
- };
695
- }
696
- let ordered = [];
697
- try {
698
- ordered = orderParts(parts);
699
- } catch (error) {
700
- issues.push({
701
- code: "PART_HIERARCHY_INVALID",
702
- message: error.message
703
- });
704
- }
705
- if (!issues.length && context.document) {
706
- const nodes = new Map(context.document.getRoot().listNodes().map((node) => [node.getName(), node]));
707
- const isAncestor = (ancestor, node) => {
708
- for (let current = node?.getParentNode?.(); current; current = current.getParentNode?.()) if (current === ancestor) return true;
709
- return false;
710
- };
711
- for (const [id, part] of ordered) {
712
- const parentId = part.parent || "$root";
713
- if (parentId === "$root") continue;
714
- if (!isAncestor(nodes.get(parts[parentId].node), nodes.get(part.node))) issues.push({
715
- code: "PART_NODE_HIERARCHY_MISMATCH",
716
- part: id,
717
- parent: parentId,
718
- message: `GLB node ${part.node} is not under parent part node ${parts[parentId].node}.`
719
- });
720
- }
721
- }
722
- const promoted = {};
723
- const unpromoted = [];
724
- if (!issues.length) for (const [id, part] of ordered) {
725
- const reason = executableReason(part, Boolean(context.interactionReview));
726
- const parent = part.parent || "$root";
727
- if (reason) {
728
- unpromoted.push({
729
- part: id,
730
- reason
731
- });
732
- continue;
733
- }
734
- if (parent !== "$root" && !promoted[parent]) {
735
- unpromoted.push({
736
- part: id,
737
- reason: "parent-not-executable"
738
- });
739
- continue;
740
- }
741
- promoted[id] = part;
742
- }
743
- const accepted = issues.length === 0;
744
- return {
745
- ...context,
746
- articulation: {
747
- ...context.articulation,
748
- ...accepted && Object.keys(promoted).length ? {
749
- parts: promoted,
750
- source: "part-proposal"
751
- } : {}
752
- },
753
- partProposal: {
754
- ...proposal,
755
- accepted,
756
- promoted: Object.keys(promoted),
757
- unpromoted,
758
- issues
759
- }
760
- };
761
- }
762
- };
763
- //#endregion
764
- //#region ../../modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js
765
- var PartGeometryEnrichmentPass = class {
766
- constructor({ provider, io } = {}) {
767
- this.provider = provider;
768
- this.io = io;
769
- }
770
- async run(context) {
771
- const parts = context.articulation.parts || {};
772
- const requested = Object.entries(parts).map(([id, part]) => ({
773
- id,
774
- node: part.node,
775
- parent: part.parent || "$root"
776
- }));
777
- if (!requested.length || !this.provider?.isConfigured?.() || typeof this.provider.runPartGeometry !== "function") return {
778
- ...context,
779
- partGeometry: { skipped: true }
780
- };
781
- try {
782
- const bytes = await this.io.writeBinary(context.document);
783
- const returned = (await this.provider.runPartGeometry(bytes, requested))?.parts || {};
784
- const nextParts = structuredClone(parts);
785
- const upgraded = [];
786
- const missing = [];
787
- const issues = [];
788
- const reports = {};
789
- const requestedIds = new Set(requested.map((part) => part.id));
790
- for (const id of Object.keys(returned)) if (!requestedIds.has(id)) issues.push({
791
- code: "PART_GEOMETRY_UNKNOWN_PART",
792
- part: id
793
- });
794
- for (const { id } of requested) {
795
- const result = returned[id];
796
- if (!result?.collision?.colliders?.length) {
797
- missing.push(id);
798
- continue;
799
- }
800
- const physics = {
801
- ...nextParts[id].physics,
802
- ...Number.isFinite(result.physics?.mass) && result.physics.mass > 0 ? { mass: result.physics.mass } : {},
803
- ...Number.isFinite(result.physics?.friction) ? { friction: result.physics.friction } : {},
804
- colliders: structuredClone(result.collision.colliders),
805
- collider: {
806
- strategy: result.collision.strategy || "provider",
807
- quality: result.collision.quality || "provider",
808
- generated: false,
809
- provider: this.provider.endpoint
810
- }
811
- };
812
- try {
813
- validatePhysics(physics, { part: id });
814
- } catch (error) {
815
- issues.push({
816
- code: "PART_GEOMETRY_INVALID_COLLIDER",
817
- part: id,
818
- message: error.message
819
- });
820
- continue;
821
- }
822
- nextParts[id].physics = physics;
823
- reports[id] = {
824
- collision: {
825
- strategy: physics.collider.strategy,
826
- quality: physics.collider.quality,
827
- hulls: result.collision.colliders.length
828
- },
829
- ...result.geometry ? { geometry: structuredClone(result.geometry) } : {},
830
- ...Number.isFinite(result.physics?.mass) ? { mass: result.physics.mass } : {}
831
- };
832
- upgraded.push(id);
833
- }
834
- return {
835
- ...context,
836
- articulation: {
837
- ...context.articulation,
838
- parts: nextParts
839
- },
840
- partGeometry: {
841
- skipped: false,
842
- provider: this.provider.endpoint,
843
- upgraded,
844
- missing,
845
- issues,
846
- reports
847
- }
848
- };
849
- } catch (error) {
850
- return {
851
- ...context,
852
- partGeometry: {
853
- skipped: true,
854
- provider: this.provider.endpoint,
855
- error: error.message
856
- }
857
- };
858
- }
859
- }
860
- };
861
- //#endregion
862
- //#region ../../modules/asset/production/compiler/passes/ArticulatedCollisionPass.js
863
- var ArticulatedCollisionPass = class {
864
- async run(context) {
865
- const parts = context.articulation.parts || {};
866
- const ids = Object.keys(parts);
867
- if (!ids.length) return context;
868
- const root = context.document.getRoot();
869
- const scene = root.getDefaultScene() || root.listScenes()[0];
870
- if (!scene) return context;
871
- const nodes = new Map(root.listNodes().map((node) => [node.getName(), node]));
872
- const partNodes = {};
873
- for (const id of ids) {
874
- const node = nodes.get(parts[id].node);
875
- if (node) partNodes[id] = node;
876
- }
877
- const ownership = sceneMeshOwnership(scene, partNodes);
878
- const generated = [];
879
- const preserved = [];
880
- const finalParts = structuredClone(parts);
881
- for (const id of ids) {
882
- const part = finalParts[id];
883
- if (!part.physics?.collider?.generated && part.physics?.colliders?.length) {
884
- preserved.push({
885
- part: id,
886
- colliders: part.physics.colliders.length
887
- });
888
- continue;
889
- }
890
- const node = partNodes[id];
891
- const colliders = boxCollidersForNodes(ownership.get(id) || [], node);
892
- if (!colliders.length) continue;
893
- part.physics = {
894
- body: part.physics?.body || "dynamic",
895
- ...part.physics,
896
- colliders,
897
- collider: {
898
- strategy: "owned-mesh-aabb",
899
- quality: "coarse",
900
- generated: true
901
- }
902
- };
903
- generated.push({
904
- part: id,
905
- colliders: colliders.length,
906
- meshNodes: (ownership.get(id) || []).map((item) => item.getName())
907
- });
908
- }
909
- const rootColliders = boxCollidersForNodes(ownership.get(null) || []);
910
- const generatedPartColliders = generated.length > 0;
911
- const wholeAssetMass = Number.isFinite(context.physics?.mass) ? context.physics.mass : null;
912
- const physics = context.physics ? { ...context.physics } : context.physics;
913
- if (physics && wholeAssetMass != null) delete physics.mass;
914
- return {
915
- ...context,
916
- physics,
917
- articulation: {
918
- ...context.articulation,
919
- parts: finalParts
920
- },
921
- collision: {
922
- strategy: "articulated-owned-mesh-aabb",
923
- quality: rootColliders.length || generatedPartColliders ? "coarse" : "provider-part-colliders",
924
- colliders: rootColliders
925
- },
926
- partCollision: {
927
- ...context.partCollision || {},
928
- final: {
929
- strategy: "nearest-executable-part-ownership",
930
- rootColliders: rootColliders.length,
931
- rootMeshNodes: (ownership.get(null) || []).map((node) => node.getName()),
932
- generated,
933
- preserved,
934
- ...wholeAssetMass != null ? { mass: {
935
- status: "unpartitioned",
936
- wholeAssetMass
937
- } } : {}
938
- }
939
- }
940
- };
941
- }
942
- };
943
- //#endregion
944
- //#region ../../modules/asset/production/compiler/passes/OptimizeGLBPass.js
945
- var OptimizeGLBPass = class {
946
- constructor({ io, enabled = true } = {}) {
947
- this.io = io;
948
- this.enabled = enabled;
949
- }
950
- async run(context) {
951
- if (!this.enabled) return {
952
- ...context,
953
- optimizedBytes: context.bytes,
954
- optimization: { skipped: true }
955
- };
956
- const document = context.document;
957
- await document.transform(dedup(), prune(), weld());
958
- const optimizedBytes = await this.io.writeBinary(document);
959
- return {
960
- ...context,
961
- optimizedBytes,
962
- optimization: {
963
- skipped: false,
964
- beforeBytes: context.bytes.byteLength,
965
- afterBytes: optimizedBytes.byteLength,
966
- ratio: context.bytes.byteLength ? Number((optimizedBytes.byteLength / context.bytes.byteLength).toFixed(4)) : 1,
967
- transforms: [
968
- "dedup",
969
- "prune",
970
- "weld"
971
- ]
972
- }
973
- };
974
- }
975
- };
976
- //#endregion
977
- //#region ../../modules/asset/production/compiler/passes/StructurePass.js
978
- const EPS = 1e-6;
979
- const isIdentityRotation = ([x, y, z, w]) => Math.abs(x) < EPS && Math.abs(y) < EPS && Math.abs(z) < EPS && Math.abs(w - 1) < EPS;
980
- const isUnitScale = (scale) => scale.every((value) => Math.abs(value - 1) < EPS);
981
- var StructurePass = class {
982
- async run(context) {
983
- const root = context.document.getRoot();
984
- const scenes = root.listScenes();
985
- const defaultScene = root.getDefaultScene() || scenes[0] || null;
986
- const rootNodes = defaultScene?.listChildren() || [];
987
- let maxDepth = 0;
988
- const visit = (node, depth) => {
989
- maxDepth = Math.max(maxDepth, depth);
990
- for (const child of node.listChildren()) visit(child, depth + 1);
991
- };
992
- rootNodes.forEach((node) => visit(node, 1));
993
- const negativeScaleNodes = [];
994
- const transformedRoots = [];
995
- const nonUniformScaleNodes = [];
996
- for (const node of root.listNodes()) {
997
- const scale = node.getScale();
998
- if (scale[0] * scale[1] * scale[2] < 0) negativeScaleNodes.push(node.getName() || "(unnamed)");
999
- if (Math.max(...scale) - Math.min(...scale) > EPS) nonUniformScaleNodes.push(node.getName() || "(unnamed)");
1000
- }
1001
- for (const node of rootNodes) if (node.getTranslation().some((value) => Math.abs(value) > EPS) || !isIdentityRotation(node.getRotation()) || !isUnitScale(node.getScale())) transformedRoots.push(node.getName() || "(unnamed)");
1002
- const warnings = [];
1003
- if (scenes.length > 1) warnings.push({
1004
- code: "MULTIPLE_SCENES",
1005
- severity: "advisory",
1006
- message: `GLB 包含 ${scenes.length} 个 Scene;运行时只实例化默认 Scene。`
1007
- });
1008
- if (!root.getDefaultScene() && scenes.length > 1) warnings.push({
1009
- code: "DEFAULT_SCENE_MISSING",
1010
- severity: "advisory",
1011
- message: "多 Scene GLB 未声明默认 Scene,将使用第一个 Scene。"
1012
- });
1013
- if (negativeScaleNodes.length) warnings.push({
1014
- code: "NEGATIVE_SCALE",
1015
- severity: "advisory",
1016
- message: `检测到 ${negativeScaleNodes.length} 个负缩放节点;碰撞和法线需要额外验证。`
1017
- });
1018
- if (root.listSkins().length) warnings.push({
1019
- code: "SKINNED_ASSET",
1020
- severity: "advisory",
1021
- message: "资产包含 Skin;禁止自动 flatten 节点层级。"
1022
- });
1023
- if (root.listAnimations().length) warnings.push({
1024
- code: "ANIMATED_ASSET",
1025
- severity: "advisory",
1026
- message: "资产包含动画;禁止自动 bake 层级变换。"
1027
- });
1028
- return {
1029
- ...context,
1030
- structure: {
1031
- scenes: scenes.length,
1032
- defaultSceneIndex: defaultScene ? scenes.indexOf(defaultScene) : -1,
1033
- rootNodes: rootNodes.length,
1034
- maxDepth,
1035
- skins: root.listSkins().length,
1036
- animations: root.listAnimations().length,
1037
- transformedRoots,
1038
- negativeScaleNodes,
1039
- nonUniformScaleNodes,
1040
- warnings,
1041
- policy: {
1042
- centerBelow: Boolean(defaultScene),
1043
- flatten: false,
1044
- inferAxisRotation: false
1045
- }
1046
- }
1047
- };
1048
- }
1049
- };
1050
- //#endregion
1051
- //#region ../../modules/asset/production/compiler/passes/NormalizeTransformPass.js
1052
- var NormalizeTransformPass = class {
1053
- async run(context) {
1054
- if (context.authoringIntent || !context.structure.policy.centerBelow) return {
1055
- ...context,
1056
- normalization: {
1057
- applied: [],
1058
- preservedOrigin: Boolean(context.authoringIntent)
1059
- }
1060
- };
1061
- await context.document.transform(center({ pivot: "below" }));
1062
- return {
1063
- ...context,
1064
- normalization: {
1065
- applied: ["center-below"],
1066
- preservedHierarchy: true,
1067
- axisRotation: "unchanged"
1068
- }
1069
- };
1070
- }
1071
- };
1072
- //#endregion
1073
- //#region ../../modules/asset/production/compiler/passes/GeometryPass.js
1074
- const safeName = (name = "") => name.trim().toLowerCase();
1075
- var GeometryPass = class {
1076
- async run(context) {
1077
- const root = context.document.getRoot();
1078
- const scene = root.getDefaultScene() || root.listScenes()[0];
1079
- if (!scene) throw new Error("GLB contains no scene");
1080
- const bounds = getBounds(scene);
1081
- const min = bounds.min.map(Number);
1082
- const max = bounds.max.map(Number);
1083
- const size = max.map((value, index) => value - min[index]);
1084
- const center = min.map((value, index) => (value + max[index]) / 2);
1085
- const maxSide = Math.max(...size);
1086
- const names = context.inspection.nodes.map((node) => safeName(node.name));
1087
- const warnings = [...context.structure.warnings];
1088
- if (!Number.isFinite(maxSide) || maxSide <= 0) warnings.push({
1089
- code: "GEOMETRY_EMPTY",
1090
- severity: "hard",
1091
- message: "资产几何为空或 Bounds 无效。"
1092
- });
1093
- if (maxSide > 100 || maxSide > 0 && maxSide < .001) warnings.push({
1094
- code: "SCALE_SUSPICIOUS",
1095
- severity: "advisory",
1096
- message: `最长边为 ${maxSide}m,物理尺度可能异常。`
1097
- });
1098
- if (!context.authoringIntent && Math.abs(min[1]) > 1e-5) warnings.push({
1099
- code: "GROUND_NORMALIZATION_FAILED",
1100
- severity: "hard",
1101
- message: `规范化后最低点仍为 y=${min[1]}。`
1102
- });
1103
- return {
1104
- ...context,
1105
- geometry: {
1106
- bounds: {
1107
- min,
1108
- max,
1109
- center,
1110
- size
1111
- },
1112
- maxSide,
1113
- originToGround: -min[1],
1114
- namedNodes: names.filter(Boolean),
1115
- warnings
1116
- }
1117
- };
1118
- }
1119
- };
1120
- //#endregion
1121
- //#region ../../modules/asset/production/compiler/passes/SemanticHeuristicPass.js
1122
- const RULES = [
1123
- {
1124
- type: "cabinet",
1125
- words: [
1126
- "cabinet",
1127
- "cupboard",
1128
- "wardrobe",
1129
- "柜",
1130
- "橱"
1131
- ],
1132
- tags: ["storage", "furniture"]
1133
- },
1134
- {
1135
- type: "drawer",
1136
- words: ["drawer", "抽屉"],
1137
- tags: ["storage"]
1138
- },
1139
- {
1140
- type: "door",
1141
- words: ["door", "门"],
1142
- tags: ["door"]
1143
- },
1144
- {
1145
- type: "cup",
1146
- words: [
1147
- "cup",
1148
- "mug",
1149
- "杯"
1150
- ],
1151
- tags: ["drinkware", "graspable"]
1152
- },
1153
- {
1154
- type: "apple",
1155
- words: ["apple", "苹果"],
1156
- tags: [
1157
- "fruit",
1158
- "food",
1159
- "round",
1160
- "graspable"
1161
- ]
1162
- },
1163
- {
1164
- type: "vase",
1165
- words: [
1166
- "vase",
1167
- "flower vase",
1168
- "花瓶"
1169
- ],
1170
- tags: [
1171
- "decor",
1172
- "container",
1173
- "graspable"
1174
- ]
1175
- },
1176
- {
1177
- type: "chair",
1178
- words: [
1179
- "chair",
1180
- "seat",
1181
- "椅"
1182
- ],
1183
- tags: ["furniture", "seat"]
1184
- },
1185
- {
1186
- type: "table",
1187
- words: [
1188
- "table",
1189
- "desk",
1190
- "桌"
1191
- ],
1192
- tags: ["furniture", "surface"]
1193
- }
1194
- ];
1195
- var SemanticHeuristicPass = class {
1196
- async run(context) {
1197
- const text = [
1198
- context.label,
1199
- context.sourceName,
1200
- ...context.geometry.namedNodes
1201
- ].filter(Boolean).join(" ").toLowerCase();
1202
- const best = RULES.map((rule) => ({
1203
- rule,
1204
- score: rule.words.filter((word) => text.includes(word)).length
1205
- })).filter((item) => item.score > 0).sort((a, b) => b.score - a.score)[0];
1206
- const base = best?.rule || {
1207
- type: "object",
1208
- tags: []
1209
- };
1210
- return {
1211
- ...context,
1212
- semantics: {
1213
- type: base.type,
1214
- label: context.label || context.sourceName.replace(/\.(glb|gltf)$/i, ""),
1215
- tags: base.tags,
1216
- actions: base.actions || ["move"],
1217
- confidence: best ? Math.min(.85, .45 + best.score * .2) : .2,
1218
- source: "heuristic"
1219
- }
1220
- };
1221
- }
1222
- };
1223
- //#endregion
1224
- //#region ../../modules/asset/production/compiler/passes/ArticulationCandidatePass.js
1225
- const revoluteWords = [
1226
- "door",
1227
- "lid",
1228
- "hinge",
1229
- "flap",
1230
- "valve",
1231
- "wheel",
1232
- "page",
1233
- "leaf",
1234
- "cover",
1235
- "knob",
1236
- "dial",
1237
- "门",
1238
- "盖",
1239
- "阀",
1240
- "轮",
1241
- "页",
1242
- "旋钮"
1243
- ];
1244
- const prismaticWords = [
1245
- "drawer",
1246
- "slider",
1247
- "slide",
1248
- "抽屉",
1249
- "滑轨"
1250
- ];
1251
- const tokenize = (name) => String(name || "").replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase();
1252
- const includesWord = (name, word) => /^[a-z]+$/.test(word) ? (name.match(/[a-z]+/g) || []).includes(word) : name.includes(word);
1253
- function suggestActions(name, jointType) {
1254
- if (jointType === "prismatic") return ["slide"];
1255
- if ([
1256
- "page",
1257
- "leaf",
1258
- "页"
1259
- ].some((word) => includesWord(name, word))) return ["turnPage"];
1260
- if ([
1261
- "lid",
1262
- "cover",
1263
- "door",
1264
- "hinge",
1265
- "flap",
1266
- "门",
1267
- "盖"
1268
- ].some((word) => includesWord(name, word))) return ["open", "close"];
1269
- if ([
1270
- "knob",
1271
- "dial",
1272
- "旋钮"
1273
- ].some((word) => includesWord(name, word))) return ["adjust"];
1274
- return ["rotateJoint"];
1275
- }
1276
- /** Name/URDF hints may propose a joint, but never grant an executable action. */
1277
- var ArticulationCandidatePass = class {
1278
- async run(context) {
1279
- const candidates = [];
1280
- const proposals = new Map((context.partProposal?.parts || []).filter((part) => part.node && ["revolute", "prismatic"].includes(part.joint?.type)).map((part) => [part.node, part]));
1281
- for (const node of context.inspection.nodes) {
1282
- const name = tokenize(node.name);
1283
- if (!name) continue;
1284
- const provider = proposals.get(node.name);
1285
- const revolute = revoluteWords.some((word) => includesWord(name, word));
1286
- const prismatic = prismaticWords.some((word) => includesWord(name, word));
1287
- const jointType = provider?.joint.type || (revolute ? "revolute" : prismatic ? "prismatic" : null);
1288
- if (!jointType) continue;
1289
- candidates.push({
1290
- node: node.name,
1291
- jointType,
1292
- ...provider ? { partId: provider.id } : {},
1293
- source: provider ? "joint-metadata" : "node-name-heuristic",
1294
- confidence: provider ? Math.min(1, Math.max(0, Number(provider.confidence) || .75)) : name.includes("hinge") ? .75 : jointType === "prismatic" ? .55 : .5,
1295
- suggestedActions: suggestActions(name, jointType),
1296
- executable: false,
1297
- physicsVerified: false,
1298
- requiresReview: true
1299
- });
1300
- }
1301
- const partProposal = context.partProposal || (context.interactionProposal && candidates.length ? {
1302
- version: 1,
1303
- source: "node-name-heuristic",
1304
- parts: candidates.map((candidate, index) => ({
1305
- id: "part_" + (index + 1),
1306
- node: candidate.node,
1307
- joint: { type: candidate.jointType },
1308
- confidence: candidate.confidence,
1309
- requiresReview: true
1310
- }))
1311
- } : null);
1312
- return {
1313
- ...context,
1314
- ...partProposal ? { partProposal } : {},
1315
- articulation: {
1316
- candidates,
1317
- source: "structural-candidate-analysis"
1318
- }
1319
- };
1320
- }
1321
- };
1322
- //#endregion
1323
- //#region ../../modules/asset/production/compiler/evidence/AnimationMotionEvidence.js
1324
- const round$2 = (value) => Number(value.toFixed(6));
1325
- const vec = (vector) => vector.toArray().map(round$2);
1326
- const sqDistance = (a, b) => a.reduce((sum, x, i) => sum + (x - b[i]) ** 2, 0);
1327
- const dot = (a, b) => a.reduce((sum, x, i) => sum + x * b[i], 0);
1328
- const norm = (value) => Math.hypot(...value);
1329
- const sub = (a, b) => a.map((value, index) => value - b[index]);
1330
- const mul = (v, scalar) => v.map((value) => value * scalar);
1331
- const hasMesh = (node) => Boolean(node.getMesh()) || node.listChildren().some(hasMesh);
1332
- const issue = (code, node, clip) => ({
1333
- code,
1334
- node,
1335
- clip
1336
- });
1337
- function readSamples(channel) {
1338
- const sampler = channel.getSampler();
1339
- const path = channel.getTargetPath();
1340
- if (!sampler || sampler.getInterpolation() !== "LINEAR") return { error: "INTERPOLATION_UNSUPPORTED" };
1341
- const input = sampler.getInput()?.getArray();
1342
- const output = sampler.getOutput()?.getArray();
1343
- const width = path === "rotation" ? 4 : 3;
1344
- if (!input || !output || input.length < 2 || output.length !== input.length * width || [...input, ...output].some((number) => !Number.isFinite(number)) || Array.from(input).some((value, index) => index && value <= input[index - 1])) return { error: "ANIMATION_TRACK_INVALID" };
1345
- return { samples: Array.from(input, (_, index) => Array.from(output.slice(index * width, (index + 1) * width))) };
1346
- }
1347
- function translationMotion(node, samples) {
1348
- const rest = node.getTranslation();
1349
- if (sqDistance(rest, samples[0]) > 1e-6) return { error: "ANIMATION_REST_POSE_MISMATCH" };
1350
- const deltas = samples.map((sample) => sub(sample, samples[0]));
1351
- const longest = deltas.reduce((best, value) => norm(value) > norm(best) ? value : best, [
1352
- 0,
1353
- 0,
1354
- 0
1355
- ]);
1356
- const span = norm(longest);
1357
- if (span < .03) return null;
1358
- const axis = mul(longest, 1 / span);
1359
- const residual = Math.max(...deltas.map((delta) => norm(sub(delta, mul(axis, dot(delta, axis))))));
1360
- if (residual > Math.max(.005, span * .02)) return { error: "TRANSLATION_NONLINEAR" };
1361
- const values = deltas.map((delta) => dot(delta, axis));
1362
- return {
1363
- type: "prismatic",
1364
- axis: axis.map(round$2),
1365
- limits: [round$2(Math.min(0, ...values)), round$2(Math.max(0, ...values))],
1366
- residual: round$2(residual)
1367
- };
1368
- }
1369
- function rotationMotion(node, samples) {
1370
- const start = new Quaternion().fromArray(samples[0]).normalize();
1371
- const rest = new Quaternion().fromArray(node.getRotation()).normalize();
1372
- if (Math.abs(start.dot(rest)) < .9999) return { error: "ANIMATION_REST_POSE_MISMATCH" };
1373
- const inverse = start.clone().invert();
1374
- const deltas = samples.map((sample) => {
1375
- const delta = new Quaternion().fromArray(sample).normalize().multiply(inverse);
1376
- if (delta.w < 0) delta.set(-delta.x, -delta.y, -delta.z, -delta.w);
1377
- const sinHalf = Math.hypot(delta.x, delta.y, delta.z);
1378
- return {
1379
- angle: 2 * Math.atan2(sinHalf, delta.w),
1380
- axis: sinHalf > 1e-8 ? new Vector3(delta.x / sinHalf, delta.y / sinHalf, delta.z / sinHalf) : null
1381
- };
1382
- });
1383
- const largest = deltas.reduce((best, value) => value.angle > best.angle ? value : best, deltas[0]);
1384
- if (largest.angle < .1) return null;
1385
- if (largest.angle > Math.PI - .01) return { error: "ROTATION_RANGE_AMBIGUOUS" };
1386
- const axis = largest.axis;
1387
- const signed = [];
1388
- for (const delta of deltas) {
1389
- if (delta.angle < 1e-5) {
1390
- signed.push(0);
1391
- continue;
1392
- }
1393
- const alignment = delta.axis.dot(axis);
1394
- if (Math.abs(alignment) < .995) return { error: "ROTATION_MULTIPLE_AXES" };
1395
- signed.push(delta.angle * Math.sign(alignment));
1396
- }
1397
- const jumps = signed.slice(1).map((value, index) => Math.abs(value - signed[index]));
1398
- if (Math.max(...jumps) > Math.PI - .01) return { error: "ROTATION_UNWRAP_AMBIGUOUS" };
1399
- return {
1400
- type: "revolute",
1401
- axis: vec(axis),
1402
- limits: [round$2(Math.min(0, ...signed)), round$2(Math.max(0, ...signed))],
1403
- residual: round$2(Math.max(...deltas.map((delta) => delta.angle < 1e-5 ? 0 : 1 - Math.abs(delta.axis.dot(axis)))))
1404
- };
1405
- }
1406
- function inferAnimationMotion(document) {
1407
- const candidates = [], issues = [];
1408
- const nodes = document.getRoot().listNodes();
1409
- for (const animation of document.getRoot().listAnimations()) {
1410
- const clip = animation.getName() || "(unnamed)";
1411
- const tracks = /* @__PURE__ */ new Map();
1412
- for (const channel of animation.listChannels()) {
1413
- const node = channel.getTargetNode();
1414
- const path = channel.getTargetPath();
1415
- if (!node || ![
1416
- "translation",
1417
- "rotation",
1418
- "scale"
1419
- ].includes(path)) continue;
1420
- if (!tracks.has(node)) tracks.set(node, {});
1421
- const group = tracks.get(node);
1422
- if (group[path]) {
1423
- issues.push(issue("ANIMATION_DUPLICATE_CHANNEL", node.getName(), clip));
1424
- group.error = true;
1425
- continue;
1426
- }
1427
- group[path] = path === "scale" ? { error: "SCALE_ANIMATION_UNSUPPORTED" } : readSamples(channel);
1428
- }
1429
- for (const [node, group] of tracks) {
1430
- if (group.error || !hasMesh(node)) continue;
1431
- if (group.scale) {
1432
- issues.push(issue("SCALE_ANIMATION_UNSUPPORTED", node.getName(), clip));
1433
- continue;
1434
- }
1435
- const translation = group.translation?.error ? group.translation : group.translation ? translationMotion(node, group.translation.samples) : null;
1436
- const rotation = group.rotation?.error ? group.rotation : group.rotation ? rotationMotion(node, group.rotation.samples) : null;
1437
- const error = translation?.error || rotation?.error || (translation && rotation ? "COMPOUND_MOTION_UNSUPPORTED" : null);
1438
- if (error) {
1439
- issues.push(issue(error, node.getName(), clip));
1440
- continue;
1441
- }
1442
- const motion = rotation || translation;
1443
- if (!motion) continue;
1444
- candidates.push({
1445
- node: node.getName() || null,
1446
- nodeIndex: nodes.indexOf(node),
1447
- parent: node.getParentNode()?.getName() || "$root",
1448
- hypothesis: {
1449
- type: motion.type,
1450
- axis: motion.axis,
1451
- parentAnchor: node.getTranslation().map(round$2),
1452
- childAnchor: [
1453
- 0,
1454
- 0,
1455
- 0
1456
- ],
1457
- limits: motion.limits
1458
- },
1459
- evidence: {
1460
- type: "gltf-animation",
1461
- clip,
1462
- sampleCount: (group.rotation || group.translation).samples.length,
1463
- axisResidual: motion.residual,
1464
- scope: "observed-local-motion-not-mechanical-truth"
1465
- },
1466
- status: "candidate",
1467
- executable: false,
1468
- physicsVerified: false,
1469
- missing: [
1470
- "geometry-contact-analysis",
1471
- "mass-and-colliders",
1472
- "isolated-physics-verification",
1473
- "task-verification"
1474
- ]
1475
- });
1476
- }
1477
- }
1478
- const count = /* @__PURE__ */ new Map();
1479
- for (const candidate of candidates) count.set(candidate.nodeIndex, (count.get(candidate.nodeIndex) || 0) + 1);
1480
- for (const [nodeIndex, amount] of count) if (amount > 1) issues.push({
1481
- code: "MULTIPLE_CLIPS_REQUIRE_REVIEW",
1482
- node: nodes[nodeIndex].getName()
1483
- });
1484
- return {
1485
- schema: "agentscape.motion-evidence-experiment",
1486
- schemaVersion: 1,
1487
- candidates: candidates.filter((candidate) => count.get(candidate.nodeIndex) === 1),
1488
- issues
1489
- };
1490
- }
1491
- //#endregion
1492
- //#region ../../modules/asset/production/compiler/evidence/StaticPanelEvidence.js
1493
- const round$1 = (value) => Number(value.toFixed(5));
1494
- const boxOf = (node) => {
1495
- const { min, max } = getBounds(node);
1496
- const size = min.map((value, index) => max[index] - value);
1497
- return {
1498
- node,
1499
- min,
1500
- max,
1501
- size,
1502
- volume: size.reduce((product, value) => product * Math.max(0, value), 1)
1503
- };
1504
- };
1505
- const overlap = (a, b, index) => Math.max(0, Math.min(a.max[index], b.max[index]) - Math.max(a.min[index], b.min[index]));
1506
- function inferStaticPanelHypotheses(document) {
1507
- const nodes = document.getRoot().listNodes().filter((node) => node.getMesh()).map(boxOf).filter((item) => item.size.every((value) => Number.isFinite(value) && value > 1e-5));
1508
- const body = [...nodes].sort((a, b) => b.volume - a.volume)[0];
1509
- const candidates = [];
1510
- if (!body || body.size[0] < .3 || body.size[1] < .3 || body.size[2] < .15) return {
1511
- schema: "agentscape.static-panel-experiment",
1512
- schemaVersion: 1,
1513
- candidates,
1514
- limitations: ["BODY_REFERENCE_NOT_AVAILABLE"]
1515
- };
1516
- for (const part of nodes) {
1517
- if (part === body) continue;
1518
- const [width, height, depth] = part.size;
1519
- const widthCover = width / body.size[0], heightCover = height / body.size[1];
1520
- const thicknessRatio = depth / Math.min(width, height);
1521
- const xyOverlap = Math.min(overlap(part, body, 0) / width, overlap(part, body, 1) / height);
1522
- const positiveFaceGap = Math.abs(part.min[2] - body.max[2]);
1523
- const negativeFaceGap = Math.abs(part.max[2] - body.min[2]);
1524
- const face = positiveFaceGap <= negativeFaceGap ? "front" : "back";
1525
- const faceGap = Math.min(positiveFaceGap, negativeFaceGap);
1526
- const faceThreshold = Math.max(.035, body.size[2] * .09);
1527
- if (widthCover < .3 || widthCover > 1.12 || heightCover < .4 || heightCover > 1.12 || thicknessRatio > .12 || xyOverlap < .85 || faceGap > faceThreshold) continue;
1528
- const centerZ = (part.min[2] + part.max[2]) / 2;
1529
- candidates.push({
1530
- node: part.node.getName() || null,
1531
- nodeIndex: document.getRoot().listNodes().indexOf(part.node),
1532
- referenceNode: body.node.getName() || null,
1533
- kind: "planar-panel-near-body-face",
1534
- jointTypeHypothesis: "revolute",
1535
- alternatives: [{
1536
- axis: [
1537
- 0,
1538
- 1,
1539
- 0
1540
- ],
1541
- worldHingeLinePoint: [
1542
- round$1(part.min[0]),
1543
- round$1(part.min[1]),
1544
- round$1(centerZ)
1545
- ]
1546
- }, {
1547
- axis: [
1548
- 0,
1549
- 1,
1550
- 0
1551
- ],
1552
- worldHingeLinePoint: [
1553
- round$1(part.max[0]),
1554
- round$1(part.min[1]),
1555
- round$1(centerZ)
1556
- ]
1557
- }],
1558
- evidence: {
1559
- source: "axis-aligned-geometry",
1560
- face,
1561
- widthCover: round$1(widthCover),
1562
- heightCover: round$1(heightCover),
1563
- thicknessRatio: round$1(thicknessRatio),
1564
- surfaceGap: round$1(faceGap),
1565
- xyOverlap: round$1(xyOverlap)
1566
- },
1567
- status: "hypothesis",
1568
- executable: false,
1569
- physicsVerified: false,
1570
- missing: [
1571
- "semantic-function",
1572
- "which-hinge",
1573
- "rest-frame-validation",
1574
- "joint-limits",
1575
- "mass-and-colliders",
1576
- "physics-and-task-verification"
1577
- ]
1578
- });
1579
- }
1580
- return {
1581
- schema: "agentscape.static-panel-experiment",
1582
- schemaVersion: 1,
1583
- candidates,
1584
- limitations: [
1585
- "ONLY_AXIS_ALIGNED_FRONT_BACK_PANELS",
1586
- "STATIC_GEOMETRY_CANNOT_PROVE_MOBILITY",
1587
- "BOTH_PIVOT_EDGES_AMBIGUOUS"
1588
- ]
1589
- };
1590
- }
1591
- //#endregion
1592
- //#region ../../modules/asset/production/compiler/passes/KinematicEvidencePass.js
1593
- const round = (value) => Number(value.toFixed(6));
1594
- const worldAxis = (node, axis) => {
1595
- const parent = node.getParentNode();
1596
- const rotation = new THREE.Quaternion();
1597
- if (parent) new THREE.Matrix4().fromArray(parent.getWorldMatrix()).decompose(new THREE.Vector3(), rotation, new THREE.Vector3());
1598
- return new THREE.Vector3(...axis).applyQuaternion(rotation).normalize().toArray().map(round);
1599
- };
1600
- /**
1601
- * Proposals, never permissions. GLB motion tracks and static planar geometry
1602
- * are kept as separate evidence sources; static hinges remain ambiguous.
1603
- * This runs only during explicit prepareInteraction, not every asset build.
1604
- */
1605
- var KinematicEvidencePass = class {
1606
- async run(context) {
1607
- if (!context.interactionProposal) return context;
1608
- const animation = inferAnimationMotion(context.document);
1609
- const panels = inferStaticPanelHypotheses(context.document);
1610
- const nodes = context.document.getRoot().listNodes();
1611
- const hypotheses = [];
1612
- let truncated = false;
1613
- const push = (entry) => {
1614
- if (hypotheses.length >= 32) {
1615
- truncated = true;
1616
- return;
1617
- }
1618
- hypotheses.push({
1619
- id: `kh_${hypotheses.length + 1}`,
1620
- ...entry,
1621
- status: "candidate",
1622
- executable: false,
1623
- physicsVerified: false,
1624
- functionVerified: false
1625
- });
1626
- };
1627
- for (const motion of animation.candidates) {
1628
- const node = nodes[motion.nodeIndex];
1629
- if (!node) continue;
1630
- const axis = worldAxis(node, motion.hypothesis.axis);
1631
- push({
1632
- source: "gltf-animation",
1633
- node: motion.node,
1634
- nodeIndex: motion.nodeIndex,
1635
- jointType: motion.hypothesis.type,
1636
- axisWorld: axis,
1637
- pivotWorld: node.getWorldTranslation().map(round),
1638
- limits: [...motion.hypothesis.limits],
1639
- evidence: motion.evidence,
1640
- missing: [...motion.missing, "joint-frame-and-collider-review"]
1641
- });
1642
- }
1643
- for (const panel of panels.candidates) for (const alternative of panel.alternatives) push({
1644
- source: "static-geometry",
1645
- node: panel.node,
1646
- nodeIndex: panel.nodeIndex,
1647
- jointType: panel.jointTypeHypothesis,
1648
- axisWorld: [...alternative.axis],
1649
- pivotWorld: [...alternative.worldHingeLinePoint],
1650
- limits: null,
1651
- evidence: panel.evidence,
1652
- missing: [...panel.missing, "joint-limits-unobserved"]
1653
- });
1654
- return {
1655
- ...context,
1656
- kinematicEvidence: {
1657
- schema: "agentscape.kinematic-evidence",
1658
- schemaVersion: 1,
1659
- hypotheses,
1660
- issues: [...animation.issues, ...truncated ? [{ code: "HYPOTHESIS_LIMIT_EXCEEDED" }] : []],
1661
- limitations: [...panels.limitations, "MOTION_OR_GEOMETRY_IS_NOT_FUNCTIONAL_VERIFICATION"],
1662
- ...truncated ? { truncated: true } : {},
1663
- evidenceSources: ["gltf-animation", "axis-aligned-geometry"]
1664
- }
1665
- };
1666
- }
1667
- };
1668
- //#endregion
1669
- //#region ../../modules/asset/production/compiler/passes/ColliderFallbackPass.js
1670
- var ColliderFallbackPass = class {
1671
- async run(context) {
1672
- const [x, y, z] = context.geometry.bounds.size;
1673
- const translation = context.geometry.bounds.center;
1674
- if (context.semantics?.tags?.includes("round")) {
1675
- const radius = Math.max(Math.min(x / 2, z / 2, Math.max(y / 2 - .005, .005)), .005);
1676
- const halfHeight = Math.max(y / 2 - radius, .005);
1677
- return {
1678
- ...context,
1679
- collision: {
1680
- strategy: "capsule-fit",
1681
- quality: "primitive",
1682
- colliders: [{
1683
- shape: "capsule",
1684
- halfHeight,
1685
- radius,
1686
- translation
1687
- }]
1688
- }
1689
- };
1690
- }
1691
- return {
1692
- ...context,
1693
- collision: {
1694
- strategy: "aabb-fallback",
1695
- quality: "coarse",
1696
- colliders: [{
1697
- shape: "box",
1698
- halfExtents: [
1699
- Math.max(x / 2, .005),
1700
- Math.max(y / 2, .005),
1701
- Math.max(z / 2, .005)
1702
- ],
1703
- translation
1704
- }]
1705
- }
1706
- };
1707
- }
1708
- };
1709
- //#endregion
1710
- //#region ../../modules/asset/production/compiler/passes/RemoteEnrichmentPass.js
1711
- var RemoteEnrichmentPass = class {
1712
- constructor({ provider } = {}) {
1713
- this.provider = provider;
1714
- }
1715
- async run(context) {
1716
- if (!this.provider?.isConfigured()) return {
1717
- ...context,
1718
- enrichment: { skipped: true }
1719
- };
1720
- try {
1721
- const response = await this.provider.run("enrich", {
1722
- source: {
1723
- name: context.sourceName,
1724
- url: context.sourceUrl
1725
- },
1726
- inspection: {
1727
- nodes: context.inspection.nodes,
1728
- stats: context.inspection.stats
1729
- },
1730
- geometry: context.geometry,
1731
- semantics: context.semantics,
1732
- articulationCandidates: context.articulation.candidates
1733
- });
1734
- return {
1735
- ...context,
1736
- semantics: response?.semantics ? {
1737
- ...context.semantics,
1738
- ...response.semantics,
1739
- source: "provider"
1740
- } : context.semantics,
1741
- articulation: context.articulation,
1742
- partProposal: response?.partProposal || context.partProposal || null,
1743
- partSegmentation: response?.partSegmentation || context.partSegmentation || null,
1744
- collision: response?.collision || context.collision,
1745
- physics: response?.physics || context.physics,
1746
- meshQuality: response?.geometry || context.meshQuality || null,
1747
- enrichment: {
1748
- skipped: false,
1749
- provider: this.provider.endpoint
1750
- }
1751
- };
1752
- } catch (error) {
1753
- return {
1754
- ...context,
1755
- enrichment: {
1756
- skipped: true,
1757
- provider: this.provider.endpoint,
1758
- error: error.message
1759
- }
1760
- };
1761
- }
1762
- }
1763
- };
1764
- //#endregion
1765
- //#region ../../modules/asset/model/resourceBudget.js
1766
- const MiB = 1048576;
1767
- const RESOURCE_BUDGET = Object.freeze({
1768
- maxInputBytes: 100 * MiB,
1769
- renderVertices: {
1770
- advisory: 1e6,
1771
- hard: 3e6
1772
- },
1773
- drawCalls: {
1774
- advisory: 200,
1775
- hard: 800
1776
- },
1777
- textureVRAM: {
1778
- advisory: 256 * MiB,
1779
- hard: 512 * MiB
1780
- },
1781
- maxTextureDimension: {
1782
- advisory: 4096,
1783
- hard: 8192
1784
- },
1785
- animationKeyframes: {
1786
- advisory: 1e5,
1787
- hard: 5e5
1788
- }
1789
- });
1790
- //#endregion
1791
- //#region ../../modules/asset/production/compiler/passes/ResourceBudgetPass.js
1792
- const textureDimension = (resolution = "") => Math.max(...resolution.split("x").map(Number).filter(Number.isFinite), 0);
1793
- const countDrawCalls = (scene) => {
1794
- let count = 0;
1795
- const visit = (node) => {
1796
- count += node.getMesh()?.listPrimitives().length || 0;
1797
- node.listChildren().forEach(visit);
1798
- };
1799
- scene?.listChildren().forEach(visit);
1800
- return count;
1801
- };
1802
- var ResourceBudgetPass = class {
1803
- async run(context) {
1804
- const report = inspect(context.document);
1805
- const scenes = context.document.getRoot().listScenes();
1806
- const sceneIndex = context.structure.defaultSceneIndex >= 0 ? context.structure.defaultSceneIndex : 0;
1807
- const scene = scenes[sceneIndex];
1808
- const sceneReport = report.scenes.properties[sceneIndex];
1809
- const metrics = {
1810
- optimizedBytes: context.optimizedBytes.byteLength,
1811
- renderVertices: sceneReport?.renderVertexCount || 0,
1812
- uploadVertices: sceneReport?.uploadVertexCount || 0,
1813
- drawCalls: countDrawCalls(scene),
1814
- textureVRAM: report.textures.properties.reduce((sum, texture) => sum + (texture.gpuSize || 0), 0),
1815
- maxTextureDimension: report.textures.properties.reduce((max, texture) => Math.max(max, textureDimension(texture.resolution)), 0),
1816
- animationKeyframes: report.animations.properties.reduce((sum, animation) => sum + animation.keyframes, 0)
1817
- };
1818
- const hard = [];
1819
- const advisory = [];
1820
- for (const [key, code, label] of [
1821
- [
1822
- "renderVertices",
1823
- "RENDER_VERTICES",
1824
- "渲染顶点数"
1825
- ],
1826
- [
1827
- "drawCalls",
1828
- "DRAW_CALLS",
1829
- "Draw Call"
1830
- ],
1831
- [
1832
- "textureVRAM",
1833
- "TEXTURE_VRAM",
1834
- "纹理显存估算"
1835
- ],
1836
- [
1837
- "maxTextureDimension",
1838
- "TEXTURE_DIMENSION",
1839
- "最大纹理边长"
1840
- ],
1841
- [
1842
- "animationKeyframes",
1843
- "ANIMATION_KEYFRAMES",
1844
- "动画关键帧数"
1845
- ]
1846
- ]) {
1847
- const value = metrics[key];
1848
- const limit = RESOURCE_BUDGET[key];
1849
- if (value > limit.hard) hard.push({
1850
- code: `BUDGET_${code}_HARD`,
1851
- message: `${label} ${value} 超过硬上限 ${limit.hard}。`
1852
- });
1853
- else if (value > limit.advisory) advisory.push({
1854
- code: `BUDGET_${code}`,
1855
- message: `${label} ${value} 超过建议上限 ${limit.advisory}。`
1856
- });
1857
- }
1858
- return {
1859
- ...context,
1860
- inspection: {
1861
- ...context.inspection,
1862
- report,
1863
- stats: {
1864
- ...context.inspection.stats,
1865
- ...metrics
1866
- }
1867
- },
1868
- resources: {
1869
- metrics,
1870
- hard,
1871
- advisory
1872
- }
1873
- };
1874
- }
1875
- };
1876
- //#endregion
1877
- //#region ../../modules/asset/production/compiler/passes/CompileQualityPass.js
1878
- var CompileQualityPass = class {
1879
- async run(context) {
1880
- const hard = [...context.geometry.warnings.filter((item) => item.severity === "hard"), ...context.resources?.hard || []];
1881
- const advisory = [...context.geometry.warnings.filter((item) => item.severity !== "hard"), ...context.resources?.advisory || []];
1882
- if (context.enrichment?.error) advisory.push({
1883
- code: "ENRICHMENT_FAILED",
1884
- message: `重型 Provider 失败,已保留本地 fallback:${context.enrichment.error}`
1885
- });
1886
- const providerLevels = context.providerEvidence?.levels || null;
1887
- if (providerLevels?.partSegmentation === "provider" && providerLevels?.partSemantics !== "provider-verified") advisory.push({
1888
- code: "PART_SEMANTICS_UNVERIFIED",
1889
- message: "Provider 已提供 Part segmentation,但 semantic Part 仍未验证。"
1890
- });
1891
- if (providerLevels?.grasps === "raw-provider-unverified" || providerLevels?.grasps === "sapien-provider-unverified") advisory.push({
1892
- code: "PROVIDER_GRASP_UNVERIFIED",
1893
- message: "Provider 声明了 grasp artifact,但 AgentScape 尚未验证其 bytes/hash/schema。"
1894
- });
1895
- else if (providerLevels?.grasps === "raw-provider-only") advisory.push({
1896
- code: "PROVIDER_GRASP_RAW_ONLY",
1897
- message: "Provider 只有已验证 bytes/schema 的 raw grasp candidates;不得视为 AgentScape pickup 已验证。"
1898
- });
1899
- else if (providerLevels?.grasps === "sapien-validated-provider-only") advisory.push({
1900
- code: "PROVIDER_GRASP_SAPIEN_ONLY",
1901
- message: "Grasp bytes/schema 已验证且仅通过 Provider/SAPIEN 验证,尚未通过 AgentScape 当前 physics runtime verification。"
1902
- });
1903
- if (context.partSegmentation?.issues?.length) advisory.push({
1904
- code: "PART_SEGMENTATION_INVALID",
1905
- message: `Part segmentation evidence 存在 ${context.partSegmentation.issues.length} 个格式或覆盖错误。`
1906
- });
1907
- else if (context.partSegmentation?.materialization?.status === "rejected") advisory.push({
1908
- code: "PART_SEGMENTATION_MATERIALIZATION_FAILED",
1909
- message: "face-level Part 分割未能安全转换为 GLB Part Nodes。"
1910
- });
1911
- else if (context.partSegmentation && context.partSegmentation?.materialization?.status !== "materialized" && Object.keys(context.articulation.parts || {}).length === 0) advisory.push({
1912
- code: "PART_SEGMENTATION_UNMATERIALIZED",
1913
- message: "已有 face-level Part 分割证据,但尚未转换成与 GLB Node 对齐的 Part。"
1914
- });
1915
- if (context.partProposal?.issues?.length) advisory.push({
1916
- code: "PART_PROPOSAL_INVALID",
1917
- message: `Part Proposal 存在 ${context.partProposal.issues.length} 个结构错误,未提升为可执行 Part。`
1918
- });
1919
- else if (context.partProposal?.unpromoted?.length) advisory.push({
1920
- code: "PART_PROPOSAL_PARTIAL",
1921
- message: `Part Proposal 中有 ${context.partProposal.unpromoted.length} 个 Part 缺少可执行条件。`
1922
- });
1923
- if (context.collision.quality === "coarse" && !context.interactionReview) advisory.push({
1924
- code: "COLLIDER_COARSE",
1925
- message: "当前仅有 AABB 碰撞代理。"
1926
- });
1927
- if (context.partCollision?.final?.generated?.length && !context.interactionReview) advisory.push({
1928
- code: "PART_COLLIDER_COARSE",
1929
- message: `${context.partCollision.final.generated.length} 个可执行 Part 当前使用 owned-mesh AABB 碰撞体。`
1930
- });
1931
- if (context.partCollision?.final?.mass?.status === "unpartitioned") advisory.push({
1932
- code: "ARTICULATED_MASS_UNPARTITIONED",
1933
- message: "Provider 的 whole-asset mass 尚未可靠分配到 Root/Parts,因此未作为 Root mass 使用。"
1934
- });
1935
- if (context.partGeometry?.error) advisory.push({
1936
- code: "PART_GEOMETRY_ENRICHMENT_FAILED",
1937
- message: "可选 per-part 重型几何 Provider 失败,继续使用浏览器 fallback collider。"
1938
- });
1939
- if (context.partGeometry?.issues?.length) advisory.push({
1940
- code: "PART_GEOMETRY_PROVIDER_INVALID",
1941
- message: `per-part Provider 返回 ${context.partGeometry.issues.length} 个无效结果,已忽略并保留 fallback。`
1942
- });
1943
- if ((context.semantics.confidence ?? 0) < .5) advisory.push({
1944
- code: "SEMANTIC_LOW_CONFIDENCE",
1945
- message: "语义分类置信度较低。"
1946
- });
1947
- const executableArticulation = Object.values(context.articulation.parts || {}).some((part) => part.joint && part.joint.type !== "fixed" && (Object.keys(part.targets || {}).length || context.interactionReview));
1948
- if (context.articulation.candidates.length && !context.articulation.parts) advisory.push({
1949
- code: "ARTICULATION_CANDIDATE_ONLY",
1950
- message: "发现关节候选,但尚未生成可执行 Part/Joint。"
1951
- });
1952
- else if (executableArticulation && !context.verification?.articulation?.ok) advisory.push({
1953
- code: "ARTICULATION_UNVERIFIED",
1954
- message: "已生成可执行 Part/Joint,但尚未通过运行时运动验证。"
1955
- });
1956
- if (context.meshQuality?.watertight === false) advisory.push({
1957
- code: "MESH_NOT_WATERTIGHT",
1958
- message: "服务端几何检查发现 Mesh 非封闭;质量、体积和凸分解结果需要谨慎使用。"
1959
- });
1960
- if (context.meshQuality?.windingConsistent === false) advisory.push({
1961
- code: "MESH_WINDING_INCONSISTENT",
1962
- message: "服务端几何检查发现三角形绕序不一致。"
1963
- });
1964
- if ((context.meshQuality?.components ?? 1) > 1) advisory.push({
1965
- code: "MESH_MULTIPLE_COMPONENTS",
1966
- message: `Mesh 包含 ${context.meshQuality.components} 个不连通组件。`
1967
- });
1968
- const status = hard.length ? "rejected" : advisory.length ? "provisional" : "ready";
1969
- return {
1970
- ...context,
1971
- quality: {
1972
- status,
1973
- hard,
1974
- advisory
1975
- }
1976
- };
1977
- }
1978
- };
1979
- //#endregion
1980
- //#region ../../modules/asset/production/compiler/passes/ManifestPass.js
1981
- const slug = (value) => String(value || "asset").toLowerCase().replace(/[^a-z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "asset";
1982
- var ManifestPass = class {
1983
- async run(context) {
1984
- const id = context.assetId || `${slug(context.semantics.type)}_${slug(context.sourceName.replace(/\.(glb|gltf)$/i, ""))}`;
1985
- const physics = context.physics || {};
1986
- const parts = context.articulation.parts || void 0;
1987
- const actions = new Set(context.semantics.actions || ["move"]);
1988
- for (const part of Object.values(parts || {})) for (const action of part.actions || []) if (Number.isFinite(part.targets?.[action])) actions.add(action);
1989
- const manifest = {
1990
- id,
1991
- type: context.semantics.type,
1992
- label: context.semantics.label,
1993
- description: context.semantics.description || "",
1994
- tags: [...new Set(context.semantics.tags || [])],
1995
- aliases: context.semantics.aliases || [],
1996
- source: {
1997
- kind: "compiled",
1998
- key: context.storageKey || id,
1999
- fallbackUrl: context.sourceUrl || null
2000
- },
2001
- actions: [...actions],
2002
- ...context.definition ? Object.fromEntries([
2003
- "requiredNodes",
2004
- "surfaces",
2005
- "receptacles",
2006
- "interactionContract",
2007
- "simulation"
2008
- ].filter((key) => context.definition[key] != null).map((key) => [key, structuredClone(context.definition[key])])) : {},
2009
- ...parts ? { parts } : {},
2010
- physics: {
2011
- ...context.definition?.physics ? structuredClone(context.definition.physics) : {},
2012
- body: physics.body || "fixed",
2013
- mass: Number(physics.mass ?? (actions.has("pickup") ? .5 : 1)),
2014
- friction: Number(physics.friction ?? .5),
2015
- colliders: context.collision.colliders
2016
- },
2017
- compiler: {
2018
- version: context.compilerVersion,
2019
- compiledAt: (/* @__PURE__ */ new Date()).toISOString(),
2020
- sourceName: context.sourceName,
2021
- quality: context.quality,
2022
- semanticConfidence: context.semantics.confidence,
2023
- collisionStrategy: context.collision.strategy,
2024
- optimization: context.optimization,
2025
- inspection: context.inspection.stats,
2026
- structure: context.structure,
2027
- normalization: context.normalization,
2028
- articulationCandidates: context.articulation.candidates,
2029
- partProposal: context.partProposal || null,
2030
- partSegmentation: context.partSegmentation || null,
2031
- partCollision: context.partCollision || null,
2032
- partGeometry: context.partGeometry || null,
2033
- meshQuality: context.meshQuality || null,
2034
- resources: context.resources
2035
- },
2036
- provenance: {
2037
- ...context.interactionReview ? { interactionReview: structuredClone(context.interactionReview) } : {},
2038
- ...context.authoringIntent ? { authoringIntent: structuredClone(context.authoringIntent) } : {},
2039
- sourceUrl: context.sourceUrl || null,
2040
- compiler: "AgentScape",
2041
- ...context.providerEvidence ? {
2042
- provider: context.providerEvidence.provider || null,
2043
- providerEvidence: structuredClone(context.providerEvidence)
2044
- } : {}
2045
- }
2046
- };
2047
- return {
2048
- ...context,
2049
- manifest
2050
- };
2051
- }
2052
- };
2053
- //#endregion
2054
- //#region ../../modules/asset/production/compiler/passes/AuthoringIntentPass.js
2055
- var AuthoringIntentPass = class {
2056
- async run(context) {
2057
- if (context.interactionReview) return {
2058
- ...context,
2059
- semantics: {
2060
- ...context.semantics,
2061
- actions: []
2062
- },
2063
- physics: context.interactionReview.physics
2064
- };
2065
- const intent = context.authoringIntent;
2066
- if (!intent) return context;
2067
- if (![
2068
- "static",
2069
- "movable",
2070
- "interactive"
2071
- ].includes(intent.usage)) throw new TypeError("Invalid authoring usage");
2072
- if (intent.usage === "interactive") return context;
2073
- const movable = intent.usage === "movable";
2074
- return {
2075
- ...context,
2076
- semantics: {
2077
- ...context.semantics,
2078
- actions: movable ? [
2079
- "move",
2080
- "pickup",
2081
- "drop",
2082
- "place"
2083
- ] : ["move"]
2084
- },
2085
- physics: {
2086
- ...context.physics,
2087
- body: movable ? "dynamic" : "fixed"
2088
- }
2089
- };
2090
- }
2091
- };
2092
- //#endregion
2093
- //#region ../../modules/asset/production/compiler/passes/ExplicitDefinitionPass.js
2094
- var ExplicitDefinitionPass = class {
2095
- async run(context) {
2096
- if (context.interactionReview && !context.definition) {
2097
- const physics = structuredClone(context.interactionReview.physics);
2098
- return {
2099
- ...context,
2100
- physics,
2101
- collision: physics.colliders ? {
2102
- strategy: "reviewed-colliders",
2103
- quality: "declared",
2104
- colliders: physics.colliders
2105
- } : context.collision
2106
- };
2107
- }
2108
- if (!context.definition) return context;
2109
- const definition = structuredClone(context.definition);
2110
- validateAssetManifest({
2111
- ...definition,
2112
- id: context.assetId,
2113
- source: {
2114
- kind: "compiled",
2115
- key: context.assetId
2116
- }
2117
- });
2118
- return {
2119
- ...context,
2120
- definition,
2121
- semantics: {
2122
- type: definition.type,
2123
- label: definition.label,
2124
- tags: definition.tags || [],
2125
- aliases: definition.aliases || [],
2126
- actions: definition.actions,
2127
- confidence: 1,
2128
- source: "explicit-definition"
2129
- },
2130
- physics: definition.physics,
2131
- collision: {
2132
- strategy: "declared-colliders",
2133
- quality: "declared",
2134
- colliders: definition.physics.colliders
2135
- },
2136
- articulation: {
2137
- ...context.articulation,
2138
- parts: definition.parts || {},
2139
- candidates: []
2140
- }
2141
- };
2142
- }
2143
- };
2144
- //#endregion
2145
- //#region ../../modules/asset/production/compiler/AssetCompiler.js
2146
- var AssetCompiler = class {
2147
- async compileVisual({ bytes, assetId, label = "Imported model", persist = true }) {
2148
- assertEmbeddedGLB(bytes);
2149
- let context = {
2150
- bytes,
2151
- assetId,
2152
- authoringIntent: { usage: "static" },
2153
- compilerVersion: this.version
2154
- };
2155
- for (const pass of [
2156
- new GLTFInspectPass({ io: this.io }),
2157
- new StructurePass(),
2158
- new GeometryPass(),
2159
- new OptimizeGLBPass({ io: this.io }),
2160
- new ResourceBudgetPass()
2161
- ]) context = await pass.run(context);
2162
- const hard = [...context.geometry.warnings.filter((w) => w.severity === "hard"), ...context.resources.hard];
2163
- const advisory = [...context.geometry.warnings.filter((w) => w.severity !== "hard"), ...context.resources.advisory];
2164
- const quality = {
2165
- status: hard.length ? "rejected" : advisory.length ? "provisional" : "ready",
2166
- hard,
2167
- advisory
2168
- };
2169
- if (hard.length) throw Object.assign(/* @__PURE__ */ new Error("Visual asset rejected"), {
2170
- code: "ASSET_COMPILE_REJECTED",
2171
- details: quality
2172
- });
2173
- const manifest = {
2174
- id: assetId,
2175
- type: "visual",
2176
- label,
2177
- capabilityLevel: "visual",
2178
- actions: [],
2179
- source: {
2180
- kind: "compiled",
2181
- key: assetId
2182
- },
2183
- compiler: {
2184
- version: this.version,
2185
- quality,
2186
- resources: context.resources
2187
- }
2188
- };
2189
- validateAssetManifest(manifest);
2190
- if (persist) await this.store.put(assetId, context.optimizedBytes, {
2191
- manifestId: assetId,
2192
- quality: quality.status
2193
- });
2194
- return {
2195
- manifest,
2196
- quality,
2197
- resources: context.resources,
2198
- optimizedBytes: context.optimizedBytes
2199
- };
2200
- }
2201
- constructor({ store, provider = null, events = null, version = "dev" } = {}) {
2202
- this.store = store;
2203
- this.provider = provider;
2204
- this.events = events;
2205
- this.version = version;
2206
- this.io = createAssetGLTFIO();
2207
- this.passes = [
2208
- new GLTFInspectPass({ io: this.io }),
2209
- new StructurePass(),
2210
- new NormalizeTransformPass(),
2211
- new GeometryPass(),
2212
- new KinematicEvidencePass(),
2213
- new SemanticHeuristicPass(),
2214
- new AuthoringIntentPass(),
2215
- new ArticulationCandidatePass(),
2216
- new ColliderFallbackPass(),
2217
- new RemoteEnrichmentPass({ provider }),
2218
- new SegmentMaterializePass(),
2219
- new SegmentationEvidencePass(),
2220
- new JointFramePass(),
2221
- new PartColliderPass(),
2222
- new PartProposalPass(),
2223
- new PartGeometryEnrichmentPass({
2224
- provider,
2225
- io: this.io
2226
- }),
2227
- new ArticulatedCollisionPass(),
2228
- new OptimizeGLBPass({ io: this.io }),
2229
- new ExplicitDefinitionPass(),
2230
- new ResourceBudgetPass(),
2231
- new CompileQualityPass(),
2232
- new ManifestPass()
2233
- ];
2234
- }
2235
- async fetchBytes(url) {
2236
- const response = await fetch(url);
2237
- if (!response.ok) throw new Error(`Failed to fetch GLB: HTTP ${response.status}`);
2238
- const declared = Number(response.headers.get("content-length") || 0);
2239
- if (declared > RESOURCE_BUDGET.maxInputBytes) throw Object.assign(/* @__PURE__ */ new Error(`GLB exceeds input limit: ${declared}`), { code: "ASSET_INPUT_TOO_LARGE" });
2240
- if (!response.body) return new Uint8Array(await response.arrayBuffer());
2241
- const reader = response.body.getReader();
2242
- const chunks = [];
2243
- let total = 0;
2244
- while (true) {
2245
- const { done, value } = await reader.read();
2246
- if (done) break;
2247
- total += value.byteLength;
2248
- if (total > RESOURCE_BUDGET.maxInputBytes) {
2249
- await reader.cancel();
2250
- throw Object.assign(/* @__PURE__ */ new Error(`GLB exceeds input limit: ${total}`), { code: "ASSET_INPUT_TOO_LARGE" });
2251
- }
2252
- chunks.push(value);
2253
- }
2254
- const bytes = new Uint8Array(total);
2255
- let offset = 0;
2256
- for (const chunk of chunks) {
2257
- bytes.set(chunk, offset);
2258
- offset += chunk.byteLength;
2259
- }
2260
- return bytes;
2261
- }
2262
- async proposeInteraction({ bytes, sourceName = "import.glb", label, partProposal = null, urdfHash = null } = {}) {
2263
- assertEmbeddedGLB(bytes);
2264
- const output = await this.compile({
2265
- bytes,
2266
- sourceName,
2267
- label,
2268
- assetId: "interaction_candidate",
2269
- partProposal,
2270
- interactionProposal: true,
2271
- authoringIntent: { usage: "static" },
2272
- persist: false
2273
- });
2274
- const sourceHash = await assetDigest(bytes);
2275
- const parts = (output.partProposal?.parts || []).map((part) => ({
2276
- ...part,
2277
- executable: false,
2278
- physicsVerified: false,
2279
- missing: [
2280
- "mass",
2281
- "friction",
2282
- ...[
2283
- "axis",
2284
- "parentAnchor",
2285
- "childAnchor",
2286
- "limits"
2287
- ].filter((field) => part.joint?.[field] == null).map((field) => `joint.${field}`),
2288
- "review-confirmation",
2289
- "runtime-verification"
2290
- ]
2291
- }));
2292
- const proposal = {
2293
- schema: "agentscape.capability-proposal",
2294
- schemaVersion: 1,
2295
- sourceHash,
2296
- urdfHash,
2297
- compilerVersion: this.version,
2298
- physics: {
2299
- body: null,
2300
- mass: null,
2301
- friction: null,
2302
- colliders: output.manifest.physics.colliders
2303
- },
2304
- parts,
2305
- kinematics: output.kinematicEvidence || {
2306
- schema: "agentscape.kinematic-evidence",
2307
- schemaVersion: 1,
2308
- hypotheses: [],
2309
- issues: []
2310
- },
2311
- operations: [
2312
- ...output.geometry.bounds.size.every((size) => Number.isFinite(size) && size > 0 && size <= 1.25) ? [
2313
- "pickup",
2314
- "drop",
2315
- "place"
2316
- ].map((action) => ({
2317
- action,
2318
- executable: false,
2319
- physicsVerified: false,
2320
- requires: "reviewed-dynamic-body-mass-and-carry-geometry"
2321
- })) : [],
2322
- ...[
2323
- "push",
2324
- "drag",
2325
- "rotate"
2326
- ].map((action) => ({
2327
- action,
2328
- executable: false,
2329
- physicsVerified: false,
2330
- requires: "reviewed-dynamic-body"
2331
- })),
2332
- ...parts.filter((part) => ["prismatic", "revolute"].includes(part.joint?.type)).map((part) => ({
2333
- action: part.joint.type === "prismatic" ? "slide" : "rotateJoint",
2334
- part: part.id,
2335
- executable: false,
2336
- physicsVerified: false,
2337
- requires: "reviewed-and-verified-joint"
2338
- })),
2339
- ...(output.articulation.candidates || []).flatMap((candidate) => (candidate.suggestedActions || []).filter((action) => !["slide", "rotateJoint"].includes(action)).map((action) => ({
2340
- action,
2341
- part: candidate.partId || candidate.node,
2342
- executable: false,
2343
- physicsVerified: false,
2344
- requires: "semantic-review-and-verified-joint-target"
2345
- })))
2346
- ],
2347
- missing: [
2348
- "physics.body",
2349
- "physics.mass",
2350
- "physics.friction",
2351
- "review-confirmation",
2352
- "runtime-verification"
2353
- ],
2354
- evidence: {
2355
- geometry: output.geometry.bounds,
2356
- collisionStrategy: output.collision.strategy,
2357
- articulationSource: output.partProposal?.source || output.articulation.source,
2358
- confidenceScope: "name-or-source-metadata-only; not physical verification",
2359
- semanticConfidence: output.manifest.compiler.semanticConfidence,
2360
- jointFrame: output.partProposal?.jointFrame || null,
2361
- issues: output.partProposal?.issues || [],
2362
- passes: [
2363
- "SemanticHeuristicPass",
2364
- "KinematicEvidencePass",
2365
- "ArticulationCandidatePass",
2366
- "PartColliderPass",
2367
- "JointFramePass"
2368
- ]
2369
- }
2370
- };
2371
- return {
2372
- ...proposal,
2373
- proposalId: await assetDigest(new TextEncoder().encode(canonicalAssetJson(proposal)))
2374
- };
2375
- }
2376
- async compile({ url, bytes, sourceName, assetId, label, partProposal = null, partSegmentation = null, providerEvidence = null, authoringIntent = null, definition = null, interactionProposal = false, interactionReview = null, persist = true } = {}) {
2377
- if (interactionReview) interactionReview = interactionReviewSchema.parse(interactionReview);
2378
- if (!bytes && !url) throw new Error("AssetCompiler requires url or bytes");
2379
- const inputBytes = bytes instanceof Uint8Array ? bytes : bytes ? new Uint8Array(bytes) : await this.fetchBytes(url);
2380
- if (inputBytes.byteLength > RESOURCE_BUDGET.maxInputBytes) {
2381
- const error = /* @__PURE__ */ new Error(`GLB exceeds input limit: ${inputBytes.byteLength} > ${RESOURCE_BUDGET.maxInputBytes}`);
2382
- error.code = "ASSET_INPUT_TOO_LARGE";
2383
- throw error;
2384
- }
2385
- const name = sourceName || (url ? new URL(url, globalThis.location?.href || "http://localhost").pathname.split("/").pop() : "asset.glb");
2386
- let context = {
2387
- bytes: inputBytes,
2388
- sourceUrl: url || null,
2389
- sourceName: name,
2390
- assetId,
2391
- label,
2392
- partProposal,
2393
- partSegmentation,
2394
- providerEvidence,
2395
- authoringIntent,
2396
- definition,
2397
- interactionProposal,
2398
- interactionReview,
2399
- compilerVersion: this.version
2400
- };
2401
- for (const pass of this.passes) {
2402
- const started = performance.now();
2403
- this.events?.emit("assetCompiler.pass.started", {
2404
- pass: pass.constructor.name,
2405
- sourceName: name
2406
- });
2407
- context = await pass.run(context);
2408
- this.events?.emit("assetCompiler.pass.completed", {
2409
- pass: pass.constructor.name,
2410
- elapsedMs: Math.round(performance.now() - started)
2411
- });
2412
- }
2413
- validateAssetManifest(context.manifest);
2414
- if (context.quality.status === "rejected") {
2415
- const error = /* @__PURE__ */ new Error("Asset compilation rejected by quality gate");
2416
- error.code = "ASSET_COMPILE_REJECTED";
2417
- error.details = context.quality;
2418
- throw error;
2419
- }
2420
- const storageKey = context.manifest.source.key;
2421
- if (persist) await this.store.put(storageKey, context.optimizedBytes, {
2422
- sourceName: name,
2423
- manifestId: context.manifest.id,
2424
- quality: context.quality.status
2425
- });
2426
- return {
2427
- manifest: context.manifest,
2428
- optimizedBytes: context.optimizedBytes,
2429
- inspection: context.inspection,
2430
- structure: context.structure,
2431
- normalization: context.normalization,
2432
- geometry: context.geometry,
2433
- optimization: context.optimization,
2434
- articulation: context.articulation,
2435
- kinematicEvidence: context.kinematicEvidence || null,
2436
- collision: context.collision,
2437
- enrichment: context.enrichment,
2438
- meshQuality: context.meshQuality || null,
2439
- partProposal: context.partProposal || null,
2440
- partSegmentation: context.partSegmentation || null,
2441
- partCollision: context.partCollision || null,
2442
- partGeometry: context.partGeometry || null,
2443
- resources: context.resources,
2444
- quality: context.quality
2445
- };
2446
- }
2447
- };
2448
- //#endregion
2449
- export { AssetCompiler };
2450
-
2451
- //# sourceMappingURL=AssetCompiler-CDFiElji.js.map