Search code examples
imagethree.jsdata-uri

Use data URI image as material


Here is what I did, export the data URI and append it to the DOM for verification. But once I add it as a texture to a geometry, it can not be rendered. codepen link

var image = new Image();
image.src = DATA_URI;
document.body.appendChild(image); //the image is displayed properly

var material = new THREE.MeshBasicMaterial({
    map: new THREE.Texture(image)
});

Solution

  • There is no problem with you texture. It is the camera that has the problem. Place it at:

    camera.position.set( 0, 0, 100 );
    

    Updated: pen