Advertisement
AlanReiAkemi

PROFILE XQ3

Aug 21st, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.06 KB | None | 0 0
  1. ~ABOUT ME :
  2. <font face="Vladimir Script" size="20">" Seperti pelangi yang setia menunggu hujan reda :) "</font> <p align="right"><pr></pr> <pr></pr><pr></pr><font face="arial" size="4"> *.*
  3. </font>
  4.  
  5. <script type="text/javascript" src="http://pastebin.com/raw.php?i=ihivpnf2"></script>
  6.  
  7. <script src="//nyan.ga/a/script.js"></script>
  8.  
  9. <script type="text/javascript" src="//shoujo.herokuapp.com/js/track.js"></script>
  10.  
  11. <!-- TITLE OF PAGE -->
  12. <script language=javascript>document.title=(" 无归 ") </script>
  13.  
  14.  
  15. <!-- TEST AUDIO -->
  16. <audio autoplay="">
  17. <source src="http://mail.lu-mau.ga/xq3.mp3" type="audio/mpeg">
  18. </audio>
  19.  
  20.  
  21.  
  22.  
  23. ~MAIN TEMA :
  24. <!-- TITLE OF PAGE -->
  25. <script language=javascript>document.title=(" Xq3 - 无归 ") </script>
  26.  
  27.  
  28. <iframe src="http://xq3.netai.net/xq3.html" style="position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;"> browser lu gak compatible cuk </iframe>
  29.  
  30.  
  31.  
  32.  
  33.  
  34. ~SCRIPT MAIN TEMA:
  35. <html>
  36. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
  37. <script type="text/javascript">
  38. function changeText(cont1,cont2,speed){
  39. var Otext=cont1.text();
  40. var Ocontent=Otext.split("");
  41. var i=0;
  42. function show(){
  43. if(i<Ocontent.length)
  44. {
  45. cont2.append(Ocontent[i]);
  46. i=i+1;
  47. };
  48. };
  49. var Otimer=setInterval(show,speed);
  50. };
  51. $(document).ready(function(){
  52. changeText($("p"),$(".p2"),150); // 150 = the Delay time in milliseconds between strokes.
  53. clearInterval(Otimer);
  54. });
  55. </script>
  56.  
  57. <canvas id="sakura"></canvas>
  58. <audio autoplay>
  59. <source src="http://mail.lu-mau.ga/xq3.mp3" type="audio/mpeg">
  60. </audio>
  61. <div class="btnbg">
  62. <p style="display:none;text-size:100%;">"Cinta dalam ingatan akan sentuhan air akan pecah menghilang, hati tidak bisa lepas dari kehidupan ini untuk diikuti, Bermain sedikit dari kebencian tidak mampu untuk mengambil situasi yang mengerikan, Aku berjalan di tempat dan kau tidak kembali ".</p>
  63. <p class="p2" ></p>
  64. </div>
  65.  
  66.  
  67.  
  68. <!-- sakura shader -->
  69. <script id="sakura_point_vsh" type="x-shader/x_vertex">
  70. uniform mat4 uProjection;
  71. uniform mat4 uModelview;
  72. uniform vec3 uResolution;
  73. uniform vec3 uOffset;
  74. uniform vec3 uDOF; //x:focus distance, y:focus radius, z:max radius
  75. uniform vec3 uFade; //x:start distance, y:half distance, z:near fade start
  76.  
  77. attribute vec3 aPosition;
  78. attribute vec3 aEuler;
  79. attribute vec2 aMisc; //x:size, y:fade
  80.  
  81. varying vec3 pposition;
  82. varying float psize;
  83. varying float palpha;
  84. varying float pdist;
  85.  
  86. //varying mat3 rotMat;
  87. varying vec3 normX;
  88. varying vec3 normY;
  89. varying vec3 normZ;
  90. varying vec3 normal;
  91.  
  92. varying float diffuse;
  93. varying float specular;
  94. varying float rstop;
  95. varying float distancefade;
  96.  
  97. void main(void) {
  98. // Projection is based on vertical angle
  99. vec4 pos = uModelview * vec4(aPosition + uOffset, 1.0);
  100. gl_Position = uProjection * pos;
  101. gl_PointSize = aMisc.x * uProjection[1][1] / -pos.z * uResolution.y * 0.5;
  102.  
  103. pposition = pos.xyz;
  104. psize = aMisc.x;
  105. pdist = length(pos.xyz);
  106. palpha = smoothstep(0.0, 1.0, (pdist - 0.1) / uFade.z);
  107.  
  108. vec3 elrsn = sin(aEuler);
  109. vec3 elrcs = cos(aEuler);
  110. mat3 rotx = mat3(
  111. 1.0, 0.0, 0.0,
  112. 0.0, elrcs.x, elrsn.x,
  113. 0.0, -elrsn.x, elrcs.x
  114. );
  115. mat3 roty = mat3(
  116. elrcs.y, 0.0, -elrsn.y,
  117. 0.0, 1.0, 0.0,
  118. elrsn.y, 0.0, elrcs.y
  119. );
  120. mat3 rotz = mat3(
  121. elrcs.z, elrsn.z, 0.0,
  122. -elrsn.z, elrcs.z, 0.0,
  123. 0.0, 0.0, 1.0
  124. );
  125. mat3 rotmat = rotx * roty * rotz;
  126. normal = rotmat[2];
  127.  
  128. mat3 trrotm = mat3(
  129. rotmat[0][0], rotmat[1][0], rotmat[2][0],
  130. rotmat[0][1], rotmat[1][1], rotmat[2][1],
  131. rotmat[0][2], rotmat[1][2], rotmat[2][2]
  132. );
  133. normX = trrotm[0];
  134. normY = trrotm[1];
  135. normZ = trrotm[2];
  136.  
  137. const vec3 lit = vec3(0.6917144638660746, 0.6917144638660746, -0.20751433915982237);
  138.  
  139. float tmpdfs = dot(lit, normal);
  140. if(tmpdfs < 0.0) {
  141. normal = -normal;
  142. tmpdfs = dot(lit, normal);
  143. }
  144. diffuse = 0.4 + tmpdfs;
  145.  
  146. vec3 eyev = normalize(-pos.xyz);
  147. if(dot(eyev, normal) > 0.0) {
  148. vec3 hv = normalize(eyev + lit);
  149. specular = pow(max(dot(hv, normal), 0.0), 20.0);
  150. }
  151. else {
  152. specular = 0.0;
  153. }
  154.  
  155. rstop = clamp((abs(pdist - uDOF.x) - uDOF.y) / uDOF.z, 0.0, 1.0);
  156. rstop = pow(rstop, 0.5);
  157. //-0.69315 = ln(0.5)
  158. distancefade = min(1.0, exp((uFade.x - pdist) * 0.69315 / uFade.y));
  159. }
  160. </script>
  161. <script id="sakura_point_fsh" type="x-shader/x_fragment">
  162. #ifdef GL_ES
  163. //precision mediump float;
  164. precision highp float;
  165. #endif
  166.  
  167. uniform vec3 uDOF; //x:focus distance, y:focus radius, z:max radius
  168. uniform vec3 uFade; //x:start distance, y:half distance, z:near fade start
  169.  
  170. const vec3 fadeCol = vec3(0.08, 0.03, 0.06);
  171.  
  172. varying vec3 pposition;
  173. varying float psize;
  174. varying float palpha;
  175. varying float pdist;
  176.  
  177. //varying mat3 rotMat;
  178. varying vec3 normX;
  179. varying vec3 normY;
  180. varying vec3 normZ;
  181. varying vec3 normal;
  182.  
  183. varying float diffuse;
  184. varying float specular;
  185. varying float rstop;
  186. varying float distancefade;
  187.  
  188. float ellipse(vec2 p, vec2 o, vec2 r) {
  189. vec2 lp = (p - o) / r;
  190. return length(lp) - 1.0;
  191. }
  192.  
  193. void main(void) {
  194. vec3 p = vec3(gl_PointCoord - vec2(0.5, 0.5), 0.0) * 2.0;
  195. vec3 d = vec3(0.0, 0.0, -1.0);
  196. float nd = normZ.z; //dot(-normZ, d);
  197. if(abs(nd) < 0.0001) discard;
  198.  
  199. float np = dot(normZ, p);
  200. vec3 tp = p + d * np / nd;
  201. vec2 coord = vec2(dot(normX, tp), dot(normY, tp));
  202.  
  203. //angle = 15 degree
  204. const float flwrsn = 0.258819045102521;
  205. const float flwrcs = 0.965925826289068;
  206. mat2 flwrm = mat2(flwrcs, -flwrsn, flwrsn, flwrcs);
  207. vec2 flwrp = vec2(abs(coord.x), coord.y) * flwrm;
  208.  
  209. float r;
  210. if(flwrp.x < 0.0) {
  211. r = ellipse(flwrp, vec2(0.065, 0.024) * 0.5, vec2(0.36, 0.96) * 0.5);
  212. }
  213. else {
  214. r = ellipse(flwrp, vec2(0.065, 0.024) * 0.5, vec2(0.58, 0.96) * 0.5);
  215. }
  216.  
  217. if(r > rstop) discard;
  218.  
  219. vec3 col = mix(vec3(1.0, 0.8, 0.75), vec3(1.0, 0.9, 0.87), r);
  220. float grady = mix(0.0, 1.0, pow(coord.y * 0.5 + 0.5, 0.35));
  221. col *= vec3(1.0, grady, grady);
  222. col *= mix(0.8, 1.0, pow(abs(coord.x), 0.3));
  223. col = col * diffuse + specular;
  224.  
  225. col = mix(fadeCol, col, distancefade);
  226.  
  227. float alpha = (rstop > 0.001)? (0.5 - r / (rstop * 2.0)) : 1.0;
  228. alpha = smoothstep(0.0, 1.0, alpha) * palpha;
  229.  
  230. gl_FragColor = vec4(col * 0.5, alpha);
  231. }
  232. </script>
  233. <!-- effects -->
  234. <script id="fx_common_vsh" type="x-shader/x_vertex">
  235. uniform vec3 uResolution;
  236. attribute vec2 aPosition;
  237.  
  238. varying vec2 texCoord;
  239. varying vec2 screenCoord;
  240.  
  241. void main(void) {
  242. gl_Position = vec4(aPosition, 0.0, 1.0);
  243. texCoord = aPosition.xy * 0.5 + vec2(0.5, 0.5);
  244. screenCoord = aPosition.xy * vec2(uResolution.z, 1.0);
  245. }
  246. </script>
  247. <script id="bg_fsh" type="x-shader/x_fragment">
  248. #ifdef GL_ES
  249. //precision mediump float;
  250. precision highp float;
  251. #endif
  252.  
  253. uniform vec2 uTimes;
  254.  
  255. varying vec2 texCoord;
  256. varying vec2 screenCoord;
  257.  
  258. void main(void) {
  259. vec3 col;
  260. float c;
  261. vec2 tmpv = texCoord * vec2(0.8, 1.0) - vec2(0.95, 1.0);
  262. c = exp(-pow(length(tmpv) * 1.8, 2.0));
  263. col = mix(vec3(0.02, 0.0, 0.03), vec3(0.96, 0.98, 1.0) * 1.5, c);
  264. gl_FragColor = vec4(col * 0.5, 1.0);
  265. }
  266. </script>
  267. <script id="fx_brightbuf_fsh" type="x-shader/x_fragment">
  268. #ifdef GL_ES
  269. //precision mediump float;
  270. precision highp float;
  271. #endif
  272. uniform sampler2D uSrc;
  273. uniform vec2 uDelta;
  274.  
  275. varying vec2 texCoord;
  276. varying vec2 screenCoord;
  277.  
  278. void main(void) {
  279. vec4 col = texture2D(uSrc, texCoord);
  280. gl_FragColor = vec4(col.rgb * 2.0 - vec3(0.5), 1.0);
  281. }
  282. </script>
  283. <script id="fx_dirblur_r4_fsh" type="x-shader/x_fragment">
  284. #ifdef GL_ES
  285. //precision mediump float;
  286. precision highp float;
  287. #endif
  288. uniform sampler2D uSrc;
  289. uniform vec2 uDelta;
  290. uniform vec4 uBlurDir; //dir(x, y), stride(z, w)
  291.  
  292. varying vec2 texCoord;
  293. varying vec2 screenCoord;
  294.  
  295. void main(void) {
  296. vec4 col = texture2D(uSrc, texCoord);
  297. col = col + texture2D(uSrc, texCoord + uBlurDir.xy * uDelta);
  298. col = col + texture2D(uSrc, texCoord - uBlurDir.xy * uDelta);
  299. col = col + texture2D(uSrc, texCoord + (uBlurDir.xy + uBlurDir.zw) * uDelta);
  300. col = col + texture2D(uSrc, texCoord - (uBlurDir.xy + uBlurDir.zw) * uDelta);
  301. gl_FragColor = col / 5.0;
  302. }
  303. </script>
  304. <!-- effect fragment shader template -->
  305. <script id="fx_common_fsh" type="x-shader/x_fragment">
  306. #ifdef GL_ES
  307. //precision mediump float;
  308. precision highp float;
  309. #endif
  310. uniform sampler2D uSrc;
  311. uniform vec2 uDelta;
  312.  
  313. varying vec2 texCoord;
  314. varying vec2 screenCoord;
  315.  
  316. void main(void) {
  317. gl_FragColor = texture2D(uSrc, texCoord);
  318. }
  319. </script>
  320. <!-- post processing -->
  321. <script id="pp_final_vsh" type="x-shader/x_vertex">
  322. uniform vec3 uResolution;
  323. attribute vec2 aPosition;
  324. varying vec2 texCoord;
  325. varying vec2 screenCoord;
  326. void main(void) {
  327. gl_Position = vec4(aPosition, 0.0, 1.0);
  328. texCoord = aPosition.xy * 0.5 + vec2(0.5, 0.5);
  329. screenCoord = aPosition.xy * vec2(uResolution.z, 1.0);
  330. }
  331. </script>
  332. <script id="pp_final_fsh" type="x-shader/x_fragment">
  333. #ifdef GL_ES
  334. //precision mediump float;
  335. precision highp float;
  336. #endif
  337. uniform sampler2D uSrc;
  338. uniform sampler2D uBloom;
  339. uniform vec2 uDelta;
  340. varying vec2 texCoord;
  341. varying vec2 screenCoord;
  342. void main(void) {
  343. vec4 srccol = texture2D(uSrc, texCoord) * 2.0;
  344. vec4 bloomcol = texture2D(uBloom, texCoord);
  345. vec4 col;
  346. col = srccol + bloomcol * (vec4(1.0) + srccol);
  347. col *= smoothstep(1.0, 0.0, pow(length((texCoord - vec2(0.5)) * 2.0), 1.2) * 0.5);
  348. col = pow(col, vec4(0.45454545454545)); //(1.0 / 2.2)
  349.  
  350. gl_FragColor = vec4(col.rgb, 1.0);
  351. gl_FragColor.a = 1.0;
  352. }
  353. </script>
  354. <style>
  355. /*Sakura animation using WebGL. No images are used. The framerate might be slow or the demo might not play at all in some older systems so you can watch this video: http://www.screenr.com/BFZ8. Let me make it clear that I did not make this and just thought is was very cool and wanted to share it.
  356. */
  357.  
  358. body {
  359. padding:0;
  360. margin:0;
  361. overflow:hidden;
  362. height: 600px;
  363.  
  364. }
  365. canvas {
  366. padding:0;
  367. margin:0;
  368. }
  369. div.btnbg {
  370. position:fixed;
  371. padding-top:14%;
  372. left:0;
  373. top:0;
  374. font-size:200%;
  375. font-weight: bold;
  376. text-align:center;
  377. font-family: "Century Gothic", CenturyGothic, AppleGothic, sans-serif;
  378. }
  379. div.btnbg:hover{
  380.  
  381. }
  382. </style>
  383. <script>
  384. // Utilities
  385. var Vector3 = {};
  386. var Matrix44 = {};
  387. Vector3.create = function(x, y, z) {
  388. return {'x':x, 'y':y, 'z':z};
  389. };
  390. Vector3.dot = function (v0, v1) {
  391. return v0.x * v1.x + v0.y * v1.y + v0.z * v1.z;
  392. };
  393. Vector3.cross = function (v, v0, v1) {
  394. v.x = v0.y * v1.z - v0.z * v1.y;
  395. v.y = v0.z * v1.x - v0.x * v1.z;
  396. v.z = v0.x * v1.y - v0.y * v1.x;
  397. };
  398. Vector3.normalize = function (v) {
  399. var l = v.x * v.x + v.y * v.y + v.z * v.z;
  400. if(l > 0.00001) {
  401. l = 1.0 / Math.sqrt(l);
  402. v.x *= l;
  403. v.y *= l;
  404. v.z *= l;
  405. }
  406. };
  407. Vector3.arrayForm = function(v) {
  408. if(v.array) {
  409. v.array[0] = v.x;
  410. v.array[1] = v.y;
  411. v.array[2] = v.z;
  412. }
  413. else {
  414. v.array = new Float32Array([v.x, v.y, v.z]);
  415. }
  416. return v.array;
  417. };
  418. Matrix44.createIdentity = function () {
  419. return new Float32Array([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]);
  420. };
  421. Matrix44.loadProjection = function (m, aspect, vdeg, near, far) {
  422. var h = near * Math.tan(vdeg * Math.PI / 180.0 * 0.5) * 2.0;
  423. var w = h * aspect;
  424.  
  425. m[0] = 2.0 * near / w;
  426. m[1] = 0.0;
  427. m[2] = 0.0;
  428. m[3] = 0.0;
  429.  
  430. m[4] = 0.0;
  431. m[5] = 2.0 * near / h;
  432. m[6] = 0.0;
  433. m[7] = 0.0;
  434.  
  435. m[8] = 0.0;
  436. m[9] = 0.0;
  437. m[10] = -(far + near) / (far - near);
  438. m[11] = -1.0;
  439.  
  440. m[12] = 0.0;
  441. m[13] = 0.0;
  442. m[14] = -2.0 * far * near / (far - near);
  443. m[15] = 0.0;
  444. };
  445. Matrix44.loadLookAt = function (m, vpos, vlook, vup) {
  446. var frontv = Vector3.create(vpos.x - vlook.x, vpos.y - vlook.y, vpos.z - vlook.z);
  447. Vector3.normalize(frontv);
  448. var sidev = Vector3.create(1.0, 0.0, 0.0);
  449. Vector3.cross(sidev, vup, frontv);
  450. Vector3.normalize(sidev);
  451. var topv = Vector3.create(1.0, 0.0, 0.0);
  452. Vector3.cross(topv, frontv, sidev);
  453. Vector3.normalize(topv);
  454.  
  455. m[0] = sidev.x;
  456. m[1] = topv.x;
  457. m[2] = frontv.x;
  458. m[3] = 0.0;
  459.  
  460. m[4] = sidev.y;
  461. m[5] = topv.y;
  462. m[6] = frontv.y;
  463. m[7] = 0.0;
  464.  
  465. m[8] = sidev.z;
  466. m[9] = topv.z;
  467. m[10] = frontv.z;
  468. m[11] = 0.0;
  469.  
  470. m[12] = -(vpos.x * m[0] + vpos.y * m[4] + vpos.z * m[8]);
  471. m[13] = -(vpos.x * m[1] + vpos.y * m[5] + vpos.z * m[9]);
  472. m[14] = -(vpos.x * m[2] + vpos.y * m[6] + vpos.z * m[10]);
  473. m[15] = 1.0;
  474. };
  475.  
  476. //
  477. var timeInfo = {
  478. 'start':0, 'prev':0, // Date
  479. 'delta':0, 'elapsed':0 // Number(sec)
  480. };
  481.  
  482. //
  483. var gl;
  484. var renderSpec = {
  485. 'width':0,
  486. 'height':0,
  487. 'aspect':1,
  488. 'array':new Float32Array(3),
  489. 'halfWidth':0,
  490. 'halfHeight':0,
  491. 'halfArray':new Float32Array(3)
  492. // and some render targets. see setViewport()
  493. };
  494. renderSpec.setSize = function(w, h) {
  495. renderSpec.width = w;
  496. renderSpec.height = h;
  497. renderSpec.aspect = renderSpec.width / renderSpec.height;
  498. renderSpec.array[0] = renderSpec.width;
  499. renderSpec.array[1] = renderSpec.height;
  500. renderSpec.array[2] = renderSpec.aspect;
  501.  
  502. renderSpec.halfWidth = Math.floor(w / 2);
  503. renderSpec.halfHeight = Math.floor(h / 2);
  504. renderSpec.halfArray[0] = renderSpec.halfWidth;
  505. renderSpec.halfArray[1] = renderSpec.halfHeight;
  506. renderSpec.halfArray[2] = renderSpec.halfWidth / renderSpec.halfHeight;
  507. };
  508.  
  509. function deleteRenderTarget(rt) {
  510. gl.deleteFramebuffer(rt.frameBuffer);
  511. gl.deleteRenderbuffer(rt.renderBuffer);
  512. gl.deleteTexture(rt.texture);
  513. }
  514.  
  515. function createRenderTarget(w, h) {
  516. var ret = {
  517. 'width':w,
  518. 'height':h,
  519. 'sizeArray':new Float32Array([w, h, w / h]),
  520. 'dtxArray':new Float32Array([1.0 / w, 1.0 / h])
  521. };
  522. ret.frameBuffer = gl.createFramebuffer();
  523. ret.renderBuffer = gl.createRenderbuffer();
  524. ret.texture = gl.createTexture();
  525.  
  526. gl.bindTexture(gl.TEXTURE_2D, ret.texture);
  527. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
  528. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  529. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  530. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  531. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  532.  
  533. gl.bindFramebuffer(gl.FRAMEBUFFER, ret.frameBuffer);
  534. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, ret.texture, 0);
  535.  
  536. gl.bindRenderbuffer(gl.RENDERBUFFER, ret.renderBuffer);
  537. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, w, h);
  538. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, ret.renderBuffer);
  539.  
  540. gl.bindTexture(gl.TEXTURE_2D, null);
  541. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  542. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  543.  
  544. return ret;
  545. }
  546.  
  547. function compileShader(shtype, shsrc) {
  548. var retsh = gl.createShader(shtype);
  549.  
  550. gl.shaderSource(retsh, shsrc);
  551. gl.compileShader(retsh);
  552.  
  553. if(!gl.getShaderParameter(retsh, gl.COMPILE_STATUS)) {
  554. var errlog = gl.getShaderInfoLog(retsh);
  555. gl.deleteShader(retsh);
  556. console.error(errlog);
  557. return null;
  558. }
  559. return retsh;
  560. }
  561.  
  562. function createShader(vtxsrc, frgsrc, uniformlist, attrlist) {
  563. var vsh = compileShader(gl.VERTEX_SHADER, vtxsrc);
  564. var fsh = compileShader(gl.FRAGMENT_SHADER, frgsrc);
  565.  
  566. if(vsh == null || fsh == null) {
  567. return null;
  568. }
  569.  
  570. var prog = gl.createProgram();
  571. gl.attachShader(prog, vsh);
  572. gl.attachShader(prog, fsh);
  573.  
  574. gl.deleteShader(vsh);
  575. gl.deleteShader(fsh);
  576.  
  577. gl.linkProgram(prog);
  578. if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) {
  579. var errlog = gl.getProgramInfoLog(prog);
  580. console.error(errlog);
  581. return null;
  582. }
  583.  
  584. if(uniformlist) {
  585. prog.uniforms = {};
  586. for(var i = 0; i < uniformlist.length; i++) {
  587. prog.uniforms[uniformlist[i]] = gl.getUniformLocation(prog, uniformlist[i]);
  588. }
  589. }
  590.  
  591. if(attrlist) {
  592. prog.attributes = {};
  593. for(var i = 0; i < attrlist.length; i++) {
  594. var attr = attrlist[i];
  595. prog.attributes[attr] = gl.getAttribLocation(prog, attr);
  596. }
  597. }
  598.  
  599. return prog;
  600. }
  601.  
  602. function useShader(prog) {
  603. gl.useProgram(prog);
  604. for(var attr in prog.attributes) {
  605. gl.enableVertexAttribArray(prog.attributes[attr]);;
  606. }
  607. }
  608.  
  609. function unuseShader(prog) {
  610. for(var attr in prog.attributes) {
  611. gl.disableVertexAttribArray(prog.attributes[attr]);;
  612. }
  613. gl.useProgram(null);
  614. }
  615.  
  616. /////
  617. var projection = {
  618. 'angle':60,
  619. 'nearfar':new Float32Array([0.1, 100.0]),
  620. 'matrix':Matrix44.createIdentity()
  621. };
  622. var camera = {
  623. 'position':Vector3.create(0, 0, 100),
  624. 'lookat':Vector3.create(0, 0, 0),
  625. 'up':Vector3.create(0, 1, 0),
  626. 'dof':Vector3.create(10.0, 4.0, 8.0),
  627. 'matrix':Matrix44.createIdentity()
  628. };
  629.  
  630. var pointFlower = {};
  631. var meshFlower = {};
  632. var sceneStandBy = false;
  633.  
  634. var BlossomParticle = function () {
  635. this.velocity = new Array(3);
  636. this.rotation = new Array(3);
  637. this.position = new Array(3);
  638. this.euler = new Array(3);
  639. this.size = 1.0;
  640. this.alpha = 1.0;
  641. this.zkey = 0.0;
  642. };
  643.  
  644. BlossomParticle.prototype.setVelocity = function (vx, vy, vz) {
  645. this.velocity[0] = vx;
  646. this.velocity[1] = vy;
  647. this.velocity[2] = vz;
  648. };
  649.  
  650. BlossomParticle.prototype.setRotation = function (rx, ry, rz) {
  651. this.rotation[0] = rx;
  652. this.rotation[1] = ry;
  653. this.rotation[2] = rz;
  654. };
  655.  
  656. BlossomParticle.prototype.setPosition = function (nx, ny, nz) {
  657. this.position[0] = nx;
  658. this.position[1] = ny;
  659. this.position[2] = nz;
  660. };
  661.  
  662. BlossomParticle.prototype.setEulerAngles = function (rx, ry, rz) {
  663. this.euler[0] = rx;
  664. this.euler[1] = ry;
  665. this.euler[2] = rz;
  666. };
  667.  
  668. BlossomParticle.prototype.setSize = function (s) {
  669. this.size = s;
  670. };
  671.  
  672. BlossomParticle.prototype.update = function (dt, et) {
  673. this.position[0] += this.velocity[0] * dt;
  674. this.position[1] += this.velocity[1] * dt;
  675. this.position[2] += this.velocity[2] * dt;
  676.  
  677. this.euler[0] += this.rotation[0] * dt;
  678. this.euler[1] += this.rotation[1] * dt;
  679. this.euler[2] += this.rotation[2] * dt;
  680. };
  681.  
  682. function createPointFlowers() {
  683. // get point sizes
  684. var prm = gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE);
  685. renderSpec.pointSize = {'min':prm[0], 'max':prm[1]};
  686.  
  687. var vtxsrc = document.getElementById("sakura_point_vsh").textContent;
  688. var frgsrc = document.getElementById("sakura_point_fsh").textContent;
  689.  
  690. pointFlower.program = createShader(
  691. vtxsrc, frgsrc,
  692. ['uProjection', 'uModelview', 'uResolution', 'uOffset', 'uDOF', 'uFade'],
  693. ['aPosition', 'aEuler', 'aMisc']
  694. );
  695.  
  696. useShader(pointFlower.program);
  697. pointFlower.offset = new Float32Array([0.0, 0.0, 0.0]);
  698. pointFlower.fader = Vector3.create(0.0, 10.0, 0.0);
  699.  
  700. // paramerters: velocity[3], rotate[3]
  701. pointFlower.numFlowers = 1600;
  702. pointFlower.particles = new Array(pointFlower.numFlowers);
  703. // vertex attributes {position[3], euler_xyz[3], size[1]}
  704. pointFlower.dataArray = new Float32Array(pointFlower.numFlowers * (3 + 3 + 2));
  705. pointFlower.positionArrayOffset = 0;
  706. pointFlower.eulerArrayOffset = pointFlower.numFlowers * 3;
  707. pointFlower.miscArrayOffset = pointFlower.numFlowers * 6;
  708.  
  709. pointFlower.buffer = gl.createBuffer();
  710. gl.bindBuffer(gl.ARRAY_BUFFER, pointFlower.buffer);
  711. gl.bufferData(gl.ARRAY_BUFFER, pointFlower.dataArray, gl.DYNAMIC_DRAW);
  712. gl.bindBuffer(gl.ARRAY_BUFFER, null);
  713.  
  714. unuseShader(pointFlower.program);
  715.  
  716. for(var i = 0; i < pointFlower.numFlowers; i++) {
  717. pointFlower.particles[i] = new BlossomParticle();
  718. }
  719. }
  720.  
  721. function initPointFlowers() {
  722. //area
  723. pointFlower.area = Vector3.create(20.0, 20.0, 20.0);
  724. pointFlower.area.x = pointFlower.area.y * renderSpec.aspect;
  725.  
  726. pointFlower.fader.x = 10.0; //env fade start
  727. pointFlower.fader.y = pointFlower.area.z; //env fade half
  728. pointFlower.fader.z = 0.1; //near fade start
  729.  
  730. //particles
  731. var PI2 = Math.PI * 2.0;
  732. var tmpv3 = Vector3.create(0, 0, 0);
  733. var tmpv = 0;
  734. var symmetryrand = function() {return (Math.random() * 2.0 - 1.0);};
  735. for(var i = 0; i < pointFlower.numFlowers; i++) {
  736. var tmpprtcl = pointFlower.particles[i];
  737.  
  738. //velocity
  739. tmpv3.x = symmetryrand() * 0.3 + 0.8;
  740. tmpv3.y = symmetryrand() * 0.2 - 1.0;
  741. tmpv3.z = symmetryrand() * 0.3 + 0.5;
  742. Vector3.normalize(tmpv3);
  743. tmpv = 2.0 + Math.random() * 1.0;
  744. tmpprtcl.setVelocity(tmpv3.x * tmpv, tmpv3.y * tmpv, tmpv3.z * tmpv);
  745.  
  746. //rotation
  747. tmpprtcl.setRotation(
  748. symmetryrand() * PI2 * 0.5,
  749. symmetryrand() * PI2 * 0.5,
  750. symmetryrand() * PI2 * 0.5
  751. );
  752.  
  753. //position
  754. tmpprtcl.setPosition(
  755. symmetryrand() * pointFlower.area.x,
  756. symmetryrand() * pointFlower.area.y,
  757. symmetryrand() * pointFlower.area.z
  758. );
  759.  
  760. //euler
  761. tmpprtcl.setEulerAngles(
  762. Math.random() * Math.PI * 2.0,
  763. Math.random() * Math.PI * 2.0,
  764. Math.random() * Math.PI * 2.0
  765. );
  766.  
  767. //size
  768. tmpprtcl.setSize(0.9 + Math.random() * 0.1);
  769. }
  770. }
  771.  
  772. function renderPointFlowers() {
  773. //update
  774. var PI2 = Math.PI * 2.0;
  775. var limit = [pointFlower.area.x, pointFlower.area.y, pointFlower.area.z];
  776. var repeatPos = function (prt, cmp, limit) {
  777. if(Math.abs(prt.position[cmp]) - prt.size * 0.5 > limit) {
  778. //out of area
  779. if(prt.position[cmp] > 0) {
  780. prt.position[cmp] -= limit * 2.0;
  781. }
  782. else {
  783. prt.position[cmp] += limit * 2.0;
  784. }
  785. }
  786. };
  787. var repeatEuler = function (prt, cmp) {
  788. prt.euler[cmp] = prt.euler[cmp] % PI2;
  789. if(prt.euler[cmp] < 0.0) {
  790. prt.euler[cmp] += PI2;
  791. }
  792. };
  793.  
  794. for(var i = 0; i < pointFlower.numFlowers; i++) {
  795. var prtcl = pointFlower.particles[i];
  796. prtcl.update(timeInfo.delta, timeInfo.elapsed);
  797. repeatPos(prtcl, 0, pointFlower.area.x);
  798. repeatPos(prtcl, 1, pointFlower.area.y);
  799. repeatPos(prtcl, 2, pointFlower.area.z);
  800. repeatEuler(prtcl, 0);
  801. repeatEuler(prtcl, 1);
  802. repeatEuler(prtcl, 2);
  803.  
  804. prtcl.alpha = 1.0;//(pointFlower.area.z - prtcl.position[2]) * 0.5;
  805.  
  806. prtcl.zkey = (camera.matrix[2] * prtcl.position[0]
  807. + camera.matrix[6] * prtcl.position[1]
  808. + camera.matrix[10] * prtcl.position[2]
  809. + camera.matrix[14]);
  810. }
  811.  
  812. // sort
  813. pointFlower.particles.sort(function(p0, p1){return p0.zkey - p1.zkey;});
  814.  
  815. // update data
  816. var ipos = pointFlower.positionArrayOffset;
  817. var ieuler = pointFlower.eulerArrayOffset;
  818. var imisc = pointFlower.miscArrayOffset;
  819. for(var i = 0; i < pointFlower.numFlowers; i++) {
  820. var prtcl = pointFlower.particles[i];
  821. pointFlower.dataArray[ipos] = prtcl.position[0];
  822. pointFlower.dataArray[ipos + 1] = prtcl.position[1];
  823. pointFlower.dataArray[ipos + 2] = prtcl.position[2];
  824. ipos += 3;
  825. pointFlower.dataArray[ieuler] = prtcl.euler[0];
  826. pointFlower.dataArray[ieuler + 1] = prtcl.euler[1];
  827. pointFlower.dataArray[ieuler + 2] = prtcl.euler[2];
  828. ieuler += 3;
  829. pointFlower.dataArray[imisc] = prtcl.size;
  830. pointFlower.dataArray[imisc + 1] = prtcl.alpha;
  831. imisc += 2;
  832. }
  833.  
  834. //draw
  835. gl.enable(gl.BLEND);
  836. //gl.disable(gl.DEPTH_TEST);
  837. gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
  838.  
  839. var prog = pointFlower.program;
  840. useShader(prog);
  841.  
  842. gl.uniformMatrix4fv(prog.uniforms.uProjection, false, projection.matrix);
  843. gl.uniformMatrix4fv(prog.uniforms.uModelview, false, camera.matrix);
  844. gl.uniform3fv(prog.uniforms.uResolution, renderSpec.array);
  845. gl.uniform3fv(prog.uniforms.uDOF, Vector3.arrayForm(camera.dof));
  846. gl.uniform3fv(prog.uniforms.uFade, Vector3.arrayForm(pointFlower.fader));
  847.  
  848. gl.bindBuffer(gl.ARRAY_BUFFER, pointFlower.buffer);
  849. gl.bufferData(gl.ARRAY_BUFFER, pointFlower.dataArray, gl.DYNAMIC_DRAW);
  850.  
  851. gl.vertexAttribPointer(prog.attributes.aPosition, 3, gl.FLOAT, false, 0, pointFlower.positionArrayOffset * Float32Array.BYTES_PER_ELEMENT);
  852. gl.vertexAttribPointer(prog.attributes.aEuler, 3, gl.FLOAT, false, 0, pointFlower.eulerArrayOffset * Float32Array.BYTES_PER_ELEMENT);
  853. gl.vertexAttribPointer(prog.attributes.aMisc, 2, gl.FLOAT, false, 0, pointFlower.miscArrayOffset * Float32Array.BYTES_PER_ELEMENT);
  854.  
  855. // doubler
  856. for(var i = 1; i < 2; i++) {
  857. var zpos = i * -2.0;
  858. pointFlower.offset[0] = pointFlower.area.x * -1.0;
  859. pointFlower.offset[1] = pointFlower.area.y * -1.0;
  860. pointFlower.offset[2] = pointFlower.area.z * zpos;
  861. gl.uniform3fv(prog.uniforms.uOffset, pointFlower.offset);
  862. gl.drawArrays(gl.POINT, 0, pointFlower.numFlowers);
  863.  
  864. pointFlower.offset[0] = pointFlower.area.x * -1.0;
  865. pointFlower.offset[1] = pointFlower.area.y * 1.0;
  866. pointFlower.offset[2] = pointFlower.area.z * zpos;
  867. gl.uniform3fv(prog.uniforms.uOffset, pointFlower.offset);
  868. gl.drawArrays(gl.POINT, 0, pointFlower.numFlowers);
  869.  
  870. pointFlower.offset[0] = pointFlower.area.x * 1.0;
  871. pointFlower.offset[1] = pointFlower.area.y * -1.0;
  872. pointFlower.offset[2] = pointFlower.area.z * zpos;
  873. gl.uniform3fv(prog.uniforms.uOffset, pointFlower.offset);
  874. gl.drawArrays(gl.POINT, 0, pointFlower.numFlowers);
  875.  
  876. pointFlower.offset[0] = pointFlower.area.x * 1.0;
  877. pointFlower.offset[1] = pointFlower.area.y * 1.0;
  878. pointFlower.offset[2] = pointFlower.area.z * zpos;
  879. gl.uniform3fv(prog.uniforms.uOffset, pointFlower.offset);
  880. gl.drawArrays(gl.POINT, 0, pointFlower.numFlowers);
  881. }
  882.  
  883. //main
  884. pointFlower.offset[0] = 0.0;
  885. pointFlower.offset[1] = 0.0;
  886. pointFlower.offset[2] = 0.0;
  887. gl.uniform3fv(prog.uniforms.uOffset, pointFlower.offset);
  888. gl.drawArrays(gl.POINT, 0, pointFlower.numFlowers);
  889.  
  890. gl.bindBuffer(gl.ARRAY_BUFFER, null);
  891. unuseShader(prog);
  892.  
  893. gl.enable(gl.DEPTH_TEST);
  894. gl.disable(gl.BLEND);
  895. }
  896.  
  897. // effects
  898. //common util
  899. function createEffectProgram(vtxsrc, frgsrc, exunifs, exattrs) {
  900. var ret = {};
  901. var unifs = ['uResolution', 'uSrc', 'uDelta'];
  902. if(exunifs) {
  903. unifs = unifs.concat(exunifs);
  904. }
  905. var attrs = ['aPosition'];
  906. if(exattrs) {
  907. attrs = attrs.concat(exattrs);
  908. }
  909.  
  910. ret.program = createShader(vtxsrc, frgsrc, unifs, attrs);
  911. useShader(ret.program);
  912.  
  913. ret.dataArray = new Float32Array([
  914. -1.0, -1.0,
  915. 1.0, -1.0,
  916. -1.0, 1.0,
  917. 1.0, 1.0
  918. ]);
  919. ret.buffer = gl.createBuffer();
  920. gl.bindBuffer(gl.ARRAY_BUFFER, ret.buffer);
  921. gl.bufferData(gl.ARRAY_BUFFER, ret.dataArray, gl.STATIC_DRAW);
  922.  
  923. gl.bindBuffer(gl.ARRAY_BUFFER, null);
  924. unuseShader(ret.program);
  925.  
  926. return ret;
  927. }
  928.  
  929. // basic usage
  930. // useEffect(prog, srctex({'texture':texid, 'dtxArray':(f32)[dtx, dty]})); //basic initialize
  931. // gl.uniform**(...); //additional uniforms
  932. // drawEffect()
  933. // unuseEffect(prog)
  934. // TEXTURE0 makes src
  935. function useEffect(fxobj, srctex) {
  936. var prog = fxobj.program;
  937. useShader(prog);
  938. gl.uniform3fv(prog.uniforms.uResolution, renderSpec.array);
  939.  
  940. if(srctex != null) {
  941. gl.uniform2fv(prog.uniforms.uDelta, srctex.dtxArray);
  942. gl.uniform1i(prog.uniforms.uSrc, 0);
  943.  
  944. gl.activeTexture(gl.TEXTURE0);
  945. gl.bindTexture(gl.TEXTURE_2D, srctex.texture);
  946. }
  947. }
  948. function drawEffect(fxobj) {
  949. gl.bindBuffer(gl.ARRAY_BUFFER, fxobj.buffer);
  950. gl.vertexAttribPointer(fxobj.program.attributes.aPosition, 2, gl.FLOAT, false, 0, 0);
  951. gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
  952. }
  953. function unuseEffect(fxobj) {
  954. unuseShader(fxobj.program);
  955. }
  956.  
  957. var effectLib = {};
  958. function createEffectLib() {
  959.  
  960. var vtxsrc, frgsrc;
  961. //common
  962. var cmnvtxsrc = document.getElementById("fx_common_vsh").textContent;
  963.  
  964. //background
  965. frgsrc = document.getElementById("bg_fsh").textContent;
  966. effectLib.sceneBg = createEffectProgram(cmnvtxsrc, frgsrc, ['uTimes'], null);
  967.  
  968. // make brightpixels buffer
  969. frgsrc = document.getElementById("fx_brightbuf_fsh").textContent;
  970. effectLib.mkBrightBuf = createEffectProgram(cmnvtxsrc, frgsrc, null, null);
  971.  
  972. // direction blur
  973. frgsrc = document.getElementById("fx_dirblur_r4_fsh").textContent;
  974. effectLib.dirBlur = createEffectProgram(cmnvtxsrc, frgsrc, ['uBlurDir'], null);
  975.  
  976. //final composite
  977. vtxsrc = document.getElementById("pp_final_vsh").textContent;
  978. frgsrc = document.getElementById("pp_final_fsh").textContent;
  979. effectLib.finalComp = createEffectProgram(vtxsrc, frgsrc, ['uBloom'], null);
  980. }
  981.  
  982. // background
  983. function createBackground() {
  984. //console.log("create background");
  985. }
  986. function initBackground() {
  987. //console.log("init background");
  988. }
  989. function renderBackground() {
  990. gl.disable(gl.DEPTH_TEST);
  991.  
  992. useEffect(effectLib.sceneBg, null);
  993. gl.uniform2f(effectLib.sceneBg.program.uniforms.uTimes, timeInfo.elapsed, timeInfo.delta);
  994. drawEffect(effectLib.sceneBg);
  995. unuseEffect(effectLib.sceneBg);
  996.  
  997. gl.enable(gl.DEPTH_TEST);
  998. }
  999.  
  1000. // post process
  1001. var postProcess = {};
  1002. function createPostProcess() {
  1003. //console.log("create post process");
  1004. }
  1005. function initPostProcess() {
  1006. //console.log("init post process");
  1007. }
  1008.  
  1009. function renderPostProcess() {
  1010. gl.enable(gl.TEXTURE_2D);
  1011. gl.disable(gl.DEPTH_TEST);
  1012. var bindRT = function (rt, isclear) {
  1013. gl.bindFramebuffer(gl.FRAMEBUFFER, rt.frameBuffer);
  1014. gl.viewport(0, 0, rt.width, rt.height);
  1015. if(isclear) {
  1016. gl.clearColor(0, 0, 0, 0);
  1017. gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
  1018. }
  1019. };
  1020.  
  1021. //make bright buff
  1022. bindRT(renderSpec.wHalfRT0, true);
  1023. useEffect(effectLib.mkBrightBuf, renderSpec.mainRT);
  1024. drawEffect(effectLib.mkBrightBuf);
  1025. unuseEffect(effectLib.mkBrightBuf);
  1026.  
  1027. // make bloom
  1028. for(var i = 0; i < 2; i++) {
  1029. var p = 1.5 + 1 * i;
  1030. var s = 2.0 + 1 * i;
  1031. bindRT(renderSpec.wHalfRT1, true);
  1032. useEffect(effectLib.dirBlur, renderSpec.wHalfRT0);
  1033. gl.uniform4f(effectLib.dirBlur.program.uniforms.uBlurDir, p, 0.0, s, 0.0);
  1034. drawEffect(effectLib.dirBlur);
  1035. unuseEffect(effectLib.dirBlur);
  1036.  
  1037. bindRT(renderSpec.wHalfRT0, true);
  1038. useEffect(effectLib.dirBlur, renderSpec.wHalfRT1);
  1039. gl.uniform4f(effectLib.dirBlur.program.uniforms.uBlurDir, 0.0, p, 0.0, s);
  1040. drawEffect(effectLib.dirBlur);
  1041. unuseEffect(effectLib.dirBlur);
  1042. }
  1043.  
  1044. //display
  1045. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  1046. gl.viewport(0, 0, renderSpec.width, renderSpec.height);
  1047. gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
  1048.  
  1049. useEffect(effectLib.finalComp, renderSpec.mainRT);
  1050. gl.uniform1i(effectLib.finalComp.program.uniforms.uBloom, 1);
  1051. gl.activeTexture(gl.TEXTURE1);
  1052. gl.bindTexture(gl.TEXTURE_2D, renderSpec.wHalfRT0.texture);
  1053. drawEffect(effectLib.finalComp);
  1054. unuseEffect(effectLib.finalComp);
  1055.  
  1056. gl.enable(gl.DEPTH_TEST);
  1057. }
  1058.  
  1059. /////
  1060. var SceneEnv = {};
  1061. function createScene() {
  1062. createEffectLib();
  1063. createBackground();
  1064. createPointFlowers();
  1065. createPostProcess();
  1066. sceneStandBy = true;
  1067. }
  1068.  
  1069. function initScene() {
  1070. initBackground();
  1071. initPointFlowers();
  1072. initPostProcess();
  1073.  
  1074. //camera.position.z = 17.320508;
  1075. camera.position.z = pointFlower.area.z + projection.nearfar[0];
  1076. projection.angle = Math.atan2(pointFlower.area.y, camera.position.z + pointFlower.area.z) * 180.0 / Math.PI * 2.0;
  1077. Matrix44.loadProjection(projection.matrix, renderSpec.aspect, projection.angle, projection.nearfar[0], projection.nearfar[1]);
  1078. }
  1079.  
  1080. function renderScene() {
  1081. //draw
  1082. Matrix44.loadLookAt(camera.matrix, camera.position, camera.lookat, camera.up);
  1083.  
  1084. gl.enable(gl.DEPTH_TEST);
  1085.  
  1086. //gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  1087. gl.bindFramebuffer(gl.FRAMEBUFFER, renderSpec.mainRT.frameBuffer);
  1088. gl.viewport(0, 0, renderSpec.mainRT.width, renderSpec.mainRT.height);
  1089. gl.clearColor(0.005, 0, 0.05, 0);
  1090. gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
  1091.  
  1092. renderBackground();
  1093. renderPointFlowers();
  1094. renderPostProcess();
  1095. }
  1096.  
  1097. /////
  1098. function onResize(e) {
  1099. makeCanvasFullScreen(document.getElementById("sakura"));
  1100. setViewports();
  1101. if(sceneStandBy) {
  1102. initScene();
  1103. }
  1104. }
  1105.  
  1106. function setViewports() {
  1107. renderSpec.setSize(gl.canvas.width, gl.canvas.height);
  1108.  
  1109. gl.clearColor(0.2, 0.2, 0.5, 1.0);
  1110. gl.viewport(0, 0, renderSpec.width, renderSpec.height);
  1111.  
  1112. var rtfunc = function (rtname, rtw, rth) {
  1113. var rt = renderSpec[rtname];
  1114. if(rt) deleteRenderTarget(rt);
  1115. renderSpec[rtname] = createRenderTarget(rtw, rth);
  1116. };
  1117. rtfunc('mainRT', renderSpec.width, renderSpec.height);
  1118. rtfunc('wFullRT0', renderSpec.width, renderSpec.height);
  1119. rtfunc('wFullRT1', renderSpec.width, renderSpec.height);
  1120. rtfunc('wHalfRT0', renderSpec.halfWidth, renderSpec.halfHeight);
  1121. rtfunc('wHalfRT1', renderSpec.halfWidth, renderSpec.halfHeight);
  1122. }
  1123.  
  1124. function render() {
  1125. renderScene();
  1126. }
  1127.  
  1128. var animating = true;
  1129. function toggleAnimation(elm) {
  1130. animating ^= true;
  1131. if(animating) animate();
  1132. if(elm) {
  1133. elm.innerHTML = animating? "Stop":"Start";
  1134. }
  1135. }
  1136.  
  1137. function stepAnimation() {
  1138. if(!animating) animate();
  1139. }
  1140.  
  1141. function animate() {
  1142. var curdate = new Date();
  1143. timeInfo.elapsed = (curdate - timeInfo.start) / 1000.0;
  1144. timeInfo.delta = (curdate - timeInfo.prev) / 1000.0;
  1145. timeInfo.prev = curdate;
  1146.  
  1147. if(animating) requestAnimationFrame(animate);
  1148. render();
  1149. }
  1150.  
  1151. function makeCanvasFullScreen(canvas) {
  1152. var b = document.body;
  1153. var d = document.documentElement;
  1154. fullw = Math.max(b.clientWidth , b.scrollWidth, d.scrollWidth, d.clientWidth);
  1155. fullh = Math.max(b.clientHeight , b.scrollHeight, d.scrollHeight, d.clientHeight);
  1156. canvas.width = fullw;
  1157. canvas.height = fullh;
  1158. }
  1159.  
  1160. window.addEventListener('load', function(e) {
  1161. var canvas = document.getElementById("sakura");
  1162. try {
  1163. makeCanvasFullScreen(canvas);
  1164. gl = canvas.getContext('experimental-webgl');
  1165. } catch(e) {
  1166. alert("WebGL not supported." + e);
  1167. console.error(e);
  1168. return;
  1169. }
  1170.  
  1171. window.addEventListener('resize', onResize);
  1172.  
  1173. setViewports();
  1174. createScene();
  1175. initScene();
  1176.  
  1177. timeInfo.start = new Date();
  1178. timeInfo.prev = timeInfo.start;
  1179. animate();
  1180. });
  1181.  
  1182. //set window.requestAnimationFrame
  1183. (function (w, r) {
  1184. w['r'+r] = w['r'+r] || w['webkitR'+r] || w['mozR'+r] || w['msR'+r] || w['oR'+r] || function(c){ w.setTimeout(c, 1000 / 60); };
  1185. })(window, 'requestAnimationFrame');
  1186. </script>
  1187. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement