fix: webgl feedback loop error

This commit is contained in:
2025-12-13 16:02:24 +01:00
parent 69abfd8aca
commit 285de91dd0

View File

@@ -4,10 +4,17 @@ 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";
// initialize scene
const scene = new THREE.Scene(); const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, 0, 0.001, 1000); const camera = new THREE.PerspectiveCamera(75, 0, 0.001, 1000);
const renderer = new THREE.WebGLRenderer(); const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
});
renderer.setClearColor(0xffffff); renderer.setClearColor(0xffffff);
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1;
camera.position.z = 5;
const controls = new OrbitControls(camera, renderer.domElement); const controls = new OrbitControls(camera, renderer.domElement);
@@ -37,12 +44,11 @@ directional.target = nds.scene;
directional.position.set(0, 100, 0); directional.position.set(0, 100, 0);
scene.add(directional); scene.add(directional);
// main loop
renderer.setAnimationLoop(() => { renderer.setAnimationLoop(() => {
controls.update(); controls.update();
renderer.render(scene, camera); renderer.render(scene, camera);
}); });
camera.position.z = 5;
document.body.appendChild(renderer.domElement); document.body.appendChild(renderer.domElement);