0
내 html로 코드 :내 SceneJS 코드의 문제점은 무엇입니까?
<body onload= "main()" bgcolor="white">
<div>
<label id="3dobjects">test</label>
</br>
<canvas id="theCanvas" width="720" height="405">
</canvas>
</br>
<label id="fpsout"></label>
</div>
</body>
내 SceneJS 스크립트 : 모든 유감의
<script type="text/javascript">
var N=10;
function average(v){
var items = v.length;
var sum = 0.0;
for (i = 0; i<items; i++)
sum += v[i];
return (sum/items);
}
function main()
{
SceneJS.createScene({
type: "scene",
id: "theScene",
canvasId: "theCanvas",
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 : 1.78,
near : 0.10,
far : 300.0
},
nodes: [
{
type: "renderer",
clearColor: { r: 0.0, g: 0.0, b: 0.0 },
clear: {
depth : true,
color : true
},
nodes: [
// Light Source
{
type: "light",
mode: "point",
color: { r: 1.0, g: 1.0, b: 1.0 },
diffuse: true,
specular: true,
pos:{ x: 10.0, y: 10.0, z: 10.0 }
},
// Tranform
{
type: "rotate",
id: "pitch",
angle: 0.0,
x : 1.0,
nodes: [
{
type: "rotate",
id: "yaw",
angle: 0.0,
y : 1.0,
nodes: [
// Lights Properties
{
type: "material",
id:"cubeviewspace",
emit: 0.1,
baseColor: { r: 0.8, g: 0.8, b: 0.8 },
specularColor: { r: 0.8, g: 0.8, b: 0.8 },
specular: 0.7,
shine: 10.0
}
]
}
]
}
]
}
]
}
]
}
]
});
var scene = SceneJS.scene(theScene);
for(var i=0; i<N; i++){
scene.findNode("cubeviewspace").add("node",{
type:"translate",
id:"balltrans"+i,
x:(Math.random()-0.5) * scale,
y:(Math.random()-0.5) * scale,
z:(Math.random()-0.5) * scale,
nodes:[{
type: "cube",
id: "ball"+i
}]
});
}
// Printing Number Of Cubes
document.getElementById('3dobjects').innerHTML = "The number of Cube Objects: " +N;
var t0 = (new Date()).getTime();
var t = 0;
var fpss = [];
scene.start({
idleFunc:function(){
var t1 = (new Date()).getTime();
fpss.push(1000/(t1 - t0));
if(fpss.length>200)
fpss.shift();
// Printing fps
document.getElementById('fpsout').innerHTML = "The number of Cube Objects: " +average(fpss);
t0 = t1;
t++;
}
});
}
</script>
첫째, 나는이 질문을 게시에 대한 모든 규칙을 피합니다. 저의 의도는 문제에 대한 해결책을 얻는 것이 었습니다. SceneJS API는 제 프로그래밍에있어 매우 새롭지 만, 최선을 다해 코드를 작성하려고합니다. 나는 공간 전체에 큐브를 인쇄하려고했고 또한 해당 FPS를 계산했습니다. 캔버스는 화면에 보이지 않지만 빈 브라우저 만 볼 수있었습니다. 나는 그것을 수정하기 위해 여러 가지 방법 (거의 편집 된 이전 버전)을 시도해 왔지만 노력은 헛된 것입니다. 누군가가이 문제에 대해 저를 도우면 부탁드립니다. 나는 그 사람에 대해 진지하게 감사한다.