annotate Earth_x/universe_x.html @ 21:87850fc55445

save
author <e085737>
date Sun, 16 Jan 2011 00:57:53 +0900
parents 0800fc0944ac
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
1 <html>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
2 <head>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
3 <title>Earth and Mars</title>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
4 <script src="jkl-parsexml.js"></script>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
5 <script src="exml.js"></script>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
6 <script src="resources/J3DI.js"> </script>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
7 <script src="resources/J3DIMath.js" type="text/javascript"> </script>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
8
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
9 <script id="vshader" type="x-shader/x-vertex">
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
10 uniform mat4 u_modelViewProjMatrix;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
11 uniform mat4 u_normalMatrix;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
12 uniform vec3 lightDir;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
13
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
14 attribute vec3 vNormal;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
15 attribute vec4 vTexCoord;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
16 attribute vec4 vPosition;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
17
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
18 varying float v_Dot;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
19 varying vec2 v_texCoord;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
20
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
21 void main()
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
22 {
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
23 gl_Position = u_modelViewProjMatrix * vPosition;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
24 v_texCoord = vTexCoord.st;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
25 vec4 transNormal = u_normalMatrix * vec4(vNormal,1);
5
<e085737>
parents: 2
diff changeset
26 v_Dot = max(dot(transNormal.xyz, lightDir), 0.0);
1
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
27 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
28 </script>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
29
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
30 <script id="fshader" type="x-shader/x-fragment">
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
31 #ifdef GL_ES
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
32 precision mediump float;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
33 #endif
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
34
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
35 uniform sampler2D sampler2d;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
36
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
37 varying float v_Dot;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
38 varying vec2 v_texCoord;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
39
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
40 void main()
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
41 {
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
42 vec4 color = texture2D(sampler2d,v_texCoord);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
43 color += vec4(0.1,0.1,0.1,1);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
44 gl_FragColor = vec4(color.xyz * v_Dot, color.a);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
45 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
46 </script>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
47
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
48 <script>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
49 function init()
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
50 {
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
51 var gl = initWebGL("example", "vshader", "fshader",
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
52 [ "vNormal", "vTexCoord", "vPosition"],
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
53 [ 0, 0, 0, 1 ], 10000);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
54
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
55 gl.uniform3f(gl.getUniformLocation(gl.program, "lightDir"), 0, 0, 1);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
56 gl.uniform1i(gl.getUniformLocation(gl.program, "sampler2d"), 0);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
57
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
58 gl.enable(gl.TEXTURE_2D);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
59
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
60 // xml_fileからtextureを読み込んでいる。
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
61 loadObjXml(gl, "./earth.xml");
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
62 loadObjXml(gl, "./moon.xml");
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
63
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
64 return gl;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
65 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
66
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
67 width = -1;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
68 height = -1;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
69
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
70 function reshape(ctx)
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
71 {
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
72 var canvas = document.getElementById('example');
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
73 if (canvas.width == width && canvas.width == height)
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
74 return;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
75
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
76 width = canvas.width;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
77 height = canvas.height;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
78
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
79 ctx.viewport(0, 0, width, height);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
80
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
81 ctx.perspectiveMatrix = new J3DIMatrix4();
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
82 ctx.perspectiveMatrix.perspective(30, width/height, 1, 10000);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
83 ctx.perspectiveMatrix.lookat(0,0,500, 0, 0, 0, 0, 1, 0);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
84 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
85
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
86 function drawOne(ctx, glObj, star)
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
87 {
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
88 // setup VBOs
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
89 ctx.enableVertexAttribArray(0);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
90 ctx.enableVertexAttribArray(1);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
91 ctx.enableVertexAttribArray(2);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
92
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
93 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.vertexObject);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
94 ctx.vertexAttribPointer(2, 3, ctx.FLOAT, false, 0, 0);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
95
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
96 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.normalObject);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
97 ctx.vertexAttribPointer(0, 3, ctx.FLOAT, false, 0, 0);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
98
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
99 ctx.bindBuffer(ctx.ARRAY_BUFFER, glObj.texCoordObject);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
100 ctx.vertexAttribPointer(1, 2, ctx.FLOAT, false, 0, 0);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
101
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
102 ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, glObj.indexObject);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
103
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
104
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
105 var mvMatrix = new J3DIMatrix4();
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
106 var $siman2 = new J3DIMatrix4();
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
107
11
0800fc0944ac walk_ver1
<e085737>
parents: 5
diff changeset
108
1
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
109 mvMatrix = star.mat;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
110 mvMatrix.rotate(star.angle, 0,1,0); // 親の変換行列を取得
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
111 mvMatrix.translate(star.x,star.y,star.z);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
112 mvMatrix.getAsArrayMatrix($siman2.$matrix); // 自身の変換行列を取得
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
113 for(num in star.cn){
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
114 star.cn.mat = $siman2; // 自分の子どもに変換行列を渡す。
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
115 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
116
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
117 mvMatrix.scale(star.scale, star.scale, star.scale);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
118
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
119 var normalMatrix = new J3DIMatrix4(mvMatrix);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
120 normalMatrix.invert();
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
121 normalMatrix.transpose();
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
122 normalMatrix.setUniform(ctx, ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
123
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
124 var mvpMatrix = new J3DIMatrix4(ctx.perspectiveMatrix);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
125 mvpMatrix.multiply(mvMatrix);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
126 mvpMatrix.setUniform(ctx, ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
127
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
128 ctx.bindTexture(ctx.TEXTURE_2D, glObj.texture);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
129 ctx.drawElements(ctx.TRIANGLES, glObj.numIndices, ctx.UNSIGNED_SHORT, 0);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
130 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
131
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
132
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
133 function drawPicture(ctx)
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
134 {
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
135 reshape(ctx);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
136 ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
137
2
e085737@tamayose-syuuichi-no-macbook.local
parents: 1
diff changeset
138 var Moon2 = new star( ctx.obj.Moon, null, currentAngle, 20, 0, 0, 0.3);
e085737@tamayose-syuuichi-no-macbook.local
parents: 1
diff changeset
139 var Moon = new star( ctx.obj.Moon, Moon2, currentAngle , 200, 0, 0, 0.6);
1
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
140 var Earth = new star( ctx.obj.Earth, Moon, currentAngle, 0, 0, 0, 1.0);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
141
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
142
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
143 render(ctx,Earth);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
144
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
145 ctx.flush();
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
146
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
147 framerate.snapshot();
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
148
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
149 currentAngle += incAngle;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
150 if (currentAngle > 360)
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
151 currentAngle -= 360;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
152 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
153
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
154 function start()
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
155 {
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
156 var c = document.getElementById("example");
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
157 var w = Math.floor(window.innerWidth * 0.9);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
158 var h = Math.floor(window.innerHeight * 0.9);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
159
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
160 c.width = w;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
161 c.height = h;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
162
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
163 var ctx = init();
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
164 currentAngle = 0;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
165 incAngle = 0.4;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
166 var f = function() { drawPicture(ctx) };
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
167 setInterval(f, 10);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
168 framerate = new Framerate("framerate");
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
169 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
170
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
171 function render(ctx,star){
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
172 var p = new Object();
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
173 for(p=star; p; p = p.cn ){
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
174 drawOne(ctx, p.texture, p);
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
175 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
176 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
177
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
178 // 惑星の情報を格納している。
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
179 function star(texture,cn,angle,x,y,z,scale){
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
180 this.x = x;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
181 this.y = y;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
182 this.z = z;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
183 this.mat = new J3DIMatrix4();
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
184 this.angle = angle;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
185 this.scale = scale;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
186 this.texture = texture;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
187 this.cn = cn; // 子どもの名前
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
188 return this;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
189 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
190 </script>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
191 <style type="text/css">
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
192 canvas {
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
193 border: 2px solid black;
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
194 }
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
195 </style>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
196 </head>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
197 <body onload="start()">
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
198 <canvas id="example">
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
199 There is supposed to be an example drawing here, but it's not important.
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
200 </canvas>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
201 <div id="framerate"></div>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
202 <div id="console"></div>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
203 </body>
fccccbcc94be xml_file_read
e085737@tamayose-syuuichi-no-macbook.local
parents:
diff changeset
204 </html>