1

我收到 Three.OBJLoader Uncaught TypeError: undefined is not a function 当我尝试加载自定义 obj 文件时。我检查了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');

任何帮助是极大的赞赏

4

1 回答 1

0

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

于 2013-03-20T16:57:45.667 回答