@prestyj/cli 5.26.0 → 5.28.0

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 (729) hide show
  1. package/README.md +9 -7
  2. package/assets/motion/BRAG-LICENSE +21 -0
  3. package/assets/motion/HYPERFRAMES-LICENSE +190 -0
  4. package/assets/motion/THIRD-PARTY.md +57 -0
  5. package/assets/motion/assets/music/README.md +20 -0
  6. package/assets/motion/assets/music/cues/happy-beats-business-moves-vol-1-by-ende-dot-app.music-cues.json +3846 -0
  7. package/assets/motion/assets/music/cues/happy-beats-business-moves-vol-1-by-ende-dot-app.music-cues.md +35 -0
  8. package/assets/motion/assets/music/cues/happy-beats-business-moves-vol-10-by-ende-dot-app.music-cues.json +1826 -0
  9. package/assets/motion/assets/music/cues/happy-beats-business-moves-vol-10-by-ende-dot-app.music-cues.md +35 -0
  10. package/assets/motion/assets/music/cues/happy-beats-business-moves-vol-11-by-ende-dot-app.music-cues.json +2266 -0
  11. package/assets/motion/assets/music/cues/happy-beats-business-moves-vol-11-by-ende-dot-app.music-cues.md +35 -0
  12. package/assets/motion/assets/music/cues/happy-beats-business-moves-vol-12-by-ende-dot-app.music-cues.json +2806 -0
  13. package/assets/motion/assets/music/cues/happy-beats-business-moves-vol-12-by-ende-dot-app.music-cues.md +35 -0
  14. package/assets/motion/assets/music/cues/happy-beats-business-moves-vol-9-by-ende-dot-app.music-cues.json +2796 -0
  15. package/assets/motion/assets/music/cues/happy-beats-business-moves-vol-9-by-ende-dot-app.music-cues.md +35 -0
  16. package/assets/motion/assets/music/happy-beats-business-moves-vol-1-by-ende-dot-app.mp3 +0 -0
  17. package/assets/motion/assets/music/happy-beats-business-moves-vol-10-by-ende-dot-app.mp3 +0 -0
  18. package/assets/motion/assets/music/happy-beats-business-moves-vol-11-by-ende-dot-app.mp3 +0 -0
  19. package/assets/motion/assets/music/happy-beats-business-moves-vol-12-by-ende-dot-app.mp3 +0 -0
  20. package/assets/motion/assets/music/happy-beats-business-moves-vol-9-by-ende-dot-app.mp3 +0 -0
  21. package/assets/motion/assets/sfx/casino/card-fan-1.ogg +0 -0
  22. package/assets/motion/assets/sfx/casino/card-fan-2.ogg +0 -0
  23. package/assets/motion/assets/sfx/casino/card-place-1.ogg +0 -0
  24. package/assets/motion/assets/sfx/casino/card-place-2.ogg +0 -0
  25. package/assets/motion/assets/sfx/casino/card-place-3.ogg +0 -0
  26. package/assets/motion/assets/sfx/casino/card-place-4.ogg +0 -0
  27. package/assets/motion/assets/sfx/casino/card-shove-1.ogg +0 -0
  28. package/assets/motion/assets/sfx/casino/card-shove-2.ogg +0 -0
  29. package/assets/motion/assets/sfx/casino/card-shove-3.ogg +0 -0
  30. package/assets/motion/assets/sfx/casino/card-shove-4.ogg +0 -0
  31. package/assets/motion/assets/sfx/casino/card-shuffle.ogg +0 -0
  32. package/assets/motion/assets/sfx/casino/card-slide-1.ogg +0 -0
  33. package/assets/motion/assets/sfx/casino/card-slide-2.ogg +0 -0
  34. package/assets/motion/assets/sfx/casino/card-slide-3.ogg +0 -0
  35. package/assets/motion/assets/sfx/casino/card-slide-4.ogg +0 -0
  36. package/assets/motion/assets/sfx/casino/card-slide-5.ogg +0 -0
  37. package/assets/motion/assets/sfx/casino/card-slide-6.ogg +0 -0
  38. package/assets/motion/assets/sfx/casino/card-slide-7.ogg +0 -0
  39. package/assets/motion/assets/sfx/casino/card-slide-8.ogg +0 -0
  40. package/assets/motion/assets/sfx/casino/cards-pack-open-1.ogg +0 -0
  41. package/assets/motion/assets/sfx/casino/cards-pack-open-2.ogg +0 -0
  42. package/assets/motion/assets/sfx/casino/chip-lay-1.ogg +0 -0
  43. package/assets/motion/assets/sfx/casino/chip-lay-2.ogg +0 -0
  44. package/assets/motion/assets/sfx/casino/chip-lay-3.ogg +0 -0
  45. package/assets/motion/assets/sfx/casino/chips-collide-1.ogg +0 -0
  46. package/assets/motion/assets/sfx/casino/chips-collide-2.ogg +0 -0
  47. package/assets/motion/assets/sfx/casino/chips-collide-3.ogg +0 -0
  48. package/assets/motion/assets/sfx/casino/chips-collide-4.ogg +0 -0
  49. package/assets/motion/assets/sfx/casino/chips-handle-1.ogg +0 -0
  50. package/assets/motion/assets/sfx/casino/chips-handle-2.ogg +0 -0
  51. package/assets/motion/assets/sfx/casino/chips-handle-3.ogg +0 -0
  52. package/assets/motion/assets/sfx/casino/chips-handle-4.ogg +0 -0
  53. package/assets/motion/assets/sfx/casino/chips-handle-6.ogg +0 -0
  54. package/assets/motion/assets/sfx/casino/chips-stack-1.ogg +0 -0
  55. package/assets/motion/assets/sfx/casino/chips-stack-2.ogg +0 -0
  56. package/assets/motion/assets/sfx/casino/chips-stack-3.ogg +0 -0
  57. package/assets/motion/assets/sfx/casino/chips-stack-4.ogg +0 -0
  58. package/assets/motion/assets/sfx/casino/chips-stack-5.ogg +0 -0
  59. package/assets/motion/assets/sfx/casino/chips-stack-6.ogg +0 -0
  60. package/assets/motion/assets/sfx/casino/dice-grab-1.ogg +0 -0
  61. package/assets/motion/assets/sfx/casino/dice-grab-2.ogg +0 -0
  62. package/assets/motion/assets/sfx/casino/dice-shake-1.ogg +0 -0
  63. package/assets/motion/assets/sfx/casino/dice-shake-2.ogg +0 -0
  64. package/assets/motion/assets/sfx/casino/dice-shake-3.ogg +0 -0
  65. package/assets/motion/assets/sfx/casino/dice-throw-1.ogg +0 -0
  66. package/assets/motion/assets/sfx/casino/dice-throw-2.ogg +0 -0
  67. package/assets/motion/assets/sfx/casino/dice-throw-3.ogg +0 -0
  68. package/assets/motion/assets/sfx/casino/die-throw-1.ogg +0 -0
  69. package/assets/motion/assets/sfx/casino/die-throw-2.ogg +0 -0
  70. package/assets/motion/assets/sfx/casino/die-throw-3.ogg +0 -0
  71. package/assets/motion/assets/sfx/casino/die-throw-4.ogg +0 -0
  72. package/assets/motion/assets/sfx/impact/footstep_carpet_000.ogg +0 -0
  73. package/assets/motion/assets/sfx/impact/footstep_carpet_003.ogg +0 -0
  74. package/assets/motion/assets/sfx/impact/footstep_carpet_004.ogg +0 -0
  75. package/assets/motion/assets/sfx/impact/footstep_concrete_000.ogg +0 -0
  76. package/assets/motion/assets/sfx/impact/footstep_concrete_001.ogg +0 -0
  77. package/assets/motion/assets/sfx/impact/footstep_concrete_002.ogg +0 -0
  78. package/assets/motion/assets/sfx/impact/footstep_concrete_003.ogg +0 -0
  79. package/assets/motion/assets/sfx/impact/footstep_concrete_004.ogg +0 -0
  80. package/assets/motion/assets/sfx/impact/footstep_grass_000.ogg +0 -0
  81. package/assets/motion/assets/sfx/impact/footstep_grass_001.ogg +0 -0
  82. package/assets/motion/assets/sfx/impact/footstep_grass_002.ogg +0 -0
  83. package/assets/motion/assets/sfx/impact/footstep_grass_003.ogg +0 -0
  84. package/assets/motion/assets/sfx/impact/footstep_grass_004.ogg +0 -0
  85. package/assets/motion/assets/sfx/impact/footstep_snow_000.ogg +0 -0
  86. package/assets/motion/assets/sfx/impact/footstep_snow_001.ogg +0 -0
  87. package/assets/motion/assets/sfx/impact/footstep_snow_002.ogg +0 -0
  88. package/assets/motion/assets/sfx/impact/footstep_snow_003.ogg +0 -0
  89. package/assets/motion/assets/sfx/impact/footstep_snow_004.ogg +0 -0
  90. package/assets/motion/assets/sfx/impact/footstep_wood_000.ogg +0 -0
  91. package/assets/motion/assets/sfx/impact/footstep_wood_001.ogg +0 -0
  92. package/assets/motion/assets/sfx/impact/footstep_wood_002.ogg +0 -0
  93. package/assets/motion/assets/sfx/impact/footstep_wood_003.ogg +0 -0
  94. package/assets/motion/assets/sfx/impact/footstep_wood_004.ogg +0 -0
  95. package/assets/motion/assets/sfx/impact/impactBell_heavy_000.ogg +0 -0
  96. package/assets/motion/assets/sfx/impact/impactBell_heavy_003.ogg +0 -0
  97. package/assets/motion/assets/sfx/impact/impactBell_heavy_004.ogg +0 -0
  98. package/assets/motion/assets/sfx/impact/impactGeneric_light_000.ogg +0 -0
  99. package/assets/motion/assets/sfx/impact/impactGeneric_light_001.ogg +0 -0
  100. package/assets/motion/assets/sfx/impact/impactGeneric_light_002.ogg +0 -0
  101. package/assets/motion/assets/sfx/impact/impactGeneric_light_003.ogg +0 -0
  102. package/assets/motion/assets/sfx/impact/impactGeneric_light_004.ogg +0 -0
  103. package/assets/motion/assets/sfx/impact/impactGlass_heavy_002.ogg +0 -0
  104. package/assets/motion/assets/sfx/impact/impactGlass_light_001.ogg +0 -0
  105. package/assets/motion/assets/sfx/impact/impactGlass_light_002.ogg +0 -0
  106. package/assets/motion/assets/sfx/impact/impactGlass_light_003.ogg +0 -0
  107. package/assets/motion/assets/sfx/impact/impactGlass_medium_000.ogg +0 -0
  108. package/assets/motion/assets/sfx/impact/impactGlass_medium_002.ogg +0 -0
  109. package/assets/motion/assets/sfx/impact/impactGlass_medium_004.ogg +0 -0
  110. package/assets/motion/assets/sfx/impact/impactMetal_heavy_000.ogg +0 -0
  111. package/assets/motion/assets/sfx/impact/impactMetal_heavy_002.ogg +0 -0
  112. package/assets/motion/assets/sfx/impact/impactMetal_heavy_004.ogg +0 -0
  113. package/assets/motion/assets/sfx/impact/impactMetal_light_002.ogg +0 -0
  114. package/assets/motion/assets/sfx/impact/impactMetal_light_003.ogg +0 -0
  115. package/assets/motion/assets/sfx/impact/impactMetal_medium_000.ogg +0 -0
  116. package/assets/motion/assets/sfx/impact/impactMetal_medium_001.ogg +0 -0
  117. package/assets/motion/assets/sfx/impact/impactMetal_medium_002.ogg +0 -0
  118. package/assets/motion/assets/sfx/impact/impactMetal_medium_003.ogg +0 -0
  119. package/assets/motion/assets/sfx/impact/impactMetal_medium_004.ogg +0 -0
  120. package/assets/motion/assets/sfx/impact/impactMining_001.ogg +0 -0
  121. package/assets/motion/assets/sfx/impact/impactPlank_medium_000.ogg +0 -0
  122. package/assets/motion/assets/sfx/impact/impactPlank_medium_001.ogg +0 -0
  123. package/assets/motion/assets/sfx/impact/impactPlank_medium_002.ogg +0 -0
  124. package/assets/motion/assets/sfx/impact/impactPlank_medium_003.ogg +0 -0
  125. package/assets/motion/assets/sfx/impact/impactPlank_medium_004.ogg +0 -0
  126. package/assets/motion/assets/sfx/impact/impactPlate_heavy_000.ogg +0 -0
  127. package/assets/motion/assets/sfx/impact/impactPlate_heavy_001.ogg +0 -0
  128. package/assets/motion/assets/sfx/impact/impactPlate_heavy_002.ogg +0 -0
  129. package/assets/motion/assets/sfx/impact/impactPlate_heavy_003.ogg +0 -0
  130. package/assets/motion/assets/sfx/impact/impactPlate_heavy_004.ogg +0 -0
  131. package/assets/motion/assets/sfx/impact/impactPlate_light_000.ogg +0 -0
  132. package/assets/motion/assets/sfx/impact/impactPlate_light_001.ogg +0 -0
  133. package/assets/motion/assets/sfx/impact/impactPlate_light_002.ogg +0 -0
  134. package/assets/motion/assets/sfx/impact/impactPlate_light_003.ogg +0 -0
  135. package/assets/motion/assets/sfx/impact/impactPlate_light_004.ogg +0 -0
  136. package/assets/motion/assets/sfx/impact/impactPlate_medium_000.ogg +0 -0
  137. package/assets/motion/assets/sfx/impact/impactPlate_medium_001.ogg +0 -0
  138. package/assets/motion/assets/sfx/impact/impactPlate_medium_002.ogg +0 -0
  139. package/assets/motion/assets/sfx/impact/impactPlate_medium_003.ogg +0 -0
  140. package/assets/motion/assets/sfx/impact/impactPlate_medium_004.ogg +0 -0
  141. package/assets/motion/assets/sfx/impact/impactPunch_heavy_000.ogg +0 -0
  142. package/assets/motion/assets/sfx/impact/impactPunch_heavy_001.ogg +0 -0
  143. package/assets/motion/assets/sfx/impact/impactPunch_heavy_002.ogg +0 -0
  144. package/assets/motion/assets/sfx/impact/impactPunch_heavy_003.ogg +0 -0
  145. package/assets/motion/assets/sfx/impact/impactPunch_heavy_004.ogg +0 -0
  146. package/assets/motion/assets/sfx/impact/impactPunch_medium_000.ogg +0 -0
  147. package/assets/motion/assets/sfx/impact/impactPunch_medium_001.ogg +0 -0
  148. package/assets/motion/assets/sfx/impact/impactPunch_medium_002.ogg +0 -0
  149. package/assets/motion/assets/sfx/impact/impactPunch_medium_003.ogg +0 -0
  150. package/assets/motion/assets/sfx/impact/impactPunch_medium_004.ogg +0 -0
  151. package/assets/motion/assets/sfx/impact/impactSoft_heavy_000.ogg +0 -0
  152. package/assets/motion/assets/sfx/impact/impactSoft_heavy_001.ogg +0 -0
  153. package/assets/motion/assets/sfx/impact/impactSoft_heavy_002.ogg +0 -0
  154. package/assets/motion/assets/sfx/impact/impactSoft_heavy_003.ogg +0 -0
  155. package/assets/motion/assets/sfx/impact/impactSoft_heavy_004.ogg +0 -0
  156. package/assets/motion/assets/sfx/impact/impactSoft_medium_000.ogg +0 -0
  157. package/assets/motion/assets/sfx/impact/impactSoft_medium_001.ogg +0 -0
  158. package/assets/motion/assets/sfx/impact/impactSoft_medium_002.ogg +0 -0
  159. package/assets/motion/assets/sfx/impact/impactSoft_medium_003.ogg +0 -0
  160. package/assets/motion/assets/sfx/impact/impactSoft_medium_004.ogg +0 -0
  161. package/assets/motion/assets/sfx/impact/impactTin_medium_000.ogg +0 -0
  162. package/assets/motion/assets/sfx/impact/impactTin_medium_001.ogg +0 -0
  163. package/assets/motion/assets/sfx/impact/impactTin_medium_002.ogg +0 -0
  164. package/assets/motion/assets/sfx/impact/impactTin_medium_003.ogg +0 -0
  165. package/assets/motion/assets/sfx/impact/impactTin_medium_004.ogg +0 -0
  166. package/assets/motion/assets/sfx/impact/impactWood_heavy_000.ogg +0 -0
  167. package/assets/motion/assets/sfx/impact/impactWood_heavy_001.ogg +0 -0
  168. package/assets/motion/assets/sfx/impact/impactWood_heavy_002.ogg +0 -0
  169. package/assets/motion/assets/sfx/impact/impactWood_heavy_003.ogg +0 -0
  170. package/assets/motion/assets/sfx/impact/impactWood_heavy_004.ogg +0 -0
  171. package/assets/motion/assets/sfx/impact/impactWood_light_000.ogg +0 -0
  172. package/assets/motion/assets/sfx/impact/impactWood_light_001.ogg +0 -0
  173. package/assets/motion/assets/sfx/impact/impactWood_light_002.ogg +0 -0
  174. package/assets/motion/assets/sfx/impact/impactWood_light_003.ogg +0 -0
  175. package/assets/motion/assets/sfx/impact/impactWood_light_004.ogg +0 -0
  176. package/assets/motion/assets/sfx/impact/impactWood_medium_000.ogg +0 -0
  177. package/assets/motion/assets/sfx/impact/impactWood_medium_001.ogg +0 -0
  178. package/assets/motion/assets/sfx/impact/impactWood_medium_002.ogg +0 -0
  179. package/assets/motion/assets/sfx/impact/impactWood_medium_003.ogg +0 -0
  180. package/assets/motion/assets/sfx/impact/impactWood_medium_004.ogg +0 -0
  181. package/assets/motion/assets/sfx/interface/bong_001.ogg +0 -0
  182. package/assets/motion/assets/sfx/interface/click_001.ogg +0 -0
  183. package/assets/motion/assets/sfx/interface/click_002.ogg +0 -0
  184. package/assets/motion/assets/sfx/interface/click_003.ogg +0 -0
  185. package/assets/motion/assets/sfx/interface/click_004.ogg +0 -0
  186. package/assets/motion/assets/sfx/interface/click_005.ogg +0 -0
  187. package/assets/motion/assets/sfx/interface/drop_001.ogg +0 -0
  188. package/assets/motion/assets/sfx/interface/drop_002.ogg +0 -0
  189. package/assets/motion/assets/sfx/interface/drop_003.ogg +0 -0
  190. package/assets/motion/assets/sfx/interface/error_005.ogg +0 -0
  191. package/assets/motion/assets/sfx/interface/error_006.ogg +0 -0
  192. package/assets/motion/assets/sfx/interface/glitch_002.ogg +0 -0
  193. package/assets/motion/assets/sfx/interface/glitch_004.ogg +0 -0
  194. package/assets/motion/assets/sfx/interface/select_008.ogg +0 -0
  195. package/assets/motion/assets/sfx/interface/switch_001.ogg +0 -0
  196. package/assets/motion/assets/sfx/interface/switch_002.ogg +0 -0
  197. package/assets/motion/assets/sfx/interface/switch_004.ogg +0 -0
  198. package/assets/motion/assets/sfx/interface/switch_005.ogg +0 -0
  199. package/assets/motion/assets/sfx/interface/switch_006.ogg +0 -0
  200. package/assets/motion/assets/sfx/interface/switch_007.ogg +0 -0
  201. package/assets/motion/assets/sfx/keyboard/keypress-001.wav +0 -0
  202. package/assets/motion/assets/sfx/keyboard/keypress-002.wav +0 -0
  203. package/assets/motion/assets/sfx/keyboard/keypress-003.wav +0 -0
  204. package/assets/motion/assets/sfx/keyboard/keypress-004.wav +0 -0
  205. package/assets/motion/assets/sfx/keyboard/keypress-005.wav +0 -0
  206. package/assets/motion/assets/sfx/keyboard/keypress-006.wav +0 -0
  207. package/assets/motion/assets/sfx/keyboard/keypress-007.wav +0 -0
  208. package/assets/motion/assets/sfx/keyboard/keypress-008.wav +0 -0
  209. package/assets/motion/assets/sfx/keyboard/keypress-009.wav +0 -0
  210. package/assets/motion/assets/sfx/keyboard/keypress-010.wav +0 -0
  211. package/assets/motion/assets/sfx/keyboard/keypress-011.wav +0 -0
  212. package/assets/motion/assets/sfx/keyboard/keypress-012.wav +0 -0
  213. package/assets/motion/assets/sfx/keyboard/keypress-013.wav +0 -0
  214. package/assets/motion/assets/sfx/keyboard/keypress-014.wav +0 -0
  215. package/assets/motion/assets/sfx/keyboard/keypress-015.wav +0 -0
  216. package/assets/motion/assets/sfx/keyboard/keypress-016.wav +0 -0
  217. package/assets/motion/assets/sfx/keyboard/keypress-017.wav +0 -0
  218. package/assets/motion/assets/sfx/keyboard/keypress-018.wav +0 -0
  219. package/assets/motion/assets/sfx/keyboard/keypress-019.wav +0 -0
  220. package/assets/motion/assets/sfx/keyboard/keypress-020.wav +0 -0
  221. package/assets/motion/assets/sfx/keyboard/keypress-021.wav +0 -0
  222. package/assets/motion/assets/sfx/keyboard/keypress-022.wav +0 -0
  223. package/assets/motion/assets/sfx/keyboard/keypress-023.wav +0 -0
  224. package/assets/motion/assets/sfx/keyboard/keypress-024.wav +0 -0
  225. package/assets/motion/assets/sfx/keyboard/keypress-025.wav +0 -0
  226. package/assets/motion/assets/sfx/keyboard/keypress-026.wav +0 -0
  227. package/assets/motion/assets/sfx/keyboard/keypress-027.wav +0 -0
  228. package/assets/motion/assets/sfx/keyboard/keypress-028.wav +0 -0
  229. package/assets/motion/assets/sfx/keyboard/keypress-029.wav +0 -0
  230. package/assets/motion/assets/sfx/keyboard/keypress-030.wav +0 -0
  231. package/assets/motion/assets/sfx/keyboard/keypress-031.wav +0 -0
  232. package/assets/motion/assets/sfx/keyboard/keypress-032.wav +0 -0
  233. package/assets/motion/assets/sfx/sfx-analysis.json +15584 -0
  234. package/assets/motion/assets/sfx/sfx-analysis.md +75 -0
  235. package/assets/motion/assets/sfx/ui/click1.ogg +0 -0
  236. package/assets/motion/assets/sfx/ui/click2.ogg +0 -0
  237. package/assets/motion/assets/sfx/ui/click3.ogg +0 -0
  238. package/assets/motion/assets/sfx/ui/click4.ogg +0 -0
  239. package/assets/motion/assets/sfx/ui/click5.ogg +0 -0
  240. package/assets/motion/assets/sfx/ui/mouseclick1.ogg +0 -0
  241. package/assets/motion/assets/sfx/ui/rollover1.ogg +0 -0
  242. package/assets/motion/assets/sfx/ui/rollover2.ogg +0 -0
  243. package/assets/motion/assets/sfx/ui/rollover4.ogg +0 -0
  244. package/assets/motion/assets/sfx/ui/rollover5.ogg +0 -0
  245. package/assets/motion/assets/sfx/ui/switch1.ogg +0 -0
  246. package/assets/motion/assets/sfx/ui/switch10.ogg +0 -0
  247. package/assets/motion/assets/sfx/ui/switch11.ogg +0 -0
  248. package/assets/motion/assets/sfx/ui/switch12.ogg +0 -0
  249. package/assets/motion/assets/sfx/ui/switch13.ogg +0 -0
  250. package/assets/motion/assets/sfx/ui/switch14.ogg +0 -0
  251. package/assets/motion/assets/sfx/ui/switch15.ogg +0 -0
  252. package/assets/motion/assets/sfx/ui/switch16.ogg +0 -0
  253. package/assets/motion/assets/sfx/ui/switch17.ogg +0 -0
  254. package/assets/motion/assets/sfx/ui/switch18.ogg +0 -0
  255. package/assets/motion/assets/sfx/ui/switch19.ogg +0 -0
  256. package/assets/motion/assets/sfx/ui/switch2.ogg +0 -0
  257. package/assets/motion/assets/sfx/ui/switch20.ogg +0 -0
  258. package/assets/motion/assets/sfx/ui/switch21.ogg +0 -0
  259. package/assets/motion/assets/sfx/ui/switch22.ogg +0 -0
  260. package/assets/motion/assets/sfx/ui/switch23.ogg +0 -0
  261. package/assets/motion/assets/sfx/ui/switch24.ogg +0 -0
  262. package/assets/motion/assets/sfx/ui/switch25.ogg +0 -0
  263. package/assets/motion/assets/sfx/ui/switch26.ogg +0 -0
  264. package/assets/motion/assets/sfx/ui/switch27.ogg +0 -0
  265. package/assets/motion/assets/sfx/ui/switch28.ogg +0 -0
  266. package/assets/motion/assets/sfx/ui/switch29.ogg +0 -0
  267. package/assets/motion/assets/sfx/ui/switch3.ogg +0 -0
  268. package/assets/motion/assets/sfx/ui/switch30.ogg +0 -0
  269. package/assets/motion/assets/sfx/ui/switch31.ogg +0 -0
  270. package/assets/motion/assets/sfx/ui/switch32.ogg +0 -0
  271. package/assets/motion/assets/sfx/ui/switch33.ogg +0 -0
  272. package/assets/motion/assets/sfx/ui/switch34.ogg +0 -0
  273. package/assets/motion/assets/sfx/ui/switch35.ogg +0 -0
  274. package/assets/motion/assets/sfx/ui/switch36.ogg +0 -0
  275. package/assets/motion/assets/sfx/ui/switch37.ogg +0 -0
  276. package/assets/motion/assets/sfx/ui/switch38.ogg +0 -0
  277. package/assets/motion/assets/sfx/ui/switch4.ogg +0 -0
  278. package/assets/motion/assets/sfx/ui/switch5.ogg +0 -0
  279. package/assets/motion/assets/sfx/ui/switch6.ogg +0 -0
  280. package/assets/motion/assets/sfx/ui/switch7.ogg +0 -0
  281. package/assets/motion/assets/sfx/ui/switch8.ogg +0 -0
  282. package/assets/motion/assets/sfx/ui/switch9.ogg +0 -0
  283. package/assets/motion/bin/contact-sheet.mjs +87 -0
  284. package/assets/motion/bin/fonts.mjs +107 -0
  285. package/assets/motion/bin/hyperframes.mjs +122 -0
  286. package/assets/motion/bin/library.mjs +210 -0
  287. package/assets/motion/bin/media-binaries.mjs +49 -0
  288. package/assets/motion/bin/motion-check.mjs +250 -0
  289. package/assets/motion/bin/pdf-extract.mjs +133 -0
  290. package/assets/motion/bin/reveal.mjs +76 -0
  291. package/assets/motion/bin/review-frames.mjs +328 -0
  292. package/assets/motion/bin/score-synth.mjs +486 -0
  293. package/assets/motion/bin/three.mjs +55 -0
  294. package/assets/motion/fonts/anybody/OFL.txt +93 -0
  295. package/assets/motion/fonts/anybody/anybody-normal.woff2 +0 -0
  296. package/assets/motion/fonts/archivo/OFL.txt +93 -0
  297. package/assets/motion/fonts/archivo/archivo-normal.woff2 +0 -0
  298. package/assets/motion/fonts/big-shoulders/OFL.txt +93 -0
  299. package/assets/motion/fonts/big-shoulders/big-shoulders-normal.woff2 +0 -0
  300. package/assets/motion/fonts/bricolage-grotesque/OFL.txt +93 -0
  301. package/assets/motion/fonts/bricolage-grotesque/bricolage-grotesque-normal.woff2 +0 -0
  302. package/assets/motion/fonts/doto/OFL.txt +93 -0
  303. package/assets/motion/fonts/doto/doto-normal.woff2 +0 -0
  304. package/assets/motion/fonts/fonts.json +209 -0
  305. package/assets/motion/fonts/fraunces/OFL.txt +93 -0
  306. package/assets/motion/fonts/fraunces/fraunces-italic.woff2 +0 -0
  307. package/assets/motion/fonts/fraunces/fraunces-normal.woff2 +0 -0
  308. package/assets/motion/fonts/funnel-display/OFL.txt +93 -0
  309. package/assets/motion/fonts/funnel-display/funnel-display-normal.woff2 +0 -0
  310. package/assets/motion/fonts/gloock/OFL.txt +93 -0
  311. package/assets/motion/fonts/gloock/gloock-normal.woff2 +0 -0
  312. package/assets/motion/fonts/host-grotesk/OFL.txt +93 -0
  313. package/assets/motion/fonts/host-grotesk/host-grotesk-normal.woff2 +0 -0
  314. package/assets/motion/fonts/hubot-sans/OFL.txt +93 -0
  315. package/assets/motion/fonts/hubot-sans/hubot-sans-normal.woff2 +0 -0
  316. package/assets/motion/fonts/martian-mono/OFL.txt +93 -0
  317. package/assets/motion/fonts/martian-mono/martian-mono-normal.woff2 +0 -0
  318. package/assets/motion/fonts/mona-sans/OFL.txt +93 -0
  319. package/assets/motion/fonts/mona-sans/mona-sans-normal.woff2 +0 -0
  320. package/assets/motion/fonts/newsreader/OFL.txt +93 -0
  321. package/assets/motion/fonts/newsreader/newsreader-italic.woff2 +0 -0
  322. package/assets/motion/fonts/newsreader/newsreader-normal.woff2 +0 -0
  323. package/assets/motion/fonts/schibsted-grotesk/OFL.txt +93 -0
  324. package/assets/motion/fonts/schibsted-grotesk/schibsted-grotesk-normal.woff2 +0 -0
  325. package/assets/motion/fonts/specimen.jpg +0 -0
  326. package/assets/motion/fonts/young-serif/OFL.txt +93 -0
  327. package/assets/motion/fonts/young-serif/young-serif-normal.woff2 +0 -0
  328. package/assets/motion/library/README.md +104 -0
  329. package/assets/motion/library/library.json +1384 -0
  330. package/assets/motion/library/looks/acid-poster/look.md +82 -0
  331. package/assets/motion/library/looks/acid-poster/meta.json +11 -0
  332. package/assets/motion/library/looks/acid-poster/preview.jpg +0 -0
  333. package/assets/motion/library/looks/acid-poster/sample.html +177 -0
  334. package/assets/motion/library/looks/acid-poster/tokens.css +16 -0
  335. package/assets/motion/library/looks/blueprint/look.md +22 -0
  336. package/assets/motion/library/looks/blueprint/meta.json +11 -0
  337. package/assets/motion/library/looks/blueprint/preview.jpg +0 -0
  338. package/assets/motion/library/looks/blueprint/sample.html +301 -0
  339. package/assets/motion/library/looks/blueprint/tokens.css +16 -0
  340. package/assets/motion/library/looks/dark-studio/look.md +85 -0
  341. package/assets/motion/library/looks/dark-studio/meta.json +11 -0
  342. package/assets/motion/library/looks/dark-studio/preview.jpg +0 -0
  343. package/assets/motion/library/looks/dark-studio/sample.html +324 -0
  344. package/assets/motion/library/looks/dark-studio/tokens.css +16 -0
  345. package/assets/motion/library/looks/data-desk/look.md +19 -0
  346. package/assets/motion/library/looks/data-desk/meta.json +9 -0
  347. package/assets/motion/library/looks/data-desk/preview.jpg +0 -0
  348. package/assets/motion/library/looks/data-desk/sample.html +17 -0
  349. package/assets/motion/library/looks/data-desk/tokens.css +15 -0
  350. package/assets/motion/library/looks/duotone-broadcast/look.md +53 -0
  351. package/assets/motion/library/looks/duotone-broadcast/meta.json +11 -0
  352. package/assets/motion/library/looks/duotone-broadcast/preview.jpg +0 -0
  353. package/assets/motion/library/looks/duotone-broadcast/sample.html +45 -0
  354. package/assets/motion/library/looks/duotone-broadcast/tokens.css +16 -0
  355. package/assets/motion/library/looks/editorial-ink/look.md +80 -0
  356. package/assets/motion/library/looks/editorial-ink/meta.json +11 -0
  357. package/assets/motion/library/looks/editorial-ink/preview.jpg +0 -0
  358. package/assets/motion/library/looks/editorial-ink/sample.html +203 -0
  359. package/assets/motion/library/looks/editorial-ink/tokens.css +16 -0
  360. package/assets/motion/library/looks/mono-luxe/look.md +19 -0
  361. package/assets/motion/library/looks/mono-luxe/meta.json +9 -0
  362. package/assets/motion/library/looks/mono-luxe/preview.jpg +0 -0
  363. package/assets/motion/library/looks/mono-luxe/sample.html +12 -0
  364. package/assets/motion/library/looks/mono-luxe/tokens.css +15 -0
  365. package/assets/motion/library/looks/soft-light-ad/look.md +63 -0
  366. package/assets/motion/library/looks/soft-light-ad/meta.json +39 -0
  367. package/assets/motion/library/looks/soft-light-ad/preview.jpg +0 -0
  368. package/assets/motion/library/looks/soft-light-ad/sample.html +44 -0
  369. package/assets/motion/library/looks/soft-light-ad/tokens.css +17 -0
  370. package/assets/motion/library/looks/sunlit-consumer/look.md +19 -0
  371. package/assets/motion/library/looks/sunlit-consumer/meta.json +9 -0
  372. package/assets/motion/library/looks/sunlit-consumer/preview.jpg +0 -0
  373. package/assets/motion/library/looks/sunlit-consumer/sample.html +12 -0
  374. package/assets/motion/library/looks/sunlit-consumer/tokens.css +15 -0
  375. package/assets/motion/library/looks/swiss-grid/look.md +81 -0
  376. package/assets/motion/library/looks/swiss-grid/meta.json +11 -0
  377. package/assets/motion/library/looks/swiss-grid/preview.jpg +0 -0
  378. package/assets/motion/library/looks/swiss-grid/sample.html +209 -0
  379. package/assets/motion/library/looks/swiss-grid/tokens.css +16 -0
  380. package/assets/motion/library/looks/terminal-phosphor/look.md +77 -0
  381. package/assets/motion/library/looks/terminal-phosphor/meta.json +11 -0
  382. package/assets/motion/library/looks/terminal-phosphor/preview.jpg +0 -0
  383. package/assets/motion/library/looks/terminal-phosphor/sample.html +182 -0
  384. package/assets/motion/library/looks/terminal-phosphor/tokens.css +16 -0
  385. package/assets/motion/library/pieces/animated-beam/LICENSE +21 -0
  386. package/assets/motion/library/pieces/animated-beam/meta.json +16 -0
  387. package/assets/motion/library/pieces/animated-beam/piece.html +273 -0
  388. package/assets/motion/library/pieces/animated-beam/preview.jpg +0 -0
  389. package/assets/motion/library/pieces/animated-list/LICENSE +21 -0
  390. package/assets/motion/library/pieces/animated-list/meta.json +16 -0
  391. package/assets/motion/library/pieces/animated-list/piece.html +189 -0
  392. package/assets/motion/library/pieces/animated-list/preview.jpg +0 -0
  393. package/assets/motion/library/pieces/before-after-split/meta.json +12 -0
  394. package/assets/motion/library/pieces/before-after-split/piece.html +262 -0
  395. package/assets/motion/library/pieces/before-after-split/preview.jpg +0 -0
  396. package/assets/motion/library/pieces/blueprint-grid/meta.json +12 -0
  397. package/assets/motion/library/pieces/blueprint-grid/piece.html +209 -0
  398. package/assets/motion/library/pieces/blueprint-grid/preview.jpg +0 -0
  399. package/assets/motion/library/pieces/broadcast-frame/meta.json +12 -0
  400. package/assets/motion/library/pieces/broadcast-frame/piece.html +100 -0
  401. package/assets/motion/library/pieces/broadcast-frame/preview.jpg +0 -0
  402. package/assets/motion/library/pieces/browser-window/meta.json +12 -0
  403. package/assets/motion/library/pieces/browser-window/piece.html +331 -0
  404. package/assets/motion/library/pieces/browser-window/preview.jpg +0 -0
  405. package/assets/motion/library/pieces/chapter-card/meta.json +6 -0
  406. package/assets/motion/library/pieces/chapter-card/piece.html +12 -0
  407. package/assets/motion/library/pieces/chapter-card/preview.jpg +0 -0
  408. package/assets/motion/library/pieces/chat-thread/meta.json +12 -0
  409. package/assets/motion/library/pieces/chat-thread/piece.html +272 -0
  410. package/assets/motion/library/pieces/chat-thread/preview.jpg +0 -0
  411. package/assets/motion/library/pieces/clay-drop-3d/meta.json +13 -0
  412. package/assets/motion/library/pieces/clay-drop-3d/piece.html +224 -0
  413. package/assets/motion/library/pieces/clay-drop-3d/preview.jpg +0 -0
  414. package/assets/motion/library/pieces/color-flip-field/meta.json +12 -0
  415. package/assets/motion/library/pieces/color-flip-field/piece.html +81 -0
  416. package/assets/motion/library/pieces/color-flip-field/preview.jpg +0 -0
  417. package/assets/motion/library/pieces/color-wipe/meta.json +6 -0
  418. package/assets/motion/library/pieces/color-wipe/piece.html +10 -0
  419. package/assets/motion/library/pieces/color-wipe/preview.jpg +0 -0
  420. package/assets/motion/library/pieces/command-palette/meta.json +12 -0
  421. package/assets/motion/library/pieces/command-palette/piece.html +339 -0
  422. package/assets/motion/library/pieces/command-palette/preview.jpg +0 -0
  423. package/assets/motion/library/pieces/comparison-bars/meta.json +12 -0
  424. package/assets/motion/library/pieces/comparison-bars/piece.html +191 -0
  425. package/assets/motion/library/pieces/comparison-bars/preview.jpg +0 -0
  426. package/assets/motion/library/pieces/counter-number/meta.json +12 -0
  427. package/assets/motion/library/pieces/counter-number/piece.html +131 -0
  428. package/assets/motion/library/pieces/counter-number/preview.jpg +0 -0
  429. package/assets/motion/library/pieces/cursor-click/meta.json +12 -0
  430. package/assets/motion/library/pieces/cursor-click/piece.html +242 -0
  431. package/assets/motion/library/pieces/cursor-click/preview.jpg +0 -0
  432. package/assets/motion/library/pieces/dock-magnify/LICENSE +21 -0
  433. package/assets/motion/library/pieces/dock-magnify/meta.json +16 -0
  434. package/assets/motion/library/pieces/dock-magnify/piece.html +234 -0
  435. package/assets/motion/library/pieces/dock-magnify/preview.jpg +0 -0
  436. package/assets/motion/library/pieces/donut-fill/meta.json +12 -0
  437. package/assets/motion/library/pieces/donut-fill/piece.html +156 -0
  438. package/assets/motion/library/pieces/donut-fill/preview.jpg +0 -0
  439. package/assets/motion/library/pieces/dot-grid-field/meta.json +12 -0
  440. package/assets/motion/library/pieces/dot-grid-field/piece.html +61 -0
  441. package/assets/motion/library/pieces/dot-grid-field/preview.jpg +0 -0
  442. package/assets/motion/library/pieces/ease-curve/meta.json +12 -0
  443. package/assets/motion/library/pieces/ease-curve/piece.html +103 -0
  444. package/assets/motion/library/pieces/ease-curve/preview.jpg +0 -0
  445. package/assets/motion/library/pieces/end-card/meta.json +6 -0
  446. package/assets/motion/library/pieces/end-card/piece.html +11 -0
  447. package/assets/motion/library/pieces/end-card/preview.jpg +0 -0
  448. package/assets/motion/library/pieces/film-grain/meta.json +12 -0
  449. package/assets/motion/library/pieces/film-grain/piece.html +93 -0
  450. package/assets/motion/library/pieces/film-grain/preview.jpg +0 -0
  451. package/assets/motion/library/pieces/flickering-grid/LICENSE +21 -0
  452. package/assets/motion/library/pieces/flickering-grid/meta.json +16 -0
  453. package/assets/motion/library/pieces/flickering-grid/piece.html +112 -0
  454. package/assets/motion/library/pieces/flickering-grid/preview.jpg +0 -0
  455. package/assets/motion/library/pieces/flow-nodes/meta.json +12 -0
  456. package/assets/motion/library/pieces/flow-nodes/piece.html +230 -0
  457. package/assets/motion/library/pieces/flow-nodes/preview.jpg +0 -0
  458. package/assets/motion/library/pieces/highlight-sweep/meta.json +12 -0
  459. package/assets/motion/library/pieces/highlight-sweep/piece.html +132 -0
  460. package/assets/motion/library/pieces/highlight-sweep/preview.jpg +0 -0
  461. package/assets/motion/library/pieces/iris-circle/meta.json +6 -0
  462. package/assets/motion/library/pieces/iris-circle/piece.html +6 -0
  463. package/assets/motion/library/pieces/iris-circle/preview.jpg +0 -0
  464. package/assets/motion/library/pieces/kinetic-letters/meta.json +12 -0
  465. package/assets/motion/library/pieces/kinetic-letters/piece.html +103 -0
  466. package/assets/motion/library/pieces/kinetic-letters/preview.jpg +0 -0
  467. package/assets/motion/library/pieces/light-leak-soft/meta.json +12 -0
  468. package/assets/motion/library/pieces/light-leak-soft/piece.html +102 -0
  469. package/assets/motion/library/pieces/light-leak-soft/preview.jpg +0 -0
  470. package/assets/motion/library/pieces/line-stack-reveal/meta.json +12 -0
  471. package/assets/motion/library/pieces/line-stack-reveal/piece.html +98 -0
  472. package/assets/motion/library/pieces/line-stack-reveal/preview.jpg +0 -0
  473. package/assets/motion/library/pieces/lower-third/meta.json +6 -0
  474. package/assets/motion/library/pieces/lower-third/piece.html +11 -0
  475. package/assets/motion/library/pieces/lower-third/preview.jpg +0 -0
  476. package/assets/motion/library/pieces/marquee-strip/meta.json +12 -0
  477. package/assets/motion/library/pieces/marquee-strip/piece.html +132 -0
  478. package/assets/motion/library/pieces/marquee-strip/preview.jpg +0 -0
  479. package/assets/motion/library/pieces/mesh-gradient/meta.json +12 -0
  480. package/assets/motion/library/pieces/mesh-gradient/piece.html +131 -0
  481. package/assets/motion/library/pieces/mesh-gradient/preview.jpg +0 -0
  482. package/assets/motion/library/pieces/orbiting-circles/LICENSE +21 -0
  483. package/assets/motion/library/pieces/orbiting-circles/meta.json +16 -0
  484. package/assets/motion/library/pieces/orbiting-circles/piece.html +185 -0
  485. package/assets/motion/library/pieces/orbiting-circles/preview.jpg +0 -0
  486. package/assets/motion/library/pieces/phone-frame/meta.json +12 -0
  487. package/assets/motion/library/pieces/phone-frame/piece.html +252 -0
  488. package/assets/motion/library/pieces/phone-frame/preview.jpg +0 -0
  489. package/assets/motion/library/pieces/pricing-toggle/meta.json +6 -0
  490. package/assets/motion/library/pieces/pricing-toggle/piece.html +18 -0
  491. package/assets/motion/library/pieces/pricing-toggle/preview.jpg +0 -0
  492. package/assets/motion/library/pieces/retro-grid/LICENSE +21 -0
  493. package/assets/motion/library/pieces/retro-grid/meta.json +16 -0
  494. package/assets/motion/library/pieces/retro-grid/piece.html +139 -0
  495. package/assets/motion/library/pieces/retro-grid/preview.jpg +0 -0
  496. package/assets/motion/library/pieces/scale-through-word/meta.json +12 -0
  497. package/assets/motion/library/pieces/scale-through-word/piece.html +139 -0
  498. package/assets/motion/library/pieces/scale-through-word/preview.jpg +0 -0
  499. package/assets/motion/library/pieces/serif-quote/meta.json +12 -0
  500. package/assets/motion/library/pieces/serif-quote/piece.html +145 -0
  501. package/assets/motion/library/pieces/serif-quote/preview.jpg +0 -0
  502. package/assets/motion/library/pieces/slam-word/meta.json +12 -0
  503. package/assets/motion/library/pieces/slam-word/piece.html +72 -0
  504. package/assets/motion/library/pieces/slam-word/preview.jpg +0 -0
  505. package/assets/motion/library/pieces/soft-light-field/meta.json +12 -0
  506. package/assets/motion/library/pieces/soft-light-field/piece.html +83 -0
  507. package/assets/motion/library/pieces/soft-light-field/preview.jpg +0 -0
  508. package/assets/motion/library/pieces/sparkline-draw/meta.json +12 -0
  509. package/assets/motion/library/pieces/sparkline-draw/piece.html +204 -0
  510. package/assets/motion/library/pieces/sparkline-draw/preview.jpg +0 -0
  511. package/assets/motion/library/pieces/stack-layers/meta.json +12 -0
  512. package/assets/motion/library/pieces/stack-layers/piece.html +239 -0
  513. package/assets/motion/library/pieces/stack-layers/preview.jpg +0 -0
  514. package/assets/motion/library/pieces/stat-grid/meta.json +12 -0
  515. package/assets/motion/library/pieces/stat-grid/piece.html +200 -0
  516. package/assets/motion/library/pieces/stat-grid/preview.jpg +0 -0
  517. package/assets/motion/library/pieces/studio-backdrop/meta.json +12 -0
  518. package/assets/motion/library/pieces/studio-backdrop/piece.html +83 -0
  519. package/assets/motion/library/pieces/studio-backdrop/preview.jpg +0 -0
  520. package/assets/motion/library/pieces/tile-flip/meta.json +6 -0
  521. package/assets/motion/library/pieces/tile-flip/piece.html +6 -0
  522. package/assets/motion/library/pieces/tile-flip/preview.jpg +0 -0
  523. package/assets/motion/library/pieces/timeline-track/meta.json +12 -0
  524. package/assets/motion/library/pieces/timeline-track/piece.html +227 -0
  525. package/assets/motion/library/pieces/timeline-track/preview.jpg +0 -0
  526. package/assets/motion/library/pieces/toast-stack/meta.json +12 -0
  527. package/assets/motion/library/pieces/toast-stack/piece.html +185 -0
  528. package/assets/motion/library/pieces/toast-stack/preview.jpg +0 -0
  529. package/assets/motion/library/pieces/typewriter-caption/meta.json +12 -0
  530. package/assets/motion/library/pieces/typewriter-caption/piece.html +112 -0
  531. package/assets/motion/library/pieces/typewriter-caption/preview.jpg +0 -0
  532. package/assets/motion/library/pieces/ui-stack-3d/meta.json +12 -0
  533. package/assets/motion/library/pieces/ui-stack-3d/piece.html +236 -0
  534. package/assets/motion/library/pieces/ui-stack-3d/preview.jpg +0 -0
  535. package/assets/motion/library/pieces/vignette/meta.json +12 -0
  536. package/assets/motion/library/pieces/vignette/piece.html +85 -0
  537. package/assets/motion/library/pieces/vignette/preview.jpg +0 -0
  538. package/assets/motion/library/pieces/word-swap/meta.json +12 -0
  539. package/assets/motion/library/pieces/word-swap/piece.html +122 -0
  540. package/assets/motion/library/pieces/word-swap/preview.jpg +0 -0
  541. package/assets/motion/library/sheets/3d.jpg +0 -0
  542. package/assets/motion/library/sheets/background.jpg +0 -0
  543. package/assets/motion/library/sheets/data.jpg +0 -0
  544. package/assets/motion/library/sheets/diagram.jpg +0 -0
  545. package/assets/motion/library/sheets/frame.jpg +0 -0
  546. package/assets/motion/library/sheets/looks.jpg +0 -0
  547. package/assets/motion/library/sheets/texture.jpg +0 -0
  548. package/assets/motion/library/sheets/transition.jpg +0 -0
  549. package/assets/motion/library/sheets/type.jpg +0 -0
  550. package/assets/motion/library/sheets/ui.jpg +0 -0
  551. package/assets/motion/plugin.json +5 -0
  552. package/assets/motion/references/README.md +20 -0
  553. package/assets/motion/references/index.json +25 -0
  554. package/assets/motion/references/runtime/data-attributes.md +78 -0
  555. package/assets/motion/references/runtime/determinism-rules.md +53 -0
  556. package/assets/motion/references/runtime/doctor-browser.md +57 -0
  557. package/assets/motion/references/runtime/gsap-easing-and-stagger.md +199 -0
  558. package/assets/motion/references/runtime/gsap-timeline-and-labels.md +96 -0
  559. package/assets/motion/references/runtime/gsap-transforms-and-perf.md +129 -0
  560. package/assets/motion/references/runtime/gsap.md +105 -0
  561. package/assets/motion/references/runtime/inputs-and-assets.md +52 -0
  562. package/assets/motion/references/runtime/lint-validate-inspect.md +131 -0
  563. package/assets/motion/references/runtime/minimal-composition.md +69 -0
  564. package/assets/motion/references/runtime/preview-render.md +156 -0
  565. package/assets/motion/references/runtime/sub-compositions.md +176 -0
  566. package/assets/motion/references/runtime/tracks-and-clips.md +87 -0
  567. package/assets/motion/references/runtime/variables-and-media.md +107 -0
  568. package/assets/motion/references/signal-study.html +39 -0
  569. package/assets/motion/references/signal-temporal.jpg +0 -0
  570. package/assets/motion/references/type-temporal.jpg +0 -0
  571. package/assets/motion/skills/brand-kit/SKILL.md +70 -0
  572. package/assets/motion/skills/mixkit-split-text-617/SKILL.md +115 -0
  573. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-480.json +1 -0
  574. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-494.json +1 -0
  575. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-5.json +1 -0
  576. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-508.json +1 -0
  577. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6525.json +1 -0
  578. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6539.json +1 -0
  579. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6647.json +1 -0
  580. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6663.json +1 -0
  581. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6677.json +1 -0
  582. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6691.json +1 -0
  583. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6706.json +1 -0
  584. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6722.json +1 -0
  585. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6736.json +1 -0
  586. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6750.json +1 -0
  587. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6764.json +1 -0
  588. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6780.json +1 -0
  589. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6794.json +1 -0
  590. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6810.json +1 -0
  591. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6823.json +1 -0
  592. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6872.json +1 -0
  593. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6936.json +1 -0
  594. package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-76.json +1 -0
  595. package/assets/motion/skills/mixkit-split-text-617/data/manifest.json +495 -0
  596. package/assets/motion/skills/mixkit-split-text-617/references/RECONSTRUCTION.md +201 -0
  597. package/assets/motion/skills/mixkit-split-text-617/references/VERIFICATION.md +107 -0
  598. package/assets/motion/skills/mixkit-split-text-617/tools/inspect_motion.py +130 -0
  599. package/assets/motion/skills/motion/SKILL.md +102 -0
  600. package/assets/motion/skills/source-ingest/SKILL.md +48 -0
  601. package/assets/motion/skills/video-qa/SKILL.md +66 -0
  602. package/assets/motion/vendor/three/LICENSE +21 -0
  603. package/assets/motion/vendor/three/addons/environments/RoomEnvironment.js +182 -0
  604. package/assets/motion/vendor/three/addons/geometries/RoundedBoxGeometry.js +216 -0
  605. package/assets/motion/vendor/three/addons/geometries/TextGeometry.js +84 -0
  606. package/assets/motion/vendor/three/addons/lights/RectAreaLightTexturesLib.js +127 -0
  607. package/assets/motion/vendor/three/addons/lights/RectAreaLightUniformsLib.js +40 -0
  608. package/assets/motion/vendor/three/addons/loaders/FontLoader.js +260 -0
  609. package/assets/motion/vendor/three/addons/loaders/GLTFLoader.js +4892 -0
  610. package/assets/motion/vendor/three/addons/loaders/HDRLoader.js +486 -0
  611. package/assets/motion/vendor/three/addons/loaders/SVGLoader.js +3267 -0
  612. package/assets/motion/vendor/three/addons/math/SimplexNoise.js +470 -0
  613. package/assets/motion/vendor/three/addons/objects/Reflector.js +338 -0
  614. package/assets/motion/vendor/three/addons/postprocessing/BokehPass.js +218 -0
  615. package/assets/motion/vendor/three/addons/postprocessing/EffectComposer.js +363 -0
  616. package/assets/motion/vendor/three/addons/postprocessing/FilmPass.js +113 -0
  617. package/assets/motion/vendor/three/addons/postprocessing/MaskPass.js +195 -0
  618. package/assets/motion/vendor/three/addons/postprocessing/OutputPass.js +139 -0
  619. package/assets/motion/vendor/three/addons/postprocessing/Pass.js +191 -0
  620. package/assets/motion/vendor/three/addons/postprocessing/RenderPass.js +183 -0
  621. package/assets/motion/vendor/three/addons/postprocessing/ShaderPass.js +135 -0
  622. package/assets/motion/vendor/three/addons/postprocessing/UnrealBloomPass.js +494 -0
  623. package/assets/motion/vendor/three/addons/renderers/CSS3DRenderer.js +454 -0
  624. package/assets/motion/vendor/three/addons/shaders/BokehShader.js +151 -0
  625. package/assets/motion/vendor/three/addons/shaders/CopyShader.js +52 -0
  626. package/assets/motion/vendor/three/addons/shaders/FilmShader.js +72 -0
  627. package/assets/motion/vendor/three/addons/shaders/LuminosityHighPassShader.js +68 -0
  628. package/assets/motion/vendor/three/addons/shaders/OutputShader.js +103 -0
  629. package/assets/motion/vendor/three/addons/utils/BufferGeometryUtils.js +1435 -0
  630. package/assets/motion/vendor/three/build/three.core.min.js +6 -0
  631. package/assets/motion/vendor/three/build/three.module.min.js +6 -0
  632. package/assets/motion/vendor/three/three.json +54 -0
  633. package/dist/app-sidecar-sessions.js +5 -0
  634. package/dist/app-sidecar-sessions.js.map +1 -1
  635. package/dist/app-sidecar.js +52 -16
  636. package/dist/app-sidecar.js.map +1 -1
  637. package/dist/cli.js +1 -1
  638. package/dist/cli.js.map +1 -1
  639. package/dist/core/agent-session.d.ts +39 -0
  640. package/dist/core/agent-session.js +160 -11
  641. package/dist/core/agent-session.js.map +1 -1
  642. package/dist/core/agents.js +14 -42
  643. package/dist/core/agents.js.map +1 -1
  644. package/dist/core/auth-providers.js +6 -6
  645. package/dist/core/auth-providers.js.map +1 -1
  646. package/dist/core/bundled-agents.js +9 -7
  647. package/dist/core/bundled-agents.js.map +1 -1
  648. package/dist/core/completion-review.d.ts +24 -0
  649. package/dist/core/completion-review.js +2 -0
  650. package/dist/core/completion-review.js.map +1 -0
  651. package/dist/core/context-limits.d.ts +6 -0
  652. package/dist/core/context-limits.js +8 -0
  653. package/dist/core/context-limits.js.map +1 -1
  654. package/dist/core/fast-apply-benchmark.d.ts +1 -1
  655. package/dist/core/fast-apply-benchmark.js +2 -2
  656. package/dist/core/fast-apply-benchmark.js.map +1 -1
  657. package/dist/core/frontmatter.d.ts +22 -0
  658. package/dist/core/frontmatter.js +90 -0
  659. package/dist/core/frontmatter.js.map +1 -0
  660. package/dist/core/lsp/pool.d.ts +2 -0
  661. package/dist/core/lsp/pool.js +4 -0
  662. package/dist/core/lsp/pool.js.map +1 -1
  663. package/dist/core/network-guard.d.ts +2 -0
  664. package/dist/core/network-guard.js +37 -0
  665. package/dist/core/network-guard.js.map +1 -1
  666. package/dist/core/project-discovery.js +3 -0
  667. package/dist/core/project-discovery.js.map +1 -1
  668. package/dist/core/regrounding.d.ts +7 -0
  669. package/dist/core/regrounding.js +27 -0
  670. package/dist/core/regrounding.js.map +1 -1
  671. package/dist/core/semantic-search-benchmark.d.ts +1 -1
  672. package/dist/core/semantic-search-benchmark.js +2 -2
  673. package/dist/core/semantic-search-benchmark.js.map +1 -1
  674. package/dist/core/session-export.d.ts +2 -2
  675. package/dist/core/session-export.js +6 -2
  676. package/dist/core/session-export.js.map +1 -1
  677. package/dist/core/skills.d.ts +16 -1
  678. package/dist/core/skills.js +40 -25
  679. package/dist/core/skills.js.map +1 -1
  680. package/dist/core/subagent-policy.js +1 -4
  681. package/dist/core/subagent-policy.js.map +1 -1
  682. package/dist/core/verification-evidence.js +7 -2
  683. package/dist/core/verification-evidence.js.map +1 -1
  684. package/dist/motion-agent/motion-agent.d.ts +35 -0
  685. package/dist/motion-agent/motion-agent.js +117 -0
  686. package/dist/motion-agent/motion-agent.js.map +1 -0
  687. package/dist/motion-agent/motion-check-tool.d.ts +21 -0
  688. package/dist/motion-agent/motion-check-tool.js +206 -0
  689. package/dist/motion-agent/motion-check-tool.js.map +1 -0
  690. package/dist/motion-agent/motion-prompt.d.ts +2 -0
  691. package/dist/motion-agent/motion-prompt.js +48 -0
  692. package/dist/motion-agent/motion-prompt.js.map +1 -0
  693. package/dist/motion-agent/motion-review-coverage.d.ts +12 -0
  694. package/dist/motion-agent/motion-review-coverage.js +33 -0
  695. package/dist/motion-agent/motion-review-coverage.js.map +1 -0
  696. package/dist/motion-agent/motion-review-gate.d.ts +48 -0
  697. package/dist/motion-agent/motion-review-gate.js +88 -0
  698. package/dist/motion-agent/motion-review-gate.js.map +1 -0
  699. package/dist/motion-agent/motion-review-session.d.ts +65 -0
  700. package/dist/motion-agent/motion-review-session.js +418 -0
  701. package/dist/motion-agent/motion-review-session.js.map +1 -0
  702. package/dist/motion-agent/motion-review.d.ts +76 -0
  703. package/dist/motion-agent/motion-review.js +225 -0
  704. package/dist/motion-agent/motion-review.js.map +1 -0
  705. package/dist/motion-agent/motion-studio-context.d.ts +44 -0
  706. package/dist/motion-agent/motion-studio-context.js +65 -0
  707. package/dist/motion-agent/motion-studio-context.js.map +1 -0
  708. package/dist/system-prompt.d.ts +3 -0
  709. package/dist/system-prompt.js +5 -1
  710. package/dist/system-prompt.js.map +1 -1
  711. package/dist/tools/bash.js +2 -2
  712. package/dist/tools/bash.js.map +1 -1
  713. package/dist/tools/edit.js +8 -1
  714. package/dist/tools/edit.js.map +1 -1
  715. package/dist/tools/redaction-guard.d.ts +10 -0
  716. package/dist/tools/redaction-guard.js +55 -0
  717. package/dist/tools/redaction-guard.js.map +1 -0
  718. package/dist/tools/steroids.d.ts +1 -1
  719. package/dist/tools/steroids.js +20 -4
  720. package/dist/tools/steroids.js.map +1 -1
  721. package/dist/tools/web-fetch.js +38 -32
  722. package/dist/tools/web-fetch.js.map +1 -1
  723. package/dist/tools/web-search.js +2 -2
  724. package/dist/tools/web-search.js.map +1 -1
  725. package/dist/tools/write.js +12 -5
  726. package/dist/tools/write.js.map +1 -1
  727. package/dist/ui/components/Footer.js +1 -5
  728. package/dist/ui/components/Footer.js.map +1 -1
  729. package/package.json +7 -4
@@ -0,0 +1,4892 @@
1
+ import {
2
+ AnimationClip,
3
+ Bone,
4
+ Box3,
5
+ BufferAttribute,
6
+ BufferGeometry,
7
+ ClampToEdgeWrapping,
8
+ Color,
9
+ ColorManagement,
10
+ DirectionalLight,
11
+ DoubleSide,
12
+ FileLoader,
13
+ FrontSide,
14
+ Group,
15
+ ImageBitmapLoader,
16
+ InstancedMesh,
17
+ InterleavedBuffer,
18
+ InterleavedBufferAttribute,
19
+ Interpolant,
20
+ InterpolateDiscrete,
21
+ InterpolateLinear,
22
+ Line,
23
+ LineBasicMaterial,
24
+ LineLoop,
25
+ LineSegments,
26
+ LinearFilter,
27
+ LinearMipmapLinearFilter,
28
+ LinearMipmapNearestFilter,
29
+ LinearSRGBColorSpace,
30
+ Loader,
31
+ LoaderUtils,
32
+ Material,
33
+ MathUtils,
34
+ Matrix4,
35
+ Mesh,
36
+ MeshBasicMaterial,
37
+ MeshPhysicalMaterial,
38
+ MeshStandardMaterial,
39
+ MirroredRepeatWrapping,
40
+ NearestFilter,
41
+ NearestMipmapLinearFilter,
42
+ NearestMipmapNearestFilter,
43
+ NumberKeyframeTrack,
44
+ Object3D,
45
+ OrthographicCamera,
46
+ PerspectiveCamera,
47
+ PointLight,
48
+ Points,
49
+ PointsMaterial,
50
+ PropertyBinding,
51
+ Quaternion,
52
+ QuaternionKeyframeTrack,
53
+ RepeatWrapping,
54
+ Skeleton,
55
+ SkinnedMesh,
56
+ Sphere,
57
+ SpotLight,
58
+ Texture,
59
+ TextureLoader,
60
+ TriangleFanDrawMode,
61
+ TriangleStripDrawMode,
62
+ Vector2,
63
+ Vector3,
64
+ VectorKeyframeTrack,
65
+ SRGBColorSpace,
66
+ InstancedBufferAttribute
67
+ } from 'three';
68
+ import { toTrianglesDrawMode } from '../utils/BufferGeometryUtils.js';
69
+
70
+ /**
71
+ * A loader for the glTF 2.0 format.
72
+ *
73
+ * [glTF](https://www.khronos.org/gltf/} (GL Transmission Format) is an [open format specification]{@link https://github.com/KhronosGroup/glTF/tree/main/specification/2.0)
74
+ * for efficient delivery and loading of 3D content. Assets may be provided either in JSON (.gltf) or binary (.glb)
75
+ * format. External files store textures (.jpg, .png) and additional binary data (.bin). A glTF asset may deliver
76
+ * one or more scenes, including meshes, materials, textures, skins, skeletons, morph targets, animations, lights,
77
+ * and/or cameras.
78
+ *
79
+ * `GLTFLoader` uses {@link ImageBitmapLoader} whenever possible. Be advised that image bitmaps are not
80
+ * automatically GC-collected when they are no longer referenced, and they require special handling during
81
+ * the disposal process.
82
+ *
83
+ * `GLTFLoader` supports the following glTF 2.0 extensions:
84
+ * - KHR_draco_mesh_compression
85
+ * - KHR_materials_clearcoat
86
+ * - KHR_materials_dispersion
87
+ * - KHR_materials_ior
88
+ * - KHR_materials_specular
89
+ * - KHR_materials_transmission
90
+ * - KHR_materials_iridescence
91
+ * - KHR_materials_unlit
92
+ * - KHR_materials_volume
93
+ * - KHR_mesh_quantization
94
+ * - KHR_lights_punctual
95
+ * - KHR_texture_basisu
96
+ * - KHR_texture_transform
97
+ * - EXT_texture_webp
98
+ * - EXT_meshopt_compression
99
+ * - EXT_mesh_gpu_instancing
100
+ *
101
+ * The following glTF 2.0 extension is supported by an external user plugin:
102
+ * - [KHR_materials_variants](https://github.com/takahirox/three-gltf-extensions)
103
+ * - [MSFT_texture_dds](https://github.com/takahirox/three-gltf-extensions)
104
+ * - [KHR_animation_pointer](https://github.com/needle-tools/three-animation-pointer)
105
+ * - [NEEDLE_progressive](https://github.com/needle-tools/gltf-progressive)
106
+ *
107
+ * ```js
108
+ * const loader = new GLTFLoader();
109
+ *
110
+ * // Optional: Provide a DRACOLoader instance to decode compressed mesh data
111
+ * const dracoLoader = new DRACOLoader();
112
+ * dracoLoader.setDecoderPath( '/examples/jsm/libs/draco/' );
113
+ * loader.setDRACOLoader( dracoLoader );
114
+ *
115
+ * const gltf = await loader.loadAsync( 'models/gltf/duck/duck.gltf' );
116
+ * scene.add( gltf.scene );
117
+ * ```
118
+ *
119
+ * @augments Loader
120
+ * @three_import import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
121
+ */
122
+ class GLTFLoader extends Loader {
123
+
124
+ /**
125
+ * Constructs a new glTF loader.
126
+ *
127
+ * @param {LoadingManager} [manager] - The loading manager.
128
+ */
129
+ constructor( manager ) {
130
+
131
+ super( manager );
132
+
133
+ this.dracoLoader = null;
134
+ this.ktx2Loader = null;
135
+ this.meshoptDecoder = null;
136
+
137
+ this.pluginCallbacks = [];
138
+
139
+ this.register( function ( parser ) {
140
+
141
+ return new GLTFMaterialsClearcoatExtension( parser );
142
+
143
+ } );
144
+
145
+ this.register( function ( parser ) {
146
+
147
+ return new GLTFMaterialsDispersionExtension( parser );
148
+
149
+ } );
150
+
151
+ this.register( function ( parser ) {
152
+
153
+ return new GLTFTextureBasisUExtension( parser );
154
+
155
+ } );
156
+
157
+ this.register( function ( parser ) {
158
+
159
+ return new GLTFTextureWebPExtension( parser );
160
+
161
+ } );
162
+
163
+ this.register( function ( parser ) {
164
+
165
+ return new GLTFTextureAVIFExtension( parser );
166
+
167
+ } );
168
+
169
+ this.register( function ( parser ) {
170
+
171
+ return new GLTFMaterialsSheenExtension( parser );
172
+
173
+ } );
174
+
175
+ this.register( function ( parser ) {
176
+
177
+ return new GLTFMaterialsTransmissionExtension( parser );
178
+
179
+ } );
180
+
181
+ this.register( function ( parser ) {
182
+
183
+ return new GLTFMaterialsVolumeExtension( parser );
184
+
185
+ } );
186
+
187
+ this.register( function ( parser ) {
188
+
189
+ return new GLTFMaterialsIorExtension( parser );
190
+
191
+ } );
192
+
193
+ this.register( function ( parser ) {
194
+
195
+ return new GLTFMaterialsEmissiveStrengthExtension( parser );
196
+
197
+ } );
198
+
199
+ this.register( function ( parser ) {
200
+
201
+ return new GLTFMaterialsSpecularExtension( parser );
202
+
203
+ } );
204
+
205
+ this.register( function ( parser ) {
206
+
207
+ return new GLTFMaterialsIridescenceExtension( parser );
208
+
209
+ } );
210
+
211
+ this.register( function ( parser ) {
212
+
213
+ return new GLTFMaterialsAnisotropyExtension( parser );
214
+
215
+ } );
216
+
217
+ this.register( function ( parser ) {
218
+
219
+ return new GLTFMaterialsBumpExtension( parser );
220
+
221
+ } );
222
+
223
+ this.register( function ( parser ) {
224
+
225
+ return new GLTFLightsExtension( parser );
226
+
227
+ } );
228
+
229
+ this.register( function ( parser ) {
230
+
231
+ return new GLTFMeshoptCompression( parser );
232
+
233
+ } );
234
+
235
+ this.register( function ( parser ) {
236
+
237
+ return new GLTFMeshGpuInstancing( parser );
238
+
239
+ } );
240
+
241
+ }
242
+
243
+ /**
244
+ * Starts loading from the given URL and passes the loaded glTF asset
245
+ * to the `onLoad()` callback.
246
+ *
247
+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
248
+ * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
249
+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.
250
+ * @param {onErrorCallback} onError - Executed when errors occur.
251
+ */
252
+ load( url, onLoad, onProgress, onError ) {
253
+
254
+ const scope = this;
255
+
256
+ let resourcePath;
257
+
258
+ if ( this.resourcePath !== '' ) {
259
+
260
+ resourcePath = this.resourcePath;
261
+
262
+ } else if ( this.path !== '' ) {
263
+
264
+ // If a base path is set, resources will be relative paths from that plus the relative path of the gltf file
265
+ // Example path = 'https://my-cnd-server.com/', url = 'assets/models/model.gltf'
266
+ // resourcePath = 'https://my-cnd-server.com/assets/models/'
267
+ // referenced resource 'model.bin' will be loaded from 'https://my-cnd-server.com/assets/models/model.bin'
268
+ // referenced resource '../textures/texture.png' will be loaded from 'https://my-cnd-server.com/assets/textures/texture.png'
269
+ const relativeUrl = LoaderUtils.extractUrlBase( url );
270
+ resourcePath = LoaderUtils.resolveURL( relativeUrl, this.path );
271
+
272
+ } else {
273
+
274
+ resourcePath = LoaderUtils.extractUrlBase( url );
275
+
276
+ }
277
+
278
+ // Tells the LoadingManager to track an extra item, which resolves after
279
+ // the model is fully loaded. This means the count of items loaded will
280
+ // be incorrect, but ensures manager.onLoad() does not fire early.
281
+ this.manager.itemStart( url );
282
+
283
+ const _onError = function ( e ) {
284
+
285
+ if ( onError ) {
286
+
287
+ onError( e );
288
+
289
+ } else {
290
+
291
+ console.error( e );
292
+
293
+ }
294
+
295
+ scope.manager.itemError( url );
296
+ scope.manager.itemEnd( url );
297
+
298
+ };
299
+
300
+ const loader = new FileLoader( this.manager );
301
+
302
+ loader.setPath( this.path );
303
+ loader.setResponseType( 'arraybuffer' );
304
+ loader.setRequestHeader( this.requestHeader );
305
+ loader.setWithCredentials( this.withCredentials );
306
+
307
+ loader.load( url, function ( data ) {
308
+
309
+ try {
310
+
311
+ scope.parse( data, resourcePath, function ( gltf ) {
312
+
313
+ onLoad( gltf );
314
+
315
+ scope.manager.itemEnd( url );
316
+
317
+ }, _onError );
318
+
319
+ } catch ( e ) {
320
+
321
+ _onError( e );
322
+
323
+ }
324
+
325
+ }, onProgress, _onError );
326
+
327
+ }
328
+
329
+ /**
330
+ * Sets the given Draco loader to this loader. Required for decoding assets
331
+ * compressed with the `KHR_draco_mesh_compression` extension.
332
+ *
333
+ * @param {DRACOLoader} dracoLoader - The Draco loader to set.
334
+ * @return {GLTFLoader} A reference to this loader.
335
+ */
336
+ setDRACOLoader( dracoLoader ) {
337
+
338
+ this.dracoLoader = dracoLoader;
339
+ return this;
340
+
341
+ }
342
+
343
+ /**
344
+ * Sets the given KTX2 loader to this loader. Required for loading KTX2
345
+ * compressed textures.
346
+ *
347
+ * @param {KTX2Loader} ktx2Loader - The KTX2 loader to set.
348
+ * @return {GLTFLoader} A reference to this loader.
349
+ */
350
+ setKTX2Loader( ktx2Loader ) {
351
+
352
+ this.ktx2Loader = ktx2Loader;
353
+ return this;
354
+
355
+ }
356
+
357
+ /**
358
+ * Sets the given meshopt decoder. Required for decoding assets
359
+ * compressed with the `EXT_meshopt_compression` extension.
360
+ *
361
+ * @param {Object} meshoptDecoder - The meshopt decoder to set.
362
+ * @return {GLTFLoader} A reference to this loader.
363
+ */
364
+ setMeshoptDecoder( meshoptDecoder ) {
365
+
366
+ this.meshoptDecoder = meshoptDecoder;
367
+ return this;
368
+
369
+ }
370
+
371
+ /**
372
+ * Registers a plugin callback. This API is internally used to implement the various
373
+ * glTF extensions but can also used by third-party code to add additional logic
374
+ * to the loader.
375
+ *
376
+ * @param {function(parser:GLTFParser)} callback - The callback function to register.
377
+ * @return {GLTFLoader} A reference to this loader.
378
+ */
379
+ register( callback ) {
380
+
381
+ if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) {
382
+
383
+ this.pluginCallbacks.push( callback );
384
+
385
+ }
386
+
387
+ return this;
388
+
389
+ }
390
+
391
+ /**
392
+ * Unregisters a plugin callback.
393
+ *
394
+ * @param {Function} callback - The callback function to unregister.
395
+ * @return {GLTFLoader} A reference to this loader.
396
+ */
397
+ unregister( callback ) {
398
+
399
+ if ( this.pluginCallbacks.indexOf( callback ) !== - 1 ) {
400
+
401
+ this.pluginCallbacks.splice( this.pluginCallbacks.indexOf( callback ), 1 );
402
+
403
+ }
404
+
405
+ return this;
406
+
407
+ }
408
+
409
+ /**
410
+ * Parses the given FBX data and returns the resulting group.
411
+ *
412
+ * @param {string|ArrayBuffer} data - The raw glTF data.
413
+ * @param {string} path - The URL base path.
414
+ * @param {function(GLTFLoader~LoadObject)} onLoad - Executed when the loading process has been finished.
415
+ * @param {onErrorCallback} onError - Executed when errors occur.
416
+ */
417
+ parse( data, path, onLoad, onError ) {
418
+
419
+ let json;
420
+ const extensions = {};
421
+ const plugins = {};
422
+ const textDecoder = new TextDecoder();
423
+
424
+ if ( typeof data === 'string' ) {
425
+
426
+ json = JSON.parse( data );
427
+
428
+ } else if ( data instanceof ArrayBuffer ) {
429
+
430
+ const magic = textDecoder.decode( new Uint8Array( data, 0, 4 ) );
431
+
432
+ if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) {
433
+
434
+ try {
435
+
436
+ extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data );
437
+
438
+ } catch ( error ) {
439
+
440
+ if ( onError ) onError( error );
441
+ return;
442
+
443
+ }
444
+
445
+ json = JSON.parse( extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content );
446
+
447
+ } else {
448
+
449
+ json = JSON.parse( textDecoder.decode( data ) );
450
+
451
+ }
452
+
453
+ } else {
454
+
455
+ json = data;
456
+
457
+ }
458
+
459
+ if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) {
460
+
461
+ if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.' ) );
462
+ return;
463
+
464
+ }
465
+
466
+ const parser = new GLTFParser( json, {
467
+
468
+ path: path || this.resourcePath || '',
469
+ crossOrigin: this.crossOrigin,
470
+ requestHeader: this.requestHeader,
471
+ manager: this.manager,
472
+ ktx2Loader: this.ktx2Loader,
473
+ meshoptDecoder: this.meshoptDecoder
474
+
475
+ } );
476
+
477
+ parser.fileLoader.setRequestHeader( this.requestHeader );
478
+
479
+ for ( let i = 0; i < this.pluginCallbacks.length; i ++ ) {
480
+
481
+ const plugin = this.pluginCallbacks[ i ]( parser );
482
+
483
+ if ( ! plugin.name ) console.error( 'THREE.GLTFLoader: Invalid plugin found: missing name' );
484
+
485
+ plugins[ plugin.name ] = plugin;
486
+
487
+ // Workaround to avoid determining as unknown extension
488
+ // in addUnknownExtensionsToUserData().
489
+ // Remove this workaround if we move all the existing
490
+ // extension handlers to plugin system
491
+ extensions[ plugin.name ] = true;
492
+
493
+ }
494
+
495
+ if ( json.extensionsUsed ) {
496
+
497
+ for ( let i = 0; i < json.extensionsUsed.length; ++ i ) {
498
+
499
+ const extensionName = json.extensionsUsed[ i ];
500
+ const extensionsRequired = json.extensionsRequired || [];
501
+
502
+ switch ( extensionName ) {
503
+
504
+ case EXTENSIONS.KHR_MATERIALS_UNLIT:
505
+ extensions[ extensionName ] = new GLTFMaterialsUnlitExtension();
506
+ break;
507
+
508
+ case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
509
+ extensions[ extensionName ] = new GLTFDracoMeshCompressionExtension( json, this.dracoLoader );
510
+ break;
511
+
512
+ case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
513
+ extensions[ extensionName ] = new GLTFTextureTransformExtension();
514
+ break;
515
+
516
+ case EXTENSIONS.KHR_MESH_QUANTIZATION:
517
+ extensions[ extensionName ] = new GLTFMeshQuantizationExtension();
518
+ break;
519
+
520
+ default:
521
+
522
+ if ( extensionsRequired.indexOf( extensionName ) >= 0 && plugins[ extensionName ] === undefined ) {
523
+
524
+ console.warn( 'THREE.GLTFLoader: Unknown extension "' + extensionName + '".' );
525
+
526
+ }
527
+
528
+ }
529
+
530
+ }
531
+
532
+ }
533
+
534
+ parser.setExtensions( extensions );
535
+ parser.setPlugins( plugins );
536
+ parser.parse( onLoad, onError );
537
+
538
+ }
539
+
540
+ /**
541
+ * Async version of {@link GLTFLoader#parse}.
542
+ *
543
+ * @async
544
+ * @param {string|ArrayBuffer} data - The raw glTF data.
545
+ * @param {string} path - The URL base path.
546
+ * @return {Promise<GLTFLoader~LoadObject>} A Promise that resolves with the loaded glTF when the parsing has been finished.
547
+ */
548
+ parseAsync( data, path ) {
549
+
550
+ const scope = this;
551
+
552
+ return new Promise( function ( resolve, reject ) {
553
+
554
+ scope.parse( data, path, resolve, reject );
555
+
556
+ } );
557
+
558
+ }
559
+
560
+ }
561
+
562
+ /* GLTFREGISTRY */
563
+
564
+ function GLTFRegistry() {
565
+
566
+ let objects = {};
567
+
568
+ return {
569
+
570
+ get: function ( key ) {
571
+
572
+ return objects[ key ];
573
+
574
+ },
575
+
576
+ add: function ( key, object ) {
577
+
578
+ objects[ key ] = object;
579
+
580
+ },
581
+
582
+ remove: function ( key ) {
583
+
584
+ delete objects[ key ];
585
+
586
+ },
587
+
588
+ removeAll: function () {
589
+
590
+ objects = {};
591
+
592
+ }
593
+
594
+ };
595
+
596
+ }
597
+
598
+ /*********************************/
599
+ /********** EXTENSIONS ***********/
600
+ /*********************************/
601
+
602
+ const EXTENSIONS = {
603
+ KHR_BINARY_GLTF: 'KHR_binary_glTF',
604
+ KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',
605
+ KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual',
606
+ KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
607
+ KHR_MATERIALS_DISPERSION: 'KHR_materials_dispersion',
608
+ KHR_MATERIALS_IOR: 'KHR_materials_ior',
609
+ KHR_MATERIALS_SHEEN: 'KHR_materials_sheen',
610
+ KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
611
+ KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
612
+ KHR_MATERIALS_IRIDESCENCE: 'KHR_materials_iridescence',
613
+ KHR_MATERIALS_ANISOTROPY: 'KHR_materials_anisotropy',
614
+ KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
615
+ KHR_MATERIALS_VOLUME: 'KHR_materials_volume',
616
+ KHR_TEXTURE_BASISU: 'KHR_texture_basisu',
617
+ KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform',
618
+ KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization',
619
+ KHR_MATERIALS_EMISSIVE_STRENGTH: 'KHR_materials_emissive_strength',
620
+ EXT_MATERIALS_BUMP: 'EXT_materials_bump',
621
+ EXT_TEXTURE_WEBP: 'EXT_texture_webp',
622
+ EXT_TEXTURE_AVIF: 'EXT_texture_avif',
623
+ EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression',
624
+ EXT_MESH_GPU_INSTANCING: 'EXT_mesh_gpu_instancing'
625
+ };
626
+
627
+ /**
628
+ * Punctual Lights Extension
629
+ *
630
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
631
+ *
632
+ * @private
633
+ */
634
+ class GLTFLightsExtension {
635
+
636
+ constructor( parser ) {
637
+
638
+ this.parser = parser;
639
+ this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL;
640
+
641
+ // Object3D instance caches
642
+ this.cache = { refs: {}, uses: {} };
643
+
644
+ }
645
+
646
+ _markDefs() {
647
+
648
+ const parser = this.parser;
649
+ const nodeDefs = this.parser.json.nodes || [];
650
+
651
+ for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) {
652
+
653
+ const nodeDef = nodeDefs[ nodeIndex ];
654
+
655
+ if ( nodeDef.extensions
656
+ && nodeDef.extensions[ this.name ]
657
+ && nodeDef.extensions[ this.name ].light !== undefined ) {
658
+
659
+ parser._addNodeRef( this.cache, nodeDef.extensions[ this.name ].light );
660
+
661
+ }
662
+
663
+ }
664
+
665
+ }
666
+
667
+ _loadLight( lightIndex ) {
668
+
669
+ const parser = this.parser;
670
+ const cacheKey = 'light:' + lightIndex;
671
+ let dependency = parser.cache.get( cacheKey );
672
+
673
+ if ( dependency ) return dependency;
674
+
675
+ const json = parser.json;
676
+ const extensions = ( json.extensions && json.extensions[ this.name ] ) || {};
677
+ const lightDefs = extensions.lights || [];
678
+ const lightDef = lightDefs[ lightIndex ];
679
+ let lightNode;
680
+
681
+ const color = new Color( 0xffffff );
682
+
683
+ if ( lightDef.color !== undefined ) color.setRGB( lightDef.color[ 0 ], lightDef.color[ 1 ], lightDef.color[ 2 ], LinearSRGBColorSpace );
684
+
685
+ const range = lightDef.range !== undefined ? lightDef.range : 0;
686
+
687
+ switch ( lightDef.type ) {
688
+
689
+ case 'directional':
690
+ lightNode = new DirectionalLight( color );
691
+ lightNode.target.position.set( 0, 0, - 1 );
692
+ lightNode.add( lightNode.target );
693
+ break;
694
+
695
+ case 'point':
696
+ lightNode = new PointLight( color );
697
+ lightNode.distance = range;
698
+ break;
699
+
700
+ case 'spot':
701
+ lightNode = new SpotLight( color );
702
+ lightNode.distance = range;
703
+ // Handle spotlight properties.
704
+ lightDef.spot = lightDef.spot || {};
705
+ lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== undefined ? lightDef.spot.innerConeAngle : 0;
706
+ lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== undefined ? lightDef.spot.outerConeAngle : Math.PI / 4.0;
707
+ lightNode.angle = lightDef.spot.outerConeAngle;
708
+ lightNode.penumbra = 1.0 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle;
709
+ lightNode.target.position.set( 0, 0, - 1 );
710
+ lightNode.add( lightNode.target );
711
+ break;
712
+
713
+ default:
714
+ throw new Error( 'THREE.GLTFLoader: Unexpected light type: ' + lightDef.type );
715
+
716
+ }
717
+
718
+ // Some lights (e.g. spot) default to a position other than the origin. Reset the position
719
+ // here, because node-level parsing will only override position if explicitly specified.
720
+ lightNode.position.set( 0, 0, 0 );
721
+
722
+ assignExtrasToUserData( lightNode, lightDef );
723
+
724
+ if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity;
725
+
726
+ lightNode.name = parser.createUniqueName( lightDef.name || ( 'light_' + lightIndex ) );
727
+
728
+ dependency = Promise.resolve( lightNode );
729
+
730
+ parser.cache.add( cacheKey, dependency );
731
+
732
+ return dependency;
733
+
734
+ }
735
+
736
+ getDependency( type, index ) {
737
+
738
+ if ( type !== 'light' ) return;
739
+
740
+ return this._loadLight( index );
741
+
742
+ }
743
+
744
+ createNodeAttachment( nodeIndex ) {
745
+
746
+ const self = this;
747
+ const parser = this.parser;
748
+ const json = parser.json;
749
+ const nodeDef = json.nodes[ nodeIndex ];
750
+ const lightDef = ( nodeDef.extensions && nodeDef.extensions[ this.name ] ) || {};
751
+ const lightIndex = lightDef.light;
752
+
753
+ if ( lightIndex === undefined ) return null;
754
+
755
+ return this._loadLight( lightIndex ).then( function ( light ) {
756
+
757
+ return parser._getNodeRef( self.cache, lightIndex, light );
758
+
759
+ } );
760
+
761
+ }
762
+
763
+ }
764
+
765
+ /**
766
+ * Unlit Materials Extension
767
+ *
768
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
769
+ *
770
+ * @private
771
+ */
772
+ class GLTFMaterialsUnlitExtension {
773
+
774
+ constructor() {
775
+
776
+ this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
777
+
778
+ }
779
+
780
+ getMaterialType() {
781
+
782
+ return MeshBasicMaterial;
783
+
784
+ }
785
+
786
+ extendParams( materialParams, materialDef, parser ) {
787
+
788
+ const pending = [];
789
+
790
+ materialParams.color = new Color( 1.0, 1.0, 1.0 );
791
+ materialParams.opacity = 1.0;
792
+
793
+ const metallicRoughness = materialDef.pbrMetallicRoughness;
794
+
795
+ if ( metallicRoughness ) {
796
+
797
+ if ( Array.isArray( metallicRoughness.baseColorFactor ) ) {
798
+
799
+ const array = metallicRoughness.baseColorFactor;
800
+
801
+ materialParams.color.setRGB( array[ 0 ], array[ 1 ], array[ 2 ], LinearSRGBColorSpace );
802
+ materialParams.opacity = array[ 3 ];
803
+
804
+ }
805
+
806
+ if ( metallicRoughness.baseColorTexture !== undefined ) {
807
+
808
+ pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, SRGBColorSpace ) );
809
+
810
+ }
811
+
812
+ }
813
+
814
+ return Promise.all( pending );
815
+
816
+ }
817
+
818
+ }
819
+
820
+ /**
821
+ * Materials Emissive Strength Extension
822
+ *
823
+ * Specification: https://github.com/KhronosGroup/glTF/blob/5768b3ce0ef32bc39cdf1bef10b948586635ead3/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md
824
+ *
825
+ * @private
826
+ */
827
+ class GLTFMaterialsEmissiveStrengthExtension {
828
+
829
+ constructor( parser ) {
830
+
831
+ this.parser = parser;
832
+ this.name = EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH;
833
+
834
+ }
835
+
836
+ extendMaterialParams( materialIndex, materialParams ) {
837
+
838
+ const parser = this.parser;
839
+ const materialDef = parser.json.materials[ materialIndex ];
840
+
841
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
842
+
843
+ return Promise.resolve();
844
+
845
+ }
846
+
847
+ const emissiveStrength = materialDef.extensions[ this.name ].emissiveStrength;
848
+
849
+ if ( emissiveStrength !== undefined ) {
850
+
851
+ materialParams.emissiveIntensity = emissiveStrength;
852
+
853
+ }
854
+
855
+ return Promise.resolve();
856
+
857
+ }
858
+
859
+ }
860
+
861
+ /**
862
+ * Clearcoat Materials Extension
863
+ *
864
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
865
+ *
866
+ * @private
867
+ */
868
+ class GLTFMaterialsClearcoatExtension {
869
+
870
+ constructor( parser ) {
871
+
872
+ this.parser = parser;
873
+ this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT;
874
+
875
+ }
876
+
877
+ getMaterialType( materialIndex ) {
878
+
879
+ const parser = this.parser;
880
+ const materialDef = parser.json.materials[ materialIndex ];
881
+
882
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
883
+
884
+ return MeshPhysicalMaterial;
885
+
886
+ }
887
+
888
+ extendMaterialParams( materialIndex, materialParams ) {
889
+
890
+ const parser = this.parser;
891
+ const materialDef = parser.json.materials[ materialIndex ];
892
+
893
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
894
+
895
+ return Promise.resolve();
896
+
897
+ }
898
+
899
+ const pending = [];
900
+
901
+ const extension = materialDef.extensions[ this.name ];
902
+
903
+ if ( extension.clearcoatFactor !== undefined ) {
904
+
905
+ materialParams.clearcoat = extension.clearcoatFactor;
906
+
907
+ }
908
+
909
+ if ( extension.clearcoatTexture !== undefined ) {
910
+
911
+ pending.push( parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) );
912
+
913
+ }
914
+
915
+ if ( extension.clearcoatRoughnessFactor !== undefined ) {
916
+
917
+ materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor;
918
+
919
+ }
920
+
921
+ if ( extension.clearcoatRoughnessTexture !== undefined ) {
922
+
923
+ pending.push( parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) );
924
+
925
+ }
926
+
927
+ if ( extension.clearcoatNormalTexture !== undefined ) {
928
+
929
+ pending.push( parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) );
930
+
931
+ if ( extension.clearcoatNormalTexture.scale !== undefined ) {
932
+
933
+ const scale = extension.clearcoatNormalTexture.scale;
934
+
935
+ materialParams.clearcoatNormalScale = new Vector2( scale, scale );
936
+
937
+ }
938
+
939
+ }
940
+
941
+ return Promise.all( pending );
942
+
943
+ }
944
+
945
+ }
946
+
947
+ /**
948
+ * Materials dispersion Extension
949
+ *
950
+ * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_dispersion
951
+ *
952
+ * @private
953
+ */
954
+ class GLTFMaterialsDispersionExtension {
955
+
956
+ constructor( parser ) {
957
+
958
+ this.parser = parser;
959
+ this.name = EXTENSIONS.KHR_MATERIALS_DISPERSION;
960
+
961
+ }
962
+
963
+ getMaterialType( materialIndex ) {
964
+
965
+ const parser = this.parser;
966
+ const materialDef = parser.json.materials[ materialIndex ];
967
+
968
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
969
+
970
+ return MeshPhysicalMaterial;
971
+
972
+ }
973
+
974
+ extendMaterialParams( materialIndex, materialParams ) {
975
+
976
+ const parser = this.parser;
977
+ const materialDef = parser.json.materials[ materialIndex ];
978
+
979
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
980
+
981
+ return Promise.resolve();
982
+
983
+ }
984
+
985
+ const extension = materialDef.extensions[ this.name ];
986
+
987
+ materialParams.dispersion = extension.dispersion !== undefined ? extension.dispersion : 0;
988
+
989
+ return Promise.resolve();
990
+
991
+ }
992
+
993
+ }
994
+
995
+ /**
996
+ * Iridescence Materials Extension
997
+ *
998
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_iridescence
999
+ *
1000
+ * @private
1001
+ */
1002
+ class GLTFMaterialsIridescenceExtension {
1003
+
1004
+ constructor( parser ) {
1005
+
1006
+ this.parser = parser;
1007
+ this.name = EXTENSIONS.KHR_MATERIALS_IRIDESCENCE;
1008
+
1009
+ }
1010
+
1011
+ getMaterialType( materialIndex ) {
1012
+
1013
+ const parser = this.parser;
1014
+ const materialDef = parser.json.materials[ materialIndex ];
1015
+
1016
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1017
+
1018
+ return MeshPhysicalMaterial;
1019
+
1020
+ }
1021
+
1022
+ extendMaterialParams( materialIndex, materialParams ) {
1023
+
1024
+ const parser = this.parser;
1025
+ const materialDef = parser.json.materials[ materialIndex ];
1026
+
1027
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1028
+
1029
+ return Promise.resolve();
1030
+
1031
+ }
1032
+
1033
+ const pending = [];
1034
+
1035
+ const extension = materialDef.extensions[ this.name ];
1036
+
1037
+ if ( extension.iridescenceFactor !== undefined ) {
1038
+
1039
+ materialParams.iridescence = extension.iridescenceFactor;
1040
+
1041
+ }
1042
+
1043
+ if ( extension.iridescenceTexture !== undefined ) {
1044
+
1045
+ pending.push( parser.assignTexture( materialParams, 'iridescenceMap', extension.iridescenceTexture ) );
1046
+
1047
+ }
1048
+
1049
+ if ( extension.iridescenceIor !== undefined ) {
1050
+
1051
+ materialParams.iridescenceIOR = extension.iridescenceIor;
1052
+
1053
+ }
1054
+
1055
+ if ( materialParams.iridescenceThicknessRange === undefined ) {
1056
+
1057
+ materialParams.iridescenceThicknessRange = [ 100, 400 ];
1058
+
1059
+ }
1060
+
1061
+ if ( extension.iridescenceThicknessMinimum !== undefined ) {
1062
+
1063
+ materialParams.iridescenceThicknessRange[ 0 ] = extension.iridescenceThicknessMinimum;
1064
+
1065
+ }
1066
+
1067
+ if ( extension.iridescenceThicknessMaximum !== undefined ) {
1068
+
1069
+ materialParams.iridescenceThicknessRange[ 1 ] = extension.iridescenceThicknessMaximum;
1070
+
1071
+ }
1072
+
1073
+ if ( extension.iridescenceThicknessTexture !== undefined ) {
1074
+
1075
+ pending.push( parser.assignTexture( materialParams, 'iridescenceThicknessMap', extension.iridescenceThicknessTexture ) );
1076
+
1077
+ }
1078
+
1079
+ return Promise.all( pending );
1080
+
1081
+ }
1082
+
1083
+ }
1084
+
1085
+ /**
1086
+ * Sheen Materials Extension
1087
+ *
1088
+ * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen
1089
+ *
1090
+ * @private
1091
+ */
1092
+ class GLTFMaterialsSheenExtension {
1093
+
1094
+ constructor( parser ) {
1095
+
1096
+ this.parser = parser;
1097
+ this.name = EXTENSIONS.KHR_MATERIALS_SHEEN;
1098
+
1099
+ }
1100
+
1101
+ getMaterialType( materialIndex ) {
1102
+
1103
+ const parser = this.parser;
1104
+ const materialDef = parser.json.materials[ materialIndex ];
1105
+
1106
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1107
+
1108
+ return MeshPhysicalMaterial;
1109
+
1110
+ }
1111
+
1112
+ extendMaterialParams( materialIndex, materialParams ) {
1113
+
1114
+ const parser = this.parser;
1115
+ const materialDef = parser.json.materials[ materialIndex ];
1116
+
1117
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1118
+
1119
+ return Promise.resolve();
1120
+
1121
+ }
1122
+
1123
+ const pending = [];
1124
+
1125
+ materialParams.sheenColor = new Color( 0, 0, 0 );
1126
+ materialParams.sheenRoughness = 0;
1127
+ materialParams.sheen = 1;
1128
+
1129
+ const extension = materialDef.extensions[ this.name ];
1130
+
1131
+ if ( extension.sheenColorFactor !== undefined ) {
1132
+
1133
+ const colorFactor = extension.sheenColorFactor;
1134
+ materialParams.sheenColor.setRGB( colorFactor[ 0 ], colorFactor[ 1 ], colorFactor[ 2 ], LinearSRGBColorSpace );
1135
+
1136
+ }
1137
+
1138
+ if ( extension.sheenRoughnessFactor !== undefined ) {
1139
+
1140
+ materialParams.sheenRoughness = extension.sheenRoughnessFactor;
1141
+
1142
+ }
1143
+
1144
+ if ( extension.sheenColorTexture !== undefined ) {
1145
+
1146
+ pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, SRGBColorSpace ) );
1147
+
1148
+ }
1149
+
1150
+ if ( extension.sheenRoughnessTexture !== undefined ) {
1151
+
1152
+ pending.push( parser.assignTexture( materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture ) );
1153
+
1154
+ }
1155
+
1156
+ return Promise.all( pending );
1157
+
1158
+ }
1159
+
1160
+ }
1161
+
1162
+ /**
1163
+ * Transmission Materials Extension
1164
+ *
1165
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
1166
+ * Draft: https://github.com/KhronosGroup/glTF/pull/1698
1167
+ *
1168
+ * @private
1169
+ */
1170
+ class GLTFMaterialsTransmissionExtension {
1171
+
1172
+ constructor( parser ) {
1173
+
1174
+ this.parser = parser;
1175
+ this.name = EXTENSIONS.KHR_MATERIALS_TRANSMISSION;
1176
+
1177
+ }
1178
+
1179
+ getMaterialType( materialIndex ) {
1180
+
1181
+ const parser = this.parser;
1182
+ const materialDef = parser.json.materials[ materialIndex ];
1183
+
1184
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1185
+
1186
+ return MeshPhysicalMaterial;
1187
+
1188
+ }
1189
+
1190
+ extendMaterialParams( materialIndex, materialParams ) {
1191
+
1192
+ const parser = this.parser;
1193
+ const materialDef = parser.json.materials[ materialIndex ];
1194
+
1195
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1196
+
1197
+ return Promise.resolve();
1198
+
1199
+ }
1200
+
1201
+ const pending = [];
1202
+
1203
+ const extension = materialDef.extensions[ this.name ];
1204
+
1205
+ if ( extension.transmissionFactor !== undefined ) {
1206
+
1207
+ materialParams.transmission = extension.transmissionFactor;
1208
+
1209
+ }
1210
+
1211
+ if ( extension.transmissionTexture !== undefined ) {
1212
+
1213
+ pending.push( parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) );
1214
+
1215
+ }
1216
+
1217
+ return Promise.all( pending );
1218
+
1219
+ }
1220
+
1221
+ }
1222
+
1223
+ /**
1224
+ * Materials Volume Extension
1225
+ *
1226
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume
1227
+ *
1228
+ * @private
1229
+ */
1230
+ class GLTFMaterialsVolumeExtension {
1231
+
1232
+ constructor( parser ) {
1233
+
1234
+ this.parser = parser;
1235
+ this.name = EXTENSIONS.KHR_MATERIALS_VOLUME;
1236
+
1237
+ }
1238
+
1239
+ getMaterialType( materialIndex ) {
1240
+
1241
+ const parser = this.parser;
1242
+ const materialDef = parser.json.materials[ materialIndex ];
1243
+
1244
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1245
+
1246
+ return MeshPhysicalMaterial;
1247
+
1248
+ }
1249
+
1250
+ extendMaterialParams( materialIndex, materialParams ) {
1251
+
1252
+ const parser = this.parser;
1253
+ const materialDef = parser.json.materials[ materialIndex ];
1254
+
1255
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1256
+
1257
+ return Promise.resolve();
1258
+
1259
+ }
1260
+
1261
+ const pending = [];
1262
+
1263
+ const extension = materialDef.extensions[ this.name ];
1264
+
1265
+ materialParams.thickness = extension.thicknessFactor !== undefined ? extension.thicknessFactor : 0;
1266
+
1267
+ if ( extension.thicknessTexture !== undefined ) {
1268
+
1269
+ pending.push( parser.assignTexture( materialParams, 'thicknessMap', extension.thicknessTexture ) );
1270
+
1271
+ }
1272
+
1273
+ materialParams.attenuationDistance = extension.attenuationDistance || Infinity;
1274
+
1275
+ const colorArray = extension.attenuationColor || [ 1, 1, 1 ];
1276
+ materialParams.attenuationColor = new Color().setRGB( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ], LinearSRGBColorSpace );
1277
+
1278
+ return Promise.all( pending );
1279
+
1280
+ }
1281
+
1282
+ }
1283
+
1284
+ /**
1285
+ * Materials ior Extension
1286
+ *
1287
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior
1288
+ *
1289
+ * @private
1290
+ */
1291
+ class GLTFMaterialsIorExtension {
1292
+
1293
+ constructor( parser ) {
1294
+
1295
+ this.parser = parser;
1296
+ this.name = EXTENSIONS.KHR_MATERIALS_IOR;
1297
+
1298
+ }
1299
+
1300
+ getMaterialType( materialIndex ) {
1301
+
1302
+ const parser = this.parser;
1303
+ const materialDef = parser.json.materials[ materialIndex ];
1304
+
1305
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1306
+
1307
+ return MeshPhysicalMaterial;
1308
+
1309
+ }
1310
+
1311
+ extendMaterialParams( materialIndex, materialParams ) {
1312
+
1313
+ const parser = this.parser;
1314
+ const materialDef = parser.json.materials[ materialIndex ];
1315
+
1316
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1317
+
1318
+ return Promise.resolve();
1319
+
1320
+ }
1321
+
1322
+ const extension = materialDef.extensions[ this.name ];
1323
+
1324
+ materialParams.ior = extension.ior !== undefined ? extension.ior : 1.5;
1325
+
1326
+ return Promise.resolve();
1327
+
1328
+ }
1329
+
1330
+ }
1331
+
1332
+ /**
1333
+ * Materials specular Extension
1334
+ *
1335
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular
1336
+ *
1337
+ * @private
1338
+ */
1339
+ class GLTFMaterialsSpecularExtension {
1340
+
1341
+ constructor( parser ) {
1342
+
1343
+ this.parser = parser;
1344
+ this.name = EXTENSIONS.KHR_MATERIALS_SPECULAR;
1345
+
1346
+ }
1347
+
1348
+ getMaterialType( materialIndex ) {
1349
+
1350
+ const parser = this.parser;
1351
+ const materialDef = parser.json.materials[ materialIndex ];
1352
+
1353
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1354
+
1355
+ return MeshPhysicalMaterial;
1356
+
1357
+ }
1358
+
1359
+ extendMaterialParams( materialIndex, materialParams ) {
1360
+
1361
+ const parser = this.parser;
1362
+ const materialDef = parser.json.materials[ materialIndex ];
1363
+
1364
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1365
+
1366
+ return Promise.resolve();
1367
+
1368
+ }
1369
+
1370
+ const pending = [];
1371
+
1372
+ const extension = materialDef.extensions[ this.name ];
1373
+
1374
+ materialParams.specularIntensity = extension.specularFactor !== undefined ? extension.specularFactor : 1.0;
1375
+
1376
+ if ( extension.specularTexture !== undefined ) {
1377
+
1378
+ pending.push( parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) );
1379
+
1380
+ }
1381
+
1382
+ const colorArray = extension.specularColorFactor || [ 1, 1, 1 ];
1383
+ materialParams.specularColor = new Color().setRGB( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ], LinearSRGBColorSpace );
1384
+
1385
+ if ( extension.specularColorTexture !== undefined ) {
1386
+
1387
+ pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, SRGBColorSpace ) );
1388
+
1389
+ }
1390
+
1391
+ return Promise.all( pending );
1392
+
1393
+ }
1394
+
1395
+ }
1396
+
1397
+
1398
+ /**
1399
+ * Materials bump Extension
1400
+ *
1401
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/EXT_materials_bump
1402
+ *
1403
+ * @private
1404
+ */
1405
+ class GLTFMaterialsBumpExtension {
1406
+
1407
+ constructor( parser ) {
1408
+
1409
+ this.parser = parser;
1410
+ this.name = EXTENSIONS.EXT_MATERIALS_BUMP;
1411
+
1412
+ }
1413
+
1414
+ getMaterialType( materialIndex ) {
1415
+
1416
+ const parser = this.parser;
1417
+ const materialDef = parser.json.materials[ materialIndex ];
1418
+
1419
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1420
+
1421
+ return MeshPhysicalMaterial;
1422
+
1423
+ }
1424
+
1425
+ extendMaterialParams( materialIndex, materialParams ) {
1426
+
1427
+ const parser = this.parser;
1428
+ const materialDef = parser.json.materials[ materialIndex ];
1429
+
1430
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1431
+
1432
+ return Promise.resolve();
1433
+
1434
+ }
1435
+
1436
+ const pending = [];
1437
+
1438
+ const extension = materialDef.extensions[ this.name ];
1439
+
1440
+ materialParams.bumpScale = extension.bumpFactor !== undefined ? extension.bumpFactor : 1.0;
1441
+
1442
+ if ( extension.bumpTexture !== undefined ) {
1443
+
1444
+ pending.push( parser.assignTexture( materialParams, 'bumpMap', extension.bumpTexture ) );
1445
+
1446
+ }
1447
+
1448
+ return Promise.all( pending );
1449
+
1450
+ }
1451
+
1452
+ }
1453
+
1454
+ /**
1455
+ * Materials anisotropy Extension
1456
+ *
1457
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_anisotropy
1458
+ *
1459
+ * @private
1460
+ */
1461
+ class GLTFMaterialsAnisotropyExtension {
1462
+
1463
+ constructor( parser ) {
1464
+
1465
+ this.parser = parser;
1466
+ this.name = EXTENSIONS.KHR_MATERIALS_ANISOTROPY;
1467
+
1468
+ }
1469
+
1470
+ getMaterialType( materialIndex ) {
1471
+
1472
+ const parser = this.parser;
1473
+ const materialDef = parser.json.materials[ materialIndex ];
1474
+
1475
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1476
+
1477
+ return MeshPhysicalMaterial;
1478
+
1479
+ }
1480
+
1481
+ extendMaterialParams( materialIndex, materialParams ) {
1482
+
1483
+ const parser = this.parser;
1484
+ const materialDef = parser.json.materials[ materialIndex ];
1485
+
1486
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1487
+
1488
+ return Promise.resolve();
1489
+
1490
+ }
1491
+
1492
+ const pending = [];
1493
+
1494
+ const extension = materialDef.extensions[ this.name ];
1495
+
1496
+ if ( extension.anisotropyStrength !== undefined ) {
1497
+
1498
+ materialParams.anisotropy = extension.anisotropyStrength;
1499
+
1500
+ }
1501
+
1502
+ if ( extension.anisotropyRotation !== undefined ) {
1503
+
1504
+ materialParams.anisotropyRotation = extension.anisotropyRotation;
1505
+
1506
+ }
1507
+
1508
+ if ( extension.anisotropyTexture !== undefined ) {
1509
+
1510
+ pending.push( parser.assignTexture( materialParams, 'anisotropyMap', extension.anisotropyTexture ) );
1511
+
1512
+ }
1513
+
1514
+ return Promise.all( pending );
1515
+
1516
+ }
1517
+
1518
+ }
1519
+
1520
+ /**
1521
+ * BasisU Texture Extension
1522
+ *
1523
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
1524
+ *
1525
+ * @private
1526
+ */
1527
+ class GLTFTextureBasisUExtension {
1528
+
1529
+ constructor( parser ) {
1530
+
1531
+ this.parser = parser;
1532
+ this.name = EXTENSIONS.KHR_TEXTURE_BASISU;
1533
+
1534
+ }
1535
+
1536
+ loadTexture( textureIndex ) {
1537
+
1538
+ const parser = this.parser;
1539
+ const json = parser.json;
1540
+
1541
+ const textureDef = json.textures[ textureIndex ];
1542
+
1543
+ if ( ! textureDef.extensions || ! textureDef.extensions[ this.name ] ) {
1544
+
1545
+ return null;
1546
+
1547
+ }
1548
+
1549
+ const extension = textureDef.extensions[ this.name ];
1550
+ const loader = parser.options.ktx2Loader;
1551
+
1552
+ if ( ! loader ) {
1553
+
1554
+ if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) {
1555
+
1556
+ throw new Error( 'THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures' );
1557
+
1558
+ } else {
1559
+
1560
+ // Assumes that the extension is optional and that a fallback texture is present
1561
+ return null;
1562
+
1563
+ }
1564
+
1565
+ }
1566
+
1567
+ return parser.loadTextureImage( textureIndex, extension.source, loader );
1568
+
1569
+ }
1570
+
1571
+ }
1572
+
1573
+ /**
1574
+ * WebP Texture Extension
1575
+ *
1576
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp
1577
+ *
1578
+ * @private
1579
+ */
1580
+ class GLTFTextureWebPExtension {
1581
+
1582
+ constructor( parser ) {
1583
+
1584
+ this.parser = parser;
1585
+ this.name = EXTENSIONS.EXT_TEXTURE_WEBP;
1586
+
1587
+ }
1588
+
1589
+ loadTexture( textureIndex ) {
1590
+
1591
+ const name = this.name;
1592
+ const parser = this.parser;
1593
+ const json = parser.json;
1594
+
1595
+ const textureDef = json.textures[ textureIndex ];
1596
+
1597
+ if ( ! textureDef.extensions || ! textureDef.extensions[ name ] ) {
1598
+
1599
+ return null;
1600
+
1601
+ }
1602
+
1603
+ const extension = textureDef.extensions[ name ];
1604
+ const source = json.images[ extension.source ];
1605
+
1606
+ let loader = parser.textureLoader;
1607
+ if ( source.uri ) {
1608
+
1609
+ const handler = parser.options.manager.getHandler( source.uri );
1610
+ if ( handler !== null ) loader = handler;
1611
+
1612
+ }
1613
+
1614
+ return parser.loadTextureImage( textureIndex, extension.source, loader );
1615
+
1616
+ }
1617
+
1618
+ }
1619
+
1620
+ /**
1621
+ * AVIF Texture Extension
1622
+ *
1623
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_avif
1624
+ *
1625
+ * @private
1626
+ */
1627
+ class GLTFTextureAVIFExtension {
1628
+
1629
+ constructor( parser ) {
1630
+
1631
+ this.parser = parser;
1632
+ this.name = EXTENSIONS.EXT_TEXTURE_AVIF;
1633
+
1634
+ }
1635
+
1636
+ loadTexture( textureIndex ) {
1637
+
1638
+ const name = this.name;
1639
+ const parser = this.parser;
1640
+ const json = parser.json;
1641
+
1642
+ const textureDef = json.textures[ textureIndex ];
1643
+
1644
+ if ( ! textureDef.extensions || ! textureDef.extensions[ name ] ) {
1645
+
1646
+ return null;
1647
+
1648
+ }
1649
+
1650
+ const extension = textureDef.extensions[ name ];
1651
+ const source = json.images[ extension.source ];
1652
+
1653
+ let loader = parser.textureLoader;
1654
+ if ( source.uri ) {
1655
+
1656
+ const handler = parser.options.manager.getHandler( source.uri );
1657
+ if ( handler !== null ) loader = handler;
1658
+
1659
+ }
1660
+
1661
+ return parser.loadTextureImage( textureIndex, extension.source, loader );
1662
+
1663
+ }
1664
+
1665
+ }
1666
+
1667
+ /**
1668
+ * meshopt BufferView Compression Extension
1669
+ *
1670
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression
1671
+ *
1672
+ * @private
1673
+ */
1674
+ class GLTFMeshoptCompression {
1675
+
1676
+ constructor( parser ) {
1677
+
1678
+ this.name = EXTENSIONS.EXT_MESHOPT_COMPRESSION;
1679
+ this.parser = parser;
1680
+
1681
+ }
1682
+
1683
+ loadBufferView( index ) {
1684
+
1685
+ const json = this.parser.json;
1686
+ const bufferView = json.bufferViews[ index ];
1687
+
1688
+ if ( bufferView.extensions && bufferView.extensions[ this.name ] ) {
1689
+
1690
+ const extensionDef = bufferView.extensions[ this.name ];
1691
+
1692
+ const buffer = this.parser.getDependency( 'buffer', extensionDef.buffer );
1693
+ const decoder = this.parser.options.meshoptDecoder;
1694
+
1695
+ if ( ! decoder || ! decoder.supported ) {
1696
+
1697
+ if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) {
1698
+
1699
+ throw new Error( 'THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files' );
1700
+
1701
+ } else {
1702
+
1703
+ // Assumes that the extension is optional and that fallback buffer data is present
1704
+ return null;
1705
+
1706
+ }
1707
+
1708
+ }
1709
+
1710
+ return buffer.then( function ( res ) {
1711
+
1712
+ const byteOffset = extensionDef.byteOffset || 0;
1713
+ const byteLength = extensionDef.byteLength || 0;
1714
+
1715
+ const count = extensionDef.count;
1716
+ const stride = extensionDef.byteStride;
1717
+
1718
+ const source = new Uint8Array( res, byteOffset, byteLength );
1719
+
1720
+ if ( decoder.decodeGltfBufferAsync ) {
1721
+
1722
+ return decoder.decodeGltfBufferAsync( count, stride, source, extensionDef.mode, extensionDef.filter ).then( function ( res ) {
1723
+
1724
+ return res.buffer;
1725
+
1726
+ } );
1727
+
1728
+ } else {
1729
+
1730
+ // Support for MeshoptDecoder 0.18 or earlier, without decodeGltfBufferAsync
1731
+ return decoder.ready.then( function () {
1732
+
1733
+ const result = new ArrayBuffer( count * stride );
1734
+ decoder.decodeGltfBuffer( new Uint8Array( result ), count, stride, source, extensionDef.mode, extensionDef.filter );
1735
+ return result;
1736
+
1737
+ } );
1738
+
1739
+ }
1740
+
1741
+ } );
1742
+
1743
+ } else {
1744
+
1745
+ return null;
1746
+
1747
+ }
1748
+
1749
+ }
1750
+
1751
+ }
1752
+
1753
+ /**
1754
+ * GPU Instancing Extension
1755
+ *
1756
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_mesh_gpu_instancing
1757
+ *
1758
+ * @private
1759
+ */
1760
+ class GLTFMeshGpuInstancing {
1761
+
1762
+ constructor( parser ) {
1763
+
1764
+ this.name = EXTENSIONS.EXT_MESH_GPU_INSTANCING;
1765
+ this.parser = parser;
1766
+
1767
+ }
1768
+
1769
+ createNodeMesh( nodeIndex ) {
1770
+
1771
+ const json = this.parser.json;
1772
+ const nodeDef = json.nodes[ nodeIndex ];
1773
+
1774
+ if ( ! nodeDef.extensions || ! nodeDef.extensions[ this.name ] ||
1775
+ nodeDef.mesh === undefined ) {
1776
+
1777
+ return null;
1778
+
1779
+ }
1780
+
1781
+ const meshDef = json.meshes[ nodeDef.mesh ];
1782
+
1783
+ // No Points or Lines + Instancing support yet
1784
+
1785
+ for ( const primitive of meshDef.primitives ) {
1786
+
1787
+ if ( primitive.mode !== WEBGL_CONSTANTS.TRIANGLES &&
1788
+ primitive.mode !== WEBGL_CONSTANTS.TRIANGLE_STRIP &&
1789
+ primitive.mode !== WEBGL_CONSTANTS.TRIANGLE_FAN &&
1790
+ primitive.mode !== undefined ) {
1791
+
1792
+ return null;
1793
+
1794
+ }
1795
+
1796
+ }
1797
+
1798
+ const extensionDef = nodeDef.extensions[ this.name ];
1799
+ const attributesDef = extensionDef.attributes;
1800
+
1801
+ // @TODO: Can we support InstancedMesh + SkinnedMesh?
1802
+
1803
+ const pending = [];
1804
+ const attributes = {};
1805
+
1806
+ for ( const key in attributesDef ) {
1807
+
1808
+ pending.push( this.parser.getDependency( 'accessor', attributesDef[ key ] ).then( accessor => {
1809
+
1810
+ attributes[ key ] = accessor;
1811
+ return attributes[ key ];
1812
+
1813
+ } ) );
1814
+
1815
+ }
1816
+
1817
+ if ( pending.length < 1 ) {
1818
+
1819
+ return null;
1820
+
1821
+ }
1822
+
1823
+ pending.push( this.parser.createNodeMesh( nodeIndex ) );
1824
+
1825
+ return Promise.all( pending ).then( results => {
1826
+
1827
+ const nodeObject = results.pop();
1828
+ const meshes = nodeObject.isGroup ? nodeObject.children : [ nodeObject ];
1829
+ const count = results[ 0 ].count; // All attribute counts should be same
1830
+ const instancedMeshes = [];
1831
+
1832
+ for ( const mesh of meshes ) {
1833
+
1834
+ // Temporal variables
1835
+ const m = new Matrix4();
1836
+ const p = new Vector3();
1837
+ const q = new Quaternion();
1838
+ const s = new Vector3( 1, 1, 1 );
1839
+
1840
+ const instancedMesh = new InstancedMesh( mesh.geometry, mesh.material, count );
1841
+
1842
+ for ( let i = 0; i < count; i ++ ) {
1843
+
1844
+ if ( attributes.TRANSLATION ) {
1845
+
1846
+ p.fromBufferAttribute( attributes.TRANSLATION, i );
1847
+
1848
+ }
1849
+
1850
+ if ( attributes.ROTATION ) {
1851
+
1852
+ q.fromBufferAttribute( attributes.ROTATION, i );
1853
+
1854
+ }
1855
+
1856
+ if ( attributes.SCALE ) {
1857
+
1858
+ s.fromBufferAttribute( attributes.SCALE, i );
1859
+
1860
+ }
1861
+
1862
+ instancedMesh.setMatrixAt( i, m.compose( p, q, s ) );
1863
+
1864
+ }
1865
+
1866
+ // Add instance attributes to the geometry, excluding TRS.
1867
+ for ( const attributeName in attributes ) {
1868
+
1869
+ if ( attributeName === '_COLOR_0' ) {
1870
+
1871
+ const attr = attributes[ attributeName ];
1872
+ instancedMesh.instanceColor = new InstancedBufferAttribute( attr.array, attr.itemSize, attr.normalized );
1873
+
1874
+ } else if ( attributeName !== 'TRANSLATION' &&
1875
+ attributeName !== 'ROTATION' &&
1876
+ attributeName !== 'SCALE' ) {
1877
+
1878
+ mesh.geometry.setAttribute( attributeName, attributes[ attributeName ] );
1879
+
1880
+ }
1881
+
1882
+ }
1883
+
1884
+ // Just in case
1885
+ Object3D.prototype.copy.call( instancedMesh, mesh );
1886
+
1887
+ this.parser.assignFinalMaterial( instancedMesh );
1888
+
1889
+ instancedMeshes.push( instancedMesh );
1890
+
1891
+ }
1892
+
1893
+ if ( nodeObject.isGroup ) {
1894
+
1895
+ nodeObject.clear();
1896
+
1897
+ nodeObject.add( ... instancedMeshes );
1898
+
1899
+ return nodeObject;
1900
+
1901
+ }
1902
+
1903
+ return instancedMeshes[ 0 ];
1904
+
1905
+ } );
1906
+
1907
+ }
1908
+
1909
+ }
1910
+
1911
+ /* BINARY EXTENSION */
1912
+ const BINARY_EXTENSION_HEADER_MAGIC = 'glTF';
1913
+ const BINARY_EXTENSION_HEADER_LENGTH = 12;
1914
+ const BINARY_EXTENSION_CHUNK_TYPES = { JSON: 0x4E4F534A, BIN: 0x004E4942 };
1915
+
1916
+ class GLTFBinaryExtension {
1917
+
1918
+ constructor( data ) {
1919
+
1920
+ this.name = EXTENSIONS.KHR_BINARY_GLTF;
1921
+ this.content = null;
1922
+ this.body = null;
1923
+
1924
+ const headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH );
1925
+ const textDecoder = new TextDecoder();
1926
+
1927
+ this.header = {
1928
+ magic: textDecoder.decode( new Uint8Array( data.slice( 0, 4 ) ) ),
1929
+ version: headerView.getUint32( 4, true ),
1930
+ length: headerView.getUint32( 8, true )
1931
+ };
1932
+
1933
+ if ( this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC ) {
1934
+
1935
+ throw new Error( 'THREE.GLTFLoader: Unsupported glTF-Binary header.' );
1936
+
1937
+ } else if ( this.header.version < 2.0 ) {
1938
+
1939
+ throw new Error( 'THREE.GLTFLoader: Legacy binary file detected.' );
1940
+
1941
+ }
1942
+
1943
+ const chunkContentsLength = this.header.length - BINARY_EXTENSION_HEADER_LENGTH;
1944
+ const chunkView = new DataView( data, BINARY_EXTENSION_HEADER_LENGTH );
1945
+ let chunkIndex = 0;
1946
+
1947
+ while ( chunkIndex < chunkContentsLength ) {
1948
+
1949
+ const chunkLength = chunkView.getUint32( chunkIndex, true );
1950
+ chunkIndex += 4;
1951
+
1952
+ const chunkType = chunkView.getUint32( chunkIndex, true );
1953
+ chunkIndex += 4;
1954
+
1955
+ if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON ) {
1956
+
1957
+ const contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength );
1958
+ this.content = textDecoder.decode( contentArray );
1959
+
1960
+ } else if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN ) {
1961
+
1962
+ const byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
1963
+ this.body = data.slice( byteOffset, byteOffset + chunkLength );
1964
+
1965
+ }
1966
+
1967
+ // Clients must ignore chunks with unknown types.
1968
+
1969
+ chunkIndex += chunkLength;
1970
+
1971
+ }
1972
+
1973
+ if ( this.content === null ) {
1974
+
1975
+ throw new Error( 'THREE.GLTFLoader: JSON content not found.' );
1976
+
1977
+ }
1978
+
1979
+ }
1980
+
1981
+ }
1982
+
1983
+ /**
1984
+ * DRACO Mesh Compression Extension
1985
+ *
1986
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
1987
+ *
1988
+ * @private
1989
+ */
1990
+ class GLTFDracoMeshCompressionExtension {
1991
+
1992
+ constructor( json, dracoLoader ) {
1993
+
1994
+ if ( ! dracoLoader ) {
1995
+
1996
+ throw new Error( 'THREE.GLTFLoader: No DRACOLoader instance provided.' );
1997
+
1998
+ }
1999
+
2000
+ this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;
2001
+ this.json = json;
2002
+ this.dracoLoader = dracoLoader;
2003
+ this.dracoLoader.preload();
2004
+
2005
+ }
2006
+
2007
+ decodePrimitive( primitive, parser ) {
2008
+
2009
+ const json = this.json;
2010
+ const dracoLoader = this.dracoLoader;
2011
+ const bufferViewIndex = primitive.extensions[ this.name ].bufferView;
2012
+ const gltfAttributeMap = primitive.extensions[ this.name ].attributes;
2013
+ const threeAttributeMap = {};
2014
+ const attributeNormalizedMap = {};
2015
+ const attributeTypeMap = {};
2016
+
2017
+ for ( const attributeName in gltfAttributeMap ) {
2018
+
2019
+ const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
2020
+
2021
+ threeAttributeMap[ threeAttributeName ] = gltfAttributeMap[ attributeName ];
2022
+
2023
+ }
2024
+
2025
+ for ( const attributeName in primitive.attributes ) {
2026
+
2027
+ const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
2028
+
2029
+ if ( gltfAttributeMap[ attributeName ] !== undefined ) {
2030
+
2031
+ const accessorDef = json.accessors[ primitive.attributes[ attributeName ] ];
2032
+ const componentType = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
2033
+
2034
+ attributeTypeMap[ threeAttributeName ] = componentType.name;
2035
+ attributeNormalizedMap[ threeAttributeName ] = accessorDef.normalized === true;
2036
+
2037
+ }
2038
+
2039
+ }
2040
+
2041
+ return parser.getDependency( 'bufferView', bufferViewIndex ).then( function ( bufferView ) {
2042
+
2043
+ return new Promise( function ( resolve, reject ) {
2044
+
2045
+ dracoLoader.decodeDracoFile( bufferView, function ( geometry ) {
2046
+
2047
+ for ( const attributeName in geometry.attributes ) {
2048
+
2049
+ const attribute = geometry.attributes[ attributeName ];
2050
+ const normalized = attributeNormalizedMap[ attributeName ];
2051
+
2052
+ if ( normalized !== undefined ) attribute.normalized = normalized;
2053
+
2054
+ }
2055
+
2056
+ resolve( geometry );
2057
+
2058
+ }, threeAttributeMap, attributeTypeMap, LinearSRGBColorSpace, reject );
2059
+
2060
+ } );
2061
+
2062
+ } );
2063
+
2064
+ }
2065
+
2066
+ }
2067
+
2068
+ /**
2069
+ * Texture Transform Extension
2070
+ *
2071
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
2072
+ *
2073
+ * @private
2074
+ */
2075
+ class GLTFTextureTransformExtension {
2076
+
2077
+ constructor() {
2078
+
2079
+ this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
2080
+
2081
+ }
2082
+
2083
+ extendTexture( texture, transform ) {
2084
+
2085
+ if ( ( transform.texCoord === undefined || transform.texCoord === texture.channel )
2086
+ && transform.offset === undefined
2087
+ && transform.rotation === undefined
2088
+ && transform.scale === undefined ) {
2089
+
2090
+ // See https://github.com/mrdoob/three.js/issues/21819.
2091
+ return texture;
2092
+
2093
+ }
2094
+
2095
+ texture = texture.clone();
2096
+
2097
+ if ( transform.texCoord !== undefined ) {
2098
+
2099
+ texture.channel = transform.texCoord;
2100
+
2101
+ }
2102
+
2103
+ if ( transform.offset !== undefined ) {
2104
+
2105
+ texture.offset.fromArray( transform.offset );
2106
+
2107
+ }
2108
+
2109
+ if ( transform.rotation !== undefined ) {
2110
+
2111
+ texture.rotation = transform.rotation;
2112
+
2113
+ }
2114
+
2115
+ if ( transform.scale !== undefined ) {
2116
+
2117
+ texture.repeat.fromArray( transform.scale );
2118
+
2119
+ }
2120
+
2121
+ texture.needsUpdate = true;
2122
+
2123
+ return texture;
2124
+
2125
+ }
2126
+
2127
+ }
2128
+
2129
+ /**
2130
+ * Mesh Quantization Extension
2131
+ *
2132
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization
2133
+ *
2134
+ * @private
2135
+ */
2136
+ class GLTFMeshQuantizationExtension {
2137
+
2138
+ constructor() {
2139
+
2140
+ this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;
2141
+
2142
+ }
2143
+
2144
+ }
2145
+
2146
+ /*********************************/
2147
+ /********** INTERPOLATION ********/
2148
+ /*********************************/
2149
+
2150
+ // Spline Interpolation
2151
+ // Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation
2152
+ class GLTFCubicSplineInterpolant extends Interpolant {
2153
+
2154
+ constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) {
2155
+
2156
+ super( parameterPositions, sampleValues, sampleSize, resultBuffer );
2157
+
2158
+ }
2159
+
2160
+ copySampleValue_( index ) {
2161
+
2162
+ // Copies a sample value to the result buffer. See description of glTF
2163
+ // CUBICSPLINE values layout in interpolate_() function below.
2164
+
2165
+ const result = this.resultBuffer,
2166
+ values = this.sampleValues,
2167
+ valueSize = this.valueSize,
2168
+ offset = index * valueSize * 3 + valueSize;
2169
+
2170
+ for ( let i = 0; i !== valueSize; i ++ ) {
2171
+
2172
+ result[ i ] = values[ offset + i ];
2173
+
2174
+ }
2175
+
2176
+ return result;
2177
+
2178
+ }
2179
+
2180
+ interpolate_( i1, t0, t, t1 ) {
2181
+
2182
+ const result = this.resultBuffer;
2183
+ const values = this.sampleValues;
2184
+ const stride = this.valueSize;
2185
+
2186
+ const stride2 = stride * 2;
2187
+ const stride3 = stride * 3;
2188
+
2189
+ const td = t1 - t0;
2190
+
2191
+ const p = ( t - t0 ) / td;
2192
+ const pp = p * p;
2193
+ const ppp = pp * p;
2194
+
2195
+ const offset1 = i1 * stride3;
2196
+ const offset0 = offset1 - stride3;
2197
+
2198
+ const s2 = - 2 * ppp + 3 * pp;
2199
+ const s3 = ppp - pp;
2200
+ const s0 = 1 - s2;
2201
+ const s1 = s3 - pp + p;
2202
+
2203
+ // Layout of keyframe output values for CUBICSPLINE animations:
2204
+ // [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ]
2205
+ for ( let i = 0; i !== stride; i ++ ) {
2206
+
2207
+ const p0 = values[ offset0 + i + stride ]; // splineVertex_k
2208
+ const m0 = values[ offset0 + i + stride2 ] * td; // outTangent_k * (t_k+1 - t_k)
2209
+ const p1 = values[ offset1 + i + stride ]; // splineVertex_k+1
2210
+ const m1 = values[ offset1 + i ] * td; // inTangent_k+1 * (t_k+1 - t_k)
2211
+
2212
+ result[ i ] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
2213
+
2214
+ }
2215
+
2216
+ return result;
2217
+
2218
+ }
2219
+
2220
+ }
2221
+
2222
+ const _quaternion = new Quaternion();
2223
+
2224
+ class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant {
2225
+
2226
+ interpolate_( i1, t0, t, t1 ) {
2227
+
2228
+ const result = super.interpolate_( i1, t0, t, t1 );
2229
+
2230
+ _quaternion.fromArray( result ).normalize().toArray( result );
2231
+
2232
+ return result;
2233
+
2234
+ }
2235
+
2236
+ }
2237
+
2238
+
2239
+ /*********************************/
2240
+ /********** INTERNALS ************/
2241
+ /*********************************/
2242
+
2243
+ /* CONSTANTS */
2244
+
2245
+ const WEBGL_CONSTANTS = {
2246
+ FLOAT: 5126,
2247
+ //FLOAT_MAT2: 35674,
2248
+ FLOAT_MAT3: 35675,
2249
+ FLOAT_MAT4: 35676,
2250
+ FLOAT_VEC2: 35664,
2251
+ FLOAT_VEC3: 35665,
2252
+ FLOAT_VEC4: 35666,
2253
+ LINEAR: 9729,
2254
+ REPEAT: 10497,
2255
+ SAMPLER_2D: 35678,
2256
+ POINTS: 0,
2257
+ LINES: 1,
2258
+ LINE_LOOP: 2,
2259
+ LINE_STRIP: 3,
2260
+ TRIANGLES: 4,
2261
+ TRIANGLE_STRIP: 5,
2262
+ TRIANGLE_FAN: 6,
2263
+ UNSIGNED_BYTE: 5121,
2264
+ UNSIGNED_SHORT: 5123
2265
+ };
2266
+
2267
+ const WEBGL_COMPONENT_TYPES = {
2268
+ 5120: Int8Array,
2269
+ 5121: Uint8Array,
2270
+ 5122: Int16Array,
2271
+ 5123: Uint16Array,
2272
+ 5125: Uint32Array,
2273
+ 5126: Float32Array
2274
+ };
2275
+
2276
+ const WEBGL_FILTERS = {
2277
+ 9728: NearestFilter,
2278
+ 9729: LinearFilter,
2279
+ 9984: NearestMipmapNearestFilter,
2280
+ 9985: LinearMipmapNearestFilter,
2281
+ 9986: NearestMipmapLinearFilter,
2282
+ 9987: LinearMipmapLinearFilter
2283
+ };
2284
+
2285
+ const WEBGL_WRAPPINGS = {
2286
+ 33071: ClampToEdgeWrapping,
2287
+ 33648: MirroredRepeatWrapping,
2288
+ 10497: RepeatWrapping
2289
+ };
2290
+
2291
+ const WEBGL_TYPE_SIZES = {
2292
+ 'SCALAR': 1,
2293
+ 'VEC2': 2,
2294
+ 'VEC3': 3,
2295
+ 'VEC4': 4,
2296
+ 'MAT2': 4,
2297
+ 'MAT3': 9,
2298
+ 'MAT4': 16
2299
+ };
2300
+
2301
+ const ATTRIBUTES = {
2302
+ POSITION: 'position',
2303
+ NORMAL: 'normal',
2304
+ TANGENT: 'tangent',
2305
+ TEXCOORD_0: 'uv',
2306
+ TEXCOORD_1: 'uv1',
2307
+ TEXCOORD_2: 'uv2',
2308
+ TEXCOORD_3: 'uv3',
2309
+ COLOR_0: 'color',
2310
+ WEIGHTS_0: 'skinWeight',
2311
+ JOINTS_0: 'skinIndex',
2312
+ };
2313
+
2314
+ const PATH_PROPERTIES = {
2315
+ scale: 'scale',
2316
+ translation: 'position',
2317
+ rotation: 'quaternion',
2318
+ weights: 'morphTargetInfluences'
2319
+ };
2320
+
2321
+ const INTERPOLATION = {
2322
+ CUBICSPLINE: undefined, // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
2323
+ // keyframe track will be initialized with a default interpolation type, then modified.
2324
+ LINEAR: InterpolateLinear,
2325
+ STEP: InterpolateDiscrete
2326
+ };
2327
+
2328
+ const ALPHA_MODES = {
2329
+ OPAQUE: 'OPAQUE',
2330
+ MASK: 'MASK',
2331
+ BLEND: 'BLEND'
2332
+ };
2333
+
2334
+ /**
2335
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
2336
+ *
2337
+ * @private
2338
+ * @param {Object<string, Material>} cache
2339
+ * @return {Material}
2340
+ */
2341
+ function createDefaultMaterial( cache ) {
2342
+
2343
+ if ( cache[ 'DefaultMaterial' ] === undefined ) {
2344
+
2345
+ cache[ 'DefaultMaterial' ] = new MeshStandardMaterial( {
2346
+ color: 0xFFFFFF,
2347
+ emissive: 0x000000,
2348
+ metalness: 1,
2349
+ roughness: 1,
2350
+ transparent: false,
2351
+ depthTest: true,
2352
+ side: FrontSide
2353
+ } );
2354
+
2355
+ }
2356
+
2357
+ return cache[ 'DefaultMaterial' ];
2358
+
2359
+ }
2360
+
2361
+ function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) {
2362
+
2363
+ // Add unknown glTF extensions to an object's userData.
2364
+
2365
+ for ( const name in objectDef.extensions ) {
2366
+
2367
+ if ( knownExtensions[ name ] === undefined ) {
2368
+
2369
+ object.userData.gltfExtensions = object.userData.gltfExtensions || {};
2370
+ object.userData.gltfExtensions[ name ] = objectDef.extensions[ name ];
2371
+
2372
+ }
2373
+
2374
+ }
2375
+
2376
+ }
2377
+
2378
+ /**
2379
+ *
2380
+ * @private
2381
+ * @param {Object3D|Material|BufferGeometry|Object|AnimationClip} object
2382
+ * @param {GLTF.definition} gltfDef
2383
+ */
2384
+ function assignExtrasToUserData( object, gltfDef ) {
2385
+
2386
+ if ( gltfDef.extras !== undefined ) {
2387
+
2388
+ if ( typeof gltfDef.extras === 'object' ) {
2389
+
2390
+ Object.assign( object.userData, gltfDef.extras );
2391
+
2392
+ } else {
2393
+
2394
+ console.warn( 'THREE.GLTFLoader: Ignoring primitive type .extras, ' + gltfDef.extras );
2395
+
2396
+ }
2397
+
2398
+ }
2399
+
2400
+ }
2401
+
2402
+ /**
2403
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
2404
+ *
2405
+ * @private
2406
+ * @param {BufferGeometry} geometry
2407
+ * @param {Array<GLTF.Target>} targets
2408
+ * @param {GLTFParser} parser
2409
+ * @return {Promise<BufferGeometry>}
2410
+ */
2411
+ function addMorphTargets( geometry, targets, parser ) {
2412
+
2413
+ let hasMorphPosition = false;
2414
+ let hasMorphNormal = false;
2415
+ let hasMorphColor = false;
2416
+
2417
+ for ( let i = 0, il = targets.length; i < il; i ++ ) {
2418
+
2419
+ const target = targets[ i ];
2420
+
2421
+ if ( target.POSITION !== undefined ) hasMorphPosition = true;
2422
+ if ( target.NORMAL !== undefined ) hasMorphNormal = true;
2423
+ if ( target.COLOR_0 !== undefined ) hasMorphColor = true;
2424
+
2425
+ if ( hasMorphPosition && hasMorphNormal && hasMorphColor ) break;
2426
+
2427
+ }
2428
+
2429
+ if ( ! hasMorphPosition && ! hasMorphNormal && ! hasMorphColor ) return Promise.resolve( geometry );
2430
+
2431
+ const pendingPositionAccessors = [];
2432
+ const pendingNormalAccessors = [];
2433
+ const pendingColorAccessors = [];
2434
+
2435
+ for ( let i = 0, il = targets.length; i < il; i ++ ) {
2436
+
2437
+ const target = targets[ i ];
2438
+
2439
+ if ( hasMorphPosition ) {
2440
+
2441
+ const pendingAccessor = target.POSITION !== undefined
2442
+ ? parser.getDependency( 'accessor', target.POSITION )
2443
+ : geometry.attributes.position;
2444
+
2445
+ pendingPositionAccessors.push( pendingAccessor );
2446
+
2447
+ }
2448
+
2449
+ if ( hasMorphNormal ) {
2450
+
2451
+ const pendingAccessor = target.NORMAL !== undefined
2452
+ ? parser.getDependency( 'accessor', target.NORMAL )
2453
+ : geometry.attributes.normal;
2454
+
2455
+ pendingNormalAccessors.push( pendingAccessor );
2456
+
2457
+ }
2458
+
2459
+ if ( hasMorphColor ) {
2460
+
2461
+ const pendingAccessor = target.COLOR_0 !== undefined
2462
+ ? parser.getDependency( 'accessor', target.COLOR_0 )
2463
+ : geometry.attributes.color;
2464
+
2465
+ pendingColorAccessors.push( pendingAccessor );
2466
+
2467
+ }
2468
+
2469
+ }
2470
+
2471
+ return Promise.all( [
2472
+ Promise.all( pendingPositionAccessors ),
2473
+ Promise.all( pendingNormalAccessors ),
2474
+ Promise.all( pendingColorAccessors )
2475
+ ] ).then( function ( accessors ) {
2476
+
2477
+ const morphPositions = accessors[ 0 ];
2478
+ const morphNormals = accessors[ 1 ];
2479
+ const morphColors = accessors[ 2 ];
2480
+
2481
+ if ( hasMorphPosition ) geometry.morphAttributes.position = morphPositions;
2482
+ if ( hasMorphNormal ) geometry.morphAttributes.normal = morphNormals;
2483
+ if ( hasMorphColor ) geometry.morphAttributes.color = morphColors;
2484
+ geometry.morphTargetsRelative = true;
2485
+
2486
+ return geometry;
2487
+
2488
+ } );
2489
+
2490
+ }
2491
+
2492
+ /**
2493
+ *
2494
+ * @private
2495
+ * @param {Mesh} mesh
2496
+ * @param {GLTF.Mesh} meshDef
2497
+ */
2498
+ function updateMorphTargets( mesh, meshDef ) {
2499
+
2500
+ mesh.updateMorphTargets();
2501
+
2502
+ if ( meshDef.weights !== undefined ) {
2503
+
2504
+ for ( let i = 0, il = meshDef.weights.length; i < il; i ++ ) {
2505
+
2506
+ mesh.morphTargetInfluences[ i ] = meshDef.weights[ i ];
2507
+
2508
+ }
2509
+
2510
+ }
2511
+
2512
+ // .extras has user-defined data, so check that .extras.targetNames is an array.
2513
+ if ( meshDef.extras && Array.isArray( meshDef.extras.targetNames ) ) {
2514
+
2515
+ const targetNames = meshDef.extras.targetNames;
2516
+
2517
+ if ( mesh.morphTargetInfluences.length === targetNames.length ) {
2518
+
2519
+ mesh.morphTargetDictionary = {};
2520
+
2521
+ for ( let i = 0, il = targetNames.length; i < il; i ++ ) {
2522
+
2523
+ mesh.morphTargetDictionary[ targetNames[ i ] ] = i;
2524
+
2525
+ }
2526
+
2527
+ } else {
2528
+
2529
+ console.warn( 'THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.' );
2530
+
2531
+ }
2532
+
2533
+ }
2534
+
2535
+ }
2536
+
2537
+ function createPrimitiveKey( primitiveDef ) {
2538
+
2539
+ let geometryKey;
2540
+
2541
+ const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ];
2542
+
2543
+ if ( dracoExtension ) {
2544
+
2545
+ geometryKey = 'draco:' + dracoExtension.bufferView
2546
+ + ':' + dracoExtension.indices
2547
+ + ':' + createAttributesKey( dracoExtension.attributes );
2548
+
2549
+ } else {
2550
+
2551
+ geometryKey = primitiveDef.indices + ':' + createAttributesKey( primitiveDef.attributes ) + ':' + primitiveDef.mode;
2552
+
2553
+ }
2554
+
2555
+ if ( primitiveDef.targets !== undefined ) {
2556
+
2557
+ for ( let i = 0, il = primitiveDef.targets.length; i < il; i ++ ) {
2558
+
2559
+ geometryKey += ':' + createAttributesKey( primitiveDef.targets[ i ] );
2560
+
2561
+ }
2562
+
2563
+ }
2564
+
2565
+ return geometryKey;
2566
+
2567
+ }
2568
+
2569
+ function createAttributesKey( attributes ) {
2570
+
2571
+ let attributesKey = '';
2572
+
2573
+ const keys = Object.keys( attributes ).sort();
2574
+
2575
+ for ( let i = 0, il = keys.length; i < il; i ++ ) {
2576
+
2577
+ attributesKey += keys[ i ] + ':' + attributes[ keys[ i ] ] + ';';
2578
+
2579
+ }
2580
+
2581
+ return attributesKey;
2582
+
2583
+ }
2584
+
2585
+ function getNormalizedComponentScale( constructor ) {
2586
+
2587
+ // Reference:
2588
+ // https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data
2589
+
2590
+ switch ( constructor ) {
2591
+
2592
+ case Int8Array:
2593
+ return 1 / 127;
2594
+
2595
+ case Uint8Array:
2596
+ return 1 / 255;
2597
+
2598
+ case Int16Array:
2599
+ return 1 / 32767;
2600
+
2601
+ case Uint16Array:
2602
+ return 1 / 65535;
2603
+
2604
+ default:
2605
+ throw new Error( 'THREE.GLTFLoader: Unsupported normalized accessor component type.' );
2606
+
2607
+ }
2608
+
2609
+ }
2610
+
2611
+ function getImageURIMimeType( uri ) {
2612
+
2613
+ if ( uri.search( /\.jpe?g($|\?)/i ) > 0 || uri.search( /^data\:image\/jpeg/ ) === 0 ) return 'image/jpeg';
2614
+ if ( uri.search( /\.webp($|\?)/i ) > 0 || uri.search( /^data\:image\/webp/ ) === 0 ) return 'image/webp';
2615
+ if ( uri.search( /\.ktx2($|\?)/i ) > 0 || uri.search( /^data\:image\/ktx2/ ) === 0 ) return 'image/ktx2';
2616
+
2617
+ return 'image/png';
2618
+
2619
+ }
2620
+
2621
+ const _identityMatrix = new Matrix4();
2622
+
2623
+ /* GLTF PARSER */
2624
+
2625
+ class GLTFParser {
2626
+
2627
+ constructor( json = {}, options = {} ) {
2628
+
2629
+ this.json = json;
2630
+ this.extensions = {};
2631
+ this.plugins = {};
2632
+ this.options = options;
2633
+
2634
+ // loader object cache
2635
+ this.cache = new GLTFRegistry();
2636
+
2637
+ // associations between Three.js objects and glTF elements
2638
+ this.associations = new Map();
2639
+
2640
+ // BufferGeometry caching
2641
+ this.primitiveCache = {};
2642
+
2643
+ // Node cache
2644
+ this.nodeCache = {};
2645
+
2646
+ // Object3D instance caches
2647
+ this.meshCache = { refs: {}, uses: {} };
2648
+ this.cameraCache = { refs: {}, uses: {} };
2649
+ this.lightCache = { refs: {}, uses: {} };
2650
+
2651
+ this.sourceCache = {};
2652
+ this.textureCache = {};
2653
+
2654
+ // Track node names, to ensure no duplicates
2655
+ this.nodeNamesUsed = {};
2656
+
2657
+ // Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
2658
+ // expensive work of uploading a texture to the GPU off the main thread.
2659
+
2660
+ let isSafari = false;
2661
+ let safariVersion = - 1;
2662
+ let isFirefox = false;
2663
+ let firefoxVersion = - 1;
2664
+
2665
+ if ( typeof navigator !== 'undefined' ) {
2666
+
2667
+ const userAgent = navigator.userAgent;
2668
+
2669
+ isSafari = /^((?!chrome|android).)*safari/i.test( userAgent ) === true;
2670
+ const safariMatch = userAgent.match( /Version\/(\d+)/ );
2671
+ safariVersion = isSafari && safariMatch ? parseInt( safariMatch[ 1 ], 10 ) : - 1;
2672
+
2673
+ isFirefox = userAgent.indexOf( 'Firefox' ) > - 1;
2674
+ firefoxVersion = isFirefox ? userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
2675
+
2676
+ }
2677
+
2678
+ if ( typeof createImageBitmap === 'undefined' || ( isSafari && safariVersion < 17 ) || ( isFirefox && firefoxVersion < 98 ) ) {
2679
+
2680
+ this.textureLoader = new TextureLoader( this.options.manager );
2681
+
2682
+ } else {
2683
+
2684
+ this.textureLoader = new ImageBitmapLoader( this.options.manager );
2685
+
2686
+ }
2687
+
2688
+ this.textureLoader.setCrossOrigin( this.options.crossOrigin );
2689
+ this.textureLoader.setRequestHeader( this.options.requestHeader );
2690
+
2691
+ this.fileLoader = new FileLoader( this.options.manager );
2692
+ this.fileLoader.setResponseType( 'arraybuffer' );
2693
+
2694
+ if ( this.options.crossOrigin === 'use-credentials' ) {
2695
+
2696
+ this.fileLoader.setWithCredentials( true );
2697
+
2698
+ }
2699
+
2700
+ }
2701
+
2702
+ setExtensions( extensions ) {
2703
+
2704
+ this.extensions = extensions;
2705
+
2706
+ }
2707
+
2708
+ setPlugins( plugins ) {
2709
+
2710
+ this.plugins = plugins;
2711
+
2712
+ }
2713
+
2714
+ parse( onLoad, onError ) {
2715
+
2716
+ const parser = this;
2717
+ const json = this.json;
2718
+ const extensions = this.extensions;
2719
+
2720
+ // Clear the loader cache
2721
+ this.cache.removeAll();
2722
+ this.nodeCache = {};
2723
+
2724
+ // Mark the special nodes/meshes in json for efficient parse
2725
+ this._invokeAll( function ( ext ) {
2726
+
2727
+ return ext._markDefs && ext._markDefs();
2728
+
2729
+ } );
2730
+
2731
+ Promise.all( this._invokeAll( function ( ext ) {
2732
+
2733
+ return ext.beforeRoot && ext.beforeRoot();
2734
+
2735
+ } ) ).then( function () {
2736
+
2737
+ return Promise.all( [
2738
+
2739
+ parser.getDependencies( 'scene' ),
2740
+ parser.getDependencies( 'animation' ),
2741
+ parser.getDependencies( 'camera' ),
2742
+
2743
+ ] );
2744
+
2745
+ } ).then( function ( dependencies ) {
2746
+
2747
+ const result = {
2748
+ scene: dependencies[ 0 ][ json.scene || 0 ],
2749
+ scenes: dependencies[ 0 ],
2750
+ animations: dependencies[ 1 ],
2751
+ cameras: dependencies[ 2 ],
2752
+ asset: json.asset,
2753
+ parser: parser,
2754
+ userData: {}
2755
+ };
2756
+
2757
+ addUnknownExtensionsToUserData( extensions, result, json );
2758
+
2759
+ assignExtrasToUserData( result, json );
2760
+
2761
+ return Promise.all( parser._invokeAll( function ( ext ) {
2762
+
2763
+ return ext.afterRoot && ext.afterRoot( result );
2764
+
2765
+ } ) ).then( function () {
2766
+
2767
+ for ( const scene of result.scenes ) {
2768
+
2769
+ scene.updateMatrixWorld();
2770
+
2771
+ }
2772
+
2773
+ onLoad( result );
2774
+
2775
+ } );
2776
+
2777
+ } ).catch( onError );
2778
+
2779
+ }
2780
+
2781
+ /**
2782
+ * Marks the special nodes/meshes in json for efficient parse.
2783
+ *
2784
+ * @private
2785
+ */
2786
+ _markDefs() {
2787
+
2788
+ const nodeDefs = this.json.nodes || [];
2789
+ const skinDefs = this.json.skins || [];
2790
+ const meshDefs = this.json.meshes || [];
2791
+
2792
+ // Nothing in the node definition indicates whether it is a Bone or an
2793
+ // Object3D. Use the skins' joint references to mark bones.
2794
+ for ( let skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex ++ ) {
2795
+
2796
+ const joints = skinDefs[ skinIndex ].joints;
2797
+
2798
+ for ( let i = 0, il = joints.length; i < il; i ++ ) {
2799
+
2800
+ nodeDefs[ joints[ i ] ].isBone = true;
2801
+
2802
+ }
2803
+
2804
+ }
2805
+
2806
+ // Iterate over all nodes, marking references to shared resources,
2807
+ // as well as skeleton joints.
2808
+ for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) {
2809
+
2810
+ const nodeDef = nodeDefs[ nodeIndex ];
2811
+
2812
+ if ( nodeDef.mesh !== undefined ) {
2813
+
2814
+ this._addNodeRef( this.meshCache, nodeDef.mesh );
2815
+
2816
+ // Nothing in the mesh definition indicates whether it is
2817
+ // a SkinnedMesh or Mesh. Use the node's mesh reference
2818
+ // to mark SkinnedMesh if node has skin.
2819
+ if ( nodeDef.skin !== undefined ) {
2820
+
2821
+ meshDefs[ nodeDef.mesh ].isSkinnedMesh = true;
2822
+
2823
+ }
2824
+
2825
+ }
2826
+
2827
+ if ( nodeDef.camera !== undefined ) {
2828
+
2829
+ this._addNodeRef( this.cameraCache, nodeDef.camera );
2830
+
2831
+ }
2832
+
2833
+ }
2834
+
2835
+ }
2836
+
2837
+ /**
2838
+ * Counts references to shared node / Object3D resources. These resources
2839
+ * can be reused, or "instantiated", at multiple nodes in the scene
2840
+ * hierarchy. Mesh, Camera, and Light instances are instantiated and must
2841
+ * be marked. Non-scenegraph resources (like Materials, Geometries, and
2842
+ * Textures) can be reused directly and are not marked here.
2843
+ *
2844
+ * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
2845
+ *
2846
+ * @private
2847
+ * @param {Object} cache
2848
+ * @param {Object3D} index
2849
+ */
2850
+ _addNodeRef( cache, index ) {
2851
+
2852
+ if ( index === undefined ) return;
2853
+
2854
+ if ( cache.refs[ index ] === undefined ) {
2855
+
2856
+ cache.refs[ index ] = cache.uses[ index ] = 0;
2857
+
2858
+ }
2859
+
2860
+ cache.refs[ index ] ++;
2861
+
2862
+ }
2863
+
2864
+ /**
2865
+ * Returns a reference to a shared resource, cloning it if necessary.
2866
+ *
2867
+ * @private
2868
+ * @param {Object} cache
2869
+ * @param {number} index
2870
+ * @param {Object} object
2871
+ * @return {Object}
2872
+ */
2873
+ _getNodeRef( cache, index, object ) {
2874
+
2875
+ if ( cache.refs[ index ] <= 1 ) return object;
2876
+
2877
+ const ref = object.clone();
2878
+
2879
+ // Propagates mappings to the cloned object, prevents mappings on the
2880
+ // original object from being lost.
2881
+ const updateMappings = ( original, clone ) => {
2882
+
2883
+ const mappings = this.associations.get( original );
2884
+ if ( mappings != null ) {
2885
+
2886
+ this.associations.set( clone, mappings );
2887
+
2888
+ }
2889
+
2890
+ for ( const [ i, child ] of original.children.entries() ) {
2891
+
2892
+ updateMappings( child, clone.children[ i ] );
2893
+
2894
+ }
2895
+
2896
+ };
2897
+
2898
+ updateMappings( object, ref );
2899
+
2900
+ ref.name += '_instance_' + ( cache.uses[ index ] ++ );
2901
+
2902
+ return ref;
2903
+
2904
+ }
2905
+
2906
+ _invokeOne( func ) {
2907
+
2908
+ const extensions = Object.values( this.plugins );
2909
+ extensions.push( this );
2910
+
2911
+ for ( let i = 0; i < extensions.length; i ++ ) {
2912
+
2913
+ const result = func( extensions[ i ] );
2914
+
2915
+ if ( result ) return result;
2916
+
2917
+ }
2918
+
2919
+ return null;
2920
+
2921
+ }
2922
+
2923
+ _invokeAll( func ) {
2924
+
2925
+ const extensions = Object.values( this.plugins );
2926
+ extensions.unshift( this );
2927
+
2928
+ const pending = [];
2929
+
2930
+ for ( let i = 0; i < extensions.length; i ++ ) {
2931
+
2932
+ const result = func( extensions[ i ] );
2933
+
2934
+ if ( result ) pending.push( result );
2935
+
2936
+ }
2937
+
2938
+ return pending;
2939
+
2940
+ }
2941
+
2942
+ /**
2943
+ * Requests the specified dependency asynchronously, with caching.
2944
+ *
2945
+ * @private
2946
+ * @param {string} type
2947
+ * @param {number} index
2948
+ * @return {Promise<Object3D|Material|Texture|AnimationClip|ArrayBuffer|Object>}
2949
+ */
2950
+ getDependency( type, index ) {
2951
+
2952
+ const cacheKey = type + ':' + index;
2953
+ let dependency = this.cache.get( cacheKey );
2954
+
2955
+ if ( ! dependency ) {
2956
+
2957
+ switch ( type ) {
2958
+
2959
+ case 'scene':
2960
+ dependency = this.loadScene( index );
2961
+ break;
2962
+
2963
+ case 'node':
2964
+ dependency = this._invokeOne( function ( ext ) {
2965
+
2966
+ return ext.loadNode && ext.loadNode( index );
2967
+
2968
+ } );
2969
+ break;
2970
+
2971
+ case 'mesh':
2972
+ dependency = this._invokeOne( function ( ext ) {
2973
+
2974
+ return ext.loadMesh && ext.loadMesh( index );
2975
+
2976
+ } );
2977
+ break;
2978
+
2979
+ case 'accessor':
2980
+ dependency = this.loadAccessor( index );
2981
+ break;
2982
+
2983
+ case 'bufferView':
2984
+ dependency = this._invokeOne( function ( ext ) {
2985
+
2986
+ return ext.loadBufferView && ext.loadBufferView( index );
2987
+
2988
+ } );
2989
+ break;
2990
+
2991
+ case 'buffer':
2992
+ dependency = this.loadBuffer( index );
2993
+ break;
2994
+
2995
+ case 'material':
2996
+ dependency = this._invokeOne( function ( ext ) {
2997
+
2998
+ return ext.loadMaterial && ext.loadMaterial( index );
2999
+
3000
+ } );
3001
+ break;
3002
+
3003
+ case 'texture':
3004
+ dependency = this._invokeOne( function ( ext ) {
3005
+
3006
+ return ext.loadTexture && ext.loadTexture( index );
3007
+
3008
+ } );
3009
+ break;
3010
+
3011
+ case 'skin':
3012
+ dependency = this.loadSkin( index );
3013
+ break;
3014
+
3015
+ case 'animation':
3016
+ dependency = this._invokeOne( function ( ext ) {
3017
+
3018
+ return ext.loadAnimation && ext.loadAnimation( index );
3019
+
3020
+ } );
3021
+ break;
3022
+
3023
+ case 'camera':
3024
+ dependency = this.loadCamera( index );
3025
+ break;
3026
+
3027
+ default:
3028
+ dependency = this._invokeOne( function ( ext ) {
3029
+
3030
+ return ext != this && ext.getDependency && ext.getDependency( type, index );
3031
+
3032
+ } );
3033
+
3034
+ if ( ! dependency ) {
3035
+
3036
+ throw new Error( 'Unknown type: ' + type );
3037
+
3038
+ }
3039
+
3040
+ break;
3041
+
3042
+ }
3043
+
3044
+ this.cache.add( cacheKey, dependency );
3045
+
3046
+ }
3047
+
3048
+ return dependency;
3049
+
3050
+ }
3051
+
3052
+ /**
3053
+ * Requests all dependencies of the specified type asynchronously, with caching.
3054
+ *
3055
+ * @private
3056
+ * @param {string} type
3057
+ * @return {Promise<Array<Object>>}
3058
+ */
3059
+ getDependencies( type ) {
3060
+
3061
+ let dependencies = this.cache.get( type );
3062
+
3063
+ if ( ! dependencies ) {
3064
+
3065
+ const parser = this;
3066
+ const defs = this.json[ type + ( type === 'mesh' ? 'es' : 's' ) ] || [];
3067
+
3068
+ dependencies = Promise.all( defs.map( function ( def, index ) {
3069
+
3070
+ return parser.getDependency( type, index );
3071
+
3072
+ } ) );
3073
+
3074
+ this.cache.add( type, dependencies );
3075
+
3076
+ }
3077
+
3078
+ return dependencies;
3079
+
3080
+ }
3081
+
3082
+ /**
3083
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
3084
+ *
3085
+ * @private
3086
+ * @param {number} bufferIndex
3087
+ * @return {Promise<ArrayBuffer>}
3088
+ */
3089
+ loadBuffer( bufferIndex ) {
3090
+
3091
+ const bufferDef = this.json.buffers[ bufferIndex ];
3092
+ const loader = this.fileLoader;
3093
+
3094
+ if ( bufferDef.type && bufferDef.type !== 'arraybuffer' ) {
3095
+
3096
+ throw new Error( 'THREE.GLTFLoader: ' + bufferDef.type + ' buffer type is not supported.' );
3097
+
3098
+ }
3099
+
3100
+ // If present, GLB container is required to be the first buffer.
3101
+ if ( bufferDef.uri === undefined && bufferIndex === 0 ) {
3102
+
3103
+ return Promise.resolve( this.extensions[ EXTENSIONS.KHR_BINARY_GLTF ].body );
3104
+
3105
+ }
3106
+
3107
+ const options = this.options;
3108
+
3109
+ return new Promise( function ( resolve, reject ) {
3110
+
3111
+ loader.load( LoaderUtils.resolveURL( bufferDef.uri, options.path ), resolve, undefined, function () {
3112
+
3113
+ reject( new Error( 'THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".' ) );
3114
+
3115
+ } );
3116
+
3117
+ } );
3118
+
3119
+ }
3120
+
3121
+ /**
3122
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
3123
+ *
3124
+ * @private
3125
+ * @param {number} bufferViewIndex
3126
+ * @return {Promise<ArrayBuffer>}
3127
+ */
3128
+ loadBufferView( bufferViewIndex ) {
3129
+
3130
+ const bufferViewDef = this.json.bufferViews[ bufferViewIndex ];
3131
+
3132
+ return this.getDependency( 'buffer', bufferViewDef.buffer ).then( function ( buffer ) {
3133
+
3134
+ const byteLength = bufferViewDef.byteLength || 0;
3135
+ const byteOffset = bufferViewDef.byteOffset || 0;
3136
+ return buffer.slice( byteOffset, byteOffset + byteLength );
3137
+
3138
+ } );
3139
+
3140
+ }
3141
+
3142
+ /**
3143
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
3144
+ *
3145
+ * @private
3146
+ * @param {number} accessorIndex
3147
+ * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
3148
+ */
3149
+ loadAccessor( accessorIndex ) {
3150
+
3151
+ const parser = this;
3152
+ const json = this.json;
3153
+
3154
+ const accessorDef = this.json.accessors[ accessorIndex ];
3155
+
3156
+ if ( accessorDef.bufferView === undefined && accessorDef.sparse === undefined ) {
3157
+
3158
+ const itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ];
3159
+ const TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
3160
+ const normalized = accessorDef.normalized === true;
3161
+
3162
+ const array = new TypedArray( accessorDef.count * itemSize );
3163
+ return Promise.resolve( new BufferAttribute( array, itemSize, normalized ) );
3164
+
3165
+ }
3166
+
3167
+ const pendingBufferViews = [];
3168
+
3169
+ if ( accessorDef.bufferView !== undefined ) {
3170
+
3171
+ pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.bufferView ) );
3172
+
3173
+ } else {
3174
+
3175
+ pendingBufferViews.push( null );
3176
+
3177
+ }
3178
+
3179
+ if ( accessorDef.sparse !== undefined ) {
3180
+
3181
+ pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.indices.bufferView ) );
3182
+ pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.values.bufferView ) );
3183
+
3184
+ }
3185
+
3186
+ return Promise.all( pendingBufferViews ).then( function ( bufferViews ) {
3187
+
3188
+ const bufferView = bufferViews[ 0 ];
3189
+
3190
+ const itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ];
3191
+ const TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
3192
+
3193
+ // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.
3194
+ const elementBytes = TypedArray.BYTES_PER_ELEMENT;
3195
+ const itemBytes = elementBytes * itemSize;
3196
+ const byteOffset = accessorDef.byteOffset || 0;
3197
+ const byteStride = accessorDef.bufferView !== undefined ? json.bufferViews[ accessorDef.bufferView ].byteStride : undefined;
3198
+ const normalized = accessorDef.normalized === true;
3199
+ let array, bufferAttribute;
3200
+
3201
+ // The buffer is not interleaved if the stride is the item size in bytes.
3202
+ if ( byteStride && byteStride !== itemBytes ) {
3203
+
3204
+ // Each "slice" of the buffer, as defined by 'count' elements of 'byteStride' bytes, gets its own InterleavedBuffer
3205
+ // This makes sure that IBA.count reflects accessor.count properly
3206
+ const ibSlice = Math.floor( byteOffset / byteStride );
3207
+ const ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType + ':' + ibSlice + ':' + accessorDef.count;
3208
+ let ib = parser.cache.get( ibCacheKey );
3209
+
3210
+ if ( ! ib ) {
3211
+
3212
+ array = new TypedArray( bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes );
3213
+
3214
+ // Integer parameters to IB/IBA are in array elements, not bytes.
3215
+ ib = new InterleavedBuffer( array, byteStride / elementBytes );
3216
+
3217
+ parser.cache.add( ibCacheKey, ib );
3218
+
3219
+ }
3220
+
3221
+ bufferAttribute = new InterleavedBufferAttribute( ib, itemSize, ( byteOffset % byteStride ) / elementBytes, normalized );
3222
+
3223
+ } else {
3224
+
3225
+ if ( bufferView === null ) {
3226
+
3227
+ array = new TypedArray( accessorDef.count * itemSize );
3228
+
3229
+ } else {
3230
+
3231
+ array = new TypedArray( bufferView, byteOffset, accessorDef.count * itemSize );
3232
+
3233
+ }
3234
+
3235
+ bufferAttribute = new BufferAttribute( array, itemSize, normalized );
3236
+
3237
+ }
3238
+
3239
+ // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors
3240
+ if ( accessorDef.sparse !== undefined ) {
3241
+
3242
+ const itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;
3243
+ const TypedArrayIndices = WEBGL_COMPONENT_TYPES[ accessorDef.sparse.indices.componentType ];
3244
+
3245
+ const byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0;
3246
+ const byteOffsetValues = accessorDef.sparse.values.byteOffset || 0;
3247
+
3248
+ const sparseIndices = new TypedArrayIndices( bufferViews[ 1 ], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices );
3249
+ const sparseValues = new TypedArray( bufferViews[ 2 ], byteOffsetValues, accessorDef.sparse.count * itemSize );
3250
+
3251
+ if ( bufferView !== null ) {
3252
+
3253
+ // Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes.
3254
+ bufferAttribute = new BufferAttribute( bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized );
3255
+
3256
+ }
3257
+
3258
+ // Ignore normalized since we copy from sparse
3259
+ bufferAttribute.normalized = false;
3260
+
3261
+ for ( let i = 0, il = sparseIndices.length; i < il; i ++ ) {
3262
+
3263
+ const index = sparseIndices[ i ];
3264
+
3265
+ bufferAttribute.setX( index, sparseValues[ i * itemSize ] );
3266
+ if ( itemSize >= 2 ) bufferAttribute.setY( index, sparseValues[ i * itemSize + 1 ] );
3267
+ if ( itemSize >= 3 ) bufferAttribute.setZ( index, sparseValues[ i * itemSize + 2 ] );
3268
+ if ( itemSize >= 4 ) bufferAttribute.setW( index, sparseValues[ i * itemSize + 3 ] );
3269
+ if ( itemSize >= 5 ) throw new Error( 'THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.' );
3270
+
3271
+ }
3272
+
3273
+ bufferAttribute.normalized = normalized;
3274
+
3275
+ }
3276
+
3277
+ return bufferAttribute;
3278
+
3279
+ } );
3280
+
3281
+ }
3282
+
3283
+ /**
3284
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
3285
+ *
3286
+ * @private
3287
+ * @param {number} textureIndex
3288
+ * @return {Promise<?Texture>}
3289
+ */
3290
+ loadTexture( textureIndex ) {
3291
+
3292
+ const json = this.json;
3293
+ const options = this.options;
3294
+ const textureDef = json.textures[ textureIndex ];
3295
+ const sourceIndex = textureDef.source;
3296
+ const sourceDef = json.images[ sourceIndex ];
3297
+
3298
+ let loader = this.textureLoader;
3299
+
3300
+ if ( sourceDef.uri ) {
3301
+
3302
+ const handler = options.manager.getHandler( sourceDef.uri );
3303
+ if ( handler !== null ) loader = handler;
3304
+
3305
+ }
3306
+
3307
+ return this.loadTextureImage( textureIndex, sourceIndex, loader );
3308
+
3309
+ }
3310
+
3311
+ loadTextureImage( textureIndex, sourceIndex, loader ) {
3312
+
3313
+ const parser = this;
3314
+ const json = this.json;
3315
+
3316
+ const textureDef = json.textures[ textureIndex ];
3317
+ const sourceDef = json.images[ sourceIndex ];
3318
+
3319
+ const cacheKey = ( sourceDef.uri || sourceDef.bufferView ) + ':' + textureDef.sampler;
3320
+
3321
+ if ( this.textureCache[ cacheKey ] ) {
3322
+
3323
+ // See https://github.com/mrdoob/three.js/issues/21559.
3324
+ return this.textureCache[ cacheKey ];
3325
+
3326
+ }
3327
+
3328
+ const promise = this.loadImageSource( sourceIndex, loader ).then( function ( texture ) {
3329
+
3330
+ texture.flipY = false;
3331
+
3332
+ texture.name = textureDef.name || sourceDef.name || '';
3333
+
3334
+ if ( texture.name === '' && typeof sourceDef.uri === 'string' && sourceDef.uri.startsWith( 'data:image/' ) === false ) {
3335
+
3336
+ texture.name = sourceDef.uri;
3337
+
3338
+ }
3339
+
3340
+ const samplers = json.samplers || {};
3341
+ const sampler = samplers[ textureDef.sampler ] || {};
3342
+
3343
+ texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || LinearFilter;
3344
+ texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || LinearMipmapLinearFilter;
3345
+ texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || RepeatWrapping;
3346
+ texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || RepeatWrapping;
3347
+ texture.generateMipmaps = ! texture.isCompressedTexture && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
3348
+
3349
+ parser.associations.set( texture, { textures: textureIndex } );
3350
+
3351
+ return texture;
3352
+
3353
+ } ).catch( function () {
3354
+
3355
+ return null;
3356
+
3357
+ } );
3358
+
3359
+ this.textureCache[ cacheKey ] = promise;
3360
+
3361
+ return promise;
3362
+
3363
+ }
3364
+
3365
+ loadImageSource( sourceIndex, loader ) {
3366
+
3367
+ const parser = this;
3368
+ const json = this.json;
3369
+ const options = this.options;
3370
+
3371
+ if ( this.sourceCache[ sourceIndex ] !== undefined ) {
3372
+
3373
+ return this.sourceCache[ sourceIndex ].then( ( texture ) => texture.clone() );
3374
+
3375
+ }
3376
+
3377
+ const sourceDef = json.images[ sourceIndex ];
3378
+
3379
+ const URL = self.URL || self.webkitURL;
3380
+
3381
+ let sourceURI = sourceDef.uri || '';
3382
+ let isObjectURL = false;
3383
+
3384
+ if ( sourceDef.bufferView !== undefined ) {
3385
+
3386
+ // Load binary image data from bufferView, if provided.
3387
+
3388
+ sourceURI = parser.getDependency( 'bufferView', sourceDef.bufferView ).then( function ( bufferView ) {
3389
+
3390
+ isObjectURL = true;
3391
+ const blob = new Blob( [ bufferView ], { type: sourceDef.mimeType } );
3392
+ sourceURI = URL.createObjectURL( blob );
3393
+ return sourceURI;
3394
+
3395
+ } );
3396
+
3397
+ } else if ( sourceDef.uri === undefined ) {
3398
+
3399
+ throw new Error( 'THREE.GLTFLoader: Image ' + sourceIndex + ' is missing URI and bufferView' );
3400
+
3401
+ }
3402
+
3403
+ const promise = Promise.resolve( sourceURI ).then( function ( sourceURI ) {
3404
+
3405
+ return new Promise( function ( resolve, reject ) {
3406
+
3407
+ let onLoad = resolve;
3408
+
3409
+ if ( loader.isImageBitmapLoader === true ) {
3410
+
3411
+ onLoad = function ( imageBitmap ) {
3412
+
3413
+ const texture = new Texture( imageBitmap );
3414
+ texture.needsUpdate = true;
3415
+
3416
+ resolve( texture );
3417
+
3418
+ };
3419
+
3420
+ }
3421
+
3422
+ loader.load( LoaderUtils.resolveURL( sourceURI, options.path ), onLoad, undefined, reject );
3423
+
3424
+ } );
3425
+
3426
+ } ).then( function ( texture ) {
3427
+
3428
+ // Clean up resources and configure Texture.
3429
+
3430
+ if ( isObjectURL === true ) {
3431
+
3432
+ URL.revokeObjectURL( sourceURI );
3433
+
3434
+ }
3435
+
3436
+ assignExtrasToUserData( texture, sourceDef );
3437
+
3438
+ texture.userData.mimeType = sourceDef.mimeType || getImageURIMimeType( sourceDef.uri );
3439
+
3440
+ return texture;
3441
+
3442
+ } ).catch( function ( error ) {
3443
+
3444
+ console.error( 'THREE.GLTFLoader: Couldn\'t load texture', sourceURI );
3445
+ throw error;
3446
+
3447
+ } );
3448
+
3449
+ this.sourceCache[ sourceIndex ] = promise;
3450
+ return promise;
3451
+
3452
+ }
3453
+
3454
+ /**
3455
+ * Asynchronously assigns a texture to the given material parameters.
3456
+ *
3457
+ * @private
3458
+ * @param {Object} materialParams
3459
+ * @param {string} mapName
3460
+ * @param {Object} mapDef
3461
+ * @param {string} [colorSpace]
3462
+ * @return {Promise<Texture>}
3463
+ */
3464
+ assignTexture( materialParams, mapName, mapDef, colorSpace ) {
3465
+
3466
+ const parser = this;
3467
+
3468
+ return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) {
3469
+
3470
+ if ( ! texture ) return null;
3471
+
3472
+ if ( mapDef.texCoord !== undefined && mapDef.texCoord > 0 ) {
3473
+
3474
+ texture = texture.clone();
3475
+ texture.channel = mapDef.texCoord;
3476
+
3477
+ }
3478
+
3479
+ if ( parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] ) {
3480
+
3481
+ const transform = mapDef.extensions !== undefined ? mapDef.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] : undefined;
3482
+
3483
+ if ( transform ) {
3484
+
3485
+ const gltfReference = parser.associations.get( texture );
3486
+ texture = parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ].extendTexture( texture, transform );
3487
+ parser.associations.set( texture, gltfReference );
3488
+
3489
+ }
3490
+
3491
+ }
3492
+
3493
+ if ( colorSpace !== undefined ) {
3494
+
3495
+ texture.colorSpace = colorSpace;
3496
+
3497
+ }
3498
+
3499
+ materialParams[ mapName ] = texture;
3500
+
3501
+ return texture;
3502
+
3503
+ } );
3504
+
3505
+ }
3506
+
3507
+ /**
3508
+ * Assigns final material to a Mesh, Line, or Points instance. The instance
3509
+ * already has a material (generated from the glTF material options alone)
3510
+ * but reuse of the same glTF material may require multiple threejs materials
3511
+ * to accommodate different primitive types, defines, etc. New materials will
3512
+ * be created if necessary, and reused from a cache.
3513
+ *
3514
+ * @private
3515
+ * @param {Object3D} mesh Mesh, Line, or Points instance.
3516
+ */
3517
+ assignFinalMaterial( mesh ) {
3518
+
3519
+ const geometry = mesh.geometry;
3520
+ let material = mesh.material;
3521
+
3522
+ const useDerivativeTangents = geometry.attributes.tangent === undefined;
3523
+ const useVertexColors = geometry.attributes.color !== undefined;
3524
+ const useFlatShading = geometry.attributes.normal === undefined;
3525
+
3526
+ if ( mesh.isPoints ) {
3527
+
3528
+ const cacheKey = 'PointsMaterial:' + material.uuid;
3529
+
3530
+ let pointsMaterial = this.cache.get( cacheKey );
3531
+
3532
+ if ( ! pointsMaterial ) {
3533
+
3534
+ pointsMaterial = new PointsMaterial();
3535
+ Material.prototype.copy.call( pointsMaterial, material );
3536
+ pointsMaterial.color.copy( material.color );
3537
+ pointsMaterial.map = material.map;
3538
+ pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px
3539
+
3540
+ this.cache.add( cacheKey, pointsMaterial );
3541
+
3542
+ }
3543
+
3544
+ material = pointsMaterial;
3545
+
3546
+ } else if ( mesh.isLine ) {
3547
+
3548
+ const cacheKey = 'LineBasicMaterial:' + material.uuid;
3549
+
3550
+ let lineMaterial = this.cache.get( cacheKey );
3551
+
3552
+ if ( ! lineMaterial ) {
3553
+
3554
+ lineMaterial = new LineBasicMaterial();
3555
+ Material.prototype.copy.call( lineMaterial, material );
3556
+ lineMaterial.color.copy( material.color );
3557
+ lineMaterial.map = material.map;
3558
+
3559
+ this.cache.add( cacheKey, lineMaterial );
3560
+
3561
+ }
3562
+
3563
+ material = lineMaterial;
3564
+
3565
+ }
3566
+
3567
+ // Clone the material if it will be modified
3568
+ if ( useDerivativeTangents || useVertexColors || useFlatShading ) {
3569
+
3570
+ let cacheKey = 'ClonedMaterial:' + material.uuid + ':';
3571
+
3572
+ if ( useDerivativeTangents ) cacheKey += 'derivative-tangents:';
3573
+ if ( useVertexColors ) cacheKey += 'vertex-colors:';
3574
+ if ( useFlatShading ) cacheKey += 'flat-shading:';
3575
+
3576
+ let cachedMaterial = this.cache.get( cacheKey );
3577
+
3578
+ if ( ! cachedMaterial ) {
3579
+
3580
+ cachedMaterial = material.clone();
3581
+
3582
+ if ( useVertexColors ) cachedMaterial.vertexColors = true;
3583
+ if ( useFlatShading ) cachedMaterial.flatShading = true;
3584
+
3585
+ if ( useDerivativeTangents ) {
3586
+
3587
+ // https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
3588
+ if ( cachedMaterial.normalScale ) cachedMaterial.normalScale.y *= - 1;
3589
+ if ( cachedMaterial.clearcoatNormalScale ) cachedMaterial.clearcoatNormalScale.y *= - 1;
3590
+
3591
+ }
3592
+
3593
+ this.cache.add( cacheKey, cachedMaterial );
3594
+
3595
+ this.associations.set( cachedMaterial, this.associations.get( material ) );
3596
+
3597
+ }
3598
+
3599
+ material = cachedMaterial;
3600
+
3601
+ }
3602
+
3603
+ mesh.material = material;
3604
+
3605
+ }
3606
+
3607
+ getMaterialType( /* materialIndex */ ) {
3608
+
3609
+ return MeshStandardMaterial;
3610
+
3611
+ }
3612
+
3613
+ /**
3614
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
3615
+ *
3616
+ * @private
3617
+ * @param {number} materialIndex
3618
+ * @return {Promise<Material>}
3619
+ */
3620
+ loadMaterial( materialIndex ) {
3621
+
3622
+ const parser = this;
3623
+ const json = this.json;
3624
+ const extensions = this.extensions;
3625
+ const materialDef = json.materials[ materialIndex ];
3626
+
3627
+ let materialType;
3628
+ const materialParams = {};
3629
+ const materialExtensions = materialDef.extensions || {};
3630
+
3631
+ const pending = [];
3632
+
3633
+ if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) {
3634
+
3635
+ const kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ];
3636
+ materialType = kmuExtension.getMaterialType();
3637
+ pending.push( kmuExtension.extendParams( materialParams, materialDef, parser ) );
3638
+
3639
+ } else {
3640
+
3641
+ // Specification:
3642
+ // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material
3643
+
3644
+ const metallicRoughness = materialDef.pbrMetallicRoughness || {};
3645
+
3646
+ materialParams.color = new Color( 1.0, 1.0, 1.0 );
3647
+ materialParams.opacity = 1.0;
3648
+
3649
+ if ( Array.isArray( metallicRoughness.baseColorFactor ) ) {
3650
+
3651
+ const array = metallicRoughness.baseColorFactor;
3652
+
3653
+ materialParams.color.setRGB( array[ 0 ], array[ 1 ], array[ 2 ], LinearSRGBColorSpace );
3654
+ materialParams.opacity = array[ 3 ];
3655
+
3656
+ }
3657
+
3658
+ if ( metallicRoughness.baseColorTexture !== undefined ) {
3659
+
3660
+ pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, SRGBColorSpace ) );
3661
+
3662
+ }
3663
+
3664
+ materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0;
3665
+ materialParams.roughness = metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0;
3666
+
3667
+ if ( metallicRoughness.metallicRoughnessTexture !== undefined ) {
3668
+
3669
+ pending.push( parser.assignTexture( materialParams, 'metalnessMap', metallicRoughness.metallicRoughnessTexture ) );
3670
+ pending.push( parser.assignTexture( materialParams, 'roughnessMap', metallicRoughness.metallicRoughnessTexture ) );
3671
+
3672
+ }
3673
+
3674
+ materialType = this._invokeOne( function ( ext ) {
3675
+
3676
+ return ext.getMaterialType && ext.getMaterialType( materialIndex );
3677
+
3678
+ } );
3679
+
3680
+ pending.push( Promise.all( this._invokeAll( function ( ext ) {
3681
+
3682
+ return ext.extendMaterialParams && ext.extendMaterialParams( materialIndex, materialParams );
3683
+
3684
+ } ) ) );
3685
+
3686
+ }
3687
+
3688
+ if ( materialDef.doubleSided === true ) {
3689
+
3690
+ materialParams.side = DoubleSide;
3691
+
3692
+ }
3693
+
3694
+ const alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;
3695
+
3696
+ if ( alphaMode === ALPHA_MODES.BLEND ) {
3697
+
3698
+ materialParams.transparent = true;
3699
+
3700
+ // See: https://github.com/mrdoob/three.js/issues/17706
3701
+ materialParams.depthWrite = false;
3702
+
3703
+ } else {
3704
+
3705
+ materialParams.transparent = false;
3706
+
3707
+ if ( alphaMode === ALPHA_MODES.MASK ) {
3708
+
3709
+ materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;
3710
+
3711
+ }
3712
+
3713
+ }
3714
+
3715
+ if ( materialDef.normalTexture !== undefined && materialType !== MeshBasicMaterial ) {
3716
+
3717
+ pending.push( parser.assignTexture( materialParams, 'normalMap', materialDef.normalTexture ) );
3718
+
3719
+ materialParams.normalScale = new Vector2( 1, 1 );
3720
+
3721
+ if ( materialDef.normalTexture.scale !== undefined ) {
3722
+
3723
+ const scale = materialDef.normalTexture.scale;
3724
+
3725
+ materialParams.normalScale.set( scale, scale );
3726
+
3727
+ }
3728
+
3729
+ }
3730
+
3731
+ if ( materialDef.occlusionTexture !== undefined && materialType !== MeshBasicMaterial ) {
3732
+
3733
+ pending.push( parser.assignTexture( materialParams, 'aoMap', materialDef.occlusionTexture ) );
3734
+
3735
+ if ( materialDef.occlusionTexture.strength !== undefined ) {
3736
+
3737
+ materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;
3738
+
3739
+ }
3740
+
3741
+ }
3742
+
3743
+ if ( materialDef.emissiveFactor !== undefined && materialType !== MeshBasicMaterial ) {
3744
+
3745
+ const emissiveFactor = materialDef.emissiveFactor;
3746
+ materialParams.emissive = new Color().setRGB( emissiveFactor[ 0 ], emissiveFactor[ 1 ], emissiveFactor[ 2 ], LinearSRGBColorSpace );
3747
+
3748
+ }
3749
+
3750
+ if ( materialDef.emissiveTexture !== undefined && materialType !== MeshBasicMaterial ) {
3751
+
3752
+ pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture, SRGBColorSpace ) );
3753
+
3754
+ }
3755
+
3756
+ return Promise.all( pending ).then( function () {
3757
+
3758
+ const material = new materialType( materialParams );
3759
+
3760
+ if ( materialDef.name ) material.name = materialDef.name;
3761
+
3762
+ assignExtrasToUserData( material, materialDef );
3763
+
3764
+ parser.associations.set( material, { materials: materialIndex } );
3765
+
3766
+ if ( materialDef.extensions ) addUnknownExtensionsToUserData( extensions, material, materialDef );
3767
+
3768
+ return material;
3769
+
3770
+ } );
3771
+
3772
+ }
3773
+
3774
+ /**
3775
+ * When Object3D instances are targeted by animation, they need unique names.
3776
+ *
3777
+ * @private
3778
+ * @param {string} originalName
3779
+ * @return {string}
3780
+ */
3781
+ createUniqueName( originalName ) {
3782
+
3783
+ const sanitizedName = PropertyBinding.sanitizeNodeName( originalName || '' );
3784
+
3785
+ if ( sanitizedName in this.nodeNamesUsed ) {
3786
+
3787
+ return sanitizedName + '_' + ( ++ this.nodeNamesUsed[ sanitizedName ] );
3788
+
3789
+ } else {
3790
+
3791
+ this.nodeNamesUsed[ sanitizedName ] = 0;
3792
+
3793
+ return sanitizedName;
3794
+
3795
+ }
3796
+
3797
+ }
3798
+
3799
+ /**
3800
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
3801
+ *
3802
+ * Creates BufferGeometries from primitives.
3803
+ *
3804
+ * @private
3805
+ * @param {Array<GLTF.Primitive>} primitives
3806
+ * @return {Promise<Array<BufferGeometry>>}
3807
+ */
3808
+ loadGeometries( primitives ) {
3809
+
3810
+ const parser = this;
3811
+ const extensions = this.extensions;
3812
+ const cache = this.primitiveCache;
3813
+
3814
+ function createDracoPrimitive( primitive ) {
3815
+
3816
+ return extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ]
3817
+ .decodePrimitive( primitive, parser )
3818
+ .then( function ( geometry ) {
3819
+
3820
+ return addPrimitiveAttributes( geometry, primitive, parser );
3821
+
3822
+ } );
3823
+
3824
+ }
3825
+
3826
+ const pending = [];
3827
+
3828
+ for ( let i = 0, il = primitives.length; i < il; i ++ ) {
3829
+
3830
+ const primitive = primitives[ i ];
3831
+ const cacheKey = createPrimitiveKey( primitive );
3832
+
3833
+ // See if we've already created this geometry
3834
+ const cached = cache[ cacheKey ];
3835
+
3836
+ if ( cached ) {
3837
+
3838
+ // Use the cached geometry if it exists
3839
+ pending.push( cached.promise );
3840
+
3841
+ } else {
3842
+
3843
+ let geometryPromise;
3844
+
3845
+ if ( primitive.extensions && primitive.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] ) {
3846
+
3847
+ // Use DRACO geometry if available
3848
+ geometryPromise = createDracoPrimitive( primitive );
3849
+
3850
+ } else {
3851
+
3852
+ // Otherwise create a new geometry
3853
+ geometryPromise = addPrimitiveAttributes( new BufferGeometry(), primitive, parser );
3854
+
3855
+ }
3856
+
3857
+ // Cache this geometry
3858
+ cache[ cacheKey ] = { primitive: primitive, promise: geometryPromise };
3859
+
3860
+ pending.push( geometryPromise );
3861
+
3862
+ }
3863
+
3864
+ }
3865
+
3866
+ return Promise.all( pending );
3867
+
3868
+ }
3869
+
3870
+ /**
3871
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
3872
+ *
3873
+ * @private
3874
+ * @param {number} meshIndex
3875
+ * @return {Promise<Group|Mesh|SkinnedMesh|Line|Points>}
3876
+ */
3877
+ loadMesh( meshIndex ) {
3878
+
3879
+ const parser = this;
3880
+ const json = this.json;
3881
+ const extensions = this.extensions;
3882
+
3883
+ const meshDef = json.meshes[ meshIndex ];
3884
+ const primitives = meshDef.primitives;
3885
+
3886
+ const pending = [];
3887
+
3888
+ for ( let i = 0, il = primitives.length; i < il; i ++ ) {
3889
+
3890
+ const material = primitives[ i ].material === undefined
3891
+ ? createDefaultMaterial( this.cache )
3892
+ : this.getDependency( 'material', primitives[ i ].material );
3893
+
3894
+ pending.push( material );
3895
+
3896
+ }
3897
+
3898
+ pending.push( parser.loadGeometries( primitives ) );
3899
+
3900
+ return Promise.all( pending ).then( function ( results ) {
3901
+
3902
+ const materials = results.slice( 0, results.length - 1 );
3903
+ const geometries = results[ results.length - 1 ];
3904
+
3905
+ const meshes = [];
3906
+
3907
+ for ( let i = 0, il = geometries.length; i < il; i ++ ) {
3908
+
3909
+ const geometry = geometries[ i ];
3910
+ const primitive = primitives[ i ];
3911
+
3912
+ // 1. create Mesh
3913
+
3914
+ let mesh;
3915
+
3916
+ const material = materials[ i ];
3917
+
3918
+ if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES ||
3919
+ primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ||
3920
+ primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ||
3921
+ primitive.mode === undefined ) {
3922
+
3923
+ // .isSkinnedMesh isn't in glTF spec. See ._markDefs()
3924
+ mesh = meshDef.isSkinnedMesh === true
3925
+ ? new SkinnedMesh( geometry, material )
3926
+ : new Mesh( geometry, material );
3927
+
3928
+ if ( mesh.isSkinnedMesh === true ) {
3929
+
3930
+ // normalize skin weights to fix malformed assets (see #15319)
3931
+ mesh.normalizeSkinWeights();
3932
+
3933
+ }
3934
+
3935
+ if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ) {
3936
+
3937
+ mesh.geometry = toTrianglesDrawMode( mesh.geometry, TriangleStripDrawMode );
3938
+
3939
+ } else if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) {
3940
+
3941
+ mesh.geometry = toTrianglesDrawMode( mesh.geometry, TriangleFanDrawMode );
3942
+
3943
+ }
3944
+
3945
+ } else if ( primitive.mode === WEBGL_CONSTANTS.LINES ) {
3946
+
3947
+ mesh = new LineSegments( geometry, material );
3948
+
3949
+ } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_STRIP ) {
3950
+
3951
+ mesh = new Line( geometry, material );
3952
+
3953
+ } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_LOOP ) {
3954
+
3955
+ mesh = new LineLoop( geometry, material );
3956
+
3957
+ } else if ( primitive.mode === WEBGL_CONSTANTS.POINTS ) {
3958
+
3959
+ mesh = new Points( geometry, material );
3960
+
3961
+ } else {
3962
+
3963
+ throw new Error( 'THREE.GLTFLoader: Primitive mode unsupported: ' + primitive.mode );
3964
+
3965
+ }
3966
+
3967
+ if ( Object.keys( mesh.geometry.morphAttributes ).length > 0 ) {
3968
+
3969
+ updateMorphTargets( mesh, meshDef );
3970
+
3971
+ }
3972
+
3973
+ mesh.name = parser.createUniqueName( meshDef.name || ( 'mesh_' + meshIndex ) );
3974
+
3975
+ assignExtrasToUserData( mesh, meshDef );
3976
+
3977
+ if ( primitive.extensions ) addUnknownExtensionsToUserData( extensions, mesh, primitive );
3978
+
3979
+ parser.assignFinalMaterial( mesh );
3980
+
3981
+ meshes.push( mesh );
3982
+
3983
+ }
3984
+
3985
+ for ( let i = 0, il = meshes.length; i < il; i ++ ) {
3986
+
3987
+ parser.associations.set( meshes[ i ], {
3988
+ meshes: meshIndex,
3989
+ primitives: i
3990
+ } );
3991
+
3992
+ }
3993
+
3994
+ if ( meshes.length === 1 ) {
3995
+
3996
+ if ( meshDef.extensions ) addUnknownExtensionsToUserData( extensions, meshes[ 0 ], meshDef );
3997
+
3998
+ return meshes[ 0 ];
3999
+
4000
+ }
4001
+
4002
+ const group = new Group();
4003
+
4004
+ if ( meshDef.extensions ) addUnknownExtensionsToUserData( extensions, group, meshDef );
4005
+
4006
+ parser.associations.set( group, { meshes: meshIndex } );
4007
+
4008
+ for ( let i = 0, il = meshes.length; i < il; i ++ ) {
4009
+
4010
+ group.add( meshes[ i ] );
4011
+
4012
+ }
4013
+
4014
+ return group;
4015
+
4016
+ } );
4017
+
4018
+ }
4019
+
4020
+ /**
4021
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
4022
+ *
4023
+ * @private
4024
+ * @param {number} cameraIndex
4025
+ * @return {Promise<Camera>|undefined}
4026
+ */
4027
+ loadCamera( cameraIndex ) {
4028
+
4029
+ let camera;
4030
+ const cameraDef = this.json.cameras[ cameraIndex ];
4031
+ const params = cameraDef[ cameraDef.type ];
4032
+
4033
+ if ( ! params ) {
4034
+
4035
+ console.warn( 'THREE.GLTFLoader: Missing camera parameters.' );
4036
+ return;
4037
+
4038
+ }
4039
+
4040
+ if ( cameraDef.type === 'perspective' ) {
4041
+
4042
+ camera = new PerspectiveCamera( MathUtils.radToDeg( params.yfov ), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6 );
4043
+
4044
+ } else if ( cameraDef.type === 'orthographic' ) {
4045
+
4046
+ camera = new OrthographicCamera( - params.xmag, params.xmag, params.ymag, - params.ymag, params.znear, params.zfar );
4047
+
4048
+ }
4049
+
4050
+ if ( cameraDef.name ) camera.name = this.createUniqueName( cameraDef.name );
4051
+
4052
+ assignExtrasToUserData( camera, cameraDef );
4053
+
4054
+ return Promise.resolve( camera );
4055
+
4056
+ }
4057
+
4058
+ /**
4059
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
4060
+ *
4061
+ * @private
4062
+ * @param {number} skinIndex
4063
+ * @return {Promise<Skeleton>}
4064
+ */
4065
+ loadSkin( skinIndex ) {
4066
+
4067
+ const skinDef = this.json.skins[ skinIndex ];
4068
+
4069
+ const pending = [];
4070
+
4071
+ for ( let i = 0, il = skinDef.joints.length; i < il; i ++ ) {
4072
+
4073
+ pending.push( this._loadNodeShallow( skinDef.joints[ i ] ) );
4074
+
4075
+ }
4076
+
4077
+ if ( skinDef.inverseBindMatrices !== undefined ) {
4078
+
4079
+ pending.push( this.getDependency( 'accessor', skinDef.inverseBindMatrices ) );
4080
+
4081
+ } else {
4082
+
4083
+ pending.push( null );
4084
+
4085
+ }
4086
+
4087
+ return Promise.all( pending ).then( function ( results ) {
4088
+
4089
+ const inverseBindMatrices = results.pop();
4090
+ const jointNodes = results;
4091
+
4092
+ // Note that bones (joint nodes) may or may not be in the
4093
+ // scene graph at this time.
4094
+
4095
+ const bones = [];
4096
+ const boneInverses = [];
4097
+
4098
+ for ( let i = 0, il = jointNodes.length; i < il; i ++ ) {
4099
+
4100
+ const jointNode = jointNodes[ i ];
4101
+
4102
+ if ( jointNode ) {
4103
+
4104
+ bones.push( jointNode );
4105
+
4106
+ const mat = new Matrix4();
4107
+
4108
+ if ( inverseBindMatrices !== null ) {
4109
+
4110
+ mat.fromArray( inverseBindMatrices.array, i * 16 );
4111
+
4112
+ }
4113
+
4114
+ boneInverses.push( mat );
4115
+
4116
+ } else {
4117
+
4118
+ console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinDef.joints[ i ] );
4119
+
4120
+ }
4121
+
4122
+ }
4123
+
4124
+ return new Skeleton( bones, boneInverses );
4125
+
4126
+ } );
4127
+
4128
+ }
4129
+
4130
+ /**
4131
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
4132
+ *
4133
+ * @private
4134
+ * @param {number} animationIndex
4135
+ * @return {Promise<AnimationClip>}
4136
+ */
4137
+ loadAnimation( animationIndex ) {
4138
+
4139
+ const json = this.json;
4140
+ const parser = this;
4141
+
4142
+ const animationDef = json.animations[ animationIndex ];
4143
+ const animationName = animationDef.name ? animationDef.name : 'animation_' + animationIndex;
4144
+
4145
+ const pendingNodes = [];
4146
+ const pendingInputAccessors = [];
4147
+ const pendingOutputAccessors = [];
4148
+ const pendingSamplers = [];
4149
+ const pendingTargets = [];
4150
+
4151
+ for ( let i = 0, il = animationDef.channels.length; i < il; i ++ ) {
4152
+
4153
+ const channel = animationDef.channels[ i ];
4154
+ const sampler = animationDef.samplers[ channel.sampler ];
4155
+ const target = channel.target;
4156
+ const name = target.node;
4157
+ const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input;
4158
+ const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output;
4159
+
4160
+ if ( target.node === undefined ) continue;
4161
+
4162
+ pendingNodes.push( this.getDependency( 'node', name ) );
4163
+ pendingInputAccessors.push( this.getDependency( 'accessor', input ) );
4164
+ pendingOutputAccessors.push( this.getDependency( 'accessor', output ) );
4165
+ pendingSamplers.push( sampler );
4166
+ pendingTargets.push( target );
4167
+
4168
+ }
4169
+
4170
+ return Promise.all( [
4171
+
4172
+ Promise.all( pendingNodes ),
4173
+ Promise.all( pendingInputAccessors ),
4174
+ Promise.all( pendingOutputAccessors ),
4175
+ Promise.all( pendingSamplers ),
4176
+ Promise.all( pendingTargets )
4177
+
4178
+ ] ).then( function ( dependencies ) {
4179
+
4180
+ const nodes = dependencies[ 0 ];
4181
+ const inputAccessors = dependencies[ 1 ];
4182
+ const outputAccessors = dependencies[ 2 ];
4183
+ const samplers = dependencies[ 3 ];
4184
+ const targets = dependencies[ 4 ];
4185
+
4186
+ const tracks = [];
4187
+
4188
+ for ( let i = 0, il = nodes.length; i < il; i ++ ) {
4189
+
4190
+ const node = nodes[ i ];
4191
+ const inputAccessor = inputAccessors[ i ];
4192
+ const outputAccessor = outputAccessors[ i ];
4193
+ const sampler = samplers[ i ];
4194
+ const target = targets[ i ];
4195
+
4196
+ if ( node === undefined ) continue;
4197
+
4198
+ if ( node.updateMatrix ) {
4199
+
4200
+ node.updateMatrix();
4201
+
4202
+ }
4203
+
4204
+ const createdTracks = parser._createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target );
4205
+
4206
+ if ( createdTracks ) {
4207
+
4208
+ for ( let k = 0; k < createdTracks.length; k ++ ) {
4209
+
4210
+ tracks.push( createdTracks[ k ] );
4211
+
4212
+ }
4213
+
4214
+ }
4215
+
4216
+ }
4217
+
4218
+ const animation = new AnimationClip( animationName, undefined, tracks );
4219
+
4220
+ assignExtrasToUserData( animation, animationDef );
4221
+
4222
+ return animation;
4223
+
4224
+ } );
4225
+
4226
+ }
4227
+
4228
+ createNodeMesh( nodeIndex ) {
4229
+
4230
+ const json = this.json;
4231
+ const parser = this;
4232
+ const nodeDef = json.nodes[ nodeIndex ];
4233
+
4234
+ if ( nodeDef.mesh === undefined ) return null;
4235
+
4236
+ return parser.getDependency( 'mesh', nodeDef.mesh ).then( function ( mesh ) {
4237
+
4238
+ const node = parser._getNodeRef( parser.meshCache, nodeDef.mesh, mesh );
4239
+
4240
+ // if weights are provided on the node, override weights on the mesh.
4241
+ if ( nodeDef.weights !== undefined ) {
4242
+
4243
+ node.traverse( function ( o ) {
4244
+
4245
+ if ( ! o.isMesh ) return;
4246
+
4247
+ for ( let i = 0, il = nodeDef.weights.length; i < il; i ++ ) {
4248
+
4249
+ o.morphTargetInfluences[ i ] = nodeDef.weights[ i ];
4250
+
4251
+ }
4252
+
4253
+ } );
4254
+
4255
+ }
4256
+
4257
+ return node;
4258
+
4259
+ } );
4260
+
4261
+ }
4262
+
4263
+ /**
4264
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
4265
+ *
4266
+ * @private
4267
+ * @param {number} nodeIndex
4268
+ * @return {Promise<Object3D>}
4269
+ */
4270
+ loadNode( nodeIndex ) {
4271
+
4272
+ const json = this.json;
4273
+ const parser = this;
4274
+
4275
+ const nodeDef = json.nodes[ nodeIndex ];
4276
+
4277
+ const nodePending = parser._loadNodeShallow( nodeIndex );
4278
+
4279
+ const childPending = [];
4280
+ const childrenDef = nodeDef.children || [];
4281
+
4282
+ for ( let i = 0, il = childrenDef.length; i < il; i ++ ) {
4283
+
4284
+ childPending.push( parser.getDependency( 'node', childrenDef[ i ] ) );
4285
+
4286
+ }
4287
+
4288
+ const skeletonPending = nodeDef.skin === undefined
4289
+ ? Promise.resolve( null )
4290
+ : parser.getDependency( 'skin', nodeDef.skin );
4291
+
4292
+ return Promise.all( [
4293
+ nodePending,
4294
+ Promise.all( childPending ),
4295
+ skeletonPending
4296
+ ] ).then( function ( results ) {
4297
+
4298
+ const node = results[ 0 ];
4299
+ const children = results[ 1 ];
4300
+ const skeleton = results[ 2 ];
4301
+
4302
+ if ( skeleton !== null ) {
4303
+
4304
+ // This full traverse should be fine because
4305
+ // child glTF nodes have not been added to this node yet.
4306
+ node.traverse( function ( mesh ) {
4307
+
4308
+ if ( ! mesh.isSkinnedMesh ) return;
4309
+
4310
+ mesh.bind( skeleton, _identityMatrix );
4311
+
4312
+ } );
4313
+
4314
+ }
4315
+
4316
+ for ( let i = 0, il = children.length; i < il; i ++ ) {
4317
+
4318
+ node.add( children[ i ] );
4319
+
4320
+ }
4321
+
4322
+ return node;
4323
+
4324
+ } );
4325
+
4326
+ }
4327
+
4328
+ // ._loadNodeShallow() parses a single node.
4329
+ // skin and child nodes are created and added in .loadNode() (no '_' prefix).
4330
+ _loadNodeShallow( nodeIndex ) {
4331
+
4332
+ const json = this.json;
4333
+ const extensions = this.extensions;
4334
+ const parser = this;
4335
+
4336
+ // This method is called from .loadNode() and .loadSkin().
4337
+ // Cache a node to avoid duplication.
4338
+
4339
+ if ( this.nodeCache[ nodeIndex ] !== undefined ) {
4340
+
4341
+ return this.nodeCache[ nodeIndex ];
4342
+
4343
+ }
4344
+
4345
+ const nodeDef = json.nodes[ nodeIndex ];
4346
+
4347
+ // reserve node's name before its dependencies, so the root has the intended name.
4348
+ const nodeName = nodeDef.name ? parser.createUniqueName( nodeDef.name ) : '';
4349
+
4350
+ const pending = [];
4351
+
4352
+ const meshPromise = parser._invokeOne( function ( ext ) {
4353
+
4354
+ return ext.createNodeMesh && ext.createNodeMesh( nodeIndex );
4355
+
4356
+ } );
4357
+
4358
+ if ( meshPromise ) {
4359
+
4360
+ pending.push( meshPromise );
4361
+
4362
+ }
4363
+
4364
+ if ( nodeDef.camera !== undefined ) {
4365
+
4366
+ pending.push( parser.getDependency( 'camera', nodeDef.camera ).then( function ( camera ) {
4367
+
4368
+ return parser._getNodeRef( parser.cameraCache, nodeDef.camera, camera );
4369
+
4370
+ } ) );
4371
+
4372
+ }
4373
+
4374
+ parser._invokeAll( function ( ext ) {
4375
+
4376
+ return ext.createNodeAttachment && ext.createNodeAttachment( nodeIndex );
4377
+
4378
+ } ).forEach( function ( promise ) {
4379
+
4380
+ pending.push( promise );
4381
+
4382
+ } );
4383
+
4384
+ this.nodeCache[ nodeIndex ] = Promise.all( pending ).then( function ( objects ) {
4385
+
4386
+ let node;
4387
+
4388
+ // .isBone isn't in glTF spec. See ._markDefs
4389
+ if ( nodeDef.isBone === true ) {
4390
+
4391
+ node = new Bone();
4392
+
4393
+ } else if ( objects.length > 1 ) {
4394
+
4395
+ node = new Group();
4396
+
4397
+ } else if ( objects.length === 1 ) {
4398
+
4399
+ node = objects[ 0 ];
4400
+
4401
+ } else {
4402
+
4403
+ node = new Object3D();
4404
+
4405
+ }
4406
+
4407
+ if ( node !== objects[ 0 ] ) {
4408
+
4409
+ for ( let i = 0, il = objects.length; i < il; i ++ ) {
4410
+
4411
+ node.add( objects[ i ] );
4412
+
4413
+ }
4414
+
4415
+ }
4416
+
4417
+ if ( nodeDef.name ) {
4418
+
4419
+ node.userData.name = nodeDef.name;
4420
+ node.name = nodeName;
4421
+
4422
+ }
4423
+
4424
+ assignExtrasToUserData( node, nodeDef );
4425
+
4426
+ if ( nodeDef.extensions ) addUnknownExtensionsToUserData( extensions, node, nodeDef );
4427
+
4428
+ if ( nodeDef.matrix !== undefined ) {
4429
+
4430
+ const matrix = new Matrix4();
4431
+ matrix.fromArray( nodeDef.matrix );
4432
+ node.applyMatrix4( matrix );
4433
+
4434
+ } else {
4435
+
4436
+ if ( nodeDef.translation !== undefined ) {
4437
+
4438
+ node.position.fromArray( nodeDef.translation );
4439
+
4440
+ }
4441
+
4442
+ if ( nodeDef.rotation !== undefined ) {
4443
+
4444
+ node.quaternion.fromArray( nodeDef.rotation );
4445
+
4446
+ }
4447
+
4448
+ if ( nodeDef.scale !== undefined ) {
4449
+
4450
+ node.scale.fromArray( nodeDef.scale );
4451
+
4452
+ }
4453
+
4454
+ }
4455
+
4456
+ if ( ! parser.associations.has( node ) ) {
4457
+
4458
+ parser.associations.set( node, {} );
4459
+
4460
+ } else if ( nodeDef.mesh !== undefined && parser.meshCache.refs[ nodeDef.mesh ] > 1 ) {
4461
+
4462
+ const mapping = parser.associations.get( node );
4463
+ parser.associations.set( node, { ...mapping } );
4464
+
4465
+ }
4466
+
4467
+ parser.associations.get( node ).nodes = nodeIndex;
4468
+
4469
+ return node;
4470
+
4471
+ } );
4472
+
4473
+ return this.nodeCache[ nodeIndex ];
4474
+
4475
+ }
4476
+
4477
+ /**
4478
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
4479
+ *
4480
+ * @private
4481
+ * @param {number} sceneIndex
4482
+ * @return {Promise<Group>}
4483
+ */
4484
+ loadScene( sceneIndex ) {
4485
+
4486
+ const extensions = this.extensions;
4487
+ const sceneDef = this.json.scenes[ sceneIndex ];
4488
+ const parser = this;
4489
+
4490
+ // Loader returns Group, not Scene.
4491
+ // See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172
4492
+ const scene = new Group();
4493
+ if ( sceneDef.name ) scene.name = parser.createUniqueName( sceneDef.name );
4494
+
4495
+ assignExtrasToUserData( scene, sceneDef );
4496
+
4497
+ if ( sceneDef.extensions ) addUnknownExtensionsToUserData( extensions, scene, sceneDef );
4498
+
4499
+ const nodeIds = sceneDef.nodes || [];
4500
+
4501
+ const pending = [];
4502
+
4503
+ for ( let i = 0, il = nodeIds.length; i < il; i ++ ) {
4504
+
4505
+ pending.push( parser.getDependency( 'node', nodeIds[ i ] ) );
4506
+
4507
+ }
4508
+
4509
+ return Promise.all( pending ).then( function ( nodes ) {
4510
+
4511
+ for ( let i = 0, il = nodes.length; i < il; i ++ ) {
4512
+
4513
+ scene.add( nodes[ i ] );
4514
+
4515
+ }
4516
+
4517
+ // Removes dangling associations, associations that reference a node that
4518
+ // didn't make it into the scene.
4519
+ const reduceAssociations = ( node ) => {
4520
+
4521
+ const reducedAssociations = new Map();
4522
+
4523
+ for ( const [ key, value ] of parser.associations ) {
4524
+
4525
+ if ( key instanceof Material || key instanceof Texture ) {
4526
+
4527
+ reducedAssociations.set( key, value );
4528
+
4529
+ }
4530
+
4531
+ }
4532
+
4533
+ node.traverse( ( node ) => {
4534
+
4535
+ const mappings = parser.associations.get( node );
4536
+
4537
+ if ( mappings != null ) {
4538
+
4539
+ reducedAssociations.set( node, mappings );
4540
+
4541
+ }
4542
+
4543
+ } );
4544
+
4545
+ return reducedAssociations;
4546
+
4547
+ };
4548
+
4549
+ parser.associations = reduceAssociations( scene );
4550
+
4551
+ return scene;
4552
+
4553
+ } );
4554
+
4555
+ }
4556
+
4557
+ _createAnimationTracks( node, inputAccessor, outputAccessor, sampler, target ) {
4558
+
4559
+ const tracks = [];
4560
+
4561
+ const targetName = node.name ? node.name : node.uuid;
4562
+ const targetNames = [];
4563
+
4564
+ if ( PATH_PROPERTIES[ target.path ] === PATH_PROPERTIES.weights ) {
4565
+
4566
+ node.traverse( function ( object ) {
4567
+
4568
+ if ( object.morphTargetInfluences ) {
4569
+
4570
+ targetNames.push( object.name ? object.name : object.uuid );
4571
+
4572
+ }
4573
+
4574
+ } );
4575
+
4576
+ } else {
4577
+
4578
+ targetNames.push( targetName );
4579
+
4580
+ }
4581
+
4582
+ let TypedKeyframeTrack;
4583
+
4584
+ switch ( PATH_PROPERTIES[ target.path ] ) {
4585
+
4586
+ case PATH_PROPERTIES.weights:
4587
+
4588
+ TypedKeyframeTrack = NumberKeyframeTrack;
4589
+ break;
4590
+
4591
+ case PATH_PROPERTIES.rotation:
4592
+
4593
+ TypedKeyframeTrack = QuaternionKeyframeTrack;
4594
+ break;
4595
+
4596
+ case PATH_PROPERTIES.translation:
4597
+ case PATH_PROPERTIES.scale:
4598
+
4599
+ TypedKeyframeTrack = VectorKeyframeTrack;
4600
+ break;
4601
+
4602
+ default:
4603
+
4604
+ switch ( outputAccessor.itemSize ) {
4605
+
4606
+ case 1:
4607
+ TypedKeyframeTrack = NumberKeyframeTrack;
4608
+ break;
4609
+ case 2:
4610
+ case 3:
4611
+ default:
4612
+ TypedKeyframeTrack = VectorKeyframeTrack;
4613
+ break;
4614
+
4615
+ }
4616
+
4617
+ break;
4618
+
4619
+ }
4620
+
4621
+ const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : InterpolateLinear;
4622
+
4623
+
4624
+ const outputArray = this._getArrayFromAccessor( outputAccessor );
4625
+
4626
+ for ( let j = 0, jl = targetNames.length; j < jl; j ++ ) {
4627
+
4628
+ const track = new TypedKeyframeTrack(
4629
+ targetNames[ j ] + '.' + PATH_PROPERTIES[ target.path ],
4630
+ inputAccessor.array,
4631
+ outputArray,
4632
+ interpolation
4633
+ );
4634
+
4635
+ // Override interpolation with custom factory method.
4636
+ if ( sampler.interpolation === 'CUBICSPLINE' ) {
4637
+
4638
+ this._createCubicSplineTrackInterpolant( track );
4639
+
4640
+ }
4641
+
4642
+ tracks.push( track );
4643
+
4644
+ }
4645
+
4646
+ return tracks;
4647
+
4648
+ }
4649
+
4650
+ _getArrayFromAccessor( accessor ) {
4651
+
4652
+ let outputArray = accessor.array;
4653
+
4654
+ if ( accessor.normalized ) {
4655
+
4656
+ const scale = getNormalizedComponentScale( outputArray.constructor );
4657
+ const scaled = new Float32Array( outputArray.length );
4658
+
4659
+ for ( let j = 0, jl = outputArray.length; j < jl; j ++ ) {
4660
+
4661
+ scaled[ j ] = outputArray[ j ] * scale;
4662
+
4663
+ }
4664
+
4665
+ outputArray = scaled;
4666
+
4667
+ }
4668
+
4669
+ return outputArray;
4670
+
4671
+ }
4672
+
4673
+ _createCubicSplineTrackInterpolant( track ) {
4674
+
4675
+ track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) {
4676
+
4677
+ // A CUBICSPLINE keyframe in glTF has three output values for each input value,
4678
+ // representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
4679
+ // must be divided by three to get the interpolant's sampleSize argument.
4680
+
4681
+ const interpolantType = ( this instanceof QuaternionKeyframeTrack ) ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
4682
+
4683
+ return new interpolantType( this.times, this.values, this.getValueSize() / 3, result );
4684
+
4685
+ };
4686
+
4687
+ // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
4688
+ track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
4689
+
4690
+ }
4691
+
4692
+ }
4693
+
4694
+ /**
4695
+ *
4696
+ * @private
4697
+ * @param {BufferGeometry} geometry
4698
+ * @param {GLTF.Primitive} primitiveDef
4699
+ * @param {GLTFParser} parser
4700
+ */
4701
+ function computeBounds( geometry, primitiveDef, parser ) {
4702
+
4703
+ const attributes = primitiveDef.attributes;
4704
+
4705
+ const box = new Box3();
4706
+
4707
+ if ( attributes.POSITION !== undefined ) {
4708
+
4709
+ const accessor = parser.json.accessors[ attributes.POSITION ];
4710
+
4711
+ const min = accessor.min;
4712
+ const max = accessor.max;
4713
+
4714
+ // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
4715
+
4716
+ if ( min !== undefined && max !== undefined ) {
4717
+
4718
+ box.set(
4719
+ new Vector3( min[ 0 ], min[ 1 ], min[ 2 ] ),
4720
+ new Vector3( max[ 0 ], max[ 1 ], max[ 2 ] )
4721
+ );
4722
+
4723
+ if ( accessor.normalized ) {
4724
+
4725
+ const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] );
4726
+ box.min.multiplyScalar( boxScale );
4727
+ box.max.multiplyScalar( boxScale );
4728
+
4729
+ }
4730
+
4731
+ } else {
4732
+
4733
+ console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' );
4734
+
4735
+ return;
4736
+
4737
+ }
4738
+
4739
+ } else {
4740
+
4741
+ return;
4742
+
4743
+ }
4744
+
4745
+ const targets = primitiveDef.targets;
4746
+
4747
+ if ( targets !== undefined ) {
4748
+
4749
+ const maxDisplacement = new Vector3();
4750
+ const vector = new Vector3();
4751
+
4752
+ for ( let i = 0, il = targets.length; i < il; i ++ ) {
4753
+
4754
+ const target = targets[ i ];
4755
+
4756
+ if ( target.POSITION !== undefined ) {
4757
+
4758
+ const accessor = parser.json.accessors[ target.POSITION ];
4759
+ const min = accessor.min;
4760
+ const max = accessor.max;
4761
+
4762
+ // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
4763
+
4764
+ if ( min !== undefined && max !== undefined ) {
4765
+
4766
+ // we need to get max of absolute components because target weight is [-1,1]
4767
+ vector.setX( Math.max( Math.abs( min[ 0 ] ), Math.abs( max[ 0 ] ) ) );
4768
+ vector.setY( Math.max( Math.abs( min[ 1 ] ), Math.abs( max[ 1 ] ) ) );
4769
+ vector.setZ( Math.max( Math.abs( min[ 2 ] ), Math.abs( max[ 2 ] ) ) );
4770
+
4771
+
4772
+ if ( accessor.normalized ) {
4773
+
4774
+ const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] );
4775
+ vector.multiplyScalar( boxScale );
4776
+
4777
+ }
4778
+
4779
+ // Note: this assumes that the sum of all weights is at most 1. This isn't quite correct - it's more conservative
4780
+ // to assume that each target can have a max weight of 1. However, for some use cases - notably, when morph targets
4781
+ // are used to implement key-frame animations and as such only two are active at a time - this results in very large
4782
+ // boxes. So for now we make a box that's sometimes a touch too small but is hopefully mostly of reasonable size.
4783
+ maxDisplacement.max( vector );
4784
+
4785
+ } else {
4786
+
4787
+ console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' );
4788
+
4789
+ }
4790
+
4791
+ }
4792
+
4793
+ }
4794
+
4795
+ // As per comment above this box isn't conservative, but has a reasonable size for a very large number of morph targets.
4796
+ box.expandByVector( maxDisplacement );
4797
+
4798
+ }
4799
+
4800
+ geometry.boundingBox = box;
4801
+
4802
+ const sphere = new Sphere();
4803
+
4804
+ box.getCenter( sphere.center );
4805
+ sphere.radius = box.min.distanceTo( box.max ) / 2;
4806
+
4807
+ geometry.boundingSphere = sphere;
4808
+
4809
+ }
4810
+
4811
+ /**
4812
+ *
4813
+ * @private
4814
+ * @param {BufferGeometry} geometry
4815
+ * @param {GLTF.Primitive} primitiveDef
4816
+ * @param {GLTFParser} parser
4817
+ * @return {Promise<BufferGeometry>}
4818
+ */
4819
+ function addPrimitiveAttributes( geometry, primitiveDef, parser ) {
4820
+
4821
+ const attributes = primitiveDef.attributes;
4822
+
4823
+ const pending = [];
4824
+
4825
+ function assignAttributeAccessor( accessorIndex, attributeName ) {
4826
+
4827
+ return parser.getDependency( 'accessor', accessorIndex )
4828
+ .then( function ( accessor ) {
4829
+
4830
+ geometry.setAttribute( attributeName, accessor );
4831
+
4832
+ } );
4833
+
4834
+ }
4835
+
4836
+ for ( const gltfAttributeName in attributes ) {
4837
+
4838
+ const threeAttributeName = ATTRIBUTES[ gltfAttributeName ] || gltfAttributeName.toLowerCase();
4839
+
4840
+ // Skip attributes already provided by e.g. Draco extension.
4841
+ if ( threeAttributeName in geometry.attributes ) continue;
4842
+
4843
+ pending.push( assignAttributeAccessor( attributes[ gltfAttributeName ], threeAttributeName ) );
4844
+
4845
+ }
4846
+
4847
+ if ( primitiveDef.indices !== undefined && ! geometry.index ) {
4848
+
4849
+ const accessor = parser.getDependency( 'accessor', primitiveDef.indices ).then( function ( accessor ) {
4850
+
4851
+ geometry.setIndex( accessor );
4852
+
4853
+ } );
4854
+
4855
+ pending.push( accessor );
4856
+
4857
+ }
4858
+
4859
+ if ( ColorManagement.workingColorSpace !== LinearSRGBColorSpace && 'COLOR_0' in attributes ) {
4860
+
4861
+ console.warn( `THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ColorManagement.workingColorSpace}" not supported.` );
4862
+
4863
+ }
4864
+
4865
+ assignExtrasToUserData( geometry, primitiveDef );
4866
+
4867
+ computeBounds( geometry, primitiveDef, parser );
4868
+
4869
+ return Promise.all( pending ).then( function () {
4870
+
4871
+ return primitiveDef.targets !== undefined
4872
+ ? addMorphTargets( geometry, primitiveDef.targets, parser )
4873
+ : geometry;
4874
+
4875
+ } );
4876
+
4877
+ }
4878
+
4879
+ /**
4880
+ * Loader result of `GLTFLoader`.
4881
+ *
4882
+ * @typedef {Object} GLTFLoader~LoadObject
4883
+ * @property {Array<AnimationClip>} animations - An array of animation clips.
4884
+ * @property {Object} asset - Meta data about the loaded asset.
4885
+ * @property {Array<Camera>} cameras - An array of cameras.
4886
+ * @property {GLTFParser} parser - A reference to the internal parser.
4887
+ * @property {Group} scene - The default scene.
4888
+ * @property {Array<Group>} scenes - glTF assets might define multiple scenes.
4889
+ * @property {Object} userData - Additional data.
4890
+ **/
4891
+
4892
+ export { GLTFLoader };