@akohn/dashql-react 0.0.0-stage → 0.0.20-dev.1001.g5e5121808

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 (356) hide show
  1. package/LICENSE +373 -0
  2. package/NOTICE +118 -0
  3. package/README.md +133 -2
  4. package/dist/_virtual/_vite/preload-helper.js +100 -0
  5. package/dist/brand/brand.d.ts +13 -0
  6. package/dist/brand/brand.js +14 -0
  7. package/dist/brand/landing_backdrop.d.ts +56 -0
  8. package/dist/brand/landing_backdrop.js +1019 -0
  9. package/dist/brand/wobble_morph.d.ts +54 -0
  10. package/dist/brand/wobble_morph.js +439 -0
  11. package/dist/components/action_list.d.ts +31 -0
  12. package/dist/components/action_list.js +63 -0
  13. package/dist/components/action_list.module.js +11 -0
  14. package/dist/components/anchored_overlay.d.ts +28 -0
  15. package/dist/components/anchored_overlay.js +93 -0
  16. package/dist/components/button.d.ts +42 -0
  17. package/dist/components/button.js +97 -0
  18. package/dist/components/button.module.js +20 -0
  19. package/dist/components/button_group.d.ts +7 -0
  20. package/dist/components/button_group.js +18 -0
  21. package/dist/components/button_group.module.js +3 -0
  22. package/dist/components/card_placeholder.d.ts +9 -0
  23. package/dist/components/card_placeholder.js +39 -0
  24. package/dist/components/card_placeholder.module.js +6 -0
  25. package/dist/components/clipboard.d.ts +19 -0
  26. package/dist/components/clipboard.js +54 -0
  27. package/dist/components/data_table/computation_tables.d.ts +12 -0
  28. package/dist/components/data_table/computation_tables.js +42 -0
  29. package/dist/components/data_table/data_table.d.ts +39 -0
  30. package/dist/components/data_table/data_table.js +415 -0
  31. package/dist/components/data_table/data_table.module.js +41 -0
  32. package/dist/components/data_table/data_table_cell.d.ts +7 -0
  33. package/dist/components/data_table/data_table_cell.js +9 -0
  34. package/dist/components/data_table/data_table_cell_data.d.ts +22 -0
  35. package/dist/components/data_table/data_table_cell_data.js +103 -0
  36. package/dist/components/data_table/data_table_cell_header_name.d.ts +17 -0
  37. package/dist/components/data_table/data_table_cell_header_name.js +73 -0
  38. package/dist/components/data_table/data_table_cell_header_plots.d.ts +29 -0
  39. package/dist/components/data_table/data_table_cell_header_plots.js +120 -0
  40. package/dist/components/data_table/data_table_colors.d.ts +19 -0
  41. package/dist/components/data_table/data_table_colors.js +27 -0
  42. package/dist/components/data_table/data_table_column_resize.d.ts +21 -0
  43. package/dist/components/data_table/data_table_column_resize.js +121 -0
  44. package/dist/components/data_table/data_table_focus.d.ts +15 -0
  45. package/dist/components/data_table/data_table_focus.js +53 -0
  46. package/dist/components/data_table/data_table_layout.d.ts +18 -0
  47. package/dist/components/data_table/data_table_layout.js +103 -0
  48. package/dist/components/data_table/data_table_ordering.d.ts +9 -0
  49. package/dist/components/data_table/data_table_ordering.js +39 -0
  50. package/dist/components/data_table/data_table_portals.d.ts +9 -0
  51. package/dist/components/data_table/data_table_portals.js +29 -0
  52. package/dist/components/data_table/data_table_row_detail.d.ts +22 -0
  53. package/dist/components/data_table/data_table_row_detail.js +68 -0
  54. package/dist/components/data_table/data_table_row_detail.module.js +7 -0
  55. package/dist/components/data_table/data_table_sticky_views.d.ts +35 -0
  56. package/dist/components/data_table/data_table_sticky_views.js +161 -0
  57. package/dist/components/data_table/data_table_window.d.ts +18 -0
  58. package/dist/components/data_table/data_table_window.js +118 -0
  59. package/dist/components/data_table/format_peek.d.ts +2 -0
  60. package/dist/components/data_table/format_peek.js +17 -0
  61. package/dist/components/data_table/histogram_bars.d.ts +36 -0
  62. package/dist/components/data_table/histogram_bars.js +100 -0
  63. package/dist/components/data_table/histogram_brush.d.ts +22 -0
  64. package/dist/components/data_table/histogram_brush.js +105 -0
  65. package/dist/components/data_table/histogram_cell.d.ts +17 -0
  66. package/dist/components/data_table/histogram_cell.js +324 -0
  67. package/dist/components/data_table/histogram_cell.module.js +9 -0
  68. package/dist/components/data_table/histogram_label.d.ts +1 -0
  69. package/dist/components/data_table/histogram_label.js +7 -0
  70. package/dist/components/data_table/memo_props.d.ts +1 -0
  71. package/dist/components/data_table/memo_props.js +17 -0
  72. package/dist/components/data_table/mostfrequent_cell.d.ts +17 -0
  73. package/dist/components/data_table/mostfrequent_cell.js +316 -0
  74. package/dist/components/data_table/mostfrequent_cell.module.js +10 -0
  75. package/dist/components/data_table/use_cross_filters.d.ts +14 -0
  76. package/dist/components/data_table/use_cross_filters.js +47 -0
  77. package/dist/components/deferred.d.ts +11 -0
  78. package/dist/components/deferred.js +41 -0
  79. package/dist/components/deferred.module.js +5 -0
  80. package/dist/components/error_boundary.d.ts +18 -0
  81. package/dist/components/error_boundary.js +15 -0
  82. package/dist/components/graph.module.js +15 -0
  83. package/dist/components/graph_port.d.ts +10 -0
  84. package/dist/components/graph_port.js +34 -0
  85. package/dist/components/inspector_overlay.d.ts +32 -0
  86. package/dist/components/inspector_overlay.js +72 -0
  87. package/dist/components/inspector_overlay.module.js +18 -0
  88. package/dist/components/json/json_arrow_symbol.d.ts +4 -0
  89. package/dist/components/json/json_arrow_symbol.js +25 -0
  90. package/dist/components/json/json_copy_button.d.ts +11 -0
  91. package/dist/components/json/json_copy_button.js +61 -0
  92. package/dist/components/json/json_ellipsis_symbol.d.ts +7 -0
  93. package/dist/components/json/json_ellipsis_symbol.js +11 -0
  94. package/dist/components/json/json_item_count.d.ts +5 -0
  95. package/dist/components/json/json_item_count.js +12 -0
  96. package/dist/components/json/json_key_name.d.ts +6 -0
  97. package/dist/components/json/json_key_name.js +40 -0
  98. package/dist/components/json/json_key_values.d.ts +12 -0
  99. package/dist/components/json/json_key_values.js +99 -0
  100. package/dist/components/json/json_literal.d.ts +8 -0
  101. package/dist/components/json/json_literal.js +140 -0
  102. package/dist/components/json/json_nested_close.d.ts +11 -0
  103. package/dist/components/json/json_nested_close.js +31 -0
  104. package/dist/components/json/json_nested_open.d.ts +18 -0
  105. package/dist/components/json/json_nested_open.js +150 -0
  106. package/dist/components/json/json_nested_state.d.ts +14 -0
  107. package/dist/components/json/json_nested_state.js +28 -0
  108. package/dist/components/json/json_tool_state.d.ts +18 -0
  109. package/dist/components/json/json_tool_state.js +46 -0
  110. package/dist/components/json/json_value.d.ts +10 -0
  111. package/dist/components/json/json_value.js +46 -0
  112. package/dist/components/json/json_view.d.ts +14 -0
  113. package/dist/components/json/json_view.js +37 -0
  114. package/dist/components/json/json_view.module.js +41 -0
  115. package/dist/components/json/json_view_state.d.ts +14 -0
  116. package/dist/components/json/json_view_state.js +32 -0
  117. package/dist/components/json/unique_key.d.ts +1 -0
  118. package/dist/components/json/unique_key.js +8 -0
  119. package/dist/components/keyvalue_list.d.ts +25 -0
  120. package/dist/components/keyvalue_list.js +106 -0
  121. package/dist/components/keyvalue_list.module.js +15 -0
  122. package/dist/components/name_input.d.ts +12 -0
  123. package/dist/components/name_input.js +63 -0
  124. package/dist/components/overlay.d.ts +53 -0
  125. package/dist/components/overlay.js +183 -0
  126. package/dist/components/overlay.module.js +32 -0
  127. package/dist/components/panel_resize_handle.d.ts +12 -0
  128. package/dist/components/panel_resize_handle.js +39 -0
  129. package/dist/components/portal.d.ts +8 -0
  130. package/dist/components/portal.js +53 -0
  131. package/dist/components/progress_bar.d.ts +7 -0
  132. package/dist/components/progress_bar.js +21 -0
  133. package/dist/components/progress_bar.module.js +3 -0
  134. package/dist/components/query_history_viewer.d.ts +31 -0
  135. package/dist/components/query_history_viewer.js +271 -0
  136. package/dist/components/query_history_viewer.module.js +7 -0
  137. package/dist/components/query_profile/engine_profile_view.d.ts +19 -0
  138. package/dist/components/query_profile/engine_profile_view.js +94 -0
  139. package/dist/components/query_profile/numeric_limits.d.ts +1 -0
  140. package/dist/components/query_profile/numeric_limits.js +2 -0
  141. package/dist/components/query_profile/profile_execution_controller.d.ts +12 -0
  142. package/dist/components/query_profile/profile_execution_controller.js +44 -0
  143. package/dist/components/query_profile/profile_fit.d.ts +24 -0
  144. package/dist/components/query_profile/profile_fit.js +22 -0
  145. package/dist/components/query_profile/profile_navigation.d.ts +3 -0
  146. package/dist/components/query_profile/profile_navigation.js +34 -0
  147. package/dist/components/query_profile/profile_scene.d.ts +64 -0
  148. package/dist/components/query_profile/profile_scene.js +422 -0
  149. package/dist/components/query_profile/query_profile_view.d.ts +36 -0
  150. package/dist/components/query_profile/query_profile_view.js +953 -0
  151. package/dist/components/query_profile/query_profile_view.module.js +23 -0
  152. package/dist/components/query_progress/query_profile_overlay.d.ts +7 -0
  153. package/dist/components/query_progress/query_profile_overlay.js +67 -0
  154. package/dist/components/query_progress/query_profile_overlay.module.js +6 -0
  155. package/dist/components/query_progress/query_progress_panel.d.ts +14 -0
  156. package/dist/components/query_progress/query_progress_panel.js +255 -0
  157. package/dist/components/query_progress/query_progress_panel.module.js +10 -0
  158. package/dist/components/query_result/cell_detail_overlay.d.ts +34 -0
  159. package/dist/components/query_result/cell_detail_overlay.js +277 -0
  160. package/dist/components/query_result/cell_detail_overlay.module.js +21 -0
  161. package/dist/components/query_result/query_result_action_menu.d.ts +12 -0
  162. package/dist/components/query_result/query_result_action_menu.js +62 -0
  163. package/dist/components/query_result/query_result_action_menu.module.js +2 -0
  164. package/dist/components/query_result/query_result_details.d.ts +17 -0
  165. package/dist/components/query_result/query_result_details.js +46 -0
  166. package/dist/components/query_result/query_result_details.module.js +5 -0
  167. package/dist/components/query_result/query_result_download_button.d.ts +8 -0
  168. package/dist/components/query_result/query_result_download_button.js +38 -0
  169. package/dist/components/query_result/query_result_header.d.ts +21 -0
  170. package/dist/components/query_result/query_result_header.js +72 -0
  171. package/dist/components/query_result/query_result_header.module.js +3 -0
  172. package/dist/components/query_result/query_result_search_controls.d.ts +12 -0
  173. package/dist/components/query_result/query_result_search_controls.js +141 -0
  174. package/dist/components/query_result/query_result_search_controls.module.js +7 -0
  175. package/dist/components/query_result/query_result_toolbar.d.ts +21 -0
  176. package/dist/components/query_result/query_result_toolbar.js +74 -0
  177. package/dist/components/query_result/result_table_overlay.d.ts +9 -0
  178. package/dist/components/query_result/result_table_overlay.js +73 -0
  179. package/dist/components/query_result/result_table_overlay.module.js +6 -0
  180. package/dist/components/query_result/use_query_result_search.d.ts +8 -0
  181. package/dist/components/query_result/use_query_result_search.js +28 -0
  182. package/dist/components/segmented_control.d.ts +58 -0
  183. package/dist/components/segmented_control.js +116 -0
  184. package/dist/components/segmented_control.module.js +17 -0
  185. package/dist/components/separator.d.ts +21 -0
  186. package/dist/components/separator.js +79 -0
  187. package/dist/components/separator.module.js +7 -0
  188. package/dist/components/sheet.d.ts +11 -0
  189. package/dist/components/sheet.js +65 -0
  190. package/dist/components/sheet.module.js +7 -0
  191. package/dist/components/size_observer.d.ts +7 -0
  192. package/dist/components/size_observer.js +57 -0
  193. package/dist/components/skeleton.d.ts +2 -0
  194. package/dist/components/skeleton.js +14 -0
  195. package/dist/components/skeleton.module.js +2 -0
  196. package/dist/components/spinners.d.ts +8 -0
  197. package/dist/components/spinners.js +33 -0
  198. package/dist/components/spinners.module.js +8 -0
  199. package/dist/components/status_indicator.d.ts +36 -0
  200. package/dist/components/status_indicator.js +182 -0
  201. package/dist/components/status_indicator.module.js +3 -0
  202. package/dist/components/symbol_icon.d.ts +65 -0
  203. package/dist/components/symbol_icon.js +213 -0
  204. package/dist/components/tab_header.d.ts +11 -0
  205. package/dist/components/tab_header.js +55 -0
  206. package/dist/components/tab_header.module.js +7 -0
  207. package/dist/components/tag.d.ts +10 -0
  208. package/dist/components/tag.js +17 -0
  209. package/dist/components/tag.module.js +4 -0
  210. package/dist/components/text_field.d.ts +44 -0
  211. package/dist/components/text_field.js +159 -0
  212. package/dist/components/text_field.module.js +15 -0
  213. package/dist/components/text_input.d.ts +25 -0
  214. package/dist/components/text_input.js +90 -0
  215. package/dist/components/text_input.module.js +13 -0
  216. package/dist/components/text_input_action.d.ts +19 -0
  217. package/dist/components/text_input_action.js +33 -0
  218. package/dist/components/text_input_action.module.js +2 -0
  219. package/dist/components/toggle_switch.d.ts +7 -0
  220. package/dist/components/toggle_switch.js +22 -0
  221. package/dist/components/toggle_switch.module.js +6 -0
  222. package/dist/components/tooltip.d.ts +22 -0
  223. package/dist/components/tooltip.js +139 -0
  224. package/dist/components/tooltip.module.js +2 -0
  225. package/dist/components/tree_entry.d.ts +17 -0
  226. package/dist/components/tree_entry.js +48 -0
  227. package/dist/components/tree_entry.module.js +9 -0
  228. package/dist/components/value_list.d.ts +17 -0
  229. package/dist/components/value_list.js +70 -0
  230. package/dist/components/value_list.module.js +8 -0
  231. package/dist/components/vegalite_chart.d.ts +16 -0
  232. package/dist/components/vegalite_chart.js +149 -0
  233. package/dist/components/vegalite_chart.module.js +3 -0
  234. package/dist/components/vegalite_view.d.ts +26 -0
  235. package/dist/components/vegalite_view.js +239 -0
  236. package/dist/components/vegalite_view.module.js +5 -0
  237. package/dist/components/vertical_scroll_shadows.d.ts +14 -0
  238. package/dist/components/vertical_scroll_shadows.js +55 -0
  239. package/dist/components/vertical_scroll_shadows.module.js +5 -0
  240. package/dist/components/vertical_split.d.ts +15 -0
  241. package/dist/components/vertical_split.js +112 -0
  242. package/dist/components/vertical_split.module.js +5 -0
  243. package/dist/components/vertical_tabs.d.ts +36 -0
  244. package/dist/components/vertical_tabs.js +169 -0
  245. package/dist/components/vertical_tabs.module.js +23 -0
  246. package/dist/components/visualization/capped_rows.d.ts +9 -0
  247. package/dist/components/visualization/capped_rows.js +23 -0
  248. package/dist/components/visualization/capped_rows.module.js +3 -0
  249. package/dist/components/visualization/chart_download_button.d.ts +12 -0
  250. package/dist/components/visualization/chart_download_button.js +41 -0
  251. package/dist/components/visualization/kpi_view.d.ts +10 -0
  252. package/dist/components/visualization/kpi_view.js +215 -0
  253. package/dist/components/visualization/kpi_view.module.js +17 -0
  254. package/dist/components/visualization/markdown_view.d.ts +17 -0
  255. package/dist/components/visualization/markdown_view.js +154 -0
  256. package/dist/components/visualization/markdown_view.module.js +4 -0
  257. package/dist/components/visualization/result_rows.d.ts +17 -0
  258. package/dist/components/visualization/result_rows.js +82 -0
  259. package/dist/components/visualization/vegalite_preview.d.ts +8 -0
  260. package/dist/components/visualization/vegalite_preview.js +17 -0
  261. package/dist/components/visualization/vegalite_preview.module.js +2 -0
  262. package/dist/components/visualization/visualization_dispatch.d.ts +13 -0
  263. package/dist/components/visualization/visualization_dispatch.js +40 -0
  264. package/dist/components/visualization/visualization_panel.d.ts +10 -0
  265. package/dist/components/visualization/visualization_panel.js +36 -0
  266. package/dist/components/visualization/visualization_panel.module.js +3 -0
  267. package/dist/dom/anchored_position.d.ts +42 -0
  268. package/dist/dom/anchored_position.js +255 -0
  269. package/dist/dom/app_host.d.ts +2 -0
  270. package/dist/dom/app_host.js +7 -0
  271. package/dist/dom/calm_frames.d.ts +29 -0
  272. package/dist/dom/calm_frames.js +120 -0
  273. package/dist/dom/classnames.d.ts +8 -0
  274. package/dist/dom/classnames.js +20 -0
  275. package/dist/dom/download_file.d.ts +1 -0
  276. package/dist/dom/download_file.js +12 -0
  277. package/dist/dom/focus.d.ts +29 -0
  278. package/dist/dom/focus.js +84 -0
  279. package/dist/dom/graph_edges.d.ts +53 -0
  280. package/dist/dom/graph_edges.js +450 -0
  281. package/dist/dom/key_events.d.ts +9 -0
  282. package/dist/dom/key_events.js +33 -0
  283. package/dist/dom/media_query.d.ts +5 -0
  284. package/dist/dom/media_query.js +18 -0
  285. package/dist/dom/outside_click.d.ts +8 -0
  286. package/dist/dom/outside_click.js +32 -0
  287. package/dist/dom/rerender_ref.d.ts +2 -0
  288. package/dist/dom/rerender_ref.js +11 -0
  289. package/dist/dom/row_context_menu.d.ts +7 -0
  290. package/dist/dom/row_context_menu.js +32 -0
  291. package/dist/dom/scrollbar.d.ts +3 -0
  292. package/dist/dom/scrollbar.js +23 -0
  293. package/dist/format/format.d.ts +11 -0
  294. package/dist/format/format.js +72 -0
  295. package/dist/format/query_progress_format.d.ts +17 -0
  296. package/dist/format/query_progress_format.js +69 -0
  297. package/dist/format/time_format.d.ts +5 -0
  298. package/dist/format/time_format.js +45 -0
  299. package/dist/hooks.d.ts +72 -0
  300. package/dist/hooks.js +305 -0
  301. package/dist/host.d.ts +10 -0
  302. package/dist/host.js +12 -0
  303. package/dist/logger.d.ts +4 -0
  304. package/dist/logger.js +13 -0
  305. package/dist/models/computation_model.d.ts +14 -0
  306. package/dist/models/computation_model.js +27 -0
  307. package/dist/models/query_model.d.ts +12 -0
  308. package/dist/models/query_model.js +27 -0
  309. package/dist/models/script_model.d.ts +17 -0
  310. package/dist/models/script_model.js +59 -0
  311. package/dist/platform/content_length.d.ts +1 -0
  312. package/dist/platform/content_length.js +7 -0
  313. package/dist/platform/core_provider.d.ts +18 -0
  314. package/dist/platform/core_provider.js +106 -0
  315. package/dist/platform/embedded_database_provider.d.ts +19 -0
  316. package/dist/platform/embedded_database_provider.js +53 -0
  317. package/dist/platform/page_runtime.d.ts +3 -0
  318. package/dist/platform/page_runtime.js +29 -0
  319. package/dist/style.css +4386 -0
  320. package/dist/svg_symbols.d.ts +2 -0
  321. package/dist/svg_symbols.js +2 -0
  322. package/dist/symbols.svg +1197 -0
  323. package/dist/theme/color_scheme.d.ts +4 -0
  324. package/dist/theme/color_scheme.js +28 -0
  325. package/dist/theme/xcode_palette.d.ts +22 -0
  326. package/dist/theme/xcode_palette.js +4 -0
  327. package/dist/theme/xcode_palettes.js +41 -0
  328. package/dist/utils/plan_engine.d.ts +2 -0
  329. package/dist/utils/plan_engine.js +13 -0
  330. package/dist/vegalite/vegalite_check.d.ts +1 -0
  331. package/dist/vegalite/vegalite_check.js +7 -0
  332. package/dist/vegalite/vegalite_crossfilter.d.ts +54 -0
  333. package/dist/vegalite/vegalite_crossfilter.js +187 -0
  334. package/dist/vegalite/vegalite_image.d.ts +14 -0
  335. package/dist/vegalite/vegalite_image.js +28 -0
  336. package/dist/vegalite/vegalite_loader.d.ts +7 -0
  337. package/dist/vegalite/vegalite_loader.js +15 -0
  338. package/dist/vegalite/vegalite_rows.d.ts +3 -0
  339. package/dist/vegalite/vegalite_rows.js +23 -0
  340. package/dist/vegalite/vegalite_theme.d.ts +13 -0
  341. package/dist/vegalite/vegalite_theme.js +141 -0
  342. package/fonts/InstrumentSans-Bold.ttf +0 -0
  343. package/fonts/InstrumentSans-Medium.ttf +0 -0
  344. package/fonts/InstrumentSans-OFL.txt +93 -0
  345. package/fonts/InstrumentSans-Regular.ttf +0 -0
  346. package/fonts/InstrumentSans-SemiBold.ttf +0 -0
  347. package/fonts/JetBrainsMono-Bold.ttf +0 -0
  348. package/fonts/JetBrainsMono-Medium.ttf +0 -0
  349. package/fonts/JetBrainsMono-OFL.txt +93 -0
  350. package/fonts/JetBrainsMono-Regular.ttf +0 -0
  351. package/fonts/JetBrainsMono-SemiBold.ttf +0 -0
  352. package/fonts/fonts.css +61 -0
  353. package/package.json +403 -4
  354. package/styles/colors.css +110 -0
  355. package/styles/flavors/dbcom.css +48 -0
  356. package/styles/tokens.css +192 -0
@@ -0,0 +1,1019 @@
1
+ import { outlineBounds, springAtRest, stepSpring } from "./wobble_morph.js";
2
+ var DEFAULT_LANDING_BACKDROP = {
3
+ period: 10,
4
+ contrast: .8,
5
+ dots: 5e3,
6
+ particles: 5e3,
7
+ ringInk: .31,
8
+ ringFps: 15,
9
+ outerWobble: .06,
10
+ gap: 2,
11
+ fly: .5,
12
+ lightSeconds: 6,
13
+ glow: .2,
14
+ density: .5,
15
+ sphereDensity: .5,
16
+ ringDensity: .6,
17
+ twinkleSeconds: 6,
18
+ wobble: .07,
19
+ markWobble: .005,
20
+ scale: .3,
21
+ eyes: true
22
+ };
23
+ var CLOUD_DENSITIES = [
24
+ 5e3,
25
+ 1e4,
26
+ 2e4,
27
+ 4e4
28
+ ];
29
+ var DOT_SIZE = 2;
30
+ var DRAWN_SHARE = .56;
31
+ var FAST_FRAME_MS = 1e3 / 60;
32
+ var REST_FRAME_MS = 1e3 / 30;
33
+ var SPHERE_RADIUS = 70;
34
+ var UNITS_PER_PAGE = 92;
35
+ var PERSPECTIVE = .3;
36
+ var MORPH_LAG = .32;
37
+ var EYE_DX = 24;
38
+ var EYE_DY = 10;
39
+ var EYE_WIDTH = 17;
40
+ var EYE_HEIGHT = 27;
41
+ var EYE_DOT_SPACING = 3.1;
42
+ var EYE_ROWS = [
43
+ 2,
44
+ 4,
45
+ 6,
46
+ 6,
47
+ 6,
48
+ 6,
49
+ 6,
50
+ 6,
51
+ 4,
52
+ 2
53
+ ];
54
+ var GLANCE_AMPLITUDE = 15;
55
+ var GLANCE_INTERVAL_MS = 2400;
56
+ var BLINK_INTERVAL_MS = 4500;
57
+ var BLINK_MS = 150;
58
+ var EYE_INK = .85;
59
+ var GLANCE_STIFFNESS = 160;
60
+ var GLANCE_DAMPING = 22;
61
+ var EYES_CLOSE_MS = 180;
62
+ var POINTER_IDLE_MS = 2500;
63
+ var BODY_INK = 3.4;
64
+ var RING_WIDTH = .6;
65
+ var RING_REACH_TOWARDS_VIEWER = Math.cos(1.2);
66
+ var PARTICLE_JOIN_SHARE = .55;
67
+ var JOIN_SPREAD = 1.4;
68
+ var JOIN_HOLD = 1.6;
69
+ var JOIN_SWAP = .3;
70
+ var SHAPE_TRACE = .16;
71
+ var DISSOLVE_SPREAD = .9;
72
+ var DISSOLVE_FADE = .5;
73
+ var REVEAL_START = .8;
74
+ var REVEAL_SPREAD = 1.5;
75
+ var REVEAL_FADE = .4;
76
+ var LIGHT_CIRCLE = 46;
77
+ var LIGHT_STILL_ANGLE = 2.4;
78
+ var MORPH_STIFFNESS = 11;
79
+ var MORPH_DAMPING = 5.2;
80
+ function seededRandom(seed) {
81
+ let state = seed;
82
+ return () => {
83
+ state = state + 1831565813 | 0;
84
+ let t = Math.imul(state ^ state >>> 15, 1 | state);
85
+ t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
86
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
87
+ };
88
+ }
89
+ function latticePlaces(brand, spacing) {
90
+ const places = [];
91
+ const crossings = [];
92
+ let row = 0;
93
+ for (let y = 0; y < 200; y += spacing * .866, ++row) {
94
+ const shift = row % 2 === 0 ? 0 : spacing / 2;
95
+ for (const piece of brand.pieces) {
96
+ const outline = piece.logo;
97
+ const n = outline.length / 2;
98
+ crossings.length = 0;
99
+ for (let i = 0, j = n - 1; i < n; j = i++) {
100
+ const ay = outline[2 * j + 1], by = outline[2 * i + 1];
101
+ if (by > y !== ay > y) {
102
+ const ax = outline[2 * j], bx = outline[2 * i];
103
+ crossings.push(ax + (y - ay) / (by - ay) * (bx - ax));
104
+ }
105
+ }
106
+ crossings.sort((a, b) => a - b);
107
+ for (let c = 0; c + 1 < crossings.length; c += 2) {
108
+ const first = Math.ceil((crossings[c] - shift) / spacing);
109
+ for (let x = first * spacing + shift; x < crossings[c + 1]; x += spacing) places.push({
110
+ x: x - 100,
111
+ y: 100 - y
112
+ });
113
+ }
114
+ }
115
+ }
116
+ return places;
117
+ }
118
+ function markLattice(brand, count) {
119
+ let spacing = 2;
120
+ for (let i = 0; i < 4; ++i) spacing *= Math.sqrt(latticePlaces(brand, spacing).length / count);
121
+ let places = latticePlaces(brand, spacing);
122
+ while (places.length < count) {
123
+ spacing *= .995;
124
+ places = latticePlaces(brand, spacing);
125
+ }
126
+ return places;
127
+ }
128
+ var CLOUD_FLOATS = 7;
129
+ var PARTICLE_FLOATS = 14;
130
+ var CLOUDS = /* @__PURE__ */ new Map();
131
+ function buildCloud(brand, count) {
132
+ const key = `${brand.id}-${count}`;
133
+ const cached = CLOUDS.get(key);
134
+ if (cached != null) return cached;
135
+ const drawn = Math.ceil(count * DRAWN_SHARE);
136
+ const cloud = new Float32Array(CLOUD_FLOATS * drawn);
137
+ const random = seededRandom(11);
138
+ const sides = [[], []];
139
+ for (let i = 0; i < drawn; ++i) {
140
+ const z = 1 - 2 * (i + .5) / count;
141
+ const ring = Math.sqrt(1 - z * z);
142
+ const angle = 2.399963229728653 * i;
143
+ const offset = CLOUD_FLOATS * i;
144
+ cloud[offset] = Math.cos(angle) * ring;
145
+ cloud[offset + 1] = Math.sin(angle) * ring;
146
+ cloud[offset + 2] = z;
147
+ sides[z >= 0 ? 0 : 1].push(i);
148
+ }
149
+ const lattice = markLattice(brand, sides[0].length);
150
+ let longest = 0;
151
+ for (const sources of sides) {
152
+ if (sources.length === 0) continue;
153
+ const targets = [];
154
+ for (let i = 0; i < sources.length; ++i) targets.push(Math.floor(i * lattice.length / sources.length));
155
+ sources.sort((a, b) => cloud[CLOUD_FLOATS * b + 1] - cloud[CLOUD_FLOATS * a + 1]);
156
+ targets.sort((a, b) => lattice[b].y - lattice[a].y);
157
+ const rows = Math.max(1, Math.round(Math.sqrt(sources.length)));
158
+ for (let row = 0; row < rows; ++row) {
159
+ const from = Math.floor(row * sources.length / rows);
160
+ const to = Math.floor((row + 1) * sources.length / rows);
161
+ const rowSources = sources.slice(from, to).sort((a, b) => cloud[CLOUD_FLOATS * a] - cloud[CLOUD_FLOATS * b]);
162
+ const rowTargets = targets.slice(from, to).sort((a, b) => lattice[a].x - lattice[b].x);
163
+ for (let k = 0; k < rowSources.length; ++k) {
164
+ const offset = CLOUD_FLOATS * rowSources[k];
165
+ const { x, y } = lattice[rowTargets[k]];
166
+ cloud[offset + 3] = x;
167
+ cloud[offset + 4] = y;
168
+ const travel = Math.hypot(cloud[offset] * SPHERE_RADIUS - x, cloud[offset + 1] * SPHERE_RADIUS - y, cloud[offset + 2] * SPHERE_RADIUS);
169
+ cloud[offset + 5] = travel;
170
+ longest = Math.max(longest, travel);
171
+ }
172
+ }
173
+ }
174
+ for (let i = 0; i < drawn; ++i) cloud[CLOUD_FLOATS * i + 5] = 1 - cloud[CLOUD_FLOATS * i + 5] / (longest || 1);
175
+ for (let i = drawn - 1; i > 0; --i) {
176
+ const j = Math.floor(random() * (i + 1));
177
+ for (let k = 0; k < CLOUD_FLOATS; ++k) {
178
+ const swap = cloud[CLOUD_FLOATS * i + k];
179
+ cloud[CLOUD_FLOATS * i + k] = cloud[CLOUD_FLOATS * j + k];
180
+ cloud[CLOUD_FLOATS * j + k] = swap;
181
+ }
182
+ }
183
+ for (let i = 0; i < drawn; ++i) cloud[CLOUD_FLOATS * i + 6] = (i + .5) / drawn;
184
+ CLOUDS.set(key, cloud);
185
+ return cloud;
186
+ }
187
+ function buildEyes() {
188
+ const places = [];
189
+ const rowStep = EYE_DOT_SPACING * .866;
190
+ EYE_ROWS.forEach((dots, row) => {
191
+ const y = (row - (EYE_ROWS.length - 1) / 2) * rowStep;
192
+ for (let dot = 0; dot < dots; ++dot) {
193
+ const x = (dot - (dots - 1) / 2) * EYE_DOT_SPACING;
194
+ places.push(-24, EYE_DY, x, y);
195
+ places.push(EYE_DX, EYE_DY, x, y);
196
+ }
197
+ });
198
+ return new Float32Array(places);
199
+ }
200
+ function buildParticles(brand, dots, count) {
201
+ const cloud = buildCloud(brand, dots);
202
+ const particles = new Float32Array(PARTICLE_FLOATS * count);
203
+ const random = seededRandom(23);
204
+ const fronts = [];
205
+ for (let i = 0; i < cloud.length / CLOUD_FLOATS; ++i) if (cloud[CLOUD_FLOATS * i + 2] >= 0) fronts.push(i);
206
+ for (let i = 0; i < count; ++i) {
207
+ const offset = PARTICLE_FLOATS * i;
208
+ for (let k = 0; k < 4; ++k) particles[offset + k] = random();
209
+ particles[offset + 4] = random() < PARTICLE_JOIN_SHARE ? 1 : 0;
210
+ particles[offset + 5] = random();
211
+ particles[offset + 6] = (i + .5) / count;
212
+ const dot = CLOUD_FLOATS * fronts[Math.floor(random() * fronts.length)];
213
+ particles.set(cloud.subarray(dot, dot + CLOUD_FLOATS), offset + 7);
214
+ }
215
+ return particles;
216
+ }
217
+ var VERTEX_HEAD = `#version 300 es
218
+ precision highp float;
219
+ uniform vec2 uView;
220
+ uniform float uTime;
221
+ uniform float uMorph;
222
+ uniform float uDpr;
223
+ uniform float uContrast;
224
+ uniform float uScale;
225
+ uniform mat3 uRotation;
226
+ uniform float uSize;
227
+ uniform float uWobble;
228
+ uniform float uMarkWobble;
229
+ // The place of the light on the brand mark and its brightness, the shares of the visible dots and the length of their cycle
230
+ uniform vec2 uLight;
231
+ uniform float uGlow;
232
+ uniform float uDensity;
233
+ uniform float uTwinkle;
234
+ // The seconds since the shape last switched between the sphere and the mark, and the seconds of the way of a particle
235
+ uniform float uSwitch;
236
+ uniform float uFly;
237
+ out float vAlpha;
238
+ out vec3 vColor;
239
+
240
+ // A dot is visible for a share of its own cycle, so that this share of the dots is visible at any time
241
+ // All dots share the length of the cycle: the visible ones are one slice of the buffers, the rest does not even get here
242
+ float twinkle(float seed, float density) {
243
+ if (density >= 0.99) return 1.0;
244
+ float way = fract(seed + uTime / uTwinkle);
245
+ float edge = min(0.5 * density, 0.15);
246
+ return smoothstep(0.0, edge, way) * (1.0 - smoothstep(density - edge, density, way));
247
+ }
248
+
249
+ // A dot that costs no drawing
250
+ void hide() {
251
+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
252
+ gl_PointSize = 0.0;
253
+ vAlpha = 0.0;
254
+ vColor = vec3(0.0);
255
+ }
256
+
257
+ void project(vec3 p, float size) {
258
+ vec3 place = uRotation * p / ${UNITS_PER_PAGE.toFixed(1)} * uScale;
259
+ float perspective = 1.0 / (1.0 - place.z * ${PERSPECTIVE.toFixed(2)});
260
+ gl_Position = vec4(place.xy * perspective * uView, 0.0, 1.0);
261
+ gl_PointSize = clamp(size * perspective, 1.0, 4.0) * uDpr;
262
+ }
263
+
264
+ // The color of the dots, from a dark grey over a light grey to white
265
+ vec3 ramp(float h) {
266
+ return mix(mix(vec3(0.26, 0.28, 0.32), vec3(0.62, 0.64, 0.68), smoothstep(0.0, 0.5, h)), vec3(1.0), smoothstep(0.55, 1.0, h));
267
+ }
268
+
269
+ float settledAt(float lag) {
270
+ float delay = ${MORPH_LAG.toFixed(3)} * lag;
271
+ return uMorph <= delay ? 0.0 : clamp((uMorph - delay) / (1.0 - delay), 0.0, 1.0);
272
+ }
273
+
274
+ // The mark has to stay readable: its outline wobbles a little
275
+ vec3 markSurface(vec2 a) {
276
+ vec2 m = a / ${SPHERE_RADIUS.toFixed(1)};
277
+ float b1 = 3.0 * m.x + 1.6 * m.y + 1.3 * uTime;
278
+ float b2 = 2.0 * m.y - 0.9 * uTime + 1.7;
279
+ float b3 = 3.0 * m.x + 2.1 * uTime + 0.4;
280
+ float wave = 0.5 * sin(b1) + 0.3 * sin(b2) + 0.2 * sin(b3);
281
+ return vec3(a, 0.0) + ${SPHERE_RADIUS.toFixed(1)} * uMarkWobble * vec3(0.6 * sin(b1) + 0.4 * sin(b3), 0.6 * sin(b2) + 0.4 * sin(b1 + 1.0), wave);
282
+ }
283
+
284
+ // How much a dot of the mark is lit: the dots show the whole mark, the light only moves over it very subtly
285
+ float markLit(vec2 a) {
286
+ vec2 d = a - uLight;
287
+ return uGlow * exp(-dot(d, d) / ${2704 .toFixed(1)});
288
+ }
289
+
290
+ vec3 sphereSurface(vec3 s, float settled) {
291
+ float wave = 0.5 * sin(3.0 * s.x + 1.6 * s.y + 1.3 * uTime)
292
+ + 0.3 * sin(2.0 * s.y - 2.4 * s.z - 0.9 * uTime + 1.7)
293
+ + 0.2 * sin(5.0 * s.z + 3.0 * s.x + 2.1 * uTime + 0.4);
294
+ return s * ${SPHERE_RADIUS.toFixed(1)} * (1.0 + uWobble * (1.0 - settled) * (wave + 0.4 * sin(0.8 * uTime)));
295
+ }
296
+ `;
297
+ var CLOUD_VERTEX = `${VERTEX_HEAD}
298
+ in vec3 aSphere;
299
+ in vec2 aMark;
300
+ in float aLag;
301
+ in float aSeed;
302
+ uniform float uSphereDensity;
303
+ // The glance of the eyes, how open they are, and if they are shown
304
+ uniform vec4 uEyes;
305
+
306
+ // The distance to a pill around a center
307
+ float pill(vec2 p, vec2 center, vec2 half_size) {
308
+ float radius = min(half_size.x, half_size.y);
309
+ vec2 d = abs(p - center) - half_size + radius;
310
+ return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - radius;
311
+ }
312
+
313
+ void main() {
314
+ float settled = settledAt(aLag);
315
+ // A switch dissolves the old shape dot by dot while it melts, and its dots light up one by one as the particles build
316
+ // the new one
317
+ float dissolveAt = aSeed * ${DISSOLVE_SPREAD.toFixed(2)} * uFly;
318
+ float dissolve = smoothstep(dissolveAt, dissolveAt + ${DISSOLVE_FADE.toFixed(2)} * uFly, uSwitch);
319
+ float revealAt = (${REVEAL_START.toFixed(2)} + aSeed * ${REVEAL_SPREAD.toFixed(2)}) * uFly;
320
+ float reveal = smoothstep(revealAt, revealAt + ${REVEAL_FADE.toFixed(2)} * uFly, uSwitch);
321
+ float switching = mix(1.0, mix(${SHAPE_TRACE.toFixed(2)}, 1.0, reveal), dissolve);
322
+
323
+ // The brand mark at rest needs nothing of the sphere, the back of the sphere has no dots on it
324
+ if (settled >= 1.0) {
325
+ float shown = aSphere.z >= 0.0 ? twinkle(aSeed, uDensity) : 0.0;
326
+ if (shown <= 0.0) {
327
+ hide();
328
+ return;
329
+ }
330
+ float lit = markLit(aMark);
331
+ project(markSurface(aMark), uSize * (0.8 + 0.2 * shown + 0.1 * lit));
332
+ vAlpha = uContrast * ${BODY_INK.toFixed(1)} * shown * (0.6 + lit) * switching;
333
+ vColor = ramp(0.55 + 0.3 * lit);
334
+ return;
335
+ }
336
+
337
+ // The harmonics of the outline of Wobble, on the surface of the sphere
338
+ float a1 = 3.0 * aSphere.x + 1.6 * aSphere.y + 1.3 * uTime;
339
+ float a2 = 2.0 * aSphere.y - 2.4 * aSphere.z - 0.9 * uTime + 1.7;
340
+ float a3 = 5.0 * aSphere.z + 3.0 * aSphere.x + 2.1 * uTime + 0.4;
341
+ float wave = 0.5 * sin(a1) + 0.3 * sin(a2) + 0.2 * sin(a3);
342
+ // The waves tilt the surface, so the light breaks on them
343
+ vec3 slope = vec3(1.5 * cos(a1) + 0.6 * cos(a3), 0.8 * cos(a1) + 0.6 * cos(a2), -0.72 * cos(a2) + cos(a3));
344
+ vec3 sphereNormal = aSphere - 2.5 * uWobble * (slope - dot(slope, aSphere) * aSphere);
345
+ // The mark is flat, the dots of the back of the sphere stay behind the ones of its front
346
+ vec3 markNormal = vec3(0.0, 0.0, aSphere.z >= 0.0 ? 1.0 : -1.0);
347
+ vec3 surfaceNormal = normalize(mix(sphereNormal, markNormal, settled));
348
+ vec3 normal = uRotation * surfaceNormal;
349
+ // The far side is not drawn at all
350
+ if (normal.z < -0.05) {
351
+ hide();
352
+ return;
353
+ }
354
+
355
+ // The eyes have dots of their own and rest while the surface wobbles. The dots of the sphere make room where they are now:
356
+ // a dot that wobbles through an eye would add to its dots and make it flicker.
357
+ vec3 sphere = sphereSurface(aSphere, settled);
358
+ float underEye = 1.0;
359
+ if (uEyes.w > 0.5 && aSphere.z > 0.0 && settled < 0.02) {
360
+ float open = uEyes.z;
361
+ vec2 size = vec2(${EYE_WIDTH.toFixed(1)} * (1.0 + 0.25 * (1.0 - open)), max(${EYE_HEIGHT.toFixed(1)} * open, 0.1)) * 0.5;
362
+ vec2 onFace = sphere.xy - uEyes.xy * ${GLANCE_AMPLITUDE.toFixed(1)};
363
+ float d = min(
364
+ pill(onFace, vec2(-${EYE_DX.toFixed(1)}, ${EYE_DY.toFixed(1)}), size),
365
+ pill(onFace, vec2(${EYE_DX.toFixed(1)}, ${EYE_DY.toFixed(1)}), size)
366
+ );
367
+ underEye = mix(1.0, smoothstep(2.5, 6.5, d), smoothstep(0.03, 0.18, open));
368
+ }
369
+
370
+ float sphereShown = twinkle(aSeed, uSphereDensity) * underEye;
371
+ float markShown = settled > 0.0 ? twinkle(aSeed, uDensity) : 0.0;
372
+ float shown = mix(sphereShown, markShown, settled);
373
+ if (shown <= 0.0) {
374
+ hide();
375
+ return;
376
+ }
377
+
378
+ float lit = settled > 0.0 ? markLit(aMark) : 0.0;
379
+ vec3 mark = settled > 0.0 ? markSurface(aMark) : vec3(0.0);
380
+ // A ripple runs over the surface while the dots are on their way
381
+ float ripple = 3.0 * sin(3.14159 * settled) * sin(6.0 * aSphere.x + 5.0 * aSphere.y + 4.0 * uTime);
382
+ project(mix(sphere, mark, settled) + surfaceNormal * ripple,
383
+ uSize * mix(1.0, 0.8 + 0.2 * markShown + 0.1 * lit, settled));
384
+
385
+ // An even body, lit only softly from the upper left so that its dots stay visible where no light falls. The edge gets
386
+ // only a hint of a rim.
387
+ float diffuse = max(dot(normal, normalize(vec3(-0.5, 0.68, 0.55))), 0.0);
388
+ float rim = pow(1.0 - max(normal.z, 0.0), 2.6);
389
+ // The crests of the waves are a little brighter
390
+ float crestWave = wave * (1.0 - settled);
391
+ float crest = 1.0 + 0.35 * crestWave;
392
+ // The dots of a sphere crowd together where it turns away and would add up to a bright outline
393
+ float crowd = mix(mix(0.4, 1.0, smoothstep(0.0, 0.5, normal.z)), 1.0, settled);
394
+ float sphereLight = (0.34 + 0.2 * diffuse + 0.05 * rim) * sphereShown;
395
+ float markLight = markShown * (0.6 + lit);
396
+ vAlpha = uContrast * crest * crowd * ${BODY_INK.toFixed(1)} * mix(sphereLight, markLight, settled) * switching;
397
+ float tone = mix(clamp(0.5 + 0.2 * diffuse + 0.05 * rim + 0.08 * crestWave, 0.0, 0.8), 0.55 + 0.3 * lit, settled);
398
+ vColor = ramp(tone);
399
+ }`;
400
+ var EYE_VERTEX = `${VERTEX_HEAD}
401
+ // The center of the eye on the face, and the place of the dot in the eye
402
+ in vec4 aEye;
403
+ uniform vec4 uEyes;
404
+ // The pixels of the canvas from its center to its edge
405
+ uniform vec2 uPixels;
406
+
407
+ void main() {
408
+ float open = uEyes.z;
409
+ const float R = ${SPHERE_RADIUS.toFixed(1)};
410
+ // The point between the eyes: both eyes move as one block, one of them must not step a frame before the other
411
+ vec2 onFace = vec2(0.0, aEye.y) + uEyes.xy * ${GLANCE_AMPLITUDE.toFixed(1)};
412
+ vec3 s = vec3(onFace, sqrt(max(0.0, R * R - dot(onFace, onFace)))) / R;
413
+ // Like on Wobble, the eyes do not follow the wobble of the surface: they rest while it moves around them
414
+ vec3 place = uRotation * s * R / ${UNITS_PER_PAGE.toFixed(1)} * uScale;
415
+ float perspective = 1.0 / (1.0 - place.z * ${PERSPECTIVE.toFixed(2)});
416
+ float pixelsPerUnit = uScale / ${UNITS_PER_PAGE.toFixed(1)} * uView.y * uPixels.y;
417
+ vec2 center = floor(place.xy * perspective * uView * uPixels) + 0.5 + vec2(floor(aEye.x * pixelsPerUnit + 0.5), 0.0);
418
+
419
+ // An even distance of the dots: half of it is the distance of the dots of a row with an even number of them to its middle
420
+ float pitch = max(4.0, 2.0 * floor(0.5 * ${EYE_DOT_SPACING.toFixed(1)} * pixelsPerUnit + 0.5));
421
+ // Rows at the same distance, the dots lie in a square grid
422
+ float rowPitch = pitch;
423
+ vec2 cell = aEye.zw / vec2(${EYE_DOT_SPACING.toFixed(1)}, ${(EYE_DOT_SPACING * .866).toFixed(4)});
424
+ // A blink squeezes the dots together, and the eye gets a little wider
425
+ vec2 fromCenter = floor(cell * vec2(pitch * (1.0 + 0.25 * (1.0 - open)), rowPitch * max(open, 0.04)) + 0.5);
426
+ gl_Position = vec4((center + fromCenter) / uPixels, 0.0, 1.0);
427
+ // An odd size has its center in the middle of a pixel
428
+ gl_PointSize = max(3.0, 2.0 * floor(0.75 * uSize * uDpr) + 1.0);
429
+ // Below full white: a dot that clips loses its soft edge
430
+ vAlpha = ${EYE_INK.toFixed(2)} * smoothstep(0.03, 0.18, open);
431
+ vColor = vec3(1.0);
432
+ }`;
433
+ var CLOUD_FRAGMENT = `#version 300 es
434
+ precision mediump float;
435
+ in float vAlpha;
436
+ in vec3 vColor;
437
+ out vec4 outColor;
438
+ void main() {
439
+ float a = smoothstep(0.5, 0.08, length(gl_PointCoord - 0.5)) * vAlpha;
440
+ outColor = vec4(vColor * a, a);
441
+ }`;
442
+ var PARTICLE_VERTEX = `${VERTEX_HEAD}
443
+ in vec4 aSeeds;
444
+ // If it joins a shape, and when it leaves
445
+ in vec2 aJoin;
446
+ in float aTwinkle;
447
+ // The dot of the shape that the particle becomes if it joins
448
+ in vec3 aSphere;
449
+ in vec2 aMark;
450
+ in float aLag;
451
+ in float aMarkSeed;
452
+ uniform float uOuterWobble;
453
+ uniform float uGap;
454
+ uniform float uRingDensity;
455
+ uniform float uRingInk;
456
+ // Do the particles fly out of the shape at this switch, or into it
457
+ uniform float uOutward;
458
+
459
+ void main() {
460
+ float a = aSeeds.x, b = aSeeds.y, c = aSeeds.z, d = aSeeds.w;
461
+ const float R = ${SPHERE_RADIUS.toFixed(1)};
462
+
463
+ float start = aJoin.y * ${JOIN_SPREAD.toFixed(2)} * uFly;
464
+ float arrive;
465
+ float handover;
466
+ if (uOutward > 0.5) {
467
+ // The globe turns into the brand mark and throws particles off: each fades out in the ring at its own moment, fades in
468
+ // on the shape and flies out to where it came from
469
+ float swapEnd = start + ${JOIN_SWAP.toFixed(2)} * uFly;
470
+ float swap = smoothstep(start, swapEnd, uSwitch);
471
+ handover = aJoin.x > 0.5 ? abs(2.0 * swap - 1.0) : 1.0;
472
+ arrive = aJoin.x > 0.5 && swap > 0.5 ? 1.0 - smoothstep(swapEnd, swapEnd + uFly, uSwitch) : 0.0;
473
+ } else {
474
+ // The brand mark turns into the globe and draws particles in: each leaves at its own moment, arcs to its dot and rides
475
+ // along with it. Later it fades out there and fades in again where it came from, it never flies back.
476
+ arrive = aJoin.x * smoothstep(start, start + uFly, uSwitch);
477
+ float leaveAt = start + uFly * (1.0 + ${JOIN_HOLD.toFixed(2)});
478
+ float release = smoothstep(leaveAt, leaveAt + 0.6, uSwitch);
479
+ handover = aJoin.x > 0.5 ? abs(2.0 * release - 1.0) : 1.0;
480
+ if (release > 0.5) arrive = 0.0;
481
+ }
482
+
483
+ // Most of the time most particles are just part of the ring, and many of them are hidden
484
+ float shown = twinkle(aTwinkle, uRingDensity);
485
+ if (arrive <= 0.0 && shown <= 0.0) {
486
+ hide();
487
+ return;
488
+ }
489
+
490
+ // A thin ring that lies at a slant, like the rings of a planet
491
+ float angle = a * 6.28318 + uTime * (0.05 + 0.05 * c);
492
+ float radius = R * (uGap + ${RING_WIDTH.toFixed(2)} * b * b);
493
+ vec3 p = vec3(cos(angle) * radius, (c - 0.5) * R * 0.1, sin(angle) * radius);
494
+ const float SLANT_COS = ${Math.cos(1.2).toFixed(6)};
495
+ const float SLANT_SIN = ${Math.sin(1.2).toFixed(6)};
496
+ const float ROLL_COS = ${Math.cos(.32).toFixed(6)};
497
+ const float ROLL_SIN = ${Math.sin(.32).toFixed(6)};
498
+ p = vec3(p.x, p.y * SLANT_COS - p.z * SLANT_SIN, p.y * SLANT_SIN + p.z * SLANT_COS);
499
+ p = vec3(p.x * ROLL_COS - p.y * ROLL_SIN, p.x * ROLL_SIN + p.y * ROLL_COS, p.z);
500
+
501
+ // The same harmonics as the sphere, slower: the whole ring wobbles a little
502
+ vec3 u = p / length(p);
503
+ float wave = 0.5 * sin(3.0 * u.x + 1.6 * u.y + 0.9 * uTime)
504
+ + 0.3 * sin(2.0 * u.y - 2.4 * u.z - 0.6 * uTime + 1.7)
505
+ + 0.2 * sin(5.0 * u.z + 3.0 * u.x + 1.4 * uTime + 0.4);
506
+ // A switch shakes the ring up: its wobble flares and settles, it keeps its form
507
+ float shaken = exp(-uSwitch * 1.5);
508
+ p *= 1.0 + (uOuterWobble + 0.1 * shaken) * wave;
509
+ if (shaken > 0.01) {
510
+ p += shaken * R * 0.02 * vec3(sin(uTime * 19.0 + a * 60.0), sin(uTime * 23.0 + b * 60.0), sin(uTime * 17.0 + c * 60.0));
511
+ }
512
+
513
+ float depth = p.z / R;
514
+ // The far ones are dim, they lie behind the shape. They twinkle slowly as well.
515
+ float ringAlpha = uRingInk * shown * (0.7 + 0.3 * sin(uTime * (0.4 + 0.8 * c) + a * 40.0)) * (0.3 + 0.9 * d) * mix(0.5, 1.0, smoothstep(-1.0, 0.6, depth));
516
+ float ringTone = 0.5 + 0.35 * d;
517
+ float ringSize = 1.3 + 1.5 * d * d;
518
+
519
+ // Only the particles on their way or on a shape need the shape
520
+ if (arrive > 0.0) {
521
+ float landed = settledAt(aLag);
522
+ float markShown = landed > 0.0 ? twinkle(aMarkSeed, uDensity) : 0.0;
523
+ float lit = landed > 0.0 ? markLit(aMark) : 0.0;
524
+ vec3 onShape = mix(sphereSurface(aSphere, landed), landed > 0.0 ? markSurface(aMark) : vec3(0.0), landed);
525
+ p = mix(p, onShape, arrive);
526
+ // The way there is an arc
527
+ p.xy += vec2(-onShape.y, onShape.x) * 0.45 * sin(3.14159 * arrive);
528
+ project(p, mix(ringSize, uSize * mix(1.0, 0.8 + 0.2 * markShown + 0.1 * lit, landed), arrive));
529
+ // On the shape it looks like the dots of the shape
530
+ vAlpha = handover * uContrast * mix(ringAlpha, mix(1.6, ${BODY_INK.toFixed(1)} * markShown * (0.6 + lit), landed), arrive);
531
+ vColor = ramp(mix(ringTone, mix(0.55, 0.55 + 0.3 * lit, landed), arrive));
532
+ } else {
533
+ project(p, ringSize);
534
+ vAlpha = handover * uContrast * ringAlpha;
535
+ vColor = ramp(ringTone);
536
+ }
537
+ if (vAlpha < 0.002) hide();
538
+ }`;
539
+ function createProgram(gl, vertex, fragment) {
540
+ const program = gl.createProgram();
541
+ for (const [type, source] of [[gl.VERTEX_SHADER, vertex], [gl.FRAGMENT_SHADER, fragment]]) {
542
+ const shader = gl.createShader(type);
543
+ gl.shaderSource(shader, source);
544
+ gl.compileShader(shader);
545
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) throw new Error(`Shader: ${gl.getShaderInfoLog(shader)}`);
546
+ gl.attachShader(program, shader);
547
+ gl.deleteShader(shader);
548
+ }
549
+ gl.linkProgram(program);
550
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) throw new Error(`Program: ${gl.getProgramInfoLog(program)}`);
551
+ return program;
552
+ }
553
+ function createVertices(gl, program, floatsPerVertex, data, attributes) {
554
+ const vao = gl.createVertexArray();
555
+ const buffer = gl.createBuffer();
556
+ gl.bindVertexArray(vao);
557
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
558
+ gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
559
+ for (const [name, size, offset] of attributes) {
560
+ const location = gl.getAttribLocation(program, name);
561
+ if (location < 0) continue;
562
+ gl.enableVertexAttribArray(location);
563
+ gl.vertexAttribPointer(location, size, gl.FLOAT, false, floatsPerVertex * 4, offset * 4);
564
+ }
565
+ gl.bindVertexArray(null);
566
+ return {
567
+ vao,
568
+ buffer
569
+ };
570
+ }
571
+ function uniformLocations(gl, program, names) {
572
+ const locations = {};
573
+ for (const name of names) locations[name] = gl.getUniformLocation(program, name);
574
+ return locations;
575
+ }
576
+ var SHARED_UNIFORMS = [
577
+ "uView",
578
+ "uTime",
579
+ "uMorph",
580
+ "uDpr",
581
+ "uContrast",
582
+ "uScale",
583
+ "uRotation",
584
+ "uSize",
585
+ "uWobble",
586
+ "uMarkWobble",
587
+ "uLight",
588
+ "uGlow",
589
+ "uDensity",
590
+ "uTwinkle",
591
+ "uSwitch",
592
+ "uFly"
593
+ ];
594
+ var NO_BACKDROP = {
595
+ update: () => {},
596
+ dispose: () => {}
597
+ };
598
+ function attachLandingBackdrop(host, options) {
599
+ const { brand, motion, dots, particles } = options;
600
+ const latest = { current: options };
601
+ const ringCanvas = document.createElement("canvas");
602
+ const shapeCanvas = document.createElement("canvas");
603
+ for (const canvas of [ringCanvas, shapeCanvas]) {
604
+ canvas.style.position = "absolute";
605
+ canvas.style.display = "block";
606
+ canvas.setAttribute("aria-hidden", "true");
607
+ }
608
+ host.append(ringCanvas, shapeCanvas);
609
+ const attributes = {
610
+ alpha: true,
611
+ premultipliedAlpha: true,
612
+ antialias: false,
613
+ depth: false,
614
+ stencil: false,
615
+ powerPreference: "low-power"
616
+ };
617
+ const ringGl = ringCanvas.getContext("webgl2", attributes);
618
+ const shapeGl = shapeCanvas.getContext("webgl2", attributes);
619
+ if (ringGl == null || shapeGl == null) {
620
+ console.warn("The backdrop needs WebGL2");
621
+ ringCanvas.remove();
622
+ shapeCanvas.remove();
623
+ return NO_BACKDROP;
624
+ }
625
+ let cloudProgram;
626
+ let eyeProgram;
627
+ let particleProgram;
628
+ try {
629
+ cloudProgram = createProgram(shapeGl, CLOUD_VERTEX, CLOUD_FRAGMENT);
630
+ eyeProgram = createProgram(shapeGl, EYE_VERTEX, CLOUD_FRAGMENT);
631
+ particleProgram = createProgram(ringGl, PARTICLE_VERTEX, CLOUD_FRAGMENT);
632
+ } catch (error) {
633
+ console.error(error);
634
+ ringCanvas.remove();
635
+ shapeCanvas.remove();
636
+ return NO_BACKDROP;
637
+ }
638
+ const drawnDots = Math.ceil(dots * DRAWN_SHARE);
639
+ const cloudVertices = createVertices(shapeGl, cloudProgram, CLOUD_FLOATS, buildCloud(brand, dots), [
640
+ [
641
+ "aSphere",
642
+ 3,
643
+ 0
644
+ ],
645
+ [
646
+ "aMark",
647
+ 2,
648
+ 3
649
+ ],
650
+ [
651
+ "aLag",
652
+ 1,
653
+ 5
654
+ ],
655
+ [
656
+ "aSeed",
657
+ 1,
658
+ 6
659
+ ]
660
+ ]);
661
+ const particleVertices = createVertices(ringGl, particleProgram, PARTICLE_FLOATS, buildParticles(brand, dots, particles), [
662
+ [
663
+ "aSeeds",
664
+ 4,
665
+ 0
666
+ ],
667
+ [
668
+ "aJoin",
669
+ 2,
670
+ 4
671
+ ],
672
+ [
673
+ "aTwinkle",
674
+ 1,
675
+ 6
676
+ ],
677
+ [
678
+ "aSphere",
679
+ 3,
680
+ 7
681
+ ],
682
+ [
683
+ "aMark",
684
+ 2,
685
+ 10
686
+ ],
687
+ [
688
+ "aLag",
689
+ 1,
690
+ 12
691
+ ],
692
+ [
693
+ "aMarkSeed",
694
+ 1,
695
+ 13
696
+ ]
697
+ ]);
698
+ const eyeData = buildEyes();
699
+ const eyeVertices = createVertices(shapeGl, eyeProgram, 4, eyeData, [[
700
+ "aEye",
701
+ 4,
702
+ 0
703
+ ]]);
704
+ const eyeUniforms = uniformLocations(shapeGl, eyeProgram, [
705
+ ...SHARED_UNIFORMS,
706
+ "uEyes",
707
+ "uPixels"
708
+ ]);
709
+ const cloudUniforms = uniformLocations(shapeGl, cloudProgram, [
710
+ ...SHARED_UNIFORMS,
711
+ "uSphereDensity",
712
+ "uEyes"
713
+ ]);
714
+ const particleUniforms = uniformLocations(ringGl, particleProgram, [
715
+ ...SHARED_UNIFORMS,
716
+ "uOuterWobble",
717
+ "uGap",
718
+ "uRingDensity",
719
+ "uRingInk",
720
+ "uOutward"
721
+ ]);
722
+ for (const gl of [ringGl, shapeGl]) {
723
+ gl.enable(gl.BLEND);
724
+ gl.blendFunc(gl.ONE, gl.ONE);
725
+ }
726
+ ringGl.clearColor(0, 0, 0, 0);
727
+ shapeGl.clearColor(0, 0, 0, 0);
728
+ let markReach = 0;
729
+ for (const piece of brand.pieces) {
730
+ const [minX, minY, maxX, maxY] = outlineBounds(piece.logo);
731
+ markReach = Math.max(markReach, 100 - minX, maxX - 100, 100 - minY, maxY - 100);
732
+ }
733
+ let dpr = 1;
734
+ const ringView = {
735
+ x: 1,
736
+ y: 1
737
+ };
738
+ const shapeView = {
739
+ x: 1,
740
+ y: 1
741
+ };
742
+ const place = (canvas, gl, view, reach, towardsViewer) => {
743
+ const current = latest.current;
744
+ const pageWidth = host.clientWidth, pageHeight = host.clientHeight;
745
+ const perspective = 1 / Math.max(.2, 1 - towardsViewer * (reach / UNITS_PER_PAGE) * current.scale * PERSPECTIVE);
746
+ const halfSide = reach / UNITS_PER_PAGE * current.scale * perspective * (pageHeight / 2) + 8;
747
+ const pageDeviceWidth = Math.round(pageWidth * dpr), pageDeviceHeight = Math.round(pageHeight * dpr);
748
+ const deviceWidth = Math.min(pageDeviceWidth, 2 * Math.ceil(halfSide * dpr));
749
+ const deviceHeight = Math.min(pageDeviceHeight, 2 * Math.ceil(halfSide * dpr));
750
+ canvas.width = Math.max(1, deviceWidth);
751
+ canvas.height = Math.max(1, deviceHeight);
752
+ canvas.style.width = `${deviceWidth / dpr}px`;
753
+ canvas.style.height = `${deviceHeight / dpr}px`;
754
+ canvas.style.left = `${Math.floor((pageDeviceWidth - deviceWidth) / 2) / dpr}px`;
755
+ canvas.style.top = `${Math.floor((pageDeviceHeight - deviceHeight) / 2) / dpr}px`;
756
+ view.x = pageHeight / Math.max(1, deviceWidth / dpr);
757
+ view.y = pageHeight / Math.max(1, deviceHeight / dpr);
758
+ gl.viewport(0, 0, canvas.width, canvas.height);
759
+ };
760
+ let layoutKey = "";
761
+ const layout = () => {
762
+ const current = latest.current;
763
+ const key = `${host.clientWidth} ${host.clientHeight} ${window.devicePixelRatio} ${current.scale} ${current.gap} ${current.outerWobble} ${current.wobble} ${current.markWobble}`;
764
+ if (key === layoutKey) return;
765
+ layoutKey = key;
766
+ dpr = window.devicePixelRatio;
767
+ place(ringCanvas, ringGl, ringView, (current.gap + RING_WIDTH) * SPHERE_RADIUS * (1.04 + current.outerWobble), RING_REACH_TOWARDS_VIEWER);
768
+ place(shapeCanvas, shapeGl, shapeView, Math.max(SPHERE_RADIUS * (1 + 1.4 * current.wobble), markReach + SPHERE_RADIUS * 1.5 * current.markWobble) + 4, 1);
769
+ };
770
+ layout();
771
+ const pointer = {
772
+ x: 0,
773
+ y: 0
774
+ };
775
+ const aim = {
776
+ x: 0,
777
+ y: 0
778
+ };
779
+ let lastPointerMove = -Infinity;
780
+ const onPointerMove = (event) => {
781
+ lastPointerMove = performance.now();
782
+ const rect = host.getBoundingClientRect();
783
+ aim.x = (event.clientX - rect.left) / rect.width * 2 - 1;
784
+ aim.y = (event.clientY - rect.top) / rect.height * 2 - 1;
785
+ };
786
+ window.addEventListener("pointermove", onPointerMove, { passive: true });
787
+ const morph = {
788
+ value: motion ? 0 : 1,
789
+ velocity: 0
790
+ };
791
+ const glance = {
792
+ value: 0,
793
+ velocity: 0
794
+ };
795
+ const look = {
796
+ value: 0,
797
+ velocity: 0
798
+ };
799
+ let glanceTarget = 0;
800
+ let nextGlance = performance.now() + GLANCE_INTERVAL_MS;
801
+ let nextBlink = performance.now() + BLINK_INTERVAL_MS;
802
+ let eyesOpen = motion ? 1 : 0;
803
+ let time = 0;
804
+ let lightAngle = LIGHT_STILL_ANGLE;
805
+ let switchedAt = -100;
806
+ let lastTarget = 0;
807
+ const setShared = (gl, view, u, rotation) => {
808
+ const current = latest.current;
809
+ gl.uniform2f(u.uView, view.x, view.y);
810
+ gl.uniform1f(u.uTime, time);
811
+ gl.uniform1f(u.uMorph, morph.value);
812
+ gl.uniform1f(u.uDpr, dpr);
813
+ gl.uniform1f(u.uContrast, current.contrast);
814
+ gl.uniform1f(u.uScale, current.scale);
815
+ gl.uniformMatrix3fv(u.uRotation, false, rotation);
816
+ gl.uniform1f(u.uSize, DOT_SIZE * Math.pow(4e4 / dots, .25) * Math.sqrt(current.scale / .8));
817
+ gl.uniform1f(u.uWobble, current.wobble);
818
+ gl.uniform1f(u.uMarkWobble, current.markWobble);
819
+ gl.uniform2f(u.uLight, LIGHT_CIRCLE * Math.cos(lightAngle), LIGHT_CIRCLE * Math.sin(lightAngle));
820
+ gl.uniform1f(u.uGlow, current.glow);
821
+ gl.uniform1f(u.uDensity, motion ? current.density : 1);
822
+ gl.uniform1f(u.uTwinkle, current.twinkleSeconds);
823
+ gl.uniform1f(u.uSwitch, time - switchedAt);
824
+ gl.uniform1f(u.uFly, current.fly);
825
+ };
826
+ const drawVisible = (gl, count, density) => {
827
+ if (density >= .99) {
828
+ gl.drawArrays(gl.POINTS, 0, count);
829
+ return;
830
+ }
831
+ const phase = time / latest.current.twinkleSeconds;
832
+ const start = Math.floor((1 - (phase - Math.floor(phase))) * count) % count;
833
+ const length = Math.min(count, Math.ceil(density * count) + 2);
834
+ if (start + length <= count) gl.drawArrays(gl.POINTS, start, length);
835
+ else {
836
+ gl.drawArrays(gl.POINTS, start, count - start);
837
+ gl.drawArrays(gl.POINTS, 0, start + length - count);
838
+ }
839
+ };
840
+ const rotationNow = () => {
841
+ const yaw = (motion ? Math.sin(time * .33) * .02 : 0) + pointer.x * .02, pitch = pointer.y * .015;
842
+ const cy = Math.cos(yaw), sy = Math.sin(yaw), cp = Math.cos(pitch), sp = Math.sin(pitch);
843
+ return [
844
+ cy,
845
+ sp * sy,
846
+ -cp * sy,
847
+ 0,
848
+ cp,
849
+ sp,
850
+ sy,
851
+ -sp * cy,
852
+ cp * cy
853
+ ];
854
+ };
855
+ const drawShape = () => {
856
+ const current = latest.current;
857
+ const gl = shapeGl;
858
+ layout();
859
+ gl.clear(gl.COLOR_BUFFER_BIT);
860
+ const rotation = rotationNow();
861
+ gl.useProgram(cloudProgram);
862
+ setShared(gl, shapeView, cloudUniforms, rotation);
863
+ const sphereDensity = motion ? current.sphereDensity : 1;
864
+ gl.uniform1f(cloudUniforms.uSphereDensity, sphereDensity);
865
+ const blinkT = (performance.now() - nextBlink) / BLINK_MS;
866
+ const blink = blinkT > 0 && blinkT < 1 ? Math.abs(2 * blinkT - 1) : 1;
867
+ const open = eyesOpen * blink;
868
+ gl.uniform4f(cloudUniforms.uEyes, glance.value, look.value, open, current.eyes ? 1 : 0);
869
+ gl.bindVertexArray(cloudVertices.vao);
870
+ if (morph.value < .001) drawVisible(gl, drawnDots, sphereDensity);
871
+ else if (morph.value > .999) drawVisible(gl, drawnDots, motion ? current.density : 1);
872
+ else gl.drawArrays(gl.POINTS, 0, drawnDots);
873
+ if (current.eyes && open > .03) {
874
+ gl.useProgram(eyeProgram);
875
+ setShared(gl, shapeView, eyeUniforms, rotation);
876
+ gl.uniform4f(eyeUniforms.uEyes, glance.value, look.value, open, 1);
877
+ gl.uniform2f(eyeUniforms.uPixels, shapeCanvas.width / 2, shapeCanvas.height / 2);
878
+ gl.bindVertexArray(eyeVertices.vao);
879
+ gl.drawArrays(gl.POINTS, 0, eyeData.length / 4);
880
+ }
881
+ };
882
+ const drawRing = () => {
883
+ const current = latest.current;
884
+ const gl = ringGl;
885
+ layout();
886
+ gl.clear(gl.COLOR_BUFFER_BIT);
887
+ if (particles === 0) return;
888
+ gl.useProgram(particleProgram);
889
+ setShared(gl, ringView, particleUniforms, rotationNow());
890
+ gl.uniform1f(particleUniforms.uOuterWobble, current.outerWobble);
891
+ gl.uniform1f(particleUniforms.uGap, current.gap);
892
+ gl.uniform1f(particleUniforms.uOutward, lastTarget === 1 ? 1 : 0);
893
+ const ringDensity = motion ? current.ringDensity : 1;
894
+ gl.uniform1f(particleUniforms.uRingInk, current.ringInk);
895
+ gl.uniform1f(particleUniforms.uRingDensity, ringDensity);
896
+ gl.bindVertexArray(particleVertices.vao);
897
+ if (time - switchedAt < current.fly * 4 + .7) gl.drawArrays(gl.POINTS, 0, particles);
898
+ else drawVisible(gl, particles, ringDensity);
899
+ };
900
+ const debugInfo = shapeGl.getExtension("WEBGL_debug_renderer_info");
901
+ const renderer = String(debugInfo == null ? shapeGl.getParameter(shapeGl.RENDERER) : shapeGl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL));
902
+ let frame = 0;
903
+ let last = performance.now();
904
+ let lastShapeDraw = 0;
905
+ let lastRingDraw = 0;
906
+ let frames = 0;
907
+ let statsFrom = last;
908
+ let onScreen = true;
909
+ const render = (now) => {
910
+ if (!onScreen) {
911
+ frame = 0;
912
+ return;
913
+ }
914
+ frame = requestAnimationFrame(render);
915
+ const current = latest.current;
916
+ const dt = Math.min((now - last) / 1e3, 1 / 20);
917
+ last = now;
918
+ time += dt;
919
+ lightAngle += dt * 2 * Math.PI / current.lightSeconds;
920
+ const phase = time / current.period % 1;
921
+ const target = phase > .1 && phase < .6 ? 1 : 0;
922
+ if (!springAtRest(morph, target)) stepSpring(morph, target, MORPH_STIFFNESS, MORPH_DAMPING, dt);
923
+ if (target !== lastTarget) {
924
+ lastTarget = target;
925
+ switchedAt = time;
926
+ }
927
+ const eyesTarget = target === 0 && morph.value < .05 ? 1 : 0;
928
+ const eyesStep = dt * 1e3 / EYES_CLOSE_MS;
929
+ eyesOpen = eyesTarget > eyesOpen ? Math.min(eyesTarget, eyesOpen + eyesStep) : Math.max(eyesTarget, eyesOpen - eyesStep);
930
+ let lookTarget = 0;
931
+ if (now - lastPointerMove < POINTER_IDLE_MS) {
932
+ glanceTarget = Math.max(-1, Math.min(1, aim.x * 1.6));
933
+ lookTarget = Math.max(-1, Math.min(1, -aim.y * 1.6));
934
+ nextGlance = now + GLANCE_INTERVAL_MS;
935
+ } else if (now >= nextGlance) {
936
+ const choices = [
937
+ -1,
938
+ -.6,
939
+ 0,
940
+ .6,
941
+ 1
942
+ ].filter((choice) => choice !== glanceTarget);
943
+ glanceTarget = choices[Math.floor(Math.random() * choices.length)];
944
+ nextGlance = now + GLANCE_INTERVAL_MS * (.8 + .4 * Math.random());
945
+ }
946
+ stepSpring(glance, eyesTarget === 1 ? glanceTarget : 0, GLANCE_STIFFNESS, GLANCE_DAMPING, dt);
947
+ stepSpring(look, eyesTarget === 1 ? lookTarget : 0, GLANCE_STIFFNESS, GLANCE_DAMPING, dt);
948
+ if (now >= nextBlink + BLINK_MS) nextBlink = now + BLINK_INTERVAL_MS * (.8 + .4 * Math.random());
949
+ const follow = 1 - Math.exp(-dt * 3);
950
+ pointer.x += (aim.x - pointer.x) * follow;
951
+ pointer.y += (aim.y - pointer.y) * follow;
952
+ const flying = time - switchedAt < current.fly * 2.7;
953
+ if (now - lastShapeDraw >= (flying ? FAST_FRAME_MS : REST_FRAME_MS) - 2) {
954
+ lastShapeDraw = now;
955
+ drawShape();
956
+ frames += 1;
957
+ if (now - lastRingDraw >= (flying ? FAST_FRAME_MS : 1e3 / current.ringFps) - 2) {
958
+ lastRingDraw = now;
959
+ drawRing();
960
+ }
961
+ }
962
+ if (now - statsFrom >= 1e3) {
963
+ current.onStats?.({
964
+ fps: Math.round(frames * 1e3 / (now - statsFrom)),
965
+ renderer
966
+ });
967
+ frames = 0;
968
+ statsFrom = now;
969
+ }
970
+ };
971
+ const drawAll = () => {
972
+ drawRing();
973
+ drawShape();
974
+ };
975
+ const visibility = new IntersectionObserver((entries) => {
976
+ onScreen = entries[entries.length - 1].isIntersecting;
977
+ if (onScreen && motion && frame === 0) {
978
+ last = performance.now();
979
+ frame = requestAnimationFrame(render);
980
+ }
981
+ });
982
+ visibility.observe(host);
983
+ const observer = new ResizeObserver(() => {
984
+ layout();
985
+ if (!motion) drawAll();
986
+ });
987
+ observer.observe(host);
988
+ if (motion) frame = requestAnimationFrame(render);
989
+ else drawAll();
990
+ const dispose = () => {
991
+ cancelAnimationFrame(frame);
992
+ observer.disconnect();
993
+ visibility.disconnect();
994
+ window.removeEventListener("pointermove", onPointerMove);
995
+ shapeGl.deleteBuffer(cloudVertices.buffer);
996
+ shapeGl.deleteVertexArray(cloudVertices.vao);
997
+ shapeGl.deleteBuffer(eyeVertices.buffer);
998
+ shapeGl.deleteVertexArray(eyeVertices.vao);
999
+ shapeGl.deleteProgram(cloudProgram);
1000
+ shapeGl.deleteProgram(eyeProgram);
1001
+ ringGl.deleteBuffer(particleVertices.buffer);
1002
+ ringGl.deleteVertexArray(particleVertices.vao);
1003
+ ringGl.deleteProgram(particleProgram);
1004
+ for (const gl of [ringGl, shapeGl]) gl.getExtension("WEBGL_lose_context")?.loseContext();
1005
+ ringCanvas.remove();
1006
+ shapeCanvas.remove();
1007
+ };
1008
+ return {
1009
+ update(options) {
1010
+ latest.current = {
1011
+ ...latest.current,
1012
+ ...options
1013
+ };
1014
+ if (!motion) drawAll();
1015
+ },
1016
+ dispose
1017
+ };
1018
+ }
1019
+ export { CLOUD_DENSITIES, DEFAULT_LANDING_BACKDROP, attachLandingBackdrop };