user2174988
user2174988

Reputation: 56

Load Blender scene

Some difficulties to load a blender exported scene:

HTML:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <style>
            body {
                background-color: #ffffff;
                margin: 0;
                overflow: hidden;
            }
        </style>
    </head>
    <body>
        <script src="JS/Stats.js"></script>
        <script src="JS/three.js"></script>

        <script src="JS/basic4.js"></script>
        <script>

            var camera, scene;


            init();
            animate();



            function init() {

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


                var callbackFinished =function ( result ) {
                    console.log (result);

                 //   scene=result.scene;
                  //  camera=result.camera;

                }


                var callbackProgress=function(progress, result){

                    console.log (progress);
                }

                loader = new THREE.ObjectLoader();
                loader.callbackProgress= callbackProgress;
                loader.load( "JS/basic4.js", callbackFinished );

            }

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

            }



        </script>
    </body>
</html>

When run in browser i get these errors:

Uncaught SyntaxError: Unexpected token :                         /JS/basic4.js:3
THREE.WebGLRenderer 65                                           three.js:19742
Uncaught TypeError: Cannot read property 'type' of undefined     three.js:11864
(anonymous function)                                             three.js:11864
THREE.ObjectLoader.parse                                         three.js:11684
(anonymous function)                                             three.js:11668
(anonymous function)

So, what's wrong?

unexpected Token means the first ":" after metadata in basic4.js

I tested various loaders and the result is always the same.

Any help out there to understand how to load a simple blender - scene to 3JS ?

Greetings

jewtis

Upvotes: 1

Views: 566

Answers (1)

user2174988
user2174988

Reputation: 56

I modified the script tag to

<script src="JS/basic4.js" type="text/JSON"></script> 

and the error: unexpected token was gone.

Then i used the THREE.SceneLoader() and the scene could be loaded.

Regards jewtis

Upvotes: 2

Related Questions