OBJLoader / ThreeJS:未捕获TypeError:undefined不是函数

时间:2013-03-20 16:10:52

标签: three.js webgl

我得到Three.OBJLoader Uncaught TypeError:当我尝试加载自定义obj文件时,undefined不是函数。 我检查了THREE.OBJLoader not working (TypeError),我试图改组OBJLoader.js的所有插入,但仍然无效。

<body>
    <script type="text/javascript" src="OBJLoader.js"></script>

    <script src="https://raw.github.com/mrdoob/three.js/master/build/three.js"></script>
    <!-- // <script src="https://raw.github.com/mrdoob/three.js/master/build/three.min.js"></script> -->

    <script>

    function init(){
        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);


        var loader = new THREE.OBJLoader();
            loader.addEventListener( 'load', function ( event ) {

                var object = event.content;

                object.traverse( function ( child ) {

                    if ( child instanceof THREE.Mesh ) {

                        child.material.map = texture;

                    }

                } );

                object.position.y = - 80;
                scene.add( object );

            });
        loader.load('gargoyle/gargoyle.obj');

非常感谢任何帮助

1 个答案:

答案 0 :(得分:0)

你的脚本标签需要在,objloader.js包含应该在主要的three.js文件之后,还要仔细检查OBJLoader.js的路径