Using textures in THREE.js

前端 未结 6 1905
遇见更好的自我
遇见更好的自我 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:34

    In version r75 of three.js, you should use:

    var loader = new THREE.TextureLoader();
    loader.load('texture.png', function ( texture ) {
      var geometry = new THREE.SphereGeometry(1000, 20, 20);
      var material = new THREE.MeshBasicMaterial({map: texture, overdraw: 0.5});
      var mesh = new THREE.Mesh(geometry, material);
      scene.add(mesh);
    });
    

提交回复
热议问题