starfleet-ui
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#6 · main · 2 min 01 s
0Étoiles
0Forks
0Issues
| 1 | <script lang="ts"> |
| 2 | import { T, useTask } from '@threlte/core'; |
| 3 | import type { IntersectionEvent } from '@threlte/extras'; |
| 4 | import { makePlanetMaterial } from './planetShader'; |
| 5 | import type { WaypointKind } from '$lib/types'; |
| 6 | |
| 7 | interface Props { |
| 8 | kind: WaypointKind; |
| 9 | symbol: string; |
| 10 | size: number; |
| 11 | position: [number, number, number]; |
| 12 | onclick?: (e: IntersectionEvent<MouseEvent>) => void; |
| 13 | } |
| 14 | |
| 15 | let { kind, symbol, size, position, onclick }: Props = $props(); |
| 16 | |
| 17 | const material = $derived(makePlanetMaterial(kind, symbol)); |
| 18 | $effect(() => { |
| 19 | const m = material; |
| 20 | return () => m.dispose(); |
| 21 | }); |
| 22 | |
| 23 | useTask((delta) => { |
| 24 | material.uniforms.uTime.value += delta; |
| 25 | }); |
| 26 | </script> |
| 27 | |
| 28 | <T.Mesh {position} {onclick} {material}> |
| 29 | <T.SphereGeometry args={[size, 48, 48]} /> |
| 30 | </T.Mesh> |