Question

im new to javascript and am intersted in creating a small o3d script:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Game Website</title>
</head>

<body>

<script type="text/javascript" src="o3djs/base.js"></script>
<script type = "text/javascript" id="myscript">

o3djs.require('o3djs.camera');

window.onload = init;

function init(){
 document.write("jkjewfjnwle");
}

</script>

<div align="background">
 <div id="game_container" style="margin: 0px auto; clear: both; background-image: url('./tmp.png'); width: 800px; height:600px; padding: 0px; background-repeat: no-repeat; padding-top: 1px;"></div>
</div>

</body>
</html>

the browser cant seem to find o3djs/base.js in this line

<script type="text/javascript" src="o3djs/base.js"></script>

and gives me an uncaught referenceerror at this line

 o3djs.require('o3djs.camera');

Obviously, because it can't find the o3djs/base.js...

I have installed the o3d pluggin from google and they say that should be IT ive tried on firefox, ie and chrome

thanks

Was it helpful?

Solution

Files that your HTML point to (CSS, JS, links) are searched relative to the document's path.

E.g. if your document's URL is http://localhost/foo/testpage.html, in this case you must put mentioned base.js in http://localhost/foo/o3djs/, etc. So, if your localhost is at C:\Server (assuming you use some Windows-like environment), the file must be called C:\Server\foo\o3djs\base.js.

OTHER TIPS

Also make sure you include all the other files needed by the API, most of them can be found here: http://o3d.googlecode.com/svn/trunk/samples_webgl/o3djs/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top