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,93 @@
1
+ import { orderParts, ROOT_PART } from '../../../model/parts.js';
2
+
3
+ const SUPPORTED_JOINTS = new Set(['revolute', 'prismatic']);
4
+ const finiteVec = (value, length) => Array.isArray(value) && value.length === length && value.every(Number.isFinite);
5
+
6
+ function executableReason(part, reviewed = false) {
7
+ if (!part.joint) return 'missing-joint';
8
+ if (!SUPPORTED_JOINTS.has(part.joint.type)) return 'unsupported-joint';
9
+ if (!finiteVec(part.joint.axis, 3) || Math.hypot(...part.joint.axis) < 1e-6) return 'invalid-axis';
10
+ if (!finiteVec(part.joint.parentAnchor, 3) || !finiteVec(part.joint.childAnchor, 3)) return 'missing-anchor';
11
+ if (!finiteVec(part.joint.limits, 2) || part.joint.limits[0] >= part.joint.limits[1]) return 'invalid-limits';
12
+ if (!part.physics?.colliders?.length) return 'missing-collider';
13
+ if (!part.actions?.length && !reviewed) return 'missing-actions';
14
+ if (!(part.actions || []).every((action) => Number.isFinite(part.targets?.[action]))) return 'missing-target';
15
+ return null;
16
+ }
17
+
18
+ export class PartProposalPass {
19
+ async run(context) {
20
+ const proposal = context.partProposal;
21
+ if (!proposal) return context;
22
+ if (proposal.version !== 1 || !Array.isArray(proposal.parts)) {
23
+ return {
24
+ ...context,
25
+ partProposal: { ...proposal, accepted:false, promoted:[], unpromoted:[], issues:[{ code:'PART_PROPOSAL_FORMAT', message:'Part proposal requires version=1 and parts[].' }] }
26
+ };
27
+ }
28
+
29
+ const issues = [];
30
+ const parts = {};
31
+ const currentNodes = context.document?.getRoot?.().listNodes?.() || [];
32
+ const nodeNames = currentNodes.length ? currentNodes.map((node) => node.getName()) : context.inspection.nodes.map((node) => node.name);
33
+ const nodeCounts = new Map();
34
+ for (const name of nodeNames) if (name) nodeCounts.set(name, (nodeCounts.get(name) || 0) + 1);
35
+ for (const raw of proposal.parts) {
36
+ const id = String(raw.id || '').trim();
37
+ if (!id || parts[id]) { issues.push({ code:'PART_ID_INVALID', part:id || null, message:'Part id must be unique and non-empty.' }); continue; }
38
+ const matches = nodeCounts.get(raw.node) || 0;
39
+ if (matches === 0) { issues.push({ code:'PART_NODE_MISSING', part:id, node:raw.node, message:`GLB node not found: ${raw.node}` }); continue; }
40
+ if (matches > 1) { issues.push({ code:'PART_NODE_AMBIGUOUS', part:id, node:raw.node, message:`GLB node name is not unique: ${raw.node}` }); continue; }
41
+ parts[id] = {
42
+ node: raw.node,
43
+ parent: raw.parent || ROOT_PART,
44
+ ...(raw.semantic ? { semantic:raw.semantic } : {}),
45
+ ...(Array.isArray(raw.actions) ? { actions:[...new Set(raw.actions)] } : {}),
46
+ ...(raw.targets ? { targets:{...raw.targets} } : {}),
47
+ ...(raw.physics ? { physics:structuredClone(raw.physics) } : {}),
48
+ ...(raw.joint ? { joint:structuredClone(raw.joint) } : {}),
49
+ proposal: { source:proposal.source || 'provider', confidence:Number(raw.confidence ?? proposal.confidence ?? 0) }
50
+ };
51
+ }
52
+
53
+ let ordered = [];
54
+ try { ordered = orderParts(parts); }
55
+ catch (error) { issues.push({ code:'PART_HIERARCHY_INVALID', message:error.message }); }
56
+
57
+ if (!issues.length && context.document) {
58
+ const nodes = new Map(context.document.getRoot().listNodes().map((node) => [node.getName(), node]));
59
+ const isAncestor = (ancestor, node) => {
60
+ for (let current = node?.getParentNode?.(); current; current = current.getParentNode?.()) if (current === ancestor) return true;
61
+ return false;
62
+ };
63
+ for (const [id, part] of ordered) {
64
+ const parentId = part.parent || ROOT_PART;
65
+ if (parentId === ROOT_PART) continue;
66
+ const parentNode = nodes.get(parts[parentId].node);
67
+ const childNode = nodes.get(part.node);
68
+ if (!isAncestor(parentNode, childNode)) {
69
+ issues.push({ code:'PART_NODE_HIERARCHY_MISMATCH', part:id, parent:parentId, message:`GLB node ${part.node} is not under parent part node ${parts[parentId].node}.` });
70
+ }
71
+ }
72
+ }
73
+
74
+ const promoted = {};
75
+ const unpromoted = [];
76
+ if (!issues.length) {
77
+ for (const [id, part] of ordered) {
78
+ const reason = executableReason(part, Boolean(context.interactionReview));
79
+ const parent = part.parent || ROOT_PART;
80
+ if (reason) { unpromoted.push({ part:id, reason }); continue; }
81
+ if (parent !== ROOT_PART && !promoted[parent]) { unpromoted.push({ part:id, reason:'parent-not-executable' }); continue; }
82
+ promoted[id] = part;
83
+ }
84
+ }
85
+
86
+ const accepted = issues.length === 0;
87
+ return {
88
+ ...context,
89
+ articulation: { ...context.articulation, ...(accepted && Object.keys(promoted).length ? { parts:promoted, source:'part-proposal' } : {}) },
90
+ partProposal: { ...proposal, accepted, promoted:Object.keys(promoted), unpromoted, issues }
91
+ };
92
+ }
93
+ }
@@ -0,0 +1,32 @@
1
+ export class RemoteEnrichmentPass {
2
+ constructor({ provider } = {}) { this.provider = provider; }
3
+
4
+ async run(context) {
5
+ if (!this.provider?.isConfigured()) return { ...context, enrichment: { skipped: true } };
6
+ try {
7
+ const response = await this.provider.run('enrich', {
8
+ source: { name: context.sourceName, url: context.sourceUrl },
9
+ inspection: { nodes: context.inspection.nodes, stats: context.inspection.stats },
10
+ geometry: context.geometry,
11
+ semantics: context.semantics,
12
+ articulationCandidates: context.articulation.candidates
13
+ });
14
+ return {
15
+ ...context,
16
+ semantics: response?.semantics ? { ...context.semantics, ...response.semantics, source: 'provider' } : context.semantics,
17
+ articulation: context.articulation,
18
+ partProposal: response?.partProposal || context.partProposal || null,
19
+ partSegmentation: response?.partSegmentation || context.partSegmentation || null,
20
+ collision: response?.collision || context.collision,
21
+ physics: response?.physics || context.physics,
22
+ meshQuality: response?.geometry || context.meshQuality || null,
23
+ enrichment: { skipped: false, provider: this.provider.endpoint }
24
+ };
25
+ } catch (error) {
26
+ return {
27
+ ...context,
28
+ enrichment: { skipped: true, provider: this.provider.endpoint, error: error.message }
29
+ };
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,55 @@
1
+ import { inspect } from '@gltf-transform/functions';
2
+
3
+ import { RESOURCE_BUDGET } from '../../../model/resourceBudget.js';
4
+
5
+ const textureDimension = (resolution = '') => Math.max(...resolution.split('x').map(Number).filter(Number.isFinite), 0);
6
+ const countDrawCalls = (scene) => {
7
+ let count = 0;
8
+ const visit = (node) => {
9
+ count += node.getMesh()?.listPrimitives().length || 0;
10
+ node.listChildren().forEach(visit);
11
+ };
12
+ scene?.listChildren().forEach(visit);
13
+ return count;
14
+ };
15
+
16
+ export class ResourceBudgetPass {
17
+ async run(context) {
18
+ const report = inspect(context.document);
19
+ const scenes = context.document.getRoot().listScenes();
20
+ const sceneIndex = context.structure.defaultSceneIndex >= 0 ? context.structure.defaultSceneIndex : 0;
21
+ const scene = scenes[sceneIndex];
22
+ const sceneReport = report.scenes.properties[sceneIndex];
23
+ const metrics = {
24
+ optimizedBytes: context.optimizedBytes.byteLength,
25
+ renderVertices: sceneReport?.renderVertexCount || 0,
26
+ uploadVertices: sceneReport?.uploadVertexCount || 0,
27
+ drawCalls: countDrawCalls(scene),
28
+ textureVRAM: report.textures.properties.reduce((sum, texture) => sum + (texture.gpuSize || 0), 0),
29
+ maxTextureDimension: report.textures.properties.reduce((max, texture) => Math.max(max, textureDimension(texture.resolution)), 0),
30
+ animationKeyframes: report.animations.properties.reduce((sum, animation) => sum + animation.keyframes, 0)
31
+ };
32
+
33
+ const hard = [];
34
+ const advisory = [];
35
+ const checks = [
36
+ ['renderVertices', 'RENDER_VERTICES', '渲染顶点数'],
37
+ ['drawCalls', 'DRAW_CALLS', 'Draw Call'],
38
+ ['textureVRAM', 'TEXTURE_VRAM', '纹理显存估算'],
39
+ ['maxTextureDimension', 'TEXTURE_DIMENSION', '最大纹理边长'],
40
+ ['animationKeyframes', 'ANIMATION_KEYFRAMES', '动画关键帧数']
41
+ ];
42
+ for (const [key, code, label] of checks) {
43
+ const value = metrics[key];
44
+ const limit = RESOURCE_BUDGET[key];
45
+ if (value > limit.hard) hard.push({ code: `BUDGET_${code}_HARD`, message: `${label} ${value} 超过硬上限 ${limit.hard}。` });
46
+ else if (value > limit.advisory) advisory.push({ code: `BUDGET_${code}`, message: `${label} ${value} 超过建议上限 ${limit.advisory}。` });
47
+ }
48
+
49
+ return {
50
+ ...context,
51
+ inspection: { ...context.inspection, report, stats: { ...context.inspection.stats, ...metrics } },
52
+ resources: { metrics, hard, advisory }
53
+ };
54
+ }
55
+ }
@@ -0,0 +1,203 @@
1
+ import { Primitive } from '@gltf-transform/core';
2
+
3
+ const slug = (value) => String(value).trim().replace(/[^a-zA-Z0-9_-]+/g, '_').replace(/^_+|_+$/g, '');
4
+ const labelsArray = (value) => Array.isArray(value) || ArrayBuffer.isView(value) ? Array.from(value, (item) => String(item)) : null;
5
+
6
+ const makeIndices = (document, sourcePrimitive, faceLabels, segmentId) => {
7
+ const sourceIndices = sourcePrimitive.getIndices()?.getArray() || null;
8
+ const positions = sourcePrimitive.getAttribute('POSITION');
9
+ const vertexCount = positions?.getCount() || 0;
10
+ const faceCount = sourceIndices ? sourceIndices.length / 3 : vertexCount / 3;
11
+ if (!Number.isInteger(faceCount)) throw new Error('Primitive triangle count is not integral.');
12
+ if (faceLabels.length !== faceCount) throw new Error(`Face label count ${faceLabels.length} does not match primitive face count ${faceCount}.`);
13
+
14
+ const selected = [];
15
+ for (let face = 0; face < faceCount; face++) {
16
+ if (faceLabels[face] !== segmentId) continue;
17
+ const offset = face * 3;
18
+ selected.push(
19
+ sourceIndices ? sourceIndices[offset] : offset,
20
+ sourceIndices ? sourceIndices[offset + 1] : offset + 1,
21
+ sourceIndices ? sourceIndices[offset + 2] : offset + 2
22
+ );
23
+ }
24
+ if (!selected.length) return null;
25
+ let max = 0;
26
+ for (const index of selected) if (index > max) max = index;
27
+ const array = max <= 65535 ? new Uint16Array(selected) : new Uint32Array(selected);
28
+ return document.createAccessor().setType('SCALAR').setArray(array);
29
+ };
30
+
31
+ const clonePrimitiveView = (document, source, indices) => {
32
+ const primitive = document.createPrimitive().setMode(source.getMode()).setIndices(indices).setMaterial(source.getMaterial());
33
+ for (const semantic of source.listSemantics()) primitive.setAttribute(semantic, source.getAttribute(semantic));
34
+ primitive.setExtras(structuredClone(source.getExtras()));
35
+ return primitive;
36
+ };
37
+
38
+ export class SegmentMaterializePass {
39
+ async run(context) {
40
+ const evidence = context.partSegmentation;
41
+ const spec = evidence?.materialization;
42
+ if (!spec) return context;
43
+ const issues = [];
44
+ const fail = (code, message, details = {}) => ({
45
+ ...context,
46
+ partSegmentation: {
47
+ ...evidence,
48
+ materialization: { status:'rejected', sourceNode:spec.sourceNode || null, issues:[...issues, { code, message, ...details }] }
49
+ }
50
+ });
51
+
52
+ if (evidence.version !== 1 || !evidence.source || !Number.isInteger(evidence.faceCount) || evidence.faceCount <= 0 || !Array.isArray(evidence.segments)) {
53
+ return fail('MATERIALIZATION_EVIDENCE_INVALID', 'Materialization requires valid Segmentation Evidence v1 metadata.');
54
+ }
55
+ if (!spec.sourceNode || !Array.isArray(spec.primitives)) return fail('MATERIALIZATION_FORMAT', 'Materialization requires sourceNode and primitives[].');
56
+ const nodes = context.document.getRoot().listNodes().filter((node) => node.getName() === spec.sourceNode);
57
+ if (nodes.length !== 1) return fail(nodes.length ? 'MATERIALIZATION_NODE_AMBIGUOUS' : 'MATERIALIZATION_NODE_MISSING', `Source node must resolve uniquely: ${spec.sourceNode}`);
58
+ const sourceNode = nodes[0];
59
+ const sourceMesh = sourceNode.getMesh();
60
+ if (!sourceMesh) return fail('MATERIALIZATION_MESH_MISSING', `Source node has no mesh: ${spec.sourceNode}`);
61
+ if (sourceNode.getSkin()) return fail('MATERIALIZATION_SKIN_UNSUPPORTED', 'Skinned nodes are not materialized automatically.');
62
+ if (sourceNode.getWeights().length || sourceMesh.getWeights().length) return fail('MATERIALIZATION_MORPH_UNSUPPORTED', 'Morph-target meshes are not materialized automatically.');
63
+ if (sourceNode.listExtensions().length || sourceMesh.listExtensions().length) return fail('MATERIALIZATION_EXTENSION_UNSUPPORTED', 'Node or mesh extensions require provider-side materialization.');
64
+
65
+ const primitives = sourceMesh.listPrimitives();
66
+ if (spec.primitives.length !== primitives.length) return fail('MATERIALIZATION_PRIMITIVE_COVERAGE', 'Every source primitive must have one face-label entry.');
67
+ const byPrimitive = new Map();
68
+ for (const entry of spec.primitives) {
69
+ if (!Number.isInteger(entry.primitive) || entry.primitive < 0 || entry.primitive >= primitives.length || byPrimitive.has(entry.primitive)) {
70
+ return fail('MATERIALIZATION_PRIMITIVE_INDEX', `Invalid or duplicate primitive index: ${entry.primitive}`);
71
+ }
72
+ const labels = labelsArray(entry.faceLabels);
73
+ if (!labels) return fail('MATERIALIZATION_LABELS_MISSING', `Primitive ${entry.primitive} requires faceLabels[].`);
74
+ byPrimitive.set(entry.primitive, labels);
75
+ }
76
+
77
+ const segmentDefs = new Map();
78
+ const generatedNames = new Set(context.document.getRoot().listNodes().map((node) => node.getName()).filter(Boolean));
79
+ for (const segment of evidence.segments || []) {
80
+ const id = String(segment.id ?? '');
81
+ 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>'}`);
82
+ const safe = slug(id);
83
+ if (!safe) return fail('MATERIALIZATION_SEGMENT_ID', `Segment id cannot form a stable node name: ${id}`);
84
+ const nodeName = `${spec.sourceNode}__part_${safe}`;
85
+ if (generatedNames.has(nodeName)) return fail('MATERIALIZATION_NODE_COLLISION', `Generated node already exists: ${nodeName}`);
86
+ if ([...segmentDefs.values()].some((item) => item.nodeName === nodeName)) return fail('MATERIALIZATION_SEGMENT_ID_COLLISION', `Segment ids collide after normalization: ${id}`);
87
+ segmentDefs.set(id, { id, nodeName, segment });
88
+ }
89
+ if (!segmentDefs.size) return fail('MATERIALIZATION_SEGMENTS_MISSING', 'No segmentation definitions are available.');
90
+
91
+ const proposalParts = new Map((context.partProposal?.parts || []).map((part) => [String(part.id), part]));
92
+ if (context.partProposal) {
93
+ const nodeById = new Map([...segmentDefs.values()].map((def) => [def.id, def.nodeName]));
94
+ for (const [id, def] of segmentDefs) {
95
+ const part = proposalParts.get(id);
96
+ if (!part) continue;
97
+ if (part.node && part.node !== def.nodeName) return fail('MATERIALIZATION_PROPOSAL_NODE_CONFLICT', `Part Proposal node conflicts with materialized segment ${id}.`, { part:id, expected:def.nodeName, actual:part.node });
98
+ const parent = part.parent || '$root';
99
+ if (parent !== '$root' && !segmentDefs.has(String(parent))) return fail('MATERIALIZATION_EXTERNAL_PARENT_UNSUPPORTED', `Materialized Part ${id} references a parent outside this segmentation batch: ${parent}.`, { part:id, parent });
100
+ }
101
+ for (const id of segmentDefs.keys()) {
102
+ const seen = new Set([id]);
103
+ for (let parent = proposalParts.get(id)?.parent; parent && parent !== '$root'; parent = proposalParts.get(String(parent))?.parent) {
104
+ parent = String(parent);
105
+ if (seen.has(parent)) return fail('MATERIALIZATION_PART_HIERARCHY_CYCLE', `Materialized Part hierarchy contains a cycle at ${parent}.`);
106
+ seen.add(parent);
107
+ }
108
+ }
109
+ }
110
+
111
+ const actualCounts = new Map([...segmentDefs.keys()].map((id) => [id, 0]));
112
+ let totalFaces = 0;
113
+ for (let primitiveIndex = 0; primitiveIndex < primitives.length; primitiveIndex++) {
114
+ const primitive = primitives[primitiveIndex];
115
+ if (primitive.getMode() !== Primitive.Mode.TRIANGLES) return fail('MATERIALIZATION_MODE_UNSUPPORTED', `Primitive ${primitiveIndex} is not TRIANGLES.`);
116
+ if (primitive.listTargets().length || primitive.listExtensions().length) return fail('MATERIALIZATION_PRIMITIVE_UNSUPPORTED', `Primitive ${primitiveIndex} has morph targets or extensions.`);
117
+ const labels = byPrimitive.get(primitiveIndex);
118
+ const indices = primitive.getIndices()?.getArray();
119
+ const faceCount = indices ? indices.length / 3 : (primitive.getAttribute('POSITION')?.getCount() || 0) / 3;
120
+ if (!Number.isInteger(faceCount) || labels.length !== faceCount) return fail('MATERIALIZATION_FACE_COUNT', `Primitive ${primitiveIndex} face labels do not exactly match its triangles.`);
121
+ totalFaces += faceCount;
122
+ for (const label of labels) {
123
+ if (!segmentDefs.has(label)) return fail('MATERIALIZATION_UNKNOWN_SEGMENT', `Face label references unknown segment: ${label}`);
124
+ actualCounts.set(label, actualCounts.get(label) + 1);
125
+ }
126
+ }
127
+ 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}.`);
128
+ for (const [id, def] of segmentDefs) {
129
+ if (!actualCounts.get(id)) return fail('MATERIALIZATION_EMPTY_SEGMENT', `Segment has no faces: ${id}`);
130
+ if (Number.isInteger(def.segment.faceCount) && def.segment.faceCount !== actualCounts.get(id)) {
131
+ return fail('MATERIALIZATION_SEGMENT_COUNT_MISMATCH', `Segment ${id} faceCount does not match labels.`);
132
+ }
133
+ }
134
+
135
+ const materializedParts = [];
136
+ const materializedNodes = new Map();
137
+ for (const [id, def] of segmentDefs) {
138
+ const mesh = context.document.createMesh(`${def.nodeName}Mesh`).setWeights(sourceMesh.getWeights()).setExtras(structuredClone(sourceMesh.getExtras()));
139
+ for (let primitiveIndex = 0; primitiveIndex < primitives.length; primitiveIndex++) {
140
+ const indices = makeIndices(context.document, primitives[primitiveIndex], byPrimitive.get(primitiveIndex), id);
141
+ if (indices) mesh.addPrimitive(clonePrimitiveView(context.document, primitives[primitiveIndex], indices));
142
+ }
143
+ const node = context.document.createNode(def.nodeName).setMesh(mesh).setExtras({ agentscape:{ segmentId:id, source:evidence.source } });
144
+ sourceNode.addChild(node);
145
+ materializedNodes.set(id, node);
146
+ materializedParts.push({
147
+ id,
148
+ node:def.nodeName,
149
+ ...(def.segment.semantic ? { semantic:def.segment.semantic } : {}),
150
+ ...(Number.isFinite(def.segment.confidence) ? { confidence:def.segment.confidence } : {})
151
+ });
152
+ }
153
+ for (const [id, node] of materializedNodes) {
154
+ const parentId = String(proposalParts.get(id)?.parent || '$root');
155
+ if (parentId !== '$root') materializedNodes.get(parentId).addChild(node);
156
+ }
157
+ sourceNode.setMesh(null);
158
+
159
+ let partProposal = context.partProposal;
160
+ if (!partProposal) {
161
+ const confidences = materializedParts.map((part) => part.confidence).filter(Number.isFinite);
162
+ const confidence = Number.isFinite(evidence.confidence)
163
+ ? evidence.confidence
164
+ : confidences.length === materializedParts.length
165
+ ? confidences.reduce((min, value) => Math.min(min, value), 1)
166
+ : 0;
167
+ partProposal = { version:1, source:`segmentation/${evidence.source}`, confidence, parts:materializedParts };
168
+ } else {
169
+ const materializedById = new Map(materializedParts.map((part) => [part.id, part]));
170
+ partProposal = structuredClone(partProposal);
171
+ partProposal.parts ||= [];
172
+ const existingIds = new Set();
173
+ for (const part of partProposal.parts) {
174
+ const id = String(part.id);
175
+ existingIds.add(id);
176
+ const materialized = materializedById.get(id);
177
+ if (materialized && !part.node) part.node = materialized.node;
178
+ if (materialized?.semantic && !part.semantic) part.semantic = materialized.semantic;
179
+ if (Number.isFinite(materialized?.confidence) && !Number.isFinite(part.confidence)) part.confidence = materialized.confidence;
180
+ }
181
+ for (const materialized of materializedParts) {
182
+ if (!existingIds.has(materialized.id)) partProposal.parts.push(structuredClone(materialized));
183
+ }
184
+ }
185
+
186
+ return {
187
+ ...context,
188
+ partProposal,
189
+ partSegmentation: {
190
+ ...evidence,
191
+ materialization: {
192
+ status:issues.length ? 'partial' : 'materialized',
193
+ strategy:'shared-accessor-index-split',
194
+ completeFacePartition:true,
195
+ sourceNodeOriginPreserved:true,
196
+ sourceNode:spec.sourceNode,
197
+ nodes:materializedParts.map((part) => ({ id:part.id, node:part.node })),
198
+ issues
199
+ }
200
+ }
201
+ };
202
+ }
203
+ }
@@ -0,0 +1,43 @@
1
+ const finiteBounds = (bounds) => bounds && ['min','max'].every((key) => Array.isArray(bounds[key]) && bounds[key].length === 3 && bounds[key].every(Number.isFinite));
2
+
3
+ export class SegmentationEvidencePass {
4
+ async run(context) {
5
+ const evidence = context.partSegmentation;
6
+ if (!evidence) return context;
7
+ const issues = [];
8
+ const faceCount = Number(evidence.faceCount);
9
+ if (evidence.version !== 1 || !evidence.source || !Number.isInteger(faceCount) || faceCount <= 0 || !Array.isArray(evidence.segments)) {
10
+ issues.push({ code:'SEGMENTATION_FORMAT', message:'Segmentation evidence requires version=1, source, faceCount and segments[].' });
11
+ }
12
+ const ids = new Set();
13
+ let labeledFaces = 0;
14
+ for (const segment of evidence.segments || []) {
15
+ const id = String(segment.id ?? '');
16
+ if (!id || ids.has(id)) { issues.push({ code:'SEGMENTATION_ID_INVALID', segment:id || null }); continue; }
17
+ ids.add(id);
18
+ if (!Number.isInteger(segment.faceCount) || segment.faceCount <= 0) issues.push({ code:'SEGMENTATION_FACE_COUNT_INVALID', segment:id });
19
+ else labeledFaces += segment.faceCount;
20
+ if (segment.bounds && !finiteBounds(segment.bounds)) issues.push({ code:'SEGMENTATION_BOUNDS_INVALID', segment:id });
21
+ }
22
+ if (Number.isFinite(faceCount) && labeledFaces > faceCount) issues.push({ code:'SEGMENTATION_COVERAGE_INVALID', message:'Segment face counts exceed source face count.' });
23
+
24
+ const summary = {
25
+ version:evidence.version,
26
+ source:evidence.source,
27
+ faceCount,
28
+ labeledFaces,
29
+ coverage:faceCount > 0 ? labeledFaces / faceCount : 0,
30
+ segments:(evidence.segments || []).map((segment) => ({
31
+ id:String(segment.id),
32
+ faceCount:segment.faceCount,
33
+ ...(Number.isFinite(segment.confidence) ? { confidence:segment.confidence } : {}),
34
+ ...(segment.semantic ? { semantic:segment.semantic } : {}),
35
+ ...(segment.bounds ? { bounds:structuredClone(segment.bounds) } : {})
36
+ })),
37
+ ...(evidence.artifact ? { artifact:structuredClone(evidence.artifact) } : {}),
38
+ ...(evidence.materialization ? { materialization:structuredClone(evidence.materialization) } : {}),
39
+ issues
40
+ };
41
+ return { ...context, partSegmentation:summary };
42
+ }
43
+ }
@@ -0,0 +1,33 @@
1
+ const RULES = [
2
+ { type: 'cabinet', words: ['cabinet','cupboard','wardrobe','柜','橱'], tags: ['storage','furniture'] },
3
+ { type: 'drawer', words: ['drawer','抽屉'], tags: ['storage'] },
4
+ { type: 'door', words: ['door','门'], tags: ['door'] },
5
+ { type: 'cup', words: ['cup','mug','杯'], tags: ['drinkware','graspable'] },
6
+ { type: 'apple', words: ['apple','苹果'], tags: ['fruit','food','round','graspable'] },
7
+ { type: 'vase', words: ['vase','flower vase','花瓶'], tags: ['decor','container','graspable'] },
8
+ { type: 'chair', words: ['chair','seat','椅'], tags: ['furniture','seat'] },
9
+ { type: 'table', words: ['table','desk','桌'], tags: ['furniture','surface'] }
10
+ ];
11
+
12
+ export class SemanticHeuristicPass {
13
+ async run(context) {
14
+ const text = [context.label, context.sourceName, ...context.geometry.namedNodes].filter(Boolean).join(' ').toLowerCase();
15
+ const hits = RULES
16
+ .map((rule) => ({ rule, score: rule.words.filter((word) => text.includes(word)).length }))
17
+ .filter((item) => item.score > 0)
18
+ .sort((a, b) => b.score - a.score);
19
+ const best = hits[0];
20
+ const base = best?.rule || { type: 'object', tags: [] };
21
+ return {
22
+ ...context,
23
+ semantics: {
24
+ type: base.type,
25
+ label: context.label || context.sourceName.replace(/\.(glb|gltf)$/i, ''),
26
+ tags: base.tags,
27
+ actions: base.actions || ['move'],
28
+ confidence: best ? Math.min(0.85, 0.45 + best.score * 0.2) : 0.2,
29
+ source: 'heuristic'
30
+ }
31
+ };
32
+ }
33
+ }
@@ -0,0 +1,60 @@
1
+ const EPS = 1e-6;
2
+ const isIdentityRotation = ([x, y, z, w]) => Math.abs(x) < EPS && Math.abs(y) < EPS && Math.abs(z) < EPS && Math.abs(w - 1) < EPS;
3
+ const isUnitScale = (scale) => scale.every((value) => Math.abs(value - 1) < EPS);
4
+
5
+ export class StructurePass {
6
+ async run(context) {
7
+ const root = context.document.getRoot();
8
+ const scenes = root.listScenes();
9
+ const defaultScene = root.getDefaultScene() || scenes[0] || null;
10
+ const rootNodes = defaultScene?.listChildren() || [];
11
+ let maxDepth = 0;
12
+ const visit = (node, depth) => {
13
+ maxDepth = Math.max(maxDepth, depth);
14
+ for (const child of node.listChildren()) visit(child, depth + 1);
15
+ };
16
+ rootNodes.forEach((node) => visit(node, 1));
17
+
18
+ const negativeScaleNodes = [];
19
+ const transformedRoots = [];
20
+ const nonUniformScaleNodes = [];
21
+ for (const node of root.listNodes()) {
22
+ const scale = node.getScale();
23
+ if (scale[0] * scale[1] * scale[2] < 0) negativeScaleNodes.push(node.getName() || '(unnamed)');
24
+ if (Math.max(...scale) - Math.min(...scale) > EPS) nonUniformScaleNodes.push(node.getName() || '(unnamed)');
25
+ }
26
+ for (const node of rootNodes) {
27
+ if (node.getTranslation().some((value) => Math.abs(value) > EPS) || !isIdentityRotation(node.getRotation()) || !isUnitScale(node.getScale())) {
28
+ transformedRoots.push(node.getName() || '(unnamed)');
29
+ }
30
+ }
31
+
32
+ const warnings = [];
33
+ if (scenes.length > 1) warnings.push({ code: 'MULTIPLE_SCENES', severity: 'advisory', message: `GLB 包含 ${scenes.length} 个 Scene;运行时只实例化默认 Scene。` });
34
+ if (!root.getDefaultScene() && scenes.length > 1) warnings.push({ code: 'DEFAULT_SCENE_MISSING', severity: 'advisory', message: '多 Scene GLB 未声明默认 Scene,将使用第一个 Scene。' });
35
+ if (negativeScaleNodes.length) warnings.push({ code: 'NEGATIVE_SCALE', severity: 'advisory', message: `检测到 ${negativeScaleNodes.length} 个负缩放节点;碰撞和法线需要额外验证。` });
36
+ if (root.listSkins().length) warnings.push({ code: 'SKINNED_ASSET', severity: 'advisory', message: '资产包含 Skin;禁止自动 flatten 节点层级。' });
37
+ if (root.listAnimations().length) warnings.push({ code: 'ANIMATED_ASSET', severity: 'advisory', message: '资产包含动画;禁止自动 bake 层级变换。' });
38
+
39
+ return {
40
+ ...context,
41
+ structure: {
42
+ scenes: scenes.length,
43
+ defaultSceneIndex: defaultScene ? scenes.indexOf(defaultScene) : -1,
44
+ rootNodes: rootNodes.length,
45
+ maxDepth,
46
+ skins: root.listSkins().length,
47
+ animations: root.listAnimations().length,
48
+ transformedRoots,
49
+ negativeScaleNodes,
50
+ nonUniformScaleNodes,
51
+ warnings,
52
+ policy: {
53
+ centerBelow: Boolean(defaultScene),
54
+ flatten: false,
55
+ inferAxisRotation: false
56
+ }
57
+ }
58
+ };
59
+ }
60
+ }
@@ -0,0 +1,23 @@
1
+ import { JsonGateway } from '../../../../../foundation/JsonGateway.js';
2
+
3
+ export class HttpCompilerProvider extends JsonGateway {
4
+ constructor(options = {}) { super({ timeoutMs: 120000, label: 'Compiler provider', ...options }); }
5
+ async run(stage, payload) { return this.post({ stage, ...payload }); }
6
+
7
+ async runPartGeometry(bytes, parts) {
8
+ const form = new FormData();
9
+ form.set('stage', 'part-geometry');
10
+ form.set('metadata', JSON.stringify({ parts }));
11
+ form.set('asset', new Blob([bytes], { type:'model/gltf-binary' }), 'asset.glb');
12
+ return this.postForm(form);
13
+ }
14
+
15
+ async runUrdfProposal(bytes) {
16
+ const data = bytes instanceof Uint8Array ? bytes : bytes instanceof ArrayBuffer ? new Uint8Array(bytes) : null;
17
+ if (!data?.byteLength) throw new Error('URDF proposal requires non-empty bytes');
18
+ const form = new FormData();
19
+ form.set('stage', 'urdf-proposal');
20
+ form.set('asset', new Blob([data], { type:'application/xml' }), 'asset.urdf');
21
+ return this.postForm(form);
22
+ }
23
+ }