<head>
<title> SceneJS Test</title>
<script type="text/javascript" src="resources/scenejs.js"></script>
</head>
SceneJSを使用して、キャンバスシーンに立方体をランダムに配置したいと思います。ライブラリには大きな学習曲線があるので、私自身はいくつかの例を確認してコーディングを開始しました。私はいくつかのコードを実行しましたが、エラーがどこにあるのか自分自身を納得させることができませんでした:
<body onload = "main()" bgcolor="white">
<canvas id="theCanvas" width="720" height="405">
</canvas>
<script type="text/javascript">
main = function({
N = 10;
var canvas = document.getElementById("theCanvas");
var sceneName = "theScene";
SceneJS.createScene({
id: sceneName,
canvasId: canvas,
nodes: [{
type:"library",
id:"mylib",
nodes:[]
},
// Viewing transform specifies eye position, looking at the origin by default
{
id:"lookat",
type: "lookAt",
eye : { x: 0.0, y: 1.0, z: 80.0 },
up : { z: 1.0 },
look:{x:0,y:0,z:0},
nodes: [
/* Camera describes the projection*/
{
type: "camera",
optics: {
type: "perspective",
fovy : 45.0,
aspect : 720/405,
near : 0.10,
far : 10000.0
},
nodes: [
{
type: "rotate",
id: "pitch",
angle: 0.0,
x : 1.0,
nodes: [
{
type: "rotate",
id: "yaw",
angle: 0.0,
y : 1.0,
}
]
}
]
}
]
}
]
});
var scale = 100;
var scene = SceneJS.scene(sceneName);
for(var i=0; i<N; i++)
{
scene.add("node",{
type:"translate",
x:(Math.random()-0.5)* scale,
y:(Math.random()-0.5)* scale,
z:(Math.random()-0.5)* scale,
nodes:[{
type: "cube",
id: "cube"+i
}]
});
}
});
</script>
</body>
エラーがどこにあるかを誰かに見つけてもらいたいのですが、本当にありがたいです。ブラウザに空白の白い画面しか表示されませんでした:(