Using textures in THREE.js

前端 未结 6 1880
遇见更好的自我
遇见更好的自我 2020-11-27 03:16

I am starting with THREE.js, and I am trying to draw a rectangle with a texture on it, lit by a single source of light. I think this is as simple as it gets (HTML omitted fo

6条回答
  •  一整个雨季
    2020-11-27 03:39

    By the time the image is loaded, the renderer has already drawn the scene, hence it is too late. The solution is to change

    texture = THREE.ImageUtils.loadTexture('crate.gif'),
    

    into

    texture = THREE.ImageUtils.loadTexture('crate.gif', {}, function() {
        renderer.render(scene);
    }),
    

提交回复
热议问题