@onerjs/loaders 8.23.1

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 (280) hide show
  1. package/OBJ/index.d.ts +4 -0
  2. package/OBJ/index.js +5 -0
  3. package/OBJ/index.js.map +1 -0
  4. package/OBJ/mtlFileLoader.d.ts +41 -0
  5. package/OBJ/mtlFileLoader.js +231 -0
  6. package/OBJ/mtlFileLoader.js.map +1 -0
  7. package/OBJ/objFileLoader.d.ts +136 -0
  8. package/OBJ/objFileLoader.js +318 -0
  9. package/OBJ/objFileLoader.js.map +1 -0
  10. package/OBJ/objFileLoader.metadata.d.ts +4 -0
  11. package/OBJ/objFileLoader.metadata.js +5 -0
  12. package/OBJ/objFileLoader.metadata.js.map +1 -0
  13. package/OBJ/objLoadingOptions.d.ts +47 -0
  14. package/OBJ/objLoadingOptions.js +2 -0
  15. package/OBJ/objLoadingOptions.js.map +1 -0
  16. package/OBJ/solidParser.d.ts +174 -0
  17. package/OBJ/solidParser.js +862 -0
  18. package/OBJ/solidParser.js.map +1 -0
  19. package/SPLAT/index.d.ts +2 -0
  20. package/SPLAT/index.js +4 -0
  21. package/SPLAT/index.js.map +1 -0
  22. package/SPLAT/splatFileLoader.d.ts +88 -0
  23. package/SPLAT/splatFileLoader.js +562 -0
  24. package/SPLAT/splatFileLoader.js.map +1 -0
  25. package/SPLAT/splatFileLoader.metadata.d.ts +14 -0
  26. package/SPLAT/splatFileLoader.metadata.js +12 -0
  27. package/SPLAT/splatFileLoader.metadata.js.map +1 -0
  28. package/SPLAT/splatLoadingOptions.d.ts +13 -0
  29. package/SPLAT/splatLoadingOptions.js +2 -0
  30. package/SPLAT/splatLoadingOptions.js.map +1 -0
  31. package/STL/index.d.ts +1 -0
  32. package/STL/index.js +2 -0
  33. package/STL/index.js.map +1 -0
  34. package/STL/stlFileLoader.d.ts +78 -0
  35. package/STL/stlFileLoader.js +239 -0
  36. package/STL/stlFileLoader.js.map +1 -0
  37. package/STL/stlFileLoader.metadata.d.ts +8 -0
  38. package/STL/stlFileLoader.metadata.js +8 -0
  39. package/STL/stlFileLoader.metadata.js.map +1 -0
  40. package/bvh/bvhFileLoader.d.ts +69 -0
  41. package/bvh/bvhFileLoader.js +133 -0
  42. package/bvh/bvhFileLoader.js.map +1 -0
  43. package/bvh/bvhFileLoader.metadata.d.ts +8 -0
  44. package/bvh/bvhFileLoader.metadata.js +8 -0
  45. package/bvh/bvhFileLoader.metadata.js.map +1 -0
  46. package/bvh/bvhLoader.d.ts +14 -0
  47. package/bvh/bvhLoader.js +329 -0
  48. package/bvh/bvhLoader.js.map +1 -0
  49. package/bvh/bvhLoadingOptions.d.ts +9 -0
  50. package/bvh/bvhLoadingOptions.js +2 -0
  51. package/bvh/bvhLoadingOptions.js.map +1 -0
  52. package/bvh/index.d.ts +2 -0
  53. package/bvh/index.js +4 -0
  54. package/bvh/index.js.map +1 -0
  55. package/bvh/license.md +21 -0
  56. package/dynamic.d.ts +5 -0
  57. package/dynamic.js +57 -0
  58. package/dynamic.js.map +1 -0
  59. package/glTF/1.0/glTFBinaryExtension.d.ts +16 -0
  60. package/glTF/1.0/glTFBinaryExtension.js +65 -0
  61. package/glTF/1.0/glTFBinaryExtension.js.map +1 -0
  62. package/glTF/1.0/glTFLoader.d.ts +144 -0
  63. package/glTF/1.0/glTFLoader.js +1841 -0
  64. package/glTF/1.0/glTFLoader.js.map +1 -0
  65. package/glTF/1.0/glTFLoaderInterfaces.d.ts +412 -0
  66. package/glTF/1.0/glTFLoaderInterfaces.js +96 -0
  67. package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -0
  68. package/glTF/1.0/glTFLoaderUtils.d.ts +71 -0
  69. package/glTF/1.0/glTFLoaderUtils.js +255 -0
  70. package/glTF/1.0/glTFLoaderUtils.js.map +1 -0
  71. package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +13 -0
  72. package/glTF/1.0/glTFMaterialsCommonExtension.js +131 -0
  73. package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -0
  74. package/glTF/1.0/index.d.ts +5 -0
  75. package/glTF/1.0/index.js +6 -0
  76. package/glTF/1.0/index.js.map +1 -0
  77. package/glTF/2.0/Extensions/EXT_lights_ies.d.ts +41 -0
  78. package/glTF/2.0/Extensions/EXT_lights_ies.js +84 -0
  79. package/glTF/2.0/Extensions/EXT_lights_ies.js.map +1 -0
  80. package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +48 -0
  81. package/glTF/2.0/Extensions/EXT_lights_image_based.js +116 -0
  82. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -0
  83. package/glTF/2.0/Extensions/EXT_materials_diffuse_roughness.d.ts +43 -0
  84. package/glTF/2.0/Extensions/EXT_materials_diffuse_roughness.js +69 -0
  85. package/glTF/2.0/Extensions/EXT_materials_diffuse_roughness.js.map +1 -0
  86. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +39 -0
  87. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +82 -0
  88. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -0
  89. package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +39 -0
  90. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +51 -0
  91. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -0
  92. package/glTF/2.0/Extensions/EXT_texture_avif.d.ts +34 -0
  93. package/glTF/2.0/Extensions/EXT_texture_avif.js +39 -0
  94. package/glTF/2.0/Extensions/EXT_texture_avif.js.map +1 -0
  95. package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +33 -0
  96. package/glTF/2.0/Extensions/EXT_texture_webp.js +38 -0
  97. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -0
  98. package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +48 -0
  99. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +63 -0
  100. package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -0
  101. package/glTF/2.0/Extensions/KHR_animation_pointer.d.ts +47 -0
  102. package/glTF/2.0/Extensions/KHR_animation_pointer.data.d.ts +1 -0
  103. package/glTF/2.0/Extensions/KHR_animation_pointer.data.js +239 -0
  104. package/glTF/2.0/Extensions/KHR_animation_pointer.data.js.map +1 -0
  105. package/glTF/2.0/Extensions/KHR_animation_pointer.js +78 -0
  106. package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -0
  107. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +47 -0
  108. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +93 -0
  109. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -0
  110. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.d.ts +352 -0
  111. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js +1700 -0
  112. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js.map +1 -0
  113. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.d.ts +33 -0
  114. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.js +20 -0
  115. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.js.map +1 -0
  116. package/glTF/2.0/Extensions/KHR_interactivity/index.d.ts +3 -0
  117. package/glTF/2.0/Extensions/KHR_interactivity/index.js +4 -0
  118. package/glTF/2.0/Extensions/KHR_interactivity/index.js.map +1 -0
  119. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.d.ts +70 -0
  120. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +450 -0
  121. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -0
  122. package/glTF/2.0/Extensions/KHR_interactivity.d.ts +38 -0
  123. package/glTF/2.0/Extensions/KHR_interactivity.js +151 -0
  124. package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -0
  125. package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +41 -0
  126. package/glTF/2.0/Extensions/KHR_lights_punctual.js +92 -0
  127. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -0
  128. package/glTF/2.0/Extensions/KHR_materials_anisotropy.d.ts +42 -0
  129. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js +61 -0
  130. package/glTF/2.0/Extensions/KHR_materials_anisotropy.js.map +1 -0
  131. package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +43 -0
  132. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +94 -0
  133. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -0
  134. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.d.ts +43 -0
  135. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +95 -0
  136. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -0
  137. package/glTF/2.0/Extensions/KHR_materials_dispersion.d.ts +43 -0
  138. package/glTF/2.0/Extensions/KHR_materials_dispersion.js +60 -0
  139. package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -0
  140. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +42 -0
  141. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +52 -0
  142. package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -0
  143. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +46 -0
  144. package/glTF/2.0/Extensions/KHR_materials_ior.js +62 -0
  145. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -0
  146. package/glTF/2.0/Extensions/KHR_materials_iridescence.d.ts +42 -0
  147. package/glTF/2.0/Extensions/KHR_materials_iridescence.js +71 -0
  148. package/glTF/2.0/Extensions/KHR_materials_iridescence.js.map +1 -0
  149. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +42 -0
  150. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +81 -0
  151. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -0
  152. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +43 -0
  153. package/glTF/2.0/Extensions/KHR_materials_sheen.js +85 -0
  154. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -0
  155. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +42 -0
  156. package/glTF/2.0/Extensions/KHR_materials_specular.js +85 -0
  157. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -0
  158. package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +42 -0
  159. package/glTF/2.0/Extensions/KHR_materials_transmission.js +306 -0
  160. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -0
  161. package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +42 -0
  162. package/glTF/2.0/Extensions/KHR_materials_unlit.js +73 -0
  163. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -0
  164. package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +112 -0
  165. package/glTF/2.0/Extensions/KHR_materials_variants.js +263 -0
  166. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -0
  167. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +43 -0
  168. package/glTF/2.0/Extensions/KHR_materials_volume.js +86 -0
  169. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -0
  170. package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +29 -0
  171. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +23 -0
  172. package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -0
  173. package/glTF/2.0/Extensions/KHR_node_hoverability.d.ts +31 -0
  174. package/glTF/2.0/Extensions/KHR_node_hoverability.js +190 -0
  175. package/glTF/2.0/Extensions/KHR_node_hoverability.js.map +1 -0
  176. package/glTF/2.0/Extensions/KHR_node_selectability.d.ts +30 -0
  177. package/glTF/2.0/Extensions/KHR_node_selectability.js +124 -0
  178. package/glTF/2.0/Extensions/KHR_node_selectability.js.map +1 -0
  179. package/glTF/2.0/Extensions/KHR_node_visibility.d.ts +30 -0
  180. package/glTF/2.0/Extensions/KHR_node_visibility.js +69 -0
  181. package/glTF/2.0/Extensions/KHR_node_visibility.js.map +1 -0
  182. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +33 -0
  183. package/glTF/2.0/Extensions/KHR_texture_basisu.js +38 -0
  184. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -0
  185. package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +37 -0
  186. package/glTF/2.0/Extensions/KHR_texture_transform.js +59 -0
  187. package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -0
  188. package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +39 -0
  189. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +48 -0
  190. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -0
  191. package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +56 -0
  192. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +227 -0
  193. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -0
  194. package/glTF/2.0/Extensions/MSFT_lod.d.ts +104 -0
  195. package/glTF/2.0/Extensions/MSFT_lod.js +338 -0
  196. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -0
  197. package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +27 -0
  198. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +41 -0
  199. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -0
  200. package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +27 -0
  201. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +42 -0
  202. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -0
  203. package/glTF/2.0/Extensions/dynamic.d.ts +4 -0
  204. package/glTF/2.0/Extensions/dynamic.js +156 -0
  205. package/glTF/2.0/Extensions/dynamic.js.map +1 -0
  206. package/glTF/2.0/Extensions/gltfPathToObjectConverter.d.ts +45 -0
  207. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js +101 -0
  208. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js.map +1 -0
  209. package/glTF/2.0/Extensions/index.d.ts +39 -0
  210. package/glTF/2.0/Extensions/index.js +41 -0
  211. package/glTF/2.0/Extensions/index.js.map +1 -0
  212. package/glTF/2.0/Extensions/objectModelMapping.d.ts +289 -0
  213. package/glTF/2.0/Extensions/objectModelMapping.js +828 -0
  214. package/glTF/2.0/Extensions/objectModelMapping.js.map +1 -0
  215. package/glTF/2.0/glTFLoader.d.ts +429 -0
  216. package/glTF/2.0/glTFLoader.js +2408 -0
  217. package/glTF/2.0/glTFLoader.js.map +1 -0
  218. package/glTF/2.0/glTFLoaderAnimation.d.ts +42 -0
  219. package/glTF/2.0/glTFLoaderAnimation.js +80 -0
  220. package/glTF/2.0/glTFLoaderAnimation.js.map +1 -0
  221. package/glTF/2.0/glTFLoaderExtension.d.ts +165 -0
  222. package/glTF/2.0/glTFLoaderExtension.js +2 -0
  223. package/glTF/2.0/glTFLoaderExtension.js.map +1 -0
  224. package/glTF/2.0/glTFLoaderExtensionRegistry.d.ts +25 -0
  225. package/glTF/2.0/glTFLoaderExtensionRegistry.js +33 -0
  226. package/glTF/2.0/glTFLoaderExtensionRegistry.js.map +1 -0
  227. package/glTF/2.0/glTFLoaderInterfaces.d.ts +257 -0
  228. package/glTF/2.0/glTFLoaderInterfaces.js +2 -0
  229. package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -0
  230. package/glTF/2.0/index.d.ts +6 -0
  231. package/glTF/2.0/index.js +8 -0
  232. package/glTF/2.0/index.js.map +1 -0
  233. package/glTF/glTFFileLoader.d.ts +516 -0
  234. package/glTF/glTFFileLoader.js +968 -0
  235. package/glTF/glTFFileLoader.js.map +1 -0
  236. package/glTF/glTFFileLoader.metadata.d.ts +15 -0
  237. package/glTF/glTFFileLoader.metadata.js +18 -0
  238. package/glTF/glTFFileLoader.metadata.js.map +1 -0
  239. package/glTF/glTFValidation.d.ts +29 -0
  240. package/glTF/glTFValidation.js +126 -0
  241. package/glTF/glTFValidation.js.map +1 -0
  242. package/glTF/index.d.ts +5 -0
  243. package/glTF/index.js +7 -0
  244. package/glTF/index.js.map +1 -0
  245. package/index.d.ts +5 -0
  246. package/index.js +7 -0
  247. package/index.js.map +1 -0
  248. package/legacy/legacy-bvhFileLoader.d.ts +1 -0
  249. package/legacy/legacy-bvhFileLoader.js +16 -0
  250. package/legacy/legacy-bvhFileLoader.js.map +1 -0
  251. package/legacy/legacy-glTF.d.ts +2 -0
  252. package/legacy/legacy-glTF.js +19 -0
  253. package/legacy/legacy-glTF.js.map +1 -0
  254. package/legacy/legacy-glTF1.d.ts +2 -0
  255. package/legacy/legacy-glTF1.js +16 -0
  256. package/legacy/legacy-glTF1.js.map +1 -0
  257. package/legacy/legacy-glTF1FileLoader.d.ts +2 -0
  258. package/legacy/legacy-glTF1FileLoader.js +4 -0
  259. package/legacy/legacy-glTF1FileLoader.js.map +1 -0
  260. package/legacy/legacy-glTF2.d.ts +2 -0
  261. package/legacy/legacy-glTF2.js +35 -0
  262. package/legacy/legacy-glTF2.js.map +1 -0
  263. package/legacy/legacy-glTF2FileLoader.d.ts +2 -0
  264. package/legacy/legacy-glTF2FileLoader.js +4 -0
  265. package/legacy/legacy-glTF2FileLoader.js.map +1 -0
  266. package/legacy/legacy-glTFFileLoader.d.ts +3 -0
  267. package/legacy/legacy-glTFFileLoader.js +5 -0
  268. package/legacy/legacy-glTFFileLoader.js.map +1 -0
  269. package/legacy/legacy-objFileLoader.d.ts +1 -0
  270. package/legacy/legacy-objFileLoader.js +16 -0
  271. package/legacy/legacy-objFileLoader.js.map +1 -0
  272. package/legacy/legacy-stlFileLoader.d.ts +1 -0
  273. package/legacy/legacy-stlFileLoader.js +16 -0
  274. package/legacy/legacy-stlFileLoader.js.map +1 -0
  275. package/legacy/legacy.d.ts +7 -0
  276. package/legacy/legacy.js +10 -0
  277. package/legacy/legacy.js.map +1 -0
  278. package/license.md +71 -0
  279. package/package.json +49 -0
  280. package/readme.md +23 -0
@@ -0,0 +1,828 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import { Matrix, Quaternion, Vector2 } from "@babylonjs/core/Maths/math.vector.js";
3
+ import { Constants } from "@babylonjs/core/Engines/constants.js";
4
+ import { Color4 } from "@babylonjs/core/Maths/math.color.js";
5
+ import { SpotLight } from "@babylonjs/core/Lights/spotLight.js";
6
+ import { GLTFPathToObjectConverter } from "./gltfPathToObjectConverter.js";
7
+ const nodesTree = {
8
+ length: {
9
+ type: "number",
10
+ get: (nodes) => nodes.length,
11
+ getTarget: (nodes) => nodes.map((node) => node._babylonTransformNode),
12
+ getPropertyName: [() => "length"],
13
+ },
14
+ __array__: {
15
+ __target__: true,
16
+ translation: {
17
+ type: "Vector3",
18
+ get: (node) => node._babylonTransformNode?.position,
19
+ set: (value, node) => node._babylonTransformNode?.position.copyFrom(value),
20
+ getTarget: (node) => node._babylonTransformNode,
21
+ getPropertyName: [() => "position"],
22
+ },
23
+ rotation: {
24
+ type: "Quaternion",
25
+ get: (node) => node._babylonTransformNode?.rotationQuaternion,
26
+ set: (value, node) => node._babylonTransformNode?.rotationQuaternion?.copyFrom(value),
27
+ getTarget: (node) => node._babylonTransformNode,
28
+ getPropertyName: [() => "rotationQuaternion"],
29
+ },
30
+ scale: {
31
+ type: "Vector3",
32
+ get: (node) => node._babylonTransformNode?.scaling,
33
+ set: (value, node) => node._babylonTransformNode?.scaling.copyFrom(value),
34
+ getTarget: (node) => node._babylonTransformNode,
35
+ getPropertyName: [() => "scaling"],
36
+ },
37
+ weights: {
38
+ length: {
39
+ type: "number",
40
+ get: (node) => node._numMorphTargets,
41
+ getTarget: (node) => node._babylonTransformNode,
42
+ getPropertyName: [() => "influence"],
43
+ },
44
+ __array__: {
45
+ __target__: true,
46
+ type: "number",
47
+ get: (node, index) => (index !== undefined ? node._primitiveBabylonMeshes?.[0].morphTargetManager?.getTarget(index).influence : undefined),
48
+ // set: (value: number, node: INode, index?: number) => node._babylonTransformNode?.getMorphTargetManager()?.getTarget(index)?.setInfluence(value),
49
+ getTarget: (node) => node._babylonTransformNode,
50
+ getPropertyName: [() => "influence"],
51
+ },
52
+ type: "number[]",
53
+ get: (node, index) => [0], // TODO: get the weights correctly
54
+ // set: (value: number, node: INode, index?: number) => node._babylonTransformNode?.getMorphTargetManager()?.getTarget(index)?.setInfluence(value),
55
+ getTarget: (node) => node._babylonTransformNode,
56
+ getPropertyName: [() => "influence"],
57
+ },
58
+ // readonly!
59
+ matrix: {
60
+ type: "Matrix",
61
+ get: (node) => Matrix.Compose(node._babylonTransformNode?.scaling, node._babylonTransformNode?.rotationQuaternion, node._babylonTransformNode?.position),
62
+ getTarget: (node) => node._babylonTransformNode,
63
+ isReadOnly: true,
64
+ },
65
+ globalMatrix: {
66
+ type: "Matrix",
67
+ get: (node) => {
68
+ const matrix = Matrix.Identity();
69
+ // RHS/LHS support
70
+ let rootNode = node.parent;
71
+ while (rootNode && rootNode.parent) {
72
+ rootNode = rootNode.parent;
73
+ }
74
+ const forceUpdate = node._babylonTransformNode?.position._isDirty || node._babylonTransformNode?.rotationQuaternion?._isDirty || node._babylonTransformNode?.scaling._isDirty;
75
+ if (rootNode) {
76
+ // take the parent root node's world matrix, invert it, and multiply it with the current node's world matrix
77
+ // This will provide the global matrix, ignoring the RHS->LHS conversion
78
+ const rootMatrix = rootNode._babylonTransformNode?.computeWorldMatrix(true).invert();
79
+ if (rootMatrix) {
80
+ node._babylonTransformNode?.computeWorldMatrix(forceUpdate)?.multiplyToRef(rootMatrix, matrix);
81
+ }
82
+ }
83
+ else if (node._babylonTransformNode) {
84
+ matrix.copyFrom(node._babylonTransformNode.computeWorldMatrix(forceUpdate));
85
+ }
86
+ return matrix;
87
+ },
88
+ getTarget: (node) => node._babylonTransformNode,
89
+ isReadOnly: true,
90
+ },
91
+ extensions: {
92
+ EXT_lights_ies: {
93
+ multiplier: {
94
+ type: "number",
95
+ get: (node) => {
96
+ return node._babylonTransformNode?.getChildren((child) => child instanceof SpotLight, true)[0]?.intensity;
97
+ },
98
+ getTarget: (node) => node._babylonTransformNode?.getChildren((child) => child instanceof SpotLight, true)[0],
99
+ set: (value, node) => {
100
+ if (node._babylonTransformNode) {
101
+ const light = node._babylonTransformNode.getChildren((child) => child instanceof SpotLight, true)[0];
102
+ if (light) {
103
+ light.intensity = value;
104
+ }
105
+ }
106
+ },
107
+ },
108
+ color: {
109
+ type: "Color3",
110
+ get: (node) => {
111
+ return node._babylonTransformNode?.getChildren((child) => child instanceof SpotLight, true)[0]?.diffuse;
112
+ },
113
+ getTarget: (node) => node._babylonTransformNode?.getChildren((child) => child instanceof SpotLight, true)[0],
114
+ set: (value, node) => {
115
+ if (node._babylonTransformNode) {
116
+ const light = node._babylonTransformNode.getChildren((child) => child instanceof SpotLight, true)[0];
117
+ if (light) {
118
+ light.diffuse = value;
119
+ }
120
+ }
121
+ },
122
+ },
123
+ },
124
+ },
125
+ },
126
+ };
127
+ const animationsTree = {
128
+ length: {
129
+ type: "number",
130
+ get: (animations) => animations.length,
131
+ getTarget: (animations) => animations.map((animation) => animation._babylonAnimationGroup),
132
+ getPropertyName: [() => "length"],
133
+ },
134
+ __array__: {},
135
+ };
136
+ const meshesTree = {
137
+ length: {
138
+ type: "number",
139
+ get: (meshes) => meshes.length,
140
+ getTarget: (meshes) => meshes.map((mesh) => mesh.primitives[0]._instanceData?.babylonSourceMesh),
141
+ getPropertyName: [() => "length"],
142
+ },
143
+ __array__: {},
144
+ };
145
+ const camerasTree = {
146
+ __array__: {
147
+ __target__: true,
148
+ orthographic: {
149
+ xmag: {
150
+ componentsCount: 2,
151
+ type: "Vector2",
152
+ get: (camera) => new Vector2(camera._babylonCamera?.orthoLeft ?? 0, camera._babylonCamera?.orthoRight ?? 0),
153
+ set: (value, camera) => {
154
+ if (camera._babylonCamera) {
155
+ camera._babylonCamera.orthoLeft = value.x;
156
+ camera._babylonCamera.orthoRight = value.y;
157
+ }
158
+ },
159
+ getTarget: (camera) => camera,
160
+ getPropertyName: [() => "orthoLeft", () => "orthoRight"],
161
+ },
162
+ ymag: {
163
+ componentsCount: 2,
164
+ type: "Vector2",
165
+ get: (camera) => new Vector2(camera._babylonCamera?.orthoBottom ?? 0, camera._babylonCamera?.orthoTop ?? 0),
166
+ set: (value, camera) => {
167
+ if (camera._babylonCamera) {
168
+ camera._babylonCamera.orthoBottom = value.x;
169
+ camera._babylonCamera.orthoTop = value.y;
170
+ }
171
+ },
172
+ getTarget: (camera) => camera,
173
+ getPropertyName: [() => "orthoBottom", () => "orthoTop"],
174
+ },
175
+ zfar: {
176
+ type: "number",
177
+ get: (camera) => camera._babylonCamera?.maxZ,
178
+ set: (value, camera) => {
179
+ if (camera._babylonCamera) {
180
+ camera._babylonCamera.maxZ = value;
181
+ }
182
+ },
183
+ getTarget: (camera) => camera,
184
+ getPropertyName: [() => "maxZ"],
185
+ },
186
+ znear: {
187
+ type: "number",
188
+ get: (camera) => camera._babylonCamera?.minZ,
189
+ set: (value, camera) => {
190
+ if (camera._babylonCamera) {
191
+ camera._babylonCamera.minZ = value;
192
+ }
193
+ },
194
+ getTarget: (camera) => camera,
195
+ getPropertyName: [() => "minZ"],
196
+ },
197
+ },
198
+ perspective: {
199
+ aspectRatio: {
200
+ type: "number",
201
+ get: (camera) => camera._babylonCamera?.getEngine().getAspectRatio(camera._babylonCamera),
202
+ getTarget: (camera) => camera,
203
+ getPropertyName: [() => "aspectRatio"],
204
+ isReadOnly: true, // might not be the case for glTF?
205
+ },
206
+ yfov: {
207
+ type: "number",
208
+ get: (camera) => camera._babylonCamera?.fov,
209
+ set: (value, camera) => {
210
+ if (camera._babylonCamera) {
211
+ camera._babylonCamera.fov = value;
212
+ }
213
+ },
214
+ getTarget: (camera) => camera,
215
+ getPropertyName: [() => "fov"],
216
+ },
217
+ zfar: {
218
+ type: "number",
219
+ get: (camera) => camera._babylonCamera?.maxZ,
220
+ set: (value, camera) => {
221
+ if (camera._babylonCamera) {
222
+ camera._babylonCamera.maxZ = value;
223
+ }
224
+ },
225
+ getTarget: (camera) => camera,
226
+ getPropertyName: [() => "maxZ"],
227
+ },
228
+ znear: {
229
+ type: "number",
230
+ get: (camera) => camera._babylonCamera?.minZ,
231
+ set: (value, camera) => {
232
+ if (camera._babylonCamera) {
233
+ camera._babylonCamera.minZ = value;
234
+ }
235
+ },
236
+ getTarget: (camera) => camera,
237
+ getPropertyName: [() => "minZ"],
238
+ },
239
+ },
240
+ },
241
+ };
242
+ const materialsTree = {
243
+ __array__: {
244
+ __target__: true,
245
+ emissiveFactor: {
246
+ type: "Color3",
247
+ get: (material, index, payload) => GetMaterial(material, index, payload).emissiveColor,
248
+ set: (value, material, index, payload) => GetMaterial(material, index, payload).emissiveColor.copyFrom(value),
249
+ getTarget: (material, index, payload) => GetMaterial(material, index, payload),
250
+ getPropertyName: [() => "emissiveColor"],
251
+ },
252
+ emissiveTexture: {
253
+ extensions: {
254
+ KHR_texture_transform: GenerateTextureMap("emissiveTexture"),
255
+ },
256
+ },
257
+ normalTexture: {
258
+ scale: {
259
+ type: "number",
260
+ get: (material, index, payload) => GetTexture(material, payload, "bumpTexture")?.level,
261
+ set: (value, material, index, payload) => {
262
+ const texture = GetTexture(material, payload, "bumpTexture");
263
+ if (texture) {
264
+ texture.level = value;
265
+ }
266
+ },
267
+ getTarget: (material, index, payload) => GetMaterial(material, index, payload),
268
+ getPropertyName: [() => "level"],
269
+ },
270
+ extensions: {
271
+ KHR_texture_transform: GenerateTextureMap("bumpTexture"),
272
+ },
273
+ },
274
+ occlusionTexture: {
275
+ strength: {
276
+ type: "number",
277
+ get: (material, index, payload) => GetMaterial(material, index, payload).ambientTextureStrength,
278
+ set: (value, material, index, payload) => {
279
+ const mat = GetMaterial(material, index, payload);
280
+ if (mat) {
281
+ mat.ambientTextureStrength = value;
282
+ }
283
+ },
284
+ getTarget: (material, index, payload) => GetMaterial(material, index, payload),
285
+ getPropertyName: [() => "ambientTextureStrength"],
286
+ },
287
+ extensions: {
288
+ KHR_texture_transform: GenerateTextureMap("ambientTexture"),
289
+ },
290
+ },
291
+ pbrMetallicRoughness: {
292
+ baseColorFactor: {
293
+ type: "Color4",
294
+ get: (material, index, payload) => {
295
+ const mat = GetMaterial(material, index, payload);
296
+ return Color4.FromColor3(mat.albedoColor, mat.alpha);
297
+ },
298
+ set: (value, material, index, payload) => {
299
+ const mat = GetMaterial(material, index, payload);
300
+ mat.albedoColor.set(value.r, value.g, value.b);
301
+ mat.alpha = value.a;
302
+ },
303
+ getTarget: (material, index, payload) => GetMaterial(material, index, payload),
304
+ // This is correct on the animation level, but incorrect as a single property of a type Color4
305
+ getPropertyName: [() => "albedoColor", () => "alpha"],
306
+ },
307
+ baseColorTexture: {
308
+ extensions: {
309
+ KHR_texture_transform: GenerateTextureMap("albedoTexture"),
310
+ },
311
+ },
312
+ metallicFactor: {
313
+ type: "number",
314
+ get: (material, index, payload) => GetMaterial(material, index, payload).metallic,
315
+ set: (value, material, index, payload) => {
316
+ const mat = GetMaterial(material, index, payload);
317
+ if (mat) {
318
+ mat.metallic = value;
319
+ }
320
+ },
321
+ getTarget: (material, index, payload) => GetMaterial(material, index, payload),
322
+ getPropertyName: [() => "metallic"],
323
+ },
324
+ roughnessFactor: {
325
+ type: "number",
326
+ get: (material, index, payload) => GetMaterial(material, index, payload).roughness,
327
+ set: (value, material, index, payload) => {
328
+ const mat = GetMaterial(material, index, payload);
329
+ if (mat) {
330
+ mat.roughness = value;
331
+ }
332
+ },
333
+ getTarget: (material, index, payload) => GetMaterial(material, index, payload),
334
+ getPropertyName: [() => "roughness"],
335
+ },
336
+ metallicRoughnessTexture: {
337
+ extensions: {
338
+ KHR_texture_transform: GenerateTextureMap("metallicTexture"),
339
+ },
340
+ },
341
+ },
342
+ extensions: {
343
+ KHR_materials_anisotropy: {
344
+ anisotropyStrength: {
345
+ type: "number",
346
+ get: (material, index, payload) => GetMaterial(material, index, payload).anisotropy.intensity,
347
+ set: (value, material, index, payload) => {
348
+ GetMaterial(material, index, payload).anisotropy.intensity = value;
349
+ },
350
+ getTarget: (material, index, payload) => GetMaterial(material, index, payload),
351
+ getPropertyName: [() => "anisotropy.intensity"],
352
+ },
353
+ anisotropyRotation: {
354
+ type: "number",
355
+ get: (material, index, payload) => GetMaterial(material, index, payload).anisotropy.angle,
356
+ set: (value, material, index, payload) => {
357
+ GetMaterial(material, index, payload).anisotropy.angle = value;
358
+ },
359
+ getTarget: (material, index, payload) => GetMaterial(material, index, payload),
360
+ getPropertyName: [() => "anisotropy.angle"],
361
+ },
362
+ anisotropyTexture: {
363
+ extensions: {
364
+ KHR_texture_transform: GenerateTextureMap("anisotropy", "texture"),
365
+ },
366
+ },
367
+ },
368
+ KHR_materials_clearcoat: {
369
+ clearcoatFactor: {
370
+ type: "number",
371
+ get: (material, index, payload) => GetMaterial(material, index, payload).clearCoat.intensity,
372
+ set: (value, material, index, payload) => {
373
+ GetMaterial(material, index, payload).clearCoat.intensity = value;
374
+ },
375
+ getTarget: (material, index, payload) => GetMaterial(material, index, payload),
376
+ getPropertyName: [() => "clearCoat.intensity"],
377
+ },
378
+ clearcoatRoughnessFactor: {
379
+ type: "number",
380
+ get: (material, index, payload) => GetMaterial(material, index, payload).clearCoat.roughness,
381
+ set: (value, material, index, payload) => {
382
+ GetMaterial(material, index, payload).clearCoat.roughness = value;
383
+ },
384
+ getTarget: (material, index, payload) => GetMaterial(material, index, payload),
385
+ getPropertyName: [() => "clearCoat.roughness"],
386
+ },
387
+ clearcoatTexture: {
388
+ extensions: {
389
+ KHR_texture_transform: GenerateTextureMap("clearCoat", "texture"),
390
+ },
391
+ },
392
+ clearcoatNormalTexture: {
393
+ scale: {
394
+ type: "number",
395
+ get: (material, index, payload) => GetMaterial(material, index, payload).clearCoat.bumpTexture?.level,
396
+ getTarget: GetMaterial,
397
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).clearCoat.bumpTexture.level = value),
398
+ },
399
+ extensions: {
400
+ KHR_texture_transform: GenerateTextureMap("clearCoat", "bumpTexture"),
401
+ },
402
+ },
403
+ clearcoatRoughnessTexture: {
404
+ extensions: {
405
+ KHR_texture_transform: GenerateTextureMap("clearCoat", "textureRoughness"),
406
+ },
407
+ },
408
+ },
409
+ KHR_materials_dispersion: {
410
+ dispersion: {
411
+ type: "number",
412
+ get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.dispersion,
413
+ getTarget: GetMaterial,
414
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).subSurface.dispersion = value),
415
+ },
416
+ },
417
+ KHR_materials_emissive_strength: {
418
+ emissiveStrength: {
419
+ type: "number",
420
+ get: (material, index, payload) => GetMaterial(material, index, payload).emissiveIntensity,
421
+ getTarget: GetMaterial,
422
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).emissiveIntensity = value),
423
+ },
424
+ },
425
+ KHR_materials_ior: {
426
+ ior: {
427
+ type: "number",
428
+ get: (material, index, payload) => GetMaterial(material, index, payload).indexOfRefraction,
429
+ getTarget: GetMaterial,
430
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).indexOfRefraction = value),
431
+ },
432
+ },
433
+ KHR_materials_iridescence: {
434
+ iridescenceFactor: {
435
+ type: "number",
436
+ get: (material, index, payload) => GetMaterial(material, index, payload).iridescence.intensity,
437
+ getTarget: GetMaterial,
438
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).iridescence.intensity = value),
439
+ },
440
+ iridescenceIor: {
441
+ type: "number",
442
+ get: (material, index, payload) => GetMaterial(material, index, payload).iridescence.indexOfRefraction,
443
+ getTarget: GetMaterial,
444
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).iridescence.indexOfRefraction = value),
445
+ },
446
+ iridescenceTexture: {
447
+ extensions: {
448
+ KHR_texture_transform: GenerateTextureMap("iridescence", "texture"),
449
+ },
450
+ },
451
+ iridescenceThicknessMaximum: {
452
+ type: "number",
453
+ get: (material, index, payload) => GetMaterial(material, index, payload).iridescence.maximumThickness,
454
+ getTarget: GetMaterial,
455
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).iridescence.maximumThickness = value),
456
+ },
457
+ iridescenceThicknessMinimum: {
458
+ type: "number",
459
+ get: (material, index, payload) => GetMaterial(material, index, payload).iridescence.minimumThickness,
460
+ getTarget: GetMaterial,
461
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).iridescence.minimumThickness = value),
462
+ },
463
+ iridescenceThicknessTexture: {
464
+ extensions: {
465
+ KHR_texture_transform: GenerateTextureMap("iridescence", "thicknessTexture"),
466
+ },
467
+ },
468
+ },
469
+ KHR_materials_sheen: {
470
+ sheenColorFactor: {
471
+ type: "Color3",
472
+ get: (material, index, payload) => GetMaterial(material, index, payload).sheen.color,
473
+ getTarget: GetMaterial,
474
+ set: (value, material, index, payload) => GetMaterial(material, index, payload).sheen.color.copyFrom(value),
475
+ },
476
+ sheenColorTexture: {
477
+ extensions: {
478
+ KHR_texture_transform: GenerateTextureMap("sheen", "texture"),
479
+ },
480
+ },
481
+ sheenRoughnessFactor: {
482
+ type: "number",
483
+ get: (material, index, payload) => GetMaterial(material, index, payload).sheen.intensity,
484
+ getTarget: GetMaterial,
485
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).sheen.intensity = value),
486
+ },
487
+ sheenRoughnessTexture: {
488
+ extensions: {
489
+ KHR_texture_transform: GenerateTextureMap("sheen", "thicknessTexture"),
490
+ },
491
+ },
492
+ },
493
+ KHR_materials_specular: {
494
+ specularFactor: {
495
+ type: "number",
496
+ get: (material, index, payload) => GetMaterial(material, index, payload).metallicF0Factor,
497
+ getTarget: GetMaterial,
498
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).metallicF0Factor = value),
499
+ getPropertyName: [() => "metallicF0Factor"],
500
+ },
501
+ specularColorFactor: {
502
+ type: "Color3",
503
+ get: (material, index, payload) => GetMaterial(material, index, payload).metallicReflectanceColor,
504
+ getTarget: GetMaterial,
505
+ set: (value, material, index, payload) => GetMaterial(material, index, payload).metallicReflectanceColor.copyFrom(value),
506
+ getPropertyName: [() => "metallicReflectanceColor"],
507
+ },
508
+ specularTexture: {
509
+ extensions: {
510
+ KHR_texture_transform: GenerateTextureMap("metallicReflectanceTexture"),
511
+ },
512
+ },
513
+ specularColorTexture: {
514
+ extensions: {
515
+ KHR_texture_transform: GenerateTextureMap("reflectanceTexture"),
516
+ },
517
+ },
518
+ },
519
+ KHR_materials_transmission: {
520
+ transmissionFactor: {
521
+ type: "number",
522
+ get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.refractionIntensity,
523
+ getTarget: GetMaterial,
524
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).subSurface.refractionIntensity = value),
525
+ getPropertyName: [() => "subSurface.refractionIntensity"],
526
+ },
527
+ transmissionTexture: {
528
+ extensions: {
529
+ KHR_texture_transform: GenerateTextureMap("subSurface", "refractionIntensityTexture"),
530
+ },
531
+ },
532
+ },
533
+ KHR_materials_diffuse_transmission: {
534
+ diffuseTransmissionFactor: {
535
+ type: "number",
536
+ get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.translucencyIntensity,
537
+ getTarget: GetMaterial,
538
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).subSurface.translucencyIntensity = value),
539
+ },
540
+ diffuseTransmissionTexture: {
541
+ extensions: {
542
+ KHR_texture_transform: GenerateTextureMap("subSurface", "translucencyIntensityTexture"),
543
+ },
544
+ },
545
+ diffuseTransmissionColorFactor: {
546
+ type: "Color3",
547
+ get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.translucencyColor,
548
+ getTarget: GetMaterial,
549
+ set: (value, material, index, payload) => value && GetMaterial(material, index, payload).subSurface.translucencyColor?.copyFrom(value),
550
+ },
551
+ diffuseTransmissionColorTexture: {
552
+ extensions: {
553
+ KHR_texture_transform: GenerateTextureMap("subSurface", "translucencyColorTexture"),
554
+ },
555
+ },
556
+ },
557
+ KHR_materials_volume: {
558
+ attenuationColor: {
559
+ type: "Color3",
560
+ get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.tintColor,
561
+ getTarget: GetMaterial,
562
+ set: (value, material, index, payload) => GetMaterial(material, index, payload).subSurface.tintColor.copyFrom(value),
563
+ },
564
+ attenuationDistance: {
565
+ type: "number",
566
+ get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.tintColorAtDistance,
567
+ getTarget: GetMaterial,
568
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).subSurface.tintColorAtDistance = value),
569
+ },
570
+ thicknessFactor: {
571
+ type: "number",
572
+ get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.maximumThickness,
573
+ getTarget: GetMaterial,
574
+ set: (value, material, index, payload) => (GetMaterial(material, index, payload).subSurface.maximumThickness = value),
575
+ },
576
+ thicknessTexture: {
577
+ extensions: {
578
+ KHR_texture_transform: GenerateTextureMap("subSurface", "thicknessTexture"),
579
+ },
580
+ },
581
+ },
582
+ },
583
+ },
584
+ };
585
+ const extensionsTree = {
586
+ KHR_lights_punctual: {
587
+ lights: {
588
+ length: {
589
+ type: "number",
590
+ get: (lights) => lights.length,
591
+ getTarget: (lights) => lights.map((light) => light._babylonLight),
592
+ getPropertyName: [(_lights) => "length"],
593
+ },
594
+ __array__: {
595
+ __target__: true,
596
+ color: {
597
+ type: "Color3",
598
+ get: (light) => light._babylonLight?.diffuse,
599
+ set: (value, light) => light._babylonLight?.diffuse.copyFrom(value),
600
+ getTarget: (light) => light._babylonLight,
601
+ getPropertyName: [(_light) => "diffuse"],
602
+ },
603
+ intensity: {
604
+ type: "number",
605
+ get: (light) => light._babylonLight?.intensity,
606
+ set: (value, light) => (light._babylonLight ? (light._babylonLight.intensity = value) : undefined),
607
+ getTarget: (light) => light._babylonLight,
608
+ getPropertyName: [(_light) => "intensity"],
609
+ },
610
+ range: {
611
+ type: "number",
612
+ get: (light) => light._babylonLight?.range,
613
+ set: (value, light) => (light._babylonLight ? (light._babylonLight.range = value) : undefined),
614
+ getTarget: (light) => light._babylonLight,
615
+ getPropertyName: [(_light) => "range"],
616
+ },
617
+ spot: {
618
+ innerConeAngle: {
619
+ type: "number",
620
+ get: (light) => light._babylonLight?.innerAngle,
621
+ set: (value, light) => (light._babylonLight ? (light._babylonLight.innerAngle = value) : undefined),
622
+ getTarget: (light) => light._babylonLight,
623
+ getPropertyName: [(_light) => "innerConeAngle"],
624
+ },
625
+ outerConeAngle: {
626
+ type: "number",
627
+ get: (light) => light._babylonLight?.angle,
628
+ set: (value, light) => (light._babylonLight ? (light._babylonLight.angle = value) : undefined),
629
+ getTarget: (light) => light._babylonLight,
630
+ getPropertyName: [(_light) => "outerConeAngle"],
631
+ },
632
+ },
633
+ },
634
+ },
635
+ },
636
+ EXT_lights_ies: {
637
+ lights: {
638
+ length: {
639
+ type: "number",
640
+ get: (lights) => lights.length,
641
+ getTarget: (lights) => lights.map((light) => light._babylonLight),
642
+ getPropertyName: [(_lights) => "length"],
643
+ },
644
+ },
645
+ },
646
+ EXT_lights_image_based: {
647
+ lights: {
648
+ length: {
649
+ type: "number",
650
+ get: (lights) => lights.length,
651
+ getTarget: (lights) => lights.map((light) => light._babylonTexture),
652
+ getPropertyName: [(_lights) => "length"],
653
+ },
654
+ __array__: {
655
+ __target__: true,
656
+ intensity: {
657
+ type: "number",
658
+ get: (light) => light._babylonTexture?.level,
659
+ set: (value, light) => {
660
+ if (light._babylonTexture) {
661
+ light._babylonTexture.level = value;
662
+ }
663
+ },
664
+ getTarget: (light) => light._babylonTexture,
665
+ },
666
+ rotation: {
667
+ type: "Quaternion",
668
+ get: (light) => light._babylonTexture && Quaternion.FromRotationMatrix(light._babylonTexture?.getReflectionTextureMatrix()),
669
+ set: (value, light) => {
670
+ if (!light._babylonTexture) {
671
+ return;
672
+ }
673
+ // Invert the rotation so that positive rotation is counter-clockwise.
674
+ if (!light._babylonTexture.getScene()?.useRightHandedSystem) {
675
+ value = Quaternion.Inverse(value);
676
+ }
677
+ Matrix.FromQuaternionToRef(value, light._babylonTexture.getReflectionTextureMatrix());
678
+ },
679
+ getTarget: (light) => light._babylonTexture,
680
+ },
681
+ },
682
+ },
683
+ },
684
+ };
685
+ function GetTexture(material, payload, textureType, textureInObject) {
686
+ const babylonMaterial = GetMaterial(material, payload);
687
+ return textureInObject ? babylonMaterial[textureType][textureInObject] : babylonMaterial[textureType];
688
+ }
689
+ function GetMaterial(material, _index, payload) {
690
+ return material._data?.[payload?.fillMode ?? Constants.MATERIAL_TriangleFillMode]?.babylonMaterial;
691
+ }
692
+ function GenerateTextureMap(textureType, textureInObject) {
693
+ return {
694
+ offset: {
695
+ componentsCount: 2,
696
+ // assuming two independent values for u and v, and NOT a Vector2
697
+ type: "Vector2",
698
+ get: (material, _index, payload) => {
699
+ const texture = GetTexture(material, payload, textureType, textureInObject);
700
+ return new Vector2(texture?.uOffset, texture?.vOffset);
701
+ },
702
+ getTarget: GetMaterial,
703
+ set: (value, material, _index, payload) => {
704
+ const texture = GetTexture(material, payload, textureType, textureInObject);
705
+ (texture.uOffset = value.x), (texture.vOffset = value.y);
706
+ },
707
+ getPropertyName: [
708
+ () => `${textureType}${textureInObject ? "." + textureInObject : ""}.uOffset`,
709
+ () => `${textureType}${textureInObject ? "." + textureInObject : ""}.vOffset`,
710
+ ],
711
+ },
712
+ rotation: {
713
+ type: "number",
714
+ get: (material, _index, payload) => GetTexture(material, payload, textureType, textureInObject)?.wAng,
715
+ getTarget: GetMaterial,
716
+ set: (value, material, _index, payload) => (GetTexture(material, payload, textureType, textureInObject).wAng = value),
717
+ getPropertyName: [() => `${textureType}${textureInObject ? "." + textureInObject : ""}.wAng`],
718
+ },
719
+ scale: {
720
+ componentsCount: 2,
721
+ type: "Vector2",
722
+ get: (material, _index, payload) => {
723
+ const texture = GetTexture(material, payload, textureType, textureInObject);
724
+ return new Vector2(texture?.uScale, texture?.vScale);
725
+ },
726
+ getTarget: GetMaterial,
727
+ set: (value, material, index, payload) => {
728
+ const texture = GetTexture(material, payload, textureType, textureInObject);
729
+ (texture.uScale = value.x), (texture.vScale = value.y);
730
+ },
731
+ getPropertyName: [
732
+ () => `${textureType}${textureInObject ? "." + textureInObject : ""}.uScale`,
733
+ () => `${textureType}${textureInObject ? "." + textureInObject : ""}.vScale`,
734
+ ],
735
+ },
736
+ };
737
+ }
738
+ const objectModelMapping = {
739
+ cameras: camerasTree,
740
+ nodes: nodesTree,
741
+ materials: materialsTree,
742
+ extensions: extensionsTree,
743
+ animations: animationsTree,
744
+ meshes: meshesTree,
745
+ };
746
+ /**
747
+ * get a path-to-object converter for the given glTF tree
748
+ * @param gltf the glTF tree to use
749
+ * @returns a path-to-object converter for the given glTF tree
750
+ */
751
+ export function GetPathToObjectConverter(gltf) {
752
+ return new GLTFPathToObjectConverter(gltf, objectModelMapping);
753
+ }
754
+ /**
755
+ * This function will return the object accessor for the given key in the object model
756
+ * If the key is not found, it will return undefined
757
+ * @param key the key to get the mapping for, for example /materials/\{\}/emissiveFactor
758
+ * @returns an object accessor for the given key, or undefined if the key is not found
759
+ */
760
+ export function GetMappingForKey(key) {
761
+ // replace every `{}` in key with __array__ to match the object model
762
+ const keyParts = key.split("/").map((part) => part.replace(/{}/g, "__array__"));
763
+ let current = objectModelMapping;
764
+ for (const part of keyParts) {
765
+ // make sure part is not empty
766
+ if (!part) {
767
+ continue;
768
+ }
769
+ current = current[part];
770
+ }
771
+ // validate that current is an object accessor
772
+ if (current && current.type && current.get) {
773
+ return current;
774
+ }
775
+ return undefined;
776
+ }
777
+ /**
778
+ * Set interpolation for a specific key in the object model
779
+ * @param key the key to set, for example /materials/\{\}/emissiveFactor
780
+ * @param interpolation the interpolation elements array
781
+ */
782
+ export function SetInterpolationForKey(key, interpolation) {
783
+ // replace every `{}` in key with __array__ to match the object model
784
+ const keyParts = key.split("/").map((part) => part.replace(/{}/g, "__array__"));
785
+ let current = objectModelMapping;
786
+ for (const part of keyParts) {
787
+ // make sure part is not empty
788
+ if (!part) {
789
+ continue;
790
+ }
791
+ current = current[part];
792
+ }
793
+ // validate that the current object is an object accessor
794
+ if (current && current.type && current.get) {
795
+ current.interpolation = interpolation;
796
+ }
797
+ }
798
+ /**
799
+ * This will ad a new object accessor in the object model at the given key.
800
+ * Note that this will NOT change the typescript types. To do that you will need to change the interface itself (extending it in the module that uses it)
801
+ * @param key the key to add the object accessor at. For example /cameras/\{\}/perspective/aspectRatio
802
+ * @param accessor the object accessor to add
803
+ */
804
+ export function AddObjectAccessorToKey(key, accessor) {
805
+ // replace every `{}` in key with __array__ to match the object model
806
+ const keyParts = key.split("/").map((part) => part.replace(/{}/g, "__array__"));
807
+ let current = objectModelMapping;
808
+ for (const part of keyParts) {
809
+ // make sure part is not empty
810
+ if (!part) {
811
+ continue;
812
+ }
813
+ if (!current[part]) {
814
+ if (part === "?") {
815
+ current.__ignoreObjectTree__ = true;
816
+ continue;
817
+ }
818
+ current[part] = {};
819
+ // if the part is __array__ then add the __target__ property
820
+ if (part === "__array__") {
821
+ current[part].__target__ = true;
822
+ }
823
+ }
824
+ current = current[part];
825
+ }
826
+ Object.assign(current, accessor);
827
+ }
828
+ //# sourceMappingURL=objectModelMapping.js.map