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,825 +0,0 @@
1
- import * as THREE from 'three';
2
- import { cloneAuthoringModelRef, getAuthoringModelRef, markAuthoringModelRef } from './ModelRef.js';
3
- import { getAuthoringObjectId, setAuthoringObjectId } from './AuthoringIdentity.js';
4
-
5
- export const AUTHORING_FORMAT = 'agentscape-world-authoring';
6
- export const AUTHORING_VERSION = 1;
7
-
8
- const ROOT_ID = 'root';
9
- const RESERVED_USER_DATA = new Set([
10
- 'authoringId',
11
- 'authoringGeometryId',
12
- 'authoringMaterialId',
13
- 'authoringTextureId',
14
- 'authoringSource',
15
- 'authoringModelRef',
16
- 'instanceId',
17
- 'visualDecoration',
18
- 'visualDecorationRoot',
19
- 'worldAuthoringRoot'
20
- ]);
21
-
22
- const PRIMITIVE_GEOMETRIES = new Set([
23
- 'BoxGeometry',
24
- 'SphereGeometry',
25
- 'PlaneGeometry',
26
- 'CylinderGeometry',
27
- 'ConeGeometry',
28
- 'TorusGeometry'
29
- ]);
30
-
31
- const MATERIAL_TYPES = new Set([
32
- 'MeshBasicMaterial',
33
- 'MeshStandardMaterial',
34
- 'MeshPhysicalMaterial'
35
- ]);
36
-
37
- const TEXTURE_SLOTS = [
38
- 'map',
39
- 'normalMap',
40
- 'roughnessMap',
41
- 'metalnessMap',
42
- 'emissiveMap',
43
- 'alphaMap',
44
- 'aoMap'
45
- ];
46
-
47
- const geometryIdsByObject = new WeakMap();
48
- const materialIdsByObject = new WeakMap();
49
- const textureIdsByObject = new WeakMap();
50
- const textureSourcesByObject = new WeakMap();
51
-
52
- function makeId(prefix) {
53
- return `${prefix}_${THREE.MathUtils.generateUUID().toLowerCase()}`;
54
- }
55
-
56
- function structuredCloneJson(value) {
57
- return JSON.parse(JSON.stringify(value));
58
- }
59
-
60
- function ensureObjectId(object, usedIds, isRoot = false) {
61
- let id = isRoot ? ROOT_ID : getAuthoringObjectId(object);
62
- if (
63
- typeof id !== 'string'
64
- || !id.trim()
65
- || (usedIds.has(id) && usedIds.get(id) !== object)
66
- ) {
67
- id = isRoot ? ROOT_ID : makeId('node');
68
- }
69
- setAuthoringObjectId(object, id);
70
- usedIds.set(id, object);
71
- return id;
72
- }
73
-
74
- function ensureResourceId(resource, legacyKey, prefix, usedIds, sidecar) {
75
- let id = sidecar.get(resource) || resource.userData?.[legacyKey];
76
- if (
77
- typeof id !== 'string'
78
- || !id.trim()
79
- || (usedIds.has(id) && usedIds.get(id) !== resource)
80
- ) {
81
- id = makeId(prefix);
82
- }
83
- sidecar.set(resource, id);
84
- usedIds.set(id, resource);
85
- return id;
86
- }
87
-
88
- function toJsonValue(value, seen = new WeakSet()) {
89
- if (value === null || typeof value === 'string' || typeof value === 'boolean') return value;
90
- if (typeof value === 'number') return Number.isFinite(value) ? value : undefined;
91
- if (Array.isArray(value)) {
92
- if (seen.has(value)) return undefined;
93
- seen.add(value);
94
- const result = value.map(item => toJsonValue(item, seen)).filter(item => item !== undefined);
95
- seen.delete(value);
96
- return result;
97
- }
98
- if (typeof value !== 'object' || value?.isObject3D || value?.isMaterial || value?.isTexture) return undefined;
99
- if (seen.has(value)) return undefined;
100
- seen.add(value);
101
- const result = {};
102
- for (const [key, entry] of Object.entries(value)) {
103
- if (RESERVED_USER_DATA.has(key)) continue;
104
- const converted = toJsonValue(entry, seen);
105
- if (converted !== undefined) result[key] = converted;
106
- }
107
- seen.delete(value);
108
- return result;
109
- }
110
-
111
- function captureMetadata(object) {
112
- const metadata = toJsonValue(object.userData);
113
- return metadata && Object.keys(metadata).length > 0 ? metadata : undefined;
114
- }
115
-
116
- function transformComponent(object) {
117
- return {
118
- type: 'Transform',
119
- properties: {
120
- position: object.position.toArray(),
121
- quaternion: object.quaternion.toArray(),
122
- scale: object.scale.toArray()
123
- }
124
- };
125
- }
126
-
127
- function geometryDefinition(geometry) {
128
- if (PRIMITIVE_GEOMETRIES.has(geometry.type) && geometry.parameters) {
129
- return {
130
- type: geometry.type,
131
- parameters: structuredCloneJson(geometry.parameters)
132
- };
133
- }
134
-
135
- const json = geometry.toJSON();
136
- delete json.metadata;
137
- delete json.uuid;
138
- delete json.userData;
139
- return {
140
- type: 'BufferGeometry',
141
- sourceType: geometry.type,
142
- json
143
- };
144
- }
145
-
146
- function textureSource(texture) {
147
- const explicit = textureSourcesByObject.get(texture) || texture.userData?.authoringSource;
148
- if (explicit && typeof explicit === 'object') {
149
- const source = toJsonValue(explicit);
150
- if (source?.type === 'url' && typeof source.uri === 'string' && source.uri) return source;
151
- }
152
-
153
- const image = texture.image;
154
- const uri = image?.currentSrc || image?.src;
155
- if (typeof uri === 'string' && uri) return { type: 'url', uri };
156
-
157
- if (image?.data && Number.isFinite(image.width) && Number.isFinite(image.height)) {
158
- const data = Array.from(image.data);
159
- return {
160
- type: 'data',
161
- width: image.width,
162
- height: image.height,
163
- dataType: image.data.constructor?.name || 'Uint8Array',
164
- data
165
- };
166
- }
167
-
168
- throw new TypeError('World Authoring texture requires a URL or DataTexture source');
169
- }
170
-
171
- function textureDefinition(texture) {
172
- return {
173
- source: textureSource(texture),
174
- mapping: texture.mapping,
175
- wrapS: texture.wrapS,
176
- wrapT: texture.wrapT,
177
- magFilter: texture.magFilter,
178
- minFilter: texture.minFilter,
179
- anisotropy: texture.anisotropy,
180
- format: texture.format,
181
- type: texture.type,
182
- colorSpace: texture.colorSpace,
183
- flipY: texture.flipY,
184
- premultiplyAlpha: texture.premultiplyAlpha,
185
- generateMipmaps: texture.generateMipmaps,
186
- offset: texture.offset.toArray(),
187
- repeat: texture.repeat.toArray(),
188
- center: texture.center.toArray(),
189
- rotation: texture.rotation
190
- };
191
- }
192
-
193
- function captureMaterial(
194
- material,
195
- textureIds,
196
- textures
197
- ) {
198
- if (!MATERIAL_TYPES.has(material.type)) {
199
- throw new TypeError(`Unsupported World Authoring material: ${material.type}`);
200
- }
201
-
202
- const json = material.toJSON();
203
- delete json.metadata;
204
- delete json.uuid;
205
- delete json.userData;
206
- delete json.textures;
207
- delete json.images;
208
-
209
- for (const slot of TEXTURE_SLOTS) {
210
- const texture = material[slot];
211
- if (!texture) {
212
- delete json[slot];
213
- continue;
214
- }
215
- const textureId = ensureResourceId(texture, 'authoringTextureId', 'tex', textureIds, textureIdsByObject);
216
- if (!textures[textureId]) textures[textureId] = textureDefinition(texture);
217
- json[slot] = textureId;
218
- }
219
-
220
- return json;
221
- }
222
-
223
- function lightComponent(object) {
224
- if (!(object.isAmbientLight || object.isHemisphereLight || object.isDirectionalLight || object.isPointLight || object.isSpotLight)) return null;
225
-
226
- const base = {
227
- color: `#${object.color.getHexString()}`,
228
- intensity: object.intensity
229
- };
230
-
231
- if (object.isAmbientLight) return { type: 'AmbientLight', properties: base };
232
- if (object.isHemisphereLight) {
233
- return {
234
- type: 'HemisphereLight',
235
- properties: {
236
- ...base,
237
- groundColor: `#${object.groundColor.getHexString()}`
238
- }
239
- };
240
- }
241
- if (object.isDirectionalLight) {
242
- return {
243
- type: 'DirectionalLight',
244
- properties: {
245
- ...base,
246
- target: object.target.position.toArray(),
247
- castShadow: object.castShadow
248
- }
249
- };
250
- }
251
- if (object.isPointLight) {
252
- return {
253
- type: 'PointLight',
254
- properties: {
255
- ...base,
256
- distance: object.distance,
257
- decay: object.decay,
258
- castShadow: object.castShadow
259
- }
260
- };
261
- }
262
- if (object.isSpotLight) {
263
- return {
264
- type: 'SpotLight',
265
- properties: {
266
- ...base,
267
- distance: object.distance,
268
- angle: object.angle,
269
- penumbra: object.penumbra,
270
- decay: object.decay,
271
- target: object.target.position.toArray(),
272
- castShadow: object.castShadow
273
- }
274
- };
275
- }
276
- return null;
277
- }
278
-
279
- function captureMeshResources(
280
- object,
281
- geometryIds,
282
- materialIds,
283
- textureIds,
284
- geometries,
285
- materials,
286
- textures
287
- ) {
288
- if (Array.isArray(object.material)) {
289
- throw new TypeError('World Authoring v1 does not persist multi-material Mesh');
290
- }
291
-
292
- const geometryId = ensureResourceId(object.geometry, 'authoringGeometryId', 'geo', geometryIds, geometryIdsByObject);
293
- const materialId = ensureResourceId(object.material, 'authoringMaterialId', 'mat', materialIds, materialIdsByObject);
294
-
295
- if (!geometries[geometryId]) geometries[geometryId] = geometryDefinition(object.geometry);
296
- if (!materials[materialId]) {
297
- materials[materialId] = captureMaterial(object.material, textureIds, textures);
298
- }
299
-
300
- return { geometryId, materialId };
301
- }
302
-
303
- function captureInstancedMesh(object) {
304
- const matrices = Array.from(object.instanceMatrix.array);
305
- const colors = object.instanceColor ? Array.from(object.instanceColor.array) : undefined;
306
- return {
307
- type: 'InstancedMesh',
308
- properties: {
309
- count: object.count,
310
- matrices,
311
- ...(colors ? { colors } : {}),
312
- castShadow: object.castShadow,
313
- receiveShadow: object.receiveShadow
314
- }
315
- };
316
- }
317
-
318
- function sceneComponent(object, textureIds, textures) {
319
- if (!object.isScene) return null;
320
- const properties = {};
321
- if (object.background?.isColor) {
322
- properties.background = { type:'color', value:`#${object.background.getHexString()}` };
323
- } else if (object.background?.isTexture) {
324
- const textureId = ensureResourceId(object.background, 'authoringTextureId', 'tex', textureIds, textureIdsByObject);
325
- if (!textures[textureId]) textures[textureId] = textureDefinition(object.background);
326
- properties.background = { type:'texture', textureId };
327
- }
328
- if (object.environment?.isTexture) {
329
- const textureId = ensureResourceId(object.environment, 'authoringTextureId', 'tex', textureIds, textureIdsByObject);
330
- if (!textures[textureId]) textures[textureId] = textureDefinition(object.environment);
331
- properties.environment = { textureId };
332
- }
333
- if (object.fog?.isFog) {
334
- properties.fog = { type:'Fog', color:`#${object.fog.color.getHexString()}`, near:object.fog.near, far:object.fog.far };
335
- } else if (object.fog?.isFogExp2) {
336
- properties.fog = { type:'FogExp2', color:`#${object.fog.color.getHexString()}`, density:object.fog.density };
337
- }
338
- if (Number.isFinite(object.backgroundBlurriness)) properties.backgroundBlurriness = object.backgroundBlurriness;
339
- if (Number.isFinite(object.backgroundIntensity)) properties.backgroundIntensity = object.backgroundIntensity;
340
- if (Number.isFinite(object.environmentIntensity)) properties.environmentIntensity = object.environmentIntensity;
341
- return { type:'Scene', properties };
342
- }
343
-
344
- function captureNode(
345
- object,
346
- geometryIds,
347
- materialIds,
348
- textureIds,
349
- geometries,
350
- materials,
351
- textures
352
- ) {
353
- const components = { transform: transformComponent(object) };
354
-
355
- const modelRef = getAuthoringModelRef(object);
356
- if (modelRef) {
357
- components.modelRef = {
358
- type: 'ModelRef',
359
- properties: cloneAuthoringModelRef(modelRef)
360
- };
361
- } else if (object.isScene) {
362
- components.scene = sceneComponent(object, textureIds, textures);
363
- } else if (object.isInstancedMesh) {
364
- const { geometryId, materialId } = captureMeshResources(
365
- object,
366
- geometryIds,
367
- materialIds,
368
- textureIds,
369
- geometries,
370
- materials,
371
- textures
372
- );
373
- components.instancedMesh = captureInstancedMesh(object);
374
- components.geometry = { type: 'GeometryRef', properties: { geometryId } };
375
- components.material = { type: 'MaterialRef', properties: { materialId } };
376
- } else if (object.isMesh) {
377
- const { geometryId, materialId } = captureMeshResources(
378
- object,
379
- geometryIds,
380
- materialIds,
381
- textureIds,
382
- geometries,
383
- materials,
384
- textures
385
- );
386
- components.mesh = {
387
- type: 'Mesh',
388
- properties: {
389
- castShadow: object.castShadow,
390
- receiveShadow: object.receiveShadow
391
- }
392
- };
393
- components.geometry = { type: 'GeometryRef', properties: { geometryId } };
394
- components.material = { type: 'MaterialRef', properties: { materialId } };
395
- } else {
396
- const light = lightComponent(object);
397
- if (light) {
398
- components.light = light;
399
- } else if (!(object.isGroup || object.type === 'Object3D')) {
400
- throw new TypeError(`Unsupported World Authoring object: ${object.type}`);
401
- }
402
- }
403
-
404
- const node = {
405
- id: getAuthoringObjectId(object),
406
- name: object.name || undefined,
407
- visible: object.visible === false ? false : undefined,
408
- components
409
- };
410
- const metadata = captureMetadata(object);
411
- if (metadata) node.metadata = metadata;
412
- return node;
413
- }
414
-
415
- export function captureAuthoringState(root) {
416
- if (!root?.isObject3D) throw new TypeError('World Authoring capture requires an Object3D root');
417
-
418
- const state = {
419
- version: AUTHORING_VERSION,
420
- rootId: ROOT_ID,
421
- nodesById: {},
422
- childIdsById: {},
423
- parentIdById: {},
424
- geometries: {},
425
- materials: {},
426
- textures: {}
427
- };
428
-
429
- const objectIds = new Map();
430
- const geometryIds = new Map();
431
- const materialIds = new Map();
432
- const textureIds = new Map();
433
-
434
- function visit(object, parentId = null, isRoot = false) {
435
- const id = ensureObjectId(object, objectIds, isRoot);
436
- const node = captureNode(
437
- object,
438
- geometryIds,
439
- materialIds,
440
- textureIds,
441
- state.geometries,
442
- state.materials,
443
- state.textures
444
- );
445
- node.id = id;
446
-
447
- state.nodesById[id] = node;
448
- state.parentIdById[id] = parentId;
449
- state.childIdsById[id] = [];
450
-
451
- if (!node.components.modelRef) {
452
- for (const child of object.children) {
453
- const childId = visit(child, id, false);
454
- state.childIdsById[id].push(childId);
455
- }
456
- }
457
- return id;
458
- }
459
-
460
- state.rootId = visit(root, null, true);
461
- return state;
462
- }
463
-
464
- function denormalizeNode(id, state) {
465
- const node = state.nodesById[id];
466
- if (!node) throw new TypeError(`Missing World Authoring node: ${id}`);
467
- const childIds = state.childIdsById[id] || [];
468
- if (node.components?.modelRef && childIds.length > 0) {
469
- throw new TypeError('World Authoring ModelRef node cannot contain authored children');
470
- }
471
- const children = childIds.map(childId => denormalizeNode(childId, state));
472
- return {
473
- ...structuredCloneJson(node),
474
- ...(children.length ? { children } : {})
475
- };
476
- }
477
-
478
- export function exportAuthoringDocument(state) {
479
- if (!state || state.version !== AUTHORING_VERSION || !state.rootId) {
480
- throw new TypeError('Invalid World Authoring state');
481
- }
482
- return {
483
- format: AUTHORING_FORMAT,
484
- version: AUTHORING_VERSION,
485
- root: denormalizeNode(state.rootId, state),
486
- ...(Object.keys(state.geometries || {}).length ? { geometries: structuredCloneJson(state.geometries) } : {}),
487
- ...(Object.keys(state.materials || {}).length ? { materials: structuredCloneJson(state.materials) } : {}),
488
- ...(Object.keys(state.textures || {}).length ? { textures: structuredCloneJson(state.textures) } : {})
489
- };
490
- }
491
-
492
- export function parseAuthoringDocument(document) {
493
- if (!document || document.format !== AUTHORING_FORMAT) {
494
- throw new TypeError(`World Authoring document format must be ${AUTHORING_FORMAT}`);
495
- }
496
- if (document.version !== AUTHORING_VERSION) {
497
- throw new TypeError(`Unsupported World Authoring document version: ${document.version}`);
498
- }
499
- if (!document.root || typeof document.root.id !== 'string') {
500
- throw new TypeError('World Authoring document requires a root node');
501
- }
502
-
503
- const state = {
504
- version: AUTHORING_VERSION,
505
- rootId: document.root.id,
506
- nodesById: {},
507
- childIdsById: {},
508
- parentIdById: {},
509
- geometries: structuredCloneJson(document.geometries || {}),
510
- materials: structuredCloneJson(document.materials || {}),
511
- textures: structuredCloneJson(document.textures || {})
512
- };
513
-
514
- function insert(node, parentId) {
515
- if (!node || typeof node.id !== 'string' || !node.id) throw new TypeError('World Authoring node id is required');
516
- if (state.nodesById[node.id]) throw new TypeError(`Duplicate World Authoring node id: ${node.id}`);
517
- const { children = [], ...record } = node;
518
- if (record.components?.modelRef && children.length > 0) {
519
- throw new TypeError('World Authoring ModelRef node cannot contain authored children');
520
- }
521
- state.nodesById[node.id] = structuredCloneJson(record);
522
- state.parentIdById[node.id] = parentId;
523
- state.childIdsById[node.id] = [];
524
- for (const child of children) {
525
- insert(child, node.id);
526
- state.childIdsById[node.id].push(child.id);
527
- }
528
- }
529
-
530
- insert(document.root, null);
531
- return state;
532
- }
533
-
534
- function createPrimitiveGeometry(definition) {
535
- const p = definition.parameters || {};
536
- switch (definition.type) {
537
- case 'BoxGeometry':
538
- return new THREE.BoxGeometry(p.width, p.height, p.depth, p.widthSegments, p.heightSegments, p.depthSegments);
539
- case 'SphereGeometry':
540
- return new THREE.SphereGeometry(p.radius, p.widthSegments, p.heightSegments, p.phiStart, p.phiLength, p.thetaStart, p.thetaLength);
541
- case 'PlaneGeometry':
542
- return new THREE.PlaneGeometry(p.width, p.height, p.widthSegments, p.heightSegments);
543
- case 'CylinderGeometry':
544
- return new THREE.CylinderGeometry(p.radiusTop, p.radiusBottom, p.height, p.radialSegments, p.heightSegments, p.openEnded, p.thetaStart, p.thetaLength);
545
- case 'ConeGeometry':
546
- return new THREE.ConeGeometry(p.radius, p.height, p.radialSegments, p.heightSegments, p.openEnded, p.thetaStart, p.thetaLength);
547
- case 'TorusGeometry':
548
- return new THREE.TorusGeometry(p.radius, p.tube, p.radialSegments, p.tubularSegments, p.arc);
549
- default:
550
- return null;
551
- }
552
- }
553
-
554
- function hydrateGeometries(definitions) {
555
- const geometries = {};
556
- for (const [id, definition] of Object.entries(definitions || {})) {
557
- let geometry = createPrimitiveGeometry(definition);
558
- if (!geometry && definition.type === 'BufferGeometry' && definition.json) {
559
- geometry = new THREE.BufferGeometryLoader().parse(definition.json);
560
- }
561
- if (!geometry) throw new TypeError(`Unsupported World Authoring geometry: ${definition.type}`);
562
- geometryIdsByObject.set(geometry, id);
563
-
564
- geometries[id] = geometry;
565
- }
566
- return geometries;
567
- }
568
-
569
- const TYPED_ARRAYS = {
570
- Uint8Array,
571
- Uint8ClampedArray,
572
- Uint16Array,
573
- Uint32Array,
574
- Int8Array,
575
- Int16Array,
576
- Int32Array,
577
- Float32Array,
578
- Float64Array
579
- };
580
-
581
- function hydrateTextureSource(source) {
582
- if (source?.type === 'data') {
583
- const ArrayType = TYPED_ARRAYS[source.dataType] || Uint8Array;
584
- const texture = new THREE.DataTexture(
585
- new ArrayType(source.data || []),
586
- source.width,
587
- source.height
588
- );
589
- texture.needsUpdate = true;
590
- return texture;
591
- }
592
-
593
- if (source?.type === 'url' && typeof source.uri === 'string' && source.uri) {
594
- let texture;
595
- if (typeof document !== 'undefined') {
596
- texture = new THREE.TextureLoader().load(source.uri);
597
- } else {
598
- texture = new THREE.Texture();
599
- }
600
-
601
- textureSourcesByObject.set(texture, structuredCloneJson(source));
602
- return texture;
603
- }
604
-
605
- throw new TypeError('Unsupported World Authoring texture source');
606
- }
607
-
608
- function hydrateTextures(definitions) {
609
- const textures = {};
610
- for (const [id, definition] of Object.entries(definitions || {})) {
611
- const texture = hydrateTextureSource(definition.source);
612
- texture.mapping = definition.mapping ?? texture.mapping;
613
- texture.wrapS = definition.wrapS ?? texture.wrapS;
614
- texture.wrapT = definition.wrapT ?? texture.wrapT;
615
- texture.magFilter = definition.magFilter ?? texture.magFilter;
616
- texture.minFilter = definition.minFilter ?? texture.minFilter;
617
- texture.anisotropy = definition.anisotropy ?? texture.anisotropy;
618
- texture.format = definition.format ?? texture.format;
619
- texture.type = definition.type ?? texture.type;
620
- texture.colorSpace = definition.colorSpace ?? texture.colorSpace;
621
- texture.flipY = definition.flipY ?? texture.flipY;
622
- texture.premultiplyAlpha = definition.premultiplyAlpha ?? texture.premultiplyAlpha;
623
- texture.generateMipmaps = definition.generateMipmaps ?? texture.generateMipmaps;
624
- if (Array.isArray(definition.offset)) texture.offset.fromArray(definition.offset);
625
- if (Array.isArray(definition.repeat)) texture.repeat.fromArray(definition.repeat);
626
- if (Array.isArray(definition.center)) texture.center.fromArray(definition.center);
627
- if (Number.isFinite(definition.rotation)) texture.rotation = definition.rotation;
628
-
629
- textureIdsByObject.set(texture, id);
630
- if (definition.source) textureSourcesByObject.set(texture, structuredCloneJson(definition.source));
631
- textures[id] = texture;
632
- }
633
- return textures;
634
- }
635
-
636
- function hydrateMaterials(definitions, textures) {
637
- const materials = {};
638
- const loader = new THREE.MaterialLoader();
639
- loader.setTextures(textures);
640
- for (const [id, definition] of Object.entries(definitions || {})) {
641
- if (!MATERIAL_TYPES.has(definition.type)) {
642
- throw new TypeError(`Unsupported World Authoring material: ${definition.type}`);
643
- }
644
- const material = loader.parse(definition);
645
- materialIdsByObject.set(material, id);
646
-
647
- materials[id] = material;
648
- }
649
- return materials;
650
- }
651
-
652
- function applyTransform(object, component) {
653
- const p = component?.properties || {};
654
- if (Array.isArray(p.position) && p.position.length === 3) object.position.fromArray(p.position);
655
- if (Array.isArray(p.quaternion) && p.quaternion.length === 4) object.quaternion.fromArray(p.quaternion);
656
- if (Array.isArray(p.scale) && p.scale.length === 3) object.scale.fromArray(p.scale);
657
- }
658
-
659
- function createLight(component) {
660
- const p = component.properties || {};
661
- const color = p.color ?? '#ffffff';
662
- let light;
663
- switch (component.type) {
664
- case 'AmbientLight':
665
- light = new THREE.AmbientLight(color, p.intensity);
666
- break;
667
- case 'HemisphereLight':
668
- light = new THREE.HemisphereLight(color, p.groundColor ?? '#ffffff', p.intensity);
669
- break;
670
- case 'DirectionalLight':
671
- light = new THREE.DirectionalLight(color, p.intensity);
672
- if (Array.isArray(p.target)) light.target.position.fromArray(p.target);
673
- light.castShadow = Boolean(p.castShadow);
674
- break;
675
- case 'PointLight':
676
- light = new THREE.PointLight(color, p.intensity, p.distance, p.decay);
677
- light.castShadow = Boolean(p.castShadow);
678
- break;
679
- case 'SpotLight':
680
- light = new THREE.SpotLight(color, p.intensity, p.distance, p.angle, p.penumbra, p.decay);
681
- if (Array.isArray(p.target)) light.target.position.fromArray(p.target);
682
- light.castShadow = Boolean(p.castShadow);
683
- break;
684
- default:
685
- throw new TypeError(`Unsupported World Authoring light: ${component.type}`);
686
- }
687
- return light;
688
- }
689
-
690
- function requiredMeshResources(components, geometries, materials) {
691
- const geometryId = components.geometry?.properties?.geometryId;
692
- const materialId = components.material?.properties?.materialId;
693
- const geometry = geometries[geometryId];
694
- const material = materials[materialId];
695
- if (!geometry) throw new TypeError(`Missing World Authoring geometry: ${geometryId}`);
696
- if (!material) throw new TypeError(`Missing World Authoring material: ${materialId}`);
697
- return { geometry, material };
698
- }
699
-
700
- function createInstancedMesh(component, geometry, material) {
701
- const p = component.properties || {};
702
- const count = Number(p.count);
703
- if (!Number.isInteger(count) || count < 0) throw new TypeError('Invalid World Authoring InstancedMesh count');
704
- const object = new THREE.InstancedMesh(geometry, material, count);
705
- const matrices = p.matrices || [];
706
- if (matrices.length !== count * 16) {
707
- throw new TypeError('Invalid World Authoring InstancedMesh matrix data');
708
- }
709
- object.instanceMatrix.array.set(matrices);
710
- object.instanceMatrix.needsUpdate = true;
711
- if (Array.isArray(p.colors)) {
712
- if (p.colors.length !== count * 3) throw new TypeError('Invalid World Authoring InstancedMesh color data');
713
- object.instanceColor = new THREE.InstancedBufferAttribute(new Float32Array(p.colors), 3);
714
- object.instanceColor.needsUpdate = true;
715
- }
716
- object.castShadow = Boolean(p.castShadow);
717
- object.receiveShadow = Boolean(p.receiveShadow);
718
- return object;
719
- }
720
-
721
- function applySceneComponent(scene, component, textures) {
722
- const p = component?.properties || {};
723
- const background = p.background;
724
- if (background?.type === 'color') scene.background = new THREE.Color(background.value);
725
- else if (background?.type === 'texture') scene.background = textures[background.textureId] || null;
726
- if (p.environment?.textureId) scene.environment = textures[p.environment.textureId] || null;
727
- if (p.fog?.type === 'Fog') scene.fog = new THREE.Fog(p.fog.color, p.fog.near, p.fog.far);
728
- else if (p.fog?.type === 'FogExp2') scene.fog = new THREE.FogExp2(p.fog.color, p.fog.density);
729
- if (Number.isFinite(p.backgroundBlurriness)) scene.backgroundBlurriness = p.backgroundBlurriness;
730
- if (Number.isFinite(p.backgroundIntensity)) scene.backgroundIntensity = p.backgroundIntensity;
731
- if (Number.isFinite(p.environmentIntensity)) scene.environmentIntensity = p.environmentIntensity;
732
- }
733
-
734
- function createObjectForNode(node, geometries, materials, textures) {
735
- const components = node.components || {};
736
- let object;
737
-
738
- if (components.modelRef) {
739
- throw new TypeError('World Authoring ModelRef requires loadAsync()');
740
- } else if (components.scene) {
741
- object = new THREE.Scene();
742
- applySceneComponent(object, components.scene, textures);
743
- } else if (components.instancedMesh) {
744
- const { geometry, material } = requiredMeshResources(components, geometries, materials);
745
- object = createInstancedMesh(components.instancedMesh, geometry, material);
746
- } else if (components.mesh) {
747
- const { geometry, material } = requiredMeshResources(components, geometries, materials);
748
- object = new THREE.Mesh(geometry, material);
749
- object.castShadow = Boolean(components.mesh.properties?.castShadow);
750
- object.receiveShadow = Boolean(components.mesh.properties?.receiveShadow);
751
- } else if (components.light) {
752
- object = createLight(components.light);
753
- } else {
754
- object = new THREE.Group();
755
- }
756
-
757
- object.name = node.name || '';
758
- object.visible = node.visible !== false;
759
- object.userData = node.metadata ? structuredCloneJson(node.metadata) : {};
760
- setAuthoringObjectId(object, node.id);
761
- applyTransform(object, components.transform);
762
- return object;
763
- }
764
-
765
- export function hydrateAuthoringState(state) {
766
- if (!state || state.version !== AUTHORING_VERSION) throw new TypeError('Invalid World Authoring state');
767
-
768
- const geometries = hydrateGeometries(state.geometries);
769
- const textures = hydrateTextures(state.textures);
770
- const materials = hydrateMaterials(state.materials, textures);
771
-
772
- function build(id) {
773
- const node = state.nodesById[id];
774
- if (!node) throw new TypeError(`Missing World Authoring node: ${id}`);
775
- const object = createObjectForNode(node, geometries, materials, textures);
776
- for (const childId of state.childIdsById[id] || []) object.add(build(childId));
777
- return object;
778
- }
779
-
780
- return build(state.rootId);
781
- }
782
-
783
-
784
-
785
- async function createObjectForNodeAsync(node, geometries, materials, textures, resolveModel) {
786
- const components = node.components || {};
787
- if (!components.modelRef) return createObjectForNode(node, geometries, materials, textures);
788
- if (typeof resolveModel !== 'function') {
789
- throw new TypeError('World Authoring loadAsync requires resolveModel for ModelRef');
790
- }
791
-
792
- const reference = cloneAuthoringModelRef(components.modelRef.properties);
793
- const resolved = await resolveModel(reference, node);
794
- if (!resolved?.isObject3D) {
795
- throw new TypeError('World Authoring ModelRef resolver must return an Object3D');
796
- }
797
-
798
- const object = new THREE.Group();
799
- object.name = node.name || '';
800
- object.visible = node.visible !== false;
801
- object.userData = node.metadata ? structuredCloneJson(node.metadata) : {};
802
- setAuthoringObjectId(object, node.id);
803
- markAuthoringModelRef(object, reference);
804
- applyTransform(object, components.transform);
805
- object.add(resolved);
806
- return object;
807
- }
808
-
809
- export async function hydrateAuthoringStateAsync(state, { resolveModel } = {}) {
810
- if (!state || state.version !== AUTHORING_VERSION) throw new TypeError('Invalid World Authoring state');
811
-
812
- const geometries = hydrateGeometries(state.geometries);
813
- const textures = hydrateTextures(state.textures);
814
- const materials = hydrateMaterials(state.materials, textures);
815
-
816
- async function build(id) {
817
- const node = state.nodesById[id];
818
- if (!node) throw new TypeError('Missing World Authoring node: ' + id);
819
- const object = await createObjectForNodeAsync(node, geometries, materials, textures, resolveModel);
820
- for (const childId of state.childIdsById[id] || []) object.add(await build(childId));
821
- return object;
822
- }
823
-
824
- return build(state.rootId);
825
- }