【问题标题】:Regarding Threejs texture Animation关于 Threejs 纹理动画
【发布时间】:2018-09-07 01:55:16
【问题描述】:

我正在使用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 );

【问题讨论】:

  • 请在您的问题中添加一些代码,说明您当前如何设置动画纹理。

标签: three.js


【解决方案1】:

您是否尝试过在纹理加载成功后触发回调函数?就像文档中的做法一样: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' );
    }
);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-09
    • 1970-01-01
    • 1970-01-01
    • 2021-11-03
    • 2015-06-03
    • 2019-05-01
    相关资源
    最近更新 更多