1

I have been trying to teach myself WebGL from LearningWebGL.com. Previously when I have created a web page with WebGL on it & saved it to my hard drive I could open it & see the result in Firefox or Chrome, but now I just get the basic black square in both! Whereas if I open an example from the website it opens fine. There are similar reports on the LearningWebGL site but now-one seems to be able to fix it! I have Firefox & Chrome on Ubuntu 12.04. Can anyone help? Thanks d0m.

d0m.
  • 11
  • 2

2 Answers2

1

If it works from a website then use a website. Open a terminal/shell/command-prompt and type

cd path/to/page
python -m SimpleHTTPServer

Then go to your browser and type

http://localhost:8000

If you want more speed, look into using node.js

Most browser now-a-days disallow doing much from a local html file because there is the possibility bad guys could use that to steal your info by reading a local file and then uploading it to their servers. The solution is to run your own server which fortunately is super simple.

Also, check the JavaScript console. It will usually provide error messages about why things are not working

Community
  • 1
  • 1
gman
  • 100,619
  • 31
  • 269
  • 393
  • Hi Tried Simple Server but still not working. I copied & pasted source code from http://get.webgl.org/ then when I open the saved file via localhost I just get the text bits. It works fine when I go to the site direct. On terminal I got localhost - - [22/Jun/2013 19:39:08] "GET / HTTP/1.1" 200 - localhost - - [22/Jun/2013 19:39:12] "GET /WebGl-SpinyBox.html HTTP/1.1" 200 - localhost - - [22/Jun/2013 19:39:12] code 404, message File not found. – d0m. Jun 22 '13 at 18:49
  • Hi The only JavaScript Console I can find is in Chrome. I have used it & it says that Uncaught ReferenceError: mat4 is not defined Failed to load resource Uncaught ReferenceError: mat4 is not defined but mat4 is I think part of webgl/opengl as described in the website http://learningwebgl.com/blog/?page_id=1217 described in the text mat4.perspective(45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0, pMatrix); As you can see, this perspective stuff is using a function from a module called mat4, and involves an intriguingly-named variable called pMatrix. have fun. d0m. – d0m. Jun 23 '13 at 11:53
  • mat4 is not part of WebGL or OpenGL. It is from glMatrix https://github.com/toji/gl-matrix – gman Jun 24 '13 at 06:41
  • Hi That doesn’t explain why it used to work back before Xmas. I've looked at the github stuff & I've looked for glMatrix in Ubuntu's Synaptic Package Manager; the only thing it has is "XScreenSaver-gl GL(Mesa) screen hacks for xscreensaver" which is loaded. I have been trying to sort this out since Xmas & I was enjoying learning 3D stuff athttp://learningwebgl.com/blog/ by Tony Parisi. – d0m. Jun 25 '13 at 17:24
  • Hi I've been looking into it a bit moor & as I understand it there is a line at the beginning ( "" ) which I believe is ment to call gl-matrix - Javascript Matrix and Vector library. Am I mistaken; have things changed. Have fun. d0m. – d0m. Jul 03 '13 at 12:04
1

Maybe this will do the trick:

https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally

Make sure that all textures are accessible and make sure that you enabled things locally (link). Hope this helps.

Dragan Okanovic
  • 7,509
  • 3
  • 32
  • 48
  • Hi I've tried entering "Dragons" & setting security.fileuri.strict_origin_policy to false but no good! – d0m. Jun 22 '13 at 18:17