@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,3279 +0,0 @@
1
- /**
2
- * @author Rich Tibbett / https://github.com/richtr
3
- * @author mrdoob / http://mrdoob.com/
4
- * @author Tony Parisi / http://www.tonyparisi.com/
5
- * @author Takahiro / https://github.com/takahirox
6
- * @author Don McCurdy / https://www.donmccurdy.com
7
- */
8
-
9
- THREE.GLTFLoader = ( function () {
10
-
11
- function GLTFLoader( manager ) {
12
-
13
- THREE.Loader.call( this, manager );
14
-
15
- this.dracoLoader = null;
16
- this.ddsLoader = null;
17
-
18
- }
19
-
20
- GLTFLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype ), {
21
-
22
- constructor: GLTFLoader,
23
-
24
- load: function ( url, onLoad, onProgress, onError ) {
25
-
26
- var scope = this;
27
-
28
- var resourcePath;
29
-
30
- if ( this.resourcePath !== '' ) {
31
-
32
- resourcePath = this.resourcePath;
33
-
34
- } else if ( this.path !== '' ) {
35
-
36
- resourcePath = this.path;
37
-
38
- } else {
39
-
40
- resourcePath = THREE.LoaderUtils.extractUrlBase( url );
41
-
42
- }
43
-
44
- // Tells the LoadingManager to track an extra item, which resolves after
45
- // the model is fully loaded. This means the count of items loaded will
46
- // be incorrect, but ensures manager.onLoad() does not fire early.
47
- scope.manager.itemStart( url );
48
-
49
- var _onError = function ( e ) {
50
-
51
- if ( onError ) {
52
-
53
- onError( e );
54
-
55
- } else {
56
-
57
- console.error( e );
58
-
59
- }
60
-
61
- scope.manager.itemError( url );
62
- scope.manager.itemEnd( url );
63
-
64
- };
65
-
66
- var loader = new THREE.FileLoader( scope.manager );
67
-
68
- loader.setPath( this.path );
69
- loader.setResponseType( 'arraybuffer' );
70
-
71
- if ( scope.crossOrigin === 'use-credentials' ) {
72
-
73
- loader.setWithCredentials( true );
74
-
75
- }
76
-
77
- loader.load( url, function ( data ) {
78
-
79
- try {
80
-
81
- scope.parse( data, resourcePath, function ( gltf ) {
82
-
83
- onLoad( gltf );
84
-
85
- scope.manager.itemEnd( url );
86
-
87
- }, _onError );
88
-
89
- } catch ( e ) {
90
-
91
- _onError( e );
92
-
93
- }
94
-
95
- }, onProgress, _onError );
96
-
97
- },
98
-
99
- setDRACOLoader: function ( dracoLoader ) {
100
-
101
- this.dracoLoader = dracoLoader;
102
- return this;
103
-
104
- },
105
-
106
- setDDSLoader: function ( ddsLoader ) {
107
-
108
- this.ddsLoader = ddsLoader;
109
- return this;
110
-
111
- },
112
-
113
- parse: function ( data, path, onLoad, onError ) {
114
-
115
- var content;
116
- var extensions = {};
117
-
118
- if ( typeof data === 'string' ) {
119
-
120
- content = data;
121
-
122
- } else {
123
-
124
- var magic = THREE.LoaderUtils.decodeText( new Uint8Array( data, 0, 4 ) );
125
-
126
- if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) {
127
-
128
- try {
129
-
130
- extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data );
131
-
132
- } catch ( error ) {
133
-
134
- if ( onError ) onError( error );
135
- return;
136
-
137
- }
138
-
139
- content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content;
140
-
141
- } else {
142
-
143
- content = THREE.LoaderUtils.decodeText( new Uint8Array( data ) );
144
-
145
- }
146
-
147
- }
148
-
149
- var json = JSON.parse( content );
150
-
151
- if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) {
152
-
153
- if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.' ) );
154
- return;
155
-
156
- }
157
-
158
- if ( json.extensionsUsed ) {
159
-
160
- for ( var i = 0; i < json.extensionsUsed.length; ++ i ) {
161
-
162
- var extensionName = json.extensionsUsed[ i ];
163
- var extensionsRequired = json.extensionsRequired || [];
164
-
165
- switch ( extensionName ) {
166
-
167
- case EXTENSIONS.KHR_LIGHTS_PUNCTUAL:
168
- extensions[ extensionName ] = new GLTFLightsExtension( json );
169
- break;
170
-
171
- case EXTENSIONS.KHR_MATERIALS_CLEARCOAT:
172
- extensions[ extensionName ] = new GLTFMaterialsClearcoatExtension();
173
- break;
174
-
175
- case EXTENSIONS.KHR_MATERIALS_UNLIT:
176
- extensions[ extensionName ] = new GLTFMaterialsUnlitExtension();
177
- break;
178
-
179
- case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:
180
- extensions[ extensionName ] = new GLTFMaterialsPbrSpecularGlossinessExtension();
181
- break;
182
-
183
- case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
184
- extensions[ extensionName ] = new GLTFDracoMeshCompressionExtension( json, this.dracoLoader );
185
- break;
186
-
187
- case EXTENSIONS.MSFT_TEXTURE_DDS:
188
- extensions[ extensionName ] = new GLTFTextureDDSExtension( this.ddsLoader );
189
- break;
190
-
191
- case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
192
- extensions[ extensionName ] = new GLTFTextureTransformExtension();
193
- break;
194
-
195
- case EXTENSIONS.KHR_MESH_QUANTIZATION:
196
- extensions[ extensionName ] = new GLTFMeshQuantizationExtension();
197
- break;
198
-
199
- default:
200
-
201
- if ( extensionsRequired.indexOf( extensionName ) >= 0 ) {
202
-
203
- console.warn( 'THREE.GLTFLoader: Unknown extension "' + extensionName + '".' );
204
-
205
- }
206
-
207
- }
208
-
209
- }
210
-
211
- }
212
-
213
- var parser = new GLTFParser( json, extensions, {
214
-
215
- path: path || this.resourcePath || '',
216
- crossOrigin: this.crossOrigin,
217
- manager: this.manager
218
-
219
- } );
220
-
221
- parser.parse( onLoad, onError );
222
-
223
- }
224
-
225
- } );
226
-
227
- /* GLTFREGISTRY */
228
-
229
- function GLTFRegistry() {
230
-
231
- var objects = {};
232
-
233
- return {
234
-
235
- get: function ( key ) {
236
-
237
- return objects[ key ];
238
-
239
- },
240
-
241
- add: function ( key, object ) {
242
-
243
- objects[ key ] = object;
244
-
245
- },
246
-
247
- remove: function ( key ) {
248
-
249
- delete objects[ key ];
250
-
251
- },
252
-
253
- removeAll: function () {
254
-
255
- objects = {};
256
-
257
- }
258
-
259
- };
260
-
261
- }
262
-
263
- /*********************************/
264
- /********** EXTENSIONS ***********/
265
- /*********************************/
266
-
267
- var EXTENSIONS = {
268
- KHR_BINARY_GLTF: 'KHR_binary_glTF',
269
- KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',
270
- KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual',
271
- KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
272
- KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',
273
- KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
274
- KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform',
275
- KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization',
276
- MSFT_TEXTURE_DDS: 'MSFT_texture_dds'
277
- };
278
-
279
- /**
280
- * DDS Texture Extension
281
- *
282
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_texture_dds
283
- *
284
- */
285
- function GLTFTextureDDSExtension( ddsLoader ) {
286
-
287
- if ( ! ddsLoader ) {
288
-
289
- throw new Error( 'THREE.GLTFLoader: Attempting to load .dds texture without importing THREE.DDSLoader' );
290
-
291
- }
292
-
293
- this.name = EXTENSIONS.MSFT_TEXTURE_DDS;
294
- this.ddsLoader = ddsLoader;
295
-
296
- }
297
-
298
- /**
299
- * Punctual Lights Extension
300
- *
301
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
302
- */
303
- function GLTFLightsExtension( json ) {
304
-
305
- this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL;
306
-
307
- var extension = ( json.extensions && json.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ] ) || {};
308
- this.lightDefs = extension.lights || [];
309
-
310
- }
311
-
312
- GLTFLightsExtension.prototype.loadLight = function ( lightIndex ) {
313
-
314
- var lightDef = this.lightDefs[ lightIndex ];
315
- var lightNode;
316
-
317
- var color = new THREE.Color( 0xffffff );
318
- if ( lightDef.color !== undefined ) color.fromArray( lightDef.color );
319
-
320
- var range = lightDef.range !== undefined ? lightDef.range : 0;
321
-
322
- switch ( lightDef.type ) {
323
-
324
- case 'directional':
325
- lightNode = new THREE.DirectionalLight( color );
326
- lightNode.target.position.set( 0, 0, - 1 );
327
- lightNode.add( lightNode.target );
328
- break;
329
-
330
- case 'point':
331
- lightNode = new THREE.PointLight( color );
332
- lightNode.distance = range;
333
- break;
334
-
335
- case 'spot':
336
- lightNode = new THREE.SpotLight( color );
337
- lightNode.distance = range;
338
- // Handle spotlight properties.
339
- lightDef.spot = lightDef.spot || {};
340
- lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== undefined ? lightDef.spot.innerConeAngle : 0;
341
- lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== undefined ? lightDef.spot.outerConeAngle : Math.PI / 4.0;
342
- lightNode.angle = lightDef.spot.outerConeAngle;
343
- lightNode.penumbra = 1.0 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle;
344
- lightNode.target.position.set( 0, 0, - 1 );
345
- lightNode.add( lightNode.target );
346
- break;
347
-
348
- default:
349
- throw new Error( 'THREE.GLTFLoader: Unexpected light type, "' + lightDef.type + '".' );
350
-
351
- }
352
-
353
- // Some lights (e.g. spot) default to a position other than the origin. Reset the position
354
- // here, because node-level parsing will only override position if explicitly specified.
355
- lightNode.position.set( 0, 0, 0 );
356
-
357
- lightNode.decay = 2;
358
-
359
- if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity;
360
-
361
- lightNode.name = lightDef.name || ( 'light_' + lightIndex );
362
-
363
- return Promise.resolve( lightNode );
364
-
365
- };
366
-
367
- /**
368
- * Unlit Materials Extension
369
- *
370
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
371
- */
372
- function GLTFMaterialsUnlitExtension() {
373
-
374
- this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
375
-
376
- }
377
-
378
- GLTFMaterialsUnlitExtension.prototype.getMaterialType = function () {
379
-
380
- return THREE.MeshBasicMaterial;
381
-
382
- };
383
-
384
- GLTFMaterialsUnlitExtension.prototype.extendParams = function ( materialParams, materialDef, parser ) {
385
-
386
- var pending = [];
387
-
388
- materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
389
- materialParams.opacity = 1.0;
390
-
391
- var metallicRoughness = materialDef.pbrMetallicRoughness;
392
-
393
- if ( metallicRoughness ) {
394
-
395
- if ( Array.isArray( metallicRoughness.baseColorFactor ) ) {
396
-
397
- var array = metallicRoughness.baseColorFactor;
398
-
399
- materialParams.color.fromArray( array );
400
- materialParams.opacity = array[ 3 ];
401
-
402
- }
403
-
404
- if ( metallicRoughness.baseColorTexture !== undefined ) {
405
-
406
- pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture ) );
407
-
408
- }
409
-
410
- }
411
-
412
- return Promise.all( pending );
413
-
414
- };
415
-
416
- /**
417
- * Clearcoat Materials Extension
418
- *
419
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
420
- */
421
- function GLTFMaterialsClearcoatExtension() {
422
-
423
- this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT;
424
-
425
- }
426
-
427
- GLTFMaterialsClearcoatExtension.prototype.getMaterialType = function () {
428
-
429
- return THREE.MeshPhysicalMaterial;
430
-
431
- };
432
-
433
- GLTFMaterialsClearcoatExtension.prototype.extendParams = function ( materialParams, materialDef, parser ) {
434
-
435
- var pending = [];
436
-
437
- var extension = materialDef.extensions[ this.name ];
438
-
439
- if ( extension.clearcoatFactor !== undefined ) {
440
-
441
- materialParams.clearcoat = extension.clearcoatFactor;
442
-
443
- }
444
-
445
- if ( extension.clearcoatTexture !== undefined ) {
446
-
447
- pending.push( parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) );
448
-
449
- }
450
-
451
- if ( extension.clearcoatRoughnessFactor !== undefined ) {
452
-
453
- materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor;
454
-
455
- }
456
-
457
- if ( extension.clearcoatRoughnessTexture !== undefined ) {
458
-
459
- pending.push( parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) );
460
-
461
- }
462
-
463
- if ( extension.clearcoatNormalTexture !== undefined ) {
464
-
465
- pending.push( parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) );
466
-
467
- if ( extension.clearcoatNormalTexture.scale !== undefined ) {
468
-
469
- var scale = extension.clearcoatNormalTexture.scale;
470
-
471
- materialParams.clearcoatNormalScale = new THREE.Vector2( scale, scale );
472
-
473
- }
474
-
475
- }
476
-
477
- return Promise.all( pending );
478
-
479
- };
480
-
481
- /* BINARY EXTENSION */
482
- var BINARY_EXTENSION_HEADER_MAGIC = 'glTF';
483
- var BINARY_EXTENSION_HEADER_LENGTH = 12;
484
- var BINARY_EXTENSION_CHUNK_TYPES = { JSON: 0x4E4F534A, BIN: 0x004E4942 };
485
-
486
- function GLTFBinaryExtension( data ) {
487
-
488
- this.name = EXTENSIONS.KHR_BINARY_GLTF;
489
- this.content = null;
490
- this.body = null;
491
-
492
- var headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH );
493
-
494
- this.header = {
495
- magic: THREE.LoaderUtils.decodeText( new Uint8Array( data.slice( 0, 4 ) ) ),
496
- version: headerView.getUint32( 4, true ),
497
- length: headerView.getUint32( 8, true )
498
- };
499
-
500
- if ( this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC ) {
501
-
502
- throw new Error( 'THREE.GLTFLoader: Unsupported glTF-Binary header.' );
503
-
504
- } else if ( this.header.version < 2.0 ) {
505
-
506
- throw new Error( 'THREE.GLTFLoader: Legacy binary file detected.' );
507
-
508
- }
509
-
510
- var chunkView = new DataView( data, BINARY_EXTENSION_HEADER_LENGTH );
511
- var chunkIndex = 0;
512
-
513
- while ( chunkIndex < chunkView.byteLength ) {
514
-
515
- var chunkLength = chunkView.getUint32( chunkIndex, true );
516
- chunkIndex += 4;
517
-
518
- var chunkType = chunkView.getUint32( chunkIndex, true );
519
- chunkIndex += 4;
520
-
521
- if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON ) {
522
-
523
- var contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength );
524
- this.content = THREE.LoaderUtils.decodeText( contentArray );
525
-
526
- } else if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN ) {
527
-
528
- var byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
529
- this.body = data.slice( byteOffset, byteOffset + chunkLength );
530
-
531
- }
532
-
533
- // Clients must ignore chunks with unknown types.
534
-
535
- chunkIndex += chunkLength;
536
-
537
- }
538
-
539
- if ( this.content === null ) {
540
-
541
- throw new Error( 'THREE.GLTFLoader: JSON content not found.' );
542
-
543
- }
544
-
545
- }
546
-
547
- /**
548
- * DRACO Mesh Compression Extension
549
- *
550
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
551
- */
552
- function GLTFDracoMeshCompressionExtension( json, dracoLoader ) {
553
-
554
- if ( ! dracoLoader ) {
555
-
556
- throw new Error( 'THREE.GLTFLoader: No DRACOLoader instance provided.' );
557
-
558
- }
559
-
560
- this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;
561
- this.json = json;
562
- this.dracoLoader = dracoLoader;
563
- this.dracoLoader.preload();
564
-
565
- }
566
-
567
- GLTFDracoMeshCompressionExtension.prototype.decodePrimitive = function ( primitive, parser ) {
568
-
569
- var json = this.json;
570
- var dracoLoader = this.dracoLoader;
571
- var bufferViewIndex = primitive.extensions[ this.name ].bufferView;
572
- var gltfAttributeMap = primitive.extensions[ this.name ].attributes;
573
- var threeAttributeMap = {};
574
- var attributeNormalizedMap = {};
575
- var attributeTypeMap = {};
576
-
577
- for ( var attributeName in gltfAttributeMap ) {
578
-
579
- var threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
580
-
581
- threeAttributeMap[ threeAttributeName ] = gltfAttributeMap[ attributeName ];
582
-
583
- }
584
-
585
- for ( attributeName in primitive.attributes ) {
586
-
587
- var threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
588
-
589
- if ( gltfAttributeMap[ attributeName ] !== undefined ) {
590
-
591
- var accessorDef = json.accessors[ primitive.attributes[ attributeName ] ];
592
- var componentType = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
593
-
594
- attributeTypeMap[ threeAttributeName ] = componentType;
595
- attributeNormalizedMap[ threeAttributeName ] = accessorDef.normalized === true;
596
-
597
- }
598
-
599
- }
600
-
601
- return parser.getDependency( 'bufferView', bufferViewIndex ).then( function ( bufferView ) {
602
-
603
- return new Promise( function ( resolve ) {
604
-
605
- dracoLoader.decodeDracoFile( bufferView, function ( geometry ) {
606
-
607
- for ( var attributeName in geometry.attributes ) {
608
-
609
- var attribute = geometry.attributes[ attributeName ];
610
- var normalized = attributeNormalizedMap[ attributeName ];
611
-
612
- if ( normalized !== undefined ) attribute.normalized = normalized;
613
-
614
- }
615
-
616
- resolve( geometry );
617
-
618
- }, threeAttributeMap, attributeTypeMap );
619
-
620
- } );
621
-
622
- } );
623
-
624
- };
625
-
626
- /**
627
- * Texture Transform Extension
628
- *
629
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
630
- */
631
- function GLTFTextureTransformExtension() {
632
-
633
- this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
634
-
635
- }
636
-
637
- GLTFTextureTransformExtension.prototype.extendTexture = function ( texture, transform ) {
638
-
639
- texture = texture.clone();
640
-
641
- if ( transform.offset !== undefined ) {
642
-
643
- texture.offset.fromArray( transform.offset );
644
-
645
- }
646
-
647
- if ( transform.rotation !== undefined ) {
648
-
649
- texture.rotation = transform.rotation;
650
-
651
- }
652
-
653
- if ( transform.scale !== undefined ) {
654
-
655
- texture.repeat.fromArray( transform.scale );
656
-
657
- }
658
-
659
- if ( transform.texCoord !== undefined ) {
660
-
661
- console.warn( 'THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.' );
662
-
663
- }
664
-
665
- texture.needsUpdate = true;
666
-
667
- return texture;
668
-
669
- };
670
-
671
- /**
672
- * Specular-Glossiness Extension
673
- *
674
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness
675
- */
676
-
677
- /**
678
- * A sub class of THREE.StandardMaterial with some of the functionality
679
- * changed via the `onBeforeCompile` callback
680
- * @pailhead
681
- */
682
-
683
- function GLTFMeshStandardSGMaterial( params ) {
684
-
685
- THREE.MeshStandardMaterial.call( this );
686
-
687
- this.isGLTFSpecularGlossinessMaterial = true;
688
-
689
- //various chunks that need replacing
690
- var specularMapParsFragmentChunk = [
691
- '#ifdef USE_SPECULARMAP',
692
- ' uniform sampler2D specularMap;',
693
- '#endif'
694
- ].join( '\n' );
695
-
696
- var glossinessMapParsFragmentChunk = [
697
- '#ifdef USE_GLOSSINESSMAP',
698
- ' uniform sampler2D glossinessMap;',
699
- '#endif'
700
- ].join( '\n' );
701
-
702
- var specularMapFragmentChunk = [
703
- 'vec3 specularFactor = specular;',
704
- '#ifdef USE_SPECULARMAP',
705
- ' vec4 texelSpecular = texture2D( specularMap, vUv );',
706
- ' texelSpecular = sRGBToLinear( texelSpecular );',
707
- ' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture',
708
- ' specularFactor *= texelSpecular.rgb;',
709
- '#endif'
710
- ].join( '\n' );
711
-
712
- var glossinessMapFragmentChunk = [
713
- 'float glossinessFactor = glossiness;',
714
- '#ifdef USE_GLOSSINESSMAP',
715
- ' vec4 texelGlossiness = texture2D( glossinessMap, vUv );',
716
- ' // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture',
717
- ' glossinessFactor *= texelGlossiness.a;',
718
- '#endif'
719
- ].join( '\n' );
720
-
721
- var lightPhysicalFragmentChunk = [
722
- 'PhysicalMaterial material;',
723
- 'material.diffuseColor = diffuseColor.rgb;',
724
- 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );',
725
- 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );',
726
- 'material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.',
727
- 'material.specularRoughness += geometryRoughness;',
728
- 'material.specularRoughness = min( material.specularRoughness, 1.0 );',
729
- 'material.specularColor = specularFactor.rgb;',
730
- ].join( '\n' );
731
-
732
- var uniforms = {
733
- specular: { value: new THREE.Color().setHex( 0xffffff ) },
734
- glossiness: { value: 1 },
735
- specularMap: { value: null },
736
- glossinessMap: { value: null }
737
- };
738
-
739
- this._extraUniforms = uniforms;
740
-
741
- // please see #14031 or #13198 for an alternate approach
742
- this.onBeforeCompile = function ( shader ) {
743
-
744
- for ( var uniformName in uniforms ) {
745
-
746
- shader.uniforms[ uniformName ] = uniforms[ uniformName ];
747
-
748
- }
749
-
750
- shader.fragmentShader = shader.fragmentShader.replace( 'uniform float roughness;', 'uniform vec3 specular;' );
751
- shader.fragmentShader = shader.fragmentShader.replace( 'uniform float metalness;', 'uniform float glossiness;' );
752
- shader.fragmentShader = shader.fragmentShader.replace( '#include <roughnessmap_pars_fragment>', specularMapParsFragmentChunk );
753
- shader.fragmentShader = shader.fragmentShader.replace( '#include <metalnessmap_pars_fragment>', glossinessMapParsFragmentChunk );
754
- shader.fragmentShader = shader.fragmentShader.replace( '#include <roughnessmap_fragment>', specularMapFragmentChunk );
755
- shader.fragmentShader = shader.fragmentShader.replace( '#include <metalnessmap_fragment>', glossinessMapFragmentChunk );
756
- shader.fragmentShader = shader.fragmentShader.replace( '#include <lights_physical_fragment>', lightPhysicalFragmentChunk );
757
-
758
- };
759
-
760
- /*eslint-disable*/
761
- Object.defineProperties(
762
- this,
763
- {
764
- specular: {
765
- get: function () { return uniforms.specular.value; },
766
- set: function ( v ) { uniforms.specular.value = v; }
767
- },
768
- specularMap: {
769
- get: function () { return uniforms.specularMap.value; },
770
- set: function ( v ) { uniforms.specularMap.value = v; }
771
- },
772
- glossiness: {
773
- get: function () { return uniforms.glossiness.value; },
774
- set: function ( v ) { uniforms.glossiness.value = v; }
775
- },
776
- glossinessMap: {
777
- get: function () { return uniforms.glossinessMap.value; },
778
- set: function ( v ) {
779
-
780
- uniforms.glossinessMap.value = v;
781
- //how about something like this - @pailhead
782
- if ( v ) {
783
-
784
- this.defines.USE_GLOSSINESSMAP = '';
785
- // set USE_ROUGHNESSMAP to enable vUv
786
- this.defines.USE_ROUGHNESSMAP = '';
787
-
788
- } else {
789
-
790
- delete this.defines.USE_ROUGHNESSMAP;
791
- delete this.defines.USE_GLOSSINESSMAP;
792
-
793
- }
794
-
795
- }
796
- }
797
- }
798
- );
799
-
800
- /*eslint-enable*/
801
- delete this.metalness;
802
- delete this.roughness;
803
- delete this.metalnessMap;
804
- delete this.roughnessMap;
805
-
806
- this.setValues( params );
807
-
808
- }
809
-
810
- GLTFMeshStandardSGMaterial.prototype = Object.create( THREE.MeshStandardMaterial.prototype );
811
- GLTFMeshStandardSGMaterial.prototype.constructor = GLTFMeshStandardSGMaterial;
812
-
813
- GLTFMeshStandardSGMaterial.prototype.copy = function ( source ) {
814
-
815
- THREE.MeshStandardMaterial.prototype.copy.call( this, source );
816
- this.specularMap = source.specularMap;
817
- this.specular.copy( source.specular );
818
- this.glossinessMap = source.glossinessMap;
819
- this.glossiness = source.glossiness;
820
- delete this.metalness;
821
- delete this.roughness;
822
- delete this.metalnessMap;
823
- delete this.roughnessMap;
824
- return this;
825
-
826
- };
827
-
828
- function GLTFMaterialsPbrSpecularGlossinessExtension() {
829
-
830
- return {
831
-
832
- name: EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,
833
-
834
- specularGlossinessParams: [
835
- 'color',
836
- 'map',
837
- 'lightMap',
838
- 'lightMapIntensity',
839
- 'aoMap',
840
- 'aoMapIntensity',
841
- 'emissive',
842
- 'emissiveIntensity',
843
- 'emissiveMap',
844
- 'bumpMap',
845
- 'bumpScale',
846
- 'normalMap',
847
- 'normalMapType',
848
- 'displacementMap',
849
- 'displacementScale',
850
- 'displacementBias',
851
- 'specularMap',
852
- 'specular',
853
- 'glossinessMap',
854
- 'glossiness',
855
- 'alphaMap',
856
- 'envMap',
857
- 'envMapIntensity',
858
- 'refractionRatio',
859
- ],
860
-
861
- getMaterialType: function () {
862
-
863
- return GLTFMeshStandardSGMaterial;
864
-
865
- },
866
-
867
- extendParams: function ( materialParams, materialDef, parser ) {
868
-
869
- var pbrSpecularGlossiness = materialDef.extensions[ this.name ];
870
-
871
- materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
872
- materialParams.opacity = 1.0;
873
-
874
- var pending = [];
875
-
876
- if ( Array.isArray( pbrSpecularGlossiness.diffuseFactor ) ) {
877
-
878
- var array = pbrSpecularGlossiness.diffuseFactor;
879
-
880
- materialParams.color.fromArray( array );
881
- materialParams.opacity = array[ 3 ];
882
-
883
- }
884
-
885
- if ( pbrSpecularGlossiness.diffuseTexture !== undefined ) {
886
-
887
- pending.push( parser.assignTexture( materialParams, 'map', pbrSpecularGlossiness.diffuseTexture ) );
888
-
889
- }
890
-
891
- materialParams.emissive = new THREE.Color( 0.0, 0.0, 0.0 );
892
- materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0;
893
- materialParams.specular = new THREE.Color( 1.0, 1.0, 1.0 );
894
-
895
- if ( Array.isArray( pbrSpecularGlossiness.specularFactor ) ) {
896
-
897
- materialParams.specular.fromArray( pbrSpecularGlossiness.specularFactor );
898
-
899
- }
900
-
901
- if ( pbrSpecularGlossiness.specularGlossinessTexture !== undefined ) {
902
-
903
- var specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;
904
- pending.push( parser.assignTexture( materialParams, 'glossinessMap', specGlossMapDef ) );
905
- pending.push( parser.assignTexture( materialParams, 'specularMap', specGlossMapDef ) );
906
-
907
- }
908
-
909
- return Promise.all( pending );
910
-
911
- },
912
-
913
- createMaterial: function ( materialParams ) {
914
-
915
- var material = new GLTFMeshStandardSGMaterial( materialParams );
916
- material.fog = true;
917
-
918
- material.color = materialParams.color;
919
-
920
- material.map = materialParams.map === undefined ? null : materialParams.map;
921
-
922
- material.lightMap = null;
923
- material.lightMapIntensity = 1.0;
924
-
925
- material.aoMap = materialParams.aoMap === undefined ? null : materialParams.aoMap;
926
- material.aoMapIntensity = 1.0;
927
-
928
- material.emissive = materialParams.emissive;
929
- material.emissiveIntensity = 1.0;
930
- material.emissiveMap = materialParams.emissiveMap === undefined ? null : materialParams.emissiveMap;
931
-
932
- material.bumpMap = materialParams.bumpMap === undefined ? null : materialParams.bumpMap;
933
- material.bumpScale = 1;
934
-
935
- material.normalMap = materialParams.normalMap === undefined ? null : materialParams.normalMap;
936
- material.normalMapType = THREE.TangentSpaceNormalMap;
937
-
938
- if ( materialParams.normalScale ) material.normalScale = materialParams.normalScale;
939
-
940
- material.displacementMap = null;
941
- material.displacementScale = 1;
942
- material.displacementBias = 0;
943
-
944
- material.specularMap = materialParams.specularMap === undefined ? null : materialParams.specularMap;
945
- material.specular = materialParams.specular;
946
-
947
- material.glossinessMap = materialParams.glossinessMap === undefined ? null : materialParams.glossinessMap;
948
- material.glossiness = materialParams.glossiness;
949
-
950
- material.alphaMap = null;
951
-
952
- material.envMap = materialParams.envMap === undefined ? null : materialParams.envMap;
953
- material.envMapIntensity = 1.0;
954
-
955
- material.refractionRatio = 0.98;
956
-
957
- return material;
958
-
959
- },
960
-
961
- };
962
-
963
- }
964
-
965
- /**
966
- * Mesh Quantization Extension
967
- *
968
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization
969
- */
970
- function GLTFMeshQuantizationExtension() {
971
-
972
- this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;
973
-
974
- }
975
-
976
- /*********************************/
977
- /********** INTERPOLATION ********/
978
- /*********************************/
979
-
980
- // Spline Interpolation
981
- // Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation
982
- function GLTFCubicSplineInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) {
983
-
984
- THREE.Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer );
985
-
986
- }
987
-
988
- GLTFCubicSplineInterpolant.prototype = Object.create( THREE.Interpolant.prototype );
989
- GLTFCubicSplineInterpolant.prototype.constructor = GLTFCubicSplineInterpolant;
990
-
991
- GLTFCubicSplineInterpolant.prototype.copySampleValue_ = function ( index ) {
992
-
993
- // Copies a sample value to the result buffer. See description of glTF
994
- // CUBICSPLINE values layout in interpolate_() function below.
995
-
996
- var result = this.resultBuffer,
997
- values = this.sampleValues,
998
- valueSize = this.valueSize,
999
- offset = index * valueSize * 3 + valueSize;
1000
-
1001
- for ( var i = 0; i !== valueSize; i ++ ) {
1002
-
1003
- result[ i ] = values[ offset + i ];
1004
-
1005
- }
1006
-
1007
- return result;
1008
-
1009
- };
1010
-
1011
- GLTFCubicSplineInterpolant.prototype.beforeStart_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
1012
-
1013
- GLTFCubicSplineInterpolant.prototype.afterEnd_ = GLTFCubicSplineInterpolant.prototype.copySampleValue_;
1014
-
1015
- GLTFCubicSplineInterpolant.prototype.interpolate_ = function ( i1, t0, t, t1 ) {
1016
-
1017
- var result = this.resultBuffer;
1018
- var values = this.sampleValues;
1019
- var stride = this.valueSize;
1020
-
1021
- var stride2 = stride * 2;
1022
- var stride3 = stride * 3;
1023
-
1024
- var td = t1 - t0;
1025
-
1026
- var p = ( t - t0 ) / td;
1027
- var pp = p * p;
1028
- var ppp = pp * p;
1029
-
1030
- var offset1 = i1 * stride3;
1031
- var offset0 = offset1 - stride3;
1032
-
1033
- var s2 = - 2 * ppp + 3 * pp;
1034
- var s3 = ppp - pp;
1035
- var s0 = 1 - s2;
1036
- var s1 = s3 - pp + p;
1037
-
1038
- // Layout of keyframe output values for CUBICSPLINE animations:
1039
- // [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ]
1040
- for ( var i = 0; i !== stride; i ++ ) {
1041
-
1042
- var p0 = values[ offset0 + i + stride ]; // splineVertex_k
1043
- var m0 = values[ offset0 + i + stride2 ] * td; // outTangent_k * (t_k+1 - t_k)
1044
- var p1 = values[ offset1 + i + stride ]; // splineVertex_k+1
1045
- var m1 = values[ offset1 + i ] * td; // inTangent_k+1 * (t_k+1 - t_k)
1046
-
1047
- result[ i ] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
1048
-
1049
- }
1050
-
1051
- return result;
1052
-
1053
- };
1054
-
1055
- /*********************************/
1056
- /********** INTERNALS ************/
1057
- /*********************************/
1058
-
1059
- /* CONSTANTS */
1060
-
1061
- var WEBGL_CONSTANTS = {
1062
- FLOAT: 5126,
1063
- //FLOAT_MAT2: 35674,
1064
- FLOAT_MAT3: 35675,
1065
- FLOAT_MAT4: 35676,
1066
- FLOAT_VEC2: 35664,
1067
- FLOAT_VEC3: 35665,
1068
- FLOAT_VEC4: 35666,
1069
- LINEAR: 9729,
1070
- REPEAT: 10497,
1071
- SAMPLER_2D: 35678,
1072
- POINTS: 0,
1073
- LINES: 1,
1074
- LINE_LOOP: 2,
1075
- LINE_STRIP: 3,
1076
- TRIANGLES: 4,
1077
- TRIANGLE_STRIP: 5,
1078
- TRIANGLE_FAN: 6,
1079
- UNSIGNED_BYTE: 5121,
1080
- UNSIGNED_SHORT: 5123
1081
- };
1082
-
1083
- var WEBGL_COMPONENT_TYPES = {
1084
- 5120: Int8Array,
1085
- 5121: Uint8Array,
1086
- 5122: Int16Array,
1087
- 5123: Uint16Array,
1088
- 5125: Uint32Array,
1089
- 5126: Float32Array
1090
- };
1091
-
1092
- var WEBGL_FILTERS = {
1093
- 9728: THREE.NearestFilter,
1094
- 9729: THREE.LinearFilter,
1095
- 9984: THREE.NearestMipmapNearestFilter,
1096
- 9985: THREE.LinearMipmapNearestFilter,
1097
- 9986: THREE.NearestMipmapLinearFilter,
1098
- 9987: THREE.LinearMipmapLinearFilter
1099
- };
1100
-
1101
- var WEBGL_WRAPPINGS = {
1102
- 33071: THREE.ClampToEdgeWrapping,
1103
- 33648: THREE.MirroredRepeatWrapping,
1104
- 10497: THREE.RepeatWrapping
1105
- };
1106
-
1107
- var WEBGL_TYPE_SIZES = {
1108
- 'SCALAR': 1,
1109
- 'VEC2': 2,
1110
- 'VEC3': 3,
1111
- 'VEC4': 4,
1112
- 'MAT2': 4,
1113
- 'MAT3': 9,
1114
- 'MAT4': 16
1115
- };
1116
-
1117
- var ATTRIBUTES = {
1118
- POSITION: 'position',
1119
- NORMAL: 'normal',
1120
- TANGENT: 'tangent',
1121
- TEXCOORD_0: 'uv',
1122
- TEXCOORD_1: 'uv2',
1123
- COLOR_0: 'color',
1124
- WEIGHTS_0: 'skinWeight',
1125
- JOINTS_0: 'skinIndex',
1126
- };
1127
-
1128
- var PATH_PROPERTIES = {
1129
- scale: 'scale',
1130
- translation: 'position',
1131
- rotation: 'quaternion',
1132
- weights: 'morphTargetInfluences'
1133
- };
1134
-
1135
- var INTERPOLATION = {
1136
- CUBICSPLINE: undefined, // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
1137
- // keyframe track will be initialized with a default interpolation type, then modified.
1138
- LINEAR: THREE.InterpolateLinear,
1139
- STEP: THREE.InterpolateDiscrete
1140
- };
1141
-
1142
- var ALPHA_MODES = {
1143
- OPAQUE: 'OPAQUE',
1144
- MASK: 'MASK',
1145
- BLEND: 'BLEND'
1146
- };
1147
-
1148
- var MIME_TYPE_FORMATS = {
1149
- 'image/png': THREE.RGBAFormat,
1150
- 'image/jpeg': THREE.RGBFormat
1151
- };
1152
-
1153
- /* UTILITY FUNCTIONS */
1154
-
1155
- function resolveURL( url, path ) {
1156
-
1157
- // Invalid URL
1158
- if ( typeof url !== 'string' || url === '' ) return '';
1159
-
1160
- // Host Relative URL
1161
- if ( /^https?:\/\//i.test( path ) && /^\//.test( url ) ) {
1162
-
1163
- path = path.replace( /(^https?:\/\/[^\/]+).*/i, '$1' );
1164
-
1165
- }
1166
-
1167
- // Absolute URL http://,https://,//
1168
- if ( /^(https?:)?\/\//i.test( url ) ) return url;
1169
-
1170
- // Data URI
1171
- if ( /^data:.*,.*$/i.test( url ) ) return url;
1172
-
1173
- // Blob URL
1174
- if ( /^blob:.*$/i.test( url ) ) return url;
1175
-
1176
- // Relative URL
1177
- return path + url;
1178
-
1179
- }
1180
-
1181
- /**
1182
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
1183
- */
1184
- function createDefaultMaterial( cache ) {
1185
-
1186
- if ( cache[ 'DefaultMaterial' ] === undefined ) {
1187
-
1188
- cache[ 'DefaultMaterial' ] = new THREE.MeshStandardMaterial( {
1189
- color: 0xFFFFFF,
1190
- emissive: 0x000000,
1191
- metalness: 1,
1192
- roughness: 1,
1193
- transparent: false,
1194
- depthTest: true,
1195
- side: THREE.FrontSide
1196
- } );
1197
-
1198
- }
1199
-
1200
- return cache[ 'DefaultMaterial' ];
1201
-
1202
- }
1203
-
1204
- function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) {
1205
-
1206
- // Add unknown glTF extensions to an object's userData.
1207
-
1208
- for ( var name in objectDef.extensions ) {
1209
-
1210
- if ( knownExtensions[ name ] === undefined ) {
1211
-
1212
- object.userData.gltfExtensions = object.userData.gltfExtensions || {};
1213
- object.userData.gltfExtensions[ name ] = objectDef.extensions[ name ];
1214
-
1215
- }
1216
-
1217
- }
1218
-
1219
- }
1220
-
1221
- /**
1222
- * @param {THREE.Object3D|THREE.Material|THREE.BufferGeometry} object
1223
- * @param {GLTF.definition} gltfDef
1224
- */
1225
- function assignExtrasToUserData( object, gltfDef ) {
1226
-
1227
- if ( gltfDef.extras !== undefined ) {
1228
-
1229
- if ( typeof gltfDef.extras === 'object' ) {
1230
-
1231
- Object.assign( object.userData, gltfDef.extras );
1232
-
1233
- } else {
1234
-
1235
- console.warn( 'THREE.GLTFLoader: Ignoring primitive type .extras, ' + gltfDef.extras );
1236
-
1237
- }
1238
-
1239
- }
1240
-
1241
- }
1242
-
1243
- /**
1244
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
1245
- *
1246
- * @param {THREE.BufferGeometry} geometry
1247
- * @param {Array<GLTF.Target>} targets
1248
- * @param {GLTFParser} parser
1249
- * @return {Promise<THREE.BufferGeometry>}
1250
- */
1251
- function addMorphTargets( geometry, targets, parser ) {
1252
-
1253
- var hasMorphPosition = false;
1254
- var hasMorphNormal = false;
1255
-
1256
- for ( var i = 0, il = targets.length; i < il; i ++ ) {
1257
-
1258
- var target = targets[ i ];
1259
-
1260
- if ( target.POSITION !== undefined ) hasMorphPosition = true;
1261
- if ( target.NORMAL !== undefined ) hasMorphNormal = true;
1262
-
1263
- if ( hasMorphPosition && hasMorphNormal ) break;
1264
-
1265
- }
1266
-
1267
- if ( ! hasMorphPosition && ! hasMorphNormal ) return Promise.resolve( geometry );
1268
-
1269
- var pendingPositionAccessors = [];
1270
- var pendingNormalAccessors = [];
1271
-
1272
- for ( var i = 0, il = targets.length; i < il; i ++ ) {
1273
-
1274
- var target = targets[ i ];
1275
-
1276
- if ( hasMorphPosition ) {
1277
-
1278
- var pendingAccessor = target.POSITION !== undefined
1279
- ? parser.getDependency( 'accessor', target.POSITION )
1280
- : geometry.attributes.position;
1281
-
1282
- pendingPositionAccessors.push( pendingAccessor );
1283
-
1284
- }
1285
-
1286
- if ( hasMorphNormal ) {
1287
-
1288
- var pendingAccessor = target.NORMAL !== undefined
1289
- ? parser.getDependency( 'accessor', target.NORMAL )
1290
- : geometry.attributes.normal;
1291
-
1292
- pendingNormalAccessors.push( pendingAccessor );
1293
-
1294
- }
1295
-
1296
- }
1297
-
1298
- return Promise.all( [
1299
- Promise.all( pendingPositionAccessors ),
1300
- Promise.all( pendingNormalAccessors )
1301
- ] ).then( function ( accessors ) {
1302
-
1303
- var morphPositions = accessors[ 0 ];
1304
- var morphNormals = accessors[ 1 ];
1305
-
1306
- if ( hasMorphPosition ) geometry.morphAttributes.position = morphPositions;
1307
- if ( hasMorphNormal ) geometry.morphAttributes.normal = morphNormals;
1308
- geometry.morphTargetsRelative = true;
1309
-
1310
- return geometry;
1311
-
1312
- } );
1313
-
1314
- }
1315
-
1316
- /**
1317
- * @param {THREE.Mesh} mesh
1318
- * @param {GLTF.Mesh} meshDef
1319
- */
1320
- function updateMorphTargets( mesh, meshDef ) {
1321
-
1322
- mesh.updateMorphTargets();
1323
-
1324
- if ( meshDef.weights !== undefined ) {
1325
-
1326
- for ( var i = 0, il = meshDef.weights.length; i < il; i ++ ) {
1327
-
1328
- mesh.morphTargetInfluences[ i ] = meshDef.weights[ i ];
1329
-
1330
- }
1331
-
1332
- }
1333
-
1334
- // .extras has user-defined data, so check that .extras.targetNames is an array.
1335
- if ( meshDef.extras && Array.isArray( meshDef.extras.targetNames ) ) {
1336
-
1337
- var targetNames = meshDef.extras.targetNames;
1338
-
1339
- if ( mesh.morphTargetInfluences.length === targetNames.length ) {
1340
-
1341
- mesh.morphTargetDictionary = {};
1342
-
1343
- for ( var i = 0, il = targetNames.length; i < il; i ++ ) {
1344
-
1345
- mesh.morphTargetDictionary[ targetNames[ i ] ] = i;
1346
-
1347
- }
1348
-
1349
- } else {
1350
-
1351
- console.warn( 'THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.' );
1352
-
1353
- }
1354
-
1355
- }
1356
-
1357
- }
1358
-
1359
- function createPrimitiveKey( primitiveDef ) {
1360
-
1361
- var dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ];
1362
- var geometryKey;
1363
-
1364
- if ( dracoExtension ) {
1365
-
1366
- geometryKey = 'draco:' + dracoExtension.bufferView
1367
- + ':' + dracoExtension.indices
1368
- + ':' + createAttributesKey( dracoExtension.attributes );
1369
-
1370
- } else {
1371
-
1372
- geometryKey = primitiveDef.indices + ':' + createAttributesKey( primitiveDef.attributes ) + ':' + primitiveDef.mode;
1373
-
1374
- }
1375
-
1376
- return geometryKey;
1377
-
1378
- }
1379
-
1380
- function createAttributesKey( attributes ) {
1381
-
1382
- var attributesKey = '';
1383
-
1384
- var keys = Object.keys( attributes ).sort();
1385
-
1386
- for ( var i = 0, il = keys.length; i < il; i ++ ) {
1387
-
1388
- attributesKey += keys[ i ] + ':' + attributes[ keys[ i ] ] + ';';
1389
-
1390
- }
1391
-
1392
- return attributesKey;
1393
-
1394
- }
1395
-
1396
- /* GLTF PARSER */
1397
-
1398
- function GLTFParser( json, extensions, options ) {
1399
-
1400
- this.json = json || {};
1401
- this.extensions = extensions || {};
1402
- this.options = options || {};
1403
-
1404
- // loader object cache
1405
- this.cache = new GLTFRegistry();
1406
-
1407
- // BufferGeometry caching
1408
- this.primitiveCache = {};
1409
-
1410
- this.textureLoader = new THREE.TextureLoader( this.options.manager );
1411
- this.textureLoader.setCrossOrigin( this.options.crossOrigin );
1412
-
1413
- this.fileLoader = new THREE.FileLoader( this.options.manager );
1414
- this.fileLoader.setResponseType( 'arraybuffer' );
1415
-
1416
- if ( this.options.crossOrigin === 'use-credentials' ) {
1417
-
1418
- this.fileLoader.setWithCredentials( true );
1419
-
1420
- }
1421
-
1422
- }
1423
-
1424
- GLTFParser.prototype.parse = function ( onLoad, onError ) {
1425
-
1426
- var parser = this;
1427
- var json = this.json;
1428
- var extensions = this.extensions;
1429
-
1430
- // Clear the loader cache
1431
- this.cache.removeAll();
1432
-
1433
- // Mark the special nodes/meshes in json for efficient parse
1434
- this.markDefs();
1435
-
1436
- Promise.all( [
1437
-
1438
- this.getDependencies( 'scene' ),
1439
- this.getDependencies( 'animation' ),
1440
- this.getDependencies( 'camera' ),
1441
-
1442
- ] ).then( function ( dependencies ) {
1443
-
1444
- var result = {
1445
- scene: dependencies[ 0 ][ json.scene || 0 ],
1446
- scenes: dependencies[ 0 ],
1447
- animations: dependencies[ 1 ],
1448
- cameras: dependencies[ 2 ],
1449
- asset: json.asset,
1450
- parser: parser,
1451
- userData: {}
1452
- };
1453
-
1454
- addUnknownExtensionsToUserData( extensions, result, json );
1455
-
1456
- assignExtrasToUserData( result, json );
1457
-
1458
- onLoad( result );
1459
-
1460
- } ).catch( onError );
1461
-
1462
- };
1463
-
1464
- /**
1465
- * Marks the special nodes/meshes in json for efficient parse.
1466
- */
1467
- GLTFParser.prototype.markDefs = function () {
1468
-
1469
- var nodeDefs = this.json.nodes || [];
1470
- var skinDefs = this.json.skins || [];
1471
- var meshDefs = this.json.meshes || [];
1472
-
1473
- var meshReferences = {};
1474
- var meshUses = {};
1475
-
1476
- // Nothing in the node definition indicates whether it is a Bone or an
1477
- // Object3D. Use the skins' joint references to mark bones.
1478
- for ( var skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex ++ ) {
1479
-
1480
- var joints = skinDefs[ skinIndex ].joints;
1481
-
1482
- for ( var i = 0, il = joints.length; i < il; i ++ ) {
1483
-
1484
- nodeDefs[ joints[ i ] ].isBone = true;
1485
-
1486
- }
1487
-
1488
- }
1489
-
1490
- // Meshes can (and should) be reused by multiple nodes in a glTF asset. To
1491
- // avoid having more than one THREE.Mesh with the same name, count
1492
- // references and rename instances below.
1493
- //
1494
- // Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
1495
- for ( var nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) {
1496
-
1497
- var nodeDef = nodeDefs[ nodeIndex ];
1498
-
1499
- if ( nodeDef.mesh !== undefined ) {
1500
-
1501
- if ( meshReferences[ nodeDef.mesh ] === undefined ) {
1502
-
1503
- meshReferences[ nodeDef.mesh ] = meshUses[ nodeDef.mesh ] = 0;
1504
-
1505
- }
1506
-
1507
- meshReferences[ nodeDef.mesh ] ++;
1508
-
1509
- // Nothing in the mesh definition indicates whether it is
1510
- // a SkinnedMesh or Mesh. Use the node's mesh reference
1511
- // to mark SkinnedMesh if node has skin.
1512
- if ( nodeDef.skin !== undefined ) {
1513
-
1514
- meshDefs[ nodeDef.mesh ].isSkinnedMesh = true;
1515
-
1516
- }
1517
-
1518
- }
1519
-
1520
- }
1521
-
1522
- this.json.meshReferences = meshReferences;
1523
- this.json.meshUses = meshUses;
1524
-
1525
- };
1526
-
1527
- /**
1528
- * Requests the specified dependency asynchronously, with caching.
1529
- * @param {string} type
1530
- * @param {number} index
1531
- * @return {Promise<THREE.Object3D|THREE.Material|THREE.Texture|THREE.AnimationClip|ArrayBuffer|Object>}
1532
- */
1533
- GLTFParser.prototype.getDependency = function ( type, index ) {
1534
-
1535
- var cacheKey = type + ':' + index;
1536
- var dependency = this.cache.get( cacheKey );
1537
-
1538
- if ( ! dependency ) {
1539
-
1540
- switch ( type ) {
1541
-
1542
- case 'scene':
1543
- dependency = this.loadScene( index );
1544
- break;
1545
-
1546
- case 'node':
1547
- dependency = this.loadNode( index );
1548
- break;
1549
-
1550
- case 'mesh':
1551
- dependency = this.loadMesh( index );
1552
- break;
1553
-
1554
- case 'accessor':
1555
- dependency = this.loadAccessor( index );
1556
- break;
1557
-
1558
- case 'bufferView':
1559
- dependency = this.loadBufferView( index );
1560
- break;
1561
-
1562
- case 'buffer':
1563
- dependency = this.loadBuffer( index );
1564
- break;
1565
-
1566
- case 'material':
1567
- dependency = this.loadMaterial( index );
1568
- break;
1569
-
1570
- case 'texture':
1571
- dependency = this.loadTexture( index );
1572
- break;
1573
-
1574
- case 'skin':
1575
- dependency = this.loadSkin( index );
1576
- break;
1577
-
1578
- case 'animation':
1579
- dependency = this.loadAnimation( index );
1580
- break;
1581
-
1582
- case 'camera':
1583
- dependency = this.loadCamera( index );
1584
- break;
1585
-
1586
- case 'light':
1587
- dependency = this.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].loadLight( index );
1588
- break;
1589
-
1590
- default:
1591
- throw new Error( 'Unknown type: ' + type );
1592
-
1593
- }
1594
-
1595
- this.cache.add( cacheKey, dependency );
1596
-
1597
- }
1598
-
1599
- return dependency;
1600
-
1601
- };
1602
-
1603
- /**
1604
- * Requests all dependencies of the specified type asynchronously, with caching.
1605
- * @param {string} type
1606
- * @return {Promise<Array<Object>>}
1607
- */
1608
- GLTFParser.prototype.getDependencies = function ( type ) {
1609
-
1610
- var dependencies = this.cache.get( type );
1611
-
1612
- if ( ! dependencies ) {
1613
-
1614
- var parser = this;
1615
- var defs = this.json[ type + ( type === 'mesh' ? 'es' : 's' ) ] || [];
1616
-
1617
- dependencies = Promise.all( defs.map( function ( def, index ) {
1618
-
1619
- return parser.getDependency( type, index );
1620
-
1621
- } ) );
1622
-
1623
- this.cache.add( type, dependencies );
1624
-
1625
- }
1626
-
1627
- return dependencies;
1628
-
1629
- };
1630
-
1631
- /**
1632
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
1633
- * @param {number} bufferIndex
1634
- * @return {Promise<ArrayBuffer>}
1635
- */
1636
- GLTFParser.prototype.loadBuffer = function ( bufferIndex ) {
1637
-
1638
- var bufferDef = this.json.buffers[ bufferIndex ];
1639
- var loader = this.fileLoader;
1640
-
1641
- if ( bufferDef.type && bufferDef.type !== 'arraybuffer' ) {
1642
-
1643
- throw new Error( 'THREE.GLTFLoader: ' + bufferDef.type + ' buffer type is not supported.' );
1644
-
1645
- }
1646
-
1647
- // If present, GLB container is required to be the first buffer.
1648
- if ( bufferDef.uri === undefined && bufferIndex === 0 ) {
1649
-
1650
- return Promise.resolve( this.extensions[ EXTENSIONS.KHR_BINARY_GLTF ].body );
1651
-
1652
- }
1653
-
1654
- var options = this.options;
1655
-
1656
- return new Promise( function ( resolve, reject ) {
1657
-
1658
- loader.load( resolveURL( bufferDef.uri, options.path ), resolve, undefined, function () {
1659
-
1660
- reject( new Error( 'THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".' ) );
1661
-
1662
- } );
1663
-
1664
- } );
1665
-
1666
- };
1667
-
1668
- /**
1669
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
1670
- * @param {number} bufferViewIndex
1671
- * @return {Promise<ArrayBuffer>}
1672
- */
1673
- GLTFParser.prototype.loadBufferView = function ( bufferViewIndex ) {
1674
-
1675
- var bufferViewDef = this.json.bufferViews[ bufferViewIndex ];
1676
-
1677
- return this.getDependency( 'buffer', bufferViewDef.buffer ).then( function ( buffer ) {
1678
-
1679
- var byteLength = bufferViewDef.byteLength || 0;
1680
- var byteOffset = bufferViewDef.byteOffset || 0;
1681
- return buffer.slice( byteOffset, byteOffset + byteLength );
1682
-
1683
- } );
1684
-
1685
- };
1686
-
1687
- /**
1688
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
1689
- * @param {number} accessorIndex
1690
- * @return {Promise<THREE.BufferAttribute|THREE.InterleavedBufferAttribute>}
1691
- */
1692
- GLTFParser.prototype.loadAccessor = function ( accessorIndex ) {
1693
-
1694
- var parser = this;
1695
- var json = this.json;
1696
-
1697
- var accessorDef = this.json.accessors[ accessorIndex ];
1698
-
1699
- if ( accessorDef.bufferView === undefined && accessorDef.sparse === undefined ) {
1700
-
1701
- // Ignore empty accessors, which may be used to declare runtime
1702
- // information about attributes coming from another source (e.g. Draco
1703
- // compression extension).
1704
- return Promise.resolve( null );
1705
-
1706
- }
1707
-
1708
- var pendingBufferViews = [];
1709
-
1710
- if ( accessorDef.bufferView !== undefined ) {
1711
-
1712
- pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.bufferView ) );
1713
-
1714
- } else {
1715
-
1716
- pendingBufferViews.push( null );
1717
-
1718
- }
1719
-
1720
- if ( accessorDef.sparse !== undefined ) {
1721
-
1722
- pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.indices.bufferView ) );
1723
- pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.values.bufferView ) );
1724
-
1725
- }
1726
-
1727
- return Promise.all( pendingBufferViews ).then( function ( bufferViews ) {
1728
-
1729
- var bufferView = bufferViews[ 0 ];
1730
-
1731
- var itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ];
1732
- var TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
1733
-
1734
- // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.
1735
- var elementBytes = TypedArray.BYTES_PER_ELEMENT;
1736
- var itemBytes = elementBytes * itemSize;
1737
- var byteOffset = accessorDef.byteOffset || 0;
1738
- var byteStride = accessorDef.bufferView !== undefined ? json.bufferViews[ accessorDef.bufferView ].byteStride : undefined;
1739
- var normalized = accessorDef.normalized === true;
1740
- var array, bufferAttribute;
1741
-
1742
- // The buffer is not interleaved if the stride is the item size in bytes.
1743
- if ( byteStride && byteStride !== itemBytes ) {
1744
-
1745
- // Each "slice" of the buffer, as defined by 'count' elements of 'byteStride' bytes, gets its own InterleavedBuffer
1746
- // This makes sure that IBA.count reflects accessor.count properly
1747
- var ibSlice = Math.floor( byteOffset / byteStride );
1748
- var ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType + ':' + ibSlice + ':' + accessorDef.count;
1749
- var ib = parser.cache.get( ibCacheKey );
1750
-
1751
- if ( ! ib ) {
1752
-
1753
- array = new TypedArray( bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes );
1754
-
1755
- // Integer parameters to IB/IBA are in array elements, not bytes.
1756
- ib = new THREE.InterleavedBuffer( array, byteStride / elementBytes );
1757
-
1758
- parser.cache.add( ibCacheKey, ib );
1759
-
1760
- }
1761
-
1762
- bufferAttribute = new THREE.InterleavedBufferAttribute( ib, itemSize, ( byteOffset % byteStride ) / elementBytes, normalized );
1763
-
1764
- } else {
1765
-
1766
- if ( bufferView === null ) {
1767
-
1768
- array = new TypedArray( accessorDef.count * itemSize );
1769
-
1770
- } else {
1771
-
1772
- array = new TypedArray( bufferView, byteOffset, accessorDef.count * itemSize );
1773
-
1774
- }
1775
-
1776
- bufferAttribute = new THREE.BufferAttribute( array, itemSize, normalized );
1777
-
1778
- }
1779
-
1780
- // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors
1781
- if ( accessorDef.sparse !== undefined ) {
1782
-
1783
- var itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;
1784
- var TypedArrayIndices = WEBGL_COMPONENT_TYPES[ accessorDef.sparse.indices.componentType ];
1785
-
1786
- var byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0;
1787
- var byteOffsetValues = accessorDef.sparse.values.byteOffset || 0;
1788
-
1789
- var sparseIndices = new TypedArrayIndices( bufferViews[ 1 ], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices );
1790
- var sparseValues = new TypedArray( bufferViews[ 2 ], byteOffsetValues, accessorDef.sparse.count * itemSize );
1791
-
1792
- if ( bufferView !== null ) {
1793
-
1794
- // Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes.
1795
- bufferAttribute = new THREE.BufferAttribute( bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized );
1796
-
1797
- }
1798
-
1799
- for ( var i = 0, il = sparseIndices.length; i < il; i ++ ) {
1800
-
1801
- var index = sparseIndices[ i ];
1802
-
1803
- bufferAttribute.setX( index, sparseValues[ i * itemSize ] );
1804
- if ( itemSize >= 2 ) bufferAttribute.setY( index, sparseValues[ i * itemSize + 1 ] );
1805
- if ( itemSize >= 3 ) bufferAttribute.setZ( index, sparseValues[ i * itemSize + 2 ] );
1806
- if ( itemSize >= 4 ) bufferAttribute.setW( index, sparseValues[ i * itemSize + 3 ] );
1807
- if ( itemSize >= 5 ) throw new Error( 'THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.' );
1808
-
1809
- }
1810
-
1811
- }
1812
-
1813
- return bufferAttribute;
1814
-
1815
- } );
1816
-
1817
- };
1818
-
1819
- /**
1820
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
1821
- * @param {number} textureIndex
1822
- * @return {Promise<THREE.Texture>}
1823
- */
1824
- GLTFParser.prototype.loadTexture = function ( textureIndex ) {
1825
-
1826
- var parser = this;
1827
- var json = this.json;
1828
- var options = this.options;
1829
- var textureLoader = this.textureLoader;
1830
-
1831
- var URL = self.URL || self.webkitURL;
1832
-
1833
- var textureDef = json.textures[ textureIndex ];
1834
-
1835
- var textureExtensions = textureDef.extensions || {};
1836
-
1837
- var source;
1838
-
1839
- if ( textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ] ) {
1840
-
1841
- source = json.images[ textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ].source ];
1842
-
1843
- } else {
1844
-
1845
- source = json.images[ textureDef.source ];
1846
-
1847
- }
1848
-
1849
- var sourceURI = source.uri;
1850
- var isObjectURL = false;
1851
-
1852
- if ( source.bufferView !== undefined ) {
1853
-
1854
- // Load binary image data from bufferView, if provided.
1855
-
1856
- sourceURI = parser.getDependency( 'bufferView', source.bufferView ).then( function ( bufferView ) {
1857
-
1858
- isObjectURL = true;
1859
- var blob = new Blob( [ bufferView ], { type: source.mimeType } );
1860
- sourceURI = URL.createObjectURL( blob );
1861
- return sourceURI;
1862
-
1863
- } );
1864
-
1865
- }
1866
-
1867
- return Promise.resolve( sourceURI ).then( function ( sourceURI ) {
1868
-
1869
- // Load Texture resource.
1870
-
1871
- var loader = options.manager.getHandler( sourceURI );
1872
-
1873
- if ( ! loader ) {
1874
-
1875
- loader = textureExtensions[ EXTENSIONS.MSFT_TEXTURE_DDS ]
1876
- ? parser.extensions[ EXTENSIONS.MSFT_TEXTURE_DDS ].ddsLoader
1877
- : textureLoader;
1878
-
1879
- }
1880
-
1881
- return new Promise( function ( resolve, reject ) {
1882
-
1883
- loader.load( resolveURL( sourceURI, options.path ), resolve, undefined, reject );
1884
-
1885
- } );
1886
-
1887
- } ).then( function ( texture ) {
1888
-
1889
- // Clean up resources and configure Texture.
1890
-
1891
- if ( isObjectURL === true ) {
1892
-
1893
- URL.revokeObjectURL( sourceURI );
1894
-
1895
- }
1896
-
1897
- texture.flipY = false;
1898
-
1899
- if ( textureDef.name ) texture.name = textureDef.name;
1900
-
1901
- // Ignore unknown mime types, like DDS files.
1902
- if ( source.mimeType in MIME_TYPE_FORMATS ) {
1903
-
1904
- texture.format = MIME_TYPE_FORMATS[ source.mimeType ];
1905
-
1906
- }
1907
-
1908
- var samplers = json.samplers || {};
1909
- var sampler = samplers[ textureDef.sampler ] || {};
1910
-
1911
- texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || THREE.LinearFilter;
1912
- texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || THREE.LinearMipmapLinearFilter;
1913
- texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || THREE.RepeatWrapping;
1914
- texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || THREE.RepeatWrapping;
1915
-
1916
- return texture;
1917
-
1918
- } );
1919
-
1920
- };
1921
-
1922
- /**
1923
- * Asynchronously assigns a texture to the given material parameters.
1924
- * @param {Object} materialParams
1925
- * @param {string} mapName
1926
- * @param {Object} mapDef
1927
- * @return {Promise}
1928
- */
1929
- GLTFParser.prototype.assignTexture = function ( materialParams, mapName, mapDef ) {
1930
-
1931
- var parser = this;
1932
-
1933
- return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) {
1934
-
1935
- if ( ! texture.isCompressedTexture ) {
1936
-
1937
- switch ( mapName ) {
1938
-
1939
- case 'aoMap':
1940
- case 'emissiveMap':
1941
- case 'metalnessMap':
1942
- case 'normalMap':
1943
- case 'roughnessMap':
1944
- texture.format = THREE.RGBFormat;
1945
- break;
1946
-
1947
- }
1948
-
1949
- }
1950
-
1951
- // Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured
1952
- // However, we will copy UV set 0 to UV set 1 on demand for aoMap
1953
- if ( mapDef.texCoord !== undefined && mapDef.texCoord != 0 && ! ( mapName === 'aoMap' && mapDef.texCoord == 1 ) ) {
1954
-
1955
- console.warn( 'THREE.GLTFLoader: Custom UV set ' + mapDef.texCoord + ' for texture ' + mapName + ' not yet supported.' );
1956
-
1957
- }
1958
-
1959
- if ( parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] ) {
1960
-
1961
- var transform = mapDef.extensions !== undefined ? mapDef.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] : undefined;
1962
-
1963
- if ( transform ) {
1964
-
1965
- texture = parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ].extendTexture( texture, transform );
1966
-
1967
- }
1968
-
1969
- }
1970
-
1971
- materialParams[ mapName ] = texture;
1972
-
1973
- } );
1974
-
1975
- };
1976
-
1977
- /**
1978
- * Assigns final material to a Mesh, Line, or Points instance. The instance
1979
- * already has a material (generated from the glTF material options alone)
1980
- * but reuse of the same glTF material may require multiple threejs materials
1981
- * to accomodate different primitive types, defines, etc. New materials will
1982
- * be created if necessary, and reused from a cache.
1983
- * @param {THREE.Object3D} mesh Mesh, Line, or Points instance.
1984
- */
1985
- GLTFParser.prototype.assignFinalMaterial = function ( mesh ) {
1986
-
1987
- var geometry = mesh.geometry;
1988
- var material = mesh.material;
1989
-
1990
- var useVertexTangents = geometry.attributes.tangent !== undefined;
1991
- var useVertexColors = geometry.attributes.color !== undefined;
1992
- var useFlatShading = geometry.attributes.normal === undefined;
1993
- var useSkinning = mesh.isSkinnedMesh === true;
1994
- var useMorphTargets = Object.keys( geometry.morphAttributes ).length > 0;
1995
- var useMorphNormals = useMorphTargets && geometry.morphAttributes.normal !== undefined;
1996
-
1997
- if ( mesh.isPoints ) {
1998
-
1999
- var cacheKey = 'PointsMaterial:' + material.uuid;
2000
-
2001
- var pointsMaterial = this.cache.get( cacheKey );
2002
-
2003
- if ( ! pointsMaterial ) {
2004
-
2005
- pointsMaterial = new THREE.PointsMaterial();
2006
- THREE.Material.prototype.copy.call( pointsMaterial, material );
2007
- pointsMaterial.color.copy( material.color );
2008
- pointsMaterial.map = material.map;
2009
- pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px
2010
-
2011
- this.cache.add( cacheKey, pointsMaterial );
2012
-
2013
- }
2014
-
2015
- material = pointsMaterial;
2016
-
2017
- } else if ( mesh.isLine ) {
2018
-
2019
- var cacheKey = 'LineBasicMaterial:' + material.uuid;
2020
-
2021
- var lineMaterial = this.cache.get( cacheKey );
2022
-
2023
- if ( ! lineMaterial ) {
2024
-
2025
- lineMaterial = new THREE.LineBasicMaterial();
2026
- THREE.Material.prototype.copy.call( lineMaterial, material );
2027
- lineMaterial.color.copy( material.color );
2028
-
2029
- this.cache.add( cacheKey, lineMaterial );
2030
-
2031
- }
2032
-
2033
- material = lineMaterial;
2034
-
2035
- }
2036
-
2037
- // Clone the material if it will be modified
2038
- if ( useVertexTangents || useVertexColors || useFlatShading || useSkinning || useMorphTargets ) {
2039
-
2040
- var cacheKey = 'ClonedMaterial:' + material.uuid + ':';
2041
-
2042
- if ( material.isGLTFSpecularGlossinessMaterial ) cacheKey += 'specular-glossiness:';
2043
- if ( useSkinning ) cacheKey += 'skinning:';
2044
- if ( useVertexTangents ) cacheKey += 'vertex-tangents:';
2045
- if ( useVertexColors ) cacheKey += 'vertex-colors:';
2046
- if ( useFlatShading ) cacheKey += 'flat-shading:';
2047
- if ( useMorphTargets ) cacheKey += 'morph-targets:';
2048
- if ( useMorphNormals ) cacheKey += 'morph-normals:';
2049
-
2050
- var cachedMaterial = this.cache.get( cacheKey );
2051
-
2052
- if ( ! cachedMaterial ) {
2053
-
2054
- cachedMaterial = material.clone();
2055
-
2056
- if ( useSkinning ) cachedMaterial.skinning = true;
2057
- if ( useVertexTangents ) cachedMaterial.vertexTangents = true;
2058
- if ( useVertexColors ) cachedMaterial.vertexColors = true;
2059
- if ( useFlatShading ) cachedMaterial.flatShading = true;
2060
- if ( useMorphTargets ) cachedMaterial.morphTargets = true;
2061
- if ( useMorphNormals ) cachedMaterial.morphNormals = true;
2062
-
2063
- this.cache.add( cacheKey, cachedMaterial );
2064
-
2065
- }
2066
-
2067
- material = cachedMaterial;
2068
-
2069
- }
2070
-
2071
- // workarounds for mesh and geometry
2072
-
2073
- if ( material.aoMap && geometry.attributes.uv2 === undefined && geometry.attributes.uv !== undefined ) {
2074
-
2075
- geometry.setAttribute( 'uv2', new THREE.BufferAttribute( geometry.attributes.uv.array, 2 ) );
2076
-
2077
- }
2078
-
2079
- // https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
2080
- if ( material.normalScale && ! useVertexTangents ) {
2081
-
2082
- material.normalScale.y = - material.normalScale.y;
2083
-
2084
- }
2085
-
2086
- if ( material.clearcoatNormalScale && ! useVertexTangents ) {
2087
-
2088
- material.clearcoatNormalScale.y = - material.clearcoatNormalScale.y;
2089
-
2090
- }
2091
-
2092
- mesh.material = material;
2093
-
2094
- };
2095
-
2096
- /**
2097
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
2098
- * @param {number} materialIndex
2099
- * @return {Promise<THREE.Material>}
2100
- */
2101
- GLTFParser.prototype.loadMaterial = function ( materialIndex ) {
2102
-
2103
- var parser = this;
2104
- var json = this.json;
2105
- var extensions = this.extensions;
2106
- var materialDef = json.materials[ materialIndex ];
2107
-
2108
- var materialType;
2109
- var materialParams = {};
2110
- var materialExtensions = materialDef.extensions || {};
2111
-
2112
- var pending = [];
2113
-
2114
- if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] ) {
2115
-
2116
- var sgExtension = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ];
2117
- materialType = sgExtension.getMaterialType();
2118
- pending.push( sgExtension.extendParams( materialParams, materialDef, parser ) );
2119
-
2120
- } else if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) {
2121
-
2122
- var kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ];
2123
- materialType = kmuExtension.getMaterialType();
2124
- pending.push( kmuExtension.extendParams( materialParams, materialDef, parser ) );
2125
-
2126
- } else {
2127
-
2128
- // Specification:
2129
- // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material
2130
-
2131
- materialType = THREE.MeshStandardMaterial;
2132
-
2133
- var metallicRoughness = materialDef.pbrMetallicRoughness || {};
2134
-
2135
- materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
2136
- materialParams.opacity = 1.0;
2137
-
2138
- if ( Array.isArray( metallicRoughness.baseColorFactor ) ) {
2139
-
2140
- var array = metallicRoughness.baseColorFactor;
2141
-
2142
- materialParams.color.fromArray( array );
2143
- materialParams.opacity = array[ 3 ];
2144
-
2145
- }
2146
-
2147
- if ( metallicRoughness.baseColorTexture !== undefined ) {
2148
-
2149
- pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture ) );
2150
-
2151
- }
2152
-
2153
- materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0;
2154
- materialParams.roughness = metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0;
2155
-
2156
- if ( metallicRoughness.metallicRoughnessTexture !== undefined ) {
2157
-
2158
- pending.push( parser.assignTexture( materialParams, 'metalnessMap', metallicRoughness.metallicRoughnessTexture ) );
2159
- pending.push( parser.assignTexture( materialParams, 'roughnessMap', metallicRoughness.metallicRoughnessTexture ) );
2160
-
2161
- }
2162
-
2163
- }
2164
-
2165
- if ( materialDef.doubleSided === true ) {
2166
-
2167
- materialParams.side = THREE.DoubleSide;
2168
-
2169
- }
2170
-
2171
- var alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;
2172
-
2173
- if ( alphaMode === ALPHA_MODES.BLEND ) {
2174
-
2175
- materialParams.transparent = true;
2176
-
2177
- // See: https://github.com/mrdoob/three.js/issues/17706
2178
- materialParams.depthWrite = false;
2179
-
2180
- } else {
2181
-
2182
- materialParams.transparent = false;
2183
-
2184
- if ( alphaMode === ALPHA_MODES.MASK ) {
2185
-
2186
- materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;
2187
-
2188
- }
2189
-
2190
- }
2191
-
2192
- if ( materialDef.normalTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
2193
-
2194
- pending.push( parser.assignTexture( materialParams, 'normalMap', materialDef.normalTexture ) );
2195
-
2196
- materialParams.normalScale = new THREE.Vector2( 1, 1 );
2197
-
2198
- if ( materialDef.normalTexture.scale !== undefined ) {
2199
-
2200
- materialParams.normalScale.set( materialDef.normalTexture.scale, materialDef.normalTexture.scale );
2201
-
2202
- }
2203
-
2204
- }
2205
-
2206
- if ( materialDef.occlusionTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
2207
-
2208
- pending.push( parser.assignTexture( materialParams, 'aoMap', materialDef.occlusionTexture ) );
2209
-
2210
- if ( materialDef.occlusionTexture.strength !== undefined ) {
2211
-
2212
- materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;
2213
-
2214
- }
2215
-
2216
- }
2217
-
2218
- if ( materialDef.emissiveFactor !== undefined && materialType !== THREE.MeshBasicMaterial ) {
2219
-
2220
- materialParams.emissive = new THREE.Color().fromArray( materialDef.emissiveFactor );
2221
-
2222
- }
2223
-
2224
- if ( materialDef.emissiveTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
2225
-
2226
- pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture ) );
2227
-
2228
- }
2229
-
2230
- if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_CLEARCOAT ] ) {
2231
-
2232
- var clearcoatExtension = extensions[ EXTENSIONS.KHR_MATERIALS_CLEARCOAT ];
2233
- materialType = clearcoatExtension.getMaterialType();
2234
- pending.push( clearcoatExtension.extendParams( materialParams, { extensions: materialExtensions }, parser ) );
2235
-
2236
- }
2237
-
2238
- return Promise.all( pending ).then( function () {
2239
-
2240
- var material;
2241
-
2242
- if ( materialType === GLTFMeshStandardSGMaterial ) {
2243
-
2244
- material = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ].createMaterial( materialParams );
2245
-
2246
- } else {
2247
-
2248
- material = new materialType( materialParams );
2249
-
2250
- }
2251
-
2252
- if ( materialDef.name ) material.name = materialDef.name;
2253
-
2254
- // baseColorTexture, emissiveTexture, and specularGlossinessTexture use sRGB encoding.
2255
- if ( material.map ) material.map.encoding = THREE.sRGBEncoding;
2256
- if ( material.emissiveMap ) material.emissiveMap.encoding = THREE.sRGBEncoding;
2257
-
2258
- assignExtrasToUserData( material, materialDef );
2259
-
2260
- if ( materialDef.extensions ) addUnknownExtensionsToUserData( extensions, material, materialDef );
2261
-
2262
- return material;
2263
-
2264
- } );
2265
-
2266
- };
2267
-
2268
- /**
2269
- * @param {THREE.BufferGeometry} geometry
2270
- * @param {GLTF.Primitive} primitiveDef
2271
- * @param {GLTFParser} parser
2272
- */
2273
- function computeBounds( geometry, primitiveDef, parser ) {
2274
-
2275
- var attributes = primitiveDef.attributes;
2276
-
2277
- var box = new THREE.Box3();
2278
-
2279
- if ( attributes.POSITION !== undefined ) {
2280
-
2281
- var accessor = parser.json.accessors[ attributes.POSITION ];
2282
-
2283
- var min = accessor.min;
2284
- var max = accessor.max;
2285
-
2286
- // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
2287
-
2288
- if ( min !== undefined && max !== undefined ) {
2289
-
2290
- box.set(
2291
- new THREE.Vector3( min[ 0 ], min[ 1 ], min[ 2 ] ),
2292
- new THREE.Vector3( max[ 0 ], max[ 1 ], max[ 2 ] ) );
2293
-
2294
- } else {
2295
-
2296
- console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' );
2297
-
2298
- return;
2299
-
2300
- }
2301
-
2302
- } else {
2303
-
2304
- return;
2305
-
2306
- }
2307
-
2308
- var targets = primitiveDef.targets;
2309
-
2310
- if ( targets !== undefined ) {
2311
-
2312
- var maxDisplacement = new THREE.Vector3();
2313
- var vector = new THREE.Vector3();
2314
-
2315
- for ( var i = 0, il = targets.length; i < il; i ++ ) {
2316
-
2317
- var target = targets[ i ];
2318
-
2319
- if ( target.POSITION !== undefined ) {
2320
-
2321
- var accessor = parser.json.accessors[ target.POSITION ];
2322
- var min = accessor.min;
2323
- var max = accessor.max;
2324
-
2325
- // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
2326
-
2327
- if ( min !== undefined && max !== undefined ) {
2328
-
2329
- // we need to get max of absolute components because target weight is [-1,1]
2330
- vector.setX( Math.max( Math.abs( min[ 0 ] ), Math.abs( max[ 0 ] ) ) );
2331
- vector.setY( Math.max( Math.abs( min[ 1 ] ), Math.abs( max[ 1 ] ) ) );
2332
- vector.setZ( Math.max( Math.abs( min[ 2 ] ), Math.abs( max[ 2 ] ) ) );
2333
-
2334
- // Note: this assumes that the sum of all weights is at most 1. This isn't quite correct - it's more conservative
2335
- // to assume that each target can have a max weight of 1. However, for some use cases - notably, when morph targets
2336
- // are used to implement key-frame animations and as such only two are active at a time - this results in very large
2337
- // boxes. So for now we make a box that's sometimes a touch too small but is hopefully mostly of reasonable size.
2338
- maxDisplacement.max( vector );
2339
-
2340
- } else {
2341
-
2342
- console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' );
2343
-
2344
- }
2345
-
2346
- }
2347
-
2348
- }
2349
-
2350
- // As per comment above this box isn't conservative, but has a reasonable size for a very large number of morph targets.
2351
- box.expandByVector( maxDisplacement );
2352
-
2353
- }
2354
-
2355
- geometry.boundingBox = box;
2356
-
2357
- var sphere = new THREE.Sphere();
2358
-
2359
- box.getCenter( sphere.center );
2360
- sphere.radius = box.min.distanceTo( box.max ) / 2;
2361
-
2362
- geometry.boundingSphere = sphere;
2363
-
2364
- }
2365
-
2366
- /**
2367
- * @param {THREE.BufferGeometry} geometry
2368
- * @param {GLTF.Primitive} primitiveDef
2369
- * @param {GLTFParser} parser
2370
- * @return {Promise<THREE.BufferGeometry>}
2371
- */
2372
- function addPrimitiveAttributes( geometry, primitiveDef, parser ) {
2373
-
2374
- var attributes = primitiveDef.attributes;
2375
-
2376
- var pending = [];
2377
-
2378
- function assignAttributeAccessor( accessorIndex, attributeName ) {
2379
-
2380
- return parser.getDependency( 'accessor', accessorIndex )
2381
- .then( function ( accessor ) {
2382
-
2383
- geometry.setAttribute( attributeName, accessor );
2384
-
2385
- } );
2386
-
2387
- }
2388
-
2389
- for ( var gltfAttributeName in attributes ) {
2390
-
2391
- var threeAttributeName = ATTRIBUTES[ gltfAttributeName ] || gltfAttributeName.toLowerCase();
2392
-
2393
- // Skip attributes already provided by e.g. Draco extension.
2394
- if ( threeAttributeName in geometry.attributes ) continue;
2395
-
2396
- pending.push( assignAttributeAccessor( attributes[ gltfAttributeName ], threeAttributeName ) );
2397
-
2398
- }
2399
-
2400
- if ( primitiveDef.indices !== undefined && ! geometry.index ) {
2401
-
2402
- var accessor = parser.getDependency( 'accessor', primitiveDef.indices ).then( function ( accessor ) {
2403
-
2404
- geometry.setIndex( accessor );
2405
-
2406
- } );
2407
-
2408
- pending.push( accessor );
2409
-
2410
- }
2411
-
2412
- assignExtrasToUserData( geometry, primitiveDef );
2413
-
2414
- computeBounds( geometry, primitiveDef, parser );
2415
-
2416
- return Promise.all( pending ).then( function () {
2417
-
2418
- return primitiveDef.targets !== undefined
2419
- ? addMorphTargets( geometry, primitiveDef.targets, parser )
2420
- : geometry;
2421
-
2422
- } );
2423
-
2424
- }
2425
-
2426
- /**
2427
- * @param {THREE.BufferGeometry} geometry
2428
- * @param {Number} drawMode
2429
- * @return {THREE.BufferGeometry}
2430
- */
2431
- function toTrianglesDrawMode( geometry, drawMode ) {
2432
-
2433
- var index = geometry.getIndex();
2434
-
2435
- // generate index if not present
2436
-
2437
- if ( index === null ) {
2438
-
2439
- var indices = [];
2440
-
2441
- var position = geometry.getAttribute( 'position' );
2442
-
2443
- if ( position !== undefined ) {
2444
-
2445
- for ( var i = 0; i < position.count; i ++ ) {
2446
-
2447
- indices.push( i );
2448
-
2449
- }
2450
-
2451
- geometry.setIndex( indices );
2452
- index = geometry.getIndex();
2453
-
2454
- } else {
2455
-
2456
- console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' );
2457
- return geometry;
2458
-
2459
- }
2460
-
2461
- }
2462
-
2463
- //
2464
-
2465
- var numberOfTriangles = index.count - 2;
2466
- var newIndices = [];
2467
-
2468
- if ( drawMode === THREE.TriangleFanDrawMode ) {
2469
-
2470
- // gl.TRIANGLE_FAN
2471
-
2472
- for ( var i = 1; i <= numberOfTriangles; i ++ ) {
2473
-
2474
- newIndices.push( index.getX( 0 ) );
2475
- newIndices.push( index.getX( i ) );
2476
- newIndices.push( index.getX( i + 1 ) );
2477
-
2478
- }
2479
-
2480
- } else {
2481
-
2482
- // gl.TRIANGLE_STRIP
2483
-
2484
- for ( var i = 0; i < numberOfTriangles; i ++ ) {
2485
-
2486
- if ( i % 2 === 0 ) {
2487
-
2488
- newIndices.push( index.getX( i ) );
2489
- newIndices.push( index.getX( i + 1 ) );
2490
- newIndices.push( index.getX( i + 2 ) );
2491
-
2492
-
2493
- } else {
2494
-
2495
- newIndices.push( index.getX( i + 2 ) );
2496
- newIndices.push( index.getX( i + 1 ) );
2497
- newIndices.push( index.getX( i ) );
2498
-
2499
- }
2500
-
2501
- }
2502
-
2503
- }
2504
-
2505
- if ( ( newIndices.length / 3 ) !== numberOfTriangles ) {
2506
-
2507
- console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' );
2508
-
2509
- }
2510
-
2511
- // build final geometry
2512
-
2513
- var newGeometry = geometry.clone();
2514
- newGeometry.setIndex( newIndices );
2515
-
2516
- return newGeometry;
2517
-
2518
- }
2519
-
2520
- /**
2521
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
2522
- *
2523
- * Creates BufferGeometries from primitives.
2524
- *
2525
- * @param {Array<GLTF.Primitive>} primitives
2526
- * @return {Promise<Array<THREE.BufferGeometry>>}
2527
- */
2528
- GLTFParser.prototype.loadGeometries = function ( primitives ) {
2529
-
2530
- var parser = this;
2531
- var extensions = this.extensions;
2532
- var cache = this.primitiveCache;
2533
-
2534
- function createDracoPrimitive( primitive ) {
2535
-
2536
- return extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ]
2537
- .decodePrimitive( primitive, parser )
2538
- .then( function ( geometry ) {
2539
-
2540
- return addPrimitiveAttributes( geometry, primitive, parser );
2541
-
2542
- } );
2543
-
2544
- }
2545
-
2546
- var pending = [];
2547
-
2548
- for ( var i = 0, il = primitives.length; i < il; i ++ ) {
2549
-
2550
- var primitive = primitives[ i ];
2551
- var cacheKey = createPrimitiveKey( primitive );
2552
-
2553
- // See if we've already created this geometry
2554
- var cached = cache[ cacheKey ];
2555
-
2556
- if ( cached ) {
2557
-
2558
- // Use the cached geometry if it exists
2559
- pending.push( cached.promise );
2560
-
2561
- } else {
2562
-
2563
- var geometryPromise;
2564
-
2565
- if ( primitive.extensions && primitive.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] ) {
2566
-
2567
- // Use DRACO geometry if available
2568
- geometryPromise = createDracoPrimitive( primitive );
2569
-
2570
- } else {
2571
-
2572
- // Otherwise create a new geometry
2573
- geometryPromise = addPrimitiveAttributes( new THREE.BufferGeometry(), primitive, parser );
2574
-
2575
- }
2576
-
2577
- // Cache this geometry
2578
- cache[ cacheKey ] = { primitive: primitive, promise: geometryPromise };
2579
-
2580
- pending.push( geometryPromise );
2581
-
2582
- }
2583
-
2584
- }
2585
-
2586
- return Promise.all( pending );
2587
-
2588
- };
2589
-
2590
- /**
2591
- * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
2592
- * @param {number} meshIndex
2593
- * @return {Promise<THREE.Group|THREE.Mesh|THREE.SkinnedMesh>}
2594
- */
2595
- GLTFParser.prototype.loadMesh = function ( meshIndex ) {
2596
-
2597
- var parser = this;
2598
- var json = this.json;
2599
-
2600
- var meshDef = json.meshes[ meshIndex ];
2601
- var primitives = meshDef.primitives;
2602
-
2603
- var pending = [];
2604
-
2605
- for ( var i = 0, il = primitives.length; i < il; i ++ ) {
2606
-
2607
- var material = primitives[ i ].material === undefined
2608
- ? createDefaultMaterial( this.cache )
2609
- : this.getDependency( 'material', primitives[ i ].material );
2610
-
2611
- pending.push( material );
2612
-
2613
- }
2614
-
2615
- pending.push( parser.loadGeometries( primitives ) );
2616
-
2617
- return Promise.all( pending ).then( function ( results ) {
2618
-
2619
- var materials = results.slice( 0, results.length - 1 );
2620
- var geometries = results[ results.length - 1 ];
2621
-
2622
- var meshes = [];
2623
-
2624
- for ( var i = 0, il = geometries.length; i < il; i ++ ) {
2625
-
2626
- var geometry = geometries[ i ];
2627
- var primitive = primitives[ i ];
2628
-
2629
- // 1. create Mesh
2630
-
2631
- var mesh;
2632
-
2633
- var material = materials[ i ];
2634
-
2635
- if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES ||
2636
- primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ||
2637
- primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ||
2638
- primitive.mode === undefined ) {
2639
-
2640
- // .isSkinnedMesh isn't in glTF spec. See .markDefs()
2641
- mesh = meshDef.isSkinnedMesh === true
2642
- ? new THREE.SkinnedMesh( geometry, material )
2643
- : new THREE.Mesh( geometry, material );
2644
-
2645
- if ( mesh.isSkinnedMesh === true && ! mesh.geometry.attributes.skinWeight.normalized ) {
2646
-
2647
- // we normalize floating point skin weight array to fix malformed assets (see #15319)
2648
- // it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs
2649
- mesh.normalizeSkinWeights();
2650
-
2651
- }
2652
-
2653
- if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ) {
2654
-
2655
- mesh.geometry = toTrianglesDrawMode( mesh.geometry, THREE.TriangleStripDrawMode );
2656
-
2657
- } else if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) {
2658
-
2659
- mesh.geometry = toTrianglesDrawMode( mesh.geometry, THREE.TriangleFanDrawMode );
2660
-
2661
- }
2662
-
2663
- } else if ( primitive.mode === WEBGL_CONSTANTS.LINES ) {
2664
-
2665
- mesh = new THREE.LineSegments( geometry, material );
2666
-
2667
- } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_STRIP ) {
2668
-
2669
- mesh = new THREE.Line( geometry, material );
2670
-
2671
- } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_LOOP ) {
2672
-
2673
- mesh = new THREE.LineLoop( geometry, material );
2674
-
2675
- } else if ( primitive.mode === WEBGL_CONSTANTS.POINTS ) {
2676
-
2677
- mesh = new THREE.Points( geometry, material );
2678
-
2679
- } else {
2680
-
2681
- throw new Error( 'THREE.GLTFLoader: Primitive mode unsupported: ' + primitive.mode );
2682
-
2683
- }
2684
-
2685
- if ( Object.keys( mesh.geometry.morphAttributes ).length > 0 ) {
2686
-
2687
- updateMorphTargets( mesh, meshDef );
2688
-
2689
- }
2690
-
2691
- mesh.name = meshDef.name || ( 'mesh_' + meshIndex );
2692
-
2693
- if ( geometries.length > 1 ) mesh.name += '_' + i;
2694
-
2695
- assignExtrasToUserData( mesh, meshDef );
2696
-
2697
- parser.assignFinalMaterial( mesh );
2698
-
2699
- meshes.push( mesh );
2700
-
2701
- }
2702
-
2703
- if ( meshes.length === 1 ) {
2704
-
2705
- return meshes[ 0 ];
2706
-
2707
- }
2708
-
2709
- var group = new THREE.Group();
2710
-
2711
- for ( var i = 0, il = meshes.length; i < il; i ++ ) {
2712
-
2713
- group.add( meshes[ i ] );
2714
-
2715
- }
2716
-
2717
- return group;
2718
-
2719
- } );
2720
-
2721
- };
2722
-
2723
- /**
2724
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
2725
- * @param {number} cameraIndex
2726
- * @return {Promise<THREE.Camera>}
2727
- */
2728
- GLTFParser.prototype.loadCamera = function ( cameraIndex ) {
2729
-
2730
- var camera;
2731
- var cameraDef = this.json.cameras[ cameraIndex ];
2732
- var params = cameraDef[ cameraDef.type ];
2733
-
2734
- if ( ! params ) {
2735
-
2736
- console.warn( 'THREE.GLTFLoader: Missing camera parameters.' );
2737
- return;
2738
-
2739
- }
2740
-
2741
- if ( cameraDef.type === 'perspective' ) {
2742
-
2743
- camera = new THREE.PerspectiveCamera( THREE.MathUtils.radToDeg( params.yfov ), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6 );
2744
-
2745
- } else if ( cameraDef.type === 'orthographic' ) {
2746
-
2747
- camera = new THREE.OrthographicCamera( params.xmag / - 2, params.xmag / 2, params.ymag / 2, params.ymag / - 2, params.znear, params.zfar );
2748
-
2749
- }
2750
-
2751
- if ( cameraDef.name ) camera.name = cameraDef.name;
2752
-
2753
- assignExtrasToUserData( camera, cameraDef );
2754
-
2755
- return Promise.resolve( camera );
2756
-
2757
- };
2758
-
2759
- /**
2760
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
2761
- * @param {number} skinIndex
2762
- * @return {Promise<Object>}
2763
- */
2764
- GLTFParser.prototype.loadSkin = function ( skinIndex ) {
2765
-
2766
- var skinDef = this.json.skins[ skinIndex ];
2767
-
2768
- var skinEntry = { joints: skinDef.joints };
2769
-
2770
- if ( skinDef.inverseBindMatrices === undefined ) {
2771
-
2772
- return Promise.resolve( skinEntry );
2773
-
2774
- }
2775
-
2776
- return this.getDependency( 'accessor', skinDef.inverseBindMatrices ).then( function ( accessor ) {
2777
-
2778
- skinEntry.inverseBindMatrices = accessor;
2779
-
2780
- return skinEntry;
2781
-
2782
- } );
2783
-
2784
- };
2785
-
2786
- /**
2787
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
2788
- * @param {number} animationIndex
2789
- * @return {Promise<THREE.AnimationClip>}
2790
- */
2791
- GLTFParser.prototype.loadAnimation = function ( animationIndex ) {
2792
-
2793
- var json = this.json;
2794
-
2795
- var animationDef = json.animations[ animationIndex ];
2796
-
2797
- var pendingNodes = [];
2798
- var pendingInputAccessors = [];
2799
- var pendingOutputAccessors = [];
2800
- var pendingSamplers = [];
2801
- var pendingTargets = [];
2802
-
2803
- for ( var i = 0, il = animationDef.channels.length; i < il; i ++ ) {
2804
-
2805
- var channel = animationDef.channels[ i ];
2806
- var sampler = animationDef.samplers[ channel.sampler ];
2807
- var target = channel.target;
2808
- var name = target.node !== undefined ? target.node : target.id; // NOTE: target.id is deprecated.
2809
- var input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input;
2810
- var output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output;
2811
-
2812
- pendingNodes.push( this.getDependency( 'node', name ) );
2813
- pendingInputAccessors.push( this.getDependency( 'accessor', input ) );
2814
- pendingOutputAccessors.push( this.getDependency( 'accessor', output ) );
2815
- pendingSamplers.push( sampler );
2816
- pendingTargets.push( target );
2817
-
2818
- }
2819
-
2820
- return Promise.all( [
2821
-
2822
- Promise.all( pendingNodes ),
2823
- Promise.all( pendingInputAccessors ),
2824
- Promise.all( pendingOutputAccessors ),
2825
- Promise.all( pendingSamplers ),
2826
- Promise.all( pendingTargets )
2827
-
2828
- ] ).then( function ( dependencies ) {
2829
-
2830
- var nodes = dependencies[ 0 ];
2831
- var inputAccessors = dependencies[ 1 ];
2832
- var outputAccessors = dependencies[ 2 ];
2833
- var samplers = dependencies[ 3 ];
2834
- var targets = dependencies[ 4 ];
2835
-
2836
- var tracks = [];
2837
-
2838
- for ( var i = 0, il = nodes.length; i < il; i ++ ) {
2839
-
2840
- var node = nodes[ i ];
2841
- var inputAccessor = inputAccessors[ i ];
2842
- var outputAccessor = outputAccessors[ i ];
2843
- var sampler = samplers[ i ];
2844
- var target = targets[ i ];
2845
-
2846
- if ( node === undefined ) continue;
2847
-
2848
- node.updateMatrix();
2849
- node.matrixAutoUpdate = true;
2850
-
2851
- var TypedKeyframeTrack;
2852
-
2853
- switch ( PATH_PROPERTIES[ target.path ] ) {
2854
-
2855
- case PATH_PROPERTIES.weights:
2856
-
2857
- TypedKeyframeTrack = THREE.NumberKeyframeTrack;
2858
- break;
2859
-
2860
- case PATH_PROPERTIES.rotation:
2861
-
2862
- TypedKeyframeTrack = THREE.QuaternionKeyframeTrack;
2863
- break;
2864
-
2865
- case PATH_PROPERTIES.position:
2866
- case PATH_PROPERTIES.scale:
2867
- default:
2868
-
2869
- TypedKeyframeTrack = THREE.VectorKeyframeTrack;
2870
- break;
2871
-
2872
- }
2873
-
2874
- var targetName = node.name ? node.name : node.uuid;
2875
-
2876
- var interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : THREE.InterpolateLinear;
2877
-
2878
- var targetNames = [];
2879
-
2880
- if ( PATH_PROPERTIES[ target.path ] === PATH_PROPERTIES.weights ) {
2881
-
2882
- // Node may be a THREE.Group (glTF mesh with several primitives) or a THREE.Mesh.
2883
- node.traverse( function ( object ) {
2884
-
2885
- if ( object.isMesh === true && object.morphTargetInfluences ) {
2886
-
2887
- targetNames.push( object.name ? object.name : object.uuid );
2888
-
2889
- }
2890
-
2891
- } );
2892
-
2893
- } else {
2894
-
2895
- targetNames.push( targetName );
2896
-
2897
- }
2898
-
2899
- var outputArray = outputAccessor.array;
2900
-
2901
- if ( outputAccessor.normalized ) {
2902
-
2903
- var scale;
2904
-
2905
- if ( outputArray.constructor === Int8Array ) {
2906
-
2907
- scale = 1 / 127;
2908
-
2909
- } else if ( outputArray.constructor === Uint8Array ) {
2910
-
2911
- scale = 1 / 255;
2912
-
2913
- } else if ( outputArray.constructor == Int16Array ) {
2914
-
2915
- scale = 1 / 32767;
2916
-
2917
- } else if ( outputArray.constructor === Uint16Array ) {
2918
-
2919
- scale = 1 / 65535;
2920
-
2921
- } else {
2922
-
2923
- throw new Error( 'THREE.GLTFLoader: Unsupported output accessor component type.' );
2924
-
2925
- }
2926
-
2927
- var scaled = new Float32Array( outputArray.length );
2928
-
2929
- for ( var j = 0, jl = outputArray.length; j < jl; j ++ ) {
2930
-
2931
- scaled[ j ] = outputArray[ j ] * scale;
2932
-
2933
- }
2934
-
2935
- outputArray = scaled;
2936
-
2937
- }
2938
-
2939
- for ( var j = 0, jl = targetNames.length; j < jl; j ++ ) {
2940
-
2941
- var track = new TypedKeyframeTrack(
2942
- targetNames[ j ] + '.' + PATH_PROPERTIES[ target.path ],
2943
- inputAccessor.array,
2944
- outputArray,
2945
- interpolation
2946
- );
2947
-
2948
- // Override interpolation with custom factory method.
2949
- if ( sampler.interpolation === 'CUBICSPLINE' ) {
2950
-
2951
- track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) {
2952
-
2953
- // A CUBICSPLINE keyframe in glTF has three output values for each input value,
2954
- // representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
2955
- // must be divided by three to get the interpolant's sampleSize argument.
2956
-
2957
- return new GLTFCubicSplineInterpolant( this.times, this.values, this.getValueSize() / 3, result );
2958
-
2959
- };
2960
-
2961
- // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
2962
- track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
2963
-
2964
- }
2965
-
2966
- tracks.push( track );
2967
-
2968
- }
2969
-
2970
- }
2971
-
2972
- var name = animationDef.name ? animationDef.name : 'animation_' + animationIndex;
2973
-
2974
- return new THREE.AnimationClip( name, undefined, tracks );
2975
-
2976
- } );
2977
-
2978
- };
2979
-
2980
- /**
2981
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
2982
- * @param {number} nodeIndex
2983
- * @return {Promise<THREE.Object3D>}
2984
- */
2985
- GLTFParser.prototype.loadNode = function ( nodeIndex ) {
2986
-
2987
- var json = this.json;
2988
- var extensions = this.extensions;
2989
- var parser = this;
2990
-
2991
- var meshReferences = json.meshReferences;
2992
- var meshUses = json.meshUses;
2993
-
2994
- var nodeDef = json.nodes[ nodeIndex ];
2995
-
2996
- return ( function () {
2997
-
2998
- var pending = [];
2999
-
3000
- if ( nodeDef.mesh !== undefined ) {
3001
-
3002
- pending.push( parser.getDependency( 'mesh', nodeDef.mesh ).then( function ( mesh ) {
3003
-
3004
- var node;
3005
-
3006
- if ( meshReferences[ nodeDef.mesh ] > 1 ) {
3007
-
3008
- var instanceNum = meshUses[ nodeDef.mesh ] ++;
3009
-
3010
- node = mesh.clone();
3011
- node.name += '_instance_' + instanceNum;
3012
-
3013
- } else {
3014
-
3015
- node = mesh;
3016
-
3017
- }
3018
-
3019
- // if weights are provided on the node, override weights on the mesh.
3020
- if ( nodeDef.weights !== undefined ) {
3021
-
3022
- node.traverse( function ( o ) {
3023
-
3024
- if ( ! o.isMesh ) return;
3025
-
3026
- for ( var i = 0, il = nodeDef.weights.length; i < il; i ++ ) {
3027
-
3028
- o.morphTargetInfluences[ i ] = nodeDef.weights[ i ];
3029
-
3030
- }
3031
-
3032
- } );
3033
-
3034
- }
3035
-
3036
- return node;
3037
-
3038
- } ) );
3039
-
3040
- }
3041
-
3042
- if ( nodeDef.camera !== undefined ) {
3043
-
3044
- pending.push( parser.getDependency( 'camera', nodeDef.camera ) );
3045
-
3046
- }
3047
-
3048
- if ( nodeDef.extensions
3049
- && nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ]
3050
- && nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].light !== undefined ) {
3051
-
3052
- pending.push( parser.getDependency( 'light', nodeDef.extensions[ EXTENSIONS.KHR_LIGHTS_PUNCTUAL ].light ) );
3053
-
3054
- }
3055
-
3056
- return Promise.all( pending );
3057
-
3058
- }() ).then( function ( objects ) {
3059
-
3060
- var node;
3061
-
3062
- // .isBone isn't in glTF spec. See .markDefs
3063
- if ( nodeDef.isBone === true ) {
3064
-
3065
- node = new THREE.Bone();
3066
-
3067
- } else if ( objects.length > 1 ) {
3068
-
3069
- node = new THREE.Group();
3070
-
3071
- } else if ( objects.length === 1 ) {
3072
-
3073
- node = objects[ 0 ];
3074
-
3075
- } else {
3076
-
3077
- node = new THREE.Object3D();
3078
-
3079
- }
3080
-
3081
- if ( node !== objects[ 0 ] ) {
3082
-
3083
- for ( var i = 0, il = objects.length; i < il; i ++ ) {
3084
-
3085
- node.add( objects[ i ] );
3086
-
3087
- }
3088
-
3089
- }
3090
-
3091
- if ( nodeDef.name ) {
3092
-
3093
- node.userData.name = nodeDef.name;
3094
- node.name = THREE.PropertyBinding.sanitizeNodeName( nodeDef.name );
3095
-
3096
- }
3097
-
3098
- assignExtrasToUserData( node, nodeDef );
3099
-
3100
- if ( nodeDef.extensions ) addUnknownExtensionsToUserData( extensions, node, nodeDef );
3101
-
3102
- if ( nodeDef.matrix !== undefined ) {
3103
-
3104
- var matrix = new THREE.Matrix4();
3105
- matrix.fromArray( nodeDef.matrix );
3106
- node.applyMatrix4( matrix );
3107
-
3108
- } else {
3109
-
3110
- if ( nodeDef.translation !== undefined ) {
3111
-
3112
- node.position.fromArray( nodeDef.translation );
3113
-
3114
- }
3115
-
3116
- if ( nodeDef.rotation !== undefined ) {
3117
-
3118
- node.quaternion.fromArray( nodeDef.rotation );
3119
-
3120
- }
3121
-
3122
- if ( nodeDef.scale !== undefined ) {
3123
-
3124
- node.scale.fromArray( nodeDef.scale );
3125
-
3126
- }
3127
-
3128
- }
3129
-
3130
- return node;
3131
-
3132
- } );
3133
-
3134
- };
3135
-
3136
- /**
3137
- * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
3138
- * @param {number} sceneIndex
3139
- * @return {Promise<THREE.Group>}
3140
- */
3141
- GLTFParser.prototype.loadScene = function () {
3142
-
3143
- // scene node hierachy builder
3144
-
3145
- function buildNodeHierachy( nodeId, parentObject, json, parser ) {
3146
-
3147
- var nodeDef = json.nodes[ nodeId ];
3148
-
3149
- return parser.getDependency( 'node', nodeId ).then( function ( node ) {
3150
-
3151
- if ( nodeDef.skin === undefined ) return node;
3152
-
3153
- // build skeleton here as well
3154
-
3155
- var skinEntry;
3156
-
3157
- return parser.getDependency( 'skin', nodeDef.skin ).then( function ( skin ) {
3158
-
3159
- skinEntry = skin;
3160
-
3161
- var pendingJoints = [];
3162
-
3163
- for ( var i = 0, il = skinEntry.joints.length; i < il; i ++ ) {
3164
-
3165
- pendingJoints.push( parser.getDependency( 'node', skinEntry.joints[ i ] ) );
3166
-
3167
- }
3168
-
3169
- return Promise.all( pendingJoints );
3170
-
3171
- } ).then( function ( jointNodes ) {
3172
-
3173
- node.traverse( function ( mesh ) {
3174
-
3175
- if ( ! mesh.isMesh ) return;
3176
-
3177
- var bones = [];
3178
- var boneInverses = [];
3179
-
3180
- for ( var j = 0, jl = jointNodes.length; j < jl; j ++ ) {
3181
-
3182
- var jointNode = jointNodes[ j ];
3183
-
3184
- if ( jointNode ) {
3185
-
3186
- bones.push( jointNode );
3187
-
3188
- var mat = new THREE.Matrix4();
3189
-
3190
- if ( skinEntry.inverseBindMatrices !== undefined ) {
3191
-
3192
- mat.fromArray( skinEntry.inverseBindMatrices.array, j * 16 );
3193
-
3194
- }
3195
-
3196
- boneInverses.push( mat );
3197
-
3198
- } else {
3199
-
3200
- console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[ j ] );
3201
-
3202
- }
3203
-
3204
- }
3205
-
3206
- mesh.bind( new THREE.Skeleton( bones, boneInverses ), mesh.matrixWorld );
3207
-
3208
- } );
3209
-
3210
- return node;
3211
-
3212
- } );
3213
-
3214
- } ).then( function ( node ) {
3215
-
3216
- // build node hierachy
3217
-
3218
- parentObject.add( node );
3219
-
3220
- var pending = [];
3221
-
3222
- if ( nodeDef.children ) {
3223
-
3224
- var children = nodeDef.children;
3225
-
3226
- for ( var i = 0, il = children.length; i < il; i ++ ) {
3227
-
3228
- var child = children[ i ];
3229
- pending.push( buildNodeHierachy( child, node, json, parser ) );
3230
-
3231
- }
3232
-
3233
- }
3234
-
3235
- return Promise.all( pending );
3236
-
3237
- } );
3238
-
3239
- }
3240
-
3241
- return function loadScene( sceneIndex ) {
3242
-
3243
- var json = this.json;
3244
- var extensions = this.extensions;
3245
- var sceneDef = this.json.scenes[ sceneIndex ];
3246
- var parser = this;
3247
-
3248
- // Loader returns Group, not Scene.
3249
- // See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172
3250
- var scene = new THREE.Group();
3251
- if ( sceneDef.name ) scene.name = sceneDef.name;
3252
-
3253
- assignExtrasToUserData( scene, sceneDef );
3254
-
3255
- if ( sceneDef.extensions ) addUnknownExtensionsToUserData( extensions, scene, sceneDef );
3256
-
3257
- var nodeIds = sceneDef.nodes || [];
3258
-
3259
- var pending = [];
3260
-
3261
- for ( var i = 0, il = nodeIds.length; i < il; i ++ ) {
3262
-
3263
- pending.push( buildNodeHierachy( nodeIds[ i ], scene, json, parser ) );
3264
-
3265
- }
3266
-
3267
- return Promise.all( pending ).then( function () {
3268
-
3269
- return scene;
3270
-
3271
- } );
3272
-
3273
- };
3274
-
3275
- }();
3276
-
3277
- return GLTFLoader;
3278
-
3279
- } )();