Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading DAE in Three.js

I have a problem, I can't load DAE file in Three.js. Can anybody help please.

I have model.dae in the same directory as index.html and when I load page it shows only black screen.

I had a file FBX and I exported it with Maya to FBX_DAE

<html>
<head>
    <title>My first Three.js app</title>
    <style>canvas { width: 100%; height: 100% }</style>
</head>
<body>
    <style type="text/css">
        html, body {
            margin:0;
            padding: 0;
        }
    </style>
    <script src="js/three.min.js"></script>
    <script src="js/ColladaLoader.min.js"></script>
    <script>
        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera( 75, window.innerWidth /     window.innerHeight, 0.1, 1000 );

        var renderer = new THREE.WebGLRenderer();
        renderer.setSize( window.innerWidth, window.innerHeight );
        document.body.appendChild( renderer.domElement );

        loader = new THREE.ColladaLoader();
        loader.load('model.DAE',function colladaReady( collada ){
        player = collada.scene;
        skin = collada.skins [ 0 ];
        scene.add( player );
        });

        /*
        var geometry = new THREE.CubeGeometry(1,1,1);
        var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
        var cube = new THREE.Mesh( geometry, material );
        scene.add( cube );
        */

        camera.position.z = 5;

        function render() {
            requestAnimationFrame(render);
            renderer.render(scene, camera);

            //cube.rotation.x += 0.1;
            //cube.rotation.y += 0.1;
        }
        render();

    </script>
</body>
</html>
like image 481
Milos Miskone Sretin Avatar asked Sep 03 '26 16:09

Milos Miskone Sretin


1 Answers

This is just a guess, but I suspect you're not loading the ColladaLoader properly.

Should be this:

<script src="js/ColladaLoader.js"></script>

Instead of this:

<script src="js/ColladaLoader.min.js"></script>

If this is the case you should be seeing a error in the console.

like image 62
mrdoob Avatar answered Sep 05 '26 06:09

mrdoob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!