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