0

I wrote a webgl program which works well with a local server, and now, I would like to run it locally. But I had errors and after some researches, I found that it's a cross domain issue in loading textures.

function loadTexture( path ) {
    var texture = new THREE.Texture( texture_placeholder );
    var material = new THREE.MeshBasicMaterial( { map: texture, overdraw: true} );

    var image = new Image();
    image.onload = function () {

        texture.needsUpdate = true;
        material.map.image = this;

       render();
   };
   texture.deallocate();
   renderer3D.deallocateTexture( texture );

   return material;
 }

I tried several solutions :

github.com/mrdoob/three.js/issues/1305

github.com/mrdoob/three.js/issues/944

gist.github.com/ekeneijeoma/1186920

github.com/mrdoob/three.js/wiki/How-to-run-things-locally (the 1.Change security for local files in a browser (access page as file:///example))

I precise that I have no problem on Firefox, it works without changing anything. The only solution which works on Chrome is to launch it with --allow-file-access-from-files. And on IE, I don't know how to solve it, I enabled in the browser security options "Access data sources across domains" and "Navigate sub-frames across different domains" (http://msdn.microsoft.com/fr-fr/library/ee797612(v=cs.20).aspx) but nothing. I use IEWebGL and I have noticed that on http://iewebgl.com/, "IEWebGL v1.0 Released" section, it's written "- Secure (no local content loading, no cross-domain textures)". So maybe it can't be solved on IE due to IEWebGL !?

So what would be the solution for IE, if there is one? And is there a way to solve the problem by changing the code, without lauching a local server or Chrome with special option?

Thanks!

SteveTJS
  • 635
  • 17
  • 32

2 Answers2

3

this question has been asked and answered at least 6 other times and is even answered in the three.js wiki.

The short of it is you need to run a local server. Open a terminal/shell/command prompt and type

cd <path/to/files>
python -m SimpleHTTPServer

Then in your browser go to

http://localhost:8000

Why is that not an option? It's simple and it solves the problem. It also doesn't leave your browser open to getting owned.

Here's several simple servers you could use

gman
  • 100,619
  • 31
  • 269
  • 393
0

thanks for your answer.

Indeed, it has already been asked and solved, I saw the solutions and it works well with a local server, and I totally agree with about security.

I was asking that because, firstly, it works without any server on Firefox and Safari, and on Google with --allow..., so if it was possible on IE, it would have been good. And secondly, because I wanted a very simple program which works quickly without having to install python or something else for a server,...

In fact, it's for an offline application (I know it's weird for a web based application but it's not my choice :) ). Anyway, it works for Firefox, Chrome and Safari so, too bad for IE.

Thanks!

SteveTJS
  • 635
  • 17
  • 32
  • This section is for answers, not replies; you should add it as a comment to the other answer, instead. If you are happy with the other answer, please accept it by clicking on the checkmark. – WestLangley Feb 06 '13 at 15:14