@sharadox/globe-web-library 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/LICENCA.md +76 -0
  2. package/LICENSE.md +76 -0
  3. package/NOTICE.md +3 -0
  4. package/README.md +60 -2
  5. package/distribution/arc/index.d.ts +4 -0
  6. package/distribution/arc/index.d.ts.map +1 -0
  7. package/distribution/arc/index.js +29 -0
  8. package/distribution/arc/index.js.map +1 -0
  9. package/distribution/arc/type.d.ts +12 -0
  10. package/distribution/arc/type.d.ts.map +1 -0
  11. package/distribution/arc/type.js +2 -0
  12. package/distribution/arc/type.js.map +1 -0
  13. package/distribution/color/index.d.ts +9 -0
  14. package/distribution/color/index.d.ts.map +1 -0
  15. package/distribution/color/index.js +11 -0
  16. package/distribution/color/index.js.map +1 -0
  17. package/distribution/color/type.d.ts +20 -0
  18. package/distribution/color/type.d.ts.map +1 -0
  19. package/distribution/color/type.js +2 -0
  20. package/distribution/color/type.js.map +1 -0
  21. package/distribution/dots/index.d.ts +4 -0
  22. package/distribution/dots/index.d.ts.map +1 -0
  23. package/distribution/dots/index.js +38 -0
  24. package/distribution/dots/index.js.map +1 -0
  25. package/distribution/dots/type.d.ts +7 -0
  26. package/distribution/dots/type.d.ts.map +1 -0
  27. package/distribution/dots/type.js +2 -0
  28. package/distribution/dots/type.js.map +1 -0
  29. package/distribution/drag-controller/index.d.ts +11 -0
  30. package/distribution/drag-controller/index.d.ts.map +1 -0
  31. package/distribution/drag-controller/index.js +65 -0
  32. package/distribution/drag-controller/index.js.map +1 -0
  33. package/distribution/drag-controller/type.d.ts +26 -0
  34. package/distribution/drag-controller/type.d.ts.map +1 -0
  35. package/distribution/drag-controller/type.js +2 -0
  36. package/distribution/drag-controller/type.js.map +1 -0
  37. package/distribution/globe/index.d.ts +12 -0
  38. package/distribution/globe/index.d.ts.map +1 -0
  39. package/distribution/globe/index.js +38 -0
  40. package/distribution/globe/index.js.map +1 -0
  41. package/distribution/globe/index.module.css +37 -0
  42. package/distribution/globe/type.d.ts +16 -0
  43. package/distribution/globe/type.d.ts.map +1 -0
  44. package/distribution/globe/type.js +2 -0
  45. package/distribution/globe/type.js.map +1 -0
  46. package/distribution/globe-drag/index.d.ts +7 -0
  47. package/distribution/globe-drag/index.d.ts.map +1 -0
  48. package/distribution/globe-drag/index.js +49 -0
  49. package/distribution/globe-drag/index.js.map +1 -0
  50. package/distribution/hex-channel/index.d.ts +3 -0
  51. package/distribution/hex-channel/index.d.ts.map +1 -0
  52. package/distribution/hex-channel/index.js +8 -0
  53. package/distribution/hex-channel/index.js.map +1 -0
  54. package/distribution/land-point-generator/entry/index.d.ts +3 -0
  55. package/distribution/land-point-generator/entry/index.d.ts.map +1 -0
  56. package/distribution/land-point-generator/entry/index.js +13 -0
  57. package/distribution/land-point-generator/entry/index.js.map +1 -0
  58. package/distribution/land-point-generator/index.d.ts +10 -0
  59. package/distribution/land-point-generator/index.d.ts.map +1 -0
  60. package/distribution/land-point-generator/index.js +23 -0
  61. package/distribution/land-point-generator/index.js.map +1 -0
  62. package/distribution/land-points/index.d.ts +6 -0
  63. package/distribution/land-points/index.d.ts.map +1 -0
  64. package/distribution/land-points/index.js +20 -0
  65. package/distribution/land-points/index.js.map +1 -0
  66. package/distribution/latitude-longitude-to-vector/index.d.ts +7 -0
  67. package/distribution/latitude-longitude-to-vector/index.d.ts.map +1 -0
  68. package/distribution/latitude-longitude-to-vector/index.js +12 -0
  69. package/distribution/latitude-longitude-to-vector/index.js.map +1 -0
  70. package/distribution/marker/index.d.ts +4 -0
  71. package/distribution/marker/index.d.ts.map +1 -0
  72. package/distribution/marker/index.js +21 -0
  73. package/distribution/marker/index.js.map +1 -0
  74. package/distribution/marker/type.d.ts +9 -0
  75. package/distribution/marker/type.d.ts.map +1 -0
  76. package/distribution/marker/type.js +2 -0
  77. package/distribution/marker/type.js.map +1 -0
  78. package/distribution/place/type.d.ts +6 -0
  79. package/distribution/place/type.d.ts.map +1 -0
  80. package/distribution/place/type.js +2 -0
  81. package/distribution/place/type.js.map +1 -0
  82. package/distribution/shader/arc/index.d.ts +6 -0
  83. package/distribution/shader/arc/index.d.ts.map +1 -0
  84. package/distribution/shader/arc/index.js +24 -0
  85. package/distribution/shader/arc/index.js.map +1 -0
  86. package/distribution/shader/atmosphere/index.d.ts +6 -0
  87. package/distribution/shader/atmosphere/index.d.ts.map +1 -0
  88. package/distribution/shader/atmosphere/index.js +15 -0
  89. package/distribution/shader/atmosphere/index.js.map +1 -0
  90. package/distribution/shader/body/index.d.ts +6 -0
  91. package/distribution/shader/body/index.d.ts.map +1 -0
  92. package/distribution/shader/body/index.js +15 -0
  93. package/distribution/shader/body/index.js.map +1 -0
  94. package/distribution/shader/dot/index.d.ts +6 -0
  95. package/distribution/shader/dot/index.d.ts.map +1 -0
  96. package/distribution/shader/dot/index.js +29 -0
  97. package/distribution/shader/dot/index.js.map +1 -0
  98. package/distribution/shader/glow-vertex/index.d.ts +3 -0
  99. package/distribution/shader/glow-vertex/index.d.ts.map +1 -0
  100. package/distribution/shader/glow-vertex/index.js +9 -0
  101. package/distribution/shader/glow-vertex/index.js.map +1 -0
  102. package/distribution/web-gl-support/index.d.ts +3 -0
  103. package/distribution/web-gl-support/index.d.ts.map +1 -0
  104. package/distribution/web-gl-support/index.js +11 -0
  105. package/distribution/web-gl-support/index.js.map +1 -0
  106. package/distribution/world/index.d.ts +4 -0
  107. package/distribution/world/index.d.ts.map +1 -0
  108. package/distribution/world/index.js +38 -0
  109. package/distribution/world/index.js.map +1 -0
  110. package/distribution/world/type.d.ts +15 -0
  111. package/distribution/world/type.d.ts.map +1 -0
  112. package/distribution/world/type.js +2 -0
  113. package/distribution/world/type.js.map +1 -0
  114. package/llms.txt +10 -0
  115. package/package.json +103 -3
package/LICENCA.md ADDED
@@ -0,0 +1,76 @@
1
+ # Licença Sharadox de Código Aberto
2
+
3
+ Versão 0.1.0
4
+
5
+ O texto em língua portuguesa é o único texto original e vinculativo desta licença. A tradução para inglês (`LICENSE.md`) é meramente informativa; em caso de divergência prevalece o texto em português.
6
+
7
+ ## 1. Definições
8
+
9
+ Para efeitos desta licença:
10
+
11
+ 1. **«Obra»** — o programa de computador, a sua documentação e quaisquer outros conteúdos disponibilizados pelo Licenciante ao abrigo desta licença, em código-fonte ou em qualquer outra forma.
12
+ 2. **«Licenciante»** — o titular dos direitos de autor identificado no aviso de direitos de autor que acompanha a Obra.
13
+ 3. **«Licenciado»** — qualquer pessoa, singular ou coletiva, que exerça os direitos concedidos por esta licença.
14
+ 4. **«Obra Derivada»** — qualquer obra baseada na Obra ou que a incorpore, total ou parcialmente, com ou sem modificações, incluindo traduções, adaptações e programas que a integrem.
15
+ 5. **«Aviso»** — o aviso de direitos de autor do Licenciante e a indicação de que a Obra está licenciada ao abrigo desta licença, incluindo a respetiva versão.
16
+
17
+ ## 2. Concessão de direitos
18
+
19
+ 1. Nos termos desta licença, o Licenciante concede ao Licenciado uma licença mundial, gratuita, não exclusiva e por todo o prazo de proteção dos direitos de autor para:
20
+ 1. utilizar a Obra para qualquer finalidade, incluindo finalidades comerciais;
21
+ 2. reproduzir a Obra, total ou parcialmente, por qualquer meio e sob qualquer forma;
22
+ 3. modificar, traduzir, adaptar e transformar a Obra e criar Obras Derivadas;
23
+ 4. distribuir, publicar, comunicar ao público, colocar à disposição, vender e sublicenciar a Obra e as Obras Derivadas.
24
+ 2. Na medida em que o Licenciante seja titular de patentes necessariamente infringidas pela Obra tal como por si disponibilizada, concede igualmente ao Licenciado, nos mesmos termos, uma licença para utilizar essas patentes no exercício dos direitos previstos no número anterior.
25
+ 3. Esta licença não transmite a titularidade de quaisquer direitos, que permanecem do Licenciante.
26
+
27
+ ## 3. Condições
28
+
29
+ O exercício dos direitos concedidos fica sujeito às seguintes condições:
30
+
31
+ 1. Todas as cópias da Obra, ou de partes substanciais da mesma, e todas as Obras Derivadas distribuídas devem incluir o Aviso e uma cópia desta licença ou uma ligação estável para o seu texto.
32
+ 2. Quem distribuir uma versão modificada da Obra deve indicar de forma visível que a mesma foi modificada, não podendo apresentá-la como versão original do Licenciante.
33
+ 3. O Licenciado pode licenciar as suas próprias modificações ao abrigo de outros termos, desde que a parte da Obra que delas faça parte continue sujeita às condições desta licença.
34
+
35
+ ## 4. Nomes e marcas
36
+
37
+ Esta licença não concede qualquer direito sobre o nome, as marcas, os logótipos ou outros sinais distintivos do Licenciante, incluindo a designação «Sharadox», salvo na medida estritamente necessária para cumprir o dever de incluir o Aviso. É proibido utilizá-los para promover ou sugerir o apoio do Licenciante a Obras Derivadas ou a quaisquer produtos ou serviços sem autorização prévia e escrita.
38
+
39
+ ## 5. Exclusão de garantias
40
+
41
+ A Obra é disponibilizada «tal como está» e «conforme disponível», sem qualquer garantia, expressa ou tácita, incluindo, designadamente, garantias de comerciabilidade, de adequação a um fim específico, de ausência de erros ou de não violação de direitos de terceiros, na medida máxima permitida pela lei aplicável.
42
+
43
+ ## 6. Limitação de responsabilidade
44
+
45
+ 1. Na medida máxima permitida pela lei aplicável, o Licenciante não é responsável por quaisquer danos, diretos ou indiretos, incluindo lucros cessantes, perda de dados ou interrupção de atividade, resultantes da utilização ou da impossibilidade de utilização da Obra, ainda que tenha sido avisado da possibilidade da sua ocorrência.
46
+ 2. Nada nesta licença exclui ou limita a responsabilidade do Licenciante nos casos em que tal exclusão ou limitação não seja permitida por lei, designadamente por atos praticados com dolo ou culpa grave, nos termos do artigo 809.º e do n.º 2 do artigo 800.º do Código Civil, nem afeta os direitos que a lei imperativamente reconheça aos consumidores.
47
+
48
+ ## 7. Cessação
49
+
50
+ 1. Os direitos concedidos por esta licença cessam automaticamente se o Licenciado violar qualquer das suas condições.
51
+ 2. Os direitos são repostos se a violação for sanada no prazo de 30 dias a contar do momento em que o Licenciado dela tome conhecimento, salvo se o Licenciante tiver entretanto comunicado por escrito a sua oposição.
52
+ 3. A cessação não afeta as licenças validamente concedidas pelo Licenciado a terceiros que cumpram esta licença.
53
+
54
+ ## 8. Lei aplicável e foro
55
+
56
+ 1. Esta licença rege-se pela lei portuguesa, designadamente pelo Código do Direito de Autor e dos Direitos Conexos, aprovado pelo Decreto-Lei n.º 63/85, de 14 de março, e pelo Decreto-Lei n.º 252/94, de 20 de outubro, relativo à proteção jurídica dos programas de computador.
57
+ 2. Para a resolução de quaisquer litígios emergentes desta licença é competente o Tribunal Judicial da Comarca de Faro, sem prejuízo das normas imperativas de competência aplicáveis, nomeadamente as que protegem os consumidores.
58
+
59
+ ## 9. Versões da licença
60
+
61
+ O Licenciante pode publicar novas versões desta licença, identificadas por um número de versão. A Obra fica sujeita à versão indicada no Aviso. O Licenciado pode, se o Aviso o permitir, optar por qualquer versão posterior.
62
+
63
+ ## 10. Disposições finais
64
+
65
+ 1. Se alguma disposição desta licença for considerada inválida ou ineficaz, as restantes mantêm-se em vigor, devendo a disposição afetada ser interpretada de forma a aproximar-se, tanto quanto possível, da intenção original.
66
+ 2. A não exigência, em qualquer momento, do cumprimento de uma disposição desta licença não constitui renúncia ao direito de o exigir posteriormente.
67
+
68
+ ## Como aplicar esta licença
69
+
70
+ Inclua na Obra um ficheiro `LICENCA.md` com este texto, a tradução `LICENSE.md` e o seguinte aviso, preenchendo o ano e o titular:
71
+
72
+ ```
73
+ Direitos de autor © <ano> <titular>.
74
+ Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.1.0.
75
+ https://github.com/Sharadox/sharadox-open-source-license
76
+ ```
package/LICENSE.md ADDED
@@ -0,0 +1,76 @@
1
+ # Sharadox Open Source Licence
2
+
3
+ Version 0.1.0
4
+
5
+ This is an informative English translation. The Portuguese text (`LICENCA.md`) is the only original and binding text of this licence; if the two differ, the Portuguese text prevails.
6
+
7
+ ## 1. Definitions
8
+
9
+ For the purposes of this licence:
10
+
11
+ 1. **"Work"** — the computer program, its documentation and any other content made available by the Licensor under this licence, in source code or in any other form.
12
+ 2. **"Licensor"** — the copyright holder identified in the copyright notice that accompanies the Work.
13
+ 3. **"Licensee"** — any natural or legal person exercising the rights granted by this licence.
14
+ 4. **"Derivative Work"** — any work based on or incorporating the Work, in whole or in part, with or without modifications, including translations, adaptations and programs that integrate it.
15
+ 5. **"Notice"** — the Licensor's copyright notice and the statement that the Work is licensed under this licence, including its version.
16
+
17
+ ## 2. Grant of rights
18
+
19
+ 1. Under this licence, the Licensor grants the Licensee a worldwide, royalty-free, non-exclusive licence, for the whole term of copyright protection, to:
20
+ 1. use the Work for any purpose, including commercial purposes;
21
+ 2. reproduce the Work, in whole or in part, by any means and in any form;
22
+ 3. modify, translate, adapt and transform the Work and create Derivative Works;
23
+ 4. distribute, publish, communicate to the public, make available, sell and sublicense the Work and Derivative Works.
24
+ 2. To the extent the Licensor holds patents necessarily infringed by the Work as made available by it, the Licensor also grants the Licensee, on the same terms, a licence to use those patents in exercising the rights in the previous paragraph.
25
+ 3. This licence does not transfer ownership of any rights, which remain with the Licensor.
26
+
27
+ ## 3. Conditions
28
+
29
+ The exercise of the rights granted is subject to the following conditions:
30
+
31
+ 1. Every copy of the Work, or of substantial parts of it, and every distributed Derivative Work must include the Notice and a copy of this licence or a stable link to its text.
32
+ 2. Anyone distributing a modified version of the Work must state visibly that it has been modified and may not present it as the Licensor's original version.
33
+ 3. The Licensee may license their own modifications under other terms, provided the part of the Work included in them remains subject to the conditions of this licence.
34
+
35
+ ## 4. Names and trademarks
36
+
37
+ This licence grants no rights to the Licensor's name, trademarks, logos or other distinctive signs, including the name "Sharadox", except as strictly necessary to comply with the duty to include the Notice. Using them to promote or suggest the Licensor's endorsement of Derivative Works or of any products or services without prior written permission is prohibited.
38
+
39
+ ## 5. Disclaimer of warranties
40
+
41
+ The Work is provided "as is" and "as available", without any warranty, express or implied, including in particular warranties of merchantability, fitness for a particular purpose, absence of errors or non-infringement of third-party rights, to the maximum extent permitted by applicable law.
42
+
43
+ ## 6. Limitation of liability
44
+
45
+ 1. To the maximum extent permitted by applicable law, the Licensor is not liable for any damages, direct or indirect, including loss of profits, loss of data or business interruption, arising from the use of or inability to use the Work, even if advised of the possibility of such damages.
46
+ 2. Nothing in this licence excludes or limits the Licensor's liability where such exclusion or limitation is not permitted by law, in particular for acts committed with intent or gross negligence, under article 809 and article 800(2) of the Portuguese Civil Code, nor does it affect rights that the law mandatorily grants to consumers.
47
+
48
+ ## 7. Termination
49
+
50
+ 1. The rights granted by this licence terminate automatically if the Licensee breaches any of its conditions.
51
+ 2. The rights are reinstated if the breach is remedied within 30 days of the Licensee becoming aware of it, unless the Licensor has meanwhile objected in writing.
52
+ 3. Termination does not affect licences validly granted by the Licensee to third parties who comply with this licence.
53
+
54
+ ## 8. Governing law and jurisdiction
55
+
56
+ 1. This licence is governed by Portuguese law, in particular the Code of Copyright and Related Rights, approved by Decree-Law no. 63/85 of 14 March, and Decree-Law no. 252/94 of 20 October on the legal protection of computer programs.
57
+ 2. The Judicial Court of the District of Faro has jurisdiction over any dispute arising from this licence, without prejudice to applicable mandatory rules of jurisdiction, in particular those protecting consumers.
58
+
59
+ ## 9. Licence versions
60
+
61
+ The Licensor may publish new versions of this licence, identified by a version number. The Work is subject to the version stated in the Notice. If the Notice allows it, the Licensee may choose any later version.
62
+
63
+ ## 10. Final provisions
64
+
65
+ 1. If any provision of this licence is held invalid or unenforceable, the remaining provisions stay in force, and the affected provision shall be interpreted as closely as possible to its original intent.
66
+ 2. Failure to enforce any provision of this licence at any time does not waive the right to enforce it later.
67
+
68
+ ## How to apply this licence
69
+
70
+ Include in the Work a `LICENCA.md` file with the Portuguese text, this translation as `LICENSE.md`, and the following notice, filling in the year and holder:
71
+
72
+ ```
73
+ Direitos de autor © <ano> <titular>.
74
+ Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.1.0.
75
+ https://github.com/Sharadox/sharadox-open-source-license
76
+ ```
package/NOTICE.md ADDED
@@ -0,0 +1,3 @@
1
+ Direitos de autor © 2026 Micael Pires (Sharadox).
2
+ Licenciado ao abrigo da Licença Sharadox de Código Aberto, versão 0.1.0.
3
+ https://github.com/Sharadox/sharadox-open-source-license
package/README.md CHANGED
@@ -1,3 +1,61 @@
1
- # Temporary Holding Version
1
+ # @sharadox/globe-web-library
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An interactive 3D dot globe for React websites, built on three.js:
4
+
5
+ - **Land:** twinkling dots that fade towards the edge.
6
+ - **Arcs:** a pulse travels from your home to each destination, and a marker with a pulsing ring sits at home.
7
+ - **Motion:** drag to spin with inertia, a slow auto-rotation that eases back in, and a small tilt towards the pointer.
8
+ - **Colours:** they come from your page, so a dark style draws white light and a light style draws dark ink.
9
+ - **Performance and fallbacks:** it pauses while off screen, shows a static sphere without WebGL, and stops auto-rotating for reduced motion.
10
+
11
+ It also ships `globe-land-points`, which generates the land dots file from Natural Earth data.
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ pnpm add @sharadox/globe-web-library
17
+ pnpm exec globe-land-points public/globe/land.bin # once; commit the file
18
+ ```
19
+
20
+ ## Use
21
+
22
+ ```tsx
23
+ "use client";
24
+ import dynamic from "next/dynamic";
25
+
26
+ const Globe = dynamic(() => import("@sharadox/globe-web-library/globe").then((module) => module.Globe), { ssr: false });
27
+
28
+ <div style={{ position: "relative", aspectRatio: 1 }}>
29
+ <Globe
30
+ palette={{ ink: "#ffffff", body: "#050505", rim: "#525252", dark: true }}
31
+ home={{ latitude: 37.08, longitude: -8.03 }}
32
+ destinations={[
33
+ { latitude: 51.51, longitude: -0.13 },
34
+ { latitude: 40.71, longitude: -74 },
35
+ ]}
36
+ />
37
+ </div>;
38
+ ```
39
+
40
+ The globe fills its positioned parent. Its halo and fallback follow `--globe-glow` (default `currentColor`) and `--globe-surface`.
41
+
42
+ ## API
43
+
44
+ | Import | Export |
45
+ | --------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
46
+ | `…/globe` | `<Globe palette home destinations? landPoints? label? className?>` |
47
+ | `…/world` | `<World>`, the three.js scene, to use inside your own `<Canvas>` |
48
+ | `…/drag-controller` | `createDragController(initial, autoRotate)`: the motion, without React |
49
+ | `…/globe-drag` | `useGlobeDrag(initial, autoRotate)` → `[reference, controller]` |
50
+ | `…/land-points` | `useLandPoints(url)` → `Float32Array` of latitude and longitude pairs, or `null` |
51
+ | `…/land-point-generator` | `landPoints(topology, samples?, southernLimit?)`; bin `globe-land-points [output]` |
52
+ | `…/color` | `globeColors({ ink, body, rim, dark })` |
53
+ | `…/latitude-longitude-to-vector`, `…/hex-channel`, `…/web-gl-support` | Helpers |
54
+
55
+ ## Develop
56
+
57
+ Tests replace the three.js renderer with a stand-in and run every frame callback by hand. `pnpm verify` runs formatting, lint, type-check, tests with 100% coverage and the build. Branches follow `<feature>.development` → `development` → `index`, and releases are `v<version>` tags on `index`.
58
+
59
+ ## Licence
60
+
61
+ Licença Sharadox de Código Aberto, versão 0.1.0. See [português](LICENCA.md) (the binding text) and the [English translation](LICENSE.md).
@@ -0,0 +1,4 @@
1
+ import type { ArcProperties } from "@sharadox/globe-web-library/arc/type";
2
+ /** A light arc lifting off the surface between two places, with a pulse running along it. */
3
+ export declare function Arc({ from, to, offset, colors }: ArcProperties): import("react").JSX.Element;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/arc/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1E,6FAA6F;AAC7F,wBAAgB,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,aAAa,+BAiC9D"}
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useFrame } from "@react-three/fiber";
4
+ import { useMemo, useRef } from "react";
5
+ import { AdditiveBlending, NormalBlending, QuadraticBezierCurve3, TubeGeometry } from "three";
6
+ import { ARC_SHADER } from "@sharadox/globe-web-library/shader/arc";
7
+ import { latitudeLongitudeToVector } from "@sharadox/globe-web-library/latitude-longitude-to-vector";
8
+ /** A light arc lifting off the surface between two places, with a pulse running along it. */
9
+ export function Arc({ from, to, offset, colors }) {
10
+ const material = useRef(null);
11
+ const geometry = useMemo(() => {
12
+ const start = latitudeLongitudeToVector(from.latitude, from.longitude, 1.002);
13
+ const end = latitudeLongitudeToVector(to[0], to[1], 1.002);
14
+ const middle = start
15
+ .clone()
16
+ .add(end)
17
+ .multiplyScalar(0.5)
18
+ .normalize()
19
+ .multiplyScalar(1 + start.distanceTo(end) * 0.38);
20
+ return new TubeGeometry(new QuadraticBezierCurve3(start, middle, end), 90, 0.0032, 6, false);
21
+ }, [from, to]);
22
+ const uniforms = useMemo(() => ({ time: { value: 0 }, offset: { value: offset }, color: { value: colors.ink } }), [offset, colors]);
23
+ useFrame((_, deltaSeconds) => {
24
+ if (material.current)
25
+ material.current.uniforms.time.value += deltaSeconds;
26
+ });
27
+ return (_jsx("mesh", { geometry: geometry, children: _jsx("shaderMaterial", { ref: material, vertexShader: ARC_SHADER.vertex, fragmentShader: ARC_SHADER.fragment, uniforms: uniforms, transparent: true, depthWrite: false, blending: colors.additive ? AdditiveBlending : NormalBlending }) }));
28
+ }
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/arc/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,EAAuB,MAAM,OAAO,CAAC;AACnH,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0DAA0D,CAAC;AAGrG,6FAA6F;AAC7F,MAAM,UAAU,GAAG,CAAC,EAAE,IAAI,E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AY,CAAC;IAC9E,CAAC,CAAC,CAAC;IACH,OAAO,CACL,eAAM,QAAQ,EAAE,QAAQ,YACtB,yBACE,GAAG,EAAE,QAAQ,EACb,YAAY,EAAE,UAAU,CAAC,MAAM,EAC/B,cAAc,EAAE,UAAU,CAAC,QAAQ,EACnC,QAAQ,EAAE,QAAQ,EAClB,WAAW,QACX,UAAU,EAAE,KAAK,EACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,cAAc,GAC7D,GACG,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { GlobeColors } from "@sharadox/globe-web-library/color/type";
2
+ export interface ArcProperties {
3
+ colors: GlobeColors;
4
+ from: {
5
+ latitude: number;
6
+ longitude: number;
7
+ };
8
+ to: readonly [number, number];
9
+ /** Phase of the travelling pulse, 0–1, so arcs don't pulse in sync. */
10
+ offset: number;
11
+ }
12
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/arc/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAE1E,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,EAAE,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/arc/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import type { GlobeColors, GlobePalette } from "@sharadox/globe-web-library/color/type";
2
+ /**
3
+ * Turns a palette (hex colours and whether the page is dark) into the colours the globe's shaders need.
4
+ *
5
+ * @example
6
+ * globeColors({ ink: "#ffffff", body: "#050505", rim: "#525252", dark: true });
7
+ */
8
+ export declare function globeColors({ ink, body, rim, dark }: GlobePalette): GlobeColors;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/color/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAExF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,YAAY,GAAG,WAAW,CAE/E"}
@@ -0,0 +1,11 @@
1
+ import { hexChannel } from "@sharadox/globe-web-library/hex-channel";
2
+ /**
3
+ * Turns a palette (hex colours and whether the page is dark) into the colours the globe's shaders need.
4
+ *
5
+ * @example
6
+ * globeColors({ ink: "#ffffff", body: "#050505", rim: "#525252", dark: true });
7
+ */
8
+ export function globeColors({ ink, body, rim, dark }) {
9
+ return { ink: hexChannel(ink), inkHex: ink, body: hexChannel(body), rim: hexChannel(rim), additive: dark };
10
+ }
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/color/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAGrE;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAgB;IAChE,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC7G,CAAC"}
@@ -0,0 +1,20 @@
1
+ /** The globe's colours, channels from 0 to 1 (as shaders take them). */
2
+ export interface GlobeColors {
3
+ /** Land dots, arcs and markers. */
4
+ ink: [number, number, number];
5
+ /** The same, as "#rrggbb", for standard three.js materials. */
6
+ inkHex: string;
7
+ /** The planet body, and its rim where it turns away. */
8
+ body: [number, number, number];
9
+ rim: [number, number, number];
10
+ /** Light adds up on dark backgrounds; on light ones the ink is drawn normally. */
11
+ additive: boolean;
12
+ }
13
+ /** Colours as a site writes them: "#rrggbb" values and whether the background is dark. */
14
+ export interface GlobePalette {
15
+ ink: string;
16
+ body: string;
17
+ rim: string;
18
+ dark: boolean;
19
+ }
20
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/color/type.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,kFAAkF;IAClF,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,0FAA0F;AAC1F,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,OAAO,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/color/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { DotsProperties } from "@sharadox/globe-web-library/dots/type";
2
+ /** The land, drawn as twinkling points that fade towards the globe's edge. */
3
+ export declare function Dots({ data, colors }: DotsProperties): import("react").JSX.Element;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/dots/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE5E,8EAA8E;AAC9E,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,cAAc,+BAwCpD"}
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { pseudoRandom } from "@sharadox/web-library/math/pseudo-random";
4
+ import { useFrame, useThree } from "@react-three/fiber";
5
+ import { useMemo, useRef } from "react";
6
+ import { BufferAttribute, BufferGeometry } from "three";
7
+ import { DOT_SHADER } from "@sharadox/globe-web-library/shader/dot";
8
+ import { latitudeLongitudeToVector } from "@sharadox/globe-web-library/latitude-longitude-to-vector";
9
+ /** The land, drawn as twinkling points that fade towards the globe's edge. */
10
+ export function Dots({ data, colors }) {
11
+ const { gl } = useThree();
12
+ const material = useRef(null);
13
+ const geometry = useMemo(() => {
14
+ const count = data.length / 2;
15
+ const position = new Float32Array(count * 3);
16
+ const seed = new Float32Array(count);
17
+ for (let index = 0; index < count; index++) {
18
+ const point = latitudeLongitudeToVector(data[index * 2], data[index * 2 + 1], 1.001);
19
+ position.set([point.x, point.y, point.z], index * 3);
20
+ seed[index] = pseudoRandom(index);
21
+ }
22
+ const points = new BufferGeometry();
23
+ points.setAttribute("position", new BufferAttribute(position, 3));
24
+ points.setAttribute("seed", new BufferAttribute(seed, 1));
25
+ return points;
26
+ }, [data]);
27
+ const uniforms = useMemo(() => ({
28
+ time: { value: 0 },
29
+ pointSize: { value: 2.6 * Math.min(gl.getPixelRatio(), 2) },
30
+ color: { value: colors.ink },
31
+ }), [gl, colors]);
32
+ useFrame((_, deltaSeconds) => {
33
+ if (material.current)
34
+ material.current.uniforms.time.value += deltaSeconds;
35
+ });
36
+ return (_jsx("points", { geometry: geometry, children: _jsx("shaderMaterial", { ref: material, vertexShader: DOT_SHADER.vertex, fragmentShader: DOT_SHADER.fragment, uniforms: uniforms, transparent: true, depthWrite: false }) }));
37
+ }
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/dots/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAuB,MAAM,OAAO,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0DAA0D,CAAC;AAGrG,8EAA8E;AAC9E,MAAM,UAAU,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAkB;IACnD,MAAM,EAAE,EAAE,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC1B,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC9C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,YAAY,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC7C,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;QACrC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAA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,CAAC;IAC9E,CAAC,CAAC,CAAC;IACH,OAAO,CACL,iBAAQ,QAAQ,EAAE,QAAQ,YACxB,yBACE,GAAG,EAAE,QAAQ,EACb,YAAY,EAAE,UAAU,CAAC,MAAM,EAC/B,cAAc,EAAE,UAAU,CAAC,QAAQ,EACnC,QAAQ,EAAE,QAAQ,EAClB,WAAW,QACX,UAAU,EAAE,KAAK,GACjB,GACK,CACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { GlobeColors } from "@sharadox/globe-web-library/color/type";
2
+ export interface DotsProperties {
3
+ colors: GlobeColors;
4
+ /** Float32 [latitude, longitude] pairs. */
5
+ data: Float32Array;
6
+ }
7
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/dots/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAE1E,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,WAAW,CAAC;IACpB,2CAA2C;IAC3C,IAAI,EAAE,YAAY,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/dots/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { GlobeDragController, GlobeRotation } from "@sharadox/globe-web-library/drag-controller/type";
2
+ /**
3
+ * The globe's motion: drag to spin with inertia, a slow auto-rotation that eases back in two seconds after a drag,
4
+ * and a small tilt towards the pointer.
5
+ *
6
+ * @example
7
+ * const controller = createDragController({ x: 0.4, y: -1 }, true);
8
+ * controller.step(1 / 60); // { x, y }
9
+ */
10
+ export declare function createDragController(initial: GlobeRotation, autoRotate: boolean): GlobeDragController;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/drag-controller/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAC;AAK3G;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,GAAG,mBAAmB,CAkDrG"}
@@ -0,0 +1,65 @@
1
+ import { clamp } from "@sharadox/web-library/math/clamp";
2
+ /** How far the globe may tip up and down, in radians. */
3
+ const TIP = [-0.9, 1.1];
4
+ /**
5
+ * The globe's motion: drag to spin with inertia, a slow auto-rotation that eases back in two seconds after a drag,
6
+ * and a small tilt towards the pointer.
7
+ *
8
+ * @example
9
+ * const controller = createDragController({ x: 0.4, y: -1 }, true);
10
+ * controller.step(1 / 60); // { x, y }
11
+ */
12
+ export function createDragController(initial, autoRotate) {
13
+ let rotationX = initial.x;
14
+ let rotationY = initial.y;
15
+ let velocityX = 0;
16
+ let velocityY = 0;
17
+ let dragging = false;
18
+ let lastX = 0;
19
+ let lastY = 0;
20
+ let idleSeconds = 0;
21
+ let tiltX = 0;
22
+ let tiltY = 0;
23
+ return {
24
+ down(clientX, clientY) {
25
+ dragging = true;
26
+ lastX = clientX;
27
+ lastY = clientY;
28
+ },
29
+ move({ clientX, clientY, bounds }) {
30
+ const width = Math.max(bounds.width, 1);
31
+ tiltX = ((clientY - bounds.top) / Math.max(bounds.height, 1) - 0.5) * 0.18;
32
+ tiltY = ((clientX - bounds.left) / width - 0.5) * 0.18;
33
+ if (!dragging)
34
+ return;
35
+ const speed = 2.6 / width;
36
+ velocityY = (clientX - lastX) * speed;
37
+ velocityX = (clientY - lastY) * speed;
38
+ lastX = clientX;
39
+ lastY = clientY;
40
+ rotationY += velocityY;
41
+ rotationX = clamp(rotationX + velocityX, ...TIP);
42
+ idleSeconds = 0;
43
+ },
44
+ up() {
45
+ dragging = false;
46
+ },
47
+ leave() {
48
+ tiltX = 0;
49
+ tiltY = 0;
50
+ },
51
+ step(deltaSeconds) {
52
+ if (!dragging) {
53
+ rotationY += velocityY;
54
+ rotationX = clamp(rotationX + velocityX, ...TIP);
55
+ velocityY *= 0.94;
56
+ velocityX *= 0.9;
57
+ idleSeconds += deltaSeconds;
58
+ if (autoRotate)
59
+ rotationY += deltaSeconds * 0.06 * Math.min(1, idleSeconds / 2);
60
+ }
61
+ return { x: rotationX + tiltX, y: rotationY + tiltY };
62
+ },
63
+ };
64
+ }
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/drag-controller/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AAGzD,yDAAyD;AACzD,MAAM,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAU,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAsB,EAAE,UAAmB;IAC9E,IAAI,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC;IAC1B,IAAI,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC;IAC1B,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO;QACL,IAAI,CAAC,OAAO,EAAE,OAAO;YACnB,QAAQ,GAAG,IAAI,CAAC;YAChB,KAAK,GAAG,OAAO,CAAC;YAChB,KAAK,GAAG,OAAO,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE;YAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,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I,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC,CAAC;YAClF,CAAC;YACD,OAAO,EAAE,CAAC,EAAE,SAAS,GAAG,KAAK,EAAE,CAAC,EAAE,SAAS,GAAG,KAAK,EAAE,CAAC;QACxD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ /** A rotation in radians. */
2
+ export interface GlobeRotation {
3
+ x: number;
4
+ y: number;
5
+ }
6
+ /** A pointer position and the element's box, as the controller needs them. */
7
+ export interface PointerSample {
8
+ clientX: number;
9
+ clientY: number;
10
+ bounds: {
11
+ left: number;
12
+ top: number;
13
+ width: number;
14
+ height: number;
15
+ };
16
+ }
17
+ /** Drag-to-spin state machine: feed it pointer events and step it every frame. */
18
+ export interface GlobeDragController {
19
+ down: (clientX: number, clientY: number) => void;
20
+ move: (sample: PointerSample) => void;
21
+ up: () => void;
22
+ leave: () => void;
23
+ /** Advances inertia and auto-rotation by `deltaSeconds`; returns the target rotation. */
24
+ step: (deltaSeconds: number) => GlobeRotation;
25
+ }
26
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/drag-controller/type.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACtE;AAED,kFAAkF;AAClF,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,IAAI,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IACtC,EAAE,EAAE,MAAM,IAAI,CAAC;IACf,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,yFAAyF;IACzF,IAAI,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,aAAa,CAAC;CAC/C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/drag-controller/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import type { GlobeProperties } from "@sharadox/globe-web-library/globe/type";
2
+ /**
3
+ * An interactive 3D dot globe: land as twinkling dots, arcs with travelling pulses from home to each destination,
4
+ * markers, a soft halo, drag to spin with inertia and a slow auto-rotation (off with reduced motion). It pauses
5
+ * when off screen and shows a static sphere without WebGL. Client only: load it with `next/dynamic` and `ssr: false`.
6
+ *
7
+ * @example
8
+ * const Globe = dynamic(() => import("@sharadox/globe-web-library/globe").then((module) => module.Globe), { ssr: false });
9
+ * <Globe palette={{ ink: "#fff", body: "#050505", rim: "#525252", dark: true }} home={{ latitude: 37.08, longitude: -8.03 }} />
10
+ */
11
+ export declare function Globe({ palette, home, destinations, landPoints, label, className, }: GlobeProperties): import("react").JSX.Element;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/globe/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAE9E;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,EACpB,OAAO,EACP,IAAI,EACJ,YAAiB,EACjB,UAA8B,EAC9B,KAA2B,EAC3B,SAAS,GACV,EAAE,eAAe,+BAmCjB"}
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Canvas } from "@react-three/fiber";
4
+ import { useEffect, useMemo, useState } from "react";
5
+ import { classNames } from "@sharadox/web-library/class-name";
6
+ import { radians } from "@sharadox/web-library/math/radians";
7
+ import { globeColors } from "@sharadox/globe-web-library/color";
8
+ import { useGlobeDrag } from "@sharadox/globe-web-library/globe-drag";
9
+ import { useLandPoints } from "@sharadox/globe-web-library/land-points";
10
+ import { supportsWebGl } from "@sharadox/globe-web-library/web-gl-support";
11
+ import { World } from "@sharadox/globe-web-library/world";
12
+ import styles from "./index.module.css";
13
+ /**
14
+ * An interactive 3D dot globe: land as twinkling dots, arcs with travelling pulses from home to each destination,
15
+ * markers, a soft halo, drag to spin with inertia and a slow auto-rotation (off with reduced motion). It pauses
16
+ * when off screen and shows a static sphere without WebGL. Client only: load it with `next/dynamic` and `ssr: false`.
17
+ *
18
+ * @example
19
+ * const Globe = dynamic(() => import("@sharadox/globe-web-library/globe").then((module) => module.Globe), { ssr: false });
20
+ * <Globe palette={{ ink: "#fff", body: "#050505", rim: "#525252", dark: true }} home={{ latitude: 37.08, longitude: -8.03 }} />
21
+ */
22
+ export function Globe({ palette, home, destinations = [], landPoints = "/globe/land.bin", label = "Interactive globe", className, }) {
23
+ const data = useLandPoints(landPoints);
24
+ const colors = useMemo(() => globeColors(palette), [palette]);
25
+ const [visible, setVisible] = useState(true);
26
+ const [webGl] = useState(supportsWebGl);
27
+ const [reduced] = useState(() => window.matchMedia("(prefers-reduced-motion: reduce)").matches);
28
+ const [wrapper, drag] = useGlobeDrag({ y: -radians(home.longitude) - 0.5, x: radians(home.latitude) * 0.62 }, !reduced);
29
+ useEffect(() => {
30
+ const observer = new IntersectionObserver(([entry]) => setVisible(!!entry?.isIntersecting), {
31
+ rootMargin: "100px",
32
+ });
33
+ observer.observe(wrapper.current);
34
+ return () => observer.disconnect();
35
+ }, [wrapper]);
36
+ return (_jsxs("div", { ref: wrapper, className: classNames(styles.globe, className), children: [_jsx("div", { className: styles.halo, "aria-hidden": true }), webGl && data ? (_jsx(Canvas, { dpr: [1, 2], camera: { position: [0, 0, 3.7], fov: 38 }, gl: { antialias: true, alpha: true, powerPreference: "high-performance" }, frameloop: visible ? "always" : "never", "aria-label": label, children: _jsx(World, { data: data, drag: drag, colors: colors, home: home, destinations: destinations }) })) : (_jsx("div", { className: styles.fallback, "aria-hidden": true }))] }));
37
+ }
38
+ //# sourceMappingURL=index.js.map