R
R
ruzaev20192021-06-29 17:53:30
JavaScript
ruzaev2019, 2021-06-29 17:53:30

How to fix error in GLTFLoader file???

I decided to add a .gltf model to the site, but I got an error in response, most likely this is due to the fact that I use WebPack , it chemistry with js files and makes them in the ES5 standard , but why? I don't have Babel installed. Is there any option to disable file conversion?
Here is the error: 60db331cba0e9370752271.png
And this is how the "schemed" GLTFLoader code looks like : 60db335e92d72151690187.png
But it should be like this: 60db337a0f1d2709259114.png

Here is the JS :

import * as THREE from './node_modules/three/build/three.module.js'; // three.js
import OrbitControls from 'three-orbitcontrols'; // камера
import GLTFLoader from 'three-gltf-loader'; // GLTFLoader
import {
  RayTracingRenderer,
  SoftDirectionalLight
} from 'ray-tracing-renderer'; // трассировка лучей

// ***** основные переменные *****
const scene = new THREE.Scene();
scene.background = new THREE.Color('#dddddd');

const camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight);
camera.position.set(5, 5, 10);

const renderer = new RayTracingRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);

document.body.appendChild(renderer.domElement);

// ***** камера *****
const controls = new OrbitControls(camera, renderer.domElement);
controls.update();

// ***** источники света *****
const light = new SoftDirectionalLight(0xF7779B, 1, 0, 3);
light.position.set(-3, 2, 2);
scene.add(light);

// ***** GLTFLoader *****
const loader = new GLTFLoader();
loader.load(
  'scene.gltf', gltf => {
    scene.add(gltf.scene);
  }
);

// ***** рендеринг *****
const animate = () => {
  requestAnimationFrame(animate);
  renderer.render(scene, camera);
};

animate();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2021-06-29
@sslion

in my project GLTFLoader is connected like this

import {GLTFLoader} from 'https://threejsfundamentals.org/threejs/resources/threejs/r127/examples/jsm/loaders/GLTFLoader.js';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question