加载Blender场景

时间:2014-02-18 18:58:09

标签: three.js

加载混合器导出场景有些困难:

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>

在浏览器中运行时,我会收到以下错误:

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)

那么,出了什么问题?

意外令牌表示basic4.js

中元数据之后的第一个“:”

我测试了各种加载器,结果总是一样。

有任何帮助可以了解如何将简单的搅拌器 - 场景加载到3JS?

问候

jewtis

1 个答案:

答案 0 :(得分:2)

我将脚本标记修改为

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

和错误:意外的令牌消失了。

然后我使用了THREE.SceneLoader()并且可以加载场景。

关心jewtis