Answers for "IMG MATERIAL IN THREEJS"

0

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;
Posted by: Guest on April-22-2021

Browse Popular Code Answers by Language