agentscape3d 1.0.0-beta.1 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (386) hide show
  1. package/README.md +23 -48
  2. package/dist/core.d.ts +68 -0
  3. package/dist/core.js +209 -0
  4. package/dist/core.js.map +1 -0
  5. package/dist/index.d.ts +10 -229
  6. package/dist/index.js +192 -15462
  7. package/dist/index.js.map +1 -1
  8. package/package.json +11 -40
  9. package/cli.mjs +0 -27
  10. package/dist/AssetCompiler-CDFiElji.js +0 -2451
  11. package/dist/AssetCompiler-CDFiElji.js.map +0 -1
  12. package/dist/AssetInputContracts-Dy8iU4eT.js +0 -228
  13. package/dist/AssetInputContracts-Dy8iU4eT.js.map +0 -1
  14. package/dist/AssetRecipe-DmFpzxr-.js +0 -55
  15. package/dist/AssetRecipe-DmFpzxr-.js.map +0 -1
  16. package/dist/BrowserCodeWorker.js +0 -53615
  17. package/dist/KinematicHypothesisScreen-D-z6qgMB.js +0 -242
  18. package/dist/KinematicHypothesisScreen-D-z6qgMB.js.map +0 -1
  19. package/dist/SceneSerializer-DPVOyeRk.js +0 -353
  20. package/dist/SceneSerializer-DPVOyeRk.js.map +0 -1
  21. package/dist/StylePack-DNrdLeGI.js +0 -6314
  22. package/dist/StylePack-DNrdLeGI.js.map +0 -1
  23. package/dist/WorldArchive-pSBIGxLa.js +0 -420
  24. package/dist/WorldArchive-pSBIGxLa.js.map +0 -1
  25. package/dist/WorldIO-wsDfZGM4.js +0 -150
  26. package/dist/WorldIO-wsDfZGM4.js.map +0 -1
  27. package/dist/blankWorld-CBWbwJGj.js +0 -76
  28. package/dist/blankWorld-CBWbwJGj.js.map +0 -1
  29. package/dist/disposeObject3D-BQ9TyVC_.js +0 -54
  30. package/dist/disposeObject3D-BQ9TyVC_.js.map +0 -1
  31. package/dist/environments-DgH66NqV.js +0 -4220
  32. package/dist/environments-DgH66NqV.js.map +0 -1
  33. package/dist/gltfIO-B87nJaat.js +0 -10
  34. package/dist/gltfIO-B87nJaat.js.map +0 -1
  35. package/dist/grandUrbanBlock-Ob9pN-CB.js +0 -516
  36. package/dist/grandUrbanBlock-Ob9pN-CB.js.map +0 -1
  37. package/dist/magicCabin-D64fD1E2.js +0 -11024
  38. package/dist/magicCabin-D64fD1E2.js.map +0 -1
  39. package/dist/mcp.d.ts +0 -2
  40. package/dist/mcp.js +0 -1
  41. package/dist/monumentHall-BKbs0UOQ.js +0 -404
  42. package/dist/monumentHall-BKbs0UOQ.js.map +0 -1
  43. package/dist/node.d.ts +0 -16
  44. package/dist/node.js +0 -25
  45. package/dist/ruinedCourtyard-BoZxHldu.js +0 -697
  46. package/dist/ruinedCourtyard-BoZxHldu.js.map +0 -1
  47. package/dist/runtime/application/AgentTools.js +0 -25
  48. package/dist/runtime/application/README.md +0 -14
  49. package/dist/runtime/application/buildTaskObservation.js +0 -117
  50. package/dist/runtime/application/code-execution/AuthoringSandboxEntry.js +0 -46
  51. package/dist/runtime/application/code-execution/BrowserCodeExecutor.js +0 -35
  52. package/dist/runtime/application/code-execution/BrowserCodeWorker.js +0 -17
  53. package/dist/runtime/application/code-execution/RemoteAuthoringDocument.js +0 -72
  54. package/dist/runtime/application/createSession.js +0 -66
  55. package/dist/runtime/application/createWorldAuthoringContext.js +0 -400
  56. package/dist/runtime/application/generation/GenerationOrchestrator.js +0 -629
  57. package/dist/runtime/application/generation/GenerationRuntime.js +0 -214
  58. package/dist/runtime/application/generation/PromptHybridWorldOrchestrator.js +0 -285
  59. package/dist/runtime/application/native-scene/CodeProject.js +0 -119
  60. package/dist/runtime/application/native-scene/CodeProjectModules.js +0 -128
  61. package/dist/runtime/application/native-scene/NativeEnvironmentGeometry.js +0 -62
  62. package/dist/runtime/application/native-scene/NativeOverlayCheckpoint.js +0 -127
  63. package/dist/runtime/application/native-scene/NativeRenderDiscovery.js +0 -51
  64. package/dist/runtime/application/native-scene/NativeSceneHost.js +0 -164
  65. package/dist/runtime/application/native-scene/NativeSceneOverlay.js +0 -116
  66. package/dist/runtime/application/native-scene/NativeThreeModule.js +0 -16
  67. package/dist/runtime/application/object-forge/SceneObjectForge.js +0 -232
  68. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetBuilder.js +0 -54
  69. package/dist/runtime/application/programmatic-assets/ProgrammaticAssetContract.js +0 -22
  70. package/dist/runtime/application/programmatic-assets/ThreeCodeAsset.js +0 -40
  71. package/dist/runtime/application/scene/CapabilityResolver.js +0 -79
  72. package/dist/runtime/application/scene/RequestWindow.js +0 -54
  73. package/dist/runtime/application/scene/SceneAgentTools.js +0 -21
  74. package/dist/runtime/application/scene/SceneContracts.js +0 -45
  75. package/dist/runtime/application/scene/SceneEditService.js +0 -144
  76. package/dist/runtime/application/scene/SceneFacade.js +0 -267
  77. package/dist/runtime/application/scene/SceneInteractionAdapters.js +0 -40
  78. package/dist/runtime/application/scene/SceneJobController.js +0 -229
  79. package/dist/runtime/application/scene/ScenePackage.js +0 -162
  80. package/dist/runtime/application/scene/ScenePersistence.js +0 -50
  81. package/dist/runtime/application/scene/SceneProject.js +0 -95
  82. package/dist/runtime/application/scene/SceneSkillNames.js +0 -5
  83. package/dist/runtime/application/scene/StarterScene.js +0 -56
  84. package/dist/runtime/application/scene/WorldArchive.js +0 -87
  85. package/dist/runtime/application/scene/WorldDirectory.js +0 -20
  86. package/dist/runtime/application/scene/WorldDocument.js +0 -74
  87. package/dist/runtime/application/scene/WorldIO.js +0 -103
  88. package/dist/runtime/application/scene/WorldStorage.js +0 -137
  89. package/dist/runtime/application/skills/SkillRegistry.js +0 -163
  90. package/dist/runtime/application/skills/packs/acceptanceSkills.js +0 -32
  91. package/dist/runtime/application/skills/packs/affordanceSkills.js +0 -36
  92. package/dist/runtime/application/skills/packs/assetSkills.js +0 -46
  93. package/dist/runtime/application/skills/packs/authoringSkills.js +0 -16
  94. package/dist/runtime/application/skills/packs/batchSkills.js +0 -22
  95. package/dist/runtime/application/skills/packs/codeSkills.js +0 -106
  96. package/dist/runtime/application/skills/packs/generationSkills.js +0 -45
  97. package/dist/runtime/application/skills/packs/interactionSkills.js +0 -46
  98. package/dist/runtime/application/skills/packs/recoverySkills.js +0 -80
  99. package/dist/runtime/application/skills/packs/sceneSkills.js +0 -24
  100. package/dist/runtime/application/skills/packs/spatialSkills.js +0 -35
  101. package/dist/runtime/application/skills/packs/verificationSkills.js +0 -14
  102. package/dist/runtime/application/skills/packs/worldSkills.js +0 -45
  103. package/dist/runtime/application/skills/registerCoreSkills.js +0 -31
  104. package/dist/runtime/application/skills/skillPrimitives.js +0 -4
  105. package/dist/runtime/application/tasks/CabinetCupTask.js +0 -76
  106. package/dist/runtime/application/tasks.jsonl +0 -67
  107. package/dist/runtime/application/world-authoring/AuthoringAssetProducer.js +0 -42
  108. package/dist/runtime/application/world-authoring/AuthoringDiff.js +0 -149
  109. package/dist/runtime/application/world-authoring/AuthoringDocument.js +0 -825
  110. package/dist/runtime/application/world-authoring/AuthoringExecutionHost.js +0 -109
  111. package/dist/runtime/application/world-authoring/AuthoringIdentity.js +0 -17
  112. package/dist/runtime/application/world-authoring/AuthoringModelResolver.js +0 -29
  113. package/dist/runtime/application/world-authoring/AuthoringPatch.js +0 -118
  114. package/dist/runtime/application/world-authoring/AuthoringPromotionController.js +0 -334
  115. package/dist/runtime/application/world-authoring/AuthoringPromotionSource.js +0 -126
  116. package/dist/runtime/application/world-authoring/AuthoringRevisionHistory.js +0 -144
  117. package/dist/runtime/application/world-authoring/HeadlessImageExport.js +0 -174
  118. package/dist/runtime/application/world-authoring/ModelRef.js +0 -62
  119. package/dist/runtime/apps/mcp-server/AUTHORING.md +0 -71
  120. package/dist/runtime/apps/mcp-server/AuthoringSandboxEntry.js +0 -1
  121. package/dist/runtime/apps/mcp-server/AuthoringSandboxWorker.mjs +0 -30
  122. package/dist/runtime/apps/mcp-server/BuildEnvironment.js +0 -17
  123. package/dist/runtime/apps/mcp-server/CodeExecutor.js +0 -71
  124. package/dist/runtime/apps/mcp-server/DEPLOYMENT-PC2.md +0 -42
  125. package/dist/runtime/apps/mcp-server/DockerBuildRunner.js +0 -66
  126. package/dist/runtime/apps/mcp-server/FileAssetRepository.js +0 -159
  127. package/dist/runtime/apps/mcp-server/HeadlessAssetIO.js +0 -8
  128. package/dist/runtime/apps/mcp-server/HeadlessGLTFLoader.js +0 -47
  129. package/dist/runtime/apps/mcp-server/HeadlessWorldHost.js +0 -132
  130. package/dist/runtime/apps/mcp-server/IsolatedAuthoringExecutor.js +0 -6
  131. package/dist/runtime/apps/mcp-server/PROGRAMMATIC-ASSETS.md +0 -116
  132. package/dist/runtime/apps/mcp-server/ProgrammaticAssets.js +0 -60
  133. package/dist/runtime/apps/mcp-server/README.md +0 -150
  134. package/dist/runtime/apps/mcp-server/RemoteAuthoringDocument.js +0 -1
  135. package/dist/runtime/apps/mcp-server/SandboxBundle.js +0 -13
  136. package/dist/runtime/apps/mcp-server/SessionManager.js +0 -80
  137. package/dist/runtime/apps/mcp-server/StudioBridgeHttp.js +0 -58
  138. package/dist/runtime/apps/mcp-server/StudioLiveBridge.js +0 -190
  139. package/dist/runtime/apps/mcp-server/TrustedAuthoringWorker.mjs +0 -16
  140. package/dist/runtime/apps/mcp-server/VALIDATION.md +0 -45
  141. package/dist/runtime/apps/mcp-server/acceptance-evidence.json +0 -332
  142. package/dist/runtime/apps/mcp-server/errorDiagnostics.js +0 -32
  143. package/dist/runtime/apps/mcp-server/examples/code-house.js +0 -24
  144. package/dist/runtime/apps/mcp-server/examples/procedural-assets.js +0 -37
  145. package/dist/runtime/apps/mcp-server/main.mjs +0 -56
  146. package/dist/runtime/apps/mcp-server/registerTools.js +0 -215
  147. package/dist/runtime/apps/mcp-server/sandbox/run.mjs +0 -23
  148. package/dist/runtime/apps/mcp-server/security.js +0 -21
  149. package/dist/runtime/apps/mcp-server/tasks.jsonl +0 -9
  150. package/dist/runtime/apps/server/CapabilityAdapterRegistry.js +0 -157
  151. package/dist/runtime/apps/server/README.md +0 -7
  152. package/dist/runtime/apps/server/WorldDiskStorage.js +0 -51
  153. package/dist/runtime/apps/server/openai-compatible-agent-gateway.mjs +0 -278
  154. package/dist/runtime/apps/server/tasks.jsonl +0 -10
  155. package/dist/runtime/foundation/EventBus.js +0 -18
  156. package/dist/runtime/foundation/JsonGateway.js +0 -47
  157. package/dist/runtime/foundation/PolicyEngine.js +0 -21
  158. package/dist/runtime/foundation/README.md +0 -7
  159. package/dist/runtime/foundation/TraceRecorder.js +0 -76
  160. package/dist/runtime/foundation/errors.js +0 -8
  161. package/dist/runtime/foundation/simulation/SimulationProfile.js +0 -143
  162. package/dist/runtime/foundation/version.js +0 -2
  163. package/dist/runtime/modules/agent/README.md +0 -11
  164. package/dist/runtime/modules/agent/ToolCallingAgent.js +0 -19
  165. package/dist/runtime/modules/agent/bootstrapWorld.js +0 -10
  166. package/dist/runtime/modules/agent/buildRecoveryProposals.js +0 -533
  167. package/dist/runtime/modules/agent/execution/AgentExecutionRules.js +0 -127
  168. package/dist/runtime/modules/agent/execution/AgentRunResults.js +0 -55
  169. package/dist/runtime/modules/agent/execution/AgentRunSession.js +0 -390
  170. package/dist/runtime/modules/agent/execution/AgentToolInvoker.js +0 -39
  171. package/dist/runtime/modules/agent/gateway/HttpLLMGateway.js +0 -19
  172. package/dist/runtime/modules/agent/prompt/index.js +0 -46
  173. package/dist/runtime/modules/agent/tasks.jsonl +0 -94
  174. package/dist/runtime/modules/artifact/ArtifactContentGate.js +0 -144
  175. package/dist/runtime/modules/artifact/ArtifactDescriptor.js +0 -280
  176. package/dist/runtime/modules/artifact/ArtifactImporter.js +0 -185
  177. package/dist/runtime/modules/artifact/ArtifactModule.js +0 -111
  178. package/dist/runtime/modules/artifact/ArtifactRegistry.js +0 -197
  179. package/dist/runtime/modules/artifact/IncrementalSha256.js +0 -129
  180. package/dist/runtime/modules/artifact/MemoryArtifactByteStore.js +0 -115
  181. package/dist/runtime/modules/artifact/README.md +0 -7
  182. package/dist/runtime/modules/artifact/storage/IndexedDbArtifactStore.js +0 -67
  183. package/dist/runtime/modules/artifact/tasks.jsonl +0 -31
  184. package/dist/runtime/modules/asset/AssetModule.js +0 -399
  185. package/dist/runtime/modules/asset/README.md +0 -54
  186. package/dist/runtime/modules/asset/loading/AssetLoader.js +0 -157
  187. package/dist/runtime/modules/asset/loading/GltfAssetLoader.js +0 -61
  188. package/dist/runtime/modules/asset/loading/builtins/BuiltinAssets.js +0 -95
  189. package/dist/runtime/modules/asset/loading/builtins/HouseDoor.js +0 -33
  190. package/dist/runtime/modules/asset/loading/builtins/IndustrialCabinet.js +0 -103
  191. package/dist/runtime/modules/asset/model/AssetInputContracts.js +0 -95
  192. package/dist/runtime/modules/asset/model/AssetRef.js +0 -12
  193. package/dist/runtime/modules/asset/model/MechanicalAssetDraft.js +0 -172
  194. package/dist/runtime/modules/asset/model/admission.js +0 -117
  195. package/dist/runtime/modules/asset/model/errors.js +0 -6
  196. package/dist/runtime/modules/asset/model/parts.js +0 -27
  197. package/dist/runtime/modules/asset/model/resourceBudget.js +0 -10
  198. package/dist/runtime/modules/asset/model/schema.js +0 -150
  199. package/dist/runtime/modules/asset/persistence/AssetManifestStore.js +0 -78
  200. package/dist/runtime/modules/asset/persistence/CompiledAssetStore.js +0 -84
  201. package/dist/runtime/modules/asset/persistence/LocalAssetLibrary.js +0 -86
  202. package/dist/runtime/modules/asset/persistence/LocalAssetLibraryStore.js +0 -81
  203. package/dist/runtime/modules/asset/production/AssetProductionPipeline.js +0 -272
  204. package/dist/runtime/modules/asset/production/AssetRecipe.js +0 -32
  205. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenAdapter.js +0 -45
  206. package/dist/runtime/modules/asset/production/adapters/EmbodiedGenBundleAdapter.js +0 -590
  207. package/dist/runtime/modules/asset/production/compiler/AssetCompiler.js +0 -173
  208. package/dist/runtime/modules/asset/production/compiler/evidence/AnimationMotionEvidence.js +0 -124
  209. package/dist/runtime/modules/asset/production/compiler/evidence/StaticPanelEvidence.js +0 -56
  210. package/dist/runtime/modules/asset/production/compiler/gltfIO.js +0 -6
  211. package/dist/runtime/modules/asset/production/compiler/partGeometry.js +0 -74
  212. package/dist/runtime/modules/asset/production/compiler/passes/ArticulatedCollisionPass.js +0 -63
  213. package/dist/runtime/modules/asset/production/compiler/passes/ArticulationCandidatePass.js +0 -48
  214. package/dist/runtime/modules/asset/production/compiler/passes/AuthoringIntentPass.js +0 -16
  215. package/dist/runtime/modules/asset/production/compiler/passes/ColliderFallbackPass.js +0 -30
  216. package/dist/runtime/modules/asset/production/compiler/passes/CompileQualityPass.js +0 -75
  217. package/dist/runtime/modules/asset/production/compiler/passes/ExplicitDefinitionPass.js +0 -20
  218. package/dist/runtime/modules/asset/production/compiler/passes/GLTFInspectPass.js +0 -34
  219. package/dist/runtime/modules/asset/production/compiler/passes/GeometryPass.js +0 -32
  220. package/dist/runtime/modules/asset/production/compiler/passes/JointFramePass.js +0 -116
  221. package/dist/runtime/modules/asset/production/compiler/passes/KinematicEvidencePass.js +0 -84
  222. package/dist/runtime/modules/asset/production/compiler/passes/ManifestPass.js +0 -63
  223. package/dist/runtime/modules/asset/production/compiler/passes/NormalizeTransformPass.js +0 -16
  224. package/dist/runtime/modules/asset/production/compiler/passes/OptimizeGLBPass.js +0 -23
  225. package/dist/runtime/modules/asset/production/compiler/passes/PartColliderPass.js +0 -50
  226. package/dist/runtime/modules/asset/production/compiler/passes/PartGeometryEnrichmentPass.js +0 -60
  227. package/dist/runtime/modules/asset/production/compiler/passes/PartProposalPass.js +0 -93
  228. package/dist/runtime/modules/asset/production/compiler/passes/RemoteEnrichmentPass.js +0 -32
  229. package/dist/runtime/modules/asset/production/compiler/passes/ResourceBudgetPass.js +0 -55
  230. package/dist/runtime/modules/asset/production/compiler/passes/SegmentMaterializePass.js +0 -203
  231. package/dist/runtime/modules/asset/production/compiler/passes/SegmentationEvidencePass.js +0 -43
  232. package/dist/runtime/modules/asset/production/compiler/passes/SemanticHeuristicPass.js +0 -33
  233. package/dist/runtime/modules/asset/production/compiler/passes/StructurePass.js +0 -60
  234. package/dist/runtime/modules/asset/production/compiler/providers/HttpCompilerProvider.js +0 -23
  235. package/dist/runtime/modules/asset/production/verification/KinematicHypothesisScreen.js +0 -198
  236. package/dist/runtime/modules/asset/registry/AssetCatalog.js +0 -72
  237. package/dist/runtime/modules/asset/registry/AssetRegistry.js +0 -51
  238. package/dist/runtime/modules/asset/registry/manifests/index.js +0 -173
  239. package/dist/runtime/modules/asset/tasks.jsonl +0 -87
  240. package/dist/runtime/modules/generation/README.md +0 -9
  241. package/dist/runtime/modules/generation/connector/ConnectorArtifactClient.js +0 -45
  242. package/dist/runtime/modules/generation/connector/ConnectorCapabilityAdapter.js +0 -169
  243. package/dist/runtime/modules/generation/connector/ConnectorClient.js +0 -192
  244. package/dist/runtime/modules/generation/connector/ConnectorJobClient.js +0 -167
  245. package/dist/runtime/modules/generation/connector/ConnectorJobEventClient.js +0 -179
  246. package/dist/runtime/modules/generation/connector/ConnectorSession.js +0 -202
  247. package/dist/runtime/modules/generation/jobs/GenerationJobProjection.js +0 -239
  248. package/dist/runtime/modules/generation/jobs/GenerationJobReconciler.js +0 -99
  249. package/dist/runtime/modules/generation/jobs/GenerationJobStore.js +0 -91
  250. package/dist/runtime/modules/generation/jobs/GenerationJobTransportOverlay.js +0 -50
  251. package/dist/runtime/modules/generation/providers/ProviderRegistry.js +0 -304
  252. package/dist/runtime/modules/generation/tasks.jsonl +0 -35
  253. package/dist/runtime/modules/navigation/NavigationBackend.js +0 -17
  254. package/dist/runtime/modules/navigation/RecastNavigationBackend.js +0 -245
  255. package/dist/runtime/modules/physics/JoltPhysicsBackend.js +0 -850
  256. package/dist/runtime/modules/physics/PhysicsApiSurface.js +0 -651
  257. package/dist/runtime/modules/physics/PhysicsBackend.js +0 -88
  258. package/dist/runtime/modules/physics/RapierPhysicsBackend.js +0 -410
  259. package/dist/runtime/modules/rendering/README.md +0 -7
  260. package/dist/runtime/modules/rendering/RendererProbe.js +0 -153
  261. package/dist/runtime/modules/rendering/WebGpuPostFxPipeline.js +0 -140
  262. package/dist/runtime/modules/rendering/createRenderer.js +0 -76
  263. package/dist/runtime/modules/rendering/disposeObject3D.js +0 -34
  264. package/dist/runtime/modules/rendering/loadGaussianSplatVisual.js +0 -74
  265. package/dist/runtime/modules/rendering/style/StylePack.js +0 -34
  266. package/dist/runtime/modules/rendering/style/StyleSystem.js +0 -173
  267. package/dist/runtime/modules/rendering/tasks.jsonl +0 -7
  268. package/dist/runtime/modules/world/README.md +0 -13
  269. package/dist/runtime/modules/world/build/WorldBuilder.js +0 -170
  270. package/dist/runtime/modules/world/compiler/PipelineEngine.js +0 -32
  271. package/dist/runtime/modules/world/compiler/WorldAdmission.js +0 -43
  272. package/dist/runtime/modules/world/compiler/WorldBehaviorCompiler.js +0 -68
  273. package/dist/runtime/modules/world/compiler/WorldCompilation.js +0 -157
  274. package/dist/runtime/modules/world/compiler/WorldComposer.js +0 -201
  275. package/dist/runtime/modules/world/compiler/WorldPhysicsAdmission.js +0 -76
  276. package/dist/runtime/modules/world/compiler/WorldRecompiler.js +0 -356
  277. package/dist/runtime/modules/world/compiler/WorldRetry.js +0 -75
  278. package/dist/runtime/modules/world/compiler/createWorldPipeline.js +0 -379
  279. package/dist/runtime/modules/world/content/blankWorld.js +0 -35
  280. package/dist/runtime/modules/world/content/environments.js +0 -84
  281. package/dist/runtime/modules/world/content/grandUrbanBlock.js +0 -189
  282. package/dist/runtime/modules/world/content/magic-cabin/README.md +0 -28
  283. package/dist/runtime/modules/world/content/magic-cabin/affordances.js +0 -64
  284. package/dist/runtime/modules/world/content/magic-cabin/cabinContents.js +0 -7078
  285. package/dist/runtime/modules/world/content/magic-cabin/lighting.js +0 -26
  286. package/dist/runtime/modules/world/content/magic-cabin/materials.js +0 -20
  287. package/dist/runtime/modules/world/content/magicCabin.js +0 -190
  288. package/dist/runtime/modules/world/content/monumentHall.js +0 -154
  289. package/dist/runtime/modules/world/content/ruinedCourtyard.js +0 -196
  290. package/dist/runtime/modules/world/content/suzhouGarden/README.md +0 -141
  291. package/dist/runtime/modules/world/content/suzhouGarden/index.js +0 -137
  292. package/dist/runtime/modules/world/content/suzhouGarden/src/arch.js +0 -491
  293. package/dist/runtime/modules/world/content/suzhouGarden/src/buildings.js +0 -670
  294. package/dist/runtime/modules/world/content/suzhouGarden/src/core.js +0 -578
  295. package/dist/runtime/modules/world/content/suzhouGarden/src/lod.js +0 -127
  296. package/dist/runtime/modules/world/content/suzhouGarden/src/main.js +0 -642
  297. package/dist/runtime/modules/world/content/suzhouGarden/src/nature.js +0 -650
  298. package/dist/runtime/modules/world/content/suzhouGarden/src/rockery.js +0 -280
  299. package/dist/runtime/modules/world/content/suzhouGarden/src/sky.js +0 -242
  300. package/dist/runtime/modules/world/content/suzhouGarden/src/water.js +0 -215
  301. package/dist/runtime/modules/world/content/woodlandWorkshop.js +0 -192
  302. package/dist/runtime/modules/world/content/yuanmingyuan/README.md +0 -36
  303. package/dist/runtime/modules/world/content/yuanmingyuan/arch.js +0 -351
  304. package/dist/runtime/modules/world/content/yuanmingyuan/buildings.js +0 -490
  305. package/dist/runtime/modules/world/content/yuanmingyuan/core.js +0 -505
  306. package/dist/runtime/modules/world/content/yuanmingyuan/index.js +0 -101
  307. package/dist/runtime/modules/world/content/yuanmingyuan/nature.js +0 -435
  308. package/dist/runtime/modules/world/content/yuanmingyuan/sky.js +0 -169
  309. package/dist/runtime/modules/world/content/yuanmingyuan/water.js +0 -245
  310. package/dist/runtime/modules/world/errors.js +0 -9
  311. package/dist/runtime/modules/world/generated/GeneratedWorldCoordinates.js +0 -50
  312. package/dist/runtime/modules/world/generated/GeneratedWorldLoader.js +0 -297
  313. package/dist/runtime/modules/world/runtime/CommandHistory.js +0 -80
  314. package/dist/runtime/modules/world/runtime/ObjectStore.js +0 -31
  315. package/dist/runtime/modules/world/runtime/ObjectTransform.js +0 -62
  316. package/dist/runtime/modules/world/runtime/ObservedEntity.js +0 -37
  317. package/dist/runtime/modules/world/runtime/ProjectCapabilities.js +0 -207
  318. package/dist/runtime/modules/world/runtime/SceneSerializer.js +0 -246
  319. package/dist/runtime/modules/world/runtime/WorldAuthority.js +0 -41
  320. package/dist/runtime/modules/world/runtime/WorldCollisionSignature.js +0 -14
  321. package/dist/runtime/modules/world/runtime/WorldCommands.js +0 -502
  322. package/dist/runtime/modules/world/runtime/WorldObservation.js +0 -71
  323. package/dist/runtime/modules/world/runtime/WorldQueries.js +0 -340
  324. package/dist/runtime/modules/world/runtime/WorldRecovery.js +0 -78
  325. package/dist/runtime/modules/world/runtime/WorldRuntime.js +0 -649
  326. package/dist/runtime/modules/world/runtime/affordance/ObjectAffordances.js +0 -107
  327. package/dist/runtime/modules/world/runtime/affordance/WorldAffordances.js +0 -130
  328. package/dist/runtime/modules/world/runtime/behavior/BehaviorCompiler.js +0 -79
  329. package/dist/runtime/modules/world/runtime/behavior/ProjectStateMachine.js +0 -195
  330. package/dist/runtime/modules/world/runtime/behavior/RuleGraph.js +0 -70
  331. package/dist/runtime/modules/world/runtime/behavior/RuleRuntime.js +0 -115
  332. package/dist/runtime/modules/world/runtime/graph/SceneGraph.js +0 -216
  333. package/dist/runtime/modules/world/runtime/interaction/ArticulationRuntime.js +0 -214
  334. package/dist/runtime/modules/world/runtime/interaction/CarryCapability.js +0 -65
  335. package/dist/runtime/modules/world/runtime/interaction/CarryRuntime.js +0 -222
  336. package/dist/runtime/modules/world/runtime/interaction/InteractionApproach.js +0 -130
  337. package/dist/runtime/modules/world/runtime/interaction/InteractionContract.js +0 -57
  338. package/dist/runtime/modules/world/runtime/interaction/RecoveryRuntime.js +0 -123
  339. package/dist/runtime/modules/world/runtime/interaction/SettleRuntime.js +0 -120
  340. package/dist/runtime/modules/world/runtime/semantic/SemanticWorldView.js +0 -102
  341. package/dist/runtime/modules/world/runtime/simulation/SimulationClock.js +0 -89
  342. package/dist/runtime/modules/world/runtime/simulation/SimulationSession.js +0 -99
  343. package/dist/runtime/modules/world/runtime/simulation/ThermalSystem.js +0 -269
  344. package/dist/runtime/modules/world/runtime/spatial/SpatialSnapshot.js +0 -56
  345. package/dist/runtime/modules/world/runtime/spatial/ThreeBvhRuntime.js +0 -36
  346. package/dist/runtime/modules/world/runtime/systems/InteractionSystem.js +0 -728
  347. package/dist/runtime/modules/world/runtime/systems/LocomotionSystem.js +0 -269
  348. package/dist/runtime/modules/world/runtime/systems/NavigationSystem.js +0 -469
  349. package/dist/runtime/modules/world/runtime/systems/PhysicsSystem.js +0 -1657
  350. package/dist/runtime/modules/world/runtime/systems/RenderingSystem.js +0 -457
  351. package/dist/runtime/modules/world/runtime/systems/SpatialSystem.js +0 -284
  352. package/dist/runtime/modules/world/spec/WorldIR.js +0 -165
  353. package/dist/runtime/modules/world/spec/WorldIRToolSchema.js +0 -86
  354. package/dist/runtime/modules/world/spec/WorldPlannerProposal.js +0 -51
  355. package/dist/runtime/modules/world/spec/WorldRevision.js +0 -231
  356. package/dist/runtime/modules/world/spec/WorldSpec.js +0 -86
  357. package/dist/runtime/modules/world/tasks.jsonl +0 -530
  358. package/dist/runtime/modules/world/verification/ArticulationVerifier.js +0 -254
  359. package/dist/runtime/modules/world/verification/Finding.js +0 -105
  360. package/dist/runtime/modules/world/verification/InteractionEvidence.js +0 -69
  361. package/dist/runtime/modules/world/verification/RepairEngine.js +0 -49
  362. package/dist/runtime/modules/world/verification/WorldAcceptance.js +0 -158
  363. package/dist/runtime/modules/world/verification/WorldValidator.js +0 -65
  364. package/dist/runtime/package-lock.json +0 -6245
  365. package/dist/runtime/package.json +0 -91
  366. package/dist/runtime/public/assets/cabinet.glb +0 -0
  367. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_diff_1k.jpg +0 -0
  368. package/dist/runtime/public/assets/grand-urban-block/clean_asphalt_nor_gl_1k.jpg +0 -0
  369. package/dist/runtime/public/assets/grand-urban-block/concrete_pavement_diff_1k.jpg +0 -0
  370. package/dist/runtime/public/assets/grand-urban-block/urban_street_01_1k.hdr +0 -0
  371. package/dist/runtime/public/assets/monument-hall/marble_diff_1k.jpg +0 -0
  372. package/dist/runtime/public/assets/monument-hall/marble_nor_gl_1k.jpg +0 -0
  373. package/dist/runtime/public/assets/monument-hall/marble_rough_1k.jpg +0 -0
  374. package/dist/runtime/public/assets/monument-hall/solitude_interior_1k.hdr +0 -0
  375. package/dist/runtime/public/assets/ruined-courtyard/courtyard_1k.hdr +0 -0
  376. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_diff_1k.jpg +0 -0
  377. package/dist/runtime/public/assets/ruined-courtyard/mossy_cobblestone_nor_gl_1k.jpg +0 -0
  378. package/dist/runtime/public/assets/ruined-courtyard/mossy_sandstone_diff_1k.jpg +0 -0
  379. package/dist/schema-Dudvovhu.js +0 -364
  380. package/dist/schema-Dudvovhu.js.map +0 -1
  381. package/dist/suzhouGarden-BCx_JeV5.js +0 -6159
  382. package/dist/suzhouGarden-BCx_JeV5.js.map +0 -1
  383. package/dist/woodlandWorkshop-BGNWPNdK.js +0 -484
  384. package/dist/woodlandWorkshop-BGNWPNdK.js.map +0 -1
  385. package/dist/yuanmingyuan-DAIb1msO.js +0 -4962
  386. package/dist/yuanmingyuan-DAIb1msO.js.map +0 -1
@@ -1,109 +0,0 @@
1
- import * as THREE from 'three';
2
- import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
3
- import { markAuthoringModelRef } from './ModelRef.js';
4
-
5
- function createThreeNamespace(GLTFLoaderClass) {
6
- class AuthoringGLTFLoader extends GLTFLoaderClass {
7
- async loadAsync(url, onProgress) {
8
- const gltf = await super.loadAsync(url, onProgress);
9
- if (gltf?.scene) markAuthoringModelRef(gltf.scene, { uri:String(url) });
10
- return gltf;
11
- }
12
-
13
- load(url, onLoad, onProgress, onError) {
14
- return super.load(url, (gltf) => {
15
- if (gltf?.scene) markAuthoringModelRef(gltf.scene, { uri:String(url) });
16
- onLoad?.(gltf);
17
- }, onProgress, onError);
18
- }
19
- }
20
-
21
- return Object.freeze({
22
- ...THREE,
23
- GLTFLoader:AuthoringGLTFLoader
24
- });
25
- }
26
-
27
- export function createAuthoringExecutionHost({
28
- gltfLoaderClass = GLTFLoader,
29
- requestFrame = globalThis.requestAnimationFrame?.bind(globalThis),
30
- cancelFrame = globalThis.cancelAnimationFrame?.bind(globalThis),
31
- setTimeoutImpl = globalThis.setTimeout?.bind(globalThis),
32
- clearTimeoutImpl = globalThis.clearTimeout?.bind(globalThis),
33
- setIntervalImpl = globalThis.setInterval?.bind(globalThis),
34
- clearIntervalImpl = globalThis.clearInterval?.bind(globalThis)
35
- } = {}) {
36
- const frames = new Set();
37
- const timeouts = new Set();
38
- const intervals = new Set();
39
- const authoringThree = createThreeNamespace(gltfLoaderClass);
40
-
41
- const requestAnimationFrame = (callback) => {
42
- if (typeof requestFrame !== 'function') throw new TypeError('requestAnimationFrame is unavailable');
43
- let id = null;
44
- id = requestFrame((time) => {
45
- frames.delete(id);
46
- callback(time);
47
- });
48
- frames.add(id);
49
- return id;
50
- };
51
-
52
- const cancelAnimationFrame = (id) => {
53
- frames.delete(id);
54
- cancelFrame?.(id);
55
- };
56
-
57
- const setTimeout = (callback, delay = 0, ...args) => {
58
- if (typeof setTimeoutImpl !== 'function') throw new TypeError('setTimeout is unavailable');
59
- let id = null;
60
- id = setTimeoutImpl((...values) => {
61
- timeouts.delete(id);
62
- callback(...values);
63
- }, delay, ...args);
64
- timeouts.add(id);
65
- return id;
66
- };
67
-
68
- const clearTimeout = (id) => {
69
- timeouts.delete(id);
70
- clearTimeoutImpl?.(id);
71
- };
72
-
73
- const setInterval = (callback, delay = 0, ...args) => {
74
- if (typeof setIntervalImpl !== 'function') throw new TypeError('setInterval is unavailable');
75
- const id = setIntervalImpl(callback, delay, ...args);
76
- intervals.add(id);
77
- return id;
78
- };
79
-
80
- const clearInterval = (id) => {
81
- intervals.delete(id);
82
- clearIntervalImpl?.(id);
83
- };
84
-
85
- const clear = () => {
86
- for (const id of frames) cancelFrame?.(id);
87
- for (const id of timeouts) clearTimeoutImpl?.(id);
88
- for (const id of intervals) clearIntervalImpl?.(id);
89
- frames.clear();
90
- timeouts.clear();
91
- intervals.clear();
92
- };
93
-
94
- return {
95
- THREE:authoringThree,
96
- requestAnimationFrame,
97
- cancelAnimationFrame,
98
- setTimeout,
99
- clearTimeout,
100
- setInterval,
101
- clearInterval,
102
- clear,
103
- diagnostics:()=>({
104
- frames:frames.size,
105
- timeouts:timeouts.size,
106
- intervals:intervals.size
107
- })
108
- };
109
- }
@@ -1,17 +0,0 @@
1
- const objectIds = new WeakMap();
2
-
3
- export function getAuthoringObjectId(object) {
4
- if (!object?.isObject3D) return null;
5
- const sidecarId = objectIds.get(object);
6
- if (sidecarId) return sidecarId;
7
- const legacyId = object.userData?.authoringId;
8
- return typeof legacyId === 'string' && legacyId.trim() ? legacyId : null;
9
- }
10
-
11
- export function setAuthoringObjectId(object, id) {
12
- if (!object?.isObject3D) throw new TypeError('World Authoring identity target must be an Object3D');
13
- const value = String(id || '').trim();
14
- if (!value) throw new TypeError('World Authoring identity requires a non-empty id');
15
- objectIds.set(object, value);
16
- return value;
17
- }
@@ -1,29 +0,0 @@
1
- import { normalizeAuthoringModelRef } from './ModelRef.js';
2
-
3
- export function createAuthoringModelResolver({
4
- assetLoader = null,
5
- gltfLoader = null
6
- } = {}) {
7
- return async function resolveAuthoringModel(reference) {
8
- const normalized = normalizeAuthoringModelRef(reference);
9
- const source = normalized.source;
10
-
11
- if (source.type === 'url') {
12
- if (!gltfLoader || typeof gltfLoader.loadScene !== 'function') {
13
- throw new TypeError('World Authoring URL ModelRef resolution requires a GLTF scene loader');
14
- }
15
- return gltfLoader.loadScene(source.uri);
16
- }
17
-
18
- if (!assetLoader || typeof assetLoader.instantiate !== 'function') {
19
- throw new TypeError('World Authoring AssetRef resolution requires AssetLoader');
20
- }
21
-
22
- const assetId = source.assetRef.assetId;
23
- const result = await assetLoader.instantiate(assetId);
24
- if (!result?.object?.isObject3D) {
25
- throw new TypeError(`World Authoring AssetRef resolver returned no Object3D: ${assetId}`);
26
- }
27
- return result.object;
28
- };
29
- }
@@ -1,118 +0,0 @@
1
- import {
2
- exportAuthoringDocument,
3
- parseAuthoringDocument
4
- } from './AuthoringDocument.js';
5
-
6
- function clone(value) {
7
- return JSON.parse(JSON.stringify(value));
8
- }
9
-
10
- function mergeObject(base, patch) {
11
- if (!patch || typeof patch !== 'object' || Array.isArray(patch)) return clone(patch);
12
- const result = { ...(base || {}) };
13
- for (const [key, value] of Object.entries(patch)) {
14
- if (value === undefined) continue;
15
- if (
16
- value
17
- && typeof value === 'object'
18
- && !Array.isArray(value)
19
- && result[key]
20
- && typeof result[key] === 'object'
21
- && !Array.isArray(result[key])
22
- ) {
23
- result[key] = mergeObject(result[key], value);
24
- } else {
25
- result[key] = clone(value);
26
- }
27
- }
28
- return result;
29
- }
30
-
31
- function removeSubtree(state, id) {
32
- if (id === state.rootId) throw new TypeError('World Authoring patch cannot remove the root');
33
- const node = state.nodesById[id];
34
- if (!node) throw new TypeError(`World Authoring patch node not found: ${id}`);
35
-
36
- for (const childId of [...(state.childIdsById[id] || [])]) {
37
- removeSubtree(state, childId);
38
- }
39
-
40
- const parentId = state.parentIdById[id];
41
- if (parentId && state.childIdsById[parentId]) {
42
- state.childIdsById[parentId] = state.childIdsById[parentId].filter(childId => childId !== id);
43
- }
44
-
45
- delete state.nodesById[id];
46
- delete state.childIdsById[id];
47
- delete state.parentIdById[id];
48
- }
49
-
50
- function insertNode(state, node, parentId, index) {
51
- if (!state.nodesById[parentId]) {
52
- throw new TypeError(`World Authoring patch parent not found: ${parentId}`);
53
- }
54
- if (state.nodesById[parentId].components?.modelRef) {
55
- throw new TypeError('World Authoring patch cannot add authored children to ModelRef');
56
- }
57
- if (!node || typeof node.id !== 'string' || !node.id) {
58
- throw new TypeError('World Authoring patch added node requires an id');
59
- }
60
- if (state.nodesById[node.id]) {
61
- throw new TypeError(`World Authoring patch duplicate node id: ${node.id}`);
62
- }
63
-
64
- const { children = [], ...record } = clone(node);
65
- state.nodesById[node.id] = record;
66
- state.parentIdById[node.id] = parentId;
67
- state.childIdsById[node.id] = [];
68
-
69
- const siblings = state.childIdsById[parentId];
70
- const insertAt = Number.isInteger(index) ? Math.max(0, Math.min(index, siblings.length)) : siblings.length;
71
- siblings.splice(insertAt, 0, node.id);
72
-
73
- for (const child of children) {
74
- insertNode(state, child, node.id);
75
- }
76
- }
77
-
78
- function mergeResources(target, additions, label) {
79
- for (const [id, definition] of Object.entries(additions || {})) {
80
- if (target[id] && JSON.stringify(target[id]) !== JSON.stringify(definition)) {
81
- throw new TypeError(`World Authoring patch ${label} id conflict: ${id}`);
82
- }
83
- target[id] = clone(definition);
84
- }
85
- }
86
-
87
- export function patchAuthoringDocument(document, patch = {}) {
88
- const state = parseAuthoringDocument(document);
89
-
90
- mergeResources(state.geometries, patch.geometries, 'geometry');
91
- mergeResources(state.materials, patch.materials, 'material');
92
- mergeResources(state.textures, patch.textures, 'texture');
93
-
94
- for (const change of patch.update || []) {
95
- if (!change || typeof change.id !== 'string') {
96
- throw new TypeError('World Authoring patch update requires an id');
97
- }
98
- const node = state.nodesById[change.id];
99
- if (!node) throw new TypeError(`World Authoring patch node not found: ${change.id}`);
100
-
101
- const { id, ...updates } = change;
102
- state.nodesById[id] = mergeObject(node, updates);
103
- state.nodesById[id].id = id;
104
- }
105
-
106
- for (const id of patch.remove || []) {
107
- removeSubtree(state, id);
108
- }
109
-
110
- for (const addition of patch.add || []) {
111
- if (!addition || typeof addition.parentId !== 'string' || !addition.node) {
112
- throw new TypeError('World Authoring patch add requires parentId and node');
113
- }
114
- insertNode(state, addition.node, addition.parentId, addition.index);
115
- }
116
-
117
- return exportAuthoringDocument(state);
118
- }
@@ -1,334 +0,0 @@
1
- import { assetAdmission } from '../../modules/asset/model/admission.js';
2
- import { physicsManifestForUniformScale, uniformScaleValue } from '../../modules/world/runtime/ObjectTransform.js';
3
- import { capturePromotionSource, promotionError } from './AuthoringPromotionSource.js';
4
-
5
- const clone = value => structuredClone(value);
6
- const uid = prefix => `${prefix}_${globalThis.crypto.randomUUID()}`;
7
- const USAGES = ['static', 'movable', 'interactive'];
8
- const ACTIONS = ['pickup', 'open', 'close', 'read', 'write', 'toggle', 'turn_on', 'turn_off', 'push', 'pull'];
9
- const portableState = state => {
10
- const result = clone(state);
11
- delete result.heldBy;
12
- delete result.navigation;
13
- return result;
14
- };
15
-
16
- export class AuthoringPromotionController {
17
- constructor({ authoring, world, produceAsset, verify = null, verifyBehavior = null }) {
18
- if (!authoring?.export || !world?.mutate || !world?.commands) throw new TypeError('Promotion requires Authoring and WorldRuntime');
19
- Object.assign(this, { authoring, world, produceAsset, verify, verifyBehavior });
20
- this.documentId = uid('authoring');
21
- this.entries = new Map();
22
- this.busy = false;
23
- this.stops = [
24
- world.events.on('object.removed', () => this.reconcile()),
25
- world.events.on('scene.restored', () => { this.invalidateVerification(); this.reconcile(); }),
26
- world.events.on('environment.replaced', () => { this.invalidateVerification(); this.reconcile(); }),
27
- world.events.on('history.changed', () => this.reconcile()),
28
- world.events.on('object.transformed', ({ id } = {}) => {
29
- this.invalidateVerification(entry => entry.entityId === id);
30
- this.reconcile();
31
- })
32
- ];
33
- }
34
-
35
- invalidateVerification(predicate = null) {
36
- for (const entry of this.entries.values()) {
37
- if (entry.verification && (!predicate || predicate(entry))) entry.verification = null;
38
- }
39
- }
40
-
41
- exportState() {
42
- // Store only our instances, and keep their latest runtime pose/state for reopening.
43
- const entries = [...this.entries.values()].map(entry => {
44
- const saved = clone(entry);
45
- const record = this.linkedRecord(entry);
46
- if (record) saved.instance = {
47
- position:record.object.position.toArray(), quaternion:record.object.quaternion.toArray(),
48
- scale:record.physicsScale || 1,
49
- // Held ownership and running navigation cannot be transferred into a partial world file.
50
- initialState:portableState(record.state)
51
- };
52
- return saved;
53
- });
54
- return { version:1, documentId:this.documentId, entries };
55
- }
56
-
57
- validateState(state) {
58
- if (state == null) return;
59
- if (state.version !== 1 || typeof state.documentId !== 'string' || !Array.isArray(state.entries)) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '晋升记录格式无效');
60
- const nodes = new Set(), entities = new Set();
61
- for (const entry of state.entries) {
62
- if (!entry.nodeId || nodes.has(entry.nodeId) || !USAGES.includes(entry.usage) || !entry.assetId || !entry.sourceHash || !entry.contentHash) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '晋升记录缺少身份或存在重复节点');
63
- nodes.add(entry.nodeId);
64
- if (entry.entityId) {
65
- if (entities.has(entry.entityId) || !entry.linkId || !entry.instance) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '晋升实体记录无效');
66
- entities.add(entry.entityId);
67
- const transform = entry.instance;
68
- const finite = (value, size) => Array.isArray(value) && value.length === size && value.every(Number.isFinite);
69
- if (!finite(transform.position, 3) || !finite(transform.quaternion, 4) || Math.hypot(...transform.quaternion) < 1e-6) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '晋升实体变换无效');
70
- uniformScaleValue(transform.scale);
71
- const link = transform.initialState?.authoringPromotion;
72
- if (link?.documentId !== state.documentId || link?.nodeId !== entry.nodeId || link?.linkId !== entry.linkId) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '晋升实体来源关联无效');
73
- if ('heldBy' in transform.initialState || 'navigation' in transform.initialState) throw promotionError('AUTHORING_PROMOTION_STATE_INVALID', '创作存档不能恢复持有关系或运行中的导航');
74
- }
75
- }
76
- }
77
-
78
- loadState(state = null) {
79
- if (this.busy) throw promotionError('AUTHORING_PROMOTION_BUSY', '晋升操作尚未完成');
80
- this.validateState(state);
81
- this.documentId = state?.documentId || uid('authoring');
82
- this.entries = new Map((state?.entries || []).map(entry => [entry.nodeId, clone(entry)]));
83
- this.reconcile();
84
- }
85
-
86
- linkedRecord(entry) {
87
- if (!entry?.entityId || entry.worldId !== (this.world.environment?.id || null) || !this.world.store.has(entry.entityId)) return null;
88
- const record = this.world.store.get(entry.entityId);
89
- const link = record.state?.authoringPromotion;
90
- return record.assetId === entry.assetId && link?.documentId === this.documentId && link?.linkId === entry.linkId ? record : null;
91
- }
92
-
93
- reconcile() {
94
- // World undo/redo can restore an older installed revision. Adopt its provenance,
95
- // not the latest editor record, without issuing another World command.
96
- for (const [, record] of this.world.store.list()) {
97
- const link = record.state?.authoringPromotion;
98
- const entry = link && this.entries.get(link.nodeId);
99
- if (entry?.entityId === record.id && link.documentId === this.documentId
100
- && entry.worldId === (this.world.environment?.id || null) && link.contentHash) {
101
- if (entry.linkId !== link.linkId) entry.verification = null;
102
- Object.assign(entry, { assetId:record.assetId, linkId:link.linkId, sourceHash:link.sourceHash,
103
- contentHash:link.contentHash, usage:link.usage, revisionId:link.revisionId });
104
- }
105
- }
106
- this.authoring.setPromotedNodes([...this.entries.values()].filter(entry => this.linkedRecord(entry)).map(entry => entry.nodeId));
107
- }
108
-
109
- list() {
110
- this.reconcile();
111
- const document = this.authoring.export();
112
- const nodes = [];
113
- const visit = (node, depth = 0) => {
114
- if (node.id !== document.root.id) {
115
- const entry = this.entries.get(node.id);
116
- let source = null, reason = null;
117
- try { source = capturePromotionSource(this.authoring, node.id); } catch (error) { reason = error.message; }
118
- const linked = this.linkedRecord(entry);
119
- let status = entry ? (entry.entityId ? (linked ? 'promoted' : 'missing') : 'prepared') : 'draft';
120
- if (entry && source && source.sourceHash !== entry.sourceHash) status = linked ? 'outdated' : 'changed';
121
- const admission = entry && this.world.assetModule.hasAsset(entry.assetId) ? assetAdmission(this.world.assetModule.getManifest(entry.assetId)) : null;
122
- if (status === 'promoted' && admission?.status !== 'ready') status = 'editing';
123
- nodes.push({ nodeId:node.id, name:node.name || node.id, depth, status, reason, usage:entry?.usage || 'static',
124
- assetId:entry?.assetId || null, entityId:entry?.entityId || null,
125
- admission,
126
- verification:entry?.verification || null });
127
- }
128
- for (const child of node.children || []) visit(child, depth + 1);
129
- };
130
- visit(document.root, -1);
131
- return nodes;
132
- }
133
-
134
- async runExclusive(operation) {
135
- if (this.busy || this.fileBusy) throw promotionError('AUTHORING_PROMOTION_BUSY', '创作存档或晋升操作尚未完成');
136
- this.busy = true;
137
- try { return await operation(); }
138
- finally { this.busy = false; this.reconcile(); this.world.events.emit('authoring.promotion.changed', {}); }
139
- }
140
-
141
- assertSource(source, worldId) {
142
- if (worldId !== (this.world.environment?.id || null)
143
- || capturePromotionSource(this.authoring, source.nodeId).sourceHash !== source.sourceHash) {
144
- throw promotionError('AUTHORING_PROMOTION_STALE', '创作对象或当前世界已改变,请重新准备');
145
- }
146
- }
147
-
148
- checkSelection(source) {
149
- for (const entry of this.entries.values()) {
150
- if (entry.nodeId === source.nodeId || !entry.entityId) continue;
151
- const other = this.authoring.get(entry.nodeId);
152
- if (!other) continue;
153
- let node = source.object;
154
- while (node) {
155
- if (node === other) throw promotionError('AUTHORING_PROMOTION_OVERLAP', '该对象属于已晋升分组,请更新该分组');
156
- node = node.parent;
157
- }
158
- if (source.ids.includes(entry.nodeId)) throw promotionError('AUTHORING_PROMOTION_OVERLAP', '该分组包含已晋升对象,请先解除已有晋升关联');
159
- }
160
- }
161
-
162
- async prepare(nodeId, { usage = 'static' } = {}) {
163
- return this.runExclusive(async () => {
164
- const source = capturePromotionSource(this.authoring, nodeId);
165
- const worldId = this.world.environment?.id || null;
166
- const prepared = await this.prepareSource(source, usage);
167
- this.assertSource(source, worldId);
168
- // Preparing a changed source must not overwrite the currently installed version.
169
- const previous = this.entries.get(nodeId);
170
- if (previous?.entityId) this.entries.set(nodeId, { ...previous, pending:prepared });
171
- else this.entries.set(nodeId, prepared);
172
- return { status:'authoring-prepared', ...clone(prepared) };
173
- });
174
- }
175
-
176
- async prepareSource(source, usage) {
177
- if (!USAGES.includes(usage)) throw promotionError('AUTHORING_USAGE_INVALID', '未知的对象用途');
178
- this.checkSelection(source);
179
- const existing = this.entries.get(source.nodeId);
180
- const cached = existing?.pending || existing;
181
- let assetId;
182
- if (source.reference?.source?.type === 'asset') assetId = source.reference.source.assetRef.assetId;
183
- else if (cached?.contentHash === source.contentHash && cached.usage === usage) assetId = cached.assetId;
184
- else {
185
- if (!this.produceAsset) throw promotionError('AUTHORING_PRODUCTION_UNAVAILABLE', '创作资产生产尚未配置');
186
- const produced = await this.produceAsset(source, { usage });
187
- if (produced.status === 'asset-rejected') throw promotionError('AUTHORING_ASSET_REJECTED', `资产被拒绝:${produced.admission?.reasons?.join(', ') || '编译失败'}`);
188
- assetId = produced.assetId;
189
- }
190
- if (!this.world.assetModule.hasAsset(assetId)) throw promotionError('AUTHORING_ASSET_MISSING', '正式资产不存在,请重新准备');
191
- const manifest = this.world.assetModule.getManifest(assetId);
192
- const admission = assetAdmission(manifest);
193
- if (admission.status === 'rejected') throw promotionError('AUTHORING_ASSET_REJECTED', admission.reasons.join(', '));
194
- if (usage === 'static' && manifest.physics?.body !== 'fixed') throw promotionError('AUTHORING_USAGE_MISMATCH', '该资产不是静态物件,请选择匹配的用途');
195
- if (usage === 'movable' && (manifest.physics?.body !== 'dynamic' || !manifest.actions?.includes('pickup'))) throw promotionError('AUTHORING_USAGE_MISMATCH', '该资产没有动态刚体和拾取能力');
196
- if (usage === 'interactive' && !manifest.actions?.some(action => ACTIONS.includes(action))) throw promotionError('AUTHORING_USAGE_MISMATCH', '该资产尚未具备可执行交互,请先完善资产能力');
197
- physicsManifestForUniformScale(manifest, source.transform.scale);
198
- return { nodeId:source.nodeId, name:source.name, assetId, usage, sourceHash:source.sourceHash,
199
- contentHash:source.contentHash, revisionId:source.revisionId, transform:source.transform, admission };
200
- }
201
-
202
- async promote(nodeId, { usage = null, allowProvisional = false, update = false } = {}) {
203
- return this.runExclusive(async () => {
204
- const source = capturePromotionSource(this.authoring, nodeId);
205
- const worldId = this.world.environment?.id || null;
206
- const previous = this.entries.get(nodeId);
207
- const linked = this.linkedRecord(previous);
208
- if (linked && source.sourceHash === previous.sourceHash && (!usage || usage === previous.usage)) return {
209
- status:assetAdmission(this.world.assetModule.getManifest(previous.assetId)).status === 'ready' ? 'authoring-promoted' : 'authoring-provisional', reused:true, ...clone(previous)
210
- };
211
- if (previous?.entityId && !update) throw promotionError('AUTHORING_UPDATE_REQUIRED', '该对象已有晋升记录,请使用更新或恢复操作');
212
- if (previous?.entityId && previous.worldId !== worldId) throw promotionError('AUTHORING_WORLD_MISMATCH', '请在原目标世界中更新此对象');
213
- const prepared = await this.prepareSource(source, usage || previous?.usage || 'static');
214
- this.assertSource(source, worldId);
215
- if (prepared.admission.status !== 'ready' && !allowProvisional) throw promotionError('AUTHORING_ASSET_PROVISIONAL', `资产仅可用于编辑态:${prepared.admission.reasons.join(', ')}`);
216
- const entry = { ...prepared, worldId, entityId:previous?.entityId || uid('entity'),
217
- linkId:uid('promotion'), instance:{ ...prepared.transform } };
218
- entry.instance.initialState = { authoringPromotion:{ documentId:this.documentId, nodeId, linkId:entry.linkId,
219
- sourceHash:source.sourceHash, contentHash:source.contentHash, usage:entry.usage, revisionId:source.revisionId } };
220
- if (linked?.assetId === entry.assetId) entry.instance.initialState = {
221
- ...portableState(linked.state), ...entry.instance.initialState
222
- };
223
- const result = await this.install(entry, { previous, source, allowProvisional });
224
- this.entries.set(nodeId, entry);
225
- return result;
226
- });
227
- }
228
-
229
- async install(entry, { previous = null, source = null, allowProvisional = false } = {}) {
230
- const manifest = this.world.assetModule.getManifest(entry.assetId);
231
- if (!manifest) throw promotionError('AUTHORING_ASSET_MISSING', '恢复所需的资产不存在');
232
- const admission = assetAdmission(manifest);
233
- if (admission.status === 'rejected' || (admission.status !== 'ready' && !allowProvisional)) throw promotionError('AUTHORING_ASSET_NOT_READY', '资产当前未通过正式准入');
234
- const old = previous && this.linkedRecord(previous);
235
- if (this.world.store.has(entry.entityId) && !old) throw promotionError('AUTHORING_ENTITY_CONFLICT', '目标实体 ID 已被其他对象占用');
236
- if (old?.state?.heldBy) throw promotionError('AUTHORING_ENTITY_HELD', '请先放下正在持有的对象');
237
- return this.world.mutate('authoring:promote', async () => {
238
- if (entry.worldId !== (this.world.environment?.id || null)) throw promotionError('AUTHORING_WORLD_MISMATCH', '晋升的目标世界不匹配');
239
- if (source) this.assertSource(source, entry.worldId);
240
- const scaled = physicsManifestForUniformScale(manifest, entry.instance.scale);
241
- let pose = this.world.physics.checkManifestPose(scaled, entry.instance.position, {
242
- quaternion:entry.instance.quaternion, excludeIds:old ? [entry.entityId] : []
243
- });
244
- // A dynamic body authored flush with the ground is routinely reported
245
- // as blocked by the environment collider alone (touching counts as a
246
- // collision, and built-in objects spawn slightly above the floor).
247
- // Retry once with a small lift; physics settles the body onto the
248
- // ground. Static placements keep the strict check.
249
- let groundLift = 0;
250
- if (pose.checked && !pose.clear && entry.usage === 'movable'
251
- && pose.blockedBy?.length && pose.blockedBy.every(id => String(id).startsWith('environment:'))) {
252
- const lifted = [entry.instance.position[0], entry.instance.position[1] + 0.05, entry.instance.position[2]];
253
- const retry = this.world.physics.checkManifestPose(scaled, lifted, {
254
- quaternion:entry.instance.quaternion, excludeIds:old ? [entry.entityId] : []
255
- });
256
- if (retry.checked && retry.clear) { pose = retry; groundLift = 0.05; entry.instance.position = lifted; }
257
- }
258
- if (pose.checked && !pose.clear) {
259
- const error = promotionError('AUTHORING_PLACEMENT_BLOCKED', `放置位置发生碰撞:${pose.blockedBy?.join(', ')}`);
260
- error.details = { blockedBy:(pose.blockedBy || []).slice(0, 8).map(id => String(id).slice(0, 64)) };
261
- throw error;
262
- }
263
- if (!pose.checked && !allowProvisional) throw promotionError('AUTHORING_PLACEMENT_UNVERIFIED', '当前物理后端无法验证该位置');
264
- if (old) this.world.commands.remove(entry.entityId);
265
- const spawned = await this.world.commands.spawn(entry.assetId, { id:entry.entityId, ...entry.instance });
266
- if (spawned?.status === 'asset-rejected') throw promotionError('AUTHORING_ASSET_REJECTED', '资产在实例化时被拒绝');
267
- if (!this.world.store.has(entry.entityId)) throw promotionError('AUTHORING_SPAWN_FAILED', '世界没有创建目标实体');
268
- const physicsPosition = this.world.physics.getPosition(entry.entityId);
269
- if (!physicsPosition) throw promotionError('AUTHORING_PHYSICS_FAILED', '世界实体没有物理刚体');
270
- const navigation = this.world.navigation?.ensureCurrent
271
- ? await this.world.navigation.ensureCurrent() : { success:false, code:'NAVIGATION_UNAVAILABLE' };
272
- entry.verification = { physics:{ registered:true, placement:{ ...clone(pose), ...(groundLift ? { groundLift } : {}) } },
273
- navigation:clone(navigation), interaction:{ status:'not-exercised', actions:manifest.actions.filter(action => ACTIONS.includes(action)) },
274
- admission:clone(admission), checkedAt:new Date().toISOString() };
275
- if (this.verify) {
276
- const verification = await this.verify(entry, this.world);
277
- if (verification?.ok === false) throw promotionError('AUTHORING_VERIFICATION_FAILED', verification.reason || '世界行为验证失败');
278
- entry.verification.behavior = clone(verification);
279
- }
280
- if (source) this.assertSource(source, entry.worldId);
281
- return { status:admission.status === 'ready' ? 'authoring-promoted' : 'authoring-provisional', ...clone(entry) };
282
- }, { source:'authoring', nodeId:entry.nodeId, documentId:this.documentId });
283
- }
284
-
285
- async restore({ allowProvisional = false } = {}) {
286
- return this.runExclusive(async () => {
287
- const results = [];
288
- for (const entry of this.entries.values()) {
289
- if (!entry.entityId || this.linkedRecord(entry)) continue;
290
- try {
291
- const result = await this.install(entry, { allowProvisional });
292
- results.push({ nodeId:entry.nodeId, ...result });
293
- } catch (error) { results.push({ nodeId:entry.nodeId, status:'authoring-restore-failed', code:error.code, reason:error.message }); }
294
- }
295
- return { status:results.some(result => result.status === 'authoring-restore-failed') ? 'authoring-restore-failed' : 'authoring-restored', results };
296
- });
297
- }
298
-
299
- async detach(nodeId) {
300
- return this.runExclusive(async () => {
301
- // Detaching leaves the formal entity intact; it explicitly makes the draft independent again.
302
- const entry = this.entries.get(nodeId);
303
- this.entries.delete(nodeId);
304
- return { status:'authoring-detached', nodeId, entityId:entry?.entityId || null };
305
- });
306
- }
307
-
308
- async verifyEntity(nodeId, { exerciseInteraction = false } = {}) {
309
- return this.runExclusive(async () => {
310
- const entry = this.entries.get(nodeId);
311
- const record = this.linkedRecord(entry);
312
- if (!record) throw promotionError('AUTHORING_ENTITY_MISSING', '请先恢复或晋升该对象');
313
- const manifest = this.world.assetModule.getManifest(entry.assetId);
314
- const actions = manifest.actions.filter(action => ACTIONS.includes(action));
315
- let interaction = { status:actions.length ? 'not-exercised' : 'not-applicable', actions };
316
- if (exerciseInteraction && actions.length) {
317
- if (!this.verifyBehavior) throw promotionError('AUTHORING_VERIFIER_UNAVAILABLE', '当前宿主没有配置行为验证器');
318
- try { interaction = { ...interaction, ...await this.verifyBehavior(entry, this.world) }; }
319
- catch (error) { interaction = { ...interaction, status:'failed', reason:error.code || error.message }; }
320
- }
321
- if (!this.linkedRecord(entry)) throw promotionError('AUTHORING_VERIFICATION_STALE', '验证过程中目标实体发生变化');
322
- const pose = this.world.physics.checkManifestPose(physicsManifestForUniformScale(manifest, record.physicsScale || 1), record.object.position.toArray(), {
323
- quaternion:record.object.quaternion.toArray(), excludeIds:[entry.entityId]
324
- });
325
- const navigation = await this.world.navigation?.ensureCurrent?.() || { success:false, code:'NAVIGATION_UNAVAILABLE' };
326
- entry.verification = { physics:{ registered:Boolean(this.world.physics.getPosition(entry.entityId)), placement:pose },
327
- navigation:clone(navigation), interaction:clone(interaction), admission:assetAdmission(manifest), checkedAt:new Date().toISOString() };
328
- const verified = pose.checked && pose.clear && navigation.success && ['verified', 'not-applicable'].includes(interaction.status);
329
- return { status:verified ? 'authoring-verified' : 'authoring-unverified', nodeId, entityId:entry.entityId, verification:clone(entry.verification) };
330
- });
331
- }
332
-
333
- dispose() { for (const stop of this.stops) stop(); this.authoring.setPromotedNodes([]); }
334
- }