@tokoronad

Почему у меня возникает ошибка — Uncaught TypeError: THREE.FBXLoader is not a constructor?

в моем коде почему то возникает ошибка с загрузчиком fbx формата на сайт
код должен загружать на сайт fbx модель с ее анимацией
вот код html(здесь только нужная часть, связанная со скриптами):
<script type="importmap">
		{
			"imports": {
				"three": "../build/three.module.js",
				"three/addons/": "./jsm/"
			}
		}
		</script>
	<script type="module" src="script/script.js"></script>
	<script type="module" src="https://threejs.org/build/three.js"></script>
	<script type="module" src="https://cdnjs.cloudflare.com/ajax/libs/stats.js/r17/Stats.min.js"></script>
	<script type="module" src="https://cdnjs.cloudflare.com/ajax/libs/stats.js/r17/Stats.min.js"></script>
	<script type="module" src="https://cdn.jsdelivr.net/npm/three@0.132.2/examples/js/loaders/FBXLoader.js"></script>

js:
"use strict";
			THREE.ColorManagement = true;
			let camera, scene, renderer, stats;
			const clock = new THREE.Clock();
			let mixer;
			init();
			animate();
			function init() {
				const container = document.createElement( 'div' );
				document.body.appendChild( container );

				camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
				camera.position.set( 100, 200, 300 );

				scene = new THREE.Scene();
				scene.background = new THREE.Color( 0xa0a0a0 );
				scene.fog = new THREE.Fog( 0xa0a0a0, 200, 1000 );

				const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444, 1.5 );
				hemiLight.position.set( 0, 200, 0 );
				scene.add( hemiLight );

				// модель
				const loader = new FBXLoader();
				loader.load( '3dmoddel/Flair.fbx', function ( object ) {

					mixer = new THREE.AnimationMixer( object );

					const action = mixer.clipAction( object.animations[ 0 ] );
					action.play();

					object.traverse( function ( child ) {

						if ( child.isMesh ) {

							child.castShadow = true;
							child.receiveShadow = true;

						}

					} );

					scene.add( object );

				} );

				renderer = new THREE.WebGLRenderer( { antialias: true } );
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( window.innerWidth, window.innerHeight );
				renderer.outputEncoding = THREE.sRGBEncoding;
				renderer.shadowMap.enabled = true;
				container.appendChild( renderer.domElement );

				window.addEventListener( 'resize', onWindowResize );

				stats = new Stats();
				container.appendChild( stats.dom );

			}
			function animate() {

				requestAnimationFrame( animate );

				const delta = clock.getDelta();

				if ( mixer ) mixer.update( delta );

				renderer.render( scene, camera );
s
				stats.update();

			}
			function openForm() {
			document.getElementById("myForm").style.display = "block";
			}

			function closeForm() {
			document.getElementById("myForm").style.display = "none";
			}
  • Вопрос задан
  • 66 просмотров
Пригласить эксперта
Ответы на вопрос 1
profesor08
@profesor08 Куратор тега JavaScript
<script type="module" src="script/script.js"></script>

В самый низ
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы