Dieser Commit ist enthalten in:
Ursprung
16cb987aff
Commit
f2e2a6ff59
@ -21,7 +21,7 @@
|
|||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
|
||||||
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
||||||
import {onMount} from "svelte";
|
import {onDestroy, onMount} from "svelte";
|
||||||
|
|
||||||
export let file: string;
|
export let file: string;
|
||||||
export let fov: number = 60;
|
export let fov: number = 60;
|
||||||
@ -72,18 +72,29 @@
|
|||||||
|
|
||||||
new ResizeObserver(handleResize).observe(div);
|
new ResizeObserver(handleResize).observe(div);
|
||||||
|
|
||||||
|
|
||||||
|
loaded = true;
|
||||||
|
|
||||||
function animate() {
|
function animate() {
|
||||||
requestAnimationFrame( animate );
|
if (loaded) {
|
||||||
|
requestAnimationFrame(animate);
|
||||||
|
}
|
||||||
|
|
||||||
renderer.render( scene, camera );
|
renderer.render( scene, camera );
|
||||||
controls.update();
|
controls.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
animate();
|
animate();
|
||||||
|
|
||||||
loaded = true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
loaded = false;
|
||||||
|
|
||||||
|
renderer.dispose();
|
||||||
|
scene.clear();
|
||||||
|
light.dispose();
|
||||||
|
})
|
||||||
|
|
||||||
function handleResize() {
|
function handleResize() {
|
||||||
let width = div.clientWidth;
|
let width = div.clientWidth;
|
||||||
let height = div.clientHeight;
|
let height = div.clientHeight;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren