Z
Z
zeni1agent2018-12-21 22:38:28
three.js
zeni1agent, 2018-12-21 22:38:28

Why doesn't three.js see some fbx models?

I am trying to load models using this js code
The code is based on the example from this page .

function A1(){ 
    var scene  = new THREE.Scene();  
    var camera = new THREE.PerspectiveCamera(65,window.innerWidth/window.innerHeight, 0.1, 10000); 
    var container = document.getElementById( 'program3d' );  
    var renderer = new THREE.WebGLRenderer();                
    renderer.setSize(window.innerWidth   , window.innerHeight   );  
    container.appendChild( renderer.domElement );         
    renderer.setSize (400, 400);  
    renderer.setClearColor ( 0xC8C7C7 );  
    camera.position.z= 5; 
    camera.position.x= 0;
    camera.position.y= 0;
    var ambientLight = new THREE.AmbientLight ( 0xfffef5, 0.45 );  
    scene.add (ambientLight);
    var directionalLight = new THREE.DirectionalLight (0xfff2e8, 0.8 );  
    directionalLight.position.set (0.1, 1, 0.2);
    scene.add(directionalLight);
    var light1 =new THREE.PointLight(0xFFFFFF, 4 , 30);  
    //scene.add (light1);
    var light2 =new THREE.PointLight(0xFFFFFF, 4 , 30);  
    //scene.add (light2);   
    var light3 =new THREE.PointLight(0xFFFFFF, 4 , 30);  
    //scene.add (light3);
    var update = function (){   
    var time = Date.now() * 0.0005; 
        light1.position.x = Math.sin ( time * 0.7) * 30;
        light1.position.y = Math.cos ( time * 0.5) * 40;
        light1.position.z = Math.cos ( time * 0.3) * 30;
        light2.position.x = Math.cos ( time * 0.3) * 30;
        light2.position.y = Math.sin ( time * 0.5) * 40;
        light2.position.z = Math.sin ( time * 0.7) * 30;
        light3.position.x = Math.sin ( time * 0.7) * 30;
        light3.position.y = Math.cos ( time * 0.3) * 40;
        light3.position.z = Math.sin ( time * 0.3) * 30;};
                var loader = new THREE.FBXLoader();
                loader.load( 'models/2B.fbx', function ( object ) {
                    object.mixer = new THREE.AnimationMixer( object );
                    mixers.push( object.mixer );
                    var action = object.mixer.clipAction( object.animations[ 0 ] );
                    action.play();
                    object.traverse( function ( child ) {
                        if ( child.isMesh ) {
                            child.castShadow = true;
                            child.receiveShadow = true;
                        }});
                    scene.add( object );} );         
    var stats = new Stats();
    container.appendChild( stats.dom );
    var clock = new THREE.Clock();
    var mixers = [];
    function animate() {
    if ( mixers.length > 0 ) {
    for ( var i = 0; i < mixers.length; i ++ ) {
    mixers[ i ].update( clock.getDelta() );
    }}}     
    var controls = new THREE.TrackballControls (camera);  
    var end_scene = function(){
        requestAnimationFrame (end_scene);
        animate();
        controls.update();  
        renderer.render(scene, camera);  
        update();};
    end_scene();};

The problem is that the code does not display all the fbx models that I give it.
There are no errors in the Console
Models on which I checked the code
Works
Does not work
Perhaps the problem is in the textures, but I can’t say for sure.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question