particle test
This commit is contained in:
parent
6be7f85b93
commit
659274b087
4 changed files with 54 additions and 21 deletions
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
var ratio = 1, width = 1, height = 1;
|
||||
var canvas, gl, positionAttributeLocation, positionBuffer, matBuffer, vpBuffer, sizeBuffer, distBuffer, fgBuffer;
|
||||
|
||||
function createShader(gl, type, source) {
|
||||
|
@ -67,12 +68,15 @@ function main() {
|
|||
function renderThing() {
|
||||
twgl.resizeCanvasToDisplaySize(gl.canvas);
|
||||
|
||||
width = gl.canvas.width;
|
||||
height = gl.canvas.height;
|
||||
|
||||
gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
|
||||
|
||||
gl.clearColor(0, 0, 0, 0);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
|
||||
var ratio = gl.canvas.width / gl.canvas.height;
|
||||
ratio = gl.canvas.width / gl.canvas.height;
|
||||
var ratioA = Math.max(ratio, 1);
|
||||
var ratioB = ratioA / ratio;
|
||||
|
||||
|
@ -109,7 +113,7 @@ function renderThing() {
|
|||
|
||||
gl.uniformMatrix4fv(matBuffer, false, new Float32Array(MDN.perspectiveMatrix(Math.PI * 100 / 180, ratio, 0.01, 1000)));
|
||||
|
||||
hud.textContent = `${Math.floor(nothingness * 100) / 100} nothings; ${Math.floor(nGain * 60 * 100) / 100} nil/sec`
|
||||
hud.textContent = `${Math.floor(nothingness * 100) / 100} nothings; ${Math.floor((nGain + getBonus) * 60 * 100) / 100} nil/sec`
|
||||
|
||||
gl.uniform1f(sizeBuffer, -Math.log(nothingness));
|
||||
gl.uniform1f(distBuffer, 0.1 + 3 * nGain / (nGain + nothingness));
|
||||
|
@ -120,11 +124,13 @@ function renderThing() {
|
|||
var count = 6;
|
||||
gl.drawArrays(primitiveType, offset, count);
|
||||
|
||||
positions = MDN.createCubeData(10,10,10);
|
||||
let sizes = 1000 / (cubePos.length+30);
|
||||
|
||||
positions = MDN.createCubeData(sizes, sizes, sizes);
|
||||
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);
|
||||
|
||||
for (let cubie of cubePos) {
|
||||
let vp = MDN.rotateYMatrix(Math.log(nothingness+1) * cubie[2] / 10);
|
||||
let vp = MDN.rotateYMatrix(Math.log(nothingness + 1) * cubie[2] / 10);
|
||||
vp = MDN.multiplyMatrices(MDN.translateMatrix(cubie[0], cubie[1], cubie[2]), vp)
|
||||
|
||||
gl.uniformMatrix4fv(vpBuffer, false, new Float32Array(vp));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue