SVG as texture?

I red this question #814

And also I run onto this js library: http://code.google.com/p/canvg/ which can do SVG to canvas to data conversion.

This is my code:

var imageCanvas2 = document.createElement("canvas");
canvg(imageCanvas2, 'images/46.svg');
var imag = imageCanvas2.toDataURL('image/png');   // --> here is the converted image data

var cubeMaterial = [new THREE.MeshBasicMaterial({
    map : THREE.ImageUtils.loadTexture(imag)
})];

This gives me error: “Cross-origin image load denied by Cross-Origin Resource Sharing policy.”

What are my options here?

Also I should mention that WebGL is not an option since I will be using this on mobile devices which don’t support WebGL.

Author: Fantashit

2 thoughts on “SVG as texture?

  1. var imageCanvas2 = document.createElement("canvas");
    canvg(imageCanvas2, 'images/46.svg');
    
    var texture = new THREE.Texture(imageCanvas2);
    texture.needsUpdate = true;
  2. My god… I can’t believe how stupid.
    This works on iOS also.

    I have an SVG image which is the same color as WebView’s background so that is why I didin’t saw it 😀
    At least it works and someone can laugh now when reads this 😀

Comments are closed.