tobogganSe connecter

starfleet-ui

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

26 lignes · 1021 octetsBrut · Historique
1<script lang="ts">
2 import { T } from '@threlte/core';
3 import { untrack } from 'svelte';
4 import { clone as cloneSkinned } from 'three/examples/jsm/utils/SkeletonUtils.js';
5 import { useGltf, type IntersectionEvent } from '@threlte/extras';
6
7 interface Props {
8 src: string;
9 position?: [number, number, number];
10 rotation?: [number, number, number];
11 scale?: number | [number, number, number];
12 onclick?: (e: IntersectionEvent<MouseEvent>) => void;
13 }
14
15 let { src, position = [0, 0, 0], rotation = [0, 0, 0], scale = 1, onclick }: Props = $props();
16
17 // Parents key models by what they show, so `src` is fixed for this instance's lifetime.
18 const gltf = useGltf(untrack(() => src));
19 // SkeletonUtils.clone rebinds skinned meshes to their cloned skeleton; a plain
20 // scene.clone() leaves rigged models (the derelict) bound to the original and invisible.
21 const scene = $derived($gltf ? cloneSkinned($gltf.scene) : undefined);
22</script>
23
24{#if scene}
25 <T is={scene} {position} {rotation} {scale} {onclick} />
26{/if}