@roomle/web-sdk 2.60.0-alpha.2 → 2.60.0-alpha.3

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 (442) hide show
  1. package/lib/TextGeometry-0776cbf7.js +2 -0
  2. package/lib/TextGeometry-0776cbf7.js.map +1 -0
  3. package/lib/TextGeometry-a3187fcf.nomodule.js +2 -0
  4. package/lib/TextGeometry-a3187fcf.nomodule.js.map +1 -0
  5. package/lib/banana-for-scale-1cd9a2fc.js +2 -0
  6. package/lib/{banana-for-scale-42f1dc5b.js.map → banana-for-scale-1cd9a2fc.js.map} +1 -1
  7. package/lib/banana-for-scale-70f00b0d.nomodule.js +2 -0
  8. package/lib/{banana-for-scale-f49704e0.nomodule.js.map → banana-for-scale-70f00b0d.nomodule.js.map} +1 -1
  9. package/lib/{budgeteer-measure-21e9de2e.js → budgeteer-measure-7daaf07a.js} +2 -2
  10. package/lib/{budgeteer-measure-21e9de2e.js.map → budgeteer-measure-7daaf07a.js.map} +1 -1
  11. package/lib/budgeteer-measure.nomodule.js +1 -1
  12. package/lib/component-dimensioning-5fb755f6.js +2 -0
  13. package/lib/component-dimensioning-5fb755f6.js.map +1 -0
  14. package/lib/component-dimensioning-72e9b95a.nomodule.js +2 -0
  15. package/lib/component-dimensioning-72e9b95a.nomodule.js.map +1 -0
  16. package/lib/component-raycast-helper-37e29c9e.js +2 -0
  17. package/lib/component-raycast-helper-37e29c9e.js.map +1 -0
  18. package/lib/component-raycast-helper-88babaeb.nomodule.js +2 -0
  19. package/lib/component-raycast-helper-88babaeb.nomodule.js.map +1 -0
  20. package/lib/configurator-55acafcc.nomodule.js +2 -0
  21. package/lib/configurator-55acafcc.nomodule.js.map +1 -0
  22. package/lib/configurator-89ce03c4.js +2 -0
  23. package/lib/configurator-89ce03c4.js.map +1 -0
  24. package/lib/configurator-dummy-app.js +1 -1
  25. package/lib/configurator-dummy-app.js.map +1 -1
  26. package/lib/configurator-dummy.html +1 -0
  27. package/lib/configurator-main-07f34c9f.js +2 -0
  28. package/lib/configurator-main-07f34c9f.js.map +1 -0
  29. package/lib/configurator-main.nomodule.js +1 -1
  30. package/lib/continuous-drawing-helper-14c9e7da.js +2 -0
  31. package/lib/continuous-drawing-helper-14c9e7da.js.map +1 -0
  32. package/lib/continuous-drawing-helper-a59e7a93.nomodule.js +2 -0
  33. package/lib/continuous-drawing-helper-a59e7a93.nomodule.js.map +1 -0
  34. package/lib/default-light-setting-3531c5f5.js +2 -0
  35. package/lib/default-light-setting-3531c5f5.js.map +1 -0
  36. package/lib/default-light-setting-bcb1df58.nomodule.js +2 -0
  37. package/lib/default-light-setting-bcb1df58.nomodule.js.map +1 -0
  38. package/lib/definitions/common-core/__tests__/image-renderer.d.ts +13 -0
  39. package/lib/definitions/common-core/config/environment.d.ts +2 -1
  40. package/lib/definitions/common-core/mock/mock-draco-loader.d.ts +6 -0
  41. package/lib/definitions/common-core/mock/mock-gltf-loader.d.ts +9 -0
  42. package/lib/definitions/common-core/mock/mock-image-renderer.d.ts +18 -0
  43. package/lib/definitions/common-core/mock/mock-pixotron.d.ts +5 -5
  44. package/lib/definitions/common-core/mock/mock-utils.d.ts +2 -2
  45. package/lib/definitions/common-core/mock/three-mock.d.ts +10 -1
  46. package/lib/definitions/common-core/src/cameracontrol/camera-control-2d.d.ts +5 -4
  47. package/lib/definitions/common-core/src/cameracontrol/camera-control-3d.d.ts +11 -10
  48. package/lib/definitions/common-core/src/cameracontrol/camera-control.d.ts +13 -12
  49. package/lib/definitions/common-core/src/environment/background-environment.d.ts +4 -3
  50. package/lib/definitions/common-core/src/environment/dynamic-environment-setting-loader.d.ts +3 -2
  51. package/lib/definitions/common-core/src/environment/environment.d.ts +7 -6
  52. package/lib/definitions/common-core/src/environment/ground-projected-environment.d.ts +14 -0
  53. package/lib/definitions/common-core/src/lightsetting/dynamic-light-setting-loader.d.ts +7 -4
  54. package/lib/definitions/common-core/src/lightsetting/dynamic-light-setting.d.ts +4 -3
  55. package/lib/definitions/common-core/src/lightsetting/light-setting.d.ts +5 -4
  56. package/lib/definitions/common-core/src/main.d.ts +2 -1
  57. package/lib/definitions/common-core/src/rapi-access.d.ts +1 -1
  58. package/lib/definitions/common-core/src/services/cache-holder.d.ts +3 -2
  59. package/lib/definitions/common-core/src/services/common-kernel-access.d.ts +3 -1
  60. package/lib/definitions/common-core/src/services/hdr-environment-loader.d.ts +18 -0
  61. package/lib/definitions/common-core/src/static-files/environment-maps.d.ts +3 -0
  62. package/lib/definitions/common-core/src/static-files/roomle-core.d.ts +1 -0
  63. package/lib/definitions/common-core/src/static-files/three.d.ts +0 -13
  64. package/lib/definitions/common-core/src/utils/dom-helper.d.ts +2 -1
  65. package/lib/definitions/common-core/src/utils/fps-couter.d.ts +12 -0
  66. package/lib/definitions/common-core/src/utils/init-data.d.ts +3 -5
  67. package/lib/definitions/common-core/src/utils/kernel-utils.d.ts +8 -7
  68. package/lib/definitions/common-core/src/utils/material-creator.d.ts +12 -0
  69. package/lib/definitions/common-core/src/utils/shims.d.ts +12 -0
  70. package/lib/definitions/common-core/src/utils/stats-helper.d.ts +2 -4
  71. package/lib/definitions/common-core/src/utils/threejs-utils.d.ts +43 -40
  72. package/lib/definitions/common-core/src/view-model/configurator-view-model.d.ts +6 -5
  73. package/lib/definitions/common-core/src/view-model/plan-element-view-model.d.ts +14 -13
  74. package/lib/definitions/common-core/src/view-model/plan-object-view-model.d.ts +2 -1
  75. package/lib/definitions/common-core/src/webgl/EnvMapReader.d.ts +1 -1
  76. package/lib/definitions/common-core/src/webgl/baked-shadow-plane.d.ts +4 -3
  77. package/lib/definitions/common-core/src/webgl/hdr-env-map-reader.d.ts +18 -0
  78. package/lib/definitions/common-core/src/webgl/image-renderer.d.ts +16 -9
  79. package/lib/definitions/common-core/src/webgl/mesh-generator.d.ts +15 -15
  80. package/lib/definitions/common-core/src/webgl/renderer/baked-ground-contact-shadow.d.ts +59 -0
  81. package/lib/definitions/common-core/src/webgl/renderer/effect-pass.d.ts +108 -0
  82. package/lib/definitions/common-core/src/webgl/renderer/gbuffer-render-target.d.ts +43 -0
  83. package/lib/definitions/common-core/src/webgl/renderer/ground-reflection-pass.d.ts +72 -0
  84. package/lib/definitions/common-core/src/webgl/renderer/light-source-detection.d.ts +76 -0
  85. package/lib/definitions/common-core/src/webgl/renderer/outline-pass.d.ts +56 -0
  86. package/lib/definitions/common-core/src/webgl/renderer/outline-renderer.d.ts +32 -0
  87. package/lib/definitions/common-core/src/webgl/renderer/render-utility.d.ts +83 -0
  88. package/lib/definitions/common-core/src/webgl/renderer/scene-renderer-gui.d.ts +16 -0
  89. package/lib/definitions/common-core/src/webgl/renderer/scene-renderer.d.ts +111 -0
  90. package/lib/definitions/common-core/src/webgl/renderer/screen-space-shadow-map.d.ts +139 -0
  91. package/lib/definitions/common-core/src/webgl/renderer/shader-utility.d.ts +98 -0
  92. package/lib/definitions/common-core/src/webgl/renderer/shadow-and-ao-pass.d.ts +123 -0
  93. package/lib/definitions/common-core/src/webgl/roomle-component-factory.d.ts +24 -22
  94. package/lib/definitions/common-core/src/webgl/roomle-webl-renderer.d.ts +42 -0
  95. package/lib/definitions/common-core/src/webgl/scene-event-handler.d.ts +2 -1
  96. package/lib/definitions/common-core/src/webgl/scene-manager.d.ts +21 -27
  97. package/lib/definitions/common-core/src/webgl/static-item-loader.d.ts +5 -6
  98. package/lib/definitions/configurator-core/src/roomle-configurator.d.ts +7 -11
  99. package/lib/definitions/configurator-core/src/utils/async-dependency-loader.d.ts +2 -1
  100. package/lib/definitions/configurator-core/src/utils/component-dimensioning-helper.d.ts +2 -1
  101. package/lib/definitions/configurator-core/src/utils/component-dimensioning.d.ts +4 -2
  102. package/lib/definitions/configurator-core/src/utils/component-raycast-helper.d.ts +3 -2
  103. package/lib/definitions/configurator-core/src/utils/dimensioning-helper.d.ts +10 -9
  104. package/lib/definitions/configurator-core/src/utils/raycast-helper.d.ts +8 -7
  105. package/lib/definitions/configurator-core/src/utils/text-with-background.d.ts +5 -3
  106. package/lib/definitions/configurator-core/src/utils/ui-intersection-helper.d.ts +3 -2
  107. package/lib/definitions/configurator-core/src/webgl/banana-for-scale.d.ts +4 -3
  108. package/lib/definitions/configurator-core/src/webgl/configurator-mesh-generator.d.ts +5 -4
  109. package/lib/definitions/configurator-core/src/webgl/configurator-scene-event-handler.d.ts +3 -2
  110. package/lib/definitions/configurator-core/src/webgl/configurator-scene-manager.d.ts +6 -9
  111. package/lib/definitions/configurator-core/src/webgl/environment/floor-environment.d.ts +6 -7
  112. package/lib/definitions/configurator-core/src/webgl/lightsetting/default-light-setting.d.ts +3 -2
  113. package/lib/definitions/configurator-core/src/webgl/lightsetting/hd-light-setting.d.ts +2 -1
  114. package/lib/definitions/configurator-core/src/webgl/lightsetting/top-image-light-setting.d.ts +2 -1
  115. package/lib/definitions/configurator-core/src/webgl/plugin-system.d.ts +18 -17
  116. package/lib/definitions/glb-viewer-core/src/camera-control/adjustable-camera-control-3d.d.ts +3 -2
  117. package/lib/definitions/glb-viewer-core/src/roomle-glb-viewer.d.ts +2 -9
  118. package/lib/definitions/glb-viewer-core/src/webgl/glb-viewer-light-setting.d.ts +2 -1
  119. package/lib/definitions/glb-viewer-core/src/webgl/glb-viewer-scene-manager.d.ts +5 -7
  120. package/lib/definitions/material-viewer/src/roomle-material-viewer.d.ts +2 -9
  121. package/lib/definitions/material-viewer/src/webgl/material-viewer-scene-manager.d.ts +2 -4
  122. package/lib/definitions/planner-core/src/camera-control/camera-control-first-person.d.ts +4 -3
  123. package/lib/definitions/planner-core/src/roomle-planner.d.ts +4 -4
  124. package/lib/definitions/planner-core/src/utils/planner-scene-manager.d.ts +2 -1
  125. package/lib/definitions/planner-core/src/view-model/ceiling-plan-element-view-model.d.ts +2 -1
  126. package/lib/definitions/planner-core/src/view-model/construction-plan-object-view-model.d.ts +3 -2
  127. package/lib/definitions/planner-core/src/view-model/floor-plan-element-view-model.d.ts +2 -1
  128. package/lib/definitions/planner-core/src/view-model/node-plan-element-view-model.d.ts +4 -2
  129. package/lib/definitions/planner-core/src/view-model/plan-view-model.d.ts +7 -6
  130. package/lib/definitions/planner-core/src/view-model/wall-plan-element-view-model.d.ts +4 -3
  131. package/lib/definitions/planner-core/src/webgl/continuous-drawing-helper.d.ts +2 -1
  132. package/lib/definitions/planner-core/src/webgl/lightsetting/planner-light-setting.d.ts +3 -2
  133. package/lib/definitions/planner-core/src/webgl/planner-mesh-generator.d.ts +5 -4
  134. package/lib/definitions/planner-core/src/webgl/planner-scene-event-handler.d.ts +7 -6
  135. package/lib/definitions/planner-core/src/webgl/planner-scene-manager.d.ts +5 -7
  136. package/lib/definitions/typings/configurator-kernel-container.d.ts +3 -2
  137. package/lib/definitions/typings/kernel.d.ts +17 -4
  138. package/lib/definitions/typings/pixotron.d.ts +7 -28
  139. package/lib/definitions/typings/planner-kernel-container.d.ts +4 -3
  140. package/lib/definitions/typings/stats.d.ts +1 -17
  141. package/lib/dimensioning-helper-79e88370.nomodule.js +2 -0
  142. package/lib/{dimensioning-helper-e0cb55a5.nomodule.js.map → dimensioning-helper-79e88370.nomodule.js.map} +1 -1
  143. package/lib/dimensioning-helper-89e15d5c.js +2 -0
  144. package/lib/{dimensioning-helper-db71ae43.js.map → dimensioning-helper-89e15d5c.js.map} +1 -1
  145. package/lib/glb-viewer-220acd23.nomodule.js +2 -0
  146. package/lib/{glb-viewer-04fd6e23.nomodule.js.map → glb-viewer-220acd23.nomodule.js.map} +1 -1
  147. package/lib/glb-viewer-4f0558f5.js +2 -0
  148. package/lib/{glb-viewer-305d8bd7.js.map → glb-viewer-4f0558f5.js.map} +1 -1
  149. package/lib/glb-viewer-dummy-app.js +1 -1
  150. package/lib/glb-viewer-dummy-app.js.map +1 -1
  151. package/lib/glb-viewer-main-e4717d13.js +2 -0
  152. package/lib/glb-viewer-main-e4717d13.js.map +1 -0
  153. package/lib/glb-viewer-main.nomodule.js +1 -1
  154. package/lib/legacy/TextGeometry-7b0ba2a4.legacy.js +2 -0
  155. package/lib/legacy/TextGeometry-7b0ba2a4.legacy.js.map +1 -0
  156. package/lib/legacy/banana-for-scale-e04c4cff.legacy.js +2 -0
  157. package/lib/legacy/{banana-for-scale-7bad9610.legacy.js.map → banana-for-scale-e04c4cff.legacy.js.map} +1 -1
  158. package/lib/legacy/budgeteer-measure.legacy.js +1 -1
  159. package/lib/legacy/component-dimensioning-5060f862.legacy.js +2 -0
  160. package/lib/legacy/component-dimensioning-5060f862.legacy.js.map +1 -0
  161. package/lib/legacy/component-raycast-helper-07671bc4.legacy.js +2 -0
  162. package/lib/legacy/component-raycast-helper-07671bc4.legacy.js.map +1 -0
  163. package/lib/legacy/configurator-b4e0e93e.legacy.js +2 -0
  164. package/lib/legacy/configurator-b4e0e93e.legacy.js.map +1 -0
  165. package/lib/legacy/configurator-main.legacy.js +1 -1
  166. package/lib/legacy/continuous-drawing-helper-a7c2d434.legacy.js +2 -0
  167. package/lib/legacy/continuous-drawing-helper-a7c2d434.legacy.js.map +1 -0
  168. package/lib/legacy/default-light-setting-195b2ab7.legacy.js +2 -0
  169. package/lib/legacy/default-light-setting-195b2ab7.legacy.js.map +1 -0
  170. package/lib/legacy/dimensioning-helper-7d4bb1f1.legacy.js +2 -0
  171. package/lib/legacy/{dimensioning-helper-be8595e0.legacy.js.map → dimensioning-helper-7d4bb1f1.legacy.js.map} +1 -1
  172. package/lib/legacy/glb-viewer-c0216056.legacy.js +2 -0
  173. package/lib/legacy/{glb-viewer-1aef71c0.legacy.js.map → glb-viewer-c0216056.legacy.js.map} +1 -1
  174. package/lib/legacy/glb-viewer-main.legacy.js +1 -1
  175. package/lib/legacy/main-thread-to-worker-ebe10a2b.legacy.js +7 -0
  176. package/lib/legacy/main-thread-to-worker-ebe10a2b.legacy.js.map +1 -0
  177. package/lib/legacy/material-viewer-32a9186e.legacy.js +2 -0
  178. package/lib/legacy/material-viewer-32a9186e.legacy.js.map +1 -0
  179. package/lib/legacy/material-viewer-main.legacy.js +1 -1
  180. package/lib/legacy/planner-b3649aa5.legacy.js +2 -0
  181. package/lib/legacy/planner-b3649aa5.legacy.js.map +1 -0
  182. package/lib/legacy/planner-main.legacy.js +1 -1
  183. package/lib/legacy/roomle-configurator-9d57ec02.legacy.js +2 -0
  184. package/lib/legacy/roomle-configurator-9d57ec02.legacy.js.map +1 -0
  185. package/lib/legacy/roomle-dependency-injection-ddf49a56.legacy.js +9 -0
  186. package/lib/legacy/roomle-dependency-injection-ddf49a56.legacy.js.map +1 -0
  187. package/lib/legacy/roomle-sdk.legacy.js +1 -1
  188. package/lib/legacy/scene-manager-f62f275a.legacy.js +2 -0
  189. package/lib/legacy/scene-manager-f62f275a.legacy.js.map +1 -0
  190. package/lib/legacy/script-loader-0bad813a.legacy.js +2 -0
  191. package/lib/legacy/script-loader-0bad813a.legacy.js.map +1 -0
  192. package/lib/legacy/static/Tween-d57ee5d181fce582.js +767 -0
  193. package/lib/legacy/static/default_1k-2aa6d42244d30fb1.exr +0 -0
  194. package/lib/legacy/static/default_256-f1c66a2764f88cc0.exr +0 -0
  195. package/lib/legacy/static/draco_decoder-b048235474cbf09e.wasm +0 -0
  196. package/lib/legacy/static/draco_decoder-dc7f397e2a2ebac4.js +34 -0
  197. package/lib/legacy/static/draco_wasm_wrapper-6263f3a4b71cdf3b.js +117 -0
  198. package/lib/legacy/static/legacy_env-d5810ec5057d4716.exr +0 -0
  199. package/lib/{stats-helper-9c26a9c0.nomodule.js → legacy/stats-helper-546b9aa8.legacy.js} +2 -2
  200. package/lib/legacy/stats-helper-546b9aa8.legacy.js.map +1 -0
  201. package/lib/legacy/tools-core-2745a165.legacy.js +2 -0
  202. package/lib/legacy/tools-core-2745a165.legacy.js.map +1 -0
  203. package/lib/main-thread-to-worker-29498ad3.js +7 -0
  204. package/lib/main-thread-to-worker-29498ad3.js.map +1 -0
  205. package/lib/main-thread-to-worker-a2554a6a.nomodule.js +8 -0
  206. package/lib/main-thread-to-worker-a2554a6a.nomodule.js.map +1 -0
  207. package/lib/material-viewer-015815c1.nomodule.js +2 -0
  208. package/lib/material-viewer-015815c1.nomodule.js.map +1 -0
  209. package/lib/material-viewer-eedffa51.js +2 -0
  210. package/lib/material-viewer-eedffa51.js.map +1 -0
  211. package/lib/material-viewer-main-24ebdc40.js +2 -0
  212. package/lib/material-viewer-main-24ebdc40.js.map +1 -0
  213. package/lib/material-viewer-main.nomodule.js +1 -1
  214. package/lib/planner-60e8f69a.nomodule.js +2 -0
  215. package/lib/planner-60e8f69a.nomodule.js.map +1 -0
  216. package/lib/planner-dummy-app.js +1 -1
  217. package/lib/planner-dummy-app.js.map +1 -1
  218. package/lib/planner-dummy.html +1 -0
  219. package/lib/planner-f9aa0a27.js +2 -0
  220. package/lib/planner-f9aa0a27.js.map +1 -0
  221. package/lib/planner-main-b3dffe75.js +2 -0
  222. package/lib/planner-main-b3dffe75.js.map +1 -0
  223. package/lib/planner-main.nomodule.js +1 -1
  224. package/lib/roomle-configurator-0a88aea7.js +2 -0
  225. package/lib/roomle-configurator-0a88aea7.js.map +1 -0
  226. package/lib/roomle-configurator-3ab6dfeb.nomodule.js +2 -0
  227. package/lib/roomle-configurator-3ab6dfeb.nomodule.js.map +1 -0
  228. package/lib/roomle-dependency-injection-2fde2714.nomodule.js +16 -0
  229. package/lib/roomle-dependency-injection-2fde2714.nomodule.js.map +1 -0
  230. package/lib/roomle-dependency-injection-5533da82.js +16 -0
  231. package/lib/roomle-dependency-injection-5533da82.js.map +1 -0
  232. package/lib/roomle-sdk-c61e6974.js +2 -0
  233. package/lib/roomle-sdk-c61e6974.js.map +1 -0
  234. package/lib/roomle-sdk.nomodule.js +1 -1
  235. package/lib/scene-manager-3ee00913.js +2 -0
  236. package/lib/scene-manager-3ee00913.js.map +1 -0
  237. package/lib/scene-manager-b2128ea9.nomodule.js +2 -0
  238. package/lib/scene-manager-b2128ea9.nomodule.js.map +1 -0
  239. package/lib/script-loader-69c064c2.nomodule.js +2 -0
  240. package/lib/script-loader-69c064c2.nomodule.js.map +1 -0
  241. package/lib/script-loader-de8249e5.js +2 -0
  242. package/lib/script-loader-de8249e5.js.map +1 -0
  243. package/lib/static/Tween-d57ee5d181fce582.js.map +1 -0
  244. package/lib/static/default_1k-2aa6d42244d30fb1.exr +0 -0
  245. package/lib/static/default_256-f1c66a2764f88cc0.exr +0 -0
  246. package/lib/static/draco_decoder-b048235474cbf09e.wasm +0 -0
  247. package/lib/static/draco_decoder-dc7f397e2a2ebac4.js +34 -0
  248. package/lib/static/draco_wasm_wrapper-6263f3a4b71cdf3b.js +117 -0
  249. package/lib/static/legacy_env-d5810ec5057d4716.exr +0 -0
  250. package/lib/stats-helper-6a0d378d.nomodule.js +2 -0
  251. package/lib/stats-helper-6a0d378d.nomodule.js.map +1 -0
  252. package/lib/stats-helper-969d208f.js +2 -0
  253. package/lib/stats-helper-969d208f.js.map +1 -0
  254. package/lib/{tools-core-d85bfa17.js → tools-core-6284706e.js} +2 -2
  255. package/lib/tools-core-6284706e.js.map +1 -0
  256. package/lib/tools-core-94cba552.nomodule.js +2 -0
  257. package/lib/tools-core-94cba552.nomodule.js.map +1 -0
  258. package/package.json +6 -4
  259. package/lib/banana-for-scale-42f1dc5b.js +0 -2
  260. package/lib/banana-for-scale-f49704e0.nomodule.js +0 -2
  261. package/lib/component-dimensioning-057d1f9f.nomodule.js +0 -2
  262. package/lib/component-dimensioning-057d1f9f.nomodule.js.map +0 -1
  263. package/lib/component-dimensioning-9f8009b8.js +0 -2
  264. package/lib/component-dimensioning-9f8009b8.js.map +0 -1
  265. package/lib/component-raycast-helper-01d2984c.js +0 -2
  266. package/lib/component-raycast-helper-01d2984c.js.map +0 -1
  267. package/lib/component-raycast-helper-1db43efc.nomodule.js +0 -2
  268. package/lib/component-raycast-helper-1db43efc.nomodule.js.map +0 -1
  269. package/lib/configurator-4ecaafca.nomodule.js +0 -2
  270. package/lib/configurator-4ecaafca.nomodule.js.map +0 -1
  271. package/lib/configurator-a73acc5a.js +0 -2
  272. package/lib/configurator-a73acc5a.js.map +0 -1
  273. package/lib/configurator-main-14811ccb.js +0 -2
  274. package/lib/configurator-main-14811ccb.js.map +0 -1
  275. package/lib/continuous-drawing-helper-69c971e8.nomodule.js +0 -2
  276. package/lib/continuous-drawing-helper-69c971e8.nomodule.js.map +0 -1
  277. package/lib/continuous-drawing-helper-eb1b4a47.js +0 -2
  278. package/lib/continuous-drawing-helper-eb1b4a47.js.map +0 -1
  279. package/lib/default-light-setting-8eeeb3da.js +0 -2
  280. package/lib/default-light-setting-8eeeb3da.js.map +0 -1
  281. package/lib/default-light-setting-ef6a0979.nomodule.js +0 -2
  282. package/lib/default-light-setting-ef6a0979.nomodule.js.map +0 -1
  283. package/lib/definitions/common-core/__tests__/environment/baked-shadow-environment.d.ts +0 -1
  284. package/lib/definitions/common-core/__tests__/three-loader.d.ts +0 -1
  285. package/lib/definitions/common-core/__tests__/webgl/baked-shadow-plane.d.ts +0 -1
  286. package/lib/definitions/common-core/__tests__/webgl/pixotron-util.d.ts +0 -1
  287. package/lib/definitions/common-core/mock/mock-environment-loader.d.ts +0 -5
  288. package/lib/definitions/common-core/mock/mock-plane-shadow-bake-pass.d.ts +0 -8
  289. package/lib/definitions/common-core/mock/pixotron-mock.d.ts +0 -5
  290. package/lib/definitions/common-core/src/dynamic-quality-setting-loader.d.ts +0 -35
  291. package/lib/definitions/common-core/src/environment/baked-shadow-environment.d.ts +0 -45
  292. package/lib/definitions/common-core/src/services/environment-loader.d.ts +0 -27
  293. package/lib/definitions/common-core/src/three-loader.d.ts +0 -11
  294. package/lib/definitions/common-core/src/webgl/pixotron-util.d.ts +0 -39
  295. package/lib/definitions/configurator-core/__tests__/configurator-image-renderer.d.ts +0 -1
  296. package/lib/dimensioning-helper-db71ae43.js +0 -2
  297. package/lib/dimensioning-helper-e0cb55a5.nomodule.js +0 -2
  298. package/lib/glb-viewer-04fd6e23.nomodule.js +0 -2
  299. package/lib/glb-viewer-305d8bd7.js +0 -2
  300. package/lib/glb-viewer-main-64649f2c.js +0 -2
  301. package/lib/glb-viewer-main-64649f2c.js.map +0 -1
  302. package/lib/legacy/banana-for-scale-7bad9610.legacy.js +0 -2
  303. package/lib/legacy/component-dimensioning-cabc5380.legacy.js +0 -2
  304. package/lib/legacy/component-dimensioning-cabc5380.legacy.js.map +0 -1
  305. package/lib/legacy/component-raycast-helper-3169ff61.legacy.js +0 -2
  306. package/lib/legacy/component-raycast-helper-3169ff61.legacy.js.map +0 -1
  307. package/lib/legacy/configurator-a5c2c92c.legacy.js +0 -2
  308. package/lib/legacy/configurator-a5c2c92c.legacy.js.map +0 -1
  309. package/lib/legacy/continuous-drawing-helper-02495806.legacy.js +0 -2
  310. package/lib/legacy/continuous-drawing-helper-02495806.legacy.js.map +0 -1
  311. package/lib/legacy/default-light-setting-c6c84dbc.legacy.js +0 -2
  312. package/lib/legacy/default-light-setting-c6c84dbc.legacy.js.map +0 -1
  313. package/lib/legacy/dimensioning-helper-be8595e0.legacy.js +0 -2
  314. package/lib/legacy/glb-viewer-1aef71c0.legacy.js +0 -2
  315. package/lib/legacy/main-thread-to-worker-84353cef.legacy.js +0 -2
  316. package/lib/legacy/main-thread-to-worker-84353cef.legacy.js.map +0 -1
  317. package/lib/legacy/material-viewer-4bd2076c.legacy.js +0 -2
  318. package/lib/legacy/material-viewer-4bd2076c.legacy.js.map +0 -1
  319. package/lib/legacy/pixotron-b035ec35.legacy.js +0 -2
  320. package/lib/legacy/pixotron-b035ec35.legacy.js.map +0 -1
  321. package/lib/legacy/planner-1cd6147c.legacy.js +0 -2
  322. package/lib/legacy/planner-1cd6147c.legacy.js.map +0 -1
  323. package/lib/legacy/roomle-configurator-70bd6103.legacy.js +0 -2
  324. package/lib/legacy/roomle-configurator-70bd6103.legacy.js.map +0 -1
  325. package/lib/legacy/roomle-dependency-injection-acdca8a9.legacy.js +0 -16
  326. package/lib/legacy/roomle-dependency-injection-acdca8a9.legacy.js.map +0 -1
  327. package/lib/legacy/script-loader-53bf7b92.legacy.js +0 -2
  328. package/lib/legacy/script-loader-53bf7b92.legacy.js.map +0 -1
  329. package/lib/legacy/static/CopyShader-cde53240fcc3e06e.js +0 -46
  330. package/lib/legacy/static/DRACOLoader-5edeeab4a8dbc0bd.js +0 -678
  331. package/lib/legacy/static/DepthShadowGenerator-a3a9d85ff2c3d24c.js +0 -266
  332. package/lib/legacy/static/EffectComposer-1e936e5d03ff43cc.js +0 -298
  333. package/lib/legacy/static/GLTFExporter-86edae059df3a219.js +0 -2297
  334. package/lib/legacy/static/GLTFLoader-5b296b5fb14cfe1a.js +0 -3279
  335. package/lib/legacy/static/GammaCorrectionShader-b3b56f244f0d1e0e.js +0 -45
  336. package/lib/legacy/static/HDRCubeTextureLoader-8f7805ba456eca09.js +0 -131
  337. package/lib/legacy/static/LuminosityHighPassShader-dd5826656142421d.js +0 -64
  338. package/lib/legacy/static/OutlinePass-f4bcd337cdd89b8d.js +0 -592
  339. package/lib/legacy/static/RGBELoader-5b196b2428d96312.js +0 -526
  340. package/lib/legacy/static/RectAreaLightUniformsLib-4b74882185efd473.js +0 -47
  341. package/lib/legacy/static/RenderPass-bc5df3810a01b2c6.js +0 -79
  342. package/lib/legacy/static/ShaderPass-31f36160e0ea282d.js +0 -66
  343. package/lib/legacy/static/Sky-6621935ea8a523af.js +0 -224
  344. package/lib/legacy/static/Tween-5ebfb82307807fdc.js +0 -767
  345. package/lib/legacy/static/dat.gui.min-24a0d861d5534d62.js +0 -2447
  346. package/lib/legacy/static/draco_decoder-3866672a1fa2f980.js +0 -31
  347. package/lib/legacy/static/draco_decoder-979e668167e37c95.wasm +0 -0
  348. package/lib/legacy/static/draco_wasm_wrapper-d775f9f135cb30ff.js +0 -129
  349. package/lib/legacy/static/pi.min-0272f873b3a4380a.js +0 -1
  350. package/lib/legacy/static/rthree-750136f8399d9f72.js +0 -2
  351. package/lib/legacy/static/shaders-940522a5e460efd1.json +0 -1
  352. package/lib/legacy/static/stats.min-f33a6e08a8864d76.js +0 -5
  353. package/lib/legacy/stats-helper-c0b5d8b6.legacy.js +0 -2
  354. package/lib/legacy/stats-helper-c0b5d8b6.legacy.js.map +0 -1
  355. package/lib/legacy/tools-core-227c6513.legacy.js +0 -2
  356. package/lib/legacy/tools-core-227c6513.legacy.js.map +0 -1
  357. package/lib/main-thread-to-worker-1651b1df.js +0 -2
  358. package/lib/main-thread-to-worker-1651b1df.js.map +0 -1
  359. package/lib/main-thread-to-worker-b7956e5b.nomodule.js +0 -2
  360. package/lib/main-thread-to-worker-b7956e5b.nomodule.js.map +0 -1
  361. package/lib/material-viewer-3fd75160.nomodule.js +0 -2
  362. package/lib/material-viewer-3fd75160.nomodule.js.map +0 -1
  363. package/lib/material-viewer-5324de36.js +0 -2
  364. package/lib/material-viewer-5324de36.js.map +0 -1
  365. package/lib/material-viewer-main-a45f2d04.js +0 -2
  366. package/lib/material-viewer-main-a45f2d04.js.map +0 -1
  367. package/lib/pixotron-cd9b0143.nomodule.js +0 -2
  368. package/lib/pixotron-cd9b0143.nomodule.js.map +0 -1
  369. package/lib/pixotron-e481d9b2.js +0 -2
  370. package/lib/pixotron-e481d9b2.js.map +0 -1
  371. package/lib/planner-377d1061.nomodule.js +0 -2
  372. package/lib/planner-377d1061.nomodule.js.map +0 -1
  373. package/lib/planner-b018f99c.js +0 -2
  374. package/lib/planner-b018f99c.js.map +0 -1
  375. package/lib/planner-main-ec5a6efa.js +0 -2
  376. package/lib/planner-main-ec5a6efa.js.map +0 -1
  377. package/lib/roomle-configurator-0d5ba529.nomodule.js +0 -2
  378. package/lib/roomle-configurator-0d5ba529.nomodule.js.map +0 -1
  379. package/lib/roomle-configurator-98c3c172.js +0 -2
  380. package/lib/roomle-configurator-98c3c172.js.map +0 -1
  381. package/lib/roomle-dependency-injection-7dcab742.nomodule.js +0 -16
  382. package/lib/roomle-dependency-injection-7dcab742.nomodule.js.map +0 -1
  383. package/lib/roomle-dependency-injection-f7298e7e.js +0 -16
  384. package/lib/roomle-dependency-injection-f7298e7e.js.map +0 -1
  385. package/lib/roomle-sdk-f9cc3d20.js +0 -2
  386. package/lib/roomle-sdk-f9cc3d20.js.map +0 -1
  387. package/lib/script-loader-17506a98.nomodule.js +0 -2
  388. package/lib/script-loader-17506a98.nomodule.js.map +0 -1
  389. package/lib/script-loader-c9cba6e8.js +0 -2
  390. package/lib/script-loader-c9cba6e8.js.map +0 -1
  391. package/lib/static/CopyShader-cde53240fcc3e06e.js +0 -1
  392. package/lib/static/CopyShader-cde53240fcc3e06e.js.map +0 -1
  393. package/lib/static/DRACOLoader-5edeeab4a8dbc0bd.js +0 -1
  394. package/lib/static/DRACOLoader-5edeeab4a8dbc0bd.js.map +0 -1
  395. package/lib/static/DepthShadowGenerator-a3a9d85ff2c3d24c.js +0 -1
  396. package/lib/static/DepthShadowGenerator-a3a9d85ff2c3d24c.js.map +0 -1
  397. package/lib/static/EffectComposer-1e936e5d03ff43cc.js +0 -1
  398. package/lib/static/EffectComposer-1e936e5d03ff43cc.js.map +0 -1
  399. package/lib/static/GLTFExporter-86edae059df3a219.js +0 -1
  400. package/lib/static/GLTFExporter-86edae059df3a219.js.map +0 -1
  401. package/lib/static/GLTFLoader-5b296b5fb14cfe1a.js +0 -1
  402. package/lib/static/GLTFLoader-5b296b5fb14cfe1a.js.map +0 -1
  403. package/lib/static/GammaCorrectionShader-b3b56f244f0d1e0e.js +0 -1
  404. package/lib/static/GammaCorrectionShader-b3b56f244f0d1e0e.js.map +0 -1
  405. package/lib/static/HDRCubeTextureLoader-8f7805ba456eca09.js +0 -1
  406. package/lib/static/HDRCubeTextureLoader-8f7805ba456eca09.js.map +0 -1
  407. package/lib/static/LuminosityHighPassShader-dd5826656142421d.js +0 -1
  408. package/lib/static/LuminosityHighPassShader-dd5826656142421d.js.map +0 -1
  409. package/lib/static/OutlinePass-f4bcd337cdd89b8d.js +0 -1
  410. package/lib/static/OutlinePass-f4bcd337cdd89b8d.js.map +0 -1
  411. package/lib/static/RGBELoader-5b196b2428d96312.js +0 -1
  412. package/lib/static/RGBELoader-5b196b2428d96312.js.map +0 -1
  413. package/lib/static/RectAreaLightUniformsLib-4b74882185efd473.js +0 -1
  414. package/lib/static/RectAreaLightUniformsLib-4b74882185efd473.js.map +0 -1
  415. package/lib/static/RenderPass-bc5df3810a01b2c6.js +0 -1
  416. package/lib/static/RenderPass-bc5df3810a01b2c6.js.map +0 -1
  417. package/lib/static/ShaderPass-31f36160e0ea282d.js +0 -1
  418. package/lib/static/ShaderPass-31f36160e0ea282d.js.map +0 -1
  419. package/lib/static/Sky-6621935ea8a523af.js +0 -1
  420. package/lib/static/Sky-6621935ea8a523af.js.map +0 -1
  421. package/lib/static/Tween-5ebfb82307807fdc.js.map +0 -1
  422. package/lib/static/dat.gui.min-24a0d861d5534d62.js +0 -1
  423. package/lib/static/dat.gui.min-24a0d861d5534d62.js.map +0 -1
  424. package/lib/static/draco_decoder-3866672a1fa2f980.js +0 -31
  425. package/lib/static/draco_decoder-979e668167e37c95.wasm +0 -0
  426. package/lib/static/draco_wasm_wrapper-d775f9f135cb30ff.js +0 -129
  427. package/lib/static/pi.min-0272f873b3a4380a.js +0 -1
  428. package/lib/static/pi.min-0272f873b3a4380a.js.map +0 -1
  429. package/lib/static/rthree-750136f8399d9f72.js +0 -1
  430. package/lib/static/rthree-750136f8399d9f72.js.map +0 -1
  431. package/lib/static/shaders-940522a5e460efd1.json +0 -1
  432. package/lib/static/stats.min-f33a6e08a8864d76.js +0 -1
  433. package/lib/static/stats.min-f33a6e08a8864d76.js.map +0 -1
  434. package/lib/stats-helper-9c26a9c0.nomodule.js.map +0 -1
  435. package/lib/stats-helper-bccf87d4.js +0 -2
  436. package/lib/stats-helper-bccf87d4.js.map +0 -1
  437. package/lib/tools-core-15d100e4.nomodule.js +0 -2
  438. package/lib/tools-core-15d100e4.nomodule.js.map +0 -1
  439. package/lib/tools-core-d85bfa17.js.map +0 -1
  440. /package/lib/definitions/{common-core/__tests__/dynamic-quality-setting-loader.d.ts → test-helpers/unit/global-setup.d.ts} +0 -0
  441. /package/lib/definitions/{common-core/__tests__/environment-loader.d.ts → test-helpers/unit/modules-setup.d.ts} +0 -0
  442. /package/lib/static/{Tween-5ebfb82307807fdc.js → Tween-d57ee5d181fce582.js} +0 -0
@@ -1,2297 +0,0 @@
1
- /**
2
- * @author fernandojsg / http://fernandojsg.com
3
- * @author Don McCurdy / https://www.donmccurdy.com
4
- * @author Takahiro / https://github.com/takahirox
5
- */
6
-
7
- //------------------------------------------------------------------------------
8
- // Constants
9
- //------------------------------------------------------------------------------
10
- var WEBGL_CONSTANTS = {
11
- POINTS: 0x0000,
12
- LINES: 0x0001,
13
- LINE_LOOP: 0x0002,
14
- LINE_STRIP: 0x0003,
15
- TRIANGLES: 0x0004,
16
- TRIANGLE_STRIP: 0x0005,
17
- TRIANGLE_FAN: 0x0006,
18
-
19
- UNSIGNED_BYTE: 0x1401,
20
- UNSIGNED_SHORT: 0x1403,
21
- FLOAT: 0x1406,
22
- UNSIGNED_INT: 0x1405,
23
- ARRAY_BUFFER: 0x8892,
24
- ELEMENT_ARRAY_BUFFER: 0x8893,
25
-
26
- NEAREST: 0x2600,
27
- LINEAR: 0x2601,
28
- NEAREST_MIPMAP_NEAREST: 0x2700,
29
- LINEAR_MIPMAP_NEAREST: 0x2701,
30
- NEAREST_MIPMAP_LINEAR: 0x2702,
31
- LINEAR_MIPMAP_LINEAR: 0x2703,
32
-
33
- CLAMP_TO_EDGE: 33071,
34
- MIRRORED_REPEAT: 33648,
35
- REPEAT: 10497
36
- };
37
-
38
- var THREE_TO_WEBGL = {};
39
-
40
- THREE_TO_WEBGL[ THREE.NearestFilter ] = WEBGL_CONSTANTS.NEAREST;
41
- THREE_TO_WEBGL[ THREE.NearestMipmapNearestFilter ] = WEBGL_CONSTANTS.NEAREST_MIPMAP_NEAREST;
42
- THREE_TO_WEBGL[ THREE.NearestMipmapLinearFilter ] = WEBGL_CONSTANTS.NEAREST_MIPMAP_LINEAR;
43
- THREE_TO_WEBGL[ THREE.LinearFilter ] = WEBGL_CONSTANTS.LINEAR;
44
- THREE_TO_WEBGL[ THREE.LinearMipmapNearestFilter ] = WEBGL_CONSTANTS.LINEAR_MIPMAP_NEAREST;
45
- THREE_TO_WEBGL[ THREE.LinearMipmapLinearFilter ] = WEBGL_CONSTANTS.LINEAR_MIPMAP_LINEAR;
46
-
47
- THREE_TO_WEBGL[ THREE.ClampToEdgeWrapping ] = WEBGL_CONSTANTS.CLAMP_TO_EDGE;
48
- THREE_TO_WEBGL[ THREE.RepeatWrapping ] = WEBGL_CONSTANTS.REPEAT;
49
- THREE_TO_WEBGL[ THREE.MirroredRepeatWrapping ] = WEBGL_CONSTANTS.MIRRORED_REPEAT;
50
-
51
- var PATH_PROPERTIES = {
52
- scale: 'scale',
53
- position: 'translation',
54
- quaternion: 'rotation',
55
- morphTargetInfluences: 'weights'
56
- };
57
-
58
- //------------------------------------------------------------------------------
59
- // GLTF Exporter
60
- //------------------------------------------------------------------------------
61
- THREE.GLTFExporter = function () {};
62
-
63
- THREE.GLTFExporter.prototype = {
64
-
65
- constructor: THREE.GLTFExporter,
66
-
67
- /**
68
- * Parse scenes and generate GLTF output
69
- * @param {THREE.Scene or [THREE.Scenes]} input THREE.Scene or Array of THREE.Scenes
70
- * @param {Function} onDone Callback on completed
71
- * @param {Object} options options
72
- */
73
- parse: function ( input, onDone, options ) {
74
-
75
- var DEFAULT_OPTIONS = {
76
- binary: false,
77
- trs: false,
78
- onlyVisible: true,
79
- truncateDrawRange: true,
80
- embedImages: true,
81
- maxTextureSize: Infinity,
82
- animations: [],
83
- forceIndices: false,
84
- forcePowerOfTwoTextures: false,
85
- includeCustomExtensions: false
86
- };
87
-
88
- options = Object.assign( {}, DEFAULT_OPTIONS, options );
89
-
90
- if ( options.animations.length > 0 ) {
91
-
92
- // Only TRS properties, and not matrices, may be targeted by animation.
93
- options.trs = true;
94
-
95
- }
96
-
97
- var outputJSON = {
98
-
99
- asset: {
100
-
101
- version: "2.0",
102
- generator: "THREE.GLTFExporter"
103
-
104
- }
105
-
106
- };
107
-
108
- var byteOffset = 0;
109
- var buffers = [];
110
- var pending = [];
111
- var nodeMap = new Map();
112
- var skins = [];
113
- var extensionsUsed = {};
114
- var cachedData = {
115
-
116
- meshes: new Map(),
117
- attributes: new Map(),
118
- attributesNormalized: new Map(),
119
- materials: new Map(),
120
- textures: new Map(),
121
- images: new Map()
122
-
123
- };
124
-
125
- var cachedCanvas;
126
-
127
- var uids = new Map();
128
- var uid = 0;
129
-
130
- /**
131
- * Assign and return a temporal unique id for an object
132
- * especially which doesn't have .uuid
133
- * @param {Object} object
134
- * @return {Integer}
135
- */
136
- function getUID( object ) {
137
-
138
- if ( ! uids.has( object ) ) uids.set( object, uid ++ );
139
-
140
- return uids.get( object );
141
-
142
- }
143
-
144
- /**
145
- * Compare two arrays
146
- * @param {Array} array1 Array 1 to compare
147
- * @param {Array} array2 Array 2 to compare
148
- * @return {Boolean} Returns true if both arrays are equal
149
- */
150
- function equalArray( array1, array2 ) {
151
-
152
- return ( array1.length === array2.length ) && array1.every( function ( element, index ) {
153
-
154
- return element === array2[ index ];
155
-
156
- } );
157
-
158
- }
159
-
160
- /**
161
- * Converts a string to an ArrayBuffer.
162
- * @param {string} text
163
- * @return {ArrayBuffer}
164
- */
165
- function stringToArrayBuffer( text ) {
166
-
167
- if ( window.TextEncoder !== undefined ) {
168
-
169
- return new TextEncoder().encode( text ).buffer;
170
-
171
- }
172
-
173
- var array = new Uint8Array( new ArrayBuffer( text.length ) );
174
-
175
- for ( var i = 0, il = text.length; i < il; i ++ ) {
176
-
177
- var value = text.charCodeAt( i );
178
-
179
- // Replacing multi-byte character with space(0x20).
180
- array[ i ] = value > 0xFF ? 0x20 : value;
181
-
182
- }
183
-
184
- return array.buffer;
185
-
186
- }
187
-
188
- /**
189
- * Get the min and max vectors from the given attribute
190
- * @param {THREE.BufferAttribute} attribute Attribute to find the min/max in range from start to start + count
191
- * @param {Integer} start
192
- * @param {Integer} count
193
- * @return {Object} Object containing the `min` and `max` values (As an array of attribute.itemSize components)
194
- */
195
- function getMinMax( attribute, start, count ) {
196
-
197
- var output = {
198
-
199
- min: new Array( attribute.itemSize ).fill( Number.POSITIVE_INFINITY ),
200
- max: new Array( attribute.itemSize ).fill( Number.NEGATIVE_INFINITY )
201
-
202
- };
203
-
204
- for ( var i = start; i < start + count; i ++ ) {
205
-
206
- for ( var a = 0; a < attribute.itemSize; a ++ ) {
207
-
208
- var value = attribute.array[ i * attribute.itemSize + a ];
209
- output.min[ a ] = Math.min( output.min[ a ], value );
210
- output.max[ a ] = Math.max( output.max[ a ], value );
211
-
212
- }
213
-
214
- }
215
-
216
- return output;
217
-
218
- }
219
-
220
- /**
221
- * Checks if image size is POT.
222
- *
223
- * @param {Image} image The image to be checked.
224
- * @returns {Boolean} Returns true if image size is POT.
225
- *
226
- */
227
- function isPowerOfTwo( image ) {
228
-
229
- return THREE.MathUtils.isPowerOfTwo( image.width ) && THREE.MathUtils.isPowerOfTwo( image.height );
230
-
231
- }
232
-
233
- /**
234
- * Checks if normal attribute values are normalized.
235
- *
236
- * @param {THREE.BufferAttribute} normal
237
- * @returns {Boolean}
238
- *
239
- */
240
- function isNormalizedNormalAttribute( normal ) {
241
-
242
- if ( cachedData.attributesNormalized.has( normal ) ) {
243
-
244
- return false;
245
-
246
- }
247
-
248
- var v = new THREE.Vector3();
249
-
250
- for ( var i = 0, il = normal.count; i < il; i ++ ) {
251
-
252
- // 0.0005 is from glTF-validator
253
- if ( Math.abs( v.fromArray( normal.array, i * 3 ).length() - 1.0 ) > 0.0005 ) return false;
254
-
255
- }
256
-
257
- return true;
258
-
259
- }
260
-
261
- /**
262
- * Creates normalized normal buffer attribute.
263
- *
264
- * @param {THREE.BufferAttribute} normal
265
- * @returns {THREE.BufferAttribute}
266
- *
267
- */
268
- function createNormalizedNormalAttribute( normal ) {
269
-
270
- if ( cachedData.attributesNormalized.has( normal ) ) {
271
-
272
- return cachedData.attributesNormalized.get( normal );
273
-
274
- }
275
-
276
- var attribute = normal.clone();
277
-
278
- var v = new THREE.Vector3();
279
-
280
- for ( var i = 0, il = attribute.count; i < il; i ++ ) {
281
-
282
- v.fromArray( attribute.array, i * 3 );
283
-
284
- if ( v.x === 0 && v.y === 0 && v.z === 0 ) {
285
-
286
- // if values can't be normalized set (1, 0, 0)
287
- v.setX( 1.0 );
288
-
289
- } else {
290
-
291
- v.normalize();
292
-
293
- }
294
-
295
- v.toArray( attribute.array, i * 3 );
296
-
297
- }
298
-
299
- cachedData.attributesNormalized.set( normal, attribute );
300
-
301
- return attribute;
302
-
303
- }
304
-
305
- /**
306
- * Get the required size + padding for a buffer, rounded to the next 4-byte boundary.
307
- * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment
308
- *
309
- * @param {Integer} bufferSize The size the original buffer.
310
- * @returns {Integer} new buffer size with required padding.
311
- *
312
- */
313
- function getPaddedBufferSize( bufferSize ) {
314
-
315
- return Math.ceil( bufferSize / 4 ) * 4;
316
-
317
- }
318
-
319
- /**
320
- * Returns a buffer aligned to 4-byte boundary.
321
- *
322
- * @param {ArrayBuffer} arrayBuffer Buffer to pad
323
- * @param {Integer} paddingByte (Optional)
324
- * @returns {ArrayBuffer} The same buffer if it's already aligned to 4-byte boundary or a new buffer
325
- */
326
- function getPaddedArrayBuffer( arrayBuffer, paddingByte ) {
327
-
328
- paddingByte = paddingByte || 0;
329
-
330
- var paddedLength = getPaddedBufferSize( arrayBuffer.byteLength );
331
-
332
- if ( paddedLength !== arrayBuffer.byteLength ) {
333
-
334
- var array = new Uint8Array( paddedLength );
335
- array.set( new Uint8Array( arrayBuffer ) );
336
-
337
- if ( paddingByte !== 0 ) {
338
-
339
- for ( var i = arrayBuffer.byteLength; i < paddedLength; i ++ ) {
340
-
341
- array[ i ] = paddingByte;
342
-
343
- }
344
-
345
- }
346
-
347
- return array.buffer;
348
-
349
- }
350
-
351
- return arrayBuffer;
352
-
353
- }
354
-
355
- /**
356
- * Serializes a userData.
357
- *
358
- * @param {THREE.Object3D|THREE.Material} object
359
- * @param {Object} gltfProperty
360
- */
361
- function serializeUserData( object, gltfProperty ) {
362
-
363
- if ( Object.keys( object.userData ).length === 0 ) {
364
-
365
- return;
366
-
367
- }
368
-
369
- try {
370
-
371
- var json = JSON.parse( JSON.stringify( object.userData ) );
372
-
373
- if ( options.includeCustomExtensions && json.gltfExtensions ) {
374
-
375
- if ( gltfProperty.extensions === undefined ) {
376
-
377
- gltfProperty.extensions = {};
378
-
379
- }
380
-
381
- for ( var extensionName in json.gltfExtensions ) {
382
-
383
- gltfProperty.extensions[ extensionName ] = json.gltfExtensions[ extensionName ];
384
- extensionsUsed[ extensionName ] = true;
385
-
386
- }
387
-
388
- delete json.gltfExtensions;
389
-
390
- }
391
-
392
- if ( Object.keys( json ).length > 0 ) {
393
-
394
- gltfProperty.extras = json;
395
-
396
- }
397
-
398
- } catch ( error ) {
399
-
400
- console.warn( 'THREE.GLTFExporter: userData of \'' + object.name + '\' ' +
401
- 'won\'t be serialized because of JSON.stringify error - ' + error.message );
402
-
403
- }
404
-
405
- }
406
-
407
- /**
408
- * Applies a texture transform, if present, to the map definition. Requires
409
- * the KHR_texture_transform extension.
410
- */
411
- function applyTextureTransform( mapDef, texture ) {
412
-
413
- var didTransform = false;
414
- var transformDef = {};
415
-
416
- if ( texture.offset.x !== 0 || texture.offset.y !== 0 ) {
417
-
418
- transformDef.offset = texture.offset.toArray();
419
- didTransform = true;
420
-
421
- }
422
-
423
- if ( texture.rotation !== 0 ) {
424
-
425
- transformDef.rotation = texture.rotation;
426
- didTransform = true;
427
-
428
- }
429
-
430
- if ( texture.repeat.x !== 1 || texture.repeat.y !== 1 ) {
431
-
432
- transformDef.scale = texture.repeat.toArray();
433
- didTransform = true;
434
-
435
- }
436
-
437
- if ( didTransform ) {
438
-
439
- mapDef.extensions = mapDef.extensions || {};
440
- mapDef.extensions[ 'KHR_texture_transform' ] = transformDef;
441
- extensionsUsed[ 'KHR_texture_transform' ] = true;
442
-
443
- }
444
-
445
- }
446
-
447
- /**
448
- * Process a buffer to append to the default one.
449
- * @param {ArrayBuffer} buffer
450
- * @return {Integer}
451
- */
452
- function processBuffer( buffer ) {
453
-
454
- if ( ! outputJSON.buffers ) {
455
-
456
- outputJSON.buffers = [ { byteLength: 0 } ];
457
-
458
- }
459
-
460
- // All buffers are merged before export.
461
- buffers.push( buffer );
462
-
463
- return 0;
464
-
465
- }
466
-
467
- /**
468
- * Process and generate a BufferView
469
- * @param {THREE.BufferAttribute} attribute
470
- * @param {number} componentType
471
- * @param {number} start
472
- * @param {number} count
473
- * @param {number} target (Optional) Target usage of the BufferView
474
- * @return {Object}
475
- */
476
- function processBufferView( attribute, componentType, start, count, target ) {
477
-
478
- if ( ! outputJSON.bufferViews ) {
479
-
480
- outputJSON.bufferViews = [];
481
-
482
- }
483
-
484
- // Create a new dataview and dump the attribute's array into it
485
-
486
- var componentSize;
487
-
488
- if ( componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE ) {
489
-
490
- componentSize = 1;
491
-
492
- } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT ) {
493
-
494
- componentSize = 2;
495
-
496
- } else {
497
-
498
- componentSize = 4;
499
-
500
- }
501
-
502
- var byteLength = getPaddedBufferSize( count * attribute.itemSize * componentSize );
503
- var dataView = new DataView( new ArrayBuffer( byteLength ) );
504
- var offset = 0;
505
-
506
- for ( var i = start; i < start + count; i ++ ) {
507
-
508
- for ( var a = 0; a < attribute.itemSize; a ++ ) {
509
-
510
- // @TODO Fails on InterleavedBufferAttribute, and could probably be
511
- // optimized for normal BufferAttribute.
512
- var value = attribute.array[ i * attribute.itemSize + a ];
513
-
514
- if ( componentType === WEBGL_CONSTANTS.FLOAT ) {
515
-
516
- dataView.setFloat32( offset, value, true );
517
-
518
- } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_INT ) {
519
-
520
- dataView.setUint32( offset, value, true );
521
-
522
- } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_SHORT ) {
523
-
524
- dataView.setUint16( offset, value, true );
525
-
526
- } else if ( componentType === WEBGL_CONSTANTS.UNSIGNED_BYTE ) {
527
-
528
- dataView.setUint8( offset, value );
529
-
530
- }
531
-
532
- offset += componentSize;
533
-
534
- }
535
-
536
- }
537
-
538
- var gltfBufferView = {
539
-
540
- buffer: processBuffer( dataView.buffer ),
541
- byteOffset: byteOffset,
542
- byteLength: byteLength
543
-
544
- };
545
-
546
- if ( target !== undefined ) gltfBufferView.target = target;
547
-
548
- if ( target === WEBGL_CONSTANTS.ARRAY_BUFFER ) {
549
-
550
- // Only define byteStride for vertex attributes.
551
- gltfBufferView.byteStride = attribute.itemSize * componentSize;
552
-
553
- }
554
-
555
- byteOffset += byteLength;
556
-
557
- outputJSON.bufferViews.push( gltfBufferView );
558
-
559
- // @TODO Merge bufferViews where possible.
560
- var output = {
561
-
562
- id: outputJSON.bufferViews.length - 1,
563
- byteLength: 0
564
-
565
- };
566
-
567
- return output;
568
-
569
- }
570
-
571
- /**
572
- * Process and generate a BufferView from an image Blob.
573
- * @param {Blob} blob
574
- * @return {Promise<Integer>}
575
- */
576
- function processBufferViewImage( blob ) {
577
-
578
- if ( ! outputJSON.bufferViews ) {
579
-
580
- outputJSON.bufferViews = [];
581
-
582
- }
583
-
584
- return new Promise( function ( resolve ) {
585
-
586
- var reader = new window.FileReader();
587
- reader.readAsArrayBuffer( blob );
588
- reader.onloadend = function () {
589
-
590
- var buffer = getPaddedArrayBuffer( reader.result );
591
-
592
- var bufferView = {
593
- buffer: processBuffer( buffer ),
594
- byteOffset: byteOffset,
595
- byteLength: buffer.byteLength
596
- };
597
-
598
- byteOffset += buffer.byteLength;
599
-
600
- outputJSON.bufferViews.push( bufferView );
601
-
602
- resolve( outputJSON.bufferViews.length - 1 );
603
-
604
- };
605
-
606
- } );
607
-
608
- }
609
-
610
- /**
611
- * Process attribute to generate an accessor
612
- * @param {THREE.BufferAttribute} attribute Attribute to process
613
- * @param {THREE.BufferGeometry} geometry (Optional) Geometry used for truncated draw range
614
- * @param {Integer} start (Optional)
615
- * @param {Integer} count (Optional)
616
- * @return {Integer} Index of the processed accessor on the "accessors" array
617
- */
618
- function processAccessor( attribute, geometry, start, count ) {
619
-
620
- var types = {
621
-
622
- 1: 'SCALAR',
623
- 2: 'VEC2',
624
- 3: 'VEC3',
625
- 4: 'VEC4',
626
- 16: 'MAT4'
627
-
628
- };
629
-
630
- var componentType;
631
-
632
- // Detect the component type of the attribute array (float, uint or ushort)
633
- if ( attribute.array.constructor === Float32Array ) {
634
-
635
- componentType = WEBGL_CONSTANTS.FLOAT;
636
-
637
- } else if ( attribute.array.constructor === Uint32Array ) {
638
-
639
- componentType = WEBGL_CONSTANTS.UNSIGNED_INT;
640
-
641
- } else if ( attribute.array.constructor === Uint16Array ) {
642
-
643
- componentType = WEBGL_CONSTANTS.UNSIGNED_SHORT;
644
-
645
- } else if ( attribute.array.constructor === Uint8Array ) {
646
-
647
- componentType = WEBGL_CONSTANTS.UNSIGNED_BYTE;
648
-
649
- } else {
650
-
651
- throw new Error( 'THREE.GLTFExporter: Unsupported bufferAttribute component type.' );
652
-
653
- }
654
-
655
- if ( start === undefined ) start = 0;
656
- if ( count === undefined ) count = attribute.count;
657
-
658
- // @TODO Indexed buffer geometry with drawRange not supported yet
659
- if ( options.truncateDrawRange && geometry !== undefined && geometry.index === null ) {
660
-
661
- var end = start + count;
662
- var end2 = geometry.drawRange.count === Infinity
663
- ? attribute.count
664
- : geometry.drawRange.start + geometry.drawRange.count;
665
-
666
- start = Math.max( start, geometry.drawRange.start );
667
- count = Math.min( end, end2 ) - start;
668
-
669
- if ( count < 0 ) count = 0;
670
-
671
- }
672
-
673
- // Skip creating an accessor if the attribute doesn't have data to export
674
- if ( count === 0 ) {
675
-
676
- return null;
677
-
678
- }
679
-
680
- var minMax = getMinMax( attribute, start, count );
681
-
682
- var bufferViewTarget;
683
-
684
- // If geometry isn't provided, don't infer the target usage of the bufferView. For
685
- // animation samplers, target must not be set.
686
- if ( geometry !== undefined ) {
687
-
688
- bufferViewTarget = attribute === geometry.index ? WEBGL_CONSTANTS.ELEMENT_ARRAY_BUFFER : WEBGL_CONSTANTS.ARRAY_BUFFER;
689
-
690
- }
691
-
692
- var bufferView = processBufferView( attribute, componentType, start, count, bufferViewTarget );
693
-
694
- var gltfAccessor = {
695
-
696
- bufferView: bufferView.id,
697
- byteOffset: bufferView.byteOffset,
698
- componentType: componentType,
699
- count: count,
700
- max: minMax.max,
701
- min: minMax.min,
702
- type: types[ attribute.itemSize ]
703
-
704
- };
705
-
706
- if ( ! outputJSON.accessors ) {
707
-
708
- outputJSON.accessors = [];
709
-
710
- }
711
-
712
- outputJSON.accessors.push( gltfAccessor );
713
-
714
- return outputJSON.accessors.length - 1;
715
-
716
- }
717
-
718
- /**
719
- * Process image
720
- * @param {Image} image to process
721
- * @param {Integer} format of the image (e.g. THREE.RGBFormat, THREE.RGBAFormat etc)
722
- * @param {Boolean} flipY before writing out the image
723
- * @return {Integer} Index of the processed texture in the "images" array
724
- */
725
- function processImage( image, format, flipY ) {
726
-
727
- if ( ! cachedData.images.has( image ) ) {
728
-
729
- cachedData.images.set( image, {} );
730
-
731
- }
732
-
733
- var cachedImages = cachedData.images.get( image );
734
- var mimeType = format === THREE.RGBAFormat ? 'image/png' : 'image/jpeg';
735
- var key = mimeType + ":flipY/" + flipY.toString();
736
-
737
- if ( cachedImages[ key ] !== undefined ) {
738
-
739
- return cachedImages[ key ];
740
-
741
- }
742
-
743
- if ( ! outputJSON.images ) {
744
-
745
- outputJSON.images = [];
746
-
747
- }
748
-
749
- var gltfImage = { mimeType: mimeType };
750
-
751
- if ( options.embedImages ) {
752
-
753
- var canvas = cachedCanvas = cachedCanvas || document.createElement( 'canvas' );
754
-
755
- canvas.width = Math.min( image.width, options.maxTextureSize );
756
- canvas.height = Math.min( image.height, options.maxTextureSize );
757
-
758
- if ( options.forcePowerOfTwoTextures && ! isPowerOfTwo( canvas ) ) {
759
-
760
- console.warn( 'GLTFExporter: Resized non-power-of-two image.', image );
761
-
762
- canvas.width = THREE.MathUtils.floorPowerOfTwo( canvas.width );
763
- canvas.height = THREE.MathUtils.floorPowerOfTwo( canvas.height );
764
-
765
- }
766
-
767
- var ctx = canvas.getContext( '2d' );
768
-
769
- if ( flipY === true ) {
770
-
771
- ctx.translate( 0, canvas.height );
772
- ctx.scale( 1, - 1 );
773
-
774
- }
775
-
776
- ctx.drawImage( image, 0, 0, canvas.width, canvas.height );
777
-
778
- if ( options.binary === true ) {
779
-
780
- pending.push( new Promise( function ( resolve ) {
781
-
782
- canvas.toBlob( function ( blob ) {
783
-
784
- processBufferViewImage( blob ).then( function ( bufferViewIndex ) {
785
-
786
- gltfImage.bufferView = bufferViewIndex;
787
-
788
- resolve();
789
-
790
- } );
791
-
792
- }, mimeType );
793
-
794
- } ) );
795
-
796
- } else {
797
-
798
- gltfImage.uri = canvas.toDataURL( mimeType );
799
-
800
- }
801
-
802
- } else {
803
-
804
- gltfImage.uri = image.src;
805
-
806
- }
807
-
808
- outputJSON.images.push( gltfImage );
809
-
810
- var index = outputJSON.images.length - 1;
811
- cachedImages[ key ] = index;
812
-
813
- return index;
814
-
815
- }
816
-
817
- /**
818
- * Process sampler
819
- * @param {Texture} map Texture to process
820
- * @return {Integer} Index of the processed texture in the "samplers" array
821
- */
822
- function processSampler( map ) {
823
-
824
- if ( ! outputJSON.samplers ) {
825
-
826
- outputJSON.samplers = [];
827
-
828
- }
829
-
830
- var gltfSampler = {
831
-
832
- magFilter: THREE_TO_WEBGL[ map.magFilter ],
833
- minFilter: THREE_TO_WEBGL[ map.minFilter ],
834
- wrapS: THREE_TO_WEBGL[ map.wrapS ],
835
- wrapT: THREE_TO_WEBGL[ map.wrapT ]
836
-
837
- };
838
-
839
- outputJSON.samplers.push( gltfSampler );
840
-
841
- return outputJSON.samplers.length - 1;
842
-
843
- }
844
-
845
- /**
846
- * Process texture
847
- * @param {Texture} map Map to process
848
- * @return {Integer} Index of the processed texture in the "textures" array
849
- */
850
- function processTexture( map ) {
851
-
852
- if ( cachedData.textures.has( map ) ) {
853
-
854
- return cachedData.textures.get( map );
855
-
856
- }
857
-
858
- if ( ! outputJSON.textures ) {
859
-
860
- outputJSON.textures = [];
861
-
862
- }
863
-
864
- var gltfTexture = {
865
-
866
- sampler: processSampler( map ),
867
- source: processImage( map.image, map.format, map.flipY )
868
-
869
- };
870
-
871
- if ( map.name ) {
872
-
873
- gltfTexture.name = map.name;
874
-
875
- }
876
-
877
- outputJSON.textures.push( gltfTexture );
878
-
879
- var index = outputJSON.textures.length - 1;
880
- cachedData.textures.set( map, index );
881
-
882
- return index;
883
-
884
- }
885
-
886
- /**
887
- * Process material
888
- * @param {THREE.Material} material Material to process
889
- * @return {Integer} Index of the processed material in the "materials" array
890
- */
891
- function processMaterial( material ) {
892
-
893
- if ( cachedData.materials.has( material ) ) {
894
-
895
- return cachedData.materials.get( material );
896
-
897
- }
898
-
899
- if ( material.isShaderMaterial ) {
900
-
901
- console.warn( 'GLTFExporter: THREE.ShaderMaterial not supported.' );
902
- return null;
903
-
904
- }
905
-
906
- if ( ! outputJSON.materials ) {
907
-
908
- outputJSON.materials = [];
909
-
910
- }
911
-
912
- // @QUESTION Should we avoid including any attribute that has the default value?
913
- var gltfMaterial = {
914
-
915
- pbrMetallicRoughness: {}
916
-
917
- };
918
-
919
- if ( material.isMeshBasicMaterial ) {
920
-
921
- gltfMaterial.extensions = { KHR_materials_unlit: {} };
922
-
923
- extensionsUsed[ 'KHR_materials_unlit' ] = true;
924
-
925
- } else if ( material.isGLTFSpecularGlossinessMaterial ) {
926
-
927
- gltfMaterial.extensions = { KHR_materials_pbrSpecularGlossiness: {} };
928
-
929
- extensionsUsed[ 'KHR_materials_pbrSpecularGlossiness' ] = true;
930
-
931
- } else if ( ! material.isMeshStandardMaterial ) {
932
-
933
- console.warn( 'GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.' );
934
-
935
- }
936
-
937
- // pbrMetallicRoughness.baseColorFactor
938
- var color = material.color.toArray().concat( [ material.opacity ] );
939
-
940
- if ( ! equalArray( color, [ 1, 1, 1, 1 ] ) ) {
941
-
942
- gltfMaterial.pbrMetallicRoughness.baseColorFactor = color;
943
-
944
- }
945
-
946
- if ( material.isMeshStandardMaterial ) {
947
-
948
- gltfMaterial.pbrMetallicRoughness.metallicFactor = material.metalness;
949
- gltfMaterial.pbrMetallicRoughness.roughnessFactor = material.roughness;
950
-
951
- } else if ( material.isMeshBasicMaterial ) {
952
-
953
- gltfMaterial.pbrMetallicRoughness.metallicFactor = 0.0;
954
- gltfMaterial.pbrMetallicRoughness.roughnessFactor = 0.9;
955
-
956
- } else {
957
-
958
- gltfMaterial.pbrMetallicRoughness.metallicFactor = 0.5;
959
- gltfMaterial.pbrMetallicRoughness.roughnessFactor = 0.5;
960
-
961
- }
962
-
963
- // pbrSpecularGlossiness diffuse, specular and glossiness factor
964
- if ( material.isGLTFSpecularGlossinessMaterial ) {
965
-
966
- if ( gltfMaterial.pbrMetallicRoughness.baseColorFactor ) {
967
-
968
- gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.diffuseFactor = gltfMaterial.pbrMetallicRoughness.baseColorFactor;
969
-
970
- }
971
-
972
- var specularFactor = [ 1, 1, 1 ];
973
- material.specular.toArray( specularFactor, 0 );
974
- gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.specularFactor = specularFactor;
975
-
976
- gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.glossinessFactor = material.glossiness;
977
-
978
- }
979
-
980
- // pbrMetallicRoughness.metallicRoughnessTexture
981
- if ( material.metalnessMap || material.roughnessMap ) {
982
-
983
- if ( material.metalnessMap === material.roughnessMap ) {
984
-
985
- var metalRoughMapDef = { index: processTexture( material.metalnessMap ) };
986
- applyTextureTransform( metalRoughMapDef, material.metalnessMap );
987
- gltfMaterial.pbrMetallicRoughness.metallicRoughnessTexture = metalRoughMapDef;
988
-
989
- } else {
990
-
991
- console.warn( 'THREE.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.' );
992
-
993
- }
994
-
995
- }
996
-
997
- // pbrMetallicRoughness.baseColorTexture or pbrSpecularGlossiness diffuseTexture
998
- if ( material.map ) {
999
-
1000
- var baseColorMapDef = { index: processTexture( material.map ) };
1001
- applyTextureTransform( baseColorMapDef, material.map );
1002
-
1003
- if ( material.isGLTFSpecularGlossinessMaterial ) {
1004
-
1005
- gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.diffuseTexture = baseColorMapDef;
1006
-
1007
- }
1008
-
1009
- gltfMaterial.pbrMetallicRoughness.baseColorTexture = baseColorMapDef;
1010
-
1011
- }
1012
-
1013
- // pbrSpecularGlossiness specular map
1014
- if ( material.isGLTFSpecularGlossinessMaterial && material.specularMap ) {
1015
-
1016
- var specularMapDef = { index: processTexture( material.specularMap ) };
1017
- applyTextureTransform( specularMapDef, material.specularMap );
1018
- gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.specularGlossinessTexture = specularMapDef;
1019
-
1020
- }
1021
-
1022
- if ( material.emissive ) {
1023
-
1024
- // emissiveFactor
1025
- var emissive = material.emissive.clone().multiplyScalar( material.emissiveIntensity ).toArray();
1026
-
1027
- if ( ! equalArray( emissive, [ 0, 0, 0 ] ) ) {
1028
-
1029
- gltfMaterial.emissiveFactor = emissive;
1030
-
1031
- }
1032
-
1033
- // emissiveTexture
1034
- if ( material.emissiveMap ) {
1035
-
1036
- var emissiveMapDef = { index: processTexture( material.emissiveMap ) };
1037
- applyTextureTransform( emissiveMapDef, material.emissiveMap );
1038
- gltfMaterial.emissiveTexture = emissiveMapDef;
1039
-
1040
- }
1041
-
1042
- }
1043
-
1044
- // normalTexture
1045
- if ( material.normalMap ) {
1046
-
1047
- var normalMapDef = { index: processTexture( material.normalMap ) };
1048
-
1049
- if ( material.normalScale && material.normalScale.x !== - 1 ) {
1050
-
1051
- if ( material.normalScale.x !== material.normalScale.y ) {
1052
-
1053
- console.warn( 'THREE.GLTFExporter: Normal scale components are different, ignoring Y and exporting X.' );
1054
-
1055
- }
1056
-
1057
- normalMapDef.scale = material.normalScale.x;
1058
-
1059
- }
1060
-
1061
- applyTextureTransform( normalMapDef, material.normalMap );
1062
-
1063
- gltfMaterial.normalTexture = normalMapDef;
1064
-
1065
- }
1066
-
1067
- // occlusionTexture
1068
- if ( material.aoMap ) {
1069
-
1070
- var occlusionMapDef = {
1071
- index: processTexture( material.aoMap ),
1072
- texCoord: 1
1073
- };
1074
-
1075
- if ( material.aoMapIntensity !== 1.0 ) {
1076
-
1077
- occlusionMapDef.strength = material.aoMapIntensity;
1078
-
1079
- }
1080
-
1081
- applyTextureTransform( occlusionMapDef, material.aoMap );
1082
-
1083
- gltfMaterial.occlusionTexture = occlusionMapDef;
1084
-
1085
- }
1086
-
1087
- // alphaMode
1088
- if ( material.transparent ) {
1089
-
1090
- gltfMaterial.alphaMode = 'BLEND';
1091
-
1092
- } else {
1093
-
1094
- if ( material.alphaTest > 0.0 ) {
1095
-
1096
- gltfMaterial.alphaMode = 'MASK';
1097
- gltfMaterial.alphaCutoff = material.alphaTest;
1098
-
1099
- }
1100
-
1101
- }
1102
-
1103
- // doubleSided
1104
- if ( material.side === THREE.DoubleSide ) {
1105
-
1106
- gltfMaterial.doubleSided = true;
1107
-
1108
- }
1109
-
1110
- if ( material.name !== '' ) {
1111
-
1112
- gltfMaterial.name = material.name;
1113
-
1114
- }
1115
-
1116
- serializeUserData( material, gltfMaterial );
1117
-
1118
- outputJSON.materials.push( gltfMaterial );
1119
-
1120
- var index = outputJSON.materials.length - 1;
1121
- cachedData.materials.set( material, index );
1122
-
1123
- return index;
1124
-
1125
- }
1126
-
1127
- /**
1128
- * Process mesh
1129
- * @param {THREE.Mesh} mesh Mesh to process
1130
- * @return {Integer} Index of the processed mesh in the "meshes" array
1131
- */
1132
- function processMesh( mesh ) {
1133
-
1134
- var meshCacheKeyParts = [ mesh.geometry.uuid ];
1135
- if ( Array.isArray( mesh.material ) ) {
1136
-
1137
- for ( var i = 0, l = mesh.material.length; i < l; i ++ ) {
1138
-
1139
- meshCacheKeyParts.push( mesh.material[ i ].uuid );
1140
-
1141
- }
1142
-
1143
- } else {
1144
-
1145
- meshCacheKeyParts.push( mesh.material.uuid );
1146
-
1147
- }
1148
-
1149
- var meshCacheKey = meshCacheKeyParts.join( ':' );
1150
- if ( cachedData.meshes.has( meshCacheKey ) ) {
1151
-
1152
- return cachedData.meshes.get( meshCacheKey );
1153
-
1154
- }
1155
-
1156
- var geometry = mesh.geometry;
1157
-
1158
- var mode;
1159
-
1160
- // Use the correct mode
1161
- if ( mesh.isLineSegments ) {
1162
-
1163
- mode = WEBGL_CONSTANTS.LINES;
1164
-
1165
- } else if ( mesh.isLineLoop ) {
1166
-
1167
- mode = WEBGL_CONSTANTS.LINE_LOOP;
1168
-
1169
- } else if ( mesh.isLine ) {
1170
-
1171
- mode = WEBGL_CONSTANTS.LINE_STRIP;
1172
-
1173
- } else if ( mesh.isPoints ) {
1174
-
1175
- mode = WEBGL_CONSTANTS.POINTS;
1176
-
1177
- } else {
1178
-
1179
- mode = mesh.material.wireframe ? WEBGL_CONSTANTS.LINES : WEBGL_CONSTANTS.TRIANGLES;
1180
-
1181
- }
1182
-
1183
- if ( ! geometry.isBufferGeometry ) {
1184
-
1185
- console.warn( 'GLTFExporter: Exporting THREE.Geometry will increase file size. Use THREE.BufferGeometry instead.' );
1186
- geometry = new THREE.BufferGeometry().setFromObject( mesh );
1187
-
1188
- }
1189
-
1190
- var gltfMesh = {};
1191
-
1192
- var attributes = {};
1193
- var primitives = [];
1194
- var targets = [];
1195
-
1196
- // Conversion between attributes names in threejs and gltf spec
1197
- var nameConversion = {
1198
-
1199
- uv: 'TEXCOORD_0',
1200
- uv2: 'TEXCOORD_1',
1201
- color: 'COLOR_0',
1202
- skinWeight: 'WEIGHTS_0',
1203
- skinIndex: 'JOINTS_0'
1204
-
1205
- };
1206
-
1207
- var originalNormal = geometry.getAttribute( 'normal' );
1208
-
1209
- if ( originalNormal !== undefined && ! isNormalizedNormalAttribute( originalNormal ) ) {
1210
-
1211
- console.warn( 'THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.' );
1212
-
1213
- geometry.setAttribute( 'normal', createNormalizedNormalAttribute( originalNormal ) );
1214
-
1215
- }
1216
-
1217
- // @QUESTION Detect if .vertexColors = true?
1218
- // For every attribute create an accessor
1219
- var modifiedAttribute = null;
1220
- for ( var attributeName in geometry.attributes ) {
1221
-
1222
- // Ignore morph target attributes, which are exported later.
1223
- if ( attributeName.substr( 0, 5 ) === 'morph' ) continue;
1224
-
1225
- var attribute = geometry.attributes[ attributeName ];
1226
- attributeName = nameConversion[ attributeName ] || attributeName.toUpperCase();
1227
-
1228
- // Prefix all geometry attributes except the ones specifically
1229
- // listed in the spec; non-spec attributes are considered custom.
1230
- var validVertexAttributes =
1231
- /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/;
1232
- if ( ! validVertexAttributes.test( attributeName ) ) {
1233
-
1234
- attributeName = '_' + attributeName;
1235
-
1236
- }
1237
-
1238
- if ( cachedData.attributes.has( getUID( attribute ) ) ) {
1239
-
1240
- attributes[ attributeName ] = cachedData.attributes.get( getUID( attribute ) );
1241
- continue;
1242
-
1243
- }
1244
-
1245
- // JOINTS_0 must be UNSIGNED_BYTE or UNSIGNED_SHORT.
1246
- modifiedAttribute = null;
1247
- var array = attribute.array;
1248
- if ( attributeName === 'JOINTS_0' &&
1249
- ! ( array instanceof Uint16Array ) &&
1250
- ! ( array instanceof Uint8Array ) ) {
1251
-
1252
- console.warn( 'GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.' );
1253
- modifiedAttribute = new THREE.BufferAttribute( new Uint16Array( array ), attribute.itemSize, attribute.normalized );
1254
-
1255
- }
1256
-
1257
- var accessor = processAccessor( modifiedAttribute || attribute, geometry );
1258
- if ( accessor !== null ) {
1259
-
1260
- attributes[ attributeName ] = accessor;
1261
- cachedData.attributes.set( getUID( attribute ), accessor );
1262
-
1263
- }
1264
-
1265
- }
1266
-
1267
- if ( originalNormal !== undefined ) geometry.setAttribute( 'normal', originalNormal );
1268
-
1269
- // Skip if no exportable attributes found
1270
- if ( Object.keys( attributes ).length === 0 ) {
1271
-
1272
- return null;
1273
-
1274
- }
1275
-
1276
- // Morph targets
1277
- if ( mesh.morphTargetInfluences !== undefined && mesh.morphTargetInfluences.length > 0 ) {
1278
-
1279
- var weights = [];
1280
- var targetNames = [];
1281
- var reverseDictionary = {};
1282
-
1283
- if ( mesh.morphTargetDictionary !== undefined ) {
1284
-
1285
- for ( var key in mesh.morphTargetDictionary ) {
1286
-
1287
- reverseDictionary[ mesh.morphTargetDictionary[ key ] ] = key;
1288
-
1289
- }
1290
-
1291
- }
1292
-
1293
- for ( var i = 0; i < mesh.morphTargetInfluences.length; ++ i ) {
1294
-
1295
- var target = {};
1296
-
1297
- var warned = false;
1298
-
1299
- for ( var attributeName in geometry.morphAttributes ) {
1300
-
1301
- // glTF 2.0 morph supports only POSITION/NORMAL/TANGENT.
1302
- // Three.js doesn't support TANGENT yet.
1303
-
1304
- if ( attributeName !== 'position' && attributeName !== 'normal' ) {
1305
-
1306
- if ( ! warned ) {
1307
-
1308
- console.warn( 'GLTFExporter: Only POSITION and NORMAL morph are supported.' );
1309
- warned = true;
1310
-
1311
- }
1312
-
1313
- continue;
1314
-
1315
- }
1316
-
1317
- var attribute = geometry.morphAttributes[ attributeName ][ i ];
1318
- var gltfAttributeName = attributeName.toUpperCase();
1319
-
1320
- // Three.js morph attribute has absolute values while the one of glTF has relative values.
1321
- //
1322
- // glTF 2.0 Specification:
1323
- // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#morph-targets
1324
-
1325
- var baseAttribute = geometry.attributes[ attributeName ];
1326
-
1327
- if ( cachedData.attributes.has( getUID( attribute ) ) ) {
1328
-
1329
- target[ gltfAttributeName ] = cachedData.attributes.get( getUID( attribute ) );
1330
- continue;
1331
-
1332
- }
1333
-
1334
- // Clones attribute not to override
1335
- var relativeAttribute = attribute.clone();
1336
-
1337
- if ( ! geometry.morphTargetsRelative ) {
1338
-
1339
- for ( var j = 0, jl = attribute.count; j < jl; j ++ ) {
1340
-
1341
- relativeAttribute.setXYZ(
1342
- j,
1343
- attribute.getX( j ) - baseAttribute.getX( j ),
1344
- attribute.getY( j ) - baseAttribute.getY( j ),
1345
- attribute.getZ( j ) - baseAttribute.getZ( j )
1346
- );
1347
-
1348
- }
1349
-
1350
- }
1351
-
1352
- target[ gltfAttributeName ] = processAccessor( relativeAttribute, geometry );
1353
- cachedData.attributes.set( getUID( baseAttribute ), target[ gltfAttributeName ] );
1354
-
1355
- }
1356
-
1357
- targets.push( target );
1358
-
1359
- weights.push( mesh.morphTargetInfluences[ i ] );
1360
- if ( mesh.morphTargetDictionary !== undefined ) targetNames.push( reverseDictionary[ i ] );
1361
-
1362
- }
1363
-
1364
- gltfMesh.weights = weights;
1365
-
1366
- if ( targetNames.length > 0 ) {
1367
-
1368
- gltfMesh.extras = {};
1369
- gltfMesh.extras.targetNames = targetNames;
1370
-
1371
- }
1372
-
1373
- }
1374
-
1375
- var forceIndices = options.forceIndices;
1376
- var isMultiMaterial = Array.isArray( mesh.material );
1377
-
1378
- if ( isMultiMaterial && geometry.groups.length === 0 ) return null;
1379
-
1380
- if ( ! forceIndices && geometry.index === null && isMultiMaterial ) {
1381
-
1382
- // temporal workaround.
1383
- console.warn( 'THREE.GLTFExporter: Creating index for non-indexed multi-material mesh.' );
1384
- forceIndices = true;
1385
-
1386
- }
1387
-
1388
- var didForceIndices = false;
1389
-
1390
- if ( geometry.index === null && forceIndices ) {
1391
-
1392
- var indices = [];
1393
-
1394
- for ( var i = 0, il = geometry.attributes.position.count; i < il; i ++ ) {
1395
-
1396
- indices[ i ] = i;
1397
-
1398
- }
1399
-
1400
- geometry.setIndex( indices );
1401
-
1402
- didForceIndices = true;
1403
-
1404
- }
1405
-
1406
- var materials = isMultiMaterial ? mesh.material : [ mesh.material ];
1407
- var groups = isMultiMaterial ? geometry.groups : [ { materialIndex: 0, start: undefined, count: undefined } ];
1408
-
1409
- for ( var i = 0, il = groups.length; i < il; i ++ ) {
1410
-
1411
- var primitive = {
1412
- mode: mode,
1413
- attributes: attributes,
1414
- };
1415
-
1416
- serializeUserData( geometry, primitive );
1417
-
1418
- if ( targets.length > 0 ) primitive.targets = targets;
1419
-
1420
- if ( geometry.index !== null ) {
1421
-
1422
- var cacheKey = getUID( geometry.index );
1423
-
1424
- if ( groups[ i ].start !== undefined || groups[ i ].count !== undefined ) {
1425
-
1426
- cacheKey += ':' + groups[ i ].start + ':' + groups[ i ].count;
1427
-
1428
- }
1429
-
1430
- if ( cachedData.attributes.has( cacheKey ) ) {
1431
-
1432
- primitive.indices = cachedData.attributes.get( cacheKey );
1433
-
1434
- } else {
1435
-
1436
- primitive.indices = processAccessor( geometry.index, geometry, groups[ i ].start, groups[ i ].count );
1437
- cachedData.attributes.set( cacheKey, primitive.indices );
1438
-
1439
- }
1440
-
1441
- if ( primitive.indices === null ) delete primitive.indices;
1442
-
1443
- }
1444
-
1445
- var material = processMaterial( materials[ groups[ i ].materialIndex ] );
1446
-
1447
- if ( material !== null ) {
1448
-
1449
- primitive.material = material;
1450
-
1451
- }
1452
-
1453
- primitives.push( primitive );
1454
-
1455
- }
1456
-
1457
- if ( didForceIndices ) {
1458
-
1459
- geometry.setIndex( null );
1460
-
1461
- }
1462
-
1463
- gltfMesh.primitives = primitives;
1464
-
1465
- if ( ! outputJSON.meshes ) {
1466
-
1467
- outputJSON.meshes = [];
1468
-
1469
- }
1470
-
1471
- outputJSON.meshes.push( gltfMesh );
1472
-
1473
- var index = outputJSON.meshes.length - 1;
1474
- cachedData.meshes.set( meshCacheKey, index );
1475
-
1476
- return index;
1477
-
1478
- }
1479
-
1480
- /**
1481
- * Process camera
1482
- * @param {THREE.Camera} camera Camera to process
1483
- * @return {Integer} Index of the processed mesh in the "camera" array
1484
- */
1485
- function processCamera( camera ) {
1486
-
1487
- if ( ! outputJSON.cameras ) {
1488
-
1489
- outputJSON.cameras = [];
1490
-
1491
- }
1492
-
1493
- var isOrtho = camera.isOrthographicCamera;
1494
-
1495
- var gltfCamera = {
1496
-
1497
- type: isOrtho ? 'orthographic' : 'perspective'
1498
-
1499
- };
1500
-
1501
- if ( isOrtho ) {
1502
-
1503
- gltfCamera.orthographic = {
1504
-
1505
- xmag: camera.right * 2,
1506
- ymag: camera.top * 2,
1507
- zfar: camera.far <= 0 ? 0.001 : camera.far,
1508
- znear: camera.near < 0 ? 0 : camera.near
1509
-
1510
- };
1511
-
1512
- } else {
1513
-
1514
- gltfCamera.perspective = {
1515
-
1516
- aspectRatio: camera.aspect,
1517
- yfov: THREE.MathUtils.degToRad( camera.fov ),
1518
- zfar: camera.far <= 0 ? 0.001 : camera.far,
1519
- znear: camera.near < 0 ? 0 : camera.near
1520
-
1521
- };
1522
-
1523
- }
1524
-
1525
- if ( camera.name !== '' ) {
1526
-
1527
- gltfCamera.name = camera.type;
1528
-
1529
- }
1530
-
1531
- outputJSON.cameras.push( gltfCamera );
1532
-
1533
- return outputJSON.cameras.length - 1;
1534
-
1535
- }
1536
-
1537
- /**
1538
- * Creates glTF animation entry from AnimationClip object.
1539
- *
1540
- * Status:
1541
- * - Only properties listed in PATH_PROPERTIES may be animated.
1542
- *
1543
- * @param {THREE.AnimationClip} clip
1544
- * @param {THREE.Object3D} root
1545
- * @return {number}
1546
- */
1547
- function processAnimation( clip, root ) {
1548
-
1549
- if ( ! outputJSON.animations ) {
1550
-
1551
- outputJSON.animations = [];
1552
-
1553
- }
1554
-
1555
- clip = THREE.GLTFExporter.Utils.mergeMorphTargetTracks( clip.clone(), root );
1556
-
1557
- var tracks = clip.tracks;
1558
- var channels = [];
1559
- var samplers = [];
1560
-
1561
- for ( var i = 0; i < tracks.length; ++ i ) {
1562
-
1563
- var track = tracks[ i ];
1564
- var trackBinding = THREE.PropertyBinding.parseTrackName( track.name );
1565
- var trackNode = THREE.PropertyBinding.findNode( root, trackBinding.nodeName );
1566
- var trackProperty = PATH_PROPERTIES[ trackBinding.propertyName ];
1567
-
1568
- if ( trackBinding.objectName === 'bones' ) {
1569
-
1570
- if ( trackNode.isSkinnedMesh === true ) {
1571
-
1572
- trackNode = trackNode.skeleton.getBoneByName( trackBinding.objectIndex );
1573
-
1574
- } else {
1575
-
1576
- trackNode = undefined;
1577
-
1578
- }
1579
-
1580
- }
1581
-
1582
- if ( ! trackNode || ! trackProperty ) {
1583
-
1584
- console.warn( 'THREE.GLTFExporter: Could not export animation track "%s".', track.name );
1585
- return null;
1586
-
1587
- }
1588
-
1589
- var inputItemSize = 1;
1590
- var outputItemSize = track.values.length / track.times.length;
1591
-
1592
- if ( trackProperty === PATH_PROPERTIES.morphTargetInfluences ) {
1593
-
1594
- outputItemSize /= trackNode.morphTargetInfluences.length;
1595
-
1596
- }
1597
-
1598
- var interpolation;
1599
-
1600
- // @TODO export CubicInterpolant(InterpolateSmooth) as CUBICSPLINE
1601
-
1602
- // Detecting glTF cubic spline interpolant by checking factory method's special property
1603
- // GLTFCubicSplineInterpolant is a custom interpolant and track doesn't return
1604
- // valid value from .getInterpolation().
1605
- if ( track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline === true ) {
1606
-
1607
- interpolation = 'CUBICSPLINE';
1608
-
1609
- // itemSize of CUBICSPLINE keyframe is 9
1610
- // (VEC3 * 3: inTangent, splineVertex, and outTangent)
1611
- // but needs to be stored as VEC3 so dividing by 3 here.
1612
- outputItemSize /= 3;
1613
-
1614
- } else if ( track.getInterpolation() === THREE.InterpolateDiscrete ) {
1615
-
1616
- interpolation = 'STEP';
1617
-
1618
- } else {
1619
-
1620
- interpolation = 'LINEAR';
1621
-
1622
- }
1623
-
1624
- samplers.push( {
1625
-
1626
- input: processAccessor( new THREE.BufferAttribute( track.times, inputItemSize ) ),
1627
- output: processAccessor( new THREE.BufferAttribute( track.values, outputItemSize ) ),
1628
- interpolation: interpolation
1629
-
1630
- } );
1631
-
1632
- channels.push( {
1633
-
1634
- sampler: samplers.length - 1,
1635
- target: {
1636
- node: nodeMap.get( trackNode ),
1637
- path: trackProperty
1638
- }
1639
-
1640
- } );
1641
-
1642
- }
1643
-
1644
- outputJSON.animations.push( {
1645
-
1646
- name: clip.name || 'clip_' + outputJSON.animations.length,
1647
- samplers: samplers,
1648
- channels: channels
1649
-
1650
- } );
1651
-
1652
- return outputJSON.animations.length - 1;
1653
-
1654
- }
1655
-
1656
- function processSkin( object ) {
1657
-
1658
- var node = outputJSON.nodes[ nodeMap.get( object ) ];
1659
-
1660
- var skeleton = object.skeleton;
1661
-
1662
- if ( skeleton === undefined ) return null;
1663
-
1664
- var rootJoint = object.skeleton.bones[ 0 ];
1665
-
1666
- if ( rootJoint === undefined ) return null;
1667
-
1668
- var joints = [];
1669
- var inverseBindMatrices = new Float32Array( skeleton.bones.length * 16 );
1670
-
1671
- for ( var i = 0; i < skeleton.bones.length; ++ i ) {
1672
-
1673
- joints.push( nodeMap.get( skeleton.bones[ i ] ) );
1674
-
1675
- skeleton.boneInverses[ i ].toArray( inverseBindMatrices, i * 16 );
1676
-
1677
- }
1678
-
1679
- if ( outputJSON.skins === undefined ) {
1680
-
1681
- outputJSON.skins = [];
1682
-
1683
- }
1684
-
1685
- outputJSON.skins.push( {
1686
-
1687
- inverseBindMatrices: processAccessor( new THREE.BufferAttribute( inverseBindMatrices, 16 ) ),
1688
- joints: joints,
1689
- skeleton: nodeMap.get( rootJoint )
1690
-
1691
- } );
1692
-
1693
- var skinIndex = node.skin = outputJSON.skins.length - 1;
1694
-
1695
- return skinIndex;
1696
-
1697
- }
1698
-
1699
- function processLight( light ) {
1700
-
1701
- var lightDef = {};
1702
-
1703
- if ( light.name ) lightDef.name = light.name;
1704
-
1705
- lightDef.color = light.color.toArray();
1706
-
1707
- lightDef.intensity = light.intensity;
1708
-
1709
- if ( light.isDirectionalLight ) {
1710
-
1711
- lightDef.type = 'directional';
1712
-
1713
- } else if ( light.isPointLight ) {
1714
-
1715
- lightDef.type = 'point';
1716
- if ( light.distance > 0 ) lightDef.range = light.distance;
1717
-
1718
- } else if ( light.isSpotLight ) {
1719
-
1720
- lightDef.type = 'spot';
1721
- if ( light.distance > 0 ) lightDef.range = light.distance;
1722
- lightDef.spot = {};
1723
- lightDef.spot.innerConeAngle = ( light.penumbra - 1.0 ) * light.angle * - 1.0;
1724
- lightDef.spot.outerConeAngle = light.angle;
1725
-
1726
- }
1727
-
1728
- if ( light.decay !== undefined && light.decay !== 2 ) {
1729
-
1730
- console.warn( 'THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, '
1731
- + 'and expects light.decay=2.' );
1732
-
1733
- }
1734
-
1735
- if ( light.target
1736
- && ( light.target.parent !== light
1737
- || light.target.position.x !== 0
1738
- || light.target.position.y !== 0
1739
- || light.target.position.z !== - 1 ) ) {
1740
-
1741
- console.warn( 'THREE.GLTFExporter: Light direction may be lost. For best results, '
1742
- + 'make light.target a child of the light with position 0,0,-1.' );
1743
-
1744
- }
1745
-
1746
- var lights = outputJSON.extensions[ 'KHR_lights_punctual' ].lights;
1747
- lights.push( lightDef );
1748
- return lights.length - 1;
1749
-
1750
- }
1751
-
1752
- /**
1753
- * Process Object3D node
1754
- * @param {THREE.Object3D} node Object3D to processNode
1755
- * @return {Integer} Index of the node in the nodes list
1756
- */
1757
- function processNode( object ) {
1758
-
1759
- if ( ! outputJSON.nodes ) {
1760
-
1761
- outputJSON.nodes = [];
1762
-
1763
- }
1764
-
1765
- var gltfNode = {};
1766
-
1767
- if ( options.trs ) {
1768
-
1769
- var rotation = object.quaternion.toArray();
1770
- var position = object.position.toArray();
1771
- var scale = object.scale.toArray();
1772
-
1773
- if ( ! equalArray( rotation, [ 0, 0, 0, 1 ] ) ) {
1774
-
1775
- gltfNode.rotation = rotation;
1776
-
1777
- }
1778
-
1779
- if ( ! equalArray( position, [ 0, 0, 0 ] ) ) {
1780
-
1781
- gltfNode.translation = position;
1782
-
1783
- }
1784
-
1785
- if ( ! equalArray( scale, [ 1, 1, 1 ] ) ) {
1786
-
1787
- gltfNode.scale = scale;
1788
-
1789
- }
1790
-
1791
- } else {
1792
-
1793
- if ( object.matrixAutoUpdate ) {
1794
-
1795
- object.updateMatrix();
1796
-
1797
- }
1798
-
1799
- if ( ! equalArray( object.matrix.elements, [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ] ) ) {
1800
-
1801
- gltfNode.matrix = object.matrix.elements;
1802
-
1803
- }
1804
-
1805
- }
1806
-
1807
- // We don't export empty strings name because it represents no-name in Three.js.
1808
- if ( object.name !== '' ) {
1809
-
1810
- gltfNode.name = String( object.name );
1811
-
1812
- }
1813
-
1814
- serializeUserData( object, gltfNode );
1815
-
1816
- if ( object.isMesh || object.isLine || object.isPoints ) {
1817
-
1818
- var mesh = processMesh( object );
1819
-
1820
- if ( mesh !== null ) {
1821
-
1822
- gltfNode.mesh = mesh;
1823
-
1824
- }
1825
-
1826
- } else if ( object.isCamera ) {
1827
-
1828
- gltfNode.camera = processCamera( object );
1829
-
1830
- } else if ( object.isDirectionalLight || object.isPointLight || object.isSpotLight ) {
1831
-
1832
- if ( ! extensionsUsed[ 'KHR_lights_punctual' ] ) {
1833
-
1834
- outputJSON.extensions = outputJSON.extensions || {};
1835
- outputJSON.extensions[ 'KHR_lights_punctual' ] = { lights: [] };
1836
- extensionsUsed[ 'KHR_lights_punctual' ] = true;
1837
-
1838
- }
1839
-
1840
- gltfNode.extensions = gltfNode.extensions || {};
1841
- gltfNode.extensions[ 'KHR_lights_punctual' ] = { light: processLight( object ) };
1842
-
1843
- } else if ( object.isLight ) {
1844
-
1845
- console.warn( 'THREE.GLTFExporter: Only directional, point, and spot lights are supported.', object );
1846
- return null;
1847
-
1848
- }
1849
-
1850
- if ( object.isSkinnedMesh ) {
1851
-
1852
- skins.push( object );
1853
-
1854
- }
1855
-
1856
- if ( object.children.length > 0 ) {
1857
-
1858
- var children = [];
1859
-
1860
- for ( var i = 0, l = object.children.length; i < l; i ++ ) {
1861
-
1862
- var child = object.children[ i ];
1863
-
1864
- if ( child.visible || options.onlyVisible === false ) {
1865
-
1866
- var node = processNode( child );
1867
-
1868
- if ( node !== null ) {
1869
-
1870
- children.push( node );
1871
-
1872
- }
1873
-
1874
- }
1875
-
1876
- }
1877
-
1878
- if ( children.length > 0 ) {
1879
-
1880
- gltfNode.children = children;
1881
-
1882
- }
1883
-
1884
-
1885
- }
1886
-
1887
- outputJSON.nodes.push( gltfNode );
1888
-
1889
- var nodeIndex = outputJSON.nodes.length - 1;
1890
- nodeMap.set( object, nodeIndex );
1891
-
1892
- return nodeIndex;
1893
-
1894
- }
1895
-
1896
- /**
1897
- * Process Scene
1898
- * @param {THREE.Scene} node Scene to process
1899
- */
1900
- function processScene( scene ) {
1901
-
1902
- if ( ! outputJSON.scenes ) {
1903
-
1904
- outputJSON.scenes = [];
1905
- outputJSON.scene = 0;
1906
-
1907
- }
1908
-
1909
- var gltfScene = {};
1910
-
1911
- if ( scene.name !== '' ) {
1912
-
1913
- gltfScene.name = scene.name;
1914
-
1915
- }
1916
-
1917
- outputJSON.scenes.push( gltfScene );
1918
-
1919
- var nodes = [];
1920
-
1921
- for ( var i = 0, l = scene.children.length; i < l; i ++ ) {
1922
-
1923
- var child = scene.children[ i ];
1924
-
1925
- if ( child.visible || options.onlyVisible === false ) {
1926
-
1927
- var node = processNode( child );
1928
-
1929
- if ( node !== null ) {
1930
-
1931
- nodes.push( node );
1932
-
1933
- }
1934
-
1935
- }
1936
-
1937
- }
1938
-
1939
- if ( nodes.length > 0 ) {
1940
-
1941
- gltfScene.nodes = nodes;
1942
-
1943
- }
1944
-
1945
- serializeUserData( scene, gltfScene );
1946
-
1947
- }
1948
-
1949
- /**
1950
- * Creates a THREE.Scene to hold a list of objects and parse it
1951
- * @param {Array} objects List of objects to process
1952
- */
1953
- function processObjects( objects ) {
1954
-
1955
- var scene = new THREE.Scene();
1956
- scene.name = 'AuxScene';
1957
-
1958
- for ( var i = 0; i < objects.length; i ++ ) {
1959
-
1960
- // We push directly to children instead of calling `add` to prevent
1961
- // modify the .parent and break its original scene and hierarchy
1962
- scene.children.push( objects[ i ] );
1963
-
1964
- }
1965
-
1966
- processScene( scene );
1967
-
1968
- }
1969
-
1970
- function processInput( input ) {
1971
-
1972
- input = input instanceof Array ? input : [ input ];
1973
-
1974
- var objectsWithoutScene = [];
1975
-
1976
- for ( var i = 0; i < input.length; i ++ ) {
1977
-
1978
- if ( input[ i ] instanceof THREE.Scene ) {
1979
-
1980
- processScene( input[ i ] );
1981
-
1982
- } else {
1983
-
1984
- objectsWithoutScene.push( input[ i ] );
1985
-
1986
- }
1987
-
1988
- }
1989
-
1990
- if ( objectsWithoutScene.length > 0 ) {
1991
-
1992
- processObjects( objectsWithoutScene );
1993
-
1994
- }
1995
-
1996
- for ( var i = 0; i < skins.length; ++ i ) {
1997
-
1998
- processSkin( skins[ i ] );
1999
-
2000
- }
2001
-
2002
- for ( var i = 0; i < options.animations.length; ++ i ) {
2003
-
2004
- processAnimation( options.animations[ i ], input[ 0 ] );
2005
-
2006
- }
2007
-
2008
- }
2009
-
2010
- processInput( input );
2011
-
2012
- Promise.all( pending ).then( function () {
2013
-
2014
- // Merge buffers.
2015
- var blob = new Blob( buffers, { type: 'application/octet-stream' } );
2016
-
2017
- // Declare extensions.
2018
- var extensionsUsedList = Object.keys( extensionsUsed );
2019
- if ( extensionsUsedList.length > 0 ) outputJSON.extensionsUsed = extensionsUsedList;
2020
-
2021
- // Update bytelength of the single buffer.
2022
- if ( outputJSON.buffers && outputJSON.buffers.length > 0 ) outputJSON.buffers[ 0 ].byteLength = blob.size;
2023
-
2024
- if ( options.binary === true ) {
2025
-
2026
- // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
2027
-
2028
- var GLB_HEADER_BYTES = 12;
2029
- var GLB_HEADER_MAGIC = 0x46546C67;
2030
- var GLB_VERSION = 2;
2031
-
2032
- var GLB_CHUNK_PREFIX_BYTES = 8;
2033
- var GLB_CHUNK_TYPE_JSON = 0x4E4F534A;
2034
- var GLB_CHUNK_TYPE_BIN = 0x004E4942;
2035
-
2036
- var reader = new window.FileReader();
2037
- reader.readAsArrayBuffer( blob );
2038
- reader.onloadend = function () {
2039
-
2040
- // Binary chunk.
2041
- var binaryChunk = getPaddedArrayBuffer( reader.result );
2042
- var binaryChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) );
2043
- binaryChunkPrefix.setUint32( 0, binaryChunk.byteLength, true );
2044
- binaryChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_BIN, true );
2045
-
2046
- // JSON chunk.
2047
- var jsonChunk = getPaddedArrayBuffer( stringToArrayBuffer( JSON.stringify( outputJSON ) ), 0x20 );
2048
- var jsonChunkPrefix = new DataView( new ArrayBuffer( GLB_CHUNK_PREFIX_BYTES ) );
2049
- jsonChunkPrefix.setUint32( 0, jsonChunk.byteLength, true );
2050
- jsonChunkPrefix.setUint32( 4, GLB_CHUNK_TYPE_JSON, true );
2051
-
2052
- // GLB header.
2053
- var header = new ArrayBuffer( GLB_HEADER_BYTES );
2054
- var headerView = new DataView( header );
2055
- headerView.setUint32( 0, GLB_HEADER_MAGIC, true );
2056
- headerView.setUint32( 4, GLB_VERSION, true );
2057
- var totalByteLength = GLB_HEADER_BYTES
2058
- + jsonChunkPrefix.byteLength + jsonChunk.byteLength
2059
- + binaryChunkPrefix.byteLength + binaryChunk.byteLength;
2060
- headerView.setUint32( 8, totalByteLength, true );
2061
-
2062
- var glbBlob = new Blob( [
2063
- header,
2064
- jsonChunkPrefix,
2065
- jsonChunk,
2066
- binaryChunkPrefix,
2067
- binaryChunk
2068
- ], { type: 'application/octet-stream' } );
2069
-
2070
- var glbReader = new window.FileReader();
2071
- glbReader.readAsArrayBuffer( glbBlob );
2072
- glbReader.onloadend = function () {
2073
-
2074
- onDone( glbReader.result );
2075
-
2076
- };
2077
-
2078
- };
2079
-
2080
- } else {
2081
-
2082
- if ( outputJSON.buffers && outputJSON.buffers.length > 0 ) {
2083
-
2084
- var reader = new window.FileReader();
2085
- reader.readAsDataURL( blob );
2086
- reader.onloadend = function () {
2087
-
2088
- var base64data = reader.result;
2089
- outputJSON.buffers[ 0 ].uri = base64data;
2090
- onDone( outputJSON );
2091
-
2092
- };
2093
-
2094
- } else {
2095
-
2096
- onDone( outputJSON );
2097
-
2098
- }
2099
-
2100
- }
2101
-
2102
- } );
2103
-
2104
- }
2105
-
2106
- };
2107
-
2108
- THREE.GLTFExporter.Utils = {
2109
-
2110
- insertKeyframe: function ( track, time ) {
2111
-
2112
- var tolerance = 0.001; // 1ms
2113
- var valueSize = track.getValueSize();
2114
-
2115
- var times = new track.TimeBufferType( track.times.length + 1 );
2116
- var values = new track.ValueBufferType( track.values.length + valueSize );
2117
- var interpolant = track.createInterpolant( new track.ValueBufferType( valueSize ) );
2118
-
2119
- var index;
2120
-
2121
- if ( track.times.length === 0 ) {
2122
-
2123
- times[ 0 ] = time;
2124
-
2125
- for ( var i = 0; i < valueSize; i ++ ) {
2126
-
2127
- values[ i ] = 0;
2128
-
2129
- }
2130
-
2131
- index = 0;
2132
-
2133
- } else if ( time < track.times[ 0 ] ) {
2134
-
2135
- if ( Math.abs( track.times[ 0 ] - time ) < tolerance ) return 0;
2136
-
2137
- times[ 0 ] = time;
2138
- times.set( track.times, 1 );
2139
-
2140
- values.set( interpolant.evaluate( time ), 0 );
2141
- values.set( track.values, valueSize );
2142
-
2143
- index = 0;
2144
-
2145
- } else if ( time > track.times[ track.times.length - 1 ] ) {
2146
-
2147
- if ( Math.abs( track.times[ track.times.length - 1 ] - time ) < tolerance ) {
2148
-
2149
- return track.times.length - 1;
2150
-
2151
- }
2152
-
2153
- times[ times.length - 1 ] = time;
2154
- times.set( track.times, 0 );
2155
-
2156
- values.set( track.values, 0 );
2157
- values.set( interpolant.evaluate( time ), track.values.length );
2158
-
2159
- index = times.length - 1;
2160
-
2161
- } else {
2162
-
2163
- for ( var i = 0; i < track.times.length; i ++ ) {
2164
-
2165
- if ( Math.abs( track.times[ i ] - time ) < tolerance ) return i;
2166
-
2167
- if ( track.times[ i ] < time && track.times[ i + 1 ] > time ) {
2168
-
2169
- times.set( track.times.slice( 0, i + 1 ), 0 );
2170
- times[ i + 1 ] = time;
2171
- times.set( track.times.slice( i + 1 ), i + 2 );
2172
-
2173
- values.set( track.values.slice( 0, ( i + 1 ) * valueSize ), 0 );
2174
- values.set( interpolant.evaluate( time ), ( i + 1 ) * valueSize );
2175
- values.set( track.values.slice( ( i + 1 ) * valueSize ), ( i + 2 ) * valueSize );
2176
-
2177
- index = i + 1;
2178
-
2179
- break;
2180
-
2181
- }
2182
-
2183
- }
2184
-
2185
- }
2186
-
2187
- track.times = times;
2188
- track.values = values;
2189
-
2190
- return index;
2191
-
2192
- },
2193
-
2194
- mergeMorphTargetTracks: function ( clip, root ) {
2195
-
2196
- var tracks = [];
2197
- var mergedTracks = {};
2198
- var sourceTracks = clip.tracks;
2199
-
2200
- for ( var i = 0; i < sourceTracks.length; ++ i ) {
2201
-
2202
- var sourceTrack = sourceTracks[ i ];
2203
- var sourceTrackBinding = THREE.PropertyBinding.parseTrackName( sourceTrack.name );
2204
- var sourceTrackNode = THREE.PropertyBinding.findNode( root, sourceTrackBinding.nodeName );
2205
-
2206
- if ( sourceTrackBinding.propertyName !== 'morphTargetInfluences' || sourceTrackBinding.propertyIndex === undefined ) {
2207
-
2208
- // Tracks that don't affect morph targets, or that affect all morph targets together, can be left as-is.
2209
- tracks.push( sourceTrack );
2210
- continue;
2211
-
2212
- }
2213
-
2214
- if ( sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodDiscrete
2215
- && sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodLinear ) {
2216
-
2217
- if ( sourceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) {
2218
-
2219
- // This should never happen, because glTF morph target animations
2220
- // affect all targets already.
2221
- throw new Error( 'THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.' );
2222
-
2223
- }
2224
-
2225
- console.warn( 'THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.' );
2226
-
2227
- sourceTrack = sourceTrack.clone();
2228
- sourceTrack.setInterpolation( THREE.InterpolateLinear );
2229
-
2230
- }
2231
-
2232
- var targetCount = sourceTrackNode.morphTargetInfluences.length;
2233
- var targetIndex = sourceTrackNode.morphTargetDictionary[ sourceTrackBinding.propertyIndex ];
2234
-
2235
- if ( targetIndex === undefined ) {
2236
-
2237
- throw new Error( 'THREE.GLTFExporter: Morph target name not found: ' + sourceTrackBinding.propertyIndex );
2238
-
2239
- }
2240
-
2241
- var mergedTrack;
2242
-
2243
- // If this is the first time we've seen this object, create a new
2244
- // track to store merged keyframe data for each morph target.
2245
- if ( mergedTracks[ sourceTrackNode.uuid ] === undefined ) {
2246
-
2247
- mergedTrack = sourceTrack.clone();
2248
-
2249
- var values = new mergedTrack.ValueBufferType( targetCount * mergedTrack.times.length );
2250
-
2251
- for ( var j = 0; j < mergedTrack.times.length; j ++ ) {
2252
-
2253
- values[ j * targetCount + targetIndex ] = mergedTrack.values[ j ];
2254
-
2255
- }
2256
-
2257
- mergedTrack.name = '.morphTargetInfluences';
2258
- mergedTrack.values = values;
2259
-
2260
- mergedTracks[ sourceTrackNode.uuid ] = mergedTrack;
2261
- tracks.push( mergedTrack );
2262
-
2263
- continue;
2264
-
2265
- }
2266
-
2267
- var sourceInterpolant = sourceTrack.createInterpolant( new sourceTrack.ValueBufferType( 1 ) );
2268
-
2269
- mergedTrack = mergedTracks[ sourceTrackNode.uuid ];
2270
-
2271
- // For every existing keyframe of the merged track, write a (possibly
2272
- // interpolated) value from the source track.
2273
- for ( var j = 0; j < mergedTrack.times.length; j ++ ) {
2274
-
2275
- mergedTrack.values[ j * targetCount + targetIndex ] = sourceInterpolant.evaluate( mergedTrack.times[ j ] );
2276
-
2277
- }
2278
-
2279
- // For every existing keyframe of the source track, write a (possibly
2280
- // new) keyframe to the merged track. Values from the previous loop may
2281
- // be written again, but keyframes are de-duplicated.
2282
- for ( var j = 0; j < sourceTrack.times.length; j ++ ) {
2283
-
2284
- var keyframeIndex = this.insertKeyframe( mergedTrack, sourceTrack.times[ j ] );
2285
- mergedTrack.values[ keyframeIndex * targetCount + targetIndex ] = sourceTrack.values[ j ];
2286
-
2287
- }
2288
-
2289
- }
2290
-
2291
- clip.tracks = tracks;
2292
-
2293
- return clip;
2294
-
2295
- }
2296
-
2297
- };