Hello,
I try to load a 3d model in THREE with the GLFTLoader but I have an error.
My code in index.html :
<script type="module">
import * as THREE from './three/build/three.module.js';
import { GLTFLoader } from './three/examples/jsm/loaders/GLTFLoader.js';
const canvas = document.querySelector("#conteneur");
const renderer = new THREE.WebGLRenderer({canvas});
const fov = 75;
const aspect = 2;
const near = 0.1;
const far = 5;
const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
camera.position.z = 5;
const scene = new THREE.Scene();
const loader = new GLTFLoader();
loader.load( 'model/free_cyberpunk_hovercar/scene.gltf', function ( gltf ) {
scene.add( gltf.scene );
}, undefined, function ( error ) {
console.error( error );
} );
renderer.render(scene, camera);
</script>
The error :
Uncaught TypeError: Error resolving module specifier 'three'. Relative module specifiers must begin with "./", "../", or "/".
the code in GLTFLoader.js :
import {
AnimationClip,
Bone,
Box3,
BufferAttribute,
BufferGeometry,
ClampToEdgeWrapping,
Color,
DirectionalLight,
DoubleSide,
FileLoader,
FrontSide,
Group,
ImageBitmapLoader,
InterleavedBuffer,
InterleavedBufferAttribute,
Interpolant,
InterpolateDiscrete,
InterpolateLinear,
Line,
LineBasicMaterial,
LineLoop,
LineSegments,
LinearFilter,
LinearMipmapLinearFilter,
LinearMipmapNearestFilter,
Loader,
LoaderUtils,
Material,
MathUtils,
Matrix4,
Mesh,
MeshBasicMaterial,
MeshPhysicalMaterial,
MeshStandardMaterial,
MirroredRepeatWrapping,
NearestFilter,
NearestMipmapLinearFilter,
NearestMipmapNearestFilter,
NumberKeyframeTrack,
Object3D,
OrthographicCamera,
PerspectiveCamera,
PointLight,
Points,
PointsMaterial,
PropertyBinding,
Quaternion,
QuaternionKeyframeTrack,
RepeatWrapping,
Skeleton,
SkinnedMesh,
Sphere,
SpotLight,
TangentSpaceNormalMap,
Texture,
TextureLoader,
TriangleFanDrawMode,
TriangleStripDrawMode,
Vector2,
Vector3,
VectorKeyframeTrack,
sRGBEncoding
} from 'three';
I researched a sibling error but I have not found
Can you help me ?