akella / fake3d

517 stars 106 forks source link

Can't load image... #2

Closed cathyleeu closed 5 years ago

cathyleeu commented 5 years ago

Hello. I read your article and I was really impressed with your work. So I downloaded your Demo code for studying and opened it. but I can't load the image. I got an error from the console.

Uncaught DOMException: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The image element contains cross-origin data, and may not be loaded.

How can I fix this problem and see properly it on my local status?

by the way, Sorry to my poor English. I hope you to understand my situation and reply it Thanks.

akella commented 5 years ago

I think you have to start some server locally, and it will work then, you cant load images in just local html file without server.

cathyleeu commented 5 years ago

Thanks!

oeliott commented 5 years ago

Hey,

I have the same issue even on local server and online. I think it is because we use Cross-domain images and not local images. From my understanding, the code needs something like: img.crossOrigin = "";

But I am not sure how to implement this... Any help would be welcome :)

Thanks.

akella commented 5 years ago

dont use cross-origin images, or disable your browser policy if thats for test https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en

oeliott commented 5 years ago

Thank you for your quick answer, For my web project, I don't have an option to host the image and need to take it from an external URL... And this extension will help this issue only for me but not for users

akella commented 5 years ago

I think this should help you https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image

oeliott commented 5 years ago

Hey, Thank you. I manage to make it work by simply adding i.crossOrigin = "Anonymous"; here: function c(t, e) { var i = new Image; i.crossOrigin = "Anonymous"; return i.src = t, i.onload = e, i }

In case anyone else has this issue 👍

And Thank you @akella for this 3d effect!

akella commented 5 years ago

You are welcome, but i would still advise to avoid crossOrigin whenever possible. You never know new policies