I
I
IliaNeverov2020-06-12 21:59:31
JavaScript
IliaNeverov, 2020-06-12 21:59:31

How to draw a texture on a mesh in three js?

Hello! I recently started learning the three js library. Unable to stretch the texture on the mesh. Please tell me how to do it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
profesor08, 2020-06-13
@IliaNeverov

https://threejs.org/docs/#api/en/loaders/TextureLoader

// instantiate a loader
var loader = new THREE.TextureLoader();

// load a resource
loader.load(
  // resource URL
  'textures/land_ocean_ice_cloud_2048.jpg',

  // onLoad callback
  function ( texture ) {
    // in this example we create the material when the texture is loaded
    var material = new THREE.MeshBasicMaterial( {
      map: texture
     } );
  },

  // onProgress callback currently not supported
  undefined,

  // onError callback
  function ( err ) {
    console.error( 'An error happened.' );
  }
);

M
McBernar, 2020-06-12
@McBernar

Well, probably, through the creation of a mesh, where you need to transfer the geometry and texture.
Show me your example, what's the point of guessing here?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question