popost 4.6.1 → 4.6.6

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 (1253) hide show
  1. package/LICENSE +59 -3
  2. package/README.md +20 -7
  3. package/SKILL.md +48 -131
  4. package/THIRD_PARTY_NOTICES +524 -0
  5. package/agents/openai.yaml +2 -2
  6. package/assets/video/examples/audio-bars.html +125 -0
  7. package/assets/video/examples/bouncing-ball.html +182 -0
  8. package/assets/video/examples/card-flip.html +92 -0
  9. package/assets/video/examples/catalogue.json +16221 -0
  10. package/assets/video/examples/counter-stat.html +155 -0
  11. package/assets/video/examples/folding-doors.html +94 -0
  12. package/assets/video/examples/glitch-title.html +120 -0
  13. package/assets/video/examples/goo-blobs.html +127 -0
  14. package/assets/video/examples/grid-reveal.html +151 -0
  15. package/assets/video/examples/hf/agent-cursor.html +781 -0
  16. package/assets/video/examples/hf/ai-answer-rank.html +767 -0
  17. package/assets/video/examples/hf/ai-chat-reveal.html +1260 -0
  18. package/assets/video/examples/hf/animated-bar-chart.html +312 -0
  19. package/assets/video/examples/hf/app-showcase.html +1115 -0
  20. package/assets/video/examples/hf/apple-money-count.html +453 -0
  21. package/assets/video/examples/hf/arc-motion-path.html +303 -0
  22. package/assets/video/examples/hf/ascii-render-pass.html +728 -0
  23. package/assets/video/examples/hf/ascii-trail-reveal.html +595 -0
  24. package/assets/video/examples/hf/aurora-drift.html +439 -0
  25. package/assets/video/examples/hf/aurora.html +258 -0
  26. package/assets/video/examples/hf/avatar-cloud.html +667 -0
  27. package/assets/video/examples/hf/avatar-group-hover.html +342 -0
  28. package/assets/video/examples/hf/badge-pop.html +400 -0
  29. package/assets/video/examples/hf/bar-chart-race.html +795 -0
  30. package/assets/video/examples/hf/beat-accent.html +507 -0
  31. package/assets/video/examples/hf/beat-freeze-cut.html +1050 -0
  32. package/assets/video/examples/hf/beat-pulse-background.html +422 -0
  33. package/assets/video/examples/hf/beat-timeline.html +488 -0
  34. package/assets/video/examples/hf/before-after-wipe.html +681 -0
  35. package/assets/video/examples/hf/blob.html +258 -0
  36. package/assets/video/examples/hf/blue-sweater-intro-video.html +1656 -0
  37. package/assets/video/examples/hf/blur-in.html +624 -0
  38. package/assets/video/examples/hf/blur-out-up.html +350 -0
  39. package/assets/video/examples/hf/bottom-up-letters.html +335 -0
  40. package/assets/video/examples/hf/browser-device-stage.html +847 -0
  41. package/assets/video/examples/hf/camcorder-hud.html +371 -0
  42. package/assets/video/examples/hf/camera-dolly-zoom.html +485 -0
  43. package/assets/video/examples/hf/camera-rig-depth-stack.html +246 -0
  44. package/assets/video/examples/hf/camera-scan-gate.html +708 -0
  45. package/assets/video/examples/hf/camera-shake.html +989 -0
  46. package/assets/video/examples/hf/canopy-part-title.html +2549 -0
  47. package/assets/video/examples/hf/caption-blend-difference.html +247 -0
  48. package/assets/video/examples/hf/caption-camera-follow.html +537 -0
  49. package/assets/video/examples/hf/caption-clip-wipe.html +363 -0
  50. package/assets/video/examples/hf/caption-editorial-emphasis.html +615 -0
  51. package/assets/video/examples/hf/caption-emoji-pop.html +623 -0
  52. package/assets/video/examples/hf/caption-glitch-rgb.html +475 -0
  53. package/assets/video/examples/hf/caption-gradient-fill.html +392 -0
  54. package/assets/video/examples/hf/caption-highlight.html +433 -0
  55. package/assets/video/examples/hf/caption-kinetic-slam.html +334 -0
  56. package/assets/video/examples/hf/caption-matrix-decode.html +399 -0
  57. package/assets/video/examples/hf/caption-neon-accent.html +684 -0
  58. package/assets/video/examples/hf/caption-neon-glow.html +373 -0
  59. package/assets/video/examples/hf/caption-parallax-layers.html +530 -0
  60. package/assets/video/examples/hf/caption-particle-burst.html +454 -0
  61. package/assets/video/examples/hf/caption-pill-karaoke.html +517 -0
  62. package/assets/video/examples/hf/caption-texture.html +368 -0
  63. package/assets/video/examples/hf/caption-weight-shift.html +566 -0
  64. package/assets/video/examples/hf/card-resize.html +435 -0
  65. package/assets/video/examples/hf/caret-swap.html +601 -0
  66. package/assets/video/examples/hf/carousel-circle-1.html +1175 -0
  67. package/assets/video/examples/hf/carousel-circle-2.html +1175 -0
  68. package/assets/video/examples/hf/carousel-circle-3.html +1175 -0
  69. package/assets/video/examples/hf/carousel-circle-4.html +1175 -0
  70. package/assets/video/examples/hf/carousel-circle-5.html +1175 -0
  71. package/assets/video/examples/hf/carousel-orbit-1.html +1198 -0
  72. package/assets/video/examples/hf/carousel-orbit-2.html +1198 -0
  73. package/assets/video/examples/hf/carousel-orbit-3.html +1198 -0
  74. package/assets/video/examples/hf/carousel-orbit-4.html +1214 -0
  75. package/assets/video/examples/hf/carousel-orbit-5.html +1198 -0
  76. package/assets/video/examples/hf/carousel-path-1.html +1219 -0
  77. package/assets/video/examples/hf/carousel-path-2.html +1176 -0
  78. package/assets/video/examples/hf/carousel-path-3.html +1190 -0
  79. package/assets/video/examples/hf/carousel-path-4.html +1219 -0
  80. package/assets/video/examples/hf/carousel-path-5.html +1218 -0
  81. package/assets/video/examples/hf/carousel-vision-1.html +1180 -0
  82. package/assets/video/examples/hf/carousel-vision-2.html +1180 -0
  83. package/assets/video/examples/hf/carousel-vision-3.html +1180 -0
  84. package/assets/video/examples/hf/carousel-vision-4.html +1187 -0
  85. package/assets/video/examples/hf/carousel-vision-5.html +1180 -0
  86. package/assets/video/examples/hf/char-slam-explode.html +546 -0
  87. package/assets/video/examples/hf/chart-story.html +973 -0
  88. package/assets/video/examples/hf/chat-message.html +635 -0
  89. package/assets/video/examples/hf/chat-thread.html +953 -0
  90. package/assets/video/examples/hf/chatgpt-exchange.html +1620 -0
  91. package/assets/video/examples/hf/chromatic-radial-split.html +613 -0
  92. package/assets/video/examples/hf/chrome-orb.html +258 -0
  93. package/assets/video/examples/hf/cinemagraph.html +422 -0
  94. package/assets/video/examples/hf/cinematic-zoom.html +613 -0
  95. package/assets/video/examples/hf/claude-exchange.html +1845 -0
  96. package/assets/video/examples/hf/code-3d-extrude.html +755 -0
  97. package/assets/video/examples/hf/code-diff.html +956 -0
  98. package/assets/video/examples/hf/code-highlight.html +885 -0
  99. package/assets/video/examples/hf/code-morph.html +1357 -0
  100. package/assets/video/examples/hf/code-particle-assemble.html +622 -0
  101. package/assets/video/examples/hf/code-scroll.html +1700 -0
  102. package/assets/video/examples/hf/code-shader-dissolve.html +677 -0
  103. package/assets/video/examples/hf/code-slice-hero.html +1276 -0
  104. package/assets/video/examples/hf/code-snippet-apple-terminal-pro.html +388 -0
  105. package/assets/video/examples/hf/code-snippet-dark-2026.html +1231 -0
  106. package/assets/video/examples/hf/code-snippet-dark-modern.html +1227 -0
  107. package/assets/video/examples/hf/code-terminal-run.html +766 -0
  108. package/assets/video/examples/hf/code-typing.html +903 -0
  109. package/assets/video/examples/hf/color-wheel.html +258 -0
  110. package/assets/video/examples/hf/colorama-wipe.html +503 -0
  111. package/assets/video/examples/hf/comparison-split.html +657 -0
  112. package/assets/video/examples/hf/confetti.html +349 -0
  113. package/assets/video/examples/hf/conic-progress-ring.html +441 -0
  114. package/assets/video/examples/hf/constellation-hub.html +662 -0
  115. package/assets/video/examples/hf/cosmic-orb.html +643 -0
  116. package/assets/video/examples/hf/count-up.html +552 -0
  117. package/assets/video/examples/hf/cross-warp-morph.html +624 -0
  118. package/assets/video/examples/hf/cta-close.html +492 -0
  119. package/assets/video/examples/hf/cta-lockup.html +470 -0
  120. package/assets/video/examples/hf/cuboid-carousel.html +2385 -0
  121. package/assets/video/examples/hf/cursor-annotate.html +827 -0
  122. package/assets/video/examples/hf/cursor-context-menu.html +757 -0
  123. package/assets/video/examples/hf/cursor-drag-drop.html +656 -0
  124. package/assets/video/examples/hf/cursor-glyph-trail.html +904 -0
  125. package/assets/video/examples/hf/cursor-marquee-select.html +1266 -0
  126. package/assets/video/examples/hf/cursor-text-select.html +638 -0
  127. package/assets/video/examples/hf/cursor-zoom-follow.html +973 -0
  128. package/assets/video/examples/hf/curtain-reveal.html +590 -0
  129. package/assets/video/examples/hf/cut-the-curve.html +715 -0
  130. package/assets/video/examples/hf/dart-cursor.html +863 -0
  131. package/assets/video/examples/hf/data-chart.html +666 -0
  132. package/assets/video/examples/hf/decision-tree.html +655 -0
  133. package/assets/video/examples/hf/decline-chart.html +485 -0
  134. package/assets/video/examples/hf/device-frame-stage.html +661 -0
  135. package/assets/video/examples/hf/domain-warp-dissolve.html +627 -0
  136. package/assets/video/examples/hf/drift-hold.html +392 -0
  137. package/assets/video/examples/hf/dynamic-grid.html +336 -0
  138. package/assets/video/examples/hf/echo-smear.html +994 -0
  139. package/assets/video/examples/hf/echo-trail.html +557 -0
  140. package/assets/video/examples/hf/editorial-flash-overlay.html +337 -0
  141. package/assets/video/examples/hf/exploded-stack.html +761 -0
  142. package/assets/video/examples/hf/extended-keyframe.html +715 -0
  143. package/assets/video/examples/hf/extruded-logo.html +757 -0
  144. package/assets/video/examples/hf/facet-morph.html +746 -0
  145. package/assets/video/examples/hf/fade-through.html +443 -0
  146. package/assets/video/examples/hf/falling-lines.html +259 -0
  147. package/assets/video/examples/hf/filmed-screen.html +1065 -0
  148. package/assets/video/examples/hf/flash-through-white.html +613 -0
  149. package/assets/video/examples/hf/flowchart-vertical.html +631 -0
  150. package/assets/video/examples/hf/flowchart.html +630 -0
  151. package/assets/video/examples/hf/flowing-gradient.html +258 -0
  152. package/assets/video/examples/hf/focus-blur-resolve.html +321 -0
  153. package/assets/video/examples/hf/focus-rack.html +542 -0
  154. package/assets/video/examples/hf/focus-swap.html +496 -0
  155. package/assets/video/examples/hf/fractal-noise.html +258 -0
  156. package/assets/video/examples/hf/freeze-frame-dressing.html +357 -0
  157. package/assets/video/examples/hf/frost.html +258 -0
  158. package/assets/video/examples/hf/gabor-noise.html +258 -0
  159. package/assets/video/examples/hf/gallery-tunnel.html +652 -0
  160. package/assets/video/examples/hf/gesture-tap.html +604 -0
  161. package/assets/video/examples/hf/glass-hero.html +505 -0
  162. package/assets/video/examples/hf/glass-shard-title.html +1618 -0
  163. package/assets/video/examples/hf/glitch.html +613 -0
  164. package/assets/video/examples/hf/gloss-sweep.html +418 -0
  165. package/assets/video/examples/hf/godrays.html +257 -0
  166. package/assets/video/examples/hf/goo.html +258 -0
  167. package/assets/video/examples/hf/gooey-split.html +1092 -0
  168. package/assets/video/examples/hf/grain-field.html +377 -0
  169. package/assets/video/examples/hf/grain-overlay.html +295 -0
  170. package/assets/video/examples/hf/gravitational-lens.html +612 -0
  171. package/assets/video/examples/hf/grid-card-assemble.html +671 -0
  172. package/assets/video/examples/hf/grid-pixelate-wipe.html +314 -0
  173. package/assets/video/examples/hf/halftone-dissolve.html +696 -0
  174. package/assets/video/examples/hf/halftone-field.html +598 -0
  175. package/assets/video/examples/hf/headline-slam.html +455 -0
  176. package/assets/video/examples/hf/heatmap.html +258 -0
  177. package/assets/video/examples/hf/heygen-avatar-promo-card.html +627 -0
  178. package/assets/video/examples/hf/hologram.html +258 -0
  179. package/assets/video/examples/hf/holographic.html +258 -0
  180. package/assets/video/examples/hf/hw-arrow.html +835 -0
  181. package/assets/video/examples/hf/hw-boil.html +632 -0
  182. package/assets/video/examples/hf/hw-box-label.html +741 -0
  183. package/assets/video/examples/hf/hw-callout-circle.html +820 -0
  184. package/assets/video/examples/hf/hw-frame.html +455 -0
  185. package/assets/video/examples/hf/hw-path-text.html +349 -0
  186. package/assets/video/examples/hf/hw-pipeline.html +472 -0
  187. package/assets/video/examples/hf/hw-scribble-transition.html +291 -0
  188. package/assets/video/examples/hf/hw-text-cloud.html +439 -0
  189. package/assets/video/examples/hf/hw-title.html +412 -0
  190. package/assets/video/examples/hf/hw-underline.html +403 -0
  191. package/assets/video/examples/hf/hw-write-title.html +1389 -0
  192. package/assets/video/examples/hf/icon-morph-beat.html +463 -0
  193. package/assets/video/examples/hf/icon-swap.html +380 -0
  194. package/assets/video/examples/hf/ink-bleed-reveal.html +659 -0
  195. package/assets/video/examples/hf/inline-highlight.html +322 -0
  196. package/assets/video/examples/hf/input-feedback.html +419 -0
  197. package/assets/video/examples/hf/instagram-follow.html +460 -0
  198. package/assets/video/examples/hf/ios26-liquid-glass.html +1597 -0
  199. package/assets/video/examples/hf/iris-reveal.html +684 -0
  200. package/assets/video/examples/hf/keyframe-scrub-stack.html +326 -0
  201. package/assets/video/examples/hf/kinetic-center-build.html +538 -0
  202. package/assets/video/examples/hf/kinetic-type-swap.html +610 -0
  203. package/assets/video/examples/hf/kinetic-type.html +862 -0
  204. package/assets/video/examples/hf/lens-flare.html +258 -0
  205. package/assets/video/examples/hf/light-edge.html +259 -0
  206. package/assets/video/examples/hf/light-leak.html +612 -0
  207. package/assets/video/examples/hf/light-sweep-pass.html +684 -0
  208. package/assets/video/examples/hf/line-by-line-slide.html +345 -0
  209. package/assets/video/examples/hf/line-swap.html +526 -0
  210. package/assets/video/examples/hf/liquid-glass-notification.html +1898 -0
  211. package/assets/video/examples/hf/liquid-glass-widgets.html +2175 -0
  212. package/assets/video/examples/hf/liquid-metal.html +259 -0
  213. package/assets/video/examples/hf/locked-nucleus-orbit.html +564 -0
  214. package/assets/video/examples/hf/logo-brand-close.html +598 -0
  215. package/assets/video/examples/hf/logo-outro.html +397 -0
  216. package/assets/video/examples/hf/logo-sting.html +378 -0
  217. package/assets/video/examples/hf/logo-wall.html +502 -0
  218. package/assets/video/examples/hf/lottie-character-walk.html +407 -0
  219. package/assets/video/examples/hf/lt-accent-underline.html +247 -0
  220. package/assets/video/examples/hf/lt-bold-block.html +249 -0
  221. package/assets/video/examples/hf/lt-clean-bar.html +251 -0
  222. package/assets/video/examples/hf/lt-color-block.html +241 -0
  223. package/assets/video/examples/hf/lt-dark-card.html +251 -0
  224. package/assets/video/examples/hf/lt-kicker-name.html +254 -0
  225. package/assets/video/examples/hf/lt-mask-reveal.html +260 -0
  226. package/assets/video/examples/hf/lt-neon-border.html +604 -0
  227. package/assets/video/examples/hf/lt-side-rule.html +254 -0
  228. package/assets/video/examples/hf/lt-soft-pill.html +259 -0
  229. package/assets/video/examples/hf/lt-stack-bars.html +249 -0
  230. package/assets/video/examples/hf/macos-notification.html +372 -0
  231. package/assets/video/examples/hf/macos-tahoe-liquid-glass.html +1701 -0
  232. package/assets/video/examples/hf/magnetic-cursor.html +684 -0
  233. package/assets/video/examples/hf/marble.html +257 -0
  234. package/assets/video/examples/hf/marker-checklist-card.html +727 -0
  235. package/assets/video/examples/hf/marker-highlight.html +589 -0
  236. package/assets/video/examples/hf/match-cut.html +505 -0
  237. package/assets/video/examples/hf/matrix-decode.html +363 -0
  238. package/assets/video/examples/hf/menu-morph.html +420 -0
  239. package/assets/video/examples/hf/mesh-gradient-bg.html +329 -0
  240. package/assets/video/examples/hf/mesh-gradient.html +257 -0
  241. package/assets/video/examples/hf/message-thread-reveal.html +1913 -0
  242. package/assets/video/examples/hf/micro-transitions.html +631 -0
  243. package/assets/video/examples/hf/mk-background.html +376 -0
  244. package/assets/video/examples/hf/mk-callout-highlight.html +322 -0
  245. package/assets/video/examples/hf/mk-clone-wall-transition.html +364 -0
  246. package/assets/video/examples/hf/mk-emphasis-type.html +235 -0
  247. package/assets/video/examples/hf/mk-line-graph.html +432 -0
  248. package/assets/video/examples/hf/mk-placeholder-grid.html +373 -0
  249. package/assets/video/examples/hf/mk-progress-stat.html +324 -0
  250. package/assets/video/examples/hf/mk-specs-list.html +362 -0
  251. package/assets/video/examples/hf/mk-usage-arc.html +297 -0
  252. package/assets/video/examples/hf/modal-morph.html +727 -0
  253. package/assets/video/examples/hf/morph-swap.html +590 -0
  254. package/assets/video/examples/hf/morph-text.html +409 -0
  255. package/assets/video/examples/hf/multi-device-splay.html +934 -0
  256. package/assets/video/examples/hf/multiplayer-cursors.html +642 -0
  257. package/assets/video/examples/hf/native-notification-pop.html +670 -0
  258. package/assets/video/examples/hf/nebula.html +258 -0
  259. package/assets/video/examples/hf/news-ticker.html +548 -0
  260. package/assets/video/examples/hf/north-korea-locked-down.html +447 -0
  261. package/assets/video/examples/hf/notes-reveal.html +2028 -0
  262. package/assets/video/examples/hf/notes-typing.html +631 -0
  263. package/assets/video/examples/hf/notification-cascade.html +740 -0
  264. package/assets/video/examples/hf/notification-pileup.html +667 -0
  265. package/assets/video/examples/hf/notification-stack.html +610 -0
  266. package/assets/video/examples/hf/number-pop-in.html +362 -0
  267. package/assets/video/examples/hf/number-wheel.html +378 -0
  268. package/assets/video/examples/hf/nyc-paris-flight.html +659 -0
  269. package/assets/video/examples/hf/nyt-graph.html +715 -0
  270. package/assets/video/examples/hf/obsidian.html +258 -0
  271. package/assets/video/examples/hf/offset-path-traveler.html +511 -0
  272. package/assets/video/examples/hf/onboarding-stepper-flow.html +292 -0
  273. package/assets/video/examples/hf/orbit-card.html +2457 -0
  274. package/assets/video/examples/hf/ordered-dither-pass.html +753 -0
  275. package/assets/video/examples/hf/organic-light-leak-overlay.html +336 -0
  276. package/assets/video/examples/hf/oscilloscope-trace.html +718 -0
  277. package/assets/video/examples/hf/outline-draw.html +394 -0
  278. package/assets/video/examples/hf/oversized-cursor.html +851 -0
  279. package/assets/video/examples/hf/overwhelm-surround.html +557 -0
  280. package/assets/video/examples/hf/page-slide.html +377 -0
  281. package/assets/video/examples/hf/pan-stations.html +555 -0
  282. package/assets/video/examples/hf/panel-reveal.html +370 -0
  283. package/assets/video/examples/hf/paper-collage-reveal.html +737 -0
  284. package/assets/video/examples/hf/parallax-device-dive.html +647 -0
  285. package/assets/video/examples/hf/parallax-unzoom.html +499 -0
  286. package/assets/video/examples/hf/parallax-zoom.html +515 -0
  287. package/assets/video/examples/hf/particle-image-reveal.html +595 -0
  288. package/assets/video/examples/hf/particle-text-dissolve.html +615 -0
  289. package/assets/video/examples/hf/path-traced-3d.html +508 -0
  290. package/assets/video/examples/hf/pendulum-swing.html +364 -0
  291. package/assets/video/examples/hf/per-word-crossfade.html +398 -0
  292. package/assets/video/examples/hf/per-word-rise.html +556 -0
  293. package/assets/video/examples/hf/perspective-marquee.html +366 -0
  294. package/assets/video/examples/hf/physical-exit.html +459 -0
  295. package/assets/video/examples/hf/plasma.html +258 -0
  296. package/assets/video/examples/hf/plastic.html +258 -0
  297. package/assets/video/examples/hf/play-mode.html +1035 -0
  298. package/assets/video/examples/hf/press-ripple.html +675 -0
  299. package/assets/video/examples/hf/prism.html +258 -0
  300. package/assets/video/examples/hf/product-promo.html +1311 -0
  301. package/assets/video/examples/hf/product-turntable.html +4569 -0
  302. package/assets/video/examples/hf/pull-back-reveal.html +546 -0
  303. package/assets/video/examples/hf/pull-to-refresh.html +861 -0
  304. package/assets/video/examples/hf/push-in.html +379 -0
  305. package/assets/video/examples/hf/rack-focus.html +779 -0
  306. package/assets/video/examples/hf/radial-surround.html +653 -0
  307. package/assets/video/examples/hf/reddit-post.html +515 -0
  308. package/assets/video/examples/hf/rgb-glitch-text.html +353 -0
  309. package/assets/video/examples/hf/ridged-burn.html +624 -0
  310. package/assets/video/examples/hf/ripple-waves.html +613 -0
  311. package/assets/video/examples/hf/ripples.html +259 -0
  312. package/assets/video/examples/hf/rubber-band-bumper.html +534 -0
  313. package/assets/video/examples/hf/scan-band.html +415 -0
  314. package/assets/video/examples/hf/scramble-reveal.html +510 -0
  315. package/assets/video/examples/hf/screen-flow-carousel.html +779 -0
  316. package/assets/video/examples/hf/scroll-camera-story.html +988 -0
  317. package/assets/video/examples/hf/scroll-feed.html +602 -0
  318. package/assets/video/examples/hf/sdf-iris.html +613 -0
  319. package/assets/video/examples/hf/segmentation-flood.html +748 -0
  320. package/assets/video/examples/hf/separator.html +620 -0
  321. package/assets/video/examples/hf/settings-toggle-flow.html +286 -0
  322. package/assets/video/examples/hf/share-sheet-carousel.html +591 -0
  323. package/assets/video/examples/hf/shared-axis-y.html +370 -0
  324. package/assets/video/examples/hf/shared-axis-z.html +514 -0
  325. package/assets/video/examples/hf/sheet-spring-up.html +681 -0
  326. package/assets/video/examples/hf/shimmer-sweep.html +301 -0
  327. package/assets/video/examples/hf/signup-flow.html +276 -0
  328. package/assets/video/examples/hf/sine-wave.html +258 -0
  329. package/assets/video/examples/hf/skeleton-reveal.html +373 -0
  330. package/assets/video/examples/hf/slack-notification-ad.html +901 -0
  331. package/assets/video/examples/hf/slit-scan-reveal.html +540 -0
  332. package/assets/video/examples/hf/slot-machine-roll.html +391 -0
  333. package/assets/video/examples/hf/snow.html +499 -0
  334. package/assets/video/examples/hf/social-proof-card.html +534 -0
  335. package/assets/video/examples/hf/soft-blur-in.html +322 -0
  336. package/assets/video/examples/hf/spain-map.html +583 -0
  337. package/assets/video/examples/hf/spiral-galaxy.html +507 -0
  338. package/assets/video/examples/hf/spiral.html +258 -0
  339. package/assets/video/examples/hf/split-flap-board.html +537 -0
  340. package/assets/video/examples/hf/split-tilt-cards.html +775 -0
  341. package/assets/video/examples/hf/spotify-card.html +470 -0
  342. package/assets/video/examples/hf/spotlight-card.html +328 -0
  343. package/assets/video/examples/hf/spring-pop.html +406 -0
  344. package/assets/video/examples/hf/spring-stack-shuffle.html +791 -0
  345. package/assets/video/examples/hf/stagger-cascade.html +465 -0
  346. package/assets/video/examples/hf/stagger-lattice.html +278 -0
  347. package/assets/video/examples/hf/staggered-fade-up.html +368 -0
  348. package/assets/video/examples/hf/star-rating-fill.html +511 -0
  349. package/assets/video/examples/hf/starfield.html +450 -0
  350. package/assets/video/examples/hf/state-chip-rail.html +585 -0
  351. package/assets/video/examples/hf/sticky-mock-swap.html +664 -0
  352. package/assets/video/examples/hf/stitched-text-draw.html +1053 -0
  353. package/assets/video/examples/hf/stop-motion-cadence.html +670 -0
  354. package/assets/video/examples/hf/store-badge-lockup.html +521 -0
  355. package/assets/video/examples/hf/strands.html +258 -0
  356. package/assets/video/examples/hf/streaming-text.html +581 -0
  357. package/assets/video/examples/hf/strikethrough-replace.html +356 -0
  358. package/assets/video/examples/hf/stripes.html +258 -0
  359. package/assets/video/examples/hf/success-check.html +390 -0
  360. package/assets/video/examples/hf/sun-burst.html +258 -0
  361. package/assets/video/examples/hf/svg-line-draw-loader.html +257 -0
  362. package/assets/video/examples/hf/svg-mask-reveal.html +523 -0
  363. package/assets/video/examples/hf/svg-stroke-trace.html +465 -0
  364. package/assets/video/examples/hf/swipe-rail.html +564 -0
  365. package/assets/video/examples/hf/swirl-vortex.html +623 -0
  366. package/assets/video/examples/hf/swirl.html +258 -0
  367. package/assets/video/examples/hf/swiss-grid.html +837 -0
  368. package/assets/video/examples/hf/tabs-slide-indicator.html +424 -0
  369. package/assets/video/examples/hf/telemetry-hud.html +760 -0
  370. package/assets/video/examples/hf/terminal-simulator.html +293 -0
  371. package/assets/video/examples/hf/testimonial-card.html +545 -0
  372. package/assets/video/examples/hf/testimonial-proof-card.html +720 -0
  373. package/assets/video/examples/hf/text-match-cut.html +1345 -0
  374. package/assets/video/examples/hf/text-shimmer.html +394 -0
  375. package/assets/video/examples/hf/text-stagger.html +373 -0
  376. package/assets/video/examples/hf/text-state-swap.html +421 -0
  377. package/assets/video/examples/hf/thermal-distortion.html +624 -0
  378. package/assets/video/examples/hf/thin-film.html +258 -0
  379. package/assets/video/examples/hf/thread-message-stack.html +377 -0
  380. package/assets/video/examples/hf/three-orbiting-cards.html +322 -0
  381. package/assets/video/examples/hf/ticker-takeover.html +534 -0
  382. package/assets/video/examples/hf/tiktok-follow.html +435 -0
  383. package/assets/video/examples/hf/tilt-card.html +406 -0
  384. package/assets/video/examples/hf/titlecard-calm.html +388 -0
  385. package/assets/video/examples/hf/titlecard-lockup.html +546 -0
  386. package/assets/video/examples/hf/toggle-flip.html +601 -0
  387. package/assets/video/examples/hf/top-down-letters.html +326 -0
  388. package/assets/video/examples/hf/torn-paper-rip.html +762 -0
  389. package/assets/video/examples/hf/touch-indicator.html +777 -0
  390. package/assets/video/examples/hf/tracing-beam.html +608 -0
  391. package/assets/video/examples/hf/tracking-in.html +317 -0
  392. package/assets/video/examples/hf/transitions-3d.html +434 -0
  393. package/assets/video/examples/hf/transitions-blur.html +524 -0
  394. package/assets/video/examples/hf/transitions-cover.html +508 -0
  395. package/assets/video/examples/hf/transitions-destruction.html +551 -0
  396. package/assets/video/examples/hf/transitions-dissolve.html +529 -0
  397. package/assets/video/examples/hf/transitions-distortion.html +522 -0
  398. package/assets/video/examples/hf/transitions-grid.html +442 -0
  399. package/assets/video/examples/hf/transitions-light.html +528 -0
  400. package/assets/video/examples/hf/transitions-mechanical.html +560 -0
  401. package/assets/video/examples/hf/transitions-other.html +532 -0
  402. package/assets/video/examples/hf/transitions-push.html +520 -0
  403. package/assets/video/examples/hf/transitions-radial.html +492 -0
  404. package/assets/video/examples/hf/transitions-scale.html +487 -0
  405. package/assets/video/examples/hf/trust-strip.html +445 -0
  406. package/assets/video/examples/hf/typed-prompt.html +619 -0
  407. package/assets/video/examples/hf/typewriter.html +350 -0
  408. package/assets/video/examples/hf/typing-indicator.html +702 -0
  409. package/assets/video/examples/hf/ui-3d-reveal.html +2929 -0
  410. package/assets/video/examples/hf/ui-focus-zoom.html +786 -0
  411. package/assets/video/examples/hf/us-map-bubble.html +669 -0
  412. package/assets/video/examples/hf/us-map-flow.html +621 -0
  413. package/assets/video/examples/hf/us-map-hex.html +733 -0
  414. package/assets/video/examples/hf/us-map.html +591 -0
  415. package/assets/video/examples/hf/variable-font-flex.html +538 -0
  416. package/assets/video/examples/hf/vector-editor-rig.html +977 -0
  417. package/assets/video/examples/hf/vfx-anamorphic-flare.html +572 -0
  418. package/assets/video/examples/hf/vfx-iphone-device.html +1089 -0
  419. package/assets/video/examples/hf/vfx-liquid-background.html +1479 -0
  420. package/assets/video/examples/hf/vfx-liquid-glass.html +2054 -0
  421. package/assets/video/examples/hf/vfx-magnetic.html +660 -0
  422. package/assets/video/examples/hf/vfx-portal.html +1090 -0
  423. package/assets/video/examples/hf/vfx-shatter.html +1382 -0
  424. package/assets/video/examples/hf/vignette.html +385 -0
  425. package/assets/video/examples/hf/voronoi.html +258 -0
  426. package/assets/video/examples/hf/vox-annotate.html +707 -0
  427. package/assets/video/examples/hf/vpn-youtube-spot.html +1118 -0
  428. package/assets/video/examples/hf/water.html +258 -0
  429. package/assets/video/examples/hf/waveform.html +258 -0
  430. package/assets/video/examples/hf/week-in-merges.html +673 -0
  431. package/assets/video/examples/hf/weight-wave.html +531 -0
  432. package/assets/video/examples/hf/whip-pan-cut.html +668 -0
  433. package/assets/video/examples/hf/whip-pan.html +613 -0
  434. package/assets/video/examples/hf/whiteboard-ink.html +763 -0
  435. package/assets/video/examples/hf/wireframe-portal-title.html +3840 -0
  436. package/assets/video/examples/hf/wordmark-tiles.html +559 -0
  437. package/assets/video/examples/hf/world-map.html +623 -0
  438. package/assets/video/examples/hf/worley-noise.html +259 -0
  439. package/assets/video/examples/hf/x-follow-card.html +286 -0
  440. package/assets/video/examples/hf/x-post.html +611 -0
  441. package/assets/video/examples/hf/yt-camera-move.html +308 -0
  442. package/assets/video/examples/hf/yt-circle-pointer.html +301 -0
  443. package/assets/video/examples/hf/yt-comment-card.html +458 -0
  444. package/assets/video/examples/hf/yt-feather-highlight.html +279 -0
  445. package/assets/video/examples/hf/yt-lcd-background.html +446 -0
  446. package/assets/video/examples/hf/yt-logo-intro.html +390 -0
  447. package/assets/video/examples/hf/yt-lower-third.html +414 -0
  448. package/assets/video/examples/hf/yt-prism-title.html +343 -0
  449. package/assets/video/examples/hf/yt-screen-warp.html +257 -0
  450. package/assets/video/examples/hf/yt-vertical-fill.html +367 -0
  451. package/assets/video/examples/kinetic-type.html +137 -0
  452. package/assets/video/examples/motion-blur-streak.html +119 -0
  453. package/assets/video/examples/object-reveal.html +107 -0
  454. package/assets/video/examples/parallax-layers.html +130 -0
  455. package/assets/video/examples/particle-burst.html +157 -0
  456. package/assets/video/examples/pen-draw.html +146 -0
  457. package/assets/video/examples/shape-morph.html +151 -0
  458. package/assets/video/examples/slam-title.html +125 -0
  459. package/assets/video/examples/speed-lines.html +123 -0
  460. package/assets/video/examples/spring-pop.html +129 -0
  461. package/assets/video/examples/streak-wipe.html +78 -0
  462. package/assets/video/examples/three-chrome-knot.html +155 -0
  463. package/assets/video/examples/three-clay.html +138 -0
  464. package/assets/video/examples/three-cube-wave.html +140 -0
  465. package/assets/video/examples/three-extruded-shape.html +148 -0
  466. package/assets/video/examples/type-on.html +128 -0
  467. package/assets/video/motion.js +991 -0
  468. package/assets/video/screen.js +298 -0
  469. package/assets/video/sfx/catalogue.json +2283 -0
  470. package/dist/cli.js +35440 -2563
  471. package/dist/index.js +35143 -2437
  472. package/dist/types/args.d.ts +2 -0
  473. package/dist/types/cloud/service.d.ts +13 -0
  474. package/dist/types/commands/usage.d.ts +2 -0
  475. package/dist/types/commands/video.d.ts +10 -0
  476. package/dist/types/cpu-budget.d.ts +43 -0
  477. package/dist/types/images/batch-jobs.d.ts +2 -0
  478. package/dist/types/images/batch-run.d.ts +2 -1
  479. package/dist/types/images/jobs.d.ts +7 -0
  480. package/dist/types/images/pending.d.ts +40 -0
  481. package/dist/types/images/retry.d.ts +4 -1
  482. package/dist/types/images/run.d.ts +9 -1
  483. package/dist/types/node-runtime.d.ts +6 -1
  484. package/dist/types/providers/api.d.ts +9 -0
  485. package/dist/types/providers/base.d.ts +2 -0
  486. package/dist/types/providers/cli-generate.d.ts +5 -1
  487. package/dist/types/providers/cli-pending.d.ts +24 -0
  488. package/dist/types/providers/errors.d.ts +2 -1
  489. package/dist/types/providers/ledger.d.ts +10 -6
  490. package/dist/types/providers/popost-async.d.ts +35 -0
  491. package/dist/types/providers/popost-tasks.d.ts +16 -5
  492. package/dist/types/providers/popost.d.ts +16 -1
  493. package/dist/types/providers/task.d.ts +43 -0
  494. package/dist/types/render/browser.d.ts +16 -2
  495. package/dist/types/runtime.d.ts +73 -2
  496. package/dist/types/version.d.ts +1 -1
  497. package/dist/types/video/align/index.d.ts +43 -0
  498. package/dist/types/video/capture/director.d.ts +70 -0
  499. package/dist/types/video/capture/index.d.ts +141 -0
  500. package/dist/types/video/capture/stage.d.ts +99 -0
  501. package/dist/types/video/capture/steps.d.ts +138 -0
  502. package/dist/types/video/commands/cast.d.ts +3 -0
  503. package/dist/types/video/commands/clips.d.ts +2 -0
  504. package/dist/types/video/commands/compare-scope.d.ts +7 -0
  505. package/dist/types/video/commands/credits.d.ts +19 -0
  506. package/dist/types/video/commands/elements.d.ts +22 -0
  507. package/dist/types/video/commands/eval.d.ts +2 -0
  508. package/dist/types/video/commands/example.d.ts +1 -0
  509. package/dist/types/video/commands/generate.d.ts +14 -0
  510. package/dist/types/video/commands/loop-shared.d.ts +12 -0
  511. package/dist/types/video/commands/loop.d.ts +4 -0
  512. package/dist/types/video/commands/make.d.ts +9 -0
  513. package/dist/types/video/commands/materials.d.ts +1 -0
  514. package/dist/types/video/commands/measure.d.ts +2 -0
  515. package/dist/types/video/commands/media.d.ts +2 -0
  516. package/dist/types/video/commands/music-plan.d.ts +1 -0
  517. package/dist/types/video/commands/music.d.ts +2 -0
  518. package/dist/types/video/commands/read.d.ts +19 -0
  519. package/dist/types/video/commands/replication.d.ts +2 -0
  520. package/dist/types/video/commands/sfx-extract.d.ts +2 -0
  521. package/dist/types/video/commands/sfx-place.d.ts +3 -0
  522. package/dist/types/video/commands/sfx.d.ts +2 -0
  523. package/dist/types/video/commands/shared.d.ts +39 -0
  524. package/dist/types/video/commands/source.d.ts +2 -0
  525. package/dist/types/video/commands/speech-check.d.ts +1 -0
  526. package/dist/types/video/commands/speech-kind.d.ts +6 -0
  527. package/dist/types/video/commands/template.d.ts +10 -0
  528. package/dist/types/video/commands/voice-profile.d.ts +2 -0
  529. package/dist/types/video/commands/voice-sample.d.ts +1 -0
  530. package/dist/types/video/compile/footage.d.ts +36 -0
  531. package/dist/types/video/compile/index.d.ts +30 -0
  532. package/dist/types/video/compile/page-bundle.d.ts +1 -0
  533. package/dist/types/video/compile/page.d.ts +10 -0
  534. package/dist/types/video/compile/words.d.ts +9 -0
  535. package/dist/types/video/describe/aim.d.ts +20 -0
  536. package/dist/types/video/describe/beats.d.ts +53 -0
  537. package/dist/types/video/describe/curves.d.ts +27 -0
  538. package/dist/types/video/describe/frames.d.ts +62 -0
  539. package/dist/types/video/describe/index.d.ts +34 -0
  540. package/dist/types/video/describe/inset.d.ts +83 -0
  541. package/dist/types/video/describe/kind.d.ts +29 -0
  542. package/dist/types/video/describe/known.d.ts +31 -0
  543. package/dist/types/video/describe/movement.d.ts +17 -0
  544. package/dist/types/video/describe/parts.d.ts +50 -0
  545. package/dist/types/video/describe/paths.d.ts +21 -0
  546. package/dist/types/video/describe/speech-kind.d.ts +144 -0
  547. package/dist/types/video/describe/unrecovered.d.ts +29 -0
  548. package/dist/types/video/draft/build.d.ts +34 -0
  549. package/dist/types/video/draft/export.d.ts +19 -0
  550. package/dist/types/video/draft/lifecycle.d.ts +9 -0
  551. package/dist/types/video/draft/native.d.ts +27 -0
  552. package/dist/types/video/draft/schema.d.ts +316 -0
  553. package/dist/types/video/draft/targets.d.ts +19 -0
  554. package/dist/types/video/elements/caption-reading.d.ts +9 -0
  555. package/dist/types/video/elements/caption-roles.d.ts +6 -0
  556. package/dist/types/video/elements/carry.d.ts +45 -0
  557. package/dist/types/video/elements/check.d.ts +14 -0
  558. package/dist/types/video/elements/findings.d.ts +49 -0
  559. package/dist/types/video/elements/main.d.ts +54 -0
  560. package/dist/types/video/elements/picture.d.ts +31 -0
  561. package/dist/types/video/elements/questions.d.ts +35 -0
  562. package/dist/types/video/elements/read.d.ts +14 -0
  563. package/dist/types/video/elements/status.d.ts +23 -0
  564. package/dist/types/video/elements/types.d.ts +120 -0
  565. package/dist/types/video/eval/contrast.d.ts +136 -0
  566. package/dist/types/video/eval/dataset.d.ts +21 -0
  567. package/dist/types/video/eval/floor.d.ts +27 -0
  568. package/dist/types/video/eval/ledger.d.ts +27 -0
  569. package/dist/types/video/eval/legibility.d.ts +33 -0
  570. package/dist/types/video/eval/readback-frames.d.ts +41 -0
  571. package/dist/types/video/eval/readback-run.d.ts +54 -0
  572. package/dist/types/video/eval/readback.d.ts +48 -0
  573. package/dist/types/video/eval/roundtrip.d.ts +71 -0
  574. package/dist/types/video/generate/approved.d.ts +74 -0
  575. package/dist/types/video/generate/cast.d.ts +56 -0
  576. package/dist/types/video/generate/character.d.ts +14 -0
  577. package/dist/types/video/generate/clip-sound.d.ts +63 -0
  578. package/dist/types/video/generate/cloud-image.d.ts +12 -0
  579. package/dist/types/video/generate/cloud.d.ts +67 -0
  580. package/dist/types/video/generate/dialogue.d.ts +116 -0
  581. package/dist/types/video/generate/index.d.ts +265 -0
  582. package/dist/types/video/generate/provenance.d.ts +11 -0
  583. package/dist/types/video/generate/speech-lock.d.ts +4 -0
  584. package/dist/types/video/generate/speech.d.ts +20 -0
  585. package/dist/types/video/host.d.ts +42 -0
  586. package/dist/types/video/hosted-api.d.ts +161 -0
  587. package/dist/types/video/look/index.d.ts +67 -0
  588. package/dist/types/video/look/like.d.ts +18 -0
  589. package/dist/types/video/look/sheets.d.ts +58 -0
  590. package/dist/types/video/measure/align.d.ts +33 -0
  591. package/dist/types/video/measure/amount.d.ts +52 -0
  592. package/dist/types/video/measure/bars.d.ts +22 -0
  593. package/dist/types/video/measure/boundaries.d.ts +18 -0
  594. package/dist/types/video/measure/cache.d.ts +6 -0
  595. package/dist/types/video/measure/camera.d.ts +21 -0
  596. package/dist/types/video/measure/colour.d.ts +12 -0
  597. package/dist/types/video/measure/curve.d.ts +29 -0
  598. package/dist/types/video/measure/cuts.d.ts +17 -0
  599. package/dist/types/video/measure/easing.d.ts +52 -0
  600. package/dist/types/video/measure/fill.d.ts +20 -0
  601. package/dist/types/video/measure/fits.d.ts +80 -0
  602. package/dist/types/video/measure/gradual.d.ts +23 -0
  603. package/dist/types/video/measure/index.d.ts +28 -0
  604. package/dist/types/video/measure/kinds.d.ts +71 -0
  605. package/dist/types/video/measure/motion.d.ts +26 -0
  606. package/dist/types/video/measure/move.d.ts +90 -0
  607. package/dist/types/video/measure/moves.d.ts +22 -0
  608. package/dist/types/video/measure/orientation.d.ts +11 -0
  609. package/dist/types/video/measure/pixels.d.ts +41 -0
  610. package/dist/types/video/measure/profile.d.ts +53 -0
  611. package/dist/types/video/measure/reveal.d.ts +48 -0
  612. package/dist/types/video/measure/rhythm.d.ts +7 -0
  613. package/dist/types/video/measure/robust.d.ts +18 -0
  614. package/dist/types/video/measure/signals.d.ts +48 -0
  615. package/dist/types/video/measure/signature.d.ts +10 -0
  616. package/dist/types/video/measure/span.d.ts +28 -0
  617. package/dist/types/video/measure/still-shots.d.ts +40 -0
  618. package/dist/types/video/measure/switch.d.ts +101 -0
  619. package/dist/types/video/measure/tracks.d.ts +20 -0
  620. package/dist/types/video/measure/unmix.d.ts +20 -0
  621. package/dist/types/video/media/decode.d.ts +59 -0
  622. package/dist/types/video/media/ffmpeg.d.ts +48 -0
  623. package/dist/types/video/media/footage.d.ts +53 -0
  624. package/dist/types/video/media/screenshot.d.ts +26 -0
  625. package/dist/types/video/media/selection.d.ts +4 -0
  626. package/dist/types/video/media/wav.d.ts +26 -0
  627. package/dist/types/video/music/hosted.d.ts +110 -0
  628. package/dist/types/video/music/plan.d.ts +103 -0
  629. package/dist/types/video/music/provenance.d.ts +86 -0
  630. package/dist/types/video/page/apply.d.ts +9 -0
  631. package/dist/types/video/page/contract.d.ts +150 -0
  632. package/dist/types/video/page/css.d.ts +9 -0
  633. package/dist/types/video/page/dom.d.ts +51 -0
  634. package/dist/types/video/page/fit.d.ts +13 -0
  635. package/dist/types/video/page/layout.d.ts +8 -0
  636. package/dist/types/video/page/main.d.ts +1 -0
  637. package/dist/types/video/page/scene.d.ts +38 -0
  638. package/dist/types/video/page/texts.d.ts +10 -0
  639. package/dist/types/video/page/words.d.ts +39 -0
  640. package/dist/types/video/paid-download.d.ts +19 -0
  641. package/dist/types/video/plan/ask.d.ts +77 -0
  642. package/dist/types/video/plan/generated.d.ts +29 -0
  643. package/dist/types/video/plan/index.d.ts +6 -0
  644. package/dist/types/video/plan/materials.d.ts +22 -0
  645. package/dist/types/video/plan/model.d.ts +59 -0
  646. package/dist/types/video/plan/prompt.d.ts +41 -0
  647. package/dist/types/video/plan/see.d.ts +35 -0
  648. package/dist/types/video/presets/camera.d.ts +27 -0
  649. package/dist/types/video/presets/easing.d.ts +11 -0
  650. package/dist/types/video/presets/fill.d.ts +16 -0
  651. package/dist/types/video/presets/loop.d.ts +20 -0
  652. package/dist/types/video/presets/motion.d.ts +47 -0
  653. package/dist/types/video/presets/spoken.d.ts +35 -0
  654. package/dist/types/video/presets/text-styles.d.ts +44 -0
  655. package/dist/types/video/presets/transition.d.ts +66 -0
  656. package/dist/types/video/preview/cloud.d.ts +13 -0
  657. package/dist/types/video/preview/edit/check.d.ts +15 -0
  658. package/dist/types/video/preview/edit/editor.d.ts +52 -0
  659. package/dist/types/video/preview/edit/ops.d.ts +52 -0
  660. package/dist/types/video/preview/edit/render.d.ts +11 -0
  661. package/dist/types/video/preview/edit/retime.d.ts +2 -0
  662. package/dist/types/video/preview/edit/routes.d.ts +1106 -0
  663. package/dist/types/video/preview/export-settings.d.ts +25 -0
  664. package/dist/types/video/preview/files.d.ts +25 -0
  665. package/dist/types/video/preview/html.d.ts +9 -0
  666. package/dist/types/video/preview/index.d.ts +20 -0
  667. package/dist/types/video/preview/project.d.ts +48 -0
  668. package/dist/types/video/preview/protocol.d.ts +91 -0
  669. package/dist/types/video/preview/server.d.ts +21 -0
  670. package/dist/types/video/preview/shell/app.d.ts +81 -0
  671. package/dist/types/video/preview/shell/dom.d.ts +40 -0
  672. package/dist/types/video/preview/shell/edit/controller.d.ts +32 -0
  673. package/dist/types/video/preview/shell/edit/fields.d.ts +49 -0
  674. package/dist/types/video/preview/shell/edit/form-parts.d.ts +17 -0
  675. package/dist/types/video/preview/shell/edit/form.d.ts +17 -0
  676. package/dist/types/video/preview/shell/edit/inline.d.ts +4 -0
  677. package/dist/types/video/preview/shell/edit/lanes-edit.d.ts +31 -0
  678. package/dist/types/video/preview/shell/edit/layer-order.d.ts +4 -0
  679. package/dist/types/video/preview/shell/edit/remove.d.ts +4 -0
  680. package/dist/types/video/preview/shell/edit/reveal.d.ts +4 -0
  681. package/dist/types/video/preview/shell/edit/scenes.d.ts +7 -0
  682. package/dist/types/video/preview/shell/edit/schema.d.ts +30 -0
  683. package/dist/types/video/preview/shell/edit/source.d.ts +83 -0
  684. package/dist/types/video/preview/shell/edit/split.d.ts +8 -0
  685. package/dist/types/video/preview/shell/edit/stage-edit.d.ts +21 -0
  686. package/dist/types/video/preview/shell/edit/text-fit.d.ts +4 -0
  687. package/dist/types/video/preview/shell/edit/toolbar.d.ts +14 -0
  688. package/dist/types/video/preview/shell/footage.d.ts +6 -0
  689. package/dist/types/video/preview/shell/i18n.d.ts +176 -0
  690. package/dist/types/video/preview/shell/lanes.d.ts +2 -0
  691. package/dist/types/video/preview/shell/main.d.ts +1 -0
  692. package/dist/types/video/preview/shell/model.d.ts +85 -0
  693. package/dist/types/video/preview/shell/panel.d.ts +3 -0
  694. package/dist/types/video/preview/shell/readonly.d.ts +1 -0
  695. package/dist/types/video/preview/shell/stage.d.ts +7 -0
  696. package/dist/types/video/preview/shell/studio/audio.d.ts +3 -0
  697. package/dist/types/video/preview/shell/studio/cloud.d.ts +3 -0
  698. package/dist/types/video/preview/shell/studio/code.d.ts +6 -0
  699. package/dist/types/video/preview/shell/studio/copy.d.ts +159 -0
  700. package/dist/types/video/preview/shell/studio/draft-result.d.ts +3 -0
  701. package/dist/types/video/preview/shell/studio/export.d.ts +3 -0
  702. package/dist/types/video/preview/shell/studio/scene-selection.d.ts +19 -0
  703. package/dist/types/video/preview/shell/studio/sidebar.d.ts +27 -0
  704. package/dist/types/video/preview/shell/studio/style.d.ts +2 -0
  705. package/dist/types/video/preview/shell/studio/timeline.d.ts +3 -0
  706. package/dist/types/video/preview/shell/studio/ui.d.ts +16 -0
  707. package/dist/types/video/preview/shell/studio/workspace.d.ts +11 -0
  708. package/dist/types/video/preview/shell/style.d.ts +5 -0
  709. package/dist/types/video/preview/shell/transport.d.ts +6 -0
  710. package/dist/types/video/preview/shell-bundle.d.ts +1 -0
  711. package/dist/types/video/preview/studio-actions.d.ts +4 -0
  712. package/dist/types/video/preview/studio-data.d.ts +32 -0
  713. package/dist/types/video/preview/thumbnails.d.ts +5 -0
  714. package/dist/types/video/preview/watch.d.ts +23 -0
  715. package/dist/types/video/progress.d.ts +28 -0
  716. package/dist/types/video/project/check-camera.d.ts +8 -0
  717. package/dist/types/video/project/check-caption.d.ts +8 -0
  718. package/dist/types/video/project/check-common.d.ts +25 -0
  719. package/dist/types/video/project/check-footage.d.ts +22 -0
  720. package/dist/types/video/project/check-look.d.ts +19 -0
  721. package/dist/types/video/project/check-sound.d.ts +54 -0
  722. package/dist/types/video/project/check-span.d.ts +11 -0
  723. package/dist/types/video/project/check-tracks.d.ts +8 -0
  724. package/dist/types/video/project/check-transition.d.ts +11 -0
  725. package/dist/types/video/project/check-words.d.ts +32 -0
  726. package/dist/types/video/project/check.d.ts +42 -0
  727. package/dist/types/video/project/issues.d.ts +43 -0
  728. package/dist/types/video/project/schema.d.ts +2074 -0
  729. package/dist/types/video/project/suggest.d.ts +4 -0
  730. package/dist/types/video/project/words.d.ts +6 -0
  731. package/dist/types/video/render/browser-step.d.ts +5 -0
  732. package/dist/types/video/render/encode.d.ts +49 -0
  733. package/dist/types/video/render/index.d.ts +90 -0
  734. package/dist/types/video/render/layout.d.ts +26 -0
  735. package/dist/types/video/render/record.d.ts +80 -0
  736. package/dist/types/video/render/session.d.ts +64 -0
  737. package/dist/types/video/render/verify.d.ts +16 -0
  738. package/dist/types/video/replication/audio-provenance.d.ts +36 -0
  739. package/dist/types/video/replication/browser.d.ts +1 -0
  740. package/dist/types/video/replication/check.d.ts +19 -0
  741. package/dist/types/video/replication/contract.d.ts +683 -0
  742. package/dist/types/video/replication/io.d.ts +22 -0
  743. package/dist/types/video/replication/motion-bundle.d.ts +1 -0
  744. package/dist/types/video/replication/motion.d.ts +109 -0
  745. package/dist/types/video/replication/pairs.d.ts +69 -0
  746. package/dist/types/video/replication/prefill.d.ts +34 -0
  747. package/dist/types/video/replication/production.d.ts +163 -0
  748. package/dist/types/video/replication/revision.d.ts +2 -0
  749. package/dist/types/video/replication/schema.d.ts +56 -0
  750. package/dist/types/video/replication/source-clock.d.ts +24 -0
  751. package/dist/types/video/replication/speech-observed.d.ts +121 -0
  752. package/dist/types/video/replication/voice-spans.d.ts +3 -0
  753. package/dist/types/video/retarget/caption-look.d.ts +14 -0
  754. package/dist/types/video/retarget/fps.d.ts +7 -0
  755. package/dist/types/video/retarget/index.d.ts +248 -0
  756. package/dist/types/video/retarget/items.d.ts +44 -0
  757. package/dist/types/video/retarget/marks.d.ts +12 -0
  758. package/dist/types/video/retarget/pace.d.ts +36 -0
  759. package/dist/types/video/retarget/speak.d.ts +41 -0
  760. package/dist/types/video/retarget/tempo.d.ts +40 -0
  761. package/dist/types/video/retarget/titles.d.ts +76 -0
  762. package/dist/types/video/retarget/words.d.ts +39 -0
  763. package/dist/types/video/scene/author.d.ts +74 -0
  764. package/dist/types/video/scene/check.d.ts +64 -0
  765. package/dist/types/video/scene/copied.d.ts +30 -0
  766. package/dist/types/video/scene/cues.d.ts +40 -0
  767. package/dist/types/video/scene/examples.d.ts +129 -0
  768. package/dist/types/video/scene/findings.d.ts +71 -0
  769. package/dist/types/video/scene/fonts.d.ts +19 -0
  770. package/dist/types/video/scene/items.d.ts +23 -0
  771. package/dist/types/video/scene/library.d.ts +41 -0
  772. package/dist/types/video/scene/lint.d.ts +15 -0
  773. package/dist/types/video/scene/numbers.d.ts +39 -0
  774. package/dist/types/video/scene/pictures.d.ts +12 -0
  775. package/dist/types/video/scene/write.d.ts +41 -0
  776. package/dist/types/video/score/index.d.ts +13 -0
  777. package/dist/types/video/score/pair.d.ts +43 -0
  778. package/dist/types/video/score/picture.d.ts +14 -0
  779. package/dist/types/video/score/project-windows.d.ts +9 -0
  780. package/dist/types/video/score/shot-transition.d.ts +62 -0
  781. package/dist/types/video/score/shots.d.ts +101 -0
  782. package/dist/types/video/score/time.d.ts +22 -0
  783. package/dist/types/video/score/tracks.d.ts +42 -0
  784. package/dist/types/video/score/weights.d.ts +19 -0
  785. package/dist/types/video/sfx/cache.d.ts +16 -0
  786. package/dist/types/video/sfx/catalogue.d.ts +64 -0
  787. package/dist/types/video/sfx/extract.d.ts +65 -0
  788. package/dist/types/video/sfx/levels.d.ts +39 -0
  789. package/dist/types/video/sfx/library.d.ts +26 -0
  790. package/dist/types/video/sfx/place.d.ts +82 -0
  791. package/dist/types/video/sfx/project.d.ts +36 -0
  792. package/dist/types/video/sound/analysis.d.ts +46 -0
  793. package/dist/types/video/sound/breaks.d.ts +84 -0
  794. package/dist/types/video/sound/measure.d.ts +106 -0
  795. package/dist/types/video/sound/modes.d.ts +75 -0
  796. package/dist/types/video/sound/pcm.d.ts +21 -0
  797. package/dist/types/video/sound/reading.d.ts +124 -0
  798. package/dist/types/video/sound/speech-check.d.ts +76 -0
  799. package/dist/types/video/source/collect.d.ts +64 -0
  800. package/dist/types/video/source/read.d.ts +57 -0
  801. package/dist/types/video/source/used.d.ts +4 -0
  802. package/dist/types/video/speech/hosted.d.ts +36 -0
  803. package/dist/types/video/speech/index.d.ts +83 -0
  804. package/dist/types/video/speech/types.d.ts +41 -0
  805. package/dist/types/video/submit-retry.d.ts +15 -0
  806. package/dist/types/video/synth/generate.d.ts +53 -0
  807. package/dist/types/video/synth/truth.d.ts +8 -0
  808. package/dist/types/video/synth/write.d.ts +13 -0
  809. package/dist/types/video/template/capacity.d.ts +37 -0
  810. package/dist/types/video/template/card-elements.d.ts +17 -0
  811. package/dist/types/video/template/card.d.ts +22 -0
  812. package/dist/types/video/template/check-captions.d.ts +11 -0
  813. package/dist/types/video/template/check.d.ts +40 -0
  814. package/dist/types/video/template/facts.d.ts +90 -0
  815. package/dist/types/video/template/fill.d.ts +51 -0
  816. package/dist/types/video/template/fingerprint.d.ts +2 -0
  817. package/dist/types/video/template/fit.d.ts +60 -0
  818. package/dist/types/video/template/index.d.ts +8 -0
  819. package/dist/types/video/template/project.d.ts +21 -0
  820. package/dist/types/video/template/save.d.ts +52 -0
  821. package/dist/types/video/template/slots.d.ts +26 -0
  822. package/dist/types/video/template/speech-rules.d.ts +61 -0
  823. package/dist/types/video/template/split.d.ts +10 -0
  824. package/dist/types/video/template/structure.d.ts +81 -0
  825. package/dist/types/video/template/swap.d.ts +33 -0
  826. package/dist/types/video/template/types.d.ts +387 -0
  827. package/dist/types/video/text/bar.d.ts +63 -0
  828. package/dist/types/video/text/change.d.ts +19 -0
  829. package/dist/types/video/text/core.d.ts +25 -0
  830. package/dist/types/video/text/cues.d.ts +26 -0
  831. package/dist/types/video/text/fold.d.ts +9 -0
  832. package/dist/types/video/text/frame.d.ts +41 -0
  833. package/dist/types/video/text/highlight.d.ts +19 -0
  834. package/dist/types/video/text/index.d.ts +67 -0
  835. package/dist/types/video/text/letters.d.ts +85 -0
  836. package/dist/types/video/text/look.d.ts +53 -0
  837. package/dist/types/video/text/reader-command.d.ts +26 -0
  838. package/dist/types/video/text/reveal.d.ts +37 -0
  839. package/dist/types/video/text/rings.d.ts +39 -0
  840. package/dist/types/video/text/shadow.d.ts +44 -0
  841. package/dist/types/video/text/share.d.ts +2 -0
  842. package/dist/types/video/text/speech.d.ts +15 -0
  843. package/dist/types/video/text/strokes.d.ts +30 -0
  844. package/dist/types/video/text/types.d.ts +147 -0
  845. package/dist/types/video/timeline/cue-words.d.ts +27 -0
  846. package/dist/types/video/timeline/footage.d.ts +25 -0
  847. package/dist/types/video/timeline/frame.d.ts +55 -0
  848. package/dist/types/video/timeline/items.d.ts +28 -0
  849. package/dist/types/video/timeline/mix.d.ts +67 -0
  850. package/dist/types/video/timeline/resolve.d.ts +20 -0
  851. package/dist/types/video/timeline/spans.d.ts +32 -0
  852. package/dist/types/video/timeline/words.d.ts +64 -0
  853. package/dist/types/video/tool.d.ts +29 -0
  854. package/dist/types/video/types.d.ts +1057 -0
  855. package/dist/types/video/voice/create.d.ts +43 -0
  856. package/dist/types/video/voice/hosted.d.ts +36 -0
  857. package/dist/types/video/voice/index.d.ts +61 -0
  858. package/dist/types/video/voice/pace.d.ts +37 -0
  859. package/dist/types/video/voice/profile.d.ts +26 -0
  860. package/dist/types/video/voice/sample.d.ts +46 -0
  861. package/dist/types/video/wallet.d.ts +38 -0
  862. package/dist/types/video/work.d.ts +10 -0
  863. package/dist/types/workflow/post-bundle.d.ts +2 -2
  864. package/package.json +13 -4
  865. package/references/image-workflow.md +111 -0
  866. package/references/onboarding.md +50 -19
  867. package/references/post-bundle.md +1 -1
  868. package/references/providers.md +5 -2
  869. package/references/video-draft-export.md +13 -0
  870. package/references/video-editing.md +43 -0
  871. package/references/video-effects.md +605 -0
  872. package/references/video-elements.md +199 -0
  873. package/references/video-examples/showcase/assets/pattern.svg +18 -0
  874. package/references/video-examples/showcase/assets/voice.sbg +4 -0
  875. package/references/video-examples/showcase/assets/voice.words.json +68 -0
  876. package/references/video-examples/showcase/video.json +550 -0
  877. package/references/video-examples/template-demo/TEMPLATE.md +30 -0
  878. package/references/video-examples/template-demo/fill.json +29 -0
  879. package/references/video-examples/template-demo/slots.json +210 -0
  880. package/references/video-examples/template-demo/template.json +105 -0
  881. package/references/video-motion.md +315 -0
  882. package/references/video-native-observation.md +37 -0
  883. package/references/video-performers.md +86 -0
  884. package/references/video-project.md +63 -0
  885. package/references/video-replication.md +276 -0
  886. package/references/video-scenes.md +366 -0
  887. package/references/video-sfx.md +109 -0
  888. package/references/video-sound.md +207 -0
  889. package/references/video-templates.md +177 -0
  890. package/references/video-tools.md +560 -0
  891. package/references/video.md +756 -0
  892. package/templates/community/README.md +274 -1
  893. package/templates/community/index.json +3829 -0
  894. package/templates/community/instagram-age-expectations/README.md +14 -0
  895. package/templates/community/instagram-age-expectations/SKILL.md +52 -0
  896. package/templates/community/instagram-age-expectations/source.json +9 -0
  897. package/templates/community/instagram-age-expectations/template.json +53 -0
  898. package/templates/community/instagram-artwork-detail/README.md +19 -0
  899. package/templates/community/instagram-artwork-detail/SKILL.md +53 -0
  900. package/templates/community/instagram-artwork-detail/source.json +9 -0
  901. package/templates/community/instagram-artwork-detail/template.json +61 -0
  902. package/templates/community/instagram-balanced-traits/README.md +12 -0
  903. package/templates/community/instagram-balanced-traits/SKILL.md +52 -0
  904. package/templates/community/instagram-balanced-traits/source.json +9 -0
  905. package/templates/community/instagram-balanced-traits/template.json +53 -0
  906. package/templates/community/instagram-behind-the-scenes/README.md +12 -0
  907. package/templates/community/instagram-behind-the-scenes/SKILL.md +53 -0
  908. package/templates/community/instagram-behind-the-scenes/source.json +9 -0
  909. package/templates/community/instagram-behind-the-scenes/template.json +52 -0
  910. package/templates/community/instagram-brand-personification/README.md +26 -0
  911. package/templates/community/instagram-brand-personification/SKILL.md +53 -0
  912. package/templates/community/instagram-brand-personification/source.json +9 -0
  913. package/templates/community/instagram-brand-personification/template.json +66 -0
  914. package/templates/community/instagram-brand-system/README.md +17 -0
  915. package/templates/community/instagram-brand-system/SKILL.md +53 -0
  916. package/templates/community/instagram-brand-system/source.json +9 -0
  917. package/templates/community/instagram-brand-system/template.json +60 -0
  918. package/templates/community/instagram-calendar-cheat-sheet/README.md +8 -0
  919. package/templates/community/instagram-calendar-cheat-sheet/SKILL.md +53 -0
  920. package/templates/community/instagram-calendar-cheat-sheet/source.json +9 -0
  921. package/templates/community/instagram-calendar-cheat-sheet/template.json +47 -0
  922. package/templates/community/instagram-capacity-planning/README.md +12 -0
  923. package/templates/community/instagram-capacity-planning/SKILL.md +53 -0
  924. package/templates/community/instagram-capacity-planning/source.json +9 -0
  925. package/templates/community/instagram-capacity-planning/template.json +55 -0
  926. package/templates/community/instagram-category-use-guide/README.md +14 -0
  927. package/templates/community/instagram-category-use-guide/SKILL.md +53 -0
  928. package/templates/community/instagram-category-use-guide/source.json +9 -0
  929. package/templates/community/instagram-category-use-guide/template.json +55 -0
  930. package/templates/community/instagram-character-led-tour/README.md +17 -0
  931. package/templates/community/instagram-character-led-tour/SKILL.md +53 -0
  932. package/templates/community/instagram-character-led-tour/source.json +9 -0
  933. package/templates/community/instagram-character-led-tour/template.json +56 -0
  934. package/templates/community/instagram-comic-dialogue/README.md +16 -0
  935. package/templates/community/instagram-comic-dialogue/SKILL.md +53 -0
  936. package/templates/community/instagram-comic-dialogue/source.json +9 -0
  937. package/templates/community/instagram-comic-dialogue/template.json +59 -0
  938. package/templates/community/instagram-command-shortcuts/README.md +13 -0
  939. package/templates/community/instagram-command-shortcuts/SKILL.md +53 -0
  940. package/templates/community/instagram-command-shortcuts/source.json +9 -0
  941. package/templates/community/instagram-command-shortcuts/template.json +52 -0
  942. package/templates/community/instagram-context-changes-meaning/README.md +11 -0
  943. package/templates/community/instagram-context-changes-meaning/SKILL.md +53 -0
  944. package/templates/community/instagram-context-changes-meaning/source.json +9 -0
  945. package/templates/community/instagram-context-changes-meaning/template.json +54 -0
  946. package/templates/community/instagram-continuous-canvas/README.md +16 -0
  947. package/templates/community/instagram-continuous-canvas/SKILL.md +52 -0
  948. package/templates/community/instagram-continuous-canvas/source.json +9 -0
  949. package/templates/community/instagram-continuous-canvas/template.json +59 -0
  950. package/templates/community/instagram-conversation-questions/README.md +12 -0
  951. package/templates/community/instagram-conversation-questions/SKILL.md +52 -0
  952. package/templates/community/instagram-conversation-questions/source.json +9 -0
  953. package/templates/community/instagram-conversation-questions/template.json +51 -0
  954. package/templates/community/instagram-copy-alternatives/README.md +11 -0
  955. package/templates/community/instagram-copy-alternatives/SKILL.md +53 -0
  956. package/templates/community/instagram-copy-alternatives/source.json +9 -0
  957. package/templates/community/instagram-copy-alternatives/template.json +50 -0
  958. package/templates/community/instagram-copyable-notes/README.md +13 -0
  959. package/templates/community/instagram-copyable-notes/SKILL.md +52 -0
  960. package/templates/community/instagram-copyable-notes/source.json +9 -0
  961. package/templates/community/instagram-copyable-notes/template.json +51 -0
  962. package/templates/community/instagram-curated-resources/README.md +13 -0
  963. package/templates/community/instagram-curated-resources/SKILL.md +52 -0
  964. package/templates/community/instagram-curated-resources/source.json +9 -0
  965. package/templates/community/instagram-curated-resources/template.json +54 -0
  966. package/templates/community/instagram-destination-costs/README.md +17 -0
  967. package/templates/community/instagram-destination-costs/SKILL.md +52 -0
  968. package/templates/community/instagram-destination-costs/source.json +9 -0
  969. package/templates/community/instagram-destination-costs/template.json +56 -0
  970. package/templates/community/instagram-diagram-reference/README.md +10 -0
  971. package/templates/community/instagram-diagram-reference/SKILL.md +53 -0
  972. package/templates/community/instagram-diagram-reference/source.json +9 -0
  973. package/templates/community/instagram-diagram-reference/template.json +52 -0
  974. package/templates/community/instagram-different-perspectives/README.md +15 -0
  975. package/templates/community/instagram-different-perspectives/SKILL.md +53 -0
  976. package/templates/community/instagram-different-perspectives/source.json +9 -0
  977. package/templates/community/instagram-different-perspectives/template.json +55 -0
  978. package/templates/community/instagram-document-reveal/README.md +8 -0
  979. package/templates/community/instagram-document-reveal/SKILL.md +53 -0
  980. package/templates/community/instagram-document-reveal/source.json +9 -0
  981. package/templates/community/instagram-document-reveal/template.json +46 -0
  982. package/templates/community/instagram-effect-breakdown/README.md +14 -0
  983. package/templates/community/instagram-effect-breakdown/SKILL.md +53 -0
  984. package/templates/community/instagram-effect-breakdown/source.json +9 -0
  985. package/templates/community/instagram-effect-breakdown/template.json +55 -0
  986. package/templates/community/instagram-effort-and-outcome/README.md +13 -0
  987. package/templates/community/instagram-effort-and-outcome/SKILL.md +52 -0
  988. package/templates/community/instagram-effort-and-outcome/source.json +9 -0
  989. package/templates/community/instagram-effort-and-outcome/template.json +54 -0
  990. package/templates/community/instagram-emotion-and-meaning/README.md +16 -0
  991. package/templates/community/instagram-emotion-and-meaning/SKILL.md +52 -0
  992. package/templates/community/instagram-emotion-and-meaning/source.json +9 -0
  993. package/templates/community/instagram-emotion-and-meaning/template.json +56 -0
  994. package/templates/community/instagram-everyday-interface-story/README.md +12 -0
  995. package/templates/community/instagram-everyday-interface-story/SKILL.md +53 -0
  996. package/templates/community/instagram-everyday-interface-story/source.json +9 -0
  997. package/templates/community/instagram-everyday-interface-story/template.json +51 -0
  998. package/templates/community/instagram-everyday-photo-diary/README.md +16 -0
  999. package/templates/community/instagram-everyday-photo-diary/SKILL.md +52 -0
  1000. package/templates/community/instagram-everyday-photo-diary/source.json +9 -0
  1001. package/templates/community/instagram-everyday-photo-diary/template.json +61 -0
  1002. package/templates/community/instagram-evidence-to-method/README.md +13 -0
  1003. package/templates/community/instagram-evidence-to-method/SKILL.md +53 -0
  1004. package/templates/community/instagram-evidence-to-method/source.json +9 -0
  1005. package/templates/community/instagram-evidence-to-method/template.json +56 -0
  1006. package/templates/community/instagram-expectation-reality-review/README.md +18 -0
  1007. package/templates/community/instagram-expectation-reality-review/SKILL.md +53 -0
  1008. package/templates/community/instagram-expectation-reality-review/source.json +9 -0
  1009. package/templates/community/instagram-expectation-reality-review/template.json +57 -0
  1010. package/templates/community/instagram-experiment-story/README.md +20 -0
  1011. package/templates/community/instagram-experiment-story/SKILL.md +54 -0
  1012. package/templates/community/instagram-experiment-story/source.json +9 -0
  1013. package/templates/community/instagram-experiment-story/template.json +58 -0
  1014. package/templates/community/instagram-fill-in-speech/README.md +14 -0
  1015. package/templates/community/instagram-fill-in-speech/SKILL.md +53 -0
  1016. package/templates/community/instagram-fill-in-speech/source.json +9 -0
  1017. package/templates/community/instagram-fill-in-speech/template.json +53 -0
  1018. package/templates/community/instagram-fill-in-workbook/README.md +16 -0
  1019. package/templates/community/instagram-fill-in-workbook/SKILL.md +53 -0
  1020. package/templates/community/instagram-fill-in-workbook/source.json +9 -0
  1021. package/templates/community/instagram-fill-in-workbook/template.json +57 -0
  1022. package/templates/community/instagram-font-pairing/README.md +14 -0
  1023. package/templates/community/instagram-font-pairing/SKILL.md +52 -0
  1024. package/templates/community/instagram-font-pairing/source.json +9 -0
  1025. package/templates/community/instagram-font-pairing/template.json +53 -0
  1026. package/templates/community/instagram-goal-benchmarks/README.md +12 -0
  1027. package/templates/community/instagram-goal-benchmarks/SKILL.md +53 -0
  1028. package/templates/community/instagram-goal-benchmarks/source.json +9 -0
  1029. package/templates/community/instagram-goal-benchmarks/template.json +51 -0
  1030. package/templates/community/instagram-identity-match/README.md +19 -0
  1031. package/templates/community/instagram-identity-match/SKILL.md +52 -0
  1032. package/templates/community/instagram-identity-match/source.json +9 -0
  1033. package/templates/community/instagram-identity-match/template.json +64 -0
  1034. package/templates/community/instagram-illustrated-opinion/README.md +16 -0
  1035. package/templates/community/instagram-illustrated-opinion/SKILL.md +52 -0
  1036. package/templates/community/instagram-illustrated-opinion/source.json +9 -0
  1037. package/templates/community/instagram-illustrated-opinion/template.json +56 -0
  1038. package/templates/community/instagram-illustrated-story-explainer/README.md +14 -0
  1039. package/templates/community/instagram-illustrated-story-explainer/SKILL.md +53 -0
  1040. package/templates/community/instagram-illustrated-story-explainer/source.json +9 -0
  1041. package/templates/community/instagram-illustrated-story-explainer/template.json +55 -0
  1042. package/templates/community/instagram-image-to-palette/README.md +17 -0
  1043. package/templates/community/instagram-image-to-palette/SKILL.md +53 -0
  1044. package/templates/community/instagram-image-to-palette/source.json +9 -0
  1045. package/templates/community/instagram-image-to-palette/template.json +58 -0
  1046. package/templates/community/instagram-incremental-assembly/README.md +15 -0
  1047. package/templates/community/instagram-incremental-assembly/SKILL.md +52 -0
  1048. package/templates/community/instagram-incremental-assembly/source.json +9 -0
  1049. package/templates/community/instagram-incremental-assembly/template.json +55 -0
  1050. package/templates/community/instagram-interview-storyboard/README.md +25 -0
  1051. package/templates/community/instagram-interview-storyboard/SKILL.md +53 -0
  1052. package/templates/community/instagram-interview-storyboard/source.json +9 -0
  1053. package/templates/community/instagram-interview-storyboard/template.json +65 -0
  1054. package/templates/community/instagram-launch-news/README.md +9 -0
  1055. package/templates/community/instagram-launch-news/SKILL.md +53 -0
  1056. package/templates/community/instagram-launch-news/source.json +9 -0
  1057. package/templates/community/instagram-launch-news/template.json +55 -0
  1058. package/templates/community/instagram-layout-anatomy/README.md +12 -0
  1059. package/templates/community/instagram-layout-anatomy/SKILL.md +53 -0
  1060. package/templates/community/instagram-layout-anatomy/source.json +9 -0
  1061. package/templates/community/instagram-layout-anatomy/template.json +54 -0
  1062. package/templates/community/instagram-learning-path/README.md +14 -0
  1063. package/templates/community/instagram-learning-path/SKILL.md +53 -0
  1064. package/templates/community/instagram-learning-path/source.json +9 -0
  1065. package/templates/community/instagram-learning-path/template.json +55 -0
  1066. package/templates/community/instagram-local-picks/README.md +16 -0
  1067. package/templates/community/instagram-local-picks/SKILL.md +52 -0
  1068. package/templates/community/instagram-local-picks/source.json +9 -0
  1069. package/templates/community/instagram-local-picks/template.json +55 -0
  1070. package/templates/community/instagram-matched-test/README.md +10 -0
  1071. package/templates/community/instagram-matched-test/SKILL.md +53 -0
  1072. package/templates/community/instagram-matched-test/source.json +9 -0
  1073. package/templates/community/instagram-matched-test/template.json +49 -0
  1074. package/templates/community/instagram-metric-formulas/README.md +15 -0
  1075. package/templates/community/instagram-metric-formulas/SKILL.md +53 -0
  1076. package/templates/community/instagram-metric-formulas/source.json +9 -0
  1077. package/templates/community/instagram-metric-formulas/template.json +55 -0
  1078. package/templates/community/instagram-milestones-and-feelings/README.md +13 -0
  1079. package/templates/community/instagram-milestones-and-feelings/SKILL.md +52 -0
  1080. package/templates/community/instagram-milestones-and-feelings/source.json +9 -0
  1081. package/templates/community/instagram-milestones-and-feelings/template.json +56 -0
  1082. package/templates/community/instagram-mistakes-and-alternatives/README.md +12 -0
  1083. package/templates/community/instagram-mistakes-and-alternatives/SKILL.md +52 -0
  1084. package/templates/community/instagram-mistakes-and-alternatives/source.json +9 -0
  1085. package/templates/community/instagram-mistakes-and-alternatives/template.json +53 -0
  1086. package/templates/community/instagram-myth-and-fact/README.md +12 -0
  1087. package/templates/community/instagram-myth-and-fact/SKILL.md +53 -0
  1088. package/templates/community/instagram-myth-and-fact/source.json +9 -0
  1089. package/templates/community/instagram-myth-and-fact/template.json +51 -0
  1090. package/templates/community/instagram-news-digest/README.md +13 -0
  1091. package/templates/community/instagram-news-digest/SKILL.md +53 -0
  1092. package/templates/community/instagram-news-digest/source.json +9 -0
  1093. package/templates/community/instagram-news-digest/template.json +52 -0
  1094. package/templates/community/instagram-numbers-at-human-scale/README.md +12 -0
  1095. package/templates/community/instagram-numbers-at-human-scale/SKILL.md +53 -0
  1096. package/templates/community/instagram-numbers-at-human-scale/source.json +9 -0
  1097. package/templates/community/instagram-numbers-at-human-scale/template.json +52 -0
  1098. package/templates/community/instagram-object-led-activities/README.md +16 -0
  1099. package/templates/community/instagram-object-led-activities/SKILL.md +53 -0
  1100. package/templates/community/instagram-object-led-activities/source.json +9 -0
  1101. package/templates/community/instagram-object-led-activities/template.json +56 -0
  1102. package/templates/community/instagram-object-name-origins/README.md +11 -0
  1103. package/templates/community/instagram-object-name-origins/SKILL.md +52 -0
  1104. package/templates/community/instagram-object-name-origins/source.json +9 -0
  1105. package/templates/community/instagram-object-name-origins/template.json +52 -0
  1106. package/templates/community/instagram-one-input-many-results/README.md +14 -0
  1107. package/templates/community/instagram-one-input-many-results/SKILL.md +53 -0
  1108. package/templates/community/instagram-one-input-many-results/source.json +9 -0
  1109. package/templates/community/instagram-one-input-many-results/template.json +52 -0
  1110. package/templates/community/instagram-one-variable-comparison/README.md +11 -0
  1111. package/templates/community/instagram-one-variable-comparison/SKILL.md +53 -0
  1112. package/templates/community/instagram-one-variable-comparison/source.json +9 -0
  1113. package/templates/community/instagram-one-variable-comparison/template.json +52 -0
  1114. package/templates/community/instagram-opportunity-guide/README.md +18 -0
  1115. package/templates/community/instagram-opportunity-guide/SKILL.md +53 -0
  1116. package/templates/community/instagram-opportunity-guide/source.json +9 -0
  1117. package/templates/community/instagram-opportunity-guide/template.json +57 -0
  1118. package/templates/community/instagram-palette-application-board/README.md +11 -0
  1119. package/templates/community/instagram-palette-application-board/SKILL.md +52 -0
  1120. package/templates/community/instagram-palette-application-board/source.json +9 -0
  1121. package/templates/community/instagram-palette-application-board/template.json +52 -0
  1122. package/templates/community/instagram-personal-budget-case/README.md +14 -0
  1123. package/templates/community/instagram-personal-budget-case/SKILL.md +53 -0
  1124. package/templates/community/instagram-personal-budget-case/source.json +9 -0
  1125. package/templates/community/instagram-personal-budget-case/template.json +53 -0
  1126. package/templates/community/instagram-personal-experiment/README.md +11 -0
  1127. package/templates/community/instagram-personal-experiment/SKILL.md +53 -0
  1128. package/templates/community/instagram-personal-experiment/source.json +9 -0
  1129. package/templates/community/instagram-personal-experiment/template.json +52 -0
  1130. package/templates/community/instagram-photo-and-technical-sketch/README.md +10 -0
  1131. package/templates/community/instagram-photo-and-technical-sketch/SKILL.md +53 -0
  1132. package/templates/community/instagram-photo-and-technical-sketch/source.json +9 -0
  1133. package/templates/community/instagram-photo-and-technical-sketch/template.json +49 -0
  1134. package/templates/community/instagram-photo-moment-story/README.md +12 -0
  1135. package/templates/community/instagram-photo-moment-story/SKILL.md +53 -0
  1136. package/templates/community/instagram-photo-moment-story/source.json +9 -0
  1137. package/templates/community/instagram-photo-moment-story/template.json +53 -0
  1138. package/templates/community/instagram-product-change/README.md +9 -0
  1139. package/templates/community/instagram-product-change/SKILL.md +53 -0
  1140. package/templates/community/instagram-product-change/source.json +10 -0
  1141. package/templates/community/instagram-product-change/template.json +53 -0
  1142. package/templates/community/instagram-prompt-result-reference/README.md +26 -0
  1143. package/templates/community/instagram-prompt-result-reference/SKILL.md +53 -0
  1144. package/templates/community/instagram-prompt-result-reference/source.json +9 -0
  1145. package/templates/community/instagram-prompt-result-reference/template.json +68 -0
  1146. package/templates/community/instagram-public-follow-up/README.md +15 -0
  1147. package/templates/community/instagram-public-follow-up/SKILL.md +53 -0
  1148. package/templates/community/instagram-public-follow-up/source.json +9 -0
  1149. package/templates/community/instagram-public-follow-up/template.json +54 -0
  1150. package/templates/community/instagram-reader-question-answer/README.md +10 -0
  1151. package/templates/community/instagram-reader-question-answer/SKILL.md +53 -0
  1152. package/templates/community/instagram-reader-question-answer/source.json +9 -0
  1153. package/templates/community/instagram-reader-question-answer/template.json +48 -0
  1154. package/templates/community/instagram-remaining-capacity/README.md +11 -0
  1155. package/templates/community/instagram-remaining-capacity/SKILL.md +52 -0
  1156. package/templates/community/instagram-remaining-capacity/source.json +9 -0
  1157. package/templates/community/instagram-remaining-capacity/template.json +52 -0
  1158. package/templates/community/instagram-research-brief/README.md +16 -0
  1159. package/templates/community/instagram-research-brief/SKILL.md +53 -0
  1160. package/templates/community/instagram-research-brief/source.json +9 -0
  1161. package/templates/community/instagram-research-brief/template.json +54 -0
  1162. package/templates/community/instagram-result-and-recipe/README.md +17 -0
  1163. package/templates/community/instagram-result-and-recipe/SKILL.md +53 -0
  1164. package/templates/community/instagram-result-and-recipe/source.json +9 -0
  1165. package/templates/community/instagram-result-and-recipe/template.json +56 -0
  1166. package/templates/community/instagram-result-to-steps/README.md +13 -0
  1167. package/templates/community/instagram-result-to-steps/SKILL.md +53 -0
  1168. package/templates/community/instagram-result-to-steps/source.json +9 -0
  1169. package/templates/community/instagram-result-to-steps/template.json +51 -0
  1170. package/templates/community/instagram-reverse-instruction/README.md +15 -0
  1171. package/templates/community/instagram-reverse-instruction/SKILL.md +53 -0
  1172. package/templates/community/instagram-reverse-instruction/source.json +9 -0
  1173. package/templates/community/instagram-reverse-instruction/template.json +54 -0
  1174. package/templates/community/instagram-said-and-meant/README.md +9 -0
  1175. package/templates/community/instagram-said-and-meant/SKILL.md +52 -0
  1176. package/templates/community/instagram-said-and-meant/source.json +10 -0
  1177. package/templates/community/instagram-said-and-meant/template.json +46 -0
  1178. package/templates/community/instagram-same-budget-choices/README.md +12 -0
  1179. package/templates/community/instagram-same-budget-choices/SKILL.md +53 -0
  1180. package/templates/community/instagram-same-budget-choices/source.json +9 -0
  1181. package/templates/community/instagram-same-budget-choices/template.json +52 -0
  1182. package/templates/community/instagram-screenshot-walkthrough/README.md +12 -0
  1183. package/templates/community/instagram-screenshot-walkthrough/SKILL.md +53 -0
  1184. package/templates/community/instagram-screenshot-walkthrough/source.json +9 -0
  1185. package/templates/community/instagram-screenshot-walkthrough/template.json +58 -0
  1186. package/templates/community/instagram-searchable-asset-index/README.md +13 -0
  1187. package/templates/community/instagram-searchable-asset-index/SKILL.md +52 -0
  1188. package/templates/community/instagram-searchable-asset-index/source.json +9 -0
  1189. package/templates/community/instagram-searchable-asset-index/template.json +53 -0
  1190. package/templates/community/instagram-similar-concepts/README.md +15 -0
  1191. package/templates/community/instagram-similar-concepts/SKILL.md +52 -0
  1192. package/templates/community/instagram-similar-concepts/source.json +9 -0
  1193. package/templates/community/instagram-similar-concepts/template.json +54 -0
  1194. package/templates/community/instagram-single-event-news/README.md +14 -0
  1195. package/templates/community/instagram-single-event-news/SKILL.md +53 -0
  1196. package/templates/community/instagram-single-event-news/source.json +9 -0
  1197. package/templates/community/instagram-single-event-news/template.json +56 -0
  1198. package/templates/community/instagram-style-assembly/README.md +13 -0
  1199. package/templates/community/instagram-style-assembly/SKILL.md +53 -0
  1200. package/templates/community/instagram-style-assembly/source.json +9 -0
  1201. package/templates/community/instagram-style-assembly/template.json +53 -0
  1202. package/templates/community/instagram-style-choice/README.md +14 -0
  1203. package/templates/community/instagram-style-choice/SKILL.md +53 -0
  1204. package/templates/community/instagram-style-choice/source.json +9 -0
  1205. package/templates/community/instagram-style-choice/template.json +58 -0
  1206. package/templates/community/instagram-symbolism-in-artifact/README.md +9 -0
  1207. package/templates/community/instagram-symbolism-in-artifact/SKILL.md +52 -0
  1208. package/templates/community/instagram-symbolism-in-artifact/source.json +9 -0
  1209. package/templates/community/instagram-symbolism-in-artifact/template.json +47 -0
  1210. package/templates/community/instagram-taste-matched-recommendations/README.md +17 -0
  1211. package/templates/community/instagram-taste-matched-recommendations/SKILL.md +52 -0
  1212. package/templates/community/instagram-taste-matched-recommendations/source.json +9 -0
  1213. package/templates/community/instagram-taste-matched-recommendations/template.json +56 -0
  1214. package/templates/community/instagram-then-now-pairs/README.md +14 -0
  1215. package/templates/community/instagram-then-now-pairs/SKILL.md +52 -0
  1216. package/templates/community/instagram-then-now-pairs/source.json +9 -0
  1217. package/templates/community/instagram-then-now-pairs/template.json +52 -0
  1218. package/templates/community/instagram-timed-action-plan/README.md +15 -0
  1219. package/templates/community/instagram-timed-action-plan/SKILL.md +53 -0
  1220. package/templates/community/instagram-timed-action-plan/source.json +9 -0
  1221. package/templates/community/instagram-timed-action-plan/template.json +60 -0
  1222. package/templates/community/instagram-tools-by-task/README.md +13 -0
  1223. package/templates/community/instagram-tools-by-task/SKILL.md +53 -0
  1224. package/templates/community/instagram-tools-by-task/source.json +9 -0
  1225. package/templates/community/instagram-tools-by-task/template.json +57 -0
  1226. package/templates/community/instagram-two-perspectives/README.md +8 -0
  1227. package/templates/community/instagram-two-perspectives/SKILL.md +52 -0
  1228. package/templates/community/instagram-two-perspectives/source.json +9 -0
  1229. package/templates/community/instagram-two-perspectives/template.json +47 -0
  1230. package/templates/community/instagram-two-views-one-dataset/README.md +8 -0
  1231. package/templates/community/instagram-two-views-one-dataset/SKILL.md +53 -0
  1232. package/templates/community/instagram-two-views-one-dataset/source.json +9 -0
  1233. package/templates/community/instagram-two-views-one-dataset/template.json +51 -0
  1234. package/templates/community/instagram-version-change-audit/README.md +10 -0
  1235. package/templates/community/instagram-version-change-audit/SKILL.md +53 -0
  1236. package/templates/community/instagram-version-change-audit/source.json +9 -0
  1237. package/templates/community/instagram-version-change-audit/template.json +51 -0
  1238. package/templates/community/instagram-visual-analogy/README.md +13 -0
  1239. package/templates/community/instagram-visual-analogy/SKILL.md +53 -0
  1240. package/templates/community/instagram-visual-analogy/source.json +9 -0
  1241. package/templates/community/instagram-visual-analogy/template.json +53 -0
  1242. package/templates/community/instagram-visual-guess/README.md +15 -0
  1243. package/templates/community/instagram-visual-guess/SKILL.md +53 -0
  1244. package/templates/community/instagram-visual-guess/source.json +9 -0
  1245. package/templates/community/instagram-visual-guess/template.json +54 -0
  1246. package/templates/community/instagram-visual-technique-reference/README.md +18 -0
  1247. package/templates/community/instagram-visual-technique-reference/SKILL.md +53 -0
  1248. package/templates/community/instagram-visual-technique-reference/source.json +9 -0
  1249. package/templates/community/instagram-visual-technique-reference/template.json +60 -0
  1250. package/templates/community/instagram-worked-examples/README.md +13 -0
  1251. package/templates/community/instagram-worked-examples/SKILL.md +52 -0
  1252. package/templates/community/instagram-worked-examples/source.json +9 -0
  1253. package/templates/community/instagram-worked-examples/template.json +57 -0
@@ -0,0 +1,4569 @@
1
+ <!doctype html>
2
+ <!--
3
+ Adapted from HyperFrames (https://github.com/heygen-com/hyperframes), registry/blocks/product-turntable, commit a8332860c396e9224d42b7ea2a9cc8f42918c961.
4
+ Copyright 2026 HeyGen, Inc. Licensed under the Apache License, Version 2.0; the licence text is in the popost
5
+ Skill's THIRD_PARTY_NOTICES. Changed for the popost Skill (tools/video/port-hyperframes.mjs): its comments removed; its fonts drawn by roles of the Skill's font library, linked from the project (../css/<role>.css); three.js modules replaced by the project's three.js (../lib/three.min.js, r147), set up as later releases are; three.js addons (environments/RoomEnvironment, loaders/GLTFLoader) put into the page from three.js r147 (MIT); comments that name what the scene lint looks for (a timer, the network, a transition) removed; GSAP loaded from the project (../lib/gsap.min.js) instead of a CDN; the 1920x1080 composition scaled into the scene's canvas (parameter "fit"); HyperFrames variables declared as parameters; its root-level clips laid out as HyperFrames lays them out; its clips shown and hidden from the scene's time; sound cues derived from its tweens.
6
+ -->
7
+
8
+ <html
9
+ lang="en"
10
+ data-composition-variables='[
11
+ { "id": "model_url", "type": "string", "role": "content", "label": "Model URL (.glb or .gltf)", "description": "Leave empty for the built-in drink can.", "default": "" },
12
+ { "id": "product_name", "type": "string", "role": "content", "label": "Label wordmark", "default": "YUZU", "maxLength": 10 },
13
+ { "id": "flavor", "type": "string", "role": "content", "label": "Label line", "default": "Sparkling Citrus", "maxLength": 28 },
14
+ { "id": "caption", "type": "string", "role": "content", "label": "Caption", "default": "Sparkling Citrus · 355 ml", "maxLength": 40 },
15
+ { "id": "label_color", "type": "color", "role": "style", "label": "Label color", "default": "#f2c230" },
16
+ { "id": "ink_color", "type": "color", "role": "style", "label": "Label ink", "default": "#1d2a24" },
17
+ { "id": "background", "type": "color", "role": "style", "label": "Backdrop", "default": "#e8e4dc" },
18
+ { "id": "turns", "type": "number", "role": "motion", "label": "Turns per clip", "default": 1, "min": 1, "max": 4, "step": 1 }
19
+ ]'
20
+ >
21
+ <head>
22
+ <meta charset="UTF-8" />
23
+ <meta name="viewport" content="width=1920, height=1080" />
24
+ <title>Product Turntable</title>
25
+ <script src="../lib/gsap.min.js"></script>
26
+ <style>
27
+
28
+ html,
29
+ body {
30
+ margin: 0;
31
+ width: 1920px;
32
+ height: 1080px;
33
+ overflow: hidden;
34
+ background: #e8e4dc;
35
+ }
36
+ #pt-root {
37
+ position: relative;
38
+ width: 1920px;
39
+ height: 1080px;
40
+ overflow: hidden;
41
+ background:
42
+ radial-gradient(1100px 760px at 50% 38%, rgba(255, 255, 255, 0.72), transparent 70%),
43
+ var(--pt-bg, #e8e4dc);
44
+ }
45
+ #pt-canvas {
46
+ position: absolute;
47
+ inset: 0;
48
+ width: 1920px;
49
+ height: 1080px;
50
+ display: block;
51
+ }
52
+ #pt-caption {
53
+ position: absolute;
54
+ left: 96px;
55
+ bottom: 96px;
56
+ font:
57
+ 500 30px/1 "PT Caption",
58
+ system-ui,
59
+ sans-serif;
60
+ letter-spacing: 0.01em;
61
+ color: rgba(20, 22, 24, 0.62);
62
+ }
63
+ </style>
64
+ <link rel="stylesheet" href="../css/latin-inter.css" />
65
+ <style id="popost-fonts">
66
+ @font-face {
67
+ font-family: "PT Caption";
68
+ font-style: normal;
69
+ font-display: swap;
70
+ font-weight: 100 900;
71
+ src: url("../fonts/latin-inter/inter-latin-ext-wght-normal.woff2") format('woff2-variations');
72
+ unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
73
+ }
74
+ @font-face {
75
+ font-family: "PT Caption";
76
+ font-style: normal;
77
+ font-display: swap;
78
+ font-weight: 100 900;
79
+ src: url("../fonts/latin-inter/inter-latin-wght-normal.woff2") format('woff2-variations');
80
+ unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
81
+ }
82
+ @font-face {
83
+ font-family: "PT Caption";
84
+ font-style: italic;
85
+ font-display: swap;
86
+ font-weight: 100 900;
87
+ src: url("../fonts/latin-inter/inter-latin-ext-wght-italic.woff2") format('woff2-variations');
88
+ unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
89
+ }
90
+ @font-face {
91
+ font-family: "PT Caption";
92
+ font-style: italic;
93
+ font-display: swap;
94
+ font-weight: 100 900;
95
+ src: url("../fonts/latin-inter/inter-latin-wght-italic.woff2") format('woff2-variations');
96
+ unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
97
+ }
98
+ </style>
99
+ <script>
100
+ /* popost: a font of the font library loads once the project has its role (popost video scene font); until then, a
101
+ load the page waits for still resolves and the text falls back to the machine's fonts. */
102
+ (function () {
103
+ var set = document.fonts, load = set.load.bind(set), faceLoad = FontFace.prototype.load;
104
+ set.load = function () { return load.apply(null, arguments).catch(function () { return []; }); };
105
+ FontFace.prototype.load = function () { var face = this; return faceLoad.call(face).catch(function () { return face; }); };
106
+ })();
107
+ </script>
108
+ <script src="../lib/three.min.js"></script>
109
+ <script>
110
+ /* popost: three.js r147 set up as later releases are by default (sRGB output, colour management, physical lights). */
111
+ (function () {
112
+ if (!window.THREE || THREE.__popostCompat) return;
113
+ THREE.__popostCompat = true;
114
+ THREE.SRGBColorSpace = THREE.SRGBColorSpace || 'srgb';
115
+ THREE.LinearSRGBColorSpace = THREE.LinearSRGBColorSpace || 'srgb-linear';
116
+ THREE.NoColorSpace = THREE.NoColorSpace || '';
117
+ if (THREE.ColorManagement) THREE.ColorManagement.legacyMode = false;
118
+ var R = THREE.WebGLRenderer;
119
+ THREE.WebGLRenderer = function (p) { R.call(this, Object.assign({ preserveDrawingBuffer: true }, p || {})); this.outputEncoding = THREE.sRGBEncoding; this.physicallyCorrectLights = true; };
120
+ THREE.WebGLRenderer.prototype = R.prototype;
121
+ Object.defineProperty(R.prototype, 'outputColorSpace', { configurable: true, get: function () { return this.outputEncoding === THREE.sRGBEncoding ? 'srgb' : 'srgb-linear'; }, set: function (v) { this.outputEncoding = v === 'srgb' ? THREE.sRGBEncoding : THREE.LinearEncoding; } });
122
+ Object.defineProperty(THREE.Texture.prototype, 'colorSpace', { configurable: true, get: function () { return this.encoding === THREE.sRGBEncoding ? 'srgb' : ''; }, set: function (v) { this.encoding = v === 'srgb' ? THREE.sRGBEncoding : THREE.LinearEncoding; } });
123
+ R.prototype.compileAsync = R.prototype.compileAsync || function (scene, camera) { this.compile(scene, camera); return Promise.resolve(); };
124
+ /* the texture coordinates of later releases' shader chunks (vMapUv, ...), for code that onBeforeCompile adds */
125
+ THREE.ShaderChunk.common = ['Map', 'AlphaMap', 'NormalMap', 'BumpMap', 'RoughnessMap', 'MetalnessMap', 'EmissiveMap', 'SpecularMap', 'ClearcoatMap', 'ClearcoatNormalMap', 'ClearcoatRoughnessMap', 'SheenColorMap', 'SheenRoughnessMap', 'TransmissionMap', 'ThicknessMap', 'DisplacementMap'].map(function (k) { return '#define v' + k + 'Uv vUv\n'; }).join('') + '#define vAoMapUv vUv2\n#define vLightMapUv vUv2\n' + THREE.ShaderChunk.common;
126
+ /* scene.environmentIntensity (later releases) as every material's envMapIntensity */
127
+ var render = R.prototype.render;
128
+ R.prototype.render = function (scene, camera) {
129
+ if (scene && typeof scene.environmentIntensity === 'number') scene.traverse(function (o) { [].concat(o.material || []).forEach(function (m) { if ('envMapIntensity' in m) m.envMapIntensity = scene.environmentIntensity; }); });
130
+ return render.apply(this, arguments);
131
+ };
132
+ /* point and spot lights fall off with the square of the distance (decay 2), as later releases default to */
133
+ var P = THREE.PointLight, S = THREE.SpotLight;
134
+ THREE.PointLight = function (color, intensity, distance, decay) { return new P(color, intensity, distance, decay === undefined ? 2 : decay); };
135
+ THREE.PointLight.prototype = P.prototype;
136
+ THREE.SpotLight = function (color, intensity, distance, angle, penumbra, decay) { return new S(color, intensity, distance, angle, penumbra, decay === undefined ? 2 : decay); };
137
+ THREE.SpotLight.prototype = S.prototype;
138
+ })();
139
+ </script>
140
+ <style id="popost-fit">
141
+ html, body { margin: 0 !important; width: 1280px; height: 720px; overflow: hidden !important; }
142
+ :where(html, body) { background: #000000; }
143
+ #popost-stage { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; overflow: hidden; }
144
+ </style>
145
+ <script type="application/json" id="popost-params">
146
+ {
147
+ "about": "A product turns a full revolution on a studio plinth in a seamless loop. Drop in a GLB or glTF model, or keep the built-in drink can with your own label.",
148
+ "class": "3d",
149
+ "tags": [
150
+ "3d-object",
151
+ "three-js",
152
+ "webgl",
153
+ "product",
154
+ "turntable",
155
+ "glb",
156
+ "loop"
157
+ ],
158
+ "seconds": 6,
159
+ "params": [
160
+ {
161
+ "name": "fit",
162
+ "type": "choice",
163
+ "default": "contain",
164
+ "options": [
165
+ "contain",
166
+ "cover"
167
+ ],
168
+ "what": "how the 1920x1080 composition is fitted into the canvas: whole with bars, or filling it and cropped"
169
+ }
170
+ ],
171
+ "values": {}
172
+ }
173
+ </script>
174
+ <script>
175
+ /* popost: the scene's parameters stand in for HyperFrames variables; random numbers are seeded; the composition is
176
+ scaled into the canvas; clips are shown and hidden from the scene's time. */
177
+ (function () {
178
+ var block = document.getElementById('popost-params');
179
+ var values = block ? (JSON.parse(block.textContent).values || {}) : {};
180
+ var vars = {};
181
+ Object.keys(values).forEach(function (k) { if (k !== 'fit') vars[k] = values[k] === 'true' ? true : values[k] === 'false' ? false : values[k]; });
182
+ window.__hyperframes = { getVariables: function () { return vars; } };
183
+ var seed = 20240229;
184
+ window.__popostRandom = function () { seed = (seed + 0x6d2b79f5) >>> 0; var t = seed; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; };
185
+ // HyperFrames variables as CSS custom properties (runtime/getVariables.ts, compositionLoader.ts). A mounted
186
+ // composition's host lists its variables (data-popost-variables, written by the port): before the composition's
187
+ // scripts run it gets those no rule gives it yet (an inherited value counts), and after them the rest; a value given
188
+ // by a parameter always wins.
189
+ var cssName = function (id) { return '--' + (String(id).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'node'); };
190
+ var givenId = function (n) { return Object.keys(values).filter(function (id) { return id !== 'fit' && cssName(id) === n; })[0]; };
191
+ var hostVars = function (h, early) {
192
+ (h.getAttribute('data-popost-variables') || '').split(';').forEach(function (d) {
193
+ var i = d.indexOf(':'), n = d.slice(0, i).trim(), k = givenId(n);
194
+ if (i < 0 || !n) return;
195
+ if (k !== undefined) h.style.setProperty(n, String(vars[k]));
196
+ else if (!(h.style.getPropertyValue(n) || (early ? getComputedStyle(h).getPropertyValue(n) : '')).trim()) h.style.setProperty(n, d.slice(i + 1).trim());
197
+ });
198
+ };
199
+ // Root-level clips laid out as HyperFrames lays them out (runtime/init.ts, applyCompositionSizing and applyClipLayout):
200
+ // its root composition (one marked data-root="true", else the first element with a data-composition-id, which is the
201
+ // page's <html> when that has one) gets its declared size, a position and overflow hidden; each child of it with a
202
+ // data-start is placed absolute unless it is absolute or fixed already, and given its declared size, or 100% where it
203
+ // measures 0. A composition box deeper in the page keeps the position its page gives it.
204
+ var layout = function () {
205
+ var hroot = document.querySelector('[data-composition-id][data-root="true"]') || document.querySelector('[data-composition-id]');
206
+ if (!hroot) return;
207
+ var px = function (v) { var n = parseFloat(v); return isFinite(n) && n > 0 ? n + 'px' : null; };
208
+ var rw = px(hroot.getAttribute('data-width')), rh = px(hroot.getAttribute('data-height'));
209
+ if (rw) { hroot.style.width = rw; hroot.style.setProperty('--comp-width', rw); }
210
+ if (rh) { hroot.style.height = rh; hroot.style.setProperty('--comp-height', rh); }
211
+ if (!hroot.style.position) hroot.style.position = 'relative';
212
+ hroot.style.overflow = 'hidden';
213
+ Array.prototype.forEach.call(hroot.children, function (el) {
214
+ if (/^(SCRIPT|STYLE|LINK|META)$/.test(el.tagName) || !el.hasAttribute('data-start')) return;
215
+ var none = el.style.getPropertyValue('display') === 'none', priority = el.style.getPropertyPriority('display');
216
+ if (none) el.style.removeProperty('display');
217
+ var cs = getComputedStyle(el);
218
+ if (cs.position !== 'absolute' && cs.position !== 'fixed') el.style.position = 'absolute';
219
+ if (el.tagName !== 'AUDIO') {
220
+ var byFile = /^(IMG|VIDEO)$/.test(el.tagName), fw = px(el.getAttribute('data-width')), fh = px(el.getAttribute('data-height'));
221
+ if (fw) { if (!el.style.width && (cs.width === '0px' || cs.width === 'auto')) el.style.width = fw; } else if (!byFile && !el.style.width && cs.width === '0px') el.style.width = '100%';
222
+ if (fh) { if (!el.style.height && (cs.height === '0px' || cs.height === 'auto')) el.style.height = fh; } else if (!byFile && !el.style.height && cs.height === '0px') el.style.height = '100%';
223
+ }
224
+ if (none) el.style.setProperty('display', 'none', priority);
225
+ });
226
+ };
227
+ // HyperFrames loads a mounted composition after it has laid out the page, so its scripts see the host placed: each
228
+ // script of a mounted composition calls this first (the port puts the call there).
229
+ window.__popostMount = function (script) {
230
+ var h = script && script.closest ? script.closest('[data-popost-host]') : null;
231
+ if (!h || h.__popostMounted) return;
232
+ h.__popostMounted = true;
233
+ layout();
234
+ hostVars(h, true);
235
+ };
236
+ window.__popostFit = function () {
237
+ // The canvas, from the size this file declares: a scene of a later shot loads in a layer that is not displayed, where the page measures 0.
238
+ var size = /width: (\d+)px; height: (\d+)px;/.exec(document.getElementById('popost-fit').textContent);
239
+ var W = 1920, H = 1080, s = document.getElementById('popost-stage'), cw = Number(size[1]), ch = Number(size[2]);
240
+ var k = (values.fit === 'cover' ? Math.max : Math.min)(cw / W, ch / H);
241
+ s.style.transform = 'translate(' + (cw - W * k) / 2 + 'px,' + (ch - H * k) / 2 + 'px) scale(' + k + ')';
242
+ // The page's own declared variables on its root element (runtime/getVariables.ts, injectCompositionCssVariables):
243
+ // each default where no rule defines its property, a value given by a parameter always.
244
+ var de = document.documentElement, declared = [];
245
+ try { declared = JSON.parse(de.getAttribute('data-composition-variables') || '[]'); } catch (e) {}
246
+ declared.forEach(function (d) {
247
+ var n = cssName(d.id), given = Object.prototype.hasOwnProperty.call(values, d.id), v = given ? vars[d.id] : d.default;
248
+ if (!((typeof v === 'string' && v !== '') || typeof v === 'number')) return;
249
+ if (!given && (de.style.getPropertyValue(n) || getComputedStyle(de).getPropertyValue(n)).trim()) return;
250
+ de.style.setProperty(n, String(v));
251
+ });
252
+ Array.prototype.forEach.call(document.querySelectorAll('[data-popost-host]'), function (h) { hostVars(h, false); });
253
+ layout();
254
+ // Timed elements as HyperFrames has them (runtime/clipTree.ts, clipWindow.ts): every element with a data-start but the
255
+ // root composition, from its start plus the starts of the compositions it sits in, for its data-duration (a
256
+ // composition without one: its timeline's length); one that runs to the end of the root keeps its last frame.
257
+ var root = s.querySelector('[data-composition-id]');
258
+ var clips = Array.prototype.slice.call(s.querySelectorAll('[data-start]')).filter(function (c) { return (root ? c !== root : c.parentNode !== s) && !/^(SCRIPT|STYLE|LINK|META|TEMPLATE|NOSCRIPT)$/.test(c.tagName) && isFinite(parseFloat(c.getAttribute('data-start'))); });
259
+ var windows = clips.map(function (c) {
260
+ var a = parseFloat(c.getAttribute('data-start')), d = parseFloat(c.getAttribute('data-duration')), id = c.getAttribute('data-composition-id');
261
+ for (var p = c.parentElement; p && p !== s; p = p.parentElement) if (p !== root && p.hasAttribute('data-composition-id') && isFinite(parseFloat(p.getAttribute('data-start')))) a += parseFloat(p.getAttribute('data-start'));
262
+ var tl = !(d > 0) && id && window.__timelines && window.__timelines[id];
263
+ return [a, d > 0 ? d : tl && tl.duration ? tl.duration() : Infinity];
264
+ });
265
+ var rootLength = parseFloat(root && root.getAttribute('data-duration'));
266
+ // A mounted composition that starts later in its host runs on its own time.
267
+ [].forEach(function (m) {
268
+ var tl = window.__timelines && window.__timelines[m.id];
269
+ if (tl) window.__timelines[m.id] = { pause: function () { tl.pause(); }, seek: function (t) { tl.seek(Math.max(0, t - m.start)); }, duration: function () { return tl.duration() + m.start; } };
270
+ });
271
+ var scene = (window.__popostScene = window.__popostScene || {}), before = scene.render;
272
+ scene.render = function (seconds, fps) {
273
+ if (before) before(seconds, fps);
274
+ for (var i = 0; i < clips.length; i++) {
275
+ var a = windows[i][0], end = a + windows[i][1];
276
+ clips[i].style.visibility = seconds >= a - 1e-6 && (seconds < end - 1e-6 || end >= rootLength - 1e-6) ? 'visible' : 'hidden';
277
+ }
278
+ };
279
+ };
280
+ })();
281
+ </script>
282
+ <script type="application/json" id="popost-cues">[{"at":0,"cue":"swish","gain":0.4}]</script>
283
+ </head>
284
+ <body>
285
+ <div id="popost-stage">
286
+ <div
287
+ id="pt-root"
288
+ data-composition-id="product-turntable"
289
+ data-start="0"
290
+ data-duration="6"
291
+ data-width="1920"
292
+ data-height="1080"
293
+ >
294
+ <canvas
295
+ id="pt-canvas"
296
+ class="clip"
297
+ data-start="0"
298
+ data-duration="6"
299
+ data-track-index="1"
300
+ ></canvas>
301
+ <div id="pt-caption"></div>
302
+ </div>
303
+
304
+ <script>
305
+ (function () {
306
+ var html = document.documentElement;
307
+ var defaults = {};
308
+ try {
309
+ JSON.parse(html.getAttribute("data-composition-variables") || "[]").forEach(function (v) {
310
+ defaults[v.id] = v.default;
311
+ });
312
+ } catch (error) {
313
+ /* malformed declaration: the scene module falls back to its own defaults */
314
+ }
315
+ var scoped =
316
+ (window.__hyperframes &&
317
+ window.__hyperframes.getVariables &&
318
+ window.__hyperframes.getVariables()) ||
319
+ {};
320
+ var vars = Object.assign({}, defaults, window.__hfVariables || {}, scoped);
321
+ var root = document.getElementById("pt-root");
322
+ var duration = Math.max(0.001, parseFloat(root.dataset.duration) || 6);
323
+ root.style.setProperty("--pt-bg", vars.background || "#e8e4dc");
324
+ document.getElementById("pt-caption").textContent = vars.caption || "";
325
+
326
+ var clock = { t: 0 };
327
+ var scene = { vars: vars, duration: duration, clock: clock, render: null };
328
+ window.__productTurntable = scene;
329
+ window.__hf = window.__hf || {};
330
+ window.__hf.buildReady = window.__hf.buildReady || {};
331
+ window.__hf.buildReady["product-turntable"] = new Promise(function (resolve) {
332
+ scene.ready = resolve;
333
+ });
334
+
335
+ var tl = gsap.timeline({ paused: true });
336
+ tl.to(clock, {
337
+ t: duration,
338
+ duration: duration,
339
+ ease: "none",
340
+ onUpdate: function () {
341
+ if (scene.render) scene.render(clock.t);
342
+ },
343
+ });
344
+ window.__timelines = window.__timelines || {};
345
+ window.__timelines["product-turntable"] = tl;
346
+ })();
347
+ </script>
348
+
349
+ <script>
350
+ ( function () {
351
+
352
+ /**
353
+ * https://github.com/google/model-viewer/blob/master/packages/model-viewer/src/three-components/EnvironmentScene.ts
354
+ */
355
+ class RoomEnvironment extends THREE.Scene {
356
+
357
+ constructor() {
358
+
359
+ super();
360
+ const geometry = new THREE.BoxGeometry();
361
+ geometry.deleteAttribute( 'uv' );
362
+ const roomMaterial = new THREE.MeshStandardMaterial( {
363
+ side: THREE.BackSide
364
+ } );
365
+ const boxMaterial = new THREE.MeshStandardMaterial();
366
+ const mainLight = new THREE.PointLight( 0xffffff, 5.0, 28, 2 );
367
+ mainLight.position.set( 0.418, 16.199, 0.300 );
368
+ this.add( mainLight );
369
+ const room = new THREE.Mesh( geometry, roomMaterial );
370
+ room.position.set( - 0.757, 13.219, 0.717 );
371
+ room.scale.set( 31.713, 28.305, 28.591 );
372
+ this.add( room );
373
+ const box1 = new THREE.Mesh( geometry, boxMaterial );
374
+ box1.position.set( - 10.906, 2.009, 1.846 );
375
+ box1.rotation.set( 0, - 0.195, 0 );
376
+ box1.scale.set( 2.328, 7.905, 4.651 );
377
+ this.add( box1 );
378
+ const box2 = new THREE.Mesh( geometry, boxMaterial );
379
+ box2.position.set( - 5.607, - 0.754, - 0.758 );
380
+ box2.rotation.set( 0, 0.994, 0 );
381
+ box2.scale.set( 1.970, 1.534, 3.955 );
382
+ this.add( box2 );
383
+ const box3 = new THREE.Mesh( geometry, boxMaterial );
384
+ box3.position.set( 6.167, 0.857, 7.803 );
385
+ box3.rotation.set( 0, 0.561, 0 );
386
+ box3.scale.set( 3.927, 6.285, 3.687 );
387
+ this.add( box3 );
388
+ const box4 = new THREE.Mesh( geometry, boxMaterial );
389
+ box4.position.set( - 2.017, 0.018, 6.124 );
390
+ box4.rotation.set( 0, 0.333, 0 );
391
+ box4.scale.set( 2.002, 4.566, 2.064 );
392
+ this.add( box4 );
393
+ const box5 = new THREE.Mesh( geometry, boxMaterial );
394
+ box5.position.set( 2.291, - 0.756, - 2.621 );
395
+ box5.rotation.set( 0, - 0.286, 0 );
396
+ box5.scale.set( 1.546, 1.552, 1.496 );
397
+ this.add( box5 );
398
+ const box6 = new THREE.Mesh( geometry, boxMaterial );
399
+ box6.position.set( - 2.193, - 0.369, - 5.547 );
400
+ box6.rotation.set( 0, 0.516, 0 );
401
+ box6.scale.set( 3.875, 3.487, 2.986 );
402
+ this.add( box6 );
403
+
404
+ // -x right
405
+ const light1 = new THREE.Mesh( geometry, createAreaLightMaterial( 50 ) );
406
+ light1.position.set( - 16.116, 14.37, 8.208 );
407
+ light1.scale.set( 0.1, 2.428, 2.739 );
408
+ this.add( light1 );
409
+
410
+ // -x left
411
+ const light2 = new THREE.Mesh( geometry, createAreaLightMaterial( 50 ) );
412
+ light2.position.set( - 16.109, 18.021, - 8.207 );
413
+ light2.scale.set( 0.1, 2.425, 2.751 );
414
+ this.add( light2 );
415
+
416
+ // +x
417
+ const light3 = new THREE.Mesh( geometry, createAreaLightMaterial( 17 ) );
418
+ light3.position.set( 14.904, 12.198, - 1.832 );
419
+ light3.scale.set( 0.15, 4.265, 6.331 );
420
+ this.add( light3 );
421
+
422
+ // +z
423
+ const light4 = new THREE.Mesh( geometry, createAreaLightMaterial( 43 ) );
424
+ light4.position.set( - 0.462, 8.89, 14.520 );
425
+ light4.scale.set( 4.38, 5.441, 0.088 );
426
+ this.add( light4 );
427
+
428
+ // -z
429
+ const light5 = new THREE.Mesh( geometry, createAreaLightMaterial( 20 ) );
430
+ light5.position.set( 3.235, 11.486, - 12.541 );
431
+ light5.scale.set( 2.5, 2.0, 0.1 );
432
+ this.add( light5 );
433
+
434
+ // +y
435
+ const light6 = new THREE.Mesh( geometry, createAreaLightMaterial( 100 ) );
436
+ light6.position.set( 0.0, 20.0, 0.0 );
437
+ light6.scale.set( 1.0, 0.1, 1.0 );
438
+ this.add( light6 );
439
+
440
+ }
441
+ dispose() {
442
+
443
+ const resources = new Set();
444
+ this.traverse( object => {
445
+
446
+ if ( object.isMesh ) {
447
+
448
+ resources.add( object.geometry );
449
+ resources.add( object.material );
450
+
451
+ }
452
+
453
+ } );
454
+ for ( const resource of resources ) {
455
+
456
+ resource.dispose();
457
+
458
+ }
459
+
460
+ }
461
+
462
+ }
463
+ function createAreaLightMaterial( intensity ) {
464
+
465
+ const material = new THREE.MeshBasicMaterial();
466
+ material.color.setScalar( intensity );
467
+ return material;
468
+
469
+ }
470
+
471
+ THREE.RoomEnvironment = RoomEnvironment;
472
+
473
+ } )();
474
+
475
+ </script><script>
476
+ ( function () {
477
+
478
+ class GLTFLoader extends THREE.Loader {
479
+
480
+ constructor( manager ) {
481
+
482
+ super( manager );
483
+ this.dracoLoader = null;
484
+ this.ktx2Loader = null;
485
+ this.meshoptDecoder = null;
486
+ this.pluginCallbacks = [];
487
+ this.register( function ( parser ) {
488
+
489
+ return new GLTFMaterialsClearcoatExtension( parser );
490
+
491
+ } );
492
+ this.register( function ( parser ) {
493
+
494
+ return new GLTFTextureBasisUExtension( parser );
495
+
496
+ } );
497
+ this.register( function ( parser ) {
498
+
499
+ return new GLTFTextureWebPExtension( parser );
500
+
501
+ } );
502
+ this.register( function ( parser ) {
503
+
504
+ return new GLTFMaterialsSheenExtension( parser );
505
+
506
+ } );
507
+ this.register( function ( parser ) {
508
+
509
+ return new GLTFMaterialsTransmissionExtension( parser );
510
+
511
+ } );
512
+ this.register( function ( parser ) {
513
+
514
+ return new GLTFMaterialsVolumeExtension( parser );
515
+
516
+ } );
517
+ this.register( function ( parser ) {
518
+
519
+ return new GLTFMaterialsIorExtension( parser );
520
+
521
+ } );
522
+ this.register( function ( parser ) {
523
+
524
+ return new GLTFMaterialsEmissiveStrengthExtension( parser );
525
+
526
+ } );
527
+ this.register( function ( parser ) {
528
+
529
+ return new GLTFMaterialsSpecularExtension( parser );
530
+
531
+ } );
532
+ this.register( function ( parser ) {
533
+
534
+ return new GLTFMaterialsIridescenceExtension( parser );
535
+
536
+ } );
537
+ this.register( function ( parser ) {
538
+
539
+ return new GLTFLightsExtension( parser );
540
+
541
+ } );
542
+ this.register( function ( parser ) {
543
+
544
+ return new GLTFMeshoptCompression( parser );
545
+
546
+ } );
547
+ this.register( function ( parser ) {
548
+
549
+ return new GLTFMeshGpuInstancing( parser );
550
+
551
+ } );
552
+
553
+ }
554
+ load( url, onLoad, onProgress, onError ) {
555
+
556
+ const scope = this;
557
+ let resourcePath;
558
+ if ( this.resourcePath !== '' ) {
559
+
560
+ resourcePath = this.resourcePath;
561
+
562
+ } else if ( this.path !== '' ) {
563
+
564
+ resourcePath = this.path;
565
+
566
+ } else {
567
+
568
+ resourcePath = THREE.LoaderUtils.extractUrlBase( url );
569
+
570
+ }
571
+
572
+ // Tells the LoadingManager to track an extra item, which resolves after
573
+ // the model is fully loaded. This means the count of items loaded will
574
+ // be incorrect, but ensures manager.onLoad() does not fire early.
575
+ this.manager.itemStart( url );
576
+ const _onError = function ( e ) {
577
+
578
+ if ( onError ) {
579
+
580
+ onError( e );
581
+
582
+ } else {
583
+
584
+ console.error( e );
585
+
586
+ }
587
+
588
+ scope.manager.itemError( url );
589
+ scope.manager.itemEnd( url );
590
+
591
+ };
592
+
593
+ const loader = new THREE.FileLoader( this.manager );
594
+ loader.setPath( this.path );
595
+ loader.setResponseType( 'arraybuffer' );
596
+ loader.setRequestHeader( this.requestHeader );
597
+ loader.setWithCredentials( this.withCredentials );
598
+ loader.load( url, function ( data ) {
599
+
600
+ try {
601
+
602
+ scope.parse( data, resourcePath, function ( gltf ) {
603
+
604
+ onLoad( gltf );
605
+ scope.manager.itemEnd( url );
606
+
607
+ }, _onError );
608
+
609
+ } catch ( e ) {
610
+
611
+ _onError( e );
612
+
613
+ }
614
+
615
+ }, onProgress, _onError );
616
+
617
+ }
618
+ setDRACOLoader( dracoLoader ) {
619
+
620
+ this.dracoLoader = dracoLoader;
621
+ return this;
622
+
623
+ }
624
+ setDDSLoader() {
625
+
626
+ throw new Error( 'THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".' );
627
+
628
+ }
629
+ setKTX2Loader( ktx2Loader ) {
630
+
631
+ this.ktx2Loader = ktx2Loader;
632
+ return this;
633
+
634
+ }
635
+ setMeshoptDecoder( meshoptDecoder ) {
636
+
637
+ this.meshoptDecoder = meshoptDecoder;
638
+ return this;
639
+
640
+ }
641
+ register( callback ) {
642
+
643
+ if ( this.pluginCallbacks.indexOf( callback ) === - 1 ) {
644
+
645
+ this.pluginCallbacks.push( callback );
646
+
647
+ }
648
+
649
+ return this;
650
+
651
+ }
652
+ unregister( callback ) {
653
+
654
+ if ( this.pluginCallbacks.indexOf( callback ) !== - 1 ) {
655
+
656
+ this.pluginCallbacks.splice( this.pluginCallbacks.indexOf( callback ), 1 );
657
+
658
+ }
659
+
660
+ return this;
661
+
662
+ }
663
+ parse( data, path, onLoad, onError ) {
664
+
665
+ let json;
666
+ const extensions = {};
667
+ const plugins = {};
668
+ if ( typeof data === 'string' ) {
669
+
670
+ json = JSON.parse( data );
671
+
672
+ } else if ( data instanceof ArrayBuffer ) {
673
+
674
+ const magic = THREE.LoaderUtils.decodeText( new Uint8Array( data, 0, 4 ) );
675
+ if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) {
676
+
677
+ try {
678
+
679
+ extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data );
680
+
681
+ } catch ( error ) {
682
+
683
+ if ( onError ) onError( error );
684
+ return;
685
+
686
+ }
687
+
688
+ json = JSON.parse( extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content );
689
+
690
+ } else {
691
+
692
+ json = JSON.parse( THREE.LoaderUtils.decodeText( new Uint8Array( data ) ) );
693
+
694
+ }
695
+
696
+ } else {
697
+
698
+ json = data;
699
+
700
+ }
701
+
702
+ if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) {
703
+
704
+ if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.' ) );
705
+ return;
706
+
707
+ }
708
+
709
+ const parser = new GLTFParser( json, {
710
+ path: path || this.resourcePath || '',
711
+ crossOrigin: this.crossOrigin,
712
+ requestHeader: this.requestHeader,
713
+ manager: this.manager,
714
+ ktx2Loader: this.ktx2Loader,
715
+ meshoptDecoder: this.meshoptDecoder
716
+ } );
717
+ parser.fileLoader.setRequestHeader( this.requestHeader );
718
+ for ( let i = 0; i < this.pluginCallbacks.length; i ++ ) {
719
+
720
+ const plugin = this.pluginCallbacks[ i ]( parser );
721
+ plugins[ plugin.name ] = plugin;
722
+
723
+ // Workaround to avoid determining as unknown extension
724
+ // in addUnknownExtensionsToUserData().
725
+ // Remove this workaround if we move all the existing
726
+ // extension handlers to plugin system
727
+ extensions[ plugin.name ] = true;
728
+
729
+ }
730
+
731
+ if ( json.extensionsUsed ) {
732
+
733
+ for ( let i = 0; i < json.extensionsUsed.length; ++ i ) {
734
+
735
+ const extensionName = json.extensionsUsed[ i ];
736
+ const extensionsRequired = json.extensionsRequired || [];
737
+ switch ( extensionName ) {
738
+
739
+ case EXTENSIONS.KHR_MATERIALS_UNLIT:
740
+ extensions[ extensionName ] = new GLTFMaterialsUnlitExtension();
741
+ break;
742
+ case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
743
+ extensions[ extensionName ] = new GLTFDracoMeshCompressionExtension( json, this.dracoLoader );
744
+ break;
745
+ case EXTENSIONS.KHR_TEXTURE_TRANSFORM:
746
+ extensions[ extensionName ] = new GLTFTextureTransformExtension();
747
+ break;
748
+ case EXTENSIONS.KHR_MESH_QUANTIZATION:
749
+ extensions[ extensionName ] = new GLTFMeshQuantizationExtension();
750
+ break;
751
+ default:
752
+ if ( extensionsRequired.indexOf( extensionName ) >= 0 && plugins[ extensionName ] === undefined ) {
753
+
754
+ console.warn( 'THREE.GLTFLoader: Unknown extension "' + extensionName + '".' );
755
+
756
+ }
757
+
758
+ }
759
+
760
+ }
761
+
762
+ }
763
+
764
+ parser.setExtensions( extensions );
765
+ parser.setPlugins( plugins );
766
+ parser.parse( onLoad, onError );
767
+
768
+ }
769
+ parseAsync( data, path ) {
770
+
771
+ const scope = this;
772
+ return new Promise( function ( resolve, reject ) {
773
+
774
+ scope.parse( data, path, resolve, reject );
775
+
776
+ } );
777
+
778
+ }
779
+
780
+ }
781
+
782
+ /* GLTFREGISTRY */
783
+
784
+ function GLTFRegistry() {
785
+
786
+ let objects = {};
787
+ return {
788
+ get: function ( key ) {
789
+
790
+ return objects[ key ];
791
+
792
+ },
793
+ add: function ( key, object ) {
794
+
795
+ objects[ key ] = object;
796
+
797
+ },
798
+ remove: function ( key ) {
799
+
800
+ delete objects[ key ];
801
+
802
+ },
803
+ removeAll: function () {
804
+
805
+ objects = {};
806
+
807
+ }
808
+ };
809
+
810
+ }
811
+
812
+ /*********************************/
813
+ /********** EXTENSIONS ***********/
814
+ /*********************************/
815
+
816
+ const EXTENSIONS = {
817
+ KHR_BINARY_GLTF: 'KHR_binary_glTF',
818
+ KHR_DRACO_MESH_COMPRESSION: 'KHR_draco_mesh_compression',
819
+ KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual',
820
+ KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
821
+ KHR_MATERIALS_IOR: 'KHR_materials_ior',
822
+ KHR_MATERIALS_SHEEN: 'KHR_materials_sheen',
823
+ KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
824
+ KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
825
+ KHR_MATERIALS_IRIDESCENCE: 'KHR_materials_iridescence',
826
+ KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
827
+ KHR_MATERIALS_VOLUME: 'KHR_materials_volume',
828
+ KHR_TEXTURE_BASISU: 'KHR_texture_basisu',
829
+ KHR_TEXTURE_TRANSFORM: 'KHR_texture_transform',
830
+ KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization',
831
+ KHR_MATERIALS_EMISSIVE_STRENGTH: 'KHR_materials_emissive_strength',
832
+ EXT_TEXTURE_WEBP: 'EXT_texture_webp',
833
+ EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression',
834
+ EXT_MESH_GPU_INSTANCING: 'EXT_mesh_gpu_instancing'
835
+ };
836
+
837
+ /**
838
+ * Punctual Lights Extension
839
+ *
840
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_lights_punctual
841
+ */
842
+ class GLTFLightsExtension {
843
+
844
+ constructor( parser ) {
845
+
846
+ this.parser = parser;
847
+ this.name = EXTENSIONS.KHR_LIGHTS_PUNCTUAL;
848
+
849
+ // THREE.Object3D instance caches
850
+ this.cache = {
851
+ refs: {},
852
+ uses: {}
853
+ };
854
+
855
+ }
856
+ _markDefs() {
857
+
858
+ const parser = this.parser;
859
+ const nodeDefs = this.parser.json.nodes || [];
860
+ for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) {
861
+
862
+ const nodeDef = nodeDefs[ nodeIndex ];
863
+ if ( nodeDef.extensions && nodeDef.extensions[ this.name ] && nodeDef.extensions[ this.name ].light !== undefined ) {
864
+
865
+ parser._addNodeRef( this.cache, nodeDef.extensions[ this.name ].light );
866
+
867
+ }
868
+
869
+ }
870
+
871
+ }
872
+ _loadLight( lightIndex ) {
873
+
874
+ const parser = this.parser;
875
+ const cacheKey = 'light:' + lightIndex;
876
+ let dependency = parser.cache.get( cacheKey );
877
+ if ( dependency ) return dependency;
878
+ const json = parser.json;
879
+ const extensions = json.extensions && json.extensions[ this.name ] || {};
880
+ const lightDefs = extensions.lights || [];
881
+ const lightDef = lightDefs[ lightIndex ];
882
+ let lightNode;
883
+ const color = new THREE.Color( 0xffffff );
884
+ if ( lightDef.color !== undefined ) color.fromArray( lightDef.color );
885
+ const range = lightDef.range !== undefined ? lightDef.range : 0;
886
+ switch ( lightDef.type ) {
887
+
888
+ case 'directional':
889
+ lightNode = new THREE.DirectionalLight( color );
890
+ lightNode.target.position.set( 0, 0, - 1 );
891
+ lightNode.add( lightNode.target );
892
+ break;
893
+ case 'point':
894
+ lightNode = new THREE.PointLight( color );
895
+ lightNode.distance = range;
896
+ break;
897
+ case 'spot':
898
+ lightNode = new THREE.SpotLight( color );
899
+ lightNode.distance = range;
900
+ // Handle spotlight properties.
901
+ lightDef.spot = lightDef.spot || {};
902
+ lightDef.spot.innerConeAngle = lightDef.spot.innerConeAngle !== undefined ? lightDef.spot.innerConeAngle : 0;
903
+ lightDef.spot.outerConeAngle = lightDef.spot.outerConeAngle !== undefined ? lightDef.spot.outerConeAngle : Math.PI / 4.0;
904
+ lightNode.angle = lightDef.spot.outerConeAngle;
905
+ lightNode.penumbra = 1.0 - lightDef.spot.innerConeAngle / lightDef.spot.outerConeAngle;
906
+ lightNode.target.position.set( 0, 0, - 1 );
907
+ lightNode.add( lightNode.target );
908
+ break;
909
+ default:
910
+ throw new Error( 'THREE.GLTFLoader: Unexpected light type: ' + lightDef.type );
911
+
912
+ }
913
+
914
+ // Some lights (e.g. spot) default to a position other than the origin. Reset the position
915
+ // here, because node-level parsing will only override position if explicitly specified.
916
+ lightNode.position.set( 0, 0, 0 );
917
+ lightNode.decay = 2;
918
+ assignExtrasToUserData( lightNode, lightDef );
919
+ if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity;
920
+ lightNode.name = parser.createUniqueName( lightDef.name || 'light_' + lightIndex );
921
+ dependency = Promise.resolve( lightNode );
922
+ parser.cache.add( cacheKey, dependency );
923
+ return dependency;
924
+
925
+ }
926
+ getDependency( type, index ) {
927
+
928
+ if ( type !== 'light' ) return;
929
+ return this._loadLight( index );
930
+
931
+ }
932
+ createNodeAttachment( nodeIndex ) {
933
+
934
+ const self = this;
935
+ const parser = this.parser;
936
+ const json = parser.json;
937
+ const nodeDef = json.nodes[ nodeIndex ];
938
+ const lightDef = nodeDef.extensions && nodeDef.extensions[ this.name ] || {};
939
+ const lightIndex = lightDef.light;
940
+ if ( lightIndex === undefined ) return null;
941
+ return this._loadLight( lightIndex ).then( function ( light ) {
942
+
943
+ return parser._getNodeRef( self.cache, lightIndex, light );
944
+
945
+ } );
946
+
947
+ }
948
+
949
+ }
950
+
951
+ /**
952
+ * Unlit Materials Extension
953
+ *
954
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit
955
+ */
956
+ class GLTFMaterialsUnlitExtension {
957
+
958
+ constructor() {
959
+
960
+ this.name = EXTENSIONS.KHR_MATERIALS_UNLIT;
961
+
962
+ }
963
+ getMaterialType() {
964
+
965
+ return THREE.MeshBasicMaterial;
966
+
967
+ }
968
+ extendParams( materialParams, materialDef, parser ) {
969
+
970
+ const pending = [];
971
+ materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
972
+ materialParams.opacity = 1.0;
973
+ const metallicRoughness = materialDef.pbrMetallicRoughness;
974
+ if ( metallicRoughness ) {
975
+
976
+ if ( Array.isArray( metallicRoughness.baseColorFactor ) ) {
977
+
978
+ const array = metallicRoughness.baseColorFactor;
979
+ materialParams.color.fromArray( array );
980
+ materialParams.opacity = array[ 3 ];
981
+
982
+ }
983
+
984
+ if ( metallicRoughness.baseColorTexture !== undefined ) {
985
+
986
+ pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, THREE.sRGBEncoding ) );
987
+
988
+ }
989
+
990
+ }
991
+
992
+ return Promise.all( pending );
993
+
994
+ }
995
+
996
+ }
997
+
998
+ /**
999
+ * Materials Emissive Strength Extension
1000
+ *
1001
+ * Specification: https://github.com/KhronosGroup/glTF/blob/5768b3ce0ef32bc39cdf1bef10b948586635ead3/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md
1002
+ */
1003
+ class GLTFMaterialsEmissiveStrengthExtension {
1004
+
1005
+ constructor( parser ) {
1006
+
1007
+ this.parser = parser;
1008
+ this.name = EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH;
1009
+
1010
+ }
1011
+ extendMaterialParams( materialIndex, materialParams ) {
1012
+
1013
+ const parser = this.parser;
1014
+ const materialDef = parser.json.materials[ materialIndex ];
1015
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1016
+
1017
+ return Promise.resolve();
1018
+
1019
+ }
1020
+
1021
+ const emissiveStrength = materialDef.extensions[ this.name ].emissiveStrength;
1022
+ if ( emissiveStrength !== undefined ) {
1023
+
1024
+ materialParams.emissiveIntensity = emissiveStrength;
1025
+
1026
+ }
1027
+
1028
+ return Promise.resolve();
1029
+
1030
+ }
1031
+
1032
+ }
1033
+
1034
+ /**
1035
+ * Clearcoat Materials Extension
1036
+ *
1037
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_clearcoat
1038
+ */
1039
+ class GLTFMaterialsClearcoatExtension {
1040
+
1041
+ constructor( parser ) {
1042
+
1043
+ this.parser = parser;
1044
+ this.name = EXTENSIONS.KHR_MATERIALS_CLEARCOAT;
1045
+
1046
+ }
1047
+ getMaterialType( materialIndex ) {
1048
+
1049
+ const parser = this.parser;
1050
+ const materialDef = parser.json.materials[ materialIndex ];
1051
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1052
+ return THREE.MeshPhysicalMaterial;
1053
+
1054
+ }
1055
+ extendMaterialParams( materialIndex, materialParams ) {
1056
+
1057
+ const parser = this.parser;
1058
+ const materialDef = parser.json.materials[ materialIndex ];
1059
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1060
+
1061
+ return Promise.resolve();
1062
+
1063
+ }
1064
+
1065
+ const pending = [];
1066
+ const extension = materialDef.extensions[ this.name ];
1067
+ if ( extension.clearcoatFactor !== undefined ) {
1068
+
1069
+ materialParams.clearcoat = extension.clearcoatFactor;
1070
+
1071
+ }
1072
+
1073
+ if ( extension.clearcoatTexture !== undefined ) {
1074
+
1075
+ pending.push( parser.assignTexture( materialParams, 'clearcoatMap', extension.clearcoatTexture ) );
1076
+
1077
+ }
1078
+
1079
+ if ( extension.clearcoatRoughnessFactor !== undefined ) {
1080
+
1081
+ materialParams.clearcoatRoughness = extension.clearcoatRoughnessFactor;
1082
+
1083
+ }
1084
+
1085
+ if ( extension.clearcoatRoughnessTexture !== undefined ) {
1086
+
1087
+ pending.push( parser.assignTexture( materialParams, 'clearcoatRoughnessMap', extension.clearcoatRoughnessTexture ) );
1088
+
1089
+ }
1090
+
1091
+ if ( extension.clearcoatNormalTexture !== undefined ) {
1092
+
1093
+ pending.push( parser.assignTexture( materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture ) );
1094
+ if ( extension.clearcoatNormalTexture.scale !== undefined ) {
1095
+
1096
+ const scale = extension.clearcoatNormalTexture.scale;
1097
+ materialParams.clearcoatNormalScale = new THREE.Vector2( scale, scale );
1098
+
1099
+ }
1100
+
1101
+ }
1102
+
1103
+ return Promise.all( pending );
1104
+
1105
+ }
1106
+
1107
+ }
1108
+
1109
+ /**
1110
+ * Iridescence Materials Extension
1111
+ *
1112
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_iridescence
1113
+ */
1114
+ class GLTFMaterialsIridescenceExtension {
1115
+
1116
+ constructor( parser ) {
1117
+
1118
+ this.parser = parser;
1119
+ this.name = EXTENSIONS.KHR_MATERIALS_IRIDESCENCE;
1120
+
1121
+ }
1122
+ getMaterialType( materialIndex ) {
1123
+
1124
+ const parser = this.parser;
1125
+ const materialDef = parser.json.materials[ materialIndex ];
1126
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1127
+ return THREE.MeshPhysicalMaterial;
1128
+
1129
+ }
1130
+ extendMaterialParams( materialIndex, materialParams ) {
1131
+
1132
+ const parser = this.parser;
1133
+ const materialDef = parser.json.materials[ materialIndex ];
1134
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1135
+
1136
+ return Promise.resolve();
1137
+
1138
+ }
1139
+
1140
+ const pending = [];
1141
+ const extension = materialDef.extensions[ this.name ];
1142
+ if ( extension.iridescenceFactor !== undefined ) {
1143
+
1144
+ materialParams.iridescence = extension.iridescenceFactor;
1145
+
1146
+ }
1147
+
1148
+ if ( extension.iridescenceTexture !== undefined ) {
1149
+
1150
+ pending.push( parser.assignTexture( materialParams, 'iridescenceMap', extension.iridescenceTexture ) );
1151
+
1152
+ }
1153
+
1154
+ if ( extension.iridescenceIor !== undefined ) {
1155
+
1156
+ materialParams.iridescenceIOR = extension.iridescenceIor;
1157
+
1158
+ }
1159
+
1160
+ if ( materialParams.iridescenceThicknessRange === undefined ) {
1161
+
1162
+ materialParams.iridescenceThicknessRange = [ 100, 400 ];
1163
+
1164
+ }
1165
+
1166
+ if ( extension.iridescenceThicknessMinimum !== undefined ) {
1167
+
1168
+ materialParams.iridescenceThicknessRange[ 0 ] = extension.iridescenceThicknessMinimum;
1169
+
1170
+ }
1171
+
1172
+ if ( extension.iridescenceThicknessMaximum !== undefined ) {
1173
+
1174
+ materialParams.iridescenceThicknessRange[ 1 ] = extension.iridescenceThicknessMaximum;
1175
+
1176
+ }
1177
+
1178
+ if ( extension.iridescenceThicknessTexture !== undefined ) {
1179
+
1180
+ pending.push( parser.assignTexture( materialParams, 'iridescenceThicknessMap', extension.iridescenceThicknessTexture ) );
1181
+
1182
+ }
1183
+
1184
+ return Promise.all( pending );
1185
+
1186
+ }
1187
+
1188
+ }
1189
+
1190
+ /**
1191
+ * Sheen Materials Extension
1192
+ *
1193
+ * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen
1194
+ */
1195
+ class GLTFMaterialsSheenExtension {
1196
+
1197
+ constructor( parser ) {
1198
+
1199
+ this.parser = parser;
1200
+ this.name = EXTENSIONS.KHR_MATERIALS_SHEEN;
1201
+
1202
+ }
1203
+ getMaterialType( materialIndex ) {
1204
+
1205
+ const parser = this.parser;
1206
+ const materialDef = parser.json.materials[ materialIndex ];
1207
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1208
+ return THREE.MeshPhysicalMaterial;
1209
+
1210
+ }
1211
+ extendMaterialParams( materialIndex, materialParams ) {
1212
+
1213
+ const parser = this.parser;
1214
+ const materialDef = parser.json.materials[ materialIndex ];
1215
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1216
+
1217
+ return Promise.resolve();
1218
+
1219
+ }
1220
+
1221
+ const pending = [];
1222
+ materialParams.sheenColor = new THREE.Color( 0, 0, 0 );
1223
+ materialParams.sheenRoughness = 0;
1224
+ materialParams.sheen = 1;
1225
+ const extension = materialDef.extensions[ this.name ];
1226
+ if ( extension.sheenColorFactor !== undefined ) {
1227
+
1228
+ materialParams.sheenColor.fromArray( extension.sheenColorFactor );
1229
+
1230
+ }
1231
+
1232
+ if ( extension.sheenRoughnessFactor !== undefined ) {
1233
+
1234
+ materialParams.sheenRoughness = extension.sheenRoughnessFactor;
1235
+
1236
+ }
1237
+
1238
+ if ( extension.sheenColorTexture !== undefined ) {
1239
+
1240
+ pending.push( parser.assignTexture( materialParams, 'sheenColorMap', extension.sheenColorTexture, THREE.sRGBEncoding ) );
1241
+
1242
+ }
1243
+
1244
+ if ( extension.sheenRoughnessTexture !== undefined ) {
1245
+
1246
+ pending.push( parser.assignTexture( materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture ) );
1247
+
1248
+ }
1249
+
1250
+ return Promise.all( pending );
1251
+
1252
+ }
1253
+
1254
+ }
1255
+
1256
+ /**
1257
+ * Transmission Materials Extension
1258
+ *
1259
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_transmission
1260
+ * Draft: https://github.com/KhronosGroup/glTF/pull/1698
1261
+ */
1262
+ class GLTFMaterialsTransmissionExtension {
1263
+
1264
+ constructor( parser ) {
1265
+
1266
+ this.parser = parser;
1267
+ this.name = EXTENSIONS.KHR_MATERIALS_TRANSMISSION;
1268
+
1269
+ }
1270
+ getMaterialType( materialIndex ) {
1271
+
1272
+ const parser = this.parser;
1273
+ const materialDef = parser.json.materials[ materialIndex ];
1274
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1275
+ return THREE.MeshPhysicalMaterial;
1276
+
1277
+ }
1278
+ extendMaterialParams( materialIndex, materialParams ) {
1279
+
1280
+ const parser = this.parser;
1281
+ const materialDef = parser.json.materials[ materialIndex ];
1282
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1283
+
1284
+ return Promise.resolve();
1285
+
1286
+ }
1287
+
1288
+ const pending = [];
1289
+ const extension = materialDef.extensions[ this.name ];
1290
+ if ( extension.transmissionFactor !== undefined ) {
1291
+
1292
+ materialParams.transmission = extension.transmissionFactor;
1293
+
1294
+ }
1295
+
1296
+ if ( extension.transmissionTexture !== undefined ) {
1297
+
1298
+ pending.push( parser.assignTexture( materialParams, 'transmissionMap', extension.transmissionTexture ) );
1299
+
1300
+ }
1301
+
1302
+ return Promise.all( pending );
1303
+
1304
+ }
1305
+
1306
+ }
1307
+
1308
+ /**
1309
+ * Materials Volume Extension
1310
+ *
1311
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume
1312
+ */
1313
+ class GLTFMaterialsVolumeExtension {
1314
+
1315
+ constructor( parser ) {
1316
+
1317
+ this.parser = parser;
1318
+ this.name = EXTENSIONS.KHR_MATERIALS_VOLUME;
1319
+
1320
+ }
1321
+ getMaterialType( materialIndex ) {
1322
+
1323
+ const parser = this.parser;
1324
+ const materialDef = parser.json.materials[ materialIndex ];
1325
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1326
+ return THREE.MeshPhysicalMaterial;
1327
+
1328
+ }
1329
+ extendMaterialParams( materialIndex, materialParams ) {
1330
+
1331
+ const parser = this.parser;
1332
+ const materialDef = parser.json.materials[ materialIndex ];
1333
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1334
+
1335
+ return Promise.resolve();
1336
+
1337
+ }
1338
+
1339
+ const pending = [];
1340
+ const extension = materialDef.extensions[ this.name ];
1341
+ materialParams.thickness = extension.thicknessFactor !== undefined ? extension.thicknessFactor : 0;
1342
+ if ( extension.thicknessTexture !== undefined ) {
1343
+
1344
+ pending.push( parser.assignTexture( materialParams, 'thicknessMap', extension.thicknessTexture ) );
1345
+
1346
+ }
1347
+
1348
+ materialParams.attenuationDistance = extension.attenuationDistance || Infinity;
1349
+ const colorArray = extension.attenuationColor || [ 1, 1, 1 ];
1350
+ materialParams.attenuationColor = new THREE.Color( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ] );
1351
+ return Promise.all( pending );
1352
+
1353
+ }
1354
+
1355
+ }
1356
+
1357
+ /**
1358
+ * Materials ior Extension
1359
+ *
1360
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior
1361
+ */
1362
+ class GLTFMaterialsIorExtension {
1363
+
1364
+ constructor( parser ) {
1365
+
1366
+ this.parser = parser;
1367
+ this.name = EXTENSIONS.KHR_MATERIALS_IOR;
1368
+
1369
+ }
1370
+ getMaterialType( materialIndex ) {
1371
+
1372
+ const parser = this.parser;
1373
+ const materialDef = parser.json.materials[ materialIndex ];
1374
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1375
+ return THREE.MeshPhysicalMaterial;
1376
+
1377
+ }
1378
+ extendMaterialParams( materialIndex, materialParams ) {
1379
+
1380
+ const parser = this.parser;
1381
+ const materialDef = parser.json.materials[ materialIndex ];
1382
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1383
+
1384
+ return Promise.resolve();
1385
+
1386
+ }
1387
+
1388
+ const extension = materialDef.extensions[ this.name ];
1389
+ materialParams.ior = extension.ior !== undefined ? extension.ior : 1.5;
1390
+ return Promise.resolve();
1391
+
1392
+ }
1393
+
1394
+ }
1395
+
1396
+ /**
1397
+ * Materials specular Extension
1398
+ *
1399
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular
1400
+ */
1401
+ class GLTFMaterialsSpecularExtension {
1402
+
1403
+ constructor( parser ) {
1404
+
1405
+ this.parser = parser;
1406
+ this.name = EXTENSIONS.KHR_MATERIALS_SPECULAR;
1407
+
1408
+ }
1409
+ getMaterialType( materialIndex ) {
1410
+
1411
+ const parser = this.parser;
1412
+ const materialDef = parser.json.materials[ materialIndex ];
1413
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) return null;
1414
+ return THREE.MeshPhysicalMaterial;
1415
+
1416
+ }
1417
+ extendMaterialParams( materialIndex, materialParams ) {
1418
+
1419
+ const parser = this.parser;
1420
+ const materialDef = parser.json.materials[ materialIndex ];
1421
+ if ( ! materialDef.extensions || ! materialDef.extensions[ this.name ] ) {
1422
+
1423
+ return Promise.resolve();
1424
+
1425
+ }
1426
+
1427
+ const pending = [];
1428
+ const extension = materialDef.extensions[ this.name ];
1429
+ materialParams.specularIntensity = extension.specularFactor !== undefined ? extension.specularFactor : 1.0;
1430
+ if ( extension.specularTexture !== undefined ) {
1431
+
1432
+ pending.push( parser.assignTexture( materialParams, 'specularIntensityMap', extension.specularTexture ) );
1433
+
1434
+ }
1435
+
1436
+ const colorArray = extension.specularColorFactor || [ 1, 1, 1 ];
1437
+ materialParams.specularColor = new THREE.Color( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ] );
1438
+ if ( extension.specularColorTexture !== undefined ) {
1439
+
1440
+ pending.push( parser.assignTexture( materialParams, 'specularColorMap', extension.specularColorTexture, THREE.sRGBEncoding ) );
1441
+
1442
+ }
1443
+
1444
+ return Promise.all( pending );
1445
+
1446
+ }
1447
+
1448
+ }
1449
+
1450
+ /**
1451
+ * BasisU THREE.Texture Extension
1452
+ *
1453
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
1454
+ */
1455
+ class GLTFTextureBasisUExtension {
1456
+
1457
+ constructor( parser ) {
1458
+
1459
+ this.parser = parser;
1460
+ this.name = EXTENSIONS.KHR_TEXTURE_BASISU;
1461
+
1462
+ }
1463
+ loadTexture( textureIndex ) {
1464
+
1465
+ const parser = this.parser;
1466
+ const json = parser.json;
1467
+ const textureDef = json.textures[ textureIndex ];
1468
+ if ( ! textureDef.extensions || ! textureDef.extensions[ this.name ] ) {
1469
+
1470
+ return null;
1471
+
1472
+ }
1473
+
1474
+ const extension = textureDef.extensions[ this.name ];
1475
+ const loader = parser.options.ktx2Loader;
1476
+ if ( ! loader ) {
1477
+
1478
+ if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) {
1479
+
1480
+ throw new Error( 'THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures' );
1481
+
1482
+ } else {
1483
+
1484
+ // Assumes that the extension is optional and that a fallback texture is present
1485
+ return null;
1486
+
1487
+ }
1488
+
1489
+ }
1490
+
1491
+ return parser.loadTextureImage( textureIndex, extension.source, loader );
1492
+
1493
+ }
1494
+
1495
+ }
1496
+
1497
+ /**
1498
+ * WebP THREE.Texture Extension
1499
+ *
1500
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp
1501
+ */
1502
+ class GLTFTextureWebPExtension {
1503
+
1504
+ constructor( parser ) {
1505
+
1506
+ this.parser = parser;
1507
+ this.name = EXTENSIONS.EXT_TEXTURE_WEBP;
1508
+ this.isSupported = null;
1509
+
1510
+ }
1511
+ loadTexture( textureIndex ) {
1512
+
1513
+ const name = this.name;
1514
+ const parser = this.parser;
1515
+ const json = parser.json;
1516
+ const textureDef = json.textures[ textureIndex ];
1517
+ if ( ! textureDef.extensions || ! textureDef.extensions[ name ] ) {
1518
+
1519
+ return null;
1520
+
1521
+ }
1522
+
1523
+ const extension = textureDef.extensions[ name ];
1524
+ const source = json.images[ extension.source ];
1525
+ let loader = parser.textureLoader;
1526
+ if ( source.uri ) {
1527
+
1528
+ const handler = parser.options.manager.getHandler( source.uri );
1529
+ if ( handler !== null ) loader = handler;
1530
+
1531
+ }
1532
+
1533
+ return this.detectSupport().then( function ( isSupported ) {
1534
+
1535
+ if ( isSupported ) return parser.loadTextureImage( textureIndex, extension.source, loader );
1536
+ if ( json.extensionsRequired && json.extensionsRequired.indexOf( name ) >= 0 ) {
1537
+
1538
+ throw new Error( 'THREE.GLTFLoader: WebP required by asset but unsupported.' );
1539
+
1540
+ }
1541
+
1542
+ // Fall back to PNG or JPEG.
1543
+ return parser.loadTexture( textureIndex );
1544
+
1545
+ } );
1546
+
1547
+ }
1548
+ detectSupport() {
1549
+
1550
+ if ( ! this.isSupported ) {
1551
+
1552
+ this.isSupported = new Promise( function ( resolve ) {
1553
+
1554
+ const image = new Image();
1555
+
1556
+ // Lossy test image. Support for lossy images doesn't guarantee support for all
1557
+ // WebP images, unfortunately.
1558
+ image.src = 'data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA';
1559
+ image.onload = image.onerror = function () {
1560
+
1561
+ resolve( image.height === 1 );
1562
+
1563
+ };
1564
+
1565
+ } );
1566
+
1567
+ }
1568
+
1569
+ return this.isSupported;
1570
+
1571
+ }
1572
+
1573
+ }
1574
+
1575
+ /**
1576
+ * meshopt BufferView Compression Extension
1577
+ *
1578
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression
1579
+ */
1580
+ class GLTFMeshoptCompression {
1581
+
1582
+ constructor( parser ) {
1583
+
1584
+ this.name = EXTENSIONS.EXT_MESHOPT_COMPRESSION;
1585
+ this.parser = parser;
1586
+
1587
+ }
1588
+ loadBufferView( index ) {
1589
+
1590
+ const json = this.parser.json;
1591
+ const bufferView = json.bufferViews[ index ];
1592
+ if ( bufferView.extensions && bufferView.extensions[ this.name ] ) {
1593
+
1594
+ const extensionDef = bufferView.extensions[ this.name ];
1595
+ const buffer = this.parser.getDependency( 'buffer', extensionDef.buffer );
1596
+ const decoder = this.parser.options.meshoptDecoder;
1597
+ if ( ! decoder || ! decoder.supported ) {
1598
+
1599
+ if ( json.extensionsRequired && json.extensionsRequired.indexOf( this.name ) >= 0 ) {
1600
+
1601
+ throw new Error( 'THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files' );
1602
+
1603
+ } else {
1604
+
1605
+ // Assumes that the extension is optional and that fallback buffer data is present
1606
+ return null;
1607
+
1608
+ }
1609
+
1610
+ }
1611
+
1612
+ return buffer.then( function ( res ) {
1613
+
1614
+ const byteOffset = extensionDef.byteOffset || 0;
1615
+ const byteLength = extensionDef.byteLength || 0;
1616
+ const count = extensionDef.count;
1617
+ const stride = extensionDef.byteStride;
1618
+ const source = new Uint8Array( res, byteOffset, byteLength );
1619
+ if ( decoder.decodeGltfBufferAsync ) {
1620
+
1621
+ return decoder.decodeGltfBufferAsync( count, stride, source, extensionDef.mode, extensionDef.filter ).then( function ( res ) {
1622
+
1623
+ return res.buffer;
1624
+
1625
+ } );
1626
+
1627
+ } else {
1628
+
1629
+ // Support for MeshoptDecoder 0.18 or earlier, without decodeGltfBufferAsync
1630
+ return decoder.ready.then( function () {
1631
+
1632
+ const result = new ArrayBuffer( count * stride );
1633
+ decoder.decodeGltfBuffer( new Uint8Array( result ), count, stride, source, extensionDef.mode, extensionDef.filter );
1634
+ return result;
1635
+
1636
+ } );
1637
+
1638
+ }
1639
+
1640
+ } );
1641
+
1642
+ } else {
1643
+
1644
+ return null;
1645
+
1646
+ }
1647
+
1648
+ }
1649
+
1650
+ }
1651
+
1652
+ /**
1653
+ * GPU Instancing Extension
1654
+ *
1655
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_mesh_gpu_instancing
1656
+ *
1657
+ */
1658
+ class GLTFMeshGpuInstancing {
1659
+
1660
+ constructor( parser ) {
1661
+
1662
+ this.name = EXTENSIONS.EXT_MESH_GPU_INSTANCING;
1663
+ this.parser = parser;
1664
+
1665
+ }
1666
+ createNodeMesh( nodeIndex ) {
1667
+
1668
+ const json = this.parser.json;
1669
+ const nodeDef = json.nodes[ nodeIndex ];
1670
+ if ( ! nodeDef.extensions || ! nodeDef.extensions[ this.name ] || nodeDef.mesh === undefined ) {
1671
+
1672
+ return null;
1673
+
1674
+ }
1675
+
1676
+ const meshDef = json.meshes[ nodeDef.mesh ];
1677
+
1678
+ // No THREE.Points or Lines + Instancing support yet
1679
+
1680
+ for ( const primitive of meshDef.primitives ) {
1681
+
1682
+ if ( primitive.mode !== WEBGL_CONSTANTS.TRIANGLES && primitive.mode !== WEBGL_CONSTANTS.TRIANGLE_STRIP && primitive.mode !== WEBGL_CONSTANTS.TRIANGLE_FAN && primitive.mode !== undefined ) {
1683
+
1684
+ return null;
1685
+
1686
+ }
1687
+
1688
+ }
1689
+
1690
+ const extensionDef = nodeDef.extensions[ this.name ];
1691
+ const attributesDef = extensionDef.attributes;
1692
+
1693
+ // @TODO: Can we support THREE.InstancedMesh + THREE.SkinnedMesh?
1694
+
1695
+ const pending = [];
1696
+ const attributes = {};
1697
+ for ( const key in attributesDef ) {
1698
+
1699
+ pending.push( this.parser.getDependency( 'accessor', attributesDef[ key ] ).then( accessor => {
1700
+
1701
+ attributes[ key ] = accessor;
1702
+ return attributes[ key ];
1703
+
1704
+ } ) );
1705
+
1706
+ }
1707
+
1708
+ if ( pending.length < 1 ) {
1709
+
1710
+ return null;
1711
+
1712
+ }
1713
+
1714
+ pending.push( this.parser.createNodeMesh( nodeIndex ) );
1715
+ return Promise.all( pending ).then( results => {
1716
+
1717
+ const nodeObject = results.pop();
1718
+ const meshes = nodeObject.isGroup ? nodeObject.children : [ nodeObject ];
1719
+ const count = results[ 0 ].count; // All attribute counts should be same
1720
+ const instancedMeshes = [];
1721
+ for ( const mesh of meshes ) {
1722
+
1723
+ // Temporal variables
1724
+ const m = new THREE.Matrix4();
1725
+ const p = new THREE.Vector3();
1726
+ const q = new THREE.Quaternion();
1727
+ const s = new THREE.Vector3( 1, 1, 1 );
1728
+ const instancedMesh = new THREE.InstancedMesh( mesh.geometry, mesh.material, count );
1729
+ for ( let i = 0; i < count; i ++ ) {
1730
+
1731
+ if ( attributes.TRANSLATION ) {
1732
+
1733
+ p.fromBufferAttribute( attributes.TRANSLATION, i );
1734
+
1735
+ }
1736
+
1737
+ if ( attributes.ROTATION ) {
1738
+
1739
+ q.fromBufferAttribute( attributes.ROTATION, i );
1740
+
1741
+ }
1742
+
1743
+ if ( attributes.SCALE ) {
1744
+
1745
+ s.fromBufferAttribute( attributes.SCALE, i );
1746
+
1747
+ }
1748
+
1749
+ instancedMesh.setMatrixAt( i, m.compose( p, q, s ) );
1750
+
1751
+ }
1752
+
1753
+ // Add instance attributes to the geometry, excluding TRS.
1754
+ for ( const attributeName in attributes ) {
1755
+
1756
+ if ( attributeName !== 'TRANSLATION' && attributeName !== 'ROTATION' && attributeName !== 'SCALE' ) {
1757
+
1758
+ mesh.geometry.setAttribute( attributeName, attributes[ attributeName ] );
1759
+
1760
+ }
1761
+
1762
+ }
1763
+
1764
+ // Just in case
1765
+ THREE.Object3D.prototype.copy.call( instancedMesh, mesh );
1766
+
1767
+ // https://github.com/mrdoob/three.js/issues/18334
1768
+ instancedMesh.frustumCulled = false;
1769
+ this.parser.assignFinalMaterial( instancedMesh );
1770
+ instancedMeshes.push( instancedMesh );
1771
+
1772
+ }
1773
+
1774
+ if ( nodeObject.isGroup ) {
1775
+
1776
+ nodeObject.clear();
1777
+ nodeObject.add( ...instancedMeshes );
1778
+ return nodeObject;
1779
+
1780
+ }
1781
+
1782
+ return instancedMeshes[ 0 ];
1783
+
1784
+ } );
1785
+
1786
+ }
1787
+
1788
+ }
1789
+
1790
+ /* BINARY EXTENSION */
1791
+ const BINARY_EXTENSION_HEADER_MAGIC = 'glTF';
1792
+ const BINARY_EXTENSION_HEADER_LENGTH = 12;
1793
+ const BINARY_EXTENSION_CHUNK_TYPES = {
1794
+ JSON: 0x4E4F534A,
1795
+ BIN: 0x004E4942
1796
+ };
1797
+ class GLTFBinaryExtension {
1798
+
1799
+ constructor( data ) {
1800
+
1801
+ this.name = EXTENSIONS.KHR_BINARY_GLTF;
1802
+ this.content = null;
1803
+ this.body = null;
1804
+ const headerView = new DataView( data, 0, BINARY_EXTENSION_HEADER_LENGTH );
1805
+ this.header = {
1806
+ magic: THREE.LoaderUtils.decodeText( new Uint8Array( data.slice( 0, 4 ) ) ),
1807
+ version: headerView.getUint32( 4, true ),
1808
+ length: headerView.getUint32( 8, true )
1809
+ };
1810
+ if ( this.header.magic !== BINARY_EXTENSION_HEADER_MAGIC ) {
1811
+
1812
+ throw new Error( 'THREE.GLTFLoader: Unsupported glTF-Binary header.' );
1813
+
1814
+ } else if ( this.header.version < 2.0 ) {
1815
+
1816
+ throw new Error( 'THREE.GLTFLoader: Legacy binary file detected.' );
1817
+
1818
+ }
1819
+
1820
+ const chunkContentsLength = this.header.length - BINARY_EXTENSION_HEADER_LENGTH;
1821
+ const chunkView = new DataView( data, BINARY_EXTENSION_HEADER_LENGTH );
1822
+ let chunkIndex = 0;
1823
+ while ( chunkIndex < chunkContentsLength ) {
1824
+
1825
+ const chunkLength = chunkView.getUint32( chunkIndex, true );
1826
+ chunkIndex += 4;
1827
+ const chunkType = chunkView.getUint32( chunkIndex, true );
1828
+ chunkIndex += 4;
1829
+ if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.JSON ) {
1830
+
1831
+ const contentArray = new Uint8Array( data, BINARY_EXTENSION_HEADER_LENGTH + chunkIndex, chunkLength );
1832
+ this.content = THREE.LoaderUtils.decodeText( contentArray );
1833
+
1834
+ } else if ( chunkType === BINARY_EXTENSION_CHUNK_TYPES.BIN ) {
1835
+
1836
+ const byteOffset = BINARY_EXTENSION_HEADER_LENGTH + chunkIndex;
1837
+ this.body = data.slice( byteOffset, byteOffset + chunkLength );
1838
+
1839
+ }
1840
+
1841
+ // Clients must ignore chunks with unknown types.
1842
+
1843
+ chunkIndex += chunkLength;
1844
+
1845
+ }
1846
+
1847
+ if ( this.content === null ) {
1848
+
1849
+ throw new Error( 'THREE.GLTFLoader: JSON content not found.' );
1850
+
1851
+ }
1852
+
1853
+ }
1854
+
1855
+ }
1856
+
1857
+ /**
1858
+ * DRACO THREE.Mesh Compression Extension
1859
+ *
1860
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
1861
+ */
1862
+ class GLTFDracoMeshCompressionExtension {
1863
+
1864
+ constructor( json, dracoLoader ) {
1865
+
1866
+ if ( ! dracoLoader ) {
1867
+
1868
+ throw new Error( 'THREE.GLTFLoader: No DRACOLoader instance provided.' );
1869
+
1870
+ }
1871
+
1872
+ this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;
1873
+ this.json = json;
1874
+ this.dracoLoader = dracoLoader;
1875
+ this.dracoLoader.preload();
1876
+
1877
+ }
1878
+ decodePrimitive( primitive, parser ) {
1879
+
1880
+ const json = this.json;
1881
+ const dracoLoader = this.dracoLoader;
1882
+ const bufferViewIndex = primitive.extensions[ this.name ].bufferView;
1883
+ const gltfAttributeMap = primitive.extensions[ this.name ].attributes;
1884
+ const threeAttributeMap = {};
1885
+ const attributeNormalizedMap = {};
1886
+ const attributeTypeMap = {};
1887
+ for ( const attributeName in gltfAttributeMap ) {
1888
+
1889
+ const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
1890
+ threeAttributeMap[ threeAttributeName ] = gltfAttributeMap[ attributeName ];
1891
+
1892
+ }
1893
+
1894
+ for ( const attributeName in primitive.attributes ) {
1895
+
1896
+ const threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
1897
+ if ( gltfAttributeMap[ attributeName ] !== undefined ) {
1898
+
1899
+ const accessorDef = json.accessors[ primitive.attributes[ attributeName ] ];
1900
+ const componentType = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
1901
+ attributeTypeMap[ threeAttributeName ] = componentType.name;
1902
+ attributeNormalizedMap[ threeAttributeName ] = accessorDef.normalized === true;
1903
+
1904
+ }
1905
+
1906
+ }
1907
+
1908
+ return parser.getDependency( 'bufferView', bufferViewIndex ).then( function ( bufferView ) {
1909
+
1910
+ return new Promise( function ( resolve ) {
1911
+
1912
+ dracoLoader.decodeDracoFile( bufferView, function ( geometry ) {
1913
+
1914
+ for ( const attributeName in geometry.attributes ) {
1915
+
1916
+ const attribute = geometry.attributes[ attributeName ];
1917
+ const normalized = attributeNormalizedMap[ attributeName ];
1918
+ if ( normalized !== undefined ) attribute.normalized = normalized;
1919
+
1920
+ }
1921
+
1922
+ resolve( geometry );
1923
+
1924
+ }, threeAttributeMap, attributeTypeMap );
1925
+
1926
+ } );
1927
+
1928
+ } );
1929
+
1930
+ }
1931
+
1932
+ }
1933
+
1934
+ /**
1935
+ * THREE.Texture Transform Extension
1936
+ *
1937
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_transform
1938
+ */
1939
+ class GLTFTextureTransformExtension {
1940
+
1941
+ constructor() {
1942
+
1943
+ this.name = EXTENSIONS.KHR_TEXTURE_TRANSFORM;
1944
+
1945
+ }
1946
+ extendTexture( texture, transform ) {
1947
+
1948
+ if ( transform.texCoord !== undefined ) {
1949
+
1950
+ console.warn( 'THREE.GLTFLoader: Custom UV sets in "' + this.name + '" extension not yet supported.' );
1951
+
1952
+ }
1953
+
1954
+ if ( transform.offset === undefined && transform.rotation === undefined && transform.scale === undefined ) {
1955
+
1956
+ // See https://github.com/mrdoob/three.js/issues/21819.
1957
+ return texture;
1958
+
1959
+ }
1960
+
1961
+ texture = texture.clone();
1962
+ if ( transform.offset !== undefined ) {
1963
+
1964
+ texture.offset.fromArray( transform.offset );
1965
+
1966
+ }
1967
+
1968
+ if ( transform.rotation !== undefined ) {
1969
+
1970
+ texture.rotation = transform.rotation;
1971
+
1972
+ }
1973
+
1974
+ if ( transform.scale !== undefined ) {
1975
+
1976
+ texture.repeat.fromArray( transform.scale );
1977
+
1978
+ }
1979
+
1980
+ texture.needsUpdate = true;
1981
+ return texture;
1982
+
1983
+ }
1984
+
1985
+ }
1986
+
1987
+ /**
1988
+ * THREE.Mesh Quantization Extension
1989
+ *
1990
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization
1991
+ */
1992
+ class GLTFMeshQuantizationExtension {
1993
+
1994
+ constructor() {
1995
+
1996
+ this.name = EXTENSIONS.KHR_MESH_QUANTIZATION;
1997
+
1998
+ }
1999
+
2000
+ }
2001
+
2002
+ /*********************************/
2003
+ /********** INTERPOLATION ********/
2004
+ /*********************************/
2005
+
2006
+ // Spline Interpolation
2007
+ // Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation
2008
+ class GLTFCubicSplineInterpolant extends THREE.Interpolant {
2009
+
2010
+ constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) {
2011
+
2012
+ super( parameterPositions, sampleValues, sampleSize, resultBuffer );
2013
+
2014
+ }
2015
+ copySampleValue_( index ) {
2016
+
2017
+ // Copies a sample value to the result buffer. See description of glTF
2018
+ // CUBICSPLINE values layout in interpolate_() function below.
2019
+
2020
+ const result = this.resultBuffer,
2021
+ values = this.sampleValues,
2022
+ valueSize = this.valueSize,
2023
+ offset = index * valueSize * 3 + valueSize;
2024
+ for ( let i = 0; i !== valueSize; i ++ ) {
2025
+
2026
+ result[ i ] = values[ offset + i ];
2027
+
2028
+ }
2029
+
2030
+ return result;
2031
+
2032
+ }
2033
+ interpolate_( i1, t0, t, t1 ) {
2034
+
2035
+ const result = this.resultBuffer;
2036
+ const values = this.sampleValues;
2037
+ const stride = this.valueSize;
2038
+ const stride2 = stride * 2;
2039
+ const stride3 = stride * 3;
2040
+ const td = t1 - t0;
2041
+ const p = ( t - t0 ) / td;
2042
+ const pp = p * p;
2043
+ const ppp = pp * p;
2044
+ const offset1 = i1 * stride3;
2045
+ const offset0 = offset1 - stride3;
2046
+ const s2 = - 2 * ppp + 3 * pp;
2047
+ const s3 = ppp - pp;
2048
+ const s0 = 1 - s2;
2049
+ const s1 = s3 - pp + p;
2050
+
2051
+ // Layout of keyframe output values for CUBICSPLINE animations:
2052
+ // [ inTangent_1, splineVertex_1, outTangent_1, inTangent_2, splineVertex_2, ... ]
2053
+ for ( let i = 0; i !== stride; i ++ ) {
2054
+
2055
+ const p0 = values[ offset0 + i + stride ]; // splineVertex_k
2056
+ const m0 = values[ offset0 + i + stride2 ] * td; // outTangent_k * (t_k+1 - t_k)
2057
+ const p1 = values[ offset1 + i + stride ]; // splineVertex_k+1
2058
+ const m1 = values[ offset1 + i ] * td; // inTangent_k+1 * (t_k+1 - t_k)
2059
+
2060
+ result[ i ] = s0 * p0 + s1 * m0 + s2 * p1 + s3 * m1;
2061
+
2062
+ }
2063
+
2064
+ return result;
2065
+
2066
+ }
2067
+
2068
+ }
2069
+ const _q = new THREE.Quaternion();
2070
+ class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant {
2071
+
2072
+ interpolate_( i1, t0, t, t1 ) {
2073
+
2074
+ const result = super.interpolate_( i1, t0, t, t1 );
2075
+ _q.fromArray( result ).normalize().toArray( result );
2076
+ return result;
2077
+
2078
+ }
2079
+
2080
+ }
2081
+
2082
+ /*********************************/
2083
+ /********** INTERNALS ************/
2084
+ /*********************************/
2085
+
2086
+ /* CONSTANTS */
2087
+
2088
+ const WEBGL_CONSTANTS = {
2089
+ FLOAT: 5126,
2090
+ //FLOAT_MAT2: 35674,
2091
+ FLOAT_MAT3: 35675,
2092
+ FLOAT_MAT4: 35676,
2093
+ FLOAT_VEC2: 35664,
2094
+ FLOAT_VEC3: 35665,
2095
+ FLOAT_VEC4: 35666,
2096
+ LINEAR: 9729,
2097
+ REPEAT: 10497,
2098
+ SAMPLER_2D: 35678,
2099
+ POINTS: 0,
2100
+ LINES: 1,
2101
+ LINE_LOOP: 2,
2102
+ LINE_STRIP: 3,
2103
+ TRIANGLES: 4,
2104
+ TRIANGLE_STRIP: 5,
2105
+ TRIANGLE_FAN: 6,
2106
+ UNSIGNED_BYTE: 5121,
2107
+ UNSIGNED_SHORT: 5123
2108
+ };
2109
+ const WEBGL_COMPONENT_TYPES = {
2110
+ 5120: Int8Array,
2111
+ 5121: Uint8Array,
2112
+ 5122: Int16Array,
2113
+ 5123: Uint16Array,
2114
+ 5125: Uint32Array,
2115
+ 5126: Float32Array
2116
+ };
2117
+ const WEBGL_FILTERS = {
2118
+ 9728: THREE.NearestFilter,
2119
+ 9729: THREE.LinearFilter,
2120
+ 9984: THREE.NearestMipmapNearestFilter,
2121
+ 9985: THREE.LinearMipmapNearestFilter,
2122
+ 9986: THREE.NearestMipmapLinearFilter,
2123
+ 9987: THREE.LinearMipmapLinearFilter
2124
+ };
2125
+ const WEBGL_WRAPPINGS = {
2126
+ 33071: THREE.ClampToEdgeWrapping,
2127
+ 33648: THREE.MirroredRepeatWrapping,
2128
+ 10497: THREE.RepeatWrapping
2129
+ };
2130
+ const WEBGL_TYPE_SIZES = {
2131
+ 'SCALAR': 1,
2132
+ 'VEC2': 2,
2133
+ 'VEC3': 3,
2134
+ 'VEC4': 4,
2135
+ 'MAT2': 4,
2136
+ 'MAT3': 9,
2137
+ 'MAT4': 16
2138
+ };
2139
+ const ATTRIBUTES = {
2140
+ POSITION: 'position',
2141
+ NORMAL: 'normal',
2142
+ TANGENT: 'tangent',
2143
+ TEXCOORD_0: 'uv',
2144
+ TEXCOORD_1: 'uv2',
2145
+ COLOR_0: 'color',
2146
+ WEIGHTS_0: 'skinWeight',
2147
+ JOINTS_0: 'skinIndex'
2148
+ };
2149
+ const PATH_PROPERTIES = {
2150
+ scale: 'scale',
2151
+ translation: 'position',
2152
+ rotation: 'quaternion',
2153
+ weights: 'morphTargetInfluences'
2154
+ };
2155
+ const INTERPOLATION = {
2156
+ CUBICSPLINE: undefined,
2157
+ // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
2158
+ // keyframe track will be initialized with a default interpolation type, then modified.
2159
+ LINEAR: THREE.InterpolateLinear,
2160
+ STEP: THREE.InterpolateDiscrete
2161
+ };
2162
+ const ALPHA_MODES = {
2163
+ OPAQUE: 'OPAQUE',
2164
+ MASK: 'MASK',
2165
+ BLEND: 'BLEND'
2166
+ };
2167
+
2168
+ /**
2169
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
2170
+ */
2171
+ function createDefaultMaterial( cache ) {
2172
+
2173
+ if ( cache[ 'DefaultMaterial' ] === undefined ) {
2174
+
2175
+ cache[ 'DefaultMaterial' ] = new THREE.MeshStandardMaterial( {
2176
+ color: 0xFFFFFF,
2177
+ emissive: 0x000000,
2178
+ metalness: 1,
2179
+ roughness: 1,
2180
+ transparent: false,
2181
+ depthTest: true,
2182
+ side: THREE.FrontSide
2183
+ } );
2184
+
2185
+ }
2186
+
2187
+ return cache[ 'DefaultMaterial' ];
2188
+
2189
+ }
2190
+
2191
+ function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) {
2192
+
2193
+ // Add unknown glTF extensions to an object's userData.
2194
+
2195
+ for ( const name in objectDef.extensions ) {
2196
+
2197
+ if ( knownExtensions[ name ] === undefined ) {
2198
+
2199
+ object.userData.gltfExtensions = object.userData.gltfExtensions || {};
2200
+ object.userData.gltfExtensions[ name ] = objectDef.extensions[ name ];
2201
+
2202
+ }
2203
+
2204
+ }
2205
+
2206
+ }
2207
+
2208
+ /**
2209
+ * @param {Object3D|Material|BufferGeometry} object
2210
+ * @param {GLTF.definition} gltfDef
2211
+ */
2212
+ function assignExtrasToUserData( object, gltfDef ) {
2213
+
2214
+ if ( gltfDef.extras !== undefined ) {
2215
+
2216
+ if ( typeof gltfDef.extras === 'object' ) {
2217
+
2218
+ Object.assign( object.userData, gltfDef.extras );
2219
+
2220
+ } else {
2221
+
2222
+ console.warn( 'THREE.GLTFLoader: Ignoring primitive type .extras, ' + gltfDef.extras );
2223
+
2224
+ }
2225
+
2226
+ }
2227
+
2228
+ }
2229
+
2230
+ /**
2231
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#morph-targets
2232
+ *
2233
+ * @param {BufferGeometry} geometry
2234
+ * @param {Array<GLTF.Target>} targets
2235
+ * @param {GLTFParser} parser
2236
+ * @return {Promise<BufferGeometry>}
2237
+ */
2238
+ function addMorphTargets( geometry, targets, parser ) {
2239
+
2240
+ let hasMorphPosition = false;
2241
+ let hasMorphNormal = false;
2242
+ let hasMorphColor = false;
2243
+ for ( let i = 0, il = targets.length; i < il; i ++ ) {
2244
+
2245
+ const target = targets[ i ];
2246
+ if ( target.POSITION !== undefined ) hasMorphPosition = true;
2247
+ if ( target.NORMAL !== undefined ) hasMorphNormal = true;
2248
+ if ( target.COLOR_0 !== undefined ) hasMorphColor = true;
2249
+ if ( hasMorphPosition && hasMorphNormal && hasMorphColor ) break;
2250
+
2251
+ }
2252
+
2253
+ if ( ! hasMorphPosition && ! hasMorphNormal && ! hasMorphColor ) return Promise.resolve( geometry );
2254
+ const pendingPositionAccessors = [];
2255
+ const pendingNormalAccessors = [];
2256
+ const pendingColorAccessors = [];
2257
+ for ( let i = 0, il = targets.length; i < il; i ++ ) {
2258
+
2259
+ const target = targets[ i ];
2260
+ if ( hasMorphPosition ) {
2261
+
2262
+ const pendingAccessor = target.POSITION !== undefined ? parser.getDependency( 'accessor', target.POSITION ) : geometry.attributes.position;
2263
+ pendingPositionAccessors.push( pendingAccessor );
2264
+
2265
+ }
2266
+
2267
+ if ( hasMorphNormal ) {
2268
+
2269
+ const pendingAccessor = target.NORMAL !== undefined ? parser.getDependency( 'accessor', target.NORMAL ) : geometry.attributes.normal;
2270
+ pendingNormalAccessors.push( pendingAccessor );
2271
+
2272
+ }
2273
+
2274
+ if ( hasMorphColor ) {
2275
+
2276
+ const pendingAccessor = target.COLOR_0 !== undefined ? parser.getDependency( 'accessor', target.COLOR_0 ) : geometry.attributes.color;
2277
+ pendingColorAccessors.push( pendingAccessor );
2278
+
2279
+ }
2280
+
2281
+ }
2282
+
2283
+ return Promise.all( [ Promise.all( pendingPositionAccessors ), Promise.all( pendingNormalAccessors ), Promise.all( pendingColorAccessors ) ] ).then( function ( accessors ) {
2284
+
2285
+ const morphPositions = accessors[ 0 ];
2286
+ const morphNormals = accessors[ 1 ];
2287
+ const morphColors = accessors[ 2 ];
2288
+ if ( hasMorphPosition ) geometry.morphAttributes.position = morphPositions;
2289
+ if ( hasMorphNormal ) geometry.morphAttributes.normal = morphNormals;
2290
+ if ( hasMorphColor ) geometry.morphAttributes.color = morphColors;
2291
+ geometry.morphTargetsRelative = true;
2292
+ return geometry;
2293
+
2294
+ } );
2295
+
2296
+ }
2297
+
2298
+ /**
2299
+ * @param {Mesh} mesh
2300
+ * @param {GLTF.Mesh} meshDef
2301
+ */
2302
+ function updateMorphTargets( mesh, meshDef ) {
2303
+
2304
+ mesh.updateMorphTargets();
2305
+ if ( meshDef.weights !== undefined ) {
2306
+
2307
+ for ( let i = 0, il = meshDef.weights.length; i < il; i ++ ) {
2308
+
2309
+ mesh.morphTargetInfluences[ i ] = meshDef.weights[ i ];
2310
+
2311
+ }
2312
+
2313
+ }
2314
+
2315
+ // .extras has user-defined data, so check that .extras.targetNames is an array.
2316
+ if ( meshDef.extras && Array.isArray( meshDef.extras.targetNames ) ) {
2317
+
2318
+ const targetNames = meshDef.extras.targetNames;
2319
+ if ( mesh.morphTargetInfluences.length === targetNames.length ) {
2320
+
2321
+ mesh.morphTargetDictionary = {};
2322
+ for ( let i = 0, il = targetNames.length; i < il; i ++ ) {
2323
+
2324
+ mesh.morphTargetDictionary[ targetNames[ i ] ] = i;
2325
+
2326
+ }
2327
+
2328
+ } else {
2329
+
2330
+ console.warn( 'THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.' );
2331
+
2332
+ }
2333
+
2334
+ }
2335
+
2336
+ }
2337
+
2338
+ function createPrimitiveKey( primitiveDef ) {
2339
+
2340
+ const dracoExtension = primitiveDef.extensions && primitiveDef.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ];
2341
+ let geometryKey;
2342
+ if ( dracoExtension ) {
2343
+
2344
+ geometryKey = 'draco:' + dracoExtension.bufferView + ':' + dracoExtension.indices + ':' + createAttributesKey( dracoExtension.attributes );
2345
+
2346
+ } else {
2347
+
2348
+ geometryKey = primitiveDef.indices + ':' + createAttributesKey( primitiveDef.attributes ) + ':' + primitiveDef.mode;
2349
+
2350
+ }
2351
+
2352
+ return geometryKey;
2353
+
2354
+ }
2355
+
2356
+ function createAttributesKey( attributes ) {
2357
+
2358
+ let attributesKey = '';
2359
+ const keys = Object.keys( attributes ).sort();
2360
+ for ( let i = 0, il = keys.length; i < il; i ++ ) {
2361
+
2362
+ attributesKey += keys[ i ] + ':' + attributes[ keys[ i ] ] + ';';
2363
+
2364
+ }
2365
+
2366
+ return attributesKey;
2367
+
2368
+ }
2369
+
2370
+ function getNormalizedComponentScale( constructor ) {
2371
+
2372
+ // Reference:
2373
+ // https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization#encoding-quantized-data
2374
+
2375
+ switch ( constructor ) {
2376
+
2377
+ case Int8Array:
2378
+ return 1 / 127;
2379
+ case Uint8Array:
2380
+ return 1 / 255;
2381
+ case Int16Array:
2382
+ return 1 / 32767;
2383
+ case Uint16Array:
2384
+ return 1 / 65535;
2385
+ default:
2386
+ throw new Error( 'THREE.GLTFLoader: Unsupported normalized accessor component type.' );
2387
+
2388
+ }
2389
+
2390
+ }
2391
+
2392
+ function getImageURIMimeType( uri ) {
2393
+
2394
+ if ( uri.search( /\.jpe?g($|\?)/i ) > 0 || uri.search( /^data\:image\/jpeg/ ) === 0 ) return 'image/jpeg';
2395
+ if ( uri.search( /\.webp($|\?)/i ) > 0 || uri.search( /^data\:image\/webp/ ) === 0 ) return 'image/webp';
2396
+ return 'image/png';
2397
+
2398
+ }
2399
+
2400
+ /* GLTF PARSER */
2401
+
2402
+ class GLTFParser {
2403
+
2404
+ constructor( json = {}, options = {} ) {
2405
+
2406
+ this.json = json;
2407
+ this.extensions = {};
2408
+ this.plugins = {};
2409
+ this.options = options;
2410
+
2411
+ // loader object cache
2412
+ this.cache = new GLTFRegistry();
2413
+
2414
+ // associations between Three.js objects and glTF elements
2415
+ this.associations = new Map();
2416
+
2417
+ // THREE.BufferGeometry caching
2418
+ this.primitiveCache = {};
2419
+
2420
+ // THREE.Object3D instance caches
2421
+ this.meshCache = {
2422
+ refs: {},
2423
+ uses: {}
2424
+ };
2425
+ this.cameraCache = {
2426
+ refs: {},
2427
+ uses: {}
2428
+ };
2429
+ this.lightCache = {
2430
+ refs: {},
2431
+ uses: {}
2432
+ };
2433
+ this.sourceCache = {};
2434
+ this.textureCache = {};
2435
+
2436
+ // Track node names, to ensure no duplicates
2437
+ this.nodeNamesUsed = {};
2438
+
2439
+ // Use an THREE.ImageBitmapLoader if imageBitmaps are supported. Moves much of the
2440
+ // expensive work of uploading a texture to the GPU off the main thread.
2441
+
2442
+ let isSafari = false;
2443
+ let isFirefox = false;
2444
+ let firefoxVersion = - 1;
2445
+ if ( typeof navigator !== 'undefined' ) {
2446
+
2447
+ isSafari = /^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === true;
2448
+ isFirefox = navigator.userAgent.indexOf( 'Firefox' ) > - 1;
2449
+ firefoxVersion = isFirefox ? navigator.userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
2450
+
2451
+ }
2452
+
2453
+ if ( typeof createImageBitmap === 'undefined' || isSafari || isFirefox && firefoxVersion < 98 ) {
2454
+
2455
+ this.textureLoader = new THREE.TextureLoader( this.options.manager );
2456
+
2457
+ } else {
2458
+
2459
+ this.textureLoader = new THREE.ImageBitmapLoader( this.options.manager );
2460
+
2461
+ }
2462
+
2463
+ this.textureLoader.setCrossOrigin( this.options.crossOrigin );
2464
+ this.textureLoader.setRequestHeader( this.options.requestHeader );
2465
+ this.fileLoader = new THREE.FileLoader( this.options.manager );
2466
+ this.fileLoader.setResponseType( 'arraybuffer' );
2467
+ if ( this.options.crossOrigin === 'use-credentials' ) {
2468
+
2469
+ this.fileLoader.setWithCredentials( true );
2470
+
2471
+ }
2472
+
2473
+ }
2474
+ setExtensions( extensions ) {
2475
+
2476
+ this.extensions = extensions;
2477
+
2478
+ }
2479
+ setPlugins( plugins ) {
2480
+
2481
+ this.plugins = plugins;
2482
+
2483
+ }
2484
+ parse( onLoad, onError ) {
2485
+
2486
+ const parser = this;
2487
+ const json = this.json;
2488
+ const extensions = this.extensions;
2489
+
2490
+ // Clear the loader cache
2491
+ this.cache.removeAll();
2492
+
2493
+ // Mark the special nodes/meshes in json for efficient parse
2494
+ this._invokeAll( function ( ext ) {
2495
+
2496
+ return ext._markDefs && ext._markDefs();
2497
+
2498
+ } );
2499
+ Promise.all( this._invokeAll( function ( ext ) {
2500
+
2501
+ return ext.beforeRoot && ext.beforeRoot();
2502
+
2503
+ } ) ).then( function () {
2504
+
2505
+ return Promise.all( [ parser.getDependencies( 'scene' ), parser.getDependencies( 'animation' ), parser.getDependencies( 'camera' ) ] );
2506
+
2507
+ } ).then( function ( dependencies ) {
2508
+
2509
+ const result = {
2510
+ scene: dependencies[ 0 ][ json.scene || 0 ],
2511
+ scenes: dependencies[ 0 ],
2512
+ animations: dependencies[ 1 ],
2513
+ cameras: dependencies[ 2 ],
2514
+ asset: json.asset,
2515
+ parser: parser,
2516
+ userData: {}
2517
+ };
2518
+ addUnknownExtensionsToUserData( extensions, result, json );
2519
+ assignExtrasToUserData( result, json );
2520
+ Promise.all( parser._invokeAll( function ( ext ) {
2521
+
2522
+ return ext.afterRoot && ext.afterRoot( result );
2523
+
2524
+ } ) ).then( function () {
2525
+
2526
+ onLoad( result );
2527
+
2528
+ } );
2529
+
2530
+ } ).catch( onError );
2531
+
2532
+ }
2533
+
2534
+ /**
2535
+ * Marks the special nodes/meshes in json for efficient parse.
2536
+ */
2537
+ _markDefs() {
2538
+
2539
+ const nodeDefs = this.json.nodes || [];
2540
+ const skinDefs = this.json.skins || [];
2541
+ const meshDefs = this.json.meshes || [];
2542
+
2543
+ // Nothing in the node definition indicates whether it is a THREE.Bone or an
2544
+ // THREE.Object3D. Use the skins' joint references to mark bones.
2545
+ for ( let skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex ++ ) {
2546
+
2547
+ const joints = skinDefs[ skinIndex ].joints;
2548
+ for ( let i = 0, il = joints.length; i < il; i ++ ) {
2549
+
2550
+ nodeDefs[ joints[ i ] ].isBone = true;
2551
+
2552
+ }
2553
+
2554
+ }
2555
+
2556
+ // Iterate over all nodes, marking references to shared resources,
2557
+ // as well as skeleton joints.
2558
+ for ( let nodeIndex = 0, nodeLength = nodeDefs.length; nodeIndex < nodeLength; nodeIndex ++ ) {
2559
+
2560
+ const nodeDef = nodeDefs[ nodeIndex ];
2561
+ if ( nodeDef.mesh !== undefined ) {
2562
+
2563
+ this._addNodeRef( this.meshCache, nodeDef.mesh );
2564
+
2565
+ // Nothing in the mesh definition indicates whether it is
2566
+ // a THREE.SkinnedMesh or THREE.Mesh. Use the node's mesh reference
2567
+ // to mark THREE.SkinnedMesh if node has skin.
2568
+ if ( nodeDef.skin !== undefined ) {
2569
+
2570
+ meshDefs[ nodeDef.mesh ].isSkinnedMesh = true;
2571
+
2572
+ }
2573
+
2574
+ }
2575
+
2576
+ if ( nodeDef.camera !== undefined ) {
2577
+
2578
+ this._addNodeRef( this.cameraCache, nodeDef.camera );
2579
+
2580
+ }
2581
+
2582
+ }
2583
+
2584
+ }
2585
+
2586
+ /**
2587
+ * Counts references to shared node / THREE.Object3D resources. These resources
2588
+ * can be reused, or "instantiated", at multiple nodes in the scene
2589
+ * hierarchy. THREE.Mesh, Camera, and Light instances are instantiated and must
2590
+ * be marked. Non-scenegraph resources (like Materials, Geometries, and
2591
+ * Textures) can be reused directly and are not marked here.
2592
+ *
2593
+ * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
2594
+ */
2595
+ _addNodeRef( cache, index ) {
2596
+
2597
+ if ( index === undefined ) return;
2598
+ if ( cache.refs[ index ] === undefined ) {
2599
+
2600
+ cache.refs[ index ] = cache.uses[ index ] = 0;
2601
+
2602
+ }
2603
+
2604
+ cache.refs[ index ] ++;
2605
+
2606
+ }
2607
+
2608
+ /** Returns a reference to a shared resource, cloning it if necessary. */
2609
+ _getNodeRef( cache, index, object ) {
2610
+
2611
+ if ( cache.refs[ index ] <= 1 ) return object;
2612
+ const ref = object.clone();
2613
+
2614
+ // Propagates mappings to the cloned object, prevents mappings on the
2615
+ // original object from being lost.
2616
+ const updateMappings = ( original, clone ) => {
2617
+
2618
+ const mappings = this.associations.get( original );
2619
+ if ( mappings != null ) {
2620
+
2621
+ this.associations.set( clone, mappings );
2622
+
2623
+ }
2624
+
2625
+ for ( const [ i, child ] of original.children.entries() ) {
2626
+
2627
+ updateMappings( child, clone.children[ i ] );
2628
+
2629
+ }
2630
+
2631
+ };
2632
+
2633
+ updateMappings( object, ref );
2634
+ ref.name += '_instance_' + cache.uses[ index ] ++;
2635
+ return ref;
2636
+
2637
+ }
2638
+ _invokeOne( func ) {
2639
+
2640
+ const extensions = Object.values( this.plugins );
2641
+ extensions.push( this );
2642
+ for ( let i = 0; i < extensions.length; i ++ ) {
2643
+
2644
+ const result = func( extensions[ i ] );
2645
+ if ( result ) return result;
2646
+
2647
+ }
2648
+
2649
+ return null;
2650
+
2651
+ }
2652
+ _invokeAll( func ) {
2653
+
2654
+ const extensions = Object.values( this.plugins );
2655
+ extensions.unshift( this );
2656
+ const pending = [];
2657
+ for ( let i = 0; i < extensions.length; i ++ ) {
2658
+
2659
+ const result = func( extensions[ i ] );
2660
+ if ( result ) pending.push( result );
2661
+
2662
+ }
2663
+
2664
+ return pending;
2665
+
2666
+ }
2667
+
2668
+ /**
2669
+ * Requests the specified dependency asynchronously, with caching.
2670
+ * @param {string} type
2671
+ * @param {number} index
2672
+ * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
2673
+ */
2674
+ getDependency( type, index ) {
2675
+
2676
+ const cacheKey = type + ':' + index;
2677
+ let dependency = this.cache.get( cacheKey );
2678
+ if ( ! dependency ) {
2679
+
2680
+ switch ( type ) {
2681
+
2682
+ case 'scene':
2683
+ dependency = this.loadScene( index );
2684
+ break;
2685
+ case 'node':
2686
+ dependency = this.loadNode( index );
2687
+ break;
2688
+ case 'mesh':
2689
+ dependency = this._invokeOne( function ( ext ) {
2690
+
2691
+ return ext.loadMesh && ext.loadMesh( index );
2692
+
2693
+ } );
2694
+ break;
2695
+ case 'accessor':
2696
+ dependency = this.loadAccessor( index );
2697
+ break;
2698
+ case 'bufferView':
2699
+ dependency = this._invokeOne( function ( ext ) {
2700
+
2701
+ return ext.loadBufferView && ext.loadBufferView( index );
2702
+
2703
+ } );
2704
+ break;
2705
+ case 'buffer':
2706
+ dependency = this.loadBuffer( index );
2707
+ break;
2708
+ case 'material':
2709
+ dependency = this._invokeOne( function ( ext ) {
2710
+
2711
+ return ext.loadMaterial && ext.loadMaterial( index );
2712
+
2713
+ } );
2714
+ break;
2715
+ case 'texture':
2716
+ dependency = this._invokeOne( function ( ext ) {
2717
+
2718
+ return ext.loadTexture && ext.loadTexture( index );
2719
+
2720
+ } );
2721
+ break;
2722
+ case 'skin':
2723
+ dependency = this.loadSkin( index );
2724
+ break;
2725
+ case 'animation':
2726
+ dependency = this._invokeOne( function ( ext ) {
2727
+
2728
+ return ext.loadAnimation && ext.loadAnimation( index );
2729
+
2730
+ } );
2731
+ break;
2732
+ case 'camera':
2733
+ dependency = this.loadCamera( index );
2734
+ break;
2735
+ default:
2736
+ dependency = this._invokeOne( function ( ext ) {
2737
+
2738
+ return ext != this && ext.getDependency && ext.getDependency( type, index );
2739
+
2740
+ } );
2741
+ if ( ! dependency ) {
2742
+
2743
+ throw new Error( 'Unknown type: ' + type );
2744
+
2745
+ }
2746
+
2747
+ break;
2748
+
2749
+ }
2750
+
2751
+ this.cache.add( cacheKey, dependency );
2752
+
2753
+ }
2754
+
2755
+ return dependency;
2756
+
2757
+ }
2758
+
2759
+ getDependencies( type ) {
2760
+
2761
+ let dependencies = this.cache.get( type );
2762
+ if ( ! dependencies ) {
2763
+
2764
+ const parser = this;
2765
+ const defs = this.json[ type + ( type === 'mesh' ? 'es' : 's' ) ] || [];
2766
+ dependencies = Promise.all( defs.map( function ( def, index ) {
2767
+
2768
+ return parser.getDependency( type, index );
2769
+
2770
+ } ) );
2771
+ this.cache.add( type, dependencies );
2772
+
2773
+ }
2774
+
2775
+ return dependencies;
2776
+
2777
+ }
2778
+
2779
+ /**
2780
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
2781
+ * @param {number} bufferIndex
2782
+ * @return {Promise<ArrayBuffer>}
2783
+ */
2784
+ loadBuffer( bufferIndex ) {
2785
+
2786
+ const bufferDef = this.json.buffers[ bufferIndex ];
2787
+ const loader = this.fileLoader;
2788
+ if ( bufferDef.type && bufferDef.type !== 'arraybuffer' ) {
2789
+
2790
+ throw new Error( 'THREE.GLTFLoader: ' + bufferDef.type + ' buffer type is not supported.' );
2791
+
2792
+ }
2793
+
2794
+ // If present, GLB container is required to be the first buffer.
2795
+ if ( bufferDef.uri === undefined && bufferIndex === 0 ) {
2796
+
2797
+ return Promise.resolve( this.extensions[ EXTENSIONS.KHR_BINARY_GLTF ].body );
2798
+
2799
+ }
2800
+
2801
+ const options = this.options;
2802
+ return new Promise( function ( resolve, reject ) {
2803
+
2804
+ loader.load( THREE.LoaderUtils.resolveURL( bufferDef.uri, options.path ), resolve, undefined, function () {
2805
+
2806
+ reject( new Error( 'THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".' ) );
2807
+
2808
+ } );
2809
+
2810
+ } );
2811
+
2812
+ }
2813
+
2814
+ /**
2815
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
2816
+ * @param {number} bufferViewIndex
2817
+ * @return {Promise<ArrayBuffer>}
2818
+ */
2819
+ loadBufferView( bufferViewIndex ) {
2820
+
2821
+ const bufferViewDef = this.json.bufferViews[ bufferViewIndex ];
2822
+ return this.getDependency( 'buffer', bufferViewDef.buffer ).then( function ( buffer ) {
2823
+
2824
+ const byteLength = bufferViewDef.byteLength || 0;
2825
+ const byteOffset = bufferViewDef.byteOffset || 0;
2826
+ return buffer.slice( byteOffset, byteOffset + byteLength );
2827
+
2828
+ } );
2829
+
2830
+ }
2831
+
2832
+ /**
2833
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
2834
+ * @param {number} accessorIndex
2835
+ * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
2836
+ */
2837
+ loadAccessor( accessorIndex ) {
2838
+
2839
+ const parser = this;
2840
+ const json = this.json;
2841
+ const accessorDef = this.json.accessors[ accessorIndex ];
2842
+ if ( accessorDef.bufferView === undefined && accessorDef.sparse === undefined ) {
2843
+
2844
+ const itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ];
2845
+ const TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
2846
+ const normalized = accessorDef.normalized === true;
2847
+ const array = new TypedArray( accessorDef.count * itemSize );
2848
+ return Promise.resolve( new THREE.BufferAttribute( array, itemSize, normalized ) );
2849
+
2850
+ }
2851
+
2852
+ const pendingBufferViews = [];
2853
+ if ( accessorDef.bufferView !== undefined ) {
2854
+
2855
+ pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.bufferView ) );
2856
+
2857
+ } else {
2858
+
2859
+ pendingBufferViews.push( null );
2860
+
2861
+ }
2862
+
2863
+ if ( accessorDef.sparse !== undefined ) {
2864
+
2865
+ pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.indices.bufferView ) );
2866
+ pendingBufferViews.push( this.getDependency( 'bufferView', accessorDef.sparse.values.bufferView ) );
2867
+
2868
+ }
2869
+
2870
+ return Promise.all( pendingBufferViews ).then( function ( bufferViews ) {
2871
+
2872
+ const bufferView = bufferViews[ 0 ];
2873
+ const itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ];
2874
+ const TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
2875
+
2876
+ // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12.
2877
+ const elementBytes = TypedArray.BYTES_PER_ELEMENT;
2878
+ const itemBytes = elementBytes * itemSize;
2879
+ const byteOffset = accessorDef.byteOffset || 0;
2880
+ const byteStride = accessorDef.bufferView !== undefined ? json.bufferViews[ accessorDef.bufferView ].byteStride : undefined;
2881
+ const normalized = accessorDef.normalized === true;
2882
+ let array, bufferAttribute;
2883
+
2884
+ // The buffer is not interleaved if the stride is the item size in bytes.
2885
+ if ( byteStride && byteStride !== itemBytes ) {
2886
+
2887
+ // Each "slice" of the buffer, as defined by 'count' elements of 'byteStride' bytes, gets its own THREE.InterleavedBuffer
2888
+ // This makes sure that IBA.count reflects accessor.count properly
2889
+ const ibSlice = Math.floor( byteOffset / byteStride );
2890
+ const ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType + ':' + ibSlice + ':' + accessorDef.count;
2891
+ let ib = parser.cache.get( ibCacheKey );
2892
+ if ( ! ib ) {
2893
+
2894
+ array = new TypedArray( bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes );
2895
+
2896
+ // Integer parameters to IB/IBA are in array elements, not bytes.
2897
+ ib = new THREE.InterleavedBuffer( array, byteStride / elementBytes );
2898
+ parser.cache.add( ibCacheKey, ib );
2899
+
2900
+ }
2901
+
2902
+ bufferAttribute = new THREE.InterleavedBufferAttribute( ib, itemSize, byteOffset % byteStride / elementBytes, normalized );
2903
+
2904
+ } else {
2905
+
2906
+ if ( bufferView === null ) {
2907
+
2908
+ array = new TypedArray( accessorDef.count * itemSize );
2909
+
2910
+ } else {
2911
+
2912
+ array = new TypedArray( bufferView, byteOffset, accessorDef.count * itemSize );
2913
+
2914
+ }
2915
+
2916
+ bufferAttribute = new THREE.BufferAttribute( array, itemSize, normalized );
2917
+
2918
+ }
2919
+
2920
+ // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors
2921
+ if ( accessorDef.sparse !== undefined ) {
2922
+
2923
+ const itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;
2924
+ const TypedArrayIndices = WEBGL_COMPONENT_TYPES[ accessorDef.sparse.indices.componentType ];
2925
+ const byteOffsetIndices = accessorDef.sparse.indices.byteOffset || 0;
2926
+ const byteOffsetValues = accessorDef.sparse.values.byteOffset || 0;
2927
+ const sparseIndices = new TypedArrayIndices( bufferViews[ 1 ], byteOffsetIndices, accessorDef.sparse.count * itemSizeIndices );
2928
+ const sparseValues = new TypedArray( bufferViews[ 2 ], byteOffsetValues, accessorDef.sparse.count * itemSize );
2929
+ if ( bufferView !== null ) {
2930
+
2931
+ // Avoid modifying the original ArrayBuffer, if the bufferView wasn't initialized with zeroes.
2932
+ bufferAttribute = new THREE.BufferAttribute( bufferAttribute.array.slice(), bufferAttribute.itemSize, bufferAttribute.normalized );
2933
+
2934
+ }
2935
+
2936
+ for ( let i = 0, il = sparseIndices.length; i < il; i ++ ) {
2937
+
2938
+ const index = sparseIndices[ i ];
2939
+ bufferAttribute.setX( index, sparseValues[ i * itemSize ] );
2940
+ if ( itemSize >= 2 ) bufferAttribute.setY( index, sparseValues[ i * itemSize + 1 ] );
2941
+ if ( itemSize >= 3 ) bufferAttribute.setZ( index, sparseValues[ i * itemSize + 2 ] );
2942
+ if ( itemSize >= 4 ) bufferAttribute.setW( index, sparseValues[ i * itemSize + 3 ] );
2943
+ if ( itemSize >= 5 ) throw new Error( 'THREE.GLTFLoader: Unsupported itemSize in sparse THREE.BufferAttribute.' );
2944
+
2945
+ }
2946
+
2947
+ }
2948
+
2949
+ return bufferAttribute;
2950
+
2951
+ } );
2952
+
2953
+ }
2954
+
2955
+ /**
2956
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
2957
+ * @param {number} textureIndex
2958
+ * @return {Promise<THREE.Texture|null>}
2959
+ */
2960
+ loadTexture( textureIndex ) {
2961
+
2962
+ const json = this.json;
2963
+ const options = this.options;
2964
+ const textureDef = json.textures[ textureIndex ];
2965
+ const sourceIndex = textureDef.source;
2966
+ const sourceDef = json.images[ sourceIndex ];
2967
+ let loader = this.textureLoader;
2968
+ if ( sourceDef.uri ) {
2969
+
2970
+ const handler = options.manager.getHandler( sourceDef.uri );
2971
+ if ( handler !== null ) loader = handler;
2972
+
2973
+ }
2974
+
2975
+ return this.loadTextureImage( textureIndex, sourceIndex, loader );
2976
+
2977
+ }
2978
+ loadTextureImage( textureIndex, sourceIndex, loader ) {
2979
+
2980
+ const parser = this;
2981
+ const json = this.json;
2982
+ const textureDef = json.textures[ textureIndex ];
2983
+ const sourceDef = json.images[ sourceIndex ];
2984
+ const cacheKey = ( sourceDef.uri || sourceDef.bufferView ) + ':' + textureDef.sampler;
2985
+ if ( this.textureCache[ cacheKey ] ) {
2986
+
2987
+ // See https://github.com/mrdoob/three.js/issues/21559.
2988
+ return this.textureCache[ cacheKey ];
2989
+
2990
+ }
2991
+
2992
+ const promise = this.loadImageSource( sourceIndex, loader ).then( function ( texture ) {
2993
+
2994
+ texture.flipY = false;
2995
+ texture.name = textureDef.name || sourceDef.name || '';
2996
+ const samplers = json.samplers || {};
2997
+ const sampler = samplers[ textureDef.sampler ] || {};
2998
+ texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ] || THREE.LinearFilter;
2999
+ texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ] || THREE.LinearMipmapLinearFilter;
3000
+ texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ] || THREE.RepeatWrapping;
3001
+ texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ] || THREE.RepeatWrapping;
3002
+ parser.associations.set( texture, {
3003
+ textures: textureIndex
3004
+ } );
3005
+ return texture;
3006
+
3007
+ } ).catch( function () {
3008
+
3009
+ return null;
3010
+
3011
+ } );
3012
+ this.textureCache[ cacheKey ] = promise;
3013
+ return promise;
3014
+
3015
+ }
3016
+ loadImageSource( sourceIndex, loader ) {
3017
+
3018
+ const parser = this;
3019
+ const json = this.json;
3020
+ const options = this.options;
3021
+ if ( this.sourceCache[ sourceIndex ] !== undefined ) {
3022
+
3023
+ return this.sourceCache[ sourceIndex ].then( texture => texture.clone() );
3024
+
3025
+ }
3026
+
3027
+ const sourceDef = json.images[ sourceIndex ];
3028
+ const URL = self.URL || self.webkitURL;
3029
+ let sourceURI = sourceDef.uri || '';
3030
+ let isObjectURL = false;
3031
+ if ( sourceDef.bufferView !== undefined ) {
3032
+
3033
+ // Load binary image data from bufferView, if provided.
3034
+
3035
+ sourceURI = parser.getDependency( 'bufferView', sourceDef.bufferView ).then( function ( bufferView ) {
3036
+
3037
+ isObjectURL = true;
3038
+ const blob = new Blob( [ bufferView ], {
3039
+ type: sourceDef.mimeType
3040
+ } );
3041
+ sourceURI = URL.createObjectURL( blob );
3042
+ return sourceURI;
3043
+
3044
+ } );
3045
+
3046
+ } else if ( sourceDef.uri === undefined ) {
3047
+
3048
+ throw new Error( 'THREE.GLTFLoader: Image ' + sourceIndex + ' is missing URI and bufferView' );
3049
+
3050
+ }
3051
+
3052
+ const promise = Promise.resolve( sourceURI ).then( function ( sourceURI ) {
3053
+
3054
+ return new Promise( function ( resolve, reject ) {
3055
+
3056
+ let onLoad = resolve;
3057
+ if ( loader.isImageBitmapLoader === true ) {
3058
+
3059
+ onLoad = function ( imageBitmap ) {
3060
+
3061
+ const texture = new THREE.Texture( imageBitmap );
3062
+ texture.needsUpdate = true;
3063
+ resolve( texture );
3064
+
3065
+ };
3066
+
3067
+ }
3068
+
3069
+ loader.load( THREE.LoaderUtils.resolveURL( sourceURI, options.path ), onLoad, undefined, reject );
3070
+
3071
+ } );
3072
+
3073
+ } ).then( function ( texture ) {
3074
+
3075
+ // Clean up resources and configure THREE.Texture.
3076
+
3077
+ if ( isObjectURL === true ) {
3078
+
3079
+ URL.revokeObjectURL( sourceURI );
3080
+
3081
+ }
3082
+
3083
+ texture.userData.mimeType = sourceDef.mimeType || getImageURIMimeType( sourceDef.uri );
3084
+ return texture;
3085
+
3086
+ } ).catch( function ( error ) {
3087
+
3088
+ console.error( 'THREE.GLTFLoader: Couldn\'t load texture', sourceURI );
3089
+ throw error;
3090
+
3091
+ } );
3092
+ this.sourceCache[ sourceIndex ] = promise;
3093
+ return promise;
3094
+
3095
+ }
3096
+
3097
+ /**
3098
+ * Asynchronously assigns a texture to the given material parameters.
3099
+ * @param {Object} materialParams
3100
+ * @param {string} mapName
3101
+ * @param {Object} mapDef
3102
+ * @return {Promise<Texture>}
3103
+ */
3104
+ assignTexture( materialParams, mapName, mapDef, encoding ) {
3105
+
3106
+ const parser = this;
3107
+ return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) {
3108
+
3109
+ if ( ! texture ) return null;
3110
+
3111
+ // Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured
3112
+ // However, we will copy UV set 0 to UV set 1 on demand for aoMap
3113
+ if ( mapDef.texCoord !== undefined && mapDef.texCoord != 0 && ! ( mapName === 'aoMap' && mapDef.texCoord == 1 ) ) {
3114
+
3115
+ console.warn( 'THREE.GLTFLoader: Custom UV set ' + mapDef.texCoord + ' for texture ' + mapName + ' not yet supported.' );
3116
+
3117
+ }
3118
+
3119
+ if ( parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] ) {
3120
+
3121
+ const transform = mapDef.extensions !== undefined ? mapDef.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ] : undefined;
3122
+ if ( transform ) {
3123
+
3124
+ const gltfReference = parser.associations.get( texture );
3125
+ texture = parser.extensions[ EXTENSIONS.KHR_TEXTURE_TRANSFORM ].extendTexture( texture, transform );
3126
+ parser.associations.set( texture, gltfReference );
3127
+
3128
+ }
3129
+
3130
+ }
3131
+
3132
+ if ( encoding !== undefined ) {
3133
+
3134
+ texture.encoding = encoding;
3135
+
3136
+ }
3137
+
3138
+ materialParams[ mapName ] = texture;
3139
+ return texture;
3140
+
3141
+ } );
3142
+
3143
+ }
3144
+
3145
+ /**
3146
+ * Assigns final material to a THREE.Mesh, THREE.Line, or THREE.Points instance. The instance
3147
+ * already has a material (generated from the glTF material options alone)
3148
+ * but reuse of the same glTF material may require multiple threejs materials
3149
+ * to accommodate different primitive types, defines, etc. New materials will
3150
+ * be created if necessary, and reused from a cache.
3151
+ * @param {Object3D} mesh THREE.Mesh, THREE.Line, or THREE.Points instance.
3152
+ */
3153
+ assignFinalMaterial( mesh ) {
3154
+
3155
+ const geometry = mesh.geometry;
3156
+ let material = mesh.material;
3157
+ const useDerivativeTangents = geometry.attributes.tangent === undefined;
3158
+ const useVertexColors = geometry.attributes.color !== undefined;
3159
+ const useFlatShading = geometry.attributes.normal === undefined;
3160
+ if ( mesh.isPoints ) {
3161
+
3162
+ const cacheKey = 'PointsMaterial:' + material.uuid;
3163
+ let pointsMaterial = this.cache.get( cacheKey );
3164
+ if ( ! pointsMaterial ) {
3165
+
3166
+ pointsMaterial = new THREE.PointsMaterial();
3167
+ THREE.Material.prototype.copy.call( pointsMaterial, material );
3168
+ pointsMaterial.color.copy( material.color );
3169
+ pointsMaterial.map = material.map;
3170
+ pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px
3171
+
3172
+ this.cache.add( cacheKey, pointsMaterial );
3173
+
3174
+ }
3175
+
3176
+ material = pointsMaterial;
3177
+
3178
+ } else if ( mesh.isLine ) {
3179
+
3180
+ const cacheKey = 'LineBasicMaterial:' + material.uuid;
3181
+ let lineMaterial = this.cache.get( cacheKey );
3182
+ if ( ! lineMaterial ) {
3183
+
3184
+ lineMaterial = new THREE.LineBasicMaterial();
3185
+ THREE.Material.prototype.copy.call( lineMaterial, material );
3186
+ lineMaterial.color.copy( material.color );
3187
+ this.cache.add( cacheKey, lineMaterial );
3188
+
3189
+ }
3190
+
3191
+ material = lineMaterial;
3192
+
3193
+ }
3194
+
3195
+ // Clone the material if it will be modified
3196
+ if ( useDerivativeTangents || useVertexColors || useFlatShading ) {
3197
+
3198
+ let cacheKey = 'ClonedMaterial:' + material.uuid + ':';
3199
+ if ( useDerivativeTangents ) cacheKey += 'derivative-tangents:';
3200
+ if ( useVertexColors ) cacheKey += 'vertex-colors:';
3201
+ if ( useFlatShading ) cacheKey += 'flat-shading:';
3202
+ let cachedMaterial = this.cache.get( cacheKey );
3203
+ if ( ! cachedMaterial ) {
3204
+
3205
+ cachedMaterial = material.clone();
3206
+ if ( useVertexColors ) cachedMaterial.vertexColors = true;
3207
+ if ( useFlatShading ) cachedMaterial.flatShading = true;
3208
+ if ( useDerivativeTangents ) {
3209
+
3210
+ // https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
3211
+ if ( cachedMaterial.normalScale ) cachedMaterial.normalScale.y *= - 1;
3212
+ if ( cachedMaterial.clearcoatNormalScale ) cachedMaterial.clearcoatNormalScale.y *= - 1;
3213
+
3214
+ }
3215
+
3216
+ this.cache.add( cacheKey, cachedMaterial );
3217
+ this.associations.set( cachedMaterial, this.associations.get( material ) );
3218
+
3219
+ }
3220
+
3221
+ material = cachedMaterial;
3222
+
3223
+ }
3224
+
3225
+ // workarounds for mesh and geometry
3226
+
3227
+ if ( material.aoMap && geometry.attributes.uv2 === undefined && geometry.attributes.uv !== undefined ) {
3228
+
3229
+ geometry.setAttribute( 'uv2', geometry.attributes.uv );
3230
+
3231
+ }
3232
+
3233
+ mesh.material = material;
3234
+
3235
+ }
3236
+ getMaterialType() {
3237
+
3238
+ return THREE.MeshStandardMaterial;
3239
+
3240
+ }
3241
+
3242
+ /**
3243
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
3244
+ * @param {number} materialIndex
3245
+ * @return {Promise<Material>}
3246
+ */
3247
+ loadMaterial( materialIndex ) {
3248
+
3249
+ const parser = this;
3250
+ const json = this.json;
3251
+ const extensions = this.extensions;
3252
+ const materialDef = json.materials[ materialIndex ];
3253
+ let materialType;
3254
+ const materialParams = {};
3255
+ const materialExtensions = materialDef.extensions || {};
3256
+ const pending = [];
3257
+ if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) {
3258
+
3259
+ const kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ];
3260
+ materialType = kmuExtension.getMaterialType();
3261
+ pending.push( kmuExtension.extendParams( materialParams, materialDef, parser ) );
3262
+
3263
+ } else {
3264
+
3265
+ // Specification:
3266
+ // https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#metallic-roughness-material
3267
+
3268
+ const metallicRoughness = materialDef.pbrMetallicRoughness || {};
3269
+ materialParams.color = new THREE.Color( 1.0, 1.0, 1.0 );
3270
+ materialParams.opacity = 1.0;
3271
+ if ( Array.isArray( metallicRoughness.baseColorFactor ) ) {
3272
+
3273
+ const array = metallicRoughness.baseColorFactor;
3274
+ materialParams.color.fromArray( array );
3275
+ materialParams.opacity = array[ 3 ];
3276
+
3277
+ }
3278
+
3279
+ if ( metallicRoughness.baseColorTexture !== undefined ) {
3280
+
3281
+ pending.push( parser.assignTexture( materialParams, 'map', metallicRoughness.baseColorTexture, THREE.sRGBEncoding ) );
3282
+
3283
+ }
3284
+
3285
+ materialParams.metalness = metallicRoughness.metallicFactor !== undefined ? metallicRoughness.metallicFactor : 1.0;
3286
+ materialParams.roughness = metallicRoughness.roughnessFactor !== undefined ? metallicRoughness.roughnessFactor : 1.0;
3287
+ if ( metallicRoughness.metallicRoughnessTexture !== undefined ) {
3288
+
3289
+ pending.push( parser.assignTexture( materialParams, 'metalnessMap', metallicRoughness.metallicRoughnessTexture ) );
3290
+ pending.push( parser.assignTexture( materialParams, 'roughnessMap', metallicRoughness.metallicRoughnessTexture ) );
3291
+
3292
+ }
3293
+
3294
+ materialType = this._invokeOne( function ( ext ) {
3295
+
3296
+ return ext.getMaterialType && ext.getMaterialType( materialIndex );
3297
+
3298
+ } );
3299
+ pending.push( Promise.all( this._invokeAll( function ( ext ) {
3300
+
3301
+ return ext.extendMaterialParams && ext.extendMaterialParams( materialIndex, materialParams );
3302
+
3303
+ } ) ) );
3304
+
3305
+ }
3306
+
3307
+ if ( materialDef.doubleSided === true ) {
3308
+
3309
+ materialParams.side = THREE.DoubleSide;
3310
+
3311
+ }
3312
+
3313
+ const alphaMode = materialDef.alphaMode || ALPHA_MODES.OPAQUE;
3314
+ if ( alphaMode === ALPHA_MODES.BLEND ) {
3315
+
3316
+ materialParams.transparent = true;
3317
+
3318
+ // See: https://github.com/mrdoob/three.js/issues/17706
3319
+ materialParams.depthWrite = false;
3320
+
3321
+ } else {
3322
+
3323
+ materialParams.transparent = false;
3324
+ if ( alphaMode === ALPHA_MODES.MASK ) {
3325
+
3326
+ materialParams.alphaTest = materialDef.alphaCutoff !== undefined ? materialDef.alphaCutoff : 0.5;
3327
+
3328
+ }
3329
+
3330
+ }
3331
+
3332
+ if ( materialDef.normalTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
3333
+
3334
+ pending.push( parser.assignTexture( materialParams, 'normalMap', materialDef.normalTexture ) );
3335
+ materialParams.normalScale = new THREE.Vector2( 1, 1 );
3336
+ if ( materialDef.normalTexture.scale !== undefined ) {
3337
+
3338
+ const scale = materialDef.normalTexture.scale;
3339
+ materialParams.normalScale.set( scale, scale );
3340
+
3341
+ }
3342
+
3343
+ }
3344
+
3345
+ if ( materialDef.occlusionTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
3346
+
3347
+ pending.push( parser.assignTexture( materialParams, 'aoMap', materialDef.occlusionTexture ) );
3348
+ if ( materialDef.occlusionTexture.strength !== undefined ) {
3349
+
3350
+ materialParams.aoMapIntensity = materialDef.occlusionTexture.strength;
3351
+
3352
+ }
3353
+
3354
+ }
3355
+
3356
+ if ( materialDef.emissiveFactor !== undefined && materialType !== THREE.MeshBasicMaterial ) {
3357
+
3358
+ materialParams.emissive = new THREE.Color().fromArray( materialDef.emissiveFactor );
3359
+
3360
+ }
3361
+
3362
+ if ( materialDef.emissiveTexture !== undefined && materialType !== THREE.MeshBasicMaterial ) {
3363
+
3364
+ pending.push( parser.assignTexture( materialParams, 'emissiveMap', materialDef.emissiveTexture, THREE.sRGBEncoding ) );
3365
+
3366
+ }
3367
+
3368
+ return Promise.all( pending ).then( function () {
3369
+
3370
+ const material = new materialType( materialParams );
3371
+ if ( materialDef.name ) material.name = materialDef.name;
3372
+ assignExtrasToUserData( material, materialDef );
3373
+ parser.associations.set( material, {
3374
+ materials: materialIndex
3375
+ } );
3376
+ if ( materialDef.extensions ) addUnknownExtensionsToUserData( extensions, material, materialDef );
3377
+ return material;
3378
+
3379
+ } );
3380
+
3381
+ }
3382
+
3383
+ /** When THREE.Object3D instances are targeted by animation, they need unique names. */
3384
+ createUniqueName( originalName ) {
3385
+
3386
+ const sanitizedName = THREE.PropertyBinding.sanitizeNodeName( originalName || '' );
3387
+ let name = sanitizedName;
3388
+ for ( let i = 1; this.nodeNamesUsed[ name ]; ++ i ) {
3389
+
3390
+ name = sanitizedName + '_' + i;
3391
+
3392
+ }
3393
+
3394
+ this.nodeNamesUsed[ name ] = true;
3395
+ return name;
3396
+
3397
+ }
3398
+
3399
+ /**
3400
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
3401
+ *
3402
+ * Creates BufferGeometries from primitives.
3403
+ *
3404
+ * @param {Array<GLTF.Primitive>} primitives
3405
+ * @return {Promise<Array<BufferGeometry>>}
3406
+ */
3407
+ loadGeometries( primitives ) {
3408
+
3409
+ const parser = this;
3410
+ const extensions = this.extensions;
3411
+ const cache = this.primitiveCache;
3412
+ function createDracoPrimitive( primitive ) {
3413
+
3414
+ return extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ].decodePrimitive( primitive, parser ).then( function ( geometry ) {
3415
+
3416
+ return addPrimitiveAttributes( geometry, primitive, parser );
3417
+
3418
+ } );
3419
+
3420
+ }
3421
+
3422
+ const pending = [];
3423
+ for ( let i = 0, il = primitives.length; i < il; i ++ ) {
3424
+
3425
+ const primitive = primitives[ i ];
3426
+ const cacheKey = createPrimitiveKey( primitive );
3427
+
3428
+ // See if we've already created this geometry
3429
+ const cached = cache[ cacheKey ];
3430
+ if ( cached ) {
3431
+
3432
+ // Use the cached geometry if it exists
3433
+ pending.push( cached.promise );
3434
+
3435
+ } else {
3436
+
3437
+ let geometryPromise;
3438
+ if ( primitive.extensions && primitive.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] ) {
3439
+
3440
+ // Use DRACO geometry if available
3441
+ geometryPromise = createDracoPrimitive( primitive );
3442
+
3443
+ } else {
3444
+
3445
+ // Otherwise create a new geometry
3446
+ geometryPromise = addPrimitiveAttributes( new THREE.BufferGeometry(), primitive, parser );
3447
+
3448
+ }
3449
+
3450
+ // Cache this geometry
3451
+ cache[ cacheKey ] = {
3452
+ primitive: primitive,
3453
+ promise: geometryPromise
3454
+ };
3455
+ pending.push( geometryPromise );
3456
+
3457
+ }
3458
+
3459
+ }
3460
+
3461
+ return Promise.all( pending );
3462
+
3463
+ }
3464
+
3465
+ /**
3466
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
3467
+ * @param {number} meshIndex
3468
+ * @return {Promise<Group|Mesh|SkinnedMesh>}
3469
+ */
3470
+ loadMesh( meshIndex ) {
3471
+
3472
+ const parser = this;
3473
+ const json = this.json;
3474
+ const extensions = this.extensions;
3475
+ const meshDef = json.meshes[ meshIndex ];
3476
+ const primitives = meshDef.primitives;
3477
+ const pending = [];
3478
+ for ( let i = 0, il = primitives.length; i < il; i ++ ) {
3479
+
3480
+ const material = primitives[ i ].material === undefined ? createDefaultMaterial( this.cache ) : this.getDependency( 'material', primitives[ i ].material );
3481
+ pending.push( material );
3482
+
3483
+ }
3484
+
3485
+ pending.push( parser.loadGeometries( primitives ) );
3486
+ return Promise.all( pending ).then( function ( results ) {
3487
+
3488
+ const materials = results.slice( 0, results.length - 1 );
3489
+ const geometries = results[ results.length - 1 ];
3490
+ const meshes = [];
3491
+ for ( let i = 0, il = geometries.length; i < il; i ++ ) {
3492
+
3493
+ const geometry = geometries[ i ];
3494
+ const primitive = primitives[ i ];
3495
+
3496
+ // 1. create THREE.Mesh
3497
+
3498
+ let mesh;
3499
+ const material = materials[ i ];
3500
+ if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP || primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN || primitive.mode === undefined ) {
3501
+
3502
+ // .isSkinnedMesh isn't in glTF spec. See ._markDefs()
3503
+ mesh = meshDef.isSkinnedMesh === true ? new THREE.SkinnedMesh( geometry, material ) : new THREE.Mesh( geometry, material );
3504
+ if ( mesh.isSkinnedMesh === true && ! mesh.geometry.attributes.skinWeight.normalized ) {
3505
+
3506
+ // we normalize floating point skin weight array to fix malformed assets (see #15319)
3507
+ // it's important to skip this for non-float32 data since normalizeSkinWeights assumes non-normalized inputs
3508
+ mesh.normalizeSkinWeights();
3509
+
3510
+ }
3511
+
3512
+ if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_STRIP ) {
3513
+
3514
+ mesh.geometry = toTrianglesDrawMode( mesh.geometry, THREE.TriangleStripDrawMode );
3515
+
3516
+ } else if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLE_FAN ) {
3517
+
3518
+ mesh.geometry = toTrianglesDrawMode( mesh.geometry, THREE.TriangleFanDrawMode );
3519
+
3520
+ }
3521
+
3522
+ } else if ( primitive.mode === WEBGL_CONSTANTS.LINES ) {
3523
+
3524
+ mesh = new THREE.LineSegments( geometry, material );
3525
+
3526
+ } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_STRIP ) {
3527
+
3528
+ mesh = new THREE.Line( geometry, material );
3529
+
3530
+ } else if ( primitive.mode === WEBGL_CONSTANTS.LINE_LOOP ) {
3531
+
3532
+ mesh = new THREE.LineLoop( geometry, material );
3533
+
3534
+ } else if ( primitive.mode === WEBGL_CONSTANTS.POINTS ) {
3535
+
3536
+ mesh = new THREE.Points( geometry, material );
3537
+
3538
+ } else {
3539
+
3540
+ throw new Error( 'THREE.GLTFLoader: Primitive mode unsupported: ' + primitive.mode );
3541
+
3542
+ }
3543
+
3544
+ if ( Object.keys( mesh.geometry.morphAttributes ).length > 0 ) {
3545
+
3546
+ updateMorphTargets( mesh, meshDef );
3547
+
3548
+ }
3549
+
3550
+ mesh.name = parser.createUniqueName( meshDef.name || 'mesh_' + meshIndex );
3551
+ assignExtrasToUserData( mesh, meshDef );
3552
+ if ( primitive.extensions ) addUnknownExtensionsToUserData( extensions, mesh, primitive );
3553
+ parser.assignFinalMaterial( mesh );
3554
+ meshes.push( mesh );
3555
+
3556
+ }
3557
+
3558
+ for ( let i = 0, il = meshes.length; i < il; i ++ ) {
3559
+
3560
+ parser.associations.set( meshes[ i ], {
3561
+ meshes: meshIndex,
3562
+ primitives: i
3563
+ } );
3564
+
3565
+ }
3566
+
3567
+ if ( meshes.length === 1 ) {
3568
+
3569
+ return meshes[ 0 ];
3570
+
3571
+ }
3572
+
3573
+ const group = new THREE.Group();
3574
+ parser.associations.set( group, {
3575
+ meshes: meshIndex
3576
+ } );
3577
+ for ( let i = 0, il = meshes.length; i < il; i ++ ) {
3578
+
3579
+ group.add( meshes[ i ] );
3580
+
3581
+ }
3582
+
3583
+ return group;
3584
+
3585
+ } );
3586
+
3587
+ }
3588
+
3589
+ /**
3590
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
3591
+ * @param {number} cameraIndex
3592
+ * @return {Promise<THREE.Camera>}
3593
+ */
3594
+ loadCamera( cameraIndex ) {
3595
+
3596
+ let camera;
3597
+ const cameraDef = this.json.cameras[ cameraIndex ];
3598
+ const params = cameraDef[ cameraDef.type ];
3599
+ if ( ! params ) {
3600
+
3601
+ console.warn( 'THREE.GLTFLoader: Missing camera parameters.' );
3602
+ return;
3603
+
3604
+ }
3605
+
3606
+ if ( cameraDef.type === 'perspective' ) {
3607
+
3608
+ camera = new THREE.PerspectiveCamera( THREE.MathUtils.radToDeg( params.yfov ), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6 );
3609
+
3610
+ } else if ( cameraDef.type === 'orthographic' ) {
3611
+
3612
+ camera = new THREE.OrthographicCamera( - params.xmag, params.xmag, params.ymag, - params.ymag, params.znear, params.zfar );
3613
+
3614
+ }
3615
+
3616
+ if ( cameraDef.name ) camera.name = this.createUniqueName( cameraDef.name );
3617
+ assignExtrasToUserData( camera, cameraDef );
3618
+ return Promise.resolve( camera );
3619
+
3620
+ }
3621
+
3622
+ /**
3623
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
3624
+ * @param {number} skinIndex
3625
+ * @return {Promise<Skeleton>}
3626
+ */
3627
+ loadSkin( skinIndex ) {
3628
+
3629
+ const skinDef = this.json.skins[ skinIndex ];
3630
+ const pending = [];
3631
+ for ( let i = 0, il = skinDef.joints.length; i < il; i ++ ) {
3632
+
3633
+ pending.push( this.getDependency( 'node', skinDef.joints[ i ] ) );
3634
+
3635
+ }
3636
+
3637
+ if ( skinDef.inverseBindMatrices !== undefined ) {
3638
+
3639
+ pending.push( this.getDependency( 'accessor', skinDef.inverseBindMatrices ) );
3640
+
3641
+ } else {
3642
+
3643
+ pending.push( null );
3644
+
3645
+ }
3646
+
3647
+ return Promise.all( pending ).then( function ( results ) {
3648
+
3649
+ const inverseBindMatrices = results.pop();
3650
+ const jointNodes = results;
3651
+ const bones = [];
3652
+ const boneInverses = [];
3653
+ for ( let i = 0, il = jointNodes.length; i < il; i ++ ) {
3654
+
3655
+ const jointNode = jointNodes[ i ];
3656
+ if ( jointNode ) {
3657
+
3658
+ bones.push( jointNode );
3659
+ const mat = new THREE.Matrix4();
3660
+ if ( inverseBindMatrices !== null ) {
3661
+
3662
+ mat.fromArray( inverseBindMatrices.array, i * 16 );
3663
+
3664
+ }
3665
+
3666
+ boneInverses.push( mat );
3667
+
3668
+ } else {
3669
+
3670
+ console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinDef.joints[ i ] );
3671
+
3672
+ }
3673
+
3674
+ }
3675
+
3676
+ return new THREE.Skeleton( bones, boneInverses );
3677
+
3678
+ } );
3679
+
3680
+ }
3681
+
3682
+ /**
3683
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
3684
+ * @param {number} animationIndex
3685
+ * @return {Promise<AnimationClip>}
3686
+ */
3687
+ loadAnimation( animationIndex ) {
3688
+
3689
+ const json = this.json;
3690
+ const animationDef = json.animations[ animationIndex ];
3691
+ const pendingNodes = [];
3692
+ const pendingInputAccessors = [];
3693
+ const pendingOutputAccessors = [];
3694
+ const pendingSamplers = [];
3695
+ const pendingTargets = [];
3696
+ for ( let i = 0, il = animationDef.channels.length; i < il; i ++ ) {
3697
+
3698
+ const channel = animationDef.channels[ i ];
3699
+ const sampler = animationDef.samplers[ channel.sampler ];
3700
+ const target = channel.target;
3701
+ const name = target.node;
3702
+ const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input;
3703
+ const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output;
3704
+ pendingNodes.push( this.getDependency( 'node', name ) );
3705
+ pendingInputAccessors.push( this.getDependency( 'accessor', input ) );
3706
+ pendingOutputAccessors.push( this.getDependency( 'accessor', output ) );
3707
+ pendingSamplers.push( sampler );
3708
+ pendingTargets.push( target );
3709
+
3710
+ }
3711
+
3712
+ return Promise.all( [ Promise.all( pendingNodes ), Promise.all( pendingInputAccessors ), Promise.all( pendingOutputAccessors ), Promise.all( pendingSamplers ), Promise.all( pendingTargets ) ] ).then( function ( dependencies ) {
3713
+
3714
+ const nodes = dependencies[ 0 ];
3715
+ const inputAccessors = dependencies[ 1 ];
3716
+ const outputAccessors = dependencies[ 2 ];
3717
+ const samplers = dependencies[ 3 ];
3718
+ const targets = dependencies[ 4 ];
3719
+ const tracks = [];
3720
+ for ( let i = 0, il = nodes.length; i < il; i ++ ) {
3721
+
3722
+ const node = nodes[ i ];
3723
+ const inputAccessor = inputAccessors[ i ];
3724
+ const outputAccessor = outputAccessors[ i ];
3725
+ const sampler = samplers[ i ];
3726
+ const target = targets[ i ];
3727
+ if ( node === undefined ) continue;
3728
+ node.updateMatrix();
3729
+ let TypedKeyframeTrack;
3730
+ switch ( PATH_PROPERTIES[ target.path ] ) {
3731
+
3732
+ case PATH_PROPERTIES.weights:
3733
+ TypedKeyframeTrack = THREE.NumberKeyframeTrack;
3734
+ break;
3735
+ case PATH_PROPERTIES.rotation:
3736
+ TypedKeyframeTrack = THREE.QuaternionKeyframeTrack;
3737
+ break;
3738
+ case PATH_PROPERTIES.position:
3739
+ case PATH_PROPERTIES.scale:
3740
+ default:
3741
+ TypedKeyframeTrack = THREE.VectorKeyframeTrack;
3742
+ break;
3743
+
3744
+ }
3745
+
3746
+ const targetName = node.name ? node.name : node.uuid;
3747
+ const interpolation = sampler.interpolation !== undefined ? INTERPOLATION[ sampler.interpolation ] : THREE.InterpolateLinear;
3748
+ const targetNames = [];
3749
+ if ( PATH_PROPERTIES[ target.path ] === PATH_PROPERTIES.weights ) {
3750
+
3751
+ node.traverse( function ( object ) {
3752
+
3753
+ if ( object.morphTargetInfluences ) {
3754
+
3755
+ targetNames.push( object.name ? object.name : object.uuid );
3756
+
3757
+ }
3758
+
3759
+ } );
3760
+
3761
+ } else {
3762
+
3763
+ targetNames.push( targetName );
3764
+
3765
+ }
3766
+
3767
+ let outputArray = outputAccessor.array;
3768
+ if ( outputAccessor.normalized ) {
3769
+
3770
+ const scale = getNormalizedComponentScale( outputArray.constructor );
3771
+ const scaled = new Float32Array( outputArray.length );
3772
+ for ( let j = 0, jl = outputArray.length; j < jl; j ++ ) {
3773
+
3774
+ scaled[ j ] = outputArray[ j ] * scale;
3775
+
3776
+ }
3777
+
3778
+ outputArray = scaled;
3779
+
3780
+ }
3781
+
3782
+ for ( let j = 0, jl = targetNames.length; j < jl; j ++ ) {
3783
+
3784
+ const track = new TypedKeyframeTrack( targetNames[ j ] + '.' + PATH_PROPERTIES[ target.path ], inputAccessor.array, outputArray, interpolation );
3785
+
3786
+ // Override interpolation with custom factory method.
3787
+ if ( sampler.interpolation === 'CUBICSPLINE' ) {
3788
+
3789
+ track.createInterpolant = function InterpolantFactoryMethodGLTFCubicSpline( result ) {
3790
+
3791
+ // A CUBICSPLINE keyframe in glTF has three output values for each input value,
3792
+ // representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
3793
+ // must be divided by three to get the interpolant's sampleSize argument.
3794
+
3795
+ const interpolantType = this instanceof THREE.QuaternionKeyframeTrack ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
3796
+ return new interpolantType( this.times, this.values, this.getValueSize() / 3, result );
3797
+
3798
+ };
3799
+
3800
+ // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
3801
+ track.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = true;
3802
+
3803
+ }
3804
+
3805
+ tracks.push( track );
3806
+
3807
+ }
3808
+
3809
+ }
3810
+
3811
+ const name = animationDef.name ? animationDef.name : 'animation_' + animationIndex;
3812
+ return new THREE.AnimationClip( name, undefined, tracks );
3813
+
3814
+ } );
3815
+
3816
+ }
3817
+ createNodeMesh( nodeIndex ) {
3818
+
3819
+ const json = this.json;
3820
+ const parser = this;
3821
+ const nodeDef = json.nodes[ nodeIndex ];
3822
+ if ( nodeDef.mesh === undefined ) return null;
3823
+ return parser.getDependency( 'mesh', nodeDef.mesh ).then( function ( mesh ) {
3824
+
3825
+ const node = parser._getNodeRef( parser.meshCache, nodeDef.mesh, mesh );
3826
+
3827
+ // if weights are provided on the node, override weights on the mesh.
3828
+ if ( nodeDef.weights !== undefined ) {
3829
+
3830
+ node.traverse( function ( o ) {
3831
+
3832
+ if ( ! o.isMesh ) return;
3833
+ for ( let i = 0, il = nodeDef.weights.length; i < il; i ++ ) {
3834
+
3835
+ o.morphTargetInfluences[ i ] = nodeDef.weights[ i ];
3836
+
3837
+ }
3838
+
3839
+ } );
3840
+
3841
+ }
3842
+
3843
+ return node;
3844
+
3845
+ } );
3846
+
3847
+ }
3848
+
3849
+ /**
3850
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
3851
+ * @param {number} nodeIndex
3852
+ * @return {Promise<Object3D>}
3853
+ */
3854
+ loadNode( nodeIndex ) {
3855
+
3856
+ const json = this.json;
3857
+ const extensions = this.extensions;
3858
+ const parser = this;
3859
+ const nodeDef = json.nodes[ nodeIndex ];
3860
+
3861
+ // reserve node's name before its dependencies, so the root has the intended name.
3862
+ const nodeName = nodeDef.name ? parser.createUniqueName( nodeDef.name ) : '';
3863
+ return function () {
3864
+
3865
+ const pending = [];
3866
+ const meshPromise = parser._invokeOne( function ( ext ) {
3867
+
3868
+ return ext.createNodeMesh && ext.createNodeMesh( nodeIndex );
3869
+
3870
+ } );
3871
+ if ( meshPromise ) {
3872
+
3873
+ pending.push( meshPromise );
3874
+
3875
+ }
3876
+
3877
+ if ( nodeDef.camera !== undefined ) {
3878
+
3879
+ pending.push( parser.getDependency( 'camera', nodeDef.camera ).then( function ( camera ) {
3880
+
3881
+ return parser._getNodeRef( parser.cameraCache, nodeDef.camera, camera );
3882
+
3883
+ } ) );
3884
+
3885
+ }
3886
+
3887
+ parser._invokeAll( function ( ext ) {
3888
+
3889
+ return ext.createNodeAttachment && ext.createNodeAttachment( nodeIndex );
3890
+
3891
+ } ).forEach( function ( promise ) {
3892
+
3893
+ pending.push( promise );
3894
+
3895
+ } );
3896
+ return Promise.all( pending );
3897
+
3898
+ }().then( function ( objects ) {
3899
+
3900
+ let node;
3901
+
3902
+ // .isBone isn't in glTF spec. See ._markDefs
3903
+ if ( nodeDef.isBone === true ) {
3904
+
3905
+ node = new THREE.Bone();
3906
+
3907
+ } else if ( objects.length > 1 ) {
3908
+
3909
+ node = new THREE.Group();
3910
+
3911
+ } else if ( objects.length === 1 ) {
3912
+
3913
+ node = objects[ 0 ];
3914
+
3915
+ } else {
3916
+
3917
+ node = new THREE.Object3D();
3918
+
3919
+ }
3920
+
3921
+ if ( node !== objects[ 0 ] ) {
3922
+
3923
+ for ( let i = 0, il = objects.length; i < il; i ++ ) {
3924
+
3925
+ node.add( objects[ i ] );
3926
+
3927
+ }
3928
+
3929
+ }
3930
+
3931
+ if ( nodeDef.name ) {
3932
+
3933
+ node.userData.name = nodeDef.name;
3934
+ node.name = nodeName;
3935
+
3936
+ }
3937
+
3938
+ assignExtrasToUserData( node, nodeDef );
3939
+ if ( nodeDef.extensions ) addUnknownExtensionsToUserData( extensions, node, nodeDef );
3940
+ if ( nodeDef.matrix !== undefined ) {
3941
+
3942
+ const matrix = new THREE.Matrix4();
3943
+ matrix.fromArray( nodeDef.matrix );
3944
+ node.applyMatrix4( matrix );
3945
+
3946
+ } else {
3947
+
3948
+ if ( nodeDef.translation !== undefined ) {
3949
+
3950
+ node.position.fromArray( nodeDef.translation );
3951
+
3952
+ }
3953
+
3954
+ if ( nodeDef.rotation !== undefined ) {
3955
+
3956
+ node.quaternion.fromArray( nodeDef.rotation );
3957
+
3958
+ }
3959
+
3960
+ if ( nodeDef.scale !== undefined ) {
3961
+
3962
+ node.scale.fromArray( nodeDef.scale );
3963
+
3964
+ }
3965
+
3966
+ }
3967
+
3968
+ if ( ! parser.associations.has( node ) ) {
3969
+
3970
+ parser.associations.set( node, {} );
3971
+
3972
+ }
3973
+
3974
+ parser.associations.get( node ).nodes = nodeIndex;
3975
+ return node;
3976
+
3977
+ } );
3978
+
3979
+ }
3980
+
3981
+ /**
3982
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
3983
+ * @param {number} sceneIndex
3984
+ * @return {Promise<Group>}
3985
+ */
3986
+ loadScene( sceneIndex ) {
3987
+
3988
+ const json = this.json;
3989
+ const extensions = this.extensions;
3990
+ const sceneDef = this.json.scenes[ sceneIndex ];
3991
+ const parser = this;
3992
+
3993
+ // THREE.Loader returns THREE.Group, not Scene.
3994
+ // See: https://github.com/mrdoob/three.js/issues/18342#issuecomment-578981172
3995
+ const scene = new THREE.Group();
3996
+ if ( sceneDef.name ) scene.name = parser.createUniqueName( sceneDef.name );
3997
+ assignExtrasToUserData( scene, sceneDef );
3998
+ if ( sceneDef.extensions ) addUnknownExtensionsToUserData( extensions, scene, sceneDef );
3999
+ const nodeIds = sceneDef.nodes || [];
4000
+ const pending = [];
4001
+ for ( let i = 0, il = nodeIds.length; i < il; i ++ ) {
4002
+
4003
+ pending.push( buildNodeHierarchy( nodeIds[ i ], scene, json, parser ) );
4004
+
4005
+ }
4006
+
4007
+ return Promise.all( pending ).then( function () {
4008
+
4009
+ // Removes dangling associations, associations that reference a node that
4010
+ // didn't make it into the scene.
4011
+ const reduceAssociations = node => {
4012
+
4013
+ const reducedAssociations = new Map();
4014
+ for ( const [ key, value ] of parser.associations ) {
4015
+
4016
+ if ( key instanceof THREE.Material || key instanceof THREE.Texture ) {
4017
+
4018
+ reducedAssociations.set( key, value );
4019
+
4020
+ }
4021
+
4022
+ }
4023
+
4024
+ node.traverse( node => {
4025
+
4026
+ const mappings = parser.associations.get( node );
4027
+ if ( mappings != null ) {
4028
+
4029
+ reducedAssociations.set( node, mappings );
4030
+
4031
+ }
4032
+
4033
+ } );
4034
+ return reducedAssociations;
4035
+
4036
+ };
4037
+
4038
+ parser.associations = reduceAssociations( scene );
4039
+ return scene;
4040
+
4041
+ } );
4042
+
4043
+ }
4044
+
4045
+ }
4046
+ function buildNodeHierarchy( nodeId, parentObject, json, parser ) {
4047
+
4048
+ const nodeDef = json.nodes[ nodeId ];
4049
+ return parser.getDependency( 'node', nodeId ).then( function ( node ) {
4050
+
4051
+ if ( nodeDef.skin === undefined ) return node;
4052
+
4053
+ // build skeleton here as well
4054
+
4055
+ return parser.getDependency( 'skin', nodeDef.skin ).then( function ( skeleton ) {
4056
+
4057
+ node.traverse( function ( mesh ) {
4058
+
4059
+ if ( ! mesh.isSkinnedMesh ) return;
4060
+ mesh.bind( skeleton, mesh.matrixWorld );
4061
+
4062
+ } );
4063
+ return node;
4064
+
4065
+ } );
4066
+
4067
+ } ).then( function ( node ) {
4068
+
4069
+ // build node hierachy
4070
+
4071
+ parentObject.add( node );
4072
+ const pending = [];
4073
+ if ( nodeDef.children ) {
4074
+
4075
+ const children = nodeDef.children;
4076
+ for ( let i = 0, il = children.length; i < il; i ++ ) {
4077
+
4078
+ const child = children[ i ];
4079
+ pending.push( buildNodeHierarchy( child, node, json, parser ) );
4080
+
4081
+ }
4082
+
4083
+ }
4084
+
4085
+ return Promise.all( pending );
4086
+
4087
+ } );
4088
+
4089
+ }
4090
+
4091
+ /**
4092
+ * @param {BufferGeometry} geometry
4093
+ * @param {GLTF.Primitive} primitiveDef
4094
+ * @param {GLTFParser} parser
4095
+ */
4096
+ function computeBounds( geometry, primitiveDef, parser ) {
4097
+
4098
+ const attributes = primitiveDef.attributes;
4099
+ const box = new THREE.Box3();
4100
+ if ( attributes.POSITION !== undefined ) {
4101
+
4102
+ const accessor = parser.json.accessors[ attributes.POSITION ];
4103
+ const min = accessor.min;
4104
+ const max = accessor.max;
4105
+
4106
+ // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
4107
+
4108
+ if ( min !== undefined && max !== undefined ) {
4109
+
4110
+ box.set( new THREE.Vector3( min[ 0 ], min[ 1 ], min[ 2 ] ), new THREE.Vector3( max[ 0 ], max[ 1 ], max[ 2 ] ) );
4111
+ if ( accessor.normalized ) {
4112
+
4113
+ const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] );
4114
+ box.min.multiplyScalar( boxScale );
4115
+ box.max.multiplyScalar( boxScale );
4116
+
4117
+ }
4118
+
4119
+ } else {
4120
+
4121
+ console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' );
4122
+ return;
4123
+
4124
+ }
4125
+
4126
+ } else {
4127
+
4128
+ return;
4129
+
4130
+ }
4131
+
4132
+ const targets = primitiveDef.targets;
4133
+ if ( targets !== undefined ) {
4134
+
4135
+ const maxDisplacement = new THREE.Vector3();
4136
+ const vector = new THREE.Vector3();
4137
+ for ( let i = 0, il = targets.length; i < il; i ++ ) {
4138
+
4139
+ const target = targets[ i ];
4140
+ if ( target.POSITION !== undefined ) {
4141
+
4142
+ const accessor = parser.json.accessors[ target.POSITION ];
4143
+ const min = accessor.min;
4144
+ const max = accessor.max;
4145
+
4146
+ // glTF requires 'min' and 'max', but VRM (which extends glTF) currently ignores that requirement.
4147
+
4148
+ if ( min !== undefined && max !== undefined ) {
4149
+
4150
+ // we need to get max of absolute components because target weight is [-1,1]
4151
+ vector.setX( Math.max( Math.abs( min[ 0 ] ), Math.abs( max[ 0 ] ) ) );
4152
+ vector.setY( Math.max( Math.abs( min[ 1 ] ), Math.abs( max[ 1 ] ) ) );
4153
+ vector.setZ( Math.max( Math.abs( min[ 2 ] ), Math.abs( max[ 2 ] ) ) );
4154
+ if ( accessor.normalized ) {
4155
+
4156
+ const boxScale = getNormalizedComponentScale( WEBGL_COMPONENT_TYPES[ accessor.componentType ] );
4157
+ vector.multiplyScalar( boxScale );
4158
+
4159
+ }
4160
+
4161
+ // Note: this assumes that the sum of all weights is at most 1. This isn't quite correct - it's more conservative
4162
+ // to assume that each target can have a max weight of 1. However, for some use cases - notably, when morph targets
4163
+ // are used to implement key-frame animations and as such only two are active at a time - this results in very large
4164
+ // boxes. So for now we make a box that's sometimes a touch too small but is hopefully mostly of reasonable size.
4165
+ maxDisplacement.max( vector );
4166
+
4167
+ } else {
4168
+
4169
+ console.warn( 'THREE.GLTFLoader: Missing min/max properties for accessor POSITION.' );
4170
+
4171
+ }
4172
+
4173
+ }
4174
+
4175
+ }
4176
+
4177
+ // As per comment above this box isn't conservative, but has a reasonable size for a very large number of morph targets.
4178
+ box.expandByVector( maxDisplacement );
4179
+
4180
+ }
4181
+
4182
+ geometry.boundingBox = box;
4183
+ const sphere = new THREE.Sphere();
4184
+ box.getCenter( sphere.center );
4185
+ sphere.radius = box.min.distanceTo( box.max ) / 2;
4186
+ geometry.boundingSphere = sphere;
4187
+
4188
+ }
4189
+
4190
+ /**
4191
+ * @param {BufferGeometry} geometry
4192
+ * @param {GLTF.Primitive} primitiveDef
4193
+ * @param {GLTFParser} parser
4194
+ * @return {Promise<BufferGeometry>}
4195
+ */
4196
+ function addPrimitiveAttributes( geometry, primitiveDef, parser ) {
4197
+
4198
+ const attributes = primitiveDef.attributes;
4199
+ const pending = [];
4200
+ function assignAttributeAccessor( accessorIndex, attributeName ) {
4201
+
4202
+ return parser.getDependency( 'accessor', accessorIndex ).then( function ( accessor ) {
4203
+
4204
+ geometry.setAttribute( attributeName, accessor );
4205
+
4206
+ } );
4207
+
4208
+ }
4209
+
4210
+ for ( const gltfAttributeName in attributes ) {
4211
+
4212
+ const threeAttributeName = ATTRIBUTES[ gltfAttributeName ] || gltfAttributeName.toLowerCase();
4213
+
4214
+ // Skip attributes already provided by e.g. Draco extension.
4215
+ if ( threeAttributeName in geometry.attributes ) continue;
4216
+ pending.push( assignAttributeAccessor( attributes[ gltfAttributeName ], threeAttributeName ) );
4217
+
4218
+ }
4219
+
4220
+ if ( primitiveDef.indices !== undefined && ! geometry.index ) {
4221
+
4222
+ const accessor = parser.getDependency( 'accessor', primitiveDef.indices ).then( function ( accessor ) {
4223
+
4224
+ geometry.setIndex( accessor );
4225
+
4226
+ } );
4227
+ pending.push( accessor );
4228
+
4229
+ }
4230
+
4231
+ assignExtrasToUserData( geometry, primitiveDef );
4232
+ computeBounds( geometry, primitiveDef, parser );
4233
+ return Promise.all( pending ).then( function () {
4234
+
4235
+ return primitiveDef.targets !== undefined ? addMorphTargets( geometry, primitiveDef.targets, parser ) : geometry;
4236
+
4237
+ } );
4238
+
4239
+ }
4240
+
4241
+ /**
4242
+ * @param {BufferGeometry} geometry
4243
+ * @param {Number} drawMode
4244
+ * @return {BufferGeometry}
4245
+ */
4246
+ function toTrianglesDrawMode( geometry, drawMode ) {
4247
+
4248
+ let index = geometry.getIndex();
4249
+
4250
+ // generate index if not present
4251
+
4252
+ if ( index === null ) {
4253
+
4254
+ const indices = [];
4255
+ const position = geometry.getAttribute( 'position' );
4256
+ if ( position !== undefined ) {
4257
+
4258
+ for ( let i = 0; i < position.count; i ++ ) {
4259
+
4260
+ indices.push( i );
4261
+
4262
+ }
4263
+
4264
+ geometry.setIndex( indices );
4265
+ index = geometry.getIndex();
4266
+
4267
+ } else {
4268
+
4269
+ console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' );
4270
+ return geometry;
4271
+
4272
+ }
4273
+
4274
+ }
4275
+
4276
+ //
4277
+
4278
+ const numberOfTriangles = index.count - 2;
4279
+ const newIndices = [];
4280
+ if ( drawMode === THREE.TriangleFanDrawMode ) {
4281
+
4282
+ // gl.TRIANGLE_FAN
4283
+
4284
+ for ( let i = 1; i <= numberOfTriangles; i ++ ) {
4285
+
4286
+ newIndices.push( index.getX( 0 ) );
4287
+ newIndices.push( index.getX( i ) );
4288
+ newIndices.push( index.getX( i + 1 ) );
4289
+
4290
+ }
4291
+
4292
+ } else {
4293
+
4294
+ // gl.TRIANGLE_STRIP
4295
+
4296
+ for ( let i = 0; i < numberOfTriangles; i ++ ) {
4297
+
4298
+ if ( i % 2 === 0 ) {
4299
+
4300
+ newIndices.push( index.getX( i ) );
4301
+ newIndices.push( index.getX( i + 1 ) );
4302
+ newIndices.push( index.getX( i + 2 ) );
4303
+
4304
+ } else {
4305
+
4306
+ newIndices.push( index.getX( i + 2 ) );
4307
+ newIndices.push( index.getX( i + 1 ) );
4308
+ newIndices.push( index.getX( i ) );
4309
+
4310
+ }
4311
+
4312
+ }
4313
+
4314
+ }
4315
+
4316
+ if ( newIndices.length / 3 !== numberOfTriangles ) {
4317
+
4318
+ console.error( 'THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' );
4319
+
4320
+ }
4321
+
4322
+ // build final geometry
4323
+
4324
+ const newGeometry = geometry.clone();
4325
+ newGeometry.setIndex( newIndices );
4326
+ return newGeometry;
4327
+
4328
+ }
4329
+
4330
+ THREE.GLTFLoader = GLTFLoader;
4331
+
4332
+ } )();
4333
+
4334
+ </script><script>
4335
+ (async function () {
4336
+
4337
+ var RoomEnvironment = THREE.RoomEnvironment;
4338
+ var GLTFLoader = THREE.GLTFLoader;
4339
+
4340
+ const host = window.__productTurntable;
4341
+ const V = host.vars;
4342
+ const hex = (v, fallback) => (/^#[0-9a-f]{6}$/i.test(String(v)) ? String(v) : fallback);
4343
+ const turns = Math.max(1, Math.min(4, Math.round(Number(V.turns) || 1)));
4344
+
4345
+ const renderer = new THREE.WebGLRenderer({
4346
+ canvas: document.getElementById("pt-canvas"),
4347
+ antialias: true,
4348
+ alpha: true,
4349
+ preserveDrawingBuffer: true,
4350
+ });
4351
+ renderer.setPixelRatio(1);
4352
+ renderer.setSize(1920, 1080, false);
4353
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
4354
+ renderer.toneMapping = THREE.ACESFilmicToneMapping;
4355
+ renderer.toneMappingExposure = 1.3;
4356
+
4357
+ const scene = new THREE.Scene();
4358
+ const pmrem = new THREE.PMREMGenerator(renderer);
4359
+ // Studio: two tall softbox strips (key 35 deg left, rim 120 deg right at 1.6x) over a dimmed room fill.
4360
+ const studio = new THREE.Scene();
4361
+ const room = new RoomEnvironment();
4362
+ room.traverse((o) => {
4363
+ if (o.isLight) o.intensity *= 0.3;
4364
+ if (o.material && o.material.emissiveIntensity) o.material.emissiveIntensity *= 0.3;
4365
+ });
4366
+ studio.add(room);
4367
+ for (const [deg, intensity] of [
4368
+ [-35, 5],
4369
+ [120, 8],
4370
+ ]) {
4371
+ const strip = new THREE.Mesh(
4372
+ new THREE.PlaneGeometry(1.2, 8),
4373
+ new THREE.MeshLambertMaterial({
4374
+ color: 0x000000,
4375
+ emissive: 0xffffff,
4376
+ emissiveIntensity: intensity,
4377
+ side: THREE.DoubleSide,
4378
+ }),
4379
+ );
4380
+ const a = THREE.MathUtils.degToRad(deg);
4381
+ strip.position.set(6 * Math.sin(a), 1, 6 * Math.cos(a));
4382
+ strip.lookAt(0, 1, 0);
4383
+ studio.add(strip);
4384
+ }
4385
+ scene.environment = pmrem.fromScene(studio, 0.02).texture;
4386
+
4387
+ // Can and plinth vertically centred, about 140 px clear above and below.
4388
+ const camera = new THREE.PerspectiveCamera(24, 1920 / 1080, 0.1, 100);
4389
+ camera.position.set(0, 2.1, 9.4);
4390
+ camera.lookAt(0, 0.9, 0);
4391
+
4392
+ const key = new THREE.DirectionalLight(0xffffff, 1.6);
4393
+ key.position.set(-3.5, 5, 4);
4394
+ scene.add(key);
4395
+ const rim = new THREE.DirectionalLight(0xfff1dc, 2.2);
4396
+ rim.position.set(4, 3, -4);
4397
+ scene.add(rim);
4398
+
4399
+ // Plinth with a soft baked contact shadow: no shadow maps, no per-frame cost.
4400
+ const plinth = new THREE.Mesh(
4401
+ new THREE.CylinderGeometry(1.42, 1.46, 0.2, 96),
4402
+ new THREE.MeshStandardMaterial({ color: 0xf4f1ec, roughness: 0.55, metalness: 0 }),
4403
+ );
4404
+ plinth.position.y = -0.1;
4405
+ scene.add(plinth);
4406
+
4407
+ function radialTexture(inner, outer) {
4408
+ const c = document.createElement("canvas");
4409
+ c.width = c.height = 256;
4410
+ const g = c.getContext("2d");
4411
+ const grad = g.createRadialGradient(128, 128, 0, 128, 128, 128);
4412
+ grad.addColorStop(0, inner);
4413
+ grad.addColorStop(1, outer);
4414
+ g.fillStyle = grad;
4415
+ g.fillRect(0, 0, 256, 256);
4416
+ const tex = new THREE.CanvasTexture(c);
4417
+ tex.colorSpace = THREE.SRGBColorSpace;
4418
+ return tex;
4419
+ }
4420
+ const shadow = new THREE.Mesh(
4421
+ new THREE.PlaneGeometry(2.4, 2.4),
4422
+ new THREE.MeshBasicMaterial({
4423
+ map: radialTexture("rgba(0,0,0,0.55)", "rgba(0,0,0,0)"),
4424
+ transparent: true,
4425
+ depthWrite: false,
4426
+ }),
4427
+ );
4428
+ shadow.rotation.x = -Math.PI / 2;
4429
+ shadow.position.y = 0.002;
4430
+ scene.add(shadow);
4431
+
4432
+ const turntable = new THREE.Group();
4433
+ scene.add(turntable);
4434
+
4435
+ async function labelTexture() {
4436
+ try {
4437
+ const face = new FontFace(
4438
+ "PT Inter",
4439
+ "url(../fonts/latin-inter/inter-latin-wght-normal.woff2)",
4440
+ { weight: "800" },
4441
+ );
4442
+ document.fonts.add(await face.load());
4443
+ } catch (error) {
4444
+ console.error("[product-turntable] label font failed to load, using system sans", error);
4445
+ }
4446
+ const c = document.createElement("canvas");
4447
+ // 2.35:1 matches the label's circumference to height, so type is not stretched.
4448
+ c.width = 2048;
4449
+ c.height = 872;
4450
+ const g = c.getContext("2d");
4451
+ const label = hex(V.label_color, "#f2c230");
4452
+ const ink = hex(V.ink_color, "#1d2a24");
4453
+ g.fillStyle = label;
4454
+ g.fillRect(0, 0, 2048, 872);
4455
+ g.fillStyle = ink;
4456
+ g.fillRect(0, 70, 2048, 12);
4457
+ g.fillRect(0, 790, 2048, 12);
4458
+ const name = String(V.product_name || "YUZU").toUpperCase();
4459
+ const flavor = String(V.flavor || "").toUpperCase();
4460
+ // Two faces, front and back, so the wordmark reads twice per revolution.
4461
+ for (const cx of [512, 1536]) {
4462
+ g.save();
4463
+ g.textAlign = "center";
4464
+ g.textBaseline = "middle";
4465
+ let size = 280;
4466
+ g.font = `800 ${size}px "PT Inter", system-ui, sans-serif`;
4467
+ while (g.measureText(name).width > 600 && size > 80) {
4468
+ size -= 10;
4469
+ g.font = `800 ${size}px "PT Inter", system-ui, sans-serif`;
4470
+ }
4471
+ g.fillText(name, cx, 400);
4472
+ g.font = `800 50px "PT Inter", system-ui, sans-serif`;
4473
+ g.globalAlpha = 0.8;
4474
+ g.fillText(flavor, cx, 590, 540);
4475
+ g.restore();
4476
+ }
4477
+ g.save();
4478
+ g.textAlign = "center";
4479
+ g.font = `800 34px "PT Inter", system-ui, sans-serif`;
4480
+ g.globalAlpha = 0.7;
4481
+ for (const cx of [0, 1024, 2048]) g.fillText("355 ML", cx, 450);
4482
+ g.restore();
4483
+ const tex = new THREE.CanvasTexture(c);
4484
+ tex.colorSpace = THREE.SRGBColorSpace;
4485
+ tex.anisotropy = renderer.capabilities.getMaxAnisotropy();
4486
+ return tex;
4487
+ }
4488
+
4489
+ async function builtInCan() {
4490
+ const can = new THREE.Group();
4491
+ const metal = new THREE.MeshStandardMaterial({
4492
+ color: 0xd4d7dc,
4493
+ metalness: 1,
4494
+ roughness: 0.24,
4495
+ });
4496
+ // Lathe profile (radius, height): domed base, straight wall, necked shoulder, rolled lip.
4497
+ const profile = [
4498
+ [0.0, 0.1],
4499
+ [0.46, 0.06],
4500
+ [0.6, 0.0],
4501
+ [0.66, 0.06],
4502
+ [0.67, 0.16],
4503
+ [0.67, 2.02],
4504
+ [0.63, 2.14],
4505
+ [0.56, 2.24],
4506
+ [0.555, 2.29],
4507
+ [0.575, 2.31],
4508
+ [0.56, 2.33],
4509
+ [0.5, 2.3],
4510
+ [0.0, 2.27],
4511
+ ].map(([x, y]) => new THREE.Vector2(x, y));
4512
+ can.add(new THREE.Mesh(new THREE.LatheGeometry(profile, 128), metal));
4513
+ const labelMat = new THREE.MeshPhysicalMaterial({
4514
+ map: await labelTexture(),
4515
+ metalness: 0.45,
4516
+ roughness: 0.32,
4517
+ clearcoat: 1,
4518
+ clearcoatRoughness: 0.12,
4519
+ });
4520
+ const label = new THREE.Mesh(
4521
+ new THREE.CylinderGeometry(0.674, 0.674, 1.8, 128, 1, true),
4522
+ labelMat,
4523
+ );
4524
+ label.position.y = 1.1;
4525
+ can.add(label);
4526
+ // Pull tab: a thin rounded plate on the lid.
4527
+ const tab = new THREE.Mesh(new THREE.CapsuleGeometry(0.07, 0.22, 4, 12), metal);
4528
+ tab.rotation.set(Math.PI / 2, 0, Math.PI / 2);
4529
+ tab.scale.set(1, 1, 0.25);
4530
+ tab.position.set(0.1, 2.285, 0);
4531
+ can.add(tab);
4532
+ return can;
4533
+ }
4534
+
4535
+ function fitModel(object) {
4536
+ const box = new THREE.Box3().setFromObject(object);
4537
+ const size = box.getSize(new THREE.Vector3());
4538
+ const center = box.getCenter(new THREE.Vector3());
4539
+ const scale = Math.min(2.3 / size.y, 2.6 / Math.max(size.x, size.z));
4540
+ object.scale.setScalar(scale);
4541
+ object.position.set(-center.x * scale, -box.min.y * scale, -center.z * scale);
4542
+ const wrapper = new THREE.Group();
4543
+ wrapper.add(object);
4544
+ return wrapper;
4545
+ }
4546
+
4547
+ // A model_url that fails to load fails the render; it never swaps in a different product.
4548
+ async function product() {
4549
+ const url = String(V.model_url || "").trim();
4550
+ if (!url) return builtInCan();
4551
+ const gltf = await new GLTFLoader().loadAsync(url);
4552
+ return fitModel(gltf.scene);
4553
+ }
4554
+
4555
+ turntable.add(await product());
4556
+
4557
+ host.render = (t) => {
4558
+ turntable.rotation.y = (t / host.duration) * turns * Math.PI * 2;
4559
+ renderer.render(scene, camera);
4560
+ };
4561
+ host.render(host.clock.t);
4562
+ host.ready();
4563
+
4564
+ })();
4565
+ </script>
4566
+ </div>
4567
+ <script>window.__popostFit();</script>
4568
+ </body>
4569
+ </html>