Skip to content

Instantly share code, notes, and snippets.

@xeolabs
Created September 5, 2010 11:55
Show Gist options
  • Save xeolabs/565978 to your computer and use it in GitHub Desktop.
Save xeolabs/565978 to your computer and use it in GitHub Desktop.
<!-- SceneJS library -->
<script src="scenejs.js"></script>
<!-- JSON airplane model -->
<script src="airplane-model.js"></script>
<!-- WebGL canvas -->
<canvas id="theCanvas" width: 900 height: 900></canvas>
<!-- Scene definition -->
<script type="text/javascript">
SceneJS.createNode({
type: "scene",
id: "myScene", // ID for scene root node
canvasId: 'theCanvas',
nodes: [
{
type: "lookAt",
eye : { x: -1.0, y: 0.0, z: 15 },
look : { x: -1.0, y: 0, z: 0 },
up : { y: 1.0 }
nodes: [
{
type: "camera",
optics: {
type: "perspective",
fovy : 55.0,
aspect : 1.0,
near : 0.10,
far : 1000.0
},
nodes: [
{
type: "light",
mode: "dir",
color: { r: 1.0, g: 1.0, b: 1.0 },
dir: { x: 1.0, y: -1.0, z: 1.0 }
},
{
type: "light",
mode: "dir",
color: { r: 1.0, g: 1.0, b: 1.0 },
dir: { x: -1.0, y: -1.0, z: -3.0 }
},
{
type: "rotate",
id: "yaw", // ID for node
y: 1.0, // Rotate about Y-axis
angle: 0.0,
nodes: [
{
type: "rotate",
id: "pitch", // ID for node
x: 1.0, // Rotate about X-axis
angle: 0.0,
nodes: [
{
type: "instance",
target: "seymourplane"
}
]
}
]
}
]
}
]
});
/* Set angles on the rotate nodes
*/
SceneJS.withNode("yaw").set("angle", yaw);
SceneJS.withNode("pitch").set("angle", pitch);
/* Start the rendering loop
*/
SceneJS.withNode("theScene").start();
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment