agentscape3d-engine 0.0.0-stage → 1.0.0-beta.2

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