in my code, for some reason, an error occurs with the fbx format loader on the site
, the code should upload a model with its animation to the fbx site
here is the html code (here is only the necessary part related to scripts):
<script type="importmap">
{
"imports": {
"three": "../build/three.module.js",
"three/addons/": "./jsm/"
}
}
</script>
<script type="module" src="script/script.js"></script>
js
import * as THREE from 'https://cdn.jsdelivr.net/npm/three@0.132.2/build/three.min.js';
import { Stats } from 'https://unpkg.com/es-module-shims@1.6.3/dist/es-module-shims.js';
import { GLTFLoader } from 'https://unpkg.com/three@0.126.0/examples/js/loaders/GLTFLoader.js';
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 );
// model
const loader = new GLTFLoader ();
loader.load( '3dmoddel/Flair.fbx', function ( gltf) {
model = gltf.scene;
mixer = new THREE.AnimationMixer( gltf);
const action = mixer.clipAction( gltf.animations );
action.play();
object.traverse( function ( child ) {
if ( child.isMesh ) {
child.castShadow = true;
child.receiveShadow = true;
}
} );
scene.add( model);
} );
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";
}