关于Threejs纹理动画

时间:2017-03-21 14:15:31

标签: three.js

我正在使用Threejs处理我遇到的纹理问题,所以我想问一个问题,即如何加载纹理而不启动动画,它显示没有开始动画的空白图像。任何人都可以告诉我该怎么做..

var geometry = new THREE.PlaneGeometry( 15, 5.3, 2 );
var te = new THREE.ImageUtils.loadTexture("b4.jpg") ;
var material = new THREE.MeshBasicMaterial( {color: "",map:te} );
plane = new THREE.Mesh( geometry, material);
plane.position.set(-12.89,-7.2,19);
plane.visible=false;
scene.add( plane );

1 个答案:

答案 0 :(得分:0)

您是否尝试在成功加载纹理后触发回调函数?就像在文档中完成它一样:TextureLoader

类似于:

var geometry = new THREE.PlaneGeometry( 15, 5.3, 2 );

var loader = new THREE.TextureLoader();
// load a resource
loader.load(
    // resource URL
    'b4.jpg',
    // Function when resource is loaded
    function ( texture ) {
        // do something with the texture
        var material = new THREE.MeshBasicMaterial( {color: "",map:te} );
        plane = new THREE.Mesh( geometry, material);

        plane.position.set(-12.89,-7.2,19);

        plane.visible=false;

        scene.add( plane );
    },
    // Function called when download errors
    function ( xhr ) {
        console.log( 'An error happened' );
    }
);
相关问题