@combeenation/3d-viewer 5.1.2 → 5.2.0-alpha1

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 (322) hide show
  1. package/README.md +111 -111
  2. package/dist/lib-cjs/buildinfo.json +3 -3
  3. package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -0
  4. package/dist/lib-cjs/{api → src/api}/classes/animationInterface.d.ts +8 -8
  5. package/dist/lib-cjs/src/api/classes/animationInterface.js +3 -0
  6. package/dist/lib-cjs/src/api/classes/animationInterface.js.map +1 -0
  7. package/dist/{lib-es6 → lib-cjs/src}/api/classes/dottedPath.d.ts +79 -79
  8. package/dist/lib-cjs/src/api/classes/dottedPath.js +167 -0
  9. package/dist/lib-cjs/src/api/classes/dottedPath.js.map +1 -0
  10. package/dist/lib-cjs/{api → src/api}/classes/element.d.ts +149 -149
  11. package/dist/lib-cjs/src/api/classes/element.js +669 -0
  12. package/dist/lib-cjs/src/api/classes/element.js.map +1 -0
  13. package/dist/{lib-es6 → lib-cjs/src}/api/classes/event.d.ts +326 -326
  14. package/dist/lib-cjs/src/api/classes/event.js +350 -0
  15. package/dist/lib-cjs/src/api/classes/event.js.map +1 -0
  16. package/dist/{lib-es6 → lib-cjs/src}/api/classes/eventBroadcaster.d.ts +26 -26
  17. package/dist/lib-cjs/src/api/classes/eventBroadcaster.js +50 -0
  18. package/dist/lib-cjs/src/api/classes/eventBroadcaster.js.map +1 -0
  19. package/dist/{lib-es6 → lib-cjs/src}/api/classes/parameter.d.ts +336 -336
  20. package/dist/lib-cjs/src/api/classes/parameter.js +462 -0
  21. package/dist/lib-cjs/src/api/classes/parameter.js.map +1 -0
  22. package/dist/lib-cjs/{api → src/api}/classes/parameterObservable.d.ts +36 -36
  23. package/dist/lib-cjs/src/api/classes/parameterObservable.js +98 -0
  24. package/dist/lib-cjs/src/api/classes/parameterObservable.js.map +1 -0
  25. package/dist/lib-cjs/{api → src/api}/classes/parameterizable.d.ts +15 -15
  26. package/dist/lib-cjs/src/api/classes/parameterizable.js +103 -0
  27. package/dist/lib-cjs/src/api/classes/parameterizable.js.map +1 -0
  28. package/dist/lib-cjs/{api → src/api}/classes/placementAnimation.d.ts +45 -44
  29. package/dist/lib-cjs/{api → src/api}/classes/placementAnimation.js +175 -163
  30. package/dist/lib-cjs/src/api/classes/placementAnimation.js.map +1 -0
  31. package/dist/{lib-es6 → lib-cjs/src}/api/classes/variant.d.ts +234 -234
  32. package/dist/lib-cjs/src/api/classes/variant.js +837 -0
  33. package/dist/lib-cjs/src/api/classes/variant.js.map +1 -0
  34. package/dist/lib-cjs/{api → src/api}/classes/variantInstance.d.ts +45 -45
  35. package/dist/lib-cjs/src/api/classes/variantInstance.js +102 -0
  36. package/dist/lib-cjs/src/api/classes/variantInstance.js.map +1 -0
  37. package/dist/{lib-es6 → lib-cjs/src}/api/classes/variantParameterizable.d.ts +17 -17
  38. package/dist/lib-cjs/src/api/classes/variantParameterizable.js +89 -0
  39. package/dist/lib-cjs/src/api/classes/variantParameterizable.js.map +1 -0
  40. package/dist/lib-cjs/{api → src/api}/classes/viewer.d.ts +187 -184
  41. package/dist/lib-cjs/src/api/classes/viewer.js +594 -0
  42. package/dist/lib-cjs/src/api/classes/viewer.js.map +1 -0
  43. package/dist/lib-cjs/{api → src/api}/classes/viewerLight.d.ts +66 -66
  44. package/dist/lib-cjs/src/api/classes/viewerLight.js +344 -0
  45. package/dist/lib-cjs/src/api/classes/viewerLight.js.map +1 -0
  46. package/dist/{lib-es6 → lib-cjs/src}/api/internal/lensRendering.d.ts +8 -8
  47. package/dist/lib-cjs/{api → src/api}/internal/lensRendering.js +11 -11
  48. package/dist/lib-cjs/src/api/internal/lensRendering.js.map +1 -0
  49. package/dist/{lib-es6 → lib-cjs/src}/api/internal/sceneSetup.d.ts +13 -13
  50. package/dist/lib-cjs/src/api/internal/sceneSetup.js +226 -0
  51. package/dist/lib-cjs/src/api/internal/sceneSetup.js.map +1 -0
  52. package/dist/lib-cjs/{api → src/api}/manager/animationManager.d.ts +30 -29
  53. package/dist/lib-cjs/src/api/manager/animationManager.js +127 -0
  54. package/dist/lib-cjs/src/api/manager/animationManager.js.map +1 -0
  55. package/dist/lib-cjs/{api → src/api}/manager/gltfExportManager.d.ts +65 -65
  56. package/dist/lib-cjs/src/api/manager/gltfExportManager.js +197 -0
  57. package/dist/lib-cjs/src/api/manager/gltfExportManager.js.map +1 -0
  58. package/dist/lib-cjs/{api → src/api}/manager/sceneManager.d.ts +31 -31
  59. package/dist/lib-cjs/src/api/manager/sceneManager.js +128 -0
  60. package/dist/lib-cjs/src/api/manager/sceneManager.js.map +1 -0
  61. package/dist/{lib-es6 → lib-cjs/src}/api/manager/variantInstanceManager.d.ts +92 -92
  62. package/dist/lib-cjs/src/api/manager/variantInstanceManager.js +261 -0
  63. package/dist/lib-cjs/src/api/manager/variantInstanceManager.js.map +1 -0
  64. package/dist/{lib-es6 → lib-cjs/src}/api/store/specStorage.d.ts +24 -24
  65. package/dist/lib-cjs/{api → src/api}/store/specStorage.js +50 -51
  66. package/dist/lib-cjs/src/api/store/specStorage.js.map +1 -0
  67. package/dist/{lib-es6 → lib-cjs/src}/api/util/babylonHelper.d.ts +174 -174
  68. package/dist/lib-cjs/{api → src/api}/util/babylonHelper.js +591 -611
  69. package/dist/lib-cjs/src/api/util/babylonHelper.js.map +1 -0
  70. package/dist/{lib-es6 → lib-cjs/src}/api/util/globalTypes.d.ts +366 -366
  71. package/dist/lib-cjs/src/api/util/globalTypes.js +2 -0
  72. package/dist/lib-cjs/src/api/util/globalTypes.js.map +1 -0
  73. package/dist/lib-cjs/{api → src/api}/util/resourceHelper.d.ts +58 -58
  74. package/dist/lib-cjs/src/api/util/resourceHelper.js +202 -0
  75. package/dist/lib-cjs/src/api/util/resourceHelper.js.map +1 -0
  76. package/dist/lib-cjs/{api → src/api}/util/sceneLoaderHelper.d.ts +35 -35
  77. package/dist/lib-cjs/{api → src/api}/util/sceneLoaderHelper.js +141 -140
  78. package/dist/lib-cjs/src/api/util/sceneLoaderHelper.js.map +1 -0
  79. package/dist/{lib-es6 → lib-cjs/src}/api/util/stringHelper.d.ts +9 -9
  80. package/dist/lib-cjs/{api → src/api}/util/stringHelper.js +23 -25
  81. package/dist/lib-cjs/src/api/util/stringHelper.js.map +1 -0
  82. package/dist/{lib-es6 → lib-cjs/src}/api/util/structureHelper.d.ts +9 -9
  83. package/dist/lib-cjs/{api → src/api}/util/structureHelper.js +48 -48
  84. package/dist/lib-cjs/src/api/util/structureHelper.js.map +1 -0
  85. package/dist/lib-cjs/{index.d.ts → src/index.d.ts} +51 -49
  86. package/dist/lib-cjs/{index.js → src/index.js} +110 -89
  87. package/dist/lib-cjs/src/index.js.map +1 -0
  88. package/dist/lib-es6/buildinfo.json +3 -3
  89. package/dist/lib-es6/es6.tsconfig.tsbuildinfo +1 -0
  90. package/dist/lib-es6/{api → src/api}/classes/animationInterface.d.ts +8 -8
  91. package/dist/lib-es6/src/api/classes/animationInterface.js +2 -0
  92. package/dist/lib-es6/src/api/classes/animationInterface.js.map +1 -0
  93. package/dist/{lib-cjs → lib-es6/src}/api/classes/dottedPath.d.ts +79 -79
  94. package/dist/lib-es6/src/api/classes/dottedPath.js +163 -0
  95. package/dist/lib-es6/src/api/classes/dottedPath.js.map +1 -0
  96. package/dist/lib-es6/{api → src/api}/classes/element.d.ts +149 -149
  97. package/dist/lib-es6/src/api/classes/element.js +665 -0
  98. package/dist/lib-es6/src/api/classes/element.js.map +1 -0
  99. package/dist/{lib-cjs → lib-es6/src}/api/classes/event.d.ts +326 -326
  100. package/dist/lib-es6/src/api/classes/event.js +346 -0
  101. package/dist/lib-es6/src/api/classes/event.js.map +1 -0
  102. package/dist/{lib-cjs → lib-es6/src}/api/classes/eventBroadcaster.d.ts +26 -26
  103. package/dist/lib-es6/src/api/classes/eventBroadcaster.js +43 -0
  104. package/dist/lib-es6/src/api/classes/eventBroadcaster.js.map +1 -0
  105. package/dist/{lib-cjs → lib-es6/src}/api/classes/parameter.d.ts +336 -336
  106. package/dist/lib-es6/src/api/classes/parameter.js +458 -0
  107. package/dist/lib-es6/src/api/classes/parameter.js.map +1 -0
  108. package/dist/lib-es6/{api → src/api}/classes/parameterObservable.d.ts +36 -36
  109. package/dist/lib-es6/src/api/classes/parameterObservable.js +94 -0
  110. package/dist/lib-es6/src/api/classes/parameterObservable.js.map +1 -0
  111. package/dist/lib-es6/{api → src/api}/classes/parameterizable.d.ts +15 -15
  112. package/dist/lib-es6/src/api/classes/parameterizable.js +99 -0
  113. package/dist/lib-es6/src/api/classes/parameterizable.js.map +1 -0
  114. package/dist/lib-es6/{api → src/api}/classes/placementAnimation.d.ts +45 -44
  115. package/dist/lib-es6/{api → src/api}/classes/placementAnimation.js +171 -160
  116. package/dist/lib-es6/src/api/classes/placementAnimation.js.map +1 -0
  117. package/dist/{lib-cjs → lib-es6/src}/api/classes/variant.d.ts +234 -234
  118. package/dist/lib-es6/src/api/classes/variant.js +833 -0
  119. package/dist/lib-es6/src/api/classes/variant.js.map +1 -0
  120. package/dist/lib-es6/{api → src/api}/classes/variantInstance.d.ts +45 -45
  121. package/dist/lib-es6/src/api/classes/variantInstance.js +98 -0
  122. package/dist/lib-es6/src/api/classes/variantInstance.js.map +1 -0
  123. package/dist/{lib-cjs → lib-es6/src}/api/classes/variantParameterizable.d.ts +17 -17
  124. package/dist/lib-es6/src/api/classes/variantParameterizable.js +85 -0
  125. package/dist/lib-es6/src/api/classes/variantParameterizable.js.map +1 -0
  126. package/dist/lib-es6/{api → src/api}/classes/viewer.d.ts +187 -184
  127. package/dist/lib-es6/src/api/classes/viewer.js +587 -0
  128. package/dist/lib-es6/src/api/classes/viewer.js.map +1 -0
  129. package/dist/lib-es6/{api → src/api}/classes/viewerLight.d.ts +66 -66
  130. package/dist/lib-es6/src/api/classes/viewerLight.js +317 -0
  131. package/dist/lib-es6/src/api/classes/viewerLight.js.map +1 -0
  132. package/dist/{lib-cjs → lib-es6/src}/api/internal/lensRendering.d.ts +8 -8
  133. package/dist/lib-es6/{api → src/api}/internal/lensRendering.js +8 -8
  134. package/dist/lib-es6/src/api/internal/lensRendering.js.map +1 -0
  135. package/dist/{lib-cjs → lib-es6/src}/api/internal/sceneSetup.d.ts +13 -13
  136. package/dist/lib-es6/src/api/internal/sceneSetup.js +198 -0
  137. package/dist/lib-es6/src/api/internal/sceneSetup.js.map +1 -0
  138. package/dist/lib-es6/{api → src/api}/manager/animationManager.d.ts +30 -29
  139. package/dist/lib-es6/src/api/manager/animationManager.js +123 -0
  140. package/dist/lib-es6/src/api/manager/animationManager.js.map +1 -0
  141. package/dist/lib-es6/{api → src/api}/manager/gltfExportManager.d.ts +65 -65
  142. package/dist/lib-es6/{api → src/api}/manager/gltfExportManager.js +192 -220
  143. package/dist/lib-es6/src/api/manager/gltfExportManager.js.map +1 -0
  144. package/dist/lib-es6/{api → src/api}/manager/sceneManager.d.ts +31 -31
  145. package/dist/lib-es6/src/api/manager/sceneManager.js +124 -0
  146. package/dist/lib-es6/src/api/manager/sceneManager.js.map +1 -0
  147. package/dist/{lib-cjs → lib-es6/src}/api/manager/variantInstanceManager.d.ts +92 -92
  148. package/dist/lib-es6/src/api/manager/variantInstanceManager.js +257 -0
  149. package/dist/lib-es6/src/api/manager/variantInstanceManager.js.map +1 -0
  150. package/dist/{lib-cjs → lib-es6/src}/api/store/specStorage.d.ts +24 -24
  151. package/dist/lib-es6/{api → src/api}/store/specStorage.js +46 -48
  152. package/dist/lib-es6/src/api/store/specStorage.js.map +1 -0
  153. package/dist/{lib-cjs → lib-es6/src}/api/util/babylonHelper.d.ts +174 -174
  154. package/dist/lib-es6/{api → src/api}/util/babylonHelper.js +561 -581
  155. package/dist/lib-es6/src/api/util/babylonHelper.js.map +1 -0
  156. package/dist/{lib-cjs → lib-es6/src}/api/util/globalTypes.d.ts +366 -366
  157. package/dist/lib-es6/src/api/util/globalTypes.js +2 -0
  158. package/dist/lib-es6/src/api/util/globalTypes.js.map +1 -0
  159. package/dist/lib-es6/{api → src/api}/util/resourceHelper.d.ts +58 -58
  160. package/dist/lib-es6/src/api/util/resourceHelper.js +192 -0
  161. package/dist/lib-es6/src/api/util/resourceHelper.js.map +1 -0
  162. package/dist/lib-es6/{api → src/api}/util/sceneLoaderHelper.d.ts +35 -35
  163. package/dist/lib-es6/{api → src/api}/util/sceneLoaderHelper.js +131 -133
  164. package/dist/lib-es6/src/api/util/sceneLoaderHelper.js.map +1 -0
  165. package/dist/{lib-cjs → lib-es6/src}/api/util/stringHelper.d.ts +9 -9
  166. package/dist/lib-es6/{api → src/api}/util/stringHelper.js +19 -21
  167. package/dist/lib-es6/src/api/util/stringHelper.js.map +1 -0
  168. package/dist/{lib-cjs → lib-es6/src}/api/util/structureHelper.d.ts +9 -9
  169. package/dist/lib-es6/{api → src/api}/util/structureHelper.js +45 -45
  170. package/dist/lib-es6/src/api/util/structureHelper.js.map +1 -0
  171. package/dist/lib-es6/{index.js → src/index.d.ts} +51 -51
  172. package/dist/lib-es6/{index.d.ts → src/index.js} +49 -49
  173. package/dist/lib-es6/src/index.js.map +1 -0
  174. package/dist/lib-full/lens-rendering.js +2 -0
  175. package/dist/lib-full/lens-rendering.js.map +1 -0
  176. package/dist/lib-full/main.js +3 -0
  177. package/dist/lib-full/main.js.LICENSE.txt +9 -0
  178. package/dist/lib-full/main.js.map +1 -0
  179. package/package.json +76 -88
  180. package/src/api/classes/animationInterface.ts +10 -10
  181. package/src/api/classes/dottedPath.ts +181 -181
  182. package/src/api/classes/element.ts +716 -716
  183. package/src/api/classes/event.ts +367 -367
  184. package/src/api/classes/eventBroadcaster.ts +52 -52
  185. package/src/api/classes/parameter.ts +494 -494
  186. package/src/api/classes/parameterObservable.ts +100 -100
  187. package/src/api/classes/parameterizable.ts +87 -87
  188. package/src/api/classes/placementAnimation.ts +161 -160
  189. package/src/api/classes/variant.ts +904 -905
  190. package/src/api/classes/variantInstance.ts +97 -97
  191. package/src/api/classes/variantParameterizable.ts +85 -85
  192. package/src/api/classes/viewer.ts +669 -668
  193. package/src/api/classes/viewerLight.ts +334 -334
  194. package/src/api/internal/debugViewer.ts +90 -90
  195. package/src/api/internal/lensRendering.ts +9 -10
  196. package/src/api/internal/sceneSetup.ts +204 -204
  197. package/src/api/manager/animationManager.ts +143 -142
  198. package/src/api/manager/gltfExportManager.ts +191 -191
  199. package/src/api/manager/sceneManager.ts +127 -127
  200. package/src/api/manager/variantInstanceManager.ts +265 -265
  201. package/src/api/store/specStorage.ts +51 -51
  202. package/src/api/util/babylonHelper.ts +663 -663
  203. package/src/api/util/globalTypes.ts +413 -413
  204. package/src/api/util/resourceHelper.ts +189 -189
  205. package/src/api/util/sceneLoaderHelper.ts +148 -147
  206. package/src/api/util/stringHelper.ts +23 -23
  207. package/src/api/util/structureHelper.ts +49 -49
  208. package/src/dev.ts +61 -64
  209. package/src/index.ts +96 -94
  210. package/src/types.d.ts +28 -28
  211. package/dist/lib-cjs/api/classes/animationInterface.js +0 -2
  212. package/dist/lib-cjs/api/classes/animationInterface.js.map +0 -1
  213. package/dist/lib-cjs/api/classes/dottedPath.js +0 -188
  214. package/dist/lib-cjs/api/classes/dottedPath.js.map +0 -1
  215. package/dist/lib-cjs/api/classes/element.js +0 -824
  216. package/dist/lib-cjs/api/classes/element.js.map +0 -1
  217. package/dist/lib-cjs/api/classes/elementParameterizable.d.ts +0 -14
  218. package/dist/lib-cjs/api/classes/elementParameterizable.js +0 -135
  219. package/dist/lib-cjs/api/classes/elementParameterizable.js.map +0 -1
  220. package/dist/lib-cjs/api/classes/event.js +0 -372
  221. package/dist/lib-cjs/api/classes/event.js.map +0 -1
  222. package/dist/lib-cjs/api/classes/eventBroadcaster.js +0 -54
  223. package/dist/lib-cjs/api/classes/eventBroadcaster.js.map +0 -1
  224. package/dist/lib-cjs/api/classes/parameter.js +0 -472
  225. package/dist/lib-cjs/api/classes/parameter.js.map +0 -1
  226. package/dist/lib-cjs/api/classes/parameterObservable.js +0 -102
  227. package/dist/lib-cjs/api/classes/parameterObservable.js.map +0 -1
  228. package/dist/lib-cjs/api/classes/parameterizable.js +0 -150
  229. package/dist/lib-cjs/api/classes/parameterizable.js.map +0 -1
  230. package/dist/lib-cjs/api/classes/placementAnimation.js.map +0 -1
  231. package/dist/lib-cjs/api/classes/variant.js +0 -1204
  232. package/dist/lib-cjs/api/classes/variant.js.map +0 -1
  233. package/dist/lib-cjs/api/classes/variantInstance.js +0 -109
  234. package/dist/lib-cjs/api/classes/variantInstance.js.map +0 -1
  235. package/dist/lib-cjs/api/classes/variantParameterizable.js +0 -100
  236. package/dist/lib-cjs/api/classes/variantParameterizable.js.map +0 -1
  237. package/dist/lib-cjs/api/classes/viewer.js +0 -732
  238. package/dist/lib-cjs/api/classes/viewer.js.map +0 -1
  239. package/dist/lib-cjs/api/classes/viewerLight.js +0 -393
  240. package/dist/lib-cjs/api/classes/viewerLight.js.map +0 -1
  241. package/dist/lib-cjs/api/internal/debugViewer.d.ts +0 -13
  242. package/dist/lib-cjs/api/internal/debugViewer.js +0 -87
  243. package/dist/lib-cjs/api/internal/debugViewer.js.map +0 -1
  244. package/dist/lib-cjs/api/internal/lensRendering.js.map +0 -1
  245. package/dist/lib-cjs/api/internal/sceneSetup.js +0 -239
  246. package/dist/lib-cjs/api/internal/sceneSetup.js.map +0 -1
  247. package/dist/lib-cjs/api/manager/animationManager.js +0 -131
  248. package/dist/lib-cjs/api/manager/animationManager.js.map +0 -1
  249. package/dist/lib-cjs/api/manager/gltfExportManager.js +0 -224
  250. package/dist/lib-cjs/api/manager/gltfExportManager.js.map +0 -1
  251. package/dist/lib-cjs/api/manager/sceneManager.js +0 -153
  252. package/dist/lib-cjs/api/manager/sceneManager.js.map +0 -1
  253. package/dist/lib-cjs/api/manager/variantInstanceManager.js +0 -336
  254. package/dist/lib-cjs/api/manager/variantInstanceManager.js.map +0 -1
  255. package/dist/lib-cjs/api/store/specStorage.js.map +0 -1
  256. package/dist/lib-cjs/api/util/babylonHelper.js.map +0 -1
  257. package/dist/lib-cjs/api/util/globalTypes.js +0 -2
  258. package/dist/lib-cjs/api/util/globalTypes.js.map +0 -1
  259. package/dist/lib-cjs/api/util/resourceHelper.js +0 -258
  260. package/dist/lib-cjs/api/util/resourceHelper.js.map +0 -1
  261. package/dist/lib-cjs/api/util/sceneLoaderHelper.js.map +0 -1
  262. package/dist/lib-cjs/api/util/stringHelper.js.map +0 -1
  263. package/dist/lib-cjs/api/util/structureHelper.js.map +0 -1
  264. package/dist/lib-cjs/index.js.map +0 -1
  265. package/dist/lib-es6/api/classes/animationInterface.js +0 -2
  266. package/dist/lib-es6/api/classes/animationInterface.js.map +0 -1
  267. package/dist/lib-es6/api/classes/dottedPath.js +0 -185
  268. package/dist/lib-es6/api/classes/dottedPath.js.map +0 -1
  269. package/dist/lib-es6/api/classes/element.js +0 -821
  270. package/dist/lib-es6/api/classes/element.js.map +0 -1
  271. package/dist/lib-es6/api/classes/event.js +0 -369
  272. package/dist/lib-es6/api/classes/event.js.map +0 -1
  273. package/dist/lib-es6/api/classes/eventBroadcaster.js +0 -51
  274. package/dist/lib-es6/api/classes/eventBroadcaster.js.map +0 -1
  275. package/dist/lib-es6/api/classes/parameter.js +0 -469
  276. package/dist/lib-es6/api/classes/parameter.js.map +0 -1
  277. package/dist/lib-es6/api/classes/parameterObservable.js +0 -99
  278. package/dist/lib-es6/api/classes/parameterObservable.js.map +0 -1
  279. package/dist/lib-es6/api/classes/parameterizable.js +0 -147
  280. package/dist/lib-es6/api/classes/parameterizable.js.map +0 -1
  281. package/dist/lib-es6/api/classes/placementAnimation.js.map +0 -1
  282. package/dist/lib-es6/api/classes/variant.js +0 -1199
  283. package/dist/lib-es6/api/classes/variant.js.map +0 -1
  284. package/dist/lib-es6/api/classes/variantInstance.js +0 -106
  285. package/dist/lib-es6/api/classes/variantInstance.js.map +0 -1
  286. package/dist/lib-es6/api/classes/variantParameterizable.js +0 -97
  287. package/dist/lib-es6/api/classes/variantParameterizable.js.map +0 -1
  288. package/dist/lib-es6/api/classes/viewer.js +0 -729
  289. package/dist/lib-es6/api/classes/viewer.js.map +0 -1
  290. package/dist/lib-es6/api/classes/viewerLight.js +0 -390
  291. package/dist/lib-es6/api/classes/viewerLight.js.map +0 -1
  292. package/dist/lib-es6/api/internal/debugViewer.d.ts +0 -13
  293. package/dist/lib-es6/api/internal/debugViewer.js +0 -84
  294. package/dist/lib-es6/api/internal/debugViewer.js.map +0 -1
  295. package/dist/lib-es6/api/internal/lensRendering.js.map +0 -1
  296. package/dist/lib-es6/api/internal/sceneSetup.js +0 -234
  297. package/dist/lib-es6/api/internal/sceneSetup.js.map +0 -1
  298. package/dist/lib-es6/api/manager/animationManager.js +0 -128
  299. package/dist/lib-es6/api/manager/animationManager.js.map +0 -1
  300. package/dist/lib-es6/api/manager/gltfExportManager.js.map +0 -1
  301. package/dist/lib-es6/api/manager/sceneManager.js +0 -150
  302. package/dist/lib-es6/api/manager/sceneManager.js.map +0 -1
  303. package/dist/lib-es6/api/manager/variantInstanceManager.js +0 -333
  304. package/dist/lib-es6/api/manager/variantInstanceManager.js.map +0 -1
  305. package/dist/lib-es6/api/store/specStorage.js.map +0 -1
  306. package/dist/lib-es6/api/util/babylonHelper.js.map +0 -1
  307. package/dist/lib-es6/api/util/globalTypes.js +0 -2
  308. package/dist/lib-es6/api/util/globalTypes.js.map +0 -1
  309. package/dist/lib-es6/api/util/resourceHelper.js +0 -248
  310. package/dist/lib-es6/api/util/resourceHelper.js.map +0 -1
  311. package/dist/lib-es6/api/util/sceneLoaderHelper.js.map +0 -1
  312. package/dist/lib-es6/api/util/stringHelper.js.map +0 -1
  313. package/dist/lib-es6/api/util/structureHelper.js.map +0 -1
  314. package/dist/lib-es6/index.js.map +0 -1
  315. package/dist/webpack-stats.json +0 -0
  316. package/src/buildinfo.json +0 -3
  317. package/src/commonjs.tsconfig.json +0 -10
  318. package/src/declaration.tsconfig.json +0 -8
  319. package/src/es6.tsconfig.json +0 -10
  320. package/src/pagesconfig.json +0 -81
  321. package/src/tsconfig.json +0 -33
  322. package/src/tsconfig.types.json +0 -9
@@ -1,1199 +0,0 @@
1
- import { __awaiter, __extends, __generator } from "tslib";
2
- import { AssetContainer } from '@babylonjs/core/assetContainer';
3
- import '@babylonjs/core/Loading/Plugins/babylonFileLoader';
4
- import { SceneLoader } from '@babylonjs/core/Loading/sceneLoader';
5
- import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
6
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression';
7
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_texture_transform';
8
- import '@babylonjs/loaders/glTF/2.0/glTFLoader';
9
- import { cloneDeep, concat, get, isEmpty, isEqual, isString, merge, set } from 'lodash-es';
10
- import { deactivateTransformNode, getDottedPathForNode, injectNodeMetadata } from '../util/babylonHelper';
11
- import { loadJson, mergeMaps } from '../util/resourceHelper';
12
- import { DottedPath } from './dottedPath';
13
- import { Element } from './element';
14
- import { Event } from './event';
15
- import { Parameter } from './parameter';
16
- import { Parameterizable } from './parameterizable';
17
- import { ViewerLight } from './viewerLight';
18
- import { getMaterialFromCbnAssets } from '../util/sceneLoaderHelper';
19
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_texture_basisu';
20
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_clearcoat';
21
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_sheen';
22
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_ior';
23
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness';
24
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_specular';
25
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_translucency';
26
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_transmission';
27
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_unlit';
28
- import '@babylonjs/loaders/glTF/2.0/Extensions/KHR_materials_variants';
29
- /**
30
- * A concrete "Variant". Most of these are handled by either the {@link Viewer} or {@link VariantInstance}.
31
- */
32
- var Variant = /** @class */ (function (_super) {
33
- __extends(Variant, _super);
34
- /**
35
- * Constructor.
36
- */
37
- function Variant(name, _structureJson, viewer, parent) {
38
- var _this = _super.call(this, cloneDeep(_structureJson.parameterDeclaration), cloneDeep(_structureJson.parameters)) || this;
39
- _this.name = name;
40
- _this._structureJson = _structureJson;
41
- _this.viewer = viewer;
42
- _this.parent = parent;
43
- _this.elements = [];
44
- _this.viewerLights = [];
45
- _this._children = new Map();
46
- _this._parameterObservers = new Map();
47
- /**
48
- * @internal
49
- */
50
- _this.parametersInitialized = false;
51
- for (var parameter in _structureJson.parameterDeclaration) {
52
- if (!(parameter in (_structureJson.parameters || []))) {
53
- throw new Error("No default value for parameter \"" + parameter + "\" defined.");
54
- }
55
- }
56
- _this.assetContainer = new AssetContainer(viewer.scene);
57
- _this.structureJson = cloneDeep(_structureJson);
58
- return _this;
59
- }
60
- /**
61
- * Creates a {@link Variant} based on given parameters.
62
- *
63
- * @throws Error if "gltf" property is provided without a filename
64
- */
65
- Variant.create = function (name, structureJson, viewer, parent) {
66
- return __awaiter(this, void 0, void 0, function () {
67
- var variant;
68
- return __generator(this, function (_a) {
69
- switch (_a.label) {
70
- case 0:
71
- variant = new Variant(name, structureJson, viewer, parent);
72
- return [4 /*yield*/, variant.loadAssets()];
73
- case 1:
74
- _a.sent();
75
- return [2 /*return*/, variant];
76
- }
77
- });
78
- });
79
- };
80
- Object.defineProperty(Variant.prototype, "ancestors", {
81
- /**
82
- * The ancestor {@link Variant}s ordered from top to bottom in the built tree.
83
- */
84
- get: function () {
85
- var ancestors = [];
86
- var variant = this;
87
- while (variant.parent) {
88
- ancestors.unshift(variant.parent);
89
- variant = variant.parent;
90
- }
91
- return ancestors;
92
- },
93
- enumerable: false,
94
- configurable: true
95
- });
96
- Object.defineProperty(Variant.prototype, "root", {
97
- /**
98
- * The root {@link Variant}.
99
- */
100
- get: function () {
101
- var _a;
102
- return (_a = this.ancestors[0]) !== null && _a !== void 0 ? _a : this;
103
- },
104
- enumerable: false,
105
- configurable: true
106
- });
107
- Object.defineProperty(Variant.prototype, "dottedPath", {
108
- /**
109
- * The {@link DottedPath} in the built tree of {@link Variant}s.
110
- * E.g. "_.top-1.sub-2.sub-sub-3"
111
- */
112
- get: function () {
113
- var parentIds = this.ancestors.map(function (ancestor) {
114
- return ancestor.name;
115
- });
116
- return DottedPath.createFromParts(parentIds).addPart(this.name);
117
- },
118
- enumerable: false,
119
- configurable: true
120
- });
121
- Object.defineProperty(Variant.prototype, "id", {
122
- /**
123
- * The id representing a {@link DottedPath}.
124
- */
125
- get: function () {
126
- var dottedPath = DottedPath.create(this.dottedPath);
127
- dottedPath.shiftPart(); // remove root
128
- return dottedPath.path || '_';
129
- },
130
- enumerable: false,
131
- configurable: true
132
- });
133
- Object.defineProperty(Variant.prototype, "glTF", {
134
- /**
135
- * The defined glTF Asset.
136
- */
137
- get: function () {
138
- if (this.structureJson.glTF) {
139
- if (isString(this.structureJson.glTF)) {
140
- return {
141
- rootUrl: this.structureJson.glTF,
142
- fileName: undefined,
143
- };
144
- }
145
- if (isEmpty(this.structureJson.glTF.rootUrl)) {
146
- throw new Error("No \"rootUrl\" defined in \"glTF\" definition for variant \"" + this.id + "\".");
147
- }
148
- return this.structureJson.glTF;
149
- }
150
- },
151
- enumerable: false,
152
- configurable: true
153
- });
154
- Object.defineProperty(Variant.prototype, "glTFUri", {
155
- /**
156
- * The defined glTF URI.
157
- */
158
- get: function () {
159
- if (this.glTF) {
160
- return [this.glTF.rootUrl, this.glTF.fileName].join('');
161
- }
162
- },
163
- enumerable: false,
164
- configurable: true
165
- });
166
- Object.defineProperty(Variant.prototype, "inheritedGlTFUri", {
167
- /**
168
- * The inherited defined glTF URI.
169
- */
170
- get: function () {
171
- if (!this.glTFUri && this.parent) {
172
- return this.parent.inheritedGlTFUri;
173
- }
174
- return this.glTFUri;
175
- },
176
- enumerable: false,
177
- configurable: true
178
- });
179
- Object.defineProperty(Variant.prototype, "nodes", {
180
- /**
181
- * The TransformNodes of the {@link Variant}.
182
- */
183
- get: function () {
184
- var rootNodes = this.assetContainer
185
- .getNodes()
186
- .filter(function (n) { return n instanceof TransformNode && !n.parent; });
187
- return rootNodes;
188
- },
189
- enumerable: false,
190
- configurable: true
191
- });
192
- Object.defineProperty(Variant.prototype, "lights", {
193
- /**
194
- * The {@link ViewerLight}s of the {@link Variant}.
195
- */
196
- get: function () {
197
- return this.assetContainer.lights;
198
- },
199
- enumerable: false,
200
- configurable: true
201
- });
202
- Object.defineProperty(Variant.prototype, "dottedNodes", {
203
- /**
204
- * All TransformNodes of the {@link Variant} mapped flat with a {@link DottedPath}.
205
- */
206
- get: function () {
207
- if (!this._dottedNodes) {
208
- var nodes = this.assetContainer.getNodes().filter(function (n) { return n instanceof TransformNode; });
209
- var dottedNodes_1 = new Map();
210
- nodes.forEach(function (node) {
211
- dottedNodes_1.set(node.metadata.dottedPath, node);
212
- });
213
- this._dottedNodes = dottedNodes_1;
214
- }
215
- return this._dottedNodes;
216
- },
217
- enumerable: false,
218
- configurable: true
219
- });
220
- Object.defineProperty(Variant.prototype, "materials", {
221
- /**
222
- * The Materials of the {@link Variant}.
223
- */
224
- get: function () {
225
- return this.assetContainer.materials;
226
- },
227
- enumerable: false,
228
- configurable: true
229
- });
230
- Object.defineProperty(Variant.prototype, "inheritedElements", {
231
- /**
232
- * All {@link Element}s from this {@link Variant}'s parents.
233
- */
234
- get: function () {
235
- var elements = [];
236
- this.ancestors.forEach(function (ancestor) {
237
- elements = concat(elements, ancestor.elements);
238
- });
239
- return concat(elements, this.elements);
240
- },
241
- enumerable: false,
242
- configurable: true
243
- });
244
- Object.defineProperty(Variant.prototype, "inheritedViewerLights", {
245
- /**
246
- * All {@link ViewerLight}s inherited from this {@link Variant}'s parents.
247
- */
248
- get: function () {
249
- var viewerLights = [];
250
- this.ancestors.forEach(function (ancestor) {
251
- viewerLights = concat(viewerLights, ancestor.viewerLights);
252
- });
253
- return concat(viewerLights, this.viewerLights);
254
- },
255
- enumerable: false,
256
- configurable: true
257
- });
258
- Object.defineProperty(Variant.prototype, "inheritedNodes", {
259
- /**
260
- * All TransformNodes inherited from this {@link Variant}'s parents.
261
- */
262
- get: function () {
263
- var nodes = [];
264
- this.ancestors.forEach(function (ancestor) {
265
- nodes = concat(nodes, ancestor.nodes);
266
- });
267
- return concat(nodes, this.nodes);
268
- },
269
- enumerable: false,
270
- configurable: true
271
- });
272
- Object.defineProperty(Variant.prototype, "inheritedDottedNodes", {
273
- /**
274
- * All TransformNodes inherited from this {@link Variant}'s parents mapped flat with a {@link DottedPath}.
275
- */
276
- get: function () {
277
- var dottedNodes = this.dottedNodes;
278
- this.ancestors.forEach(function (ancestor) {
279
- dottedNodes = mergeMaps(dottedNodes, ancestor.dottedNodes);
280
- });
281
- return dottedNodes;
282
- },
283
- enumerable: false,
284
- configurable: true
285
- });
286
- Object.defineProperty(Variant.prototype, "inheritedLights", {
287
- /**
288
- * All Lights inherited from this {@link Variant}'s parents.
289
- */
290
- get: function () {
291
- var lights = [];
292
- this.ancestors.forEach(function (ancestor) {
293
- lights = concat(lights, ancestor.lights);
294
- });
295
- return concat(lights, this.lights);
296
- },
297
- enumerable: false,
298
- configurable: true
299
- });
300
- Object.defineProperty(Variant.prototype, "inheritedParameterDeclaration", {
301
- /**
302
- * The {@link ParameterDeclarations} inherited from this {@link Variant}'s parents.
303
- */
304
- get: function () {
305
- var declaration = {};
306
- this.ancestors.forEach(function (ancestor) {
307
- merge(declaration, ancestor.parameterDeclaration);
308
- });
309
- return merge(declaration, this.parameterDeclaration);
310
- },
311
- enumerable: false,
312
- configurable: true
313
- });
314
- Object.defineProperty(Variant.prototype, "inheritedParameters", {
315
- /**
316
- * The {@link ParameterBag} inherited from this {@link Variant}'s parents.
317
- */
318
- get: function () {
319
- var parameters = {};
320
- this.ancestors.forEach(function (ancestor) {
321
- merge(parameters, ancestor.parameters);
322
- });
323
- return merge(parameters, this.parameters);
324
- },
325
- enumerable: false,
326
- configurable: true
327
- });
328
- Object.defineProperty(Variant.prototype, "inheritedMaterials", {
329
- /**
330
- * All Materials from this {@link Variant}'s parents.
331
- */
332
- get: function () {
333
- var materials = [];
334
- this.ancestors.forEach(function (ancestor) {
335
- materials = concat(materials, ancestor.materials);
336
- });
337
- return concat(materials, this.materials);
338
- },
339
- enumerable: false,
340
- configurable: true
341
- });
342
- /**
343
- * Gets the direct children of the current {@link Variant}.
344
- */
345
- Variant.prototype.getChildren = function () {
346
- return __awaiter(this, void 0, void 0, function () {
347
- var children, _a, _b, _i, name_1, _c, _d;
348
- return __generator(this, function (_e) {
349
- switch (_e.label) {
350
- case 0:
351
- children = [];
352
- _a = [];
353
- for (_b in this.structureJson.variants)
354
- _a.push(_b);
355
- _i = 0;
356
- _e.label = 1;
357
- case 1:
358
- if (!(_i < _a.length)) return [3 /*break*/, 4];
359
- name_1 = _a[_i];
360
- _d = (_c = children).push;
361
- return [4 /*yield*/, this.getDescendant(name_1)];
362
- case 2:
363
- _d.apply(_c, [_e.sent()]);
364
- _e.label = 3;
365
- case 3:
366
- _i++;
367
- return [3 /*break*/, 1];
368
- case 4: return [2 /*return*/, children];
369
- }
370
- });
371
- });
372
- };
373
- /**
374
- * Gets a descendant {@link Variant} of the current {@link Variant} relative to its {@link DottedPath}.
375
- * If you have the dotted path `_.product_x.variant_blue.with_yellow_highlight` in a tree and you operate on the
376
- * `product_x`, you can call `this.getDescendant('variant_blue.with_yellow_highlight')` to get the lowermost
377
- * {@link Variant}.
378
- */
379
- Variant.prototype.getDescendant = function (dottedPath) {
380
- return __awaiter(this, void 0, void 0, function () {
381
- var _dottedPath, _a, name, descendantParts, variant, file, _b, _c, _d;
382
- return __generator(this, function (_e) {
383
- switch (_e.label) {
384
- case 0:
385
- _dottedPath = DottedPath.create(dottedPath);
386
- _a = _dottedPath.parts, name = _a[0], descendantParts = _a.slice(1);
387
- if (!this._children.has(name)) return [3 /*break*/, 1];
388
- variant = this._children.get(name);
389
- return [3 /*break*/, 7];
390
- case 1:
391
- if (!this.structureJson.variants) {
392
- throw new Error("Missing key \"variants\" in JSON structure for variant \"" + this.id + "\".");
393
- }
394
- if (!this.structureJson.variants[name]) {
395
- throw new Error("Variant \"" + _dottedPath.path + "\" not defined in JSON structure for variant \"" + this.id + "\".");
396
- }
397
- if (!this.structureJson.variants[name].file) return [3 /*break*/, 4];
398
- file = this.structureJson.variants[name].file;
399
- _c = (_b = Variant).create;
400
- _d = [name];
401
- return [4 /*yield*/, loadJson(file)];
402
- case 2: return [4 /*yield*/, _c.apply(_b, _d.concat([_e.sent(), this.viewer, this]))];
403
- case 3:
404
- variant = _e.sent();
405
- return [3 /*break*/, 6];
406
- case 4: return [4 /*yield*/, Variant.create(name, this.structureJson.variants[name], this.viewer, this)];
407
- case 5:
408
- variant = _e.sent();
409
- _e.label = 6;
410
- case 6:
411
- this._children.set(name, variant);
412
- _e.label = 7;
413
- case 7:
414
- if (!variant) {
415
- throw new Error("Variant \"" + _dottedPath.path + "\" was not created.");
416
- }
417
- if (!(descendantParts.length > 0)) return [3 /*break*/, 9];
418
- return [4 /*yield*/, variant.getDescendant(DottedPath.createFromParts(descendantParts))];
419
- case 8: return [2 /*return*/, _e.sent()];
420
- case 9: return [2 /*return*/, variant];
421
- }
422
- });
423
- });
424
- };
425
- /**
426
- * Gets the desired {@link Element} of the current {@link Variant} relative to its {@link DottedPath}.
427
- * Uses the mechanism of {@link getDescendant} to resolve the appropriate variant in tree.
428
- */
429
- Variant.prototype.getElement = function (dottedPath) {
430
- return __awaiter(this, void 0, void 0, function () {
431
- var _dottedPath, elementName, variant, element;
432
- return __generator(this, function (_a) {
433
- switch (_a.label) {
434
- case 0:
435
- _dottedPath = DottedPath.create(dottedPath);
436
- elementName = _dottedPath.popPart();
437
- variant = this;
438
- if (!(_dottedPath.parts.length > 0)) return [3 /*break*/, 2];
439
- return [4 /*yield*/, this.getDescendant(_dottedPath)];
440
- case 1:
441
- variant = _a.sent();
442
- _a.label = 2;
443
- case 2:
444
- if (variant.inheritedElements.length === 0) {
445
- throw new Error("No elements for variant \"" + variant.id + "\" found. " +
446
- "Either none are defined or they are not initialized (are you operating on the appropriate living?).");
447
- }
448
- variant.inheritedElements.forEach(function (_element) {
449
- if (_element.name === elementName) {
450
- element = _element;
451
- }
452
- });
453
- if (!element) {
454
- throw new Error("Element with name \"" + elementName + "\" does not exist for variant \"" + variant.id + "\".");
455
- }
456
- return [2 /*return*/, element];
457
- }
458
- });
459
- });
460
- };
461
- /**
462
- * Gets the desired {@link ViewerLight} of the current {@link Variant} relative to its {@link DottedPath}.
463
- * Uses the mechanism of {@link getDescendant} to resolve the appropriate variant in tree.
464
- */
465
- Variant.prototype.getViewerLight = function (dottedPath) {
466
- return __awaiter(this, void 0, void 0, function () {
467
- var _dottedPath, viewerLightName, variant, viewerLight;
468
- return __generator(this, function (_a) {
469
- switch (_a.label) {
470
- case 0:
471
- _dottedPath = DottedPath.create(dottedPath);
472
- viewerLightName = _dottedPath.popPart();
473
- variant = this;
474
- if (!(_dottedPath.parts.length > 0)) return [3 /*break*/, 2];
475
- return [4 /*yield*/, this.getDescendant(_dottedPath)];
476
- case 1:
477
- variant = _a.sent();
478
- _a.label = 2;
479
- case 2:
480
- if (variant.inheritedViewerLights.length === 0) {
481
- throw new Error("No viewerLights for variant \"" + variant.id + "\" found. " +
482
- "Either none are defined or they are not initialized (are you operating on the appropriate living?).");
483
- }
484
- variant.inheritedViewerLights.forEach(function (_viewerLight) {
485
- if (_viewerLight.name === viewerLightName) {
486
- viewerLight = _viewerLight;
487
- }
488
- });
489
- if (!viewerLight) {
490
- throw new Error("ViewerLight with name \"" + viewerLightName + "\" does not exist for variant \"" + variant.id + "\".");
491
- }
492
- return [2 /*return*/, viewerLight];
493
- }
494
- });
495
- });
496
- };
497
- /**
498
- * A proxy for directly getting a Node from an {@link Element} by its {@link DottedPath}s.
499
- */
500
- Variant.prototype.getNode = function (elementDottedPath, nodeDottedPath) {
501
- return __awaiter(this, void 0, void 0, function () {
502
- var element;
503
- return __generator(this, function (_a) {
504
- switch (_a.label) {
505
- case 0: return [4 /*yield*/, this.getElement(elementDottedPath)];
506
- case 1:
507
- element = _a.sent();
508
- return [2 /*return*/, element.getNode(nodeDottedPath)];
509
- }
510
- });
511
- });
512
- };
513
- /**
514
- * A proxy for directly getting a Mesh from an {@link Element} by its {@link DottedPath}s.
515
- */
516
- Variant.prototype.getMesh = function (elementDottedPath, meshDottedPath) {
517
- return __awaiter(this, void 0, void 0, function () {
518
- var element;
519
- return __generator(this, function (_a) {
520
- switch (_a.label) {
521
- case 0: return [4 /*yield*/, this.getElement(elementDottedPath)];
522
- case 1:
523
- element = _a.sent();
524
- return [2 /*return*/, element.getMesh(meshDottedPath)];
525
- }
526
- });
527
- });
528
- };
529
- /**
530
- * Gets the Material defined in one of the variants glTFs by its id.
531
- */
532
- Variant.prototype.getMaterial = function (id) {
533
- var scene = this.viewer.scene;
534
- for (var _i = 0, _a = this.inheritedMaterials; _i < _a.length; _i++) {
535
- var material = _a[_i];
536
- if (material.id === id) {
537
- return material;
538
- }
539
- }
540
- // fallback to dynamically created materials on scene
541
- for (var _b = 0, _c = scene.materials; _b < _c.length; _b++) {
542
- var material = _c[_b];
543
- if (material.id === id) {
544
- return material;
545
- }
546
- }
547
- var cbnAssetMaterial = getMaterialFromCbnAssets(id, scene);
548
- if (cbnAssetMaterial) {
549
- return cbnAssetMaterial;
550
- }
551
- throw new Error("Material with id \"" + id + "\" does not exist for variant \"" + this.id + "\".");
552
- };
553
- /**
554
- * Creates a living clone of this {@link Variant}. Will clone all parent {@link Variant}s in tree.
555
- *
556
- * @emit {@link Event.VARIANT_CREATED}
557
- * @ignore
558
- */
559
- Variant.prototype.createLiving = function (parameters) {
560
- var _a;
561
- return __awaiter(this, void 0, void 0, function () {
562
- var parent, variant;
563
- return __generator(this, function (_b) {
564
- switch (_b.label) {
565
- case 0: return [4 /*yield*/, ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.createLiving())];
566
- case 1:
567
- parent = _b.sent();
568
- variant = new Variant(this.name, this._structureJson, this.viewer, parent);
569
- parent === null || parent === void 0 ? void 0 : parent._children.set(variant.name, variant);
570
- variant.assetContainer = this.assetContainer;
571
- variant.parameterObservers = cloneDeep(this.parameterObservers);
572
- return [4 /*yield*/, variant.createElements()];
573
- case 2:
574
- _b.sent();
575
- return [4 /*yield*/, variant.createViewerLights()];
576
- case 3:
577
- _b.sent();
578
- variant.addParameterObservers();
579
- return [4 /*yield*/, variant.bootstrapParameters(parameters)];
580
- case 4:
581
- _b.sent();
582
- this.broadcastEvent(Event.VARIANT_CREATED, variant);
583
- return [2 /*return*/, variant];
584
- }
585
- });
586
- });
587
- };
588
- /**
589
- * Destroys this {@link Variant}, all parents and destroy the {@link Element}s.
590
- */
591
- Variant.prototype.destroy = function () {
592
- this.elements.forEach(function (element) { return element.destroy(); });
593
- if (this.parent) {
594
- this.parent.destroy();
595
- }
596
- this.broadcastEvent(Event.VARIANT_DESTROYED, this);
597
- return this;
598
- };
599
- /**
600
- * Places the given {@link ParameterBag} in the {@link Variant}'s parameters, replaces all patterns in the
601
- * {@link StructureJson}, broadcasts all {@link ParameterObserver}s and delegates them to its {@link Element}s.
602
- *
603
- * @emit {@link Event.VARIANT_PARAMETER_COMMITTED}
604
- */
605
- Variant.prototype.commitParameters = function (parameters) {
606
- return __awaiter(this, void 0, void 0, function () {
607
- var oldParameters, _parameters, parameter, value, search, mergedParameters, structureParameters, _structureParameters, parameter, value, search, replacedStructureParameters, differentStructureParameters, parameter, newParameters, structure, parameter, value, search, observerPromises, _loop_1, this_1, parameter;
608
- var _this = this;
609
- return __generator(this, function (_a) {
610
- switch (_a.label) {
611
- case 0:
612
- parameters = merge({}, parameters);
613
- oldParameters = cloneDeep(this.inheritedParameters);
614
- _parameters = JSON.stringify(parameters);
615
- for (parameter in this.inheritedParameters) {
616
- value = this.inheritedParameters[parameter];
617
- search = new RegExp("\\$\\{" + parameter + "\\}", 'g');
618
- _parameters = _parameters.replace(search, value.toString());
619
- }
620
- merge(parameters, JSON.parse(_parameters));
621
- mergedParameters = merge({}, this.inheritedParameters, parameters);
622
- structureParameters = this._structureJson.parameters || {};
623
- _structureParameters = JSON.stringify(structureParameters);
624
- for (parameter in mergedParameters) {
625
- value = mergedParameters[parameter];
626
- search = new RegExp("\\$\\{" + parameter + "\\}", 'g');
627
- _structureParameters = _structureParameters.replace(search, value.toString());
628
- }
629
- replacedStructureParameters = JSON.parse(_structureParameters);
630
- differentStructureParameters = {};
631
- for (parameter in replacedStructureParameters) {
632
- if (!isEqual(structureParameters[parameter], replacedStructureParameters[parameter])) {
633
- differentStructureParameters[parameter] = replacedStructureParameters[parameter];
634
- }
635
- }
636
- // merge replaced structure parameters and given inherited parameters to structure parameters
637
- merge(this.parameters, mergedParameters, differentStructureParameters);
638
- newParameters = this.inheritedParameters;
639
- structure = JSON.stringify(this._structureJson);
640
- for (parameter in newParameters) {
641
- value = newParameters[parameter];
642
- search = new RegExp("\\$\\{" + parameter + "\\}", 'g');
643
- structure = structure.replace(search, value.toString());
644
- }
645
- this.structureJson = JSON.parse(structure);
646
- observerPromises = [];
647
- _loop_1 = function (parameter) {
648
- var oldParameterValue = oldParameters[parameter];
649
- var newParameterValue = newParameters[parameter];
650
- this_1.assertParameter(this_1.inheritedParameterDeclaration, parameter, newParameterValue);
651
- if (oldParameterValue === newParameterValue && this_1.parametersInitialized) {
652
- return "continue";
653
- }
654
- // parameter changed
655
- var parameterObservers = mergeMaps(this_1._parameterObservers, this_1.parameterObservers);
656
- if (parameterObservers.has(parameter)) {
657
- var observers = parameterObservers.get(parameter);
658
- observerPromises = concat(observerPromises, observers.map(function (observer) {
659
- var observerResult = observer(_this, oldParameterValue, newParameterValue);
660
- return Promise.resolve(observerResult).then(function () {
661
- if (_this.parametersInitialized) {
662
- _this.broadcastEvent(Event.VARIANT_PARAMETER_COMMITTED, _this, parameter, oldParameterValue, newParameterValue);
663
- }
664
- });
665
- }));
666
- }
667
- };
668
- this_1 = this;
669
- for (parameter in newParameters) {
670
- _loop_1(parameter);
671
- }
672
- return [4 /*yield*/, Promise.all(observerPromises)];
673
- case 1:
674
- _a.sent();
675
- // broadcast that bag has been committed
676
- this.broadcastEvent(Event.VARIANT_PARAMETER_BAG_COMMITTED, this, oldParameters, newParameters);
677
- // commit parameters to elements
678
- return [4 /*yield*/, this.commitParametersToElements(newParameters)];
679
- case 2:
680
- // commit parameters to elements
681
- _a.sent();
682
- // commit parameters to lights
683
- return [4 /*yield*/, this.commitParametersToViewerLights(newParameters)];
684
- case 3:
685
- // commit parameters to lights
686
- _a.sent();
687
- if (!this.parent) return [3 /*break*/, 5];
688
- return [4 /*yield*/, this.parent.commitParameters(this.parameters)];
689
- case 4:
690
- _a.sent();
691
- _a.label = 5;
692
- case 5: return [2 /*return*/, this];
693
- }
694
- });
695
- });
696
- };
697
- /**
698
- * Adds an observer function for camera matrix changes for given `dottedPath` representing the {@link Element}
699
- * and the `traceable`. The `observer` gets 2 parameters: the `AbstractMesh` and a `ClientRect` object.
700
- */
701
- Variant.prototype.addTraceableObserver = function (dottedPath, observer, payload) {
702
- return __awaiter(this, void 0, void 0, function () {
703
- var _dottedPath, traceableName, element;
704
- return __generator(this, function (_a) {
705
- switch (_a.label) {
706
- case 0:
707
- _dottedPath = DottedPath.create(dottedPath);
708
- traceableName = _dottedPath.popPart();
709
- if (!traceableName) {
710
- throw new Error("The dottedPath must consist of the element and the name of the defined corresponding " +
711
- ("traceable (\"" + _dottedPath.path + "\" given)."));
712
- }
713
- return [4 /*yield*/, this.getElement(_dottedPath)];
714
- case 1:
715
- element = _a.sent();
716
- return [2 /*return*/, element.addTraceableObserver(traceableName, observer, payload)];
717
- }
718
- });
719
- });
720
- };
721
- /**
722
- * Loads {@link glTFUri} with assets, adds them to the {@link Variant}'s `assetContainer` and deactivates the meshes.
723
- * (for further processing).
724
- * @emits {@link Event.ASSET_LOADING_START}
725
- * @emits {@link Event.ASSET_LOADING_END}
726
- */
727
- Variant.prototype.loadAssets = function () {
728
- return __awaiter(this, void 0, void 0, function () {
729
- var promisifiedLoader;
730
- var _this = this;
731
- return __generator(this, function (_a) {
732
- switch (_a.label) {
733
- case 0:
734
- this.broadcastEvent(Event.ASSET_LOADING_START, this);
735
- promisifiedLoader = new Promise(function (resolve, reject) {
736
- if (!_this.structureJson) {
737
- _this.broadcastEvent(Event.ASSET_LOADING_END, _this);
738
- return resolve(_this);
739
- }
740
- if (!_this.glTF) {
741
- _this.broadcastEvent(Event.ASSET_LOADING_END, _this);
742
- return resolve(_this);
743
- }
744
- SceneLoader.LoadAssetContainer(_this.glTF.rootUrl, _this.glTF.fileName, _this.viewer.scene,
745
- // on success
746
- function (container) {
747
- _this.assetContainer = container;
748
- var nodes = _this.assetContainer.getNodes().filter(function (n) { return n instanceof TransformNode; });
749
- nodes.forEach(function (node) {
750
- deactivateTransformNode(node, false);
751
- injectNodeMetadata(node, { dottedPath: getDottedPathForNode(node) }, false);
752
- });
753
- _this.assetContainer.lights.forEach(function (light) {
754
- light.setEnabled(false);
755
- injectNodeMetadata(light, { dottedPath: getDottedPathForNode(light) }, false);
756
- _this.viewer.scene.addLight(light);
757
- });
758
- _this.assetContainer.cameras.forEach(function (camera) {
759
- camera.setEnabled(false);
760
- injectNodeMetadata(camera, { dottedPath: getDottedPathForNode(camera) }, false);
761
- _this.viewer.scene.addCamera(camera);
762
- });
763
- _this.assetContainer.materials.forEach(function (material) { return _this.viewer.scene.materials.push(material); });
764
- _this.broadcastEvent(Event.ASSET_LOADING_END, _this);
765
- resolve(_this);
766
- },
767
- // on progress
768
- undefined,
769
- // on error
770
- function (reason) {
771
- _this.broadcastEvent(Event.ASSET_LOADING_END, _this);
772
- throw new Error("Error loading assets for variant \"" + _this.id + "\": " + reason + ".");
773
- });
774
- });
775
- return [4 /*yield*/, promisifiedLoader];
776
- case 1: return [2 /*return*/, _a.sent()];
777
- }
778
- });
779
- });
780
- };
781
- /**
782
- * Commits given parameters to all {@link Element}s.
783
- */
784
- Variant.prototype.commitParametersToElements = function (parameters) {
785
- return __awaiter(this, void 0, void 0, function () {
786
- var _this = this;
787
- return __generator(this, function (_a) {
788
- switch (_a.label) {
789
- case 0: return [4 /*yield*/, Promise.all(this.elements.map(function (element) { return _this.commitParametersToVariantParameterizable(parameters, element, 'elements'); }))];
790
- case 1:
791
- _a.sent();
792
- return [2 /*return*/];
793
- }
794
- });
795
- });
796
- };
797
- /**
798
- * Commits given parameters to all {@link ViewerLight}s.
799
- */
800
- Variant.prototype.commitParametersToViewerLights = function (parameters) {
801
- return __awaiter(this, void 0, void 0, function () {
802
- var _this = this;
803
- return __generator(this, function (_a) {
804
- switch (_a.label) {
805
- case 0: return [4 /*yield*/, Promise.all(this.viewerLights.map(function (viewerLight) {
806
- return _this.commitParametersToVariantParameterizable(parameters, viewerLight, 'lights');
807
- }))];
808
- case 1:
809
- _a.sent();
810
- return [2 /*return*/];
811
- }
812
- });
813
- });
814
- };
815
- /**
816
- * Commits given parameters to a {@link VariantParameterizable} and updates the according definition with given
817
- * key in the {@link StructureJson}. The `definitionKey` "elements" for example will update the definition in
818
- * `this.structureJson.elements`.
819
- */
820
- Variant.prototype.commitParametersToVariantParameterizable = function (parameters, parameterizable, definitionKey) {
821
- return __awaiter(this, void 0, void 0, function () {
822
- var initialDefinition, initialDefinitionStr, _parameters, parameter, dpp, parameterValue, parameterizableParameter, search, definition;
823
- return __generator(this, function (_a) {
824
- switch (_a.label) {
825
- case 0:
826
- initialDefinition = get(this._structureJson, definitionKey)[parameterizable.name];
827
- initialDefinitionStr = JSON.stringify(initialDefinition);
828
- _parameters = {};
829
- for (parameter in parameters) {
830
- dpp = DottedPath.create(parameter);
831
- if (dpp.shiftPart() !== parameterizable.name) {
832
- continue;
833
- }
834
- parameterValue = parameters[parameter];
835
- parameterizableParameter = dpp.path;
836
- // If the variant is explicitly hidden, we must not override the visibility with element parameters. We need
837
- // an exception for visibility to avoid overloading already applied element parameters with element parameters
838
- // defined in the variant spec ("dotted parameters").
839
- // @see https://github.com/Combeenation/3d-viewer/issues/44
840
- if (parameterizableParameter === Parameter.VISIBLE && parameters[Parameter.VISIBLE] === false) {
841
- parameterValue = false;
842
- }
843
- _parameters[parameterizableParameter] = parameterValue;
844
- search = new RegExp("\\$\\{" + parameterizableParameter + "\\}", 'g');
845
- initialDefinitionStr = initialDefinitionStr.replace(search, parameterValue.toString());
846
- }
847
- definition = get(this.structureJson, definitionKey);
848
- definition[this.name] = JSON.parse(initialDefinitionStr);
849
- set(this.structureJson, definitionKey, definition);
850
- return [4 /*yield*/, parameterizable.commitParameters(_parameters)];
851
- case 1: return [2 /*return*/, _a.sent()];
852
- }
853
- });
854
- });
855
- };
856
- /**
857
- * Commits given {@link Parameter} to the {@link Variant}'s {@link Element}s.
858
- */
859
- Variant.prototype.commitParameterToElements = function (parameter, value) {
860
- return __awaiter(this, void 0, void 0, function () {
861
- var promises, _i, _a, element, paramShowsElement, elementVisibleParamPath, elementIsHiddenViaParams, elementMaterialParamPath, elementMaterialParamValue;
862
- return __generator(this, function (_b) {
863
- switch (_b.label) {
864
- case 0:
865
- promises = [];
866
- _i = 0, _a = this.elements;
867
- _b.label = 1;
868
- case 1:
869
- if (!(_i < _a.length)) return [3 /*break*/, 5];
870
- element = _a[_i];
871
- paramShowsElement = Parameter.VISIBLE === parameter && value;
872
- elementVisibleParamPath = DottedPath.create([element.name, Parameter.VISIBLE]).toString();
873
- elementIsHiddenViaParams = this.inheritedParameters[elementVisibleParamPath] === false;
874
- if (paramShowsElement && elementIsHiddenViaParams)
875
- return [3 /*break*/, 4];
876
- elementMaterialParamPath = DottedPath.create([element.name, Parameter.MATERIAL]).toString();
877
- elementMaterialParamValue = this.inheritedParameters[elementMaterialParamPath];
878
- if (!(paramShowsElement && elementMaterialParamValue)) return [3 /*break*/, 3];
879
- // To discuss: Should we rather use `this.commitParametersToElements` here?
880
- // I'm not really sure about the actual differences, both seem to do the job 🤷‍♂️
881
- // To discuss: Should we actively `await` this (as is) or should we also push the resulting promise into the
882
- // `promises` array as dome some lines below?
883
- // I wasn't sure whether not awaiting this could result in "not guaranteed application order" of
884
- // new visibility & material param value...
885
- return [4 /*yield*/, element.commitParameter(Parameter.MATERIAL, elementMaterialParamValue)];
886
- case 2:
887
- // To discuss: Should we rather use `this.commitParametersToElements` here?
888
- // I'm not really sure about the actual differences, both seem to do the job 🤷‍♂️
889
- // To discuss: Should we actively `await` this (as is) or should we also push the resulting promise into the
890
- // `promises` array as dome some lines below?
891
- // I wasn't sure whether not awaiting this could result in "not guaranteed application order" of
892
- // new visibility & material param value...
893
- _b.sent();
894
- _b.label = 3;
895
- case 3:
896
- promises.push(element.commitParameter(parameter, value));
897
- _b.label = 4;
898
- case 4:
899
- _i++;
900
- return [3 /*break*/, 1];
901
- case 5: return [4 /*yield*/, Promise.all(promises)];
902
- case 6:
903
- _b.sent();
904
- return [2 /*return*/, this];
905
- }
906
- });
907
- });
908
- };
909
- /**
910
- * Commits given {@link Parameter} to the {@link Variant}'s {@link Element}s.
911
- */
912
- Variant.prototype.commitParameterToViewerLights = function (parameter, value) {
913
- return __awaiter(this, void 0, void 0, function () {
914
- var promises, _i, _a, viewerLight;
915
- return __generator(this, function (_b) {
916
- switch (_b.label) {
917
- case 0:
918
- promises = [];
919
- for (_i = 0, _a = this.viewerLights; _i < _a.length; _i++) {
920
- viewerLight = _a[_i];
921
- promises.push(viewerLight.commitParameter(parameter, value));
922
- }
923
- return [4 /*yield*/, Promise.all(promises)];
924
- case 1:
925
- _b.sent();
926
- return [2 /*return*/, this];
927
- }
928
- });
929
- });
930
- };
931
- /**
932
- * Adds the default {@link ParameterObserver}s which are called every time {@link commitParameters} is called.
933
- */
934
- Variant.prototype.addParameterObservers = function () {
935
- var _this = this;
936
- this._parameterObservers.set(Parameter.VISIBLE, [
937
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
938
- return __generator(this, function (_a) {
939
- switch (_a.label) {
940
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.VISIBLE, newValue)];
941
- case 1:
942
- _a.sent();
943
- return [4 /*yield*/, variant.commitParameterToViewerLights(Parameter.VISIBLE, newValue)];
944
- case 2:
945
- _a.sent();
946
- return [2 /*return*/];
947
- }
948
- });
949
- }); },
950
- ]);
951
- this._parameterObservers.set(Parameter.SCALING, [
952
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
953
- return __generator(this, function (_a) {
954
- switch (_a.label) {
955
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.SCALING, newValue)];
956
- case 1:
957
- _a.sent();
958
- return [4 /*yield*/, variant.commitParameterToViewerLights(Parameter.SCALING, newValue)];
959
- case 2:
960
- _a.sent();
961
- return [2 /*return*/];
962
- }
963
- });
964
- }); },
965
- ]);
966
- this._parameterObservers.set(Parameter.MATERIAL, [
967
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
968
- return __generator(this, function (_a) {
969
- switch (_a.label) {
970
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.MATERIAL, newValue)];
971
- case 1:
972
- _a.sent();
973
- return [2 /*return*/];
974
- }
975
- });
976
- }); },
977
- ]);
978
- this._parameterObservers.set(Parameter.MATERIAL_COLOR, [
979
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
980
- return __generator(this, function (_a) {
981
- switch (_a.label) {
982
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.MATERIAL_COLOR, newValue)];
983
- case 1:
984
- _a.sent();
985
- return [2 /*return*/];
986
- }
987
- });
988
- }); },
989
- ]);
990
- this._parameterObservers.set(Parameter.MATERIAL_METALLNESS, [
991
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
992
- return __generator(this, function (_a) {
993
- switch (_a.label) {
994
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.MATERIAL_METALLNESS, newValue)];
995
- case 1:
996
- _a.sent();
997
- return [2 /*return*/];
998
- }
999
- });
1000
- }); },
1001
- ]);
1002
- this._parameterObservers.set(Parameter.MATERIAL_ROUGHNESS, [
1003
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
1004
- return __generator(this, function (_a) {
1005
- switch (_a.label) {
1006
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.MATERIAL_ROUGHNESS, newValue)];
1007
- case 1:
1008
- _a.sent();
1009
- return [2 /*return*/];
1010
- }
1011
- });
1012
- }); },
1013
- ]);
1014
- this._parameterObservers.set(Parameter.HIGHLIGHT_COLOR, [
1015
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
1016
- return __generator(this, function (_a) {
1017
- switch (_a.label) {
1018
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.HIGHLIGHT_COLOR, newValue)];
1019
- case 1:
1020
- _a.sent();
1021
- return [2 /*return*/];
1022
- }
1023
- });
1024
- }); },
1025
- ]);
1026
- this._parameterObservers.set(Parameter.HIGHLIGHTED, [
1027
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
1028
- return __generator(this, function (_a) {
1029
- switch (_a.label) {
1030
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.HIGHLIGHTED, newValue)];
1031
- case 1:
1032
- _a.sent();
1033
- return [2 /*return*/];
1034
- }
1035
- });
1036
- }); },
1037
- ]);
1038
- this._parameterObservers.set(Parameter.POSITION, [
1039
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
1040
- return __generator(this, function (_a) {
1041
- switch (_a.label) {
1042
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.POSITION, newValue)];
1043
- case 1:
1044
- _a.sent();
1045
- return [4 /*yield*/, variant.commitParameterToViewerLights(Parameter.POSITION, newValue)];
1046
- case 2:
1047
- _a.sent();
1048
- return [2 /*return*/];
1049
- }
1050
- });
1051
- }); },
1052
- ]);
1053
- this._parameterObservers.set(Parameter.ROTATION, [
1054
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
1055
- return __generator(this, function (_a) {
1056
- switch (_a.label) {
1057
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.ROTATION, newValue)];
1058
- case 1:
1059
- _a.sent();
1060
- return [4 /*yield*/, variant.commitParameterToViewerLights(Parameter.ROTATION, newValue)];
1061
- case 2:
1062
- _a.sent();
1063
- return [2 /*return*/];
1064
- }
1065
- });
1066
- }); },
1067
- ]);
1068
- this._parameterObservers.set(Parameter.CAST_SHADOW, [
1069
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
1070
- return __generator(this, function (_a) {
1071
- switch (_a.label) {
1072
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.CAST_SHADOW, newValue)];
1073
- case 1:
1074
- _a.sent();
1075
- return [2 /*return*/];
1076
- }
1077
- });
1078
- }); },
1079
- ]);
1080
- this._parameterObservers.set(Parameter.CAST_SHADOW_FROM_LIGHTS, [
1081
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
1082
- return __generator(this, function (_a) {
1083
- switch (_a.label) {
1084
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.CAST_SHADOW_FROM_LIGHTS, newValue)];
1085
- case 1:
1086
- _a.sent();
1087
- return [2 /*return*/];
1088
- }
1089
- });
1090
- }); },
1091
- ]);
1092
- this._parameterObservers.set(Parameter.RECEIVE_SHADOWS, [
1093
- function (variant, oldValue, newValue) { return __awaiter(_this, void 0, void 0, function () {
1094
- return __generator(this, function (_a) {
1095
- switch (_a.label) {
1096
- case 0: return [4 /*yield*/, variant.commitParameterToElements(Parameter.RECEIVE_SHADOWS, newValue)];
1097
- case 1:
1098
- _a.sent();
1099
- return [2 /*return*/];
1100
- }
1101
- });
1102
- }); },
1103
- ]);
1104
- return this;
1105
- };
1106
- /**
1107
- * Creates {@link Element}s and clones nodes into them.
1108
- */
1109
- Variant.prototype.createElements = function () {
1110
- return __awaiter(this, void 0, void 0, function () {
1111
- var _a, _b, _i, name_2, _c, _d;
1112
- var _this = this;
1113
- return __generator(this, function (_e) {
1114
- switch (_e.label) {
1115
- case 0:
1116
- _a = [];
1117
- for (_b in this.structureJson.elements || {})
1118
- _a.push(_b);
1119
- _i = 0;
1120
- _e.label = 1;
1121
- case 1:
1122
- if (!(_i < _a.length)) return [3 /*break*/, 4];
1123
- name_2 = _a[_i];
1124
- _d = (_c = this.elements).push;
1125
- return [4 /*yield*/, Element.create(this, name_2)];
1126
- case 2:
1127
- _d.apply(_c, [_e.sent()]);
1128
- _e.label = 3;
1129
- case 3:
1130
- _i++;
1131
- return [3 /*break*/, 1];
1132
- case 4:
1133
- // inject node meta to all inherited elements
1134
- // we do this to inject the deepest and most concrete variant information to all cloned nodes in the tree
1135
- this.inheritedElements.forEach(function (element) {
1136
- element.nodes.forEach(function (node) {
1137
- injectNodeMetadata(node, { variant: _this, variantParameterizable: element });
1138
- });
1139
- });
1140
- return [2 /*return*/, this];
1141
- }
1142
- });
1143
- });
1144
- };
1145
- /**
1146
- * Creates {@link ViewerLight}s.
1147
- */
1148
- Variant.prototype.createViewerLights = function () {
1149
- return __awaiter(this, void 0, void 0, function () {
1150
- var _a, _b, _i, name_3, _c, _d;
1151
- var _this = this;
1152
- return __generator(this, function (_e) {
1153
- switch (_e.label) {
1154
- case 0:
1155
- _a = [];
1156
- for (_b in this.structureJson.lights || {})
1157
- _a.push(_b);
1158
- _i = 0;
1159
- _e.label = 1;
1160
- case 1:
1161
- if (!(_i < _a.length)) return [3 /*break*/, 4];
1162
- name_3 = _a[_i];
1163
- _d = (_c = this.viewerLights).push;
1164
- return [4 /*yield*/, ViewerLight.create(this, name_3)];
1165
- case 2:
1166
- _d.apply(_c, [_e.sent()]);
1167
- _e.label = 3;
1168
- case 3:
1169
- _i++;
1170
- return [3 /*break*/, 1];
1171
- case 4:
1172
- this.inheritedViewerLights.forEach(function (viewerLight) {
1173
- injectNodeMetadata(viewerLight.light, { variant: _this, variantParameterizable: viewerLight });
1174
- });
1175
- return [2 /*return*/, this];
1176
- }
1177
- });
1178
- });
1179
- };
1180
- /**
1181
- * Bootstrapping for parameters. It sets the `parametersInitialized` to true for all ancestors.
1182
- */
1183
- Variant.prototype.bootstrapParameters = function (parameters) {
1184
- return __awaiter(this, void 0, void 0, function () {
1185
- return __generator(this, function (_a) {
1186
- switch (_a.label) {
1187
- case 0: return [4 /*yield*/, this.commitParameters(merge(cloneDeep(this.parameters), parameters))];
1188
- case 1:
1189
- _a.sent();
1190
- concat(this.ancestors, this).forEach(function (ancestor) { return (ancestor.parametersInitialized = true); });
1191
- return [2 /*return*/, this];
1192
- }
1193
- });
1194
- });
1195
- };
1196
- return Variant;
1197
- }(Parameterizable));
1198
- export { Variant };
1199
- //# sourceMappingURL=variant.js.map