Schoening Posted May 29, 2015 Share Posted May 29, 2015 I am new to v3 and running into a couple of issues... Firstly. I am making a game with my Girlfriend to teach her some JavaScript. She is afraid of using commands or installing a webserver on her mac, so I am trying to make crossOrigin work to load textures. I am using an array of objects that store the name and url, I then add the crossOrigin msg "behind the scenes":var textures = [ { name: "burger", url: "images/Hamburger.png" }, { name: "moon", url: "images/Lunaone_1.png" }];var l = textures.length;for ( var i = 0; i < l; i += 1 ) { textures[i].crossOrigin = "Anonymous"; loader.add( textures[i] );}However when I try to use the textures:var burger = new PIXI.Sprite( textures["burger"].texture );I get the following error:Uncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at file:///C:/Users/Oliver/Documents/pirate-game/images/Hamburger.png may not be loaded.Is there something I can do here without having to install a webserver? Quote Link to comment Share on other sites More sharing options...
xerver Posted May 29, 2015 Share Posted May 29, 2015 Without telling chrome to allow file:// protocol access from local (with a command line param) this will fail because it is a security violation. Also, if your opening a file:// locally, and loading a file:// then that isn't cross origin IIRC. Running a local server is easier than using a special launch of chrome most of the time. You can just install the `http-server` module (npm i -g http-server), then start it with 4 characters:hs .Doesn't get much easier than that. Quote Link to comment Share on other sites More sharing options...
dirkk0 Posted May 29, 2015 Share Posted May 29, 2015 You can also do a "python -m SimpleHTTPServer" in the directory the files are in and surf to http://localhost:8000. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.