image as material three.js code example

Example: IMG MATERIAL IN THREEJS

var img = new Image()
    var canvas = document.createElement("canvas"),
    ctx = canvas.getContext("2d"),
    url = "http://imageurl"; // insert image url here

img.crossOrigin = "Anonymous";

img.onload = function() {
    canvas.width = img.width;
    canvas.height = img.height;
    ctx.drawImage( img, 0, 0 );

mat.map = new THREE.CanvasTexture(canvas);
var object = new THREE.Mesh( geometry, mat );
scene.add( object );
}
img.src = url;

Tags:

Misc Example