for(_='in~s~(Z9.*ZYatXmX4W=n.V707UvecT]+[i[R TQ,0OmoM.)LL*Zg/2K(fJJ).xyzfloor(=(o=>{Child(1,-9,T4((34962,=-U.+uniform999,),Don;outQ4 g)*g.c.,0 g.;}"cS(oo)void ma~(){cos(floXahJ,(o=h(3563so(o,"#versi 300 es\\nfor(i ~ g=b.appendb.reMvea).cleNode()).getCtext("webgl2"g)g[i[0R7]R13]]]=g[i];l(.7O,1e(2929n=FloX32Array.of(------9,-1c=s=.6,f=r(dlear(166403f(e,o,c,sdX(5O,14,5e5requestAnimXiFrame(d)}3Q3 n;~Q3 pf;W v=W(1.3,2-1-1-20L;T3 s( v, s){ mMd(v,UL*2cv/U.*2g=c+s/2L*2.;returnQ3(m,Ym/30K0L+.*Zm/KL+4.*fract(ZLc-Md(s,2L);} mVx/c=Y-m/30L+3 gVy*.006,DVz*.002-.8;f=v*W(gZZ-ZZ Zg-Z-c, 1L*p+s((gl_InstanceIm1L;gl_Positi=f2precisi lowp ;~Q4 fc;c=mix(normalize(cross(dFdx,dFdy)1.1.7, 1.clamp(lengthJ-0L)/9 1L)lgJe=g.goaJ,"n"urJbfu()ban,35044eet(0vto(0,3,5126OOOb.MuseMvec=o.x,s=o.y}d(0);';G=/[^ -INPS[-}]/.exec(_);)with(_.split(G))_=join(shift());eval(_)
Zm9yKF89J2lufnN+KFo5LipaWWF0WG1YNFc9bi5WNzA3VXZlY1RdK1tpW1IgVFEsME9tb00uKUxMKlpnLzJLKGZKSikueHl6H2Zsb29yKB49KG89PnsdQ2hpbGQoHDEsGy0bGjksGhlUNCgYKDM0OTYyLBc9LVUuKxZ1bmlmb3JtFTk5FDksGxMpLBJEEhFvbhA7b3V0UTQgD2cpKg5nLmMMLiwLMAsJCQkIEmcuBzt9IgdjUyhvEm8pBnZvaWQgbWF+KCl7BWNvcygEZmxvWAMHYWhKLChvPQxoKDM1NjMCB3NvKG8sIiN2ZXJzaRAgMzAwIGVzXFxuAWZvcihpIH4gZz1iLmFwcGVuZBxiLnJlTXZlHGEpLmNsEGVOb2RlKCkpLmdldEMQdGV4dCgid2ViZ2wyIhJnKWdbaVswUjddUjEzXV1dPWdbaV07DGwoGy43TywxB2UoMjkyORJuPUZsb1gzMkFycmF5Lm9mKBoTGxMaLRMbLRMbLRkbExsZGhMaGRotExotGRstGRoZGzksLTESYz1zPS42LGY9DHIoEmQdDGxlYXIoMTY2NDAHFTNmKGUsbyxjLHMHZFgoNU8sMTQsNWU1EnJlcXVlc3RBbmltWGkQRnJhbWUoZCl9AjMBFVEzIG47flEzIHAPZjtXIHY9VygxLjMsCAgyCwgILTELLTELCC0yCzBMO1QzIHMoAyB2LAMgcyl7AyBtFk1kKHYsVUwqMgtjFnYvVS4qMgtnPWMrHnMvMkwqMi47cmV0dXJuUTMobSweWW0vMzBLMEwrFC4qWm0vFEsUTCs0LipmcmFjdChaDhRMEmMtTWQocywyTCk7fQUDIG1WeC8UC2M9WS1tLzMwTCszCWdWeSouMDA2LERWeiouMDAyLS44O2Y9dipXKARnEloOWhEtWg4EEQgEEVoRCVpnEi0EDloRBA4EEQgtYywJMUwqGHArcygDKGdsX0luc3RhbmNlSRFtEjFMO2dsX1Bvc2l0aRA9ZgYCMgFwcmVjaXNpECBsb3dwIAM7flE0IGYPYzsFYz1taXgoGG5vcm1hbGl6ZShjcm9zcyhkRmR4HyxkRmR5HykSMS4SGDELLjcsCTEuEmNsYW1wKGxlbmd0aEotGDBMKS8UOQsJMUwpBgdsZ0oSZT1nLmdvYUosIm4iB3VySgdiZhcMdSgpB2JhF24sMzUwNDQHZWV0KDAHdnRvKDAsMyw1MTI2T09PEmIuEE11c2VNdmUdYz1vLngscz1vLnl9EmQoMCk7JztHPS9bXiAtSU5QU1stfV0vLmV4ZWMoXyk7KXdpdGgoXy5zcGxpdChHKSlfPWpvaW4oc2hpZnQoKSk7ZXZhbChfKQ==
g.clearColor(1, .7, 0, 1);
g.enable(g.DEPTH_TEST);
g.enable(g.CULL_FACE);
// The number of voxels along the edge of the world.
let EDGE_COUNT = 707,
shader,
vertices = Float32Array.of(
1, 9, 1, -1, 9, 1, -1, -9, 1,
1, -9, 1, 1, 9, 1, -1, -9, 1,
1, 9, 1, 1, -9, 1, 1, -9, -1,
1, 9, -1, 1, 9, 1, 1, -9, -1,
1, 9, 1, 1, 9, -1, -1, 9, -1,
-1, 9, 1, 1, 9, 1, -1, 9, -1,
-1, -9, -1, -1, 9, -1, 1, 9, -1,
1, -9, -1, -1, -9, -1, 1, 9, -1,
-1, -9, -1, -1, -9, 1, -1, 9, 1,
-1, 9, -1, -1, -9, -1, -1, 9, 1,
-1, -9, -1, 1, -9, -1, 1, -9, 1,
-1, -9, 1, -1, -9, -1, 1, -9, 1
),
compile_shader = (type, source) => {
shader = g.createShader(type);
g.shaderSource(shader, source);
g.compileShader(shader);
if (!g.getShaderParameter(shader, g.COMPILE_STATUS)) // DEBUG
throw new Error(g.getShaderInfoLog(shader)); // DEBUG
return shader;
},
mousex = 0.6,
mousey = 0.6,
audio,
program = g.createProgram(),
uniform_now, uniform_mouse,
timestamp = 0,
processor,
tick = now => {
timestamp = now;
g.clear(16640);
g.uniform3iv(uniform_now, Float32Array.of(now, mousex, mousey));
// g.uniform2f(uniform_mouse, mousex, mousey);
g.drawArraysInstanced(g.TRIANGLES, 0, 36, EDGE_COUNT * EDGE_COUNT);
requestAnimationFrame(tick);
};
g.attachShader(program, compile_shader(g.VERTEX_SHADER, `#version 300 es
uniform ivec3 n;
// Vertex position in the mesh
in vec3 p;
// Vertex position in the instance
out vec4 f;
// Projection matrix
const mat4 P=mat4(
1.299,0.,0.,0.,
0.,1.732,0.,0.,
0.,0.,-1.002,-1.,
0.,0.,-2.002,0.);
// Compute the translation of the instance
vec3 t(float id,float o){
float x=-${EDGE_COUNT}.+mod(id,${EDGE_COUNT}.)*2.;
float z=-${EDGE_COUNT}.+(id/${EDGE_COUNT}.)*2.;
// Make offset discrete in increments of the cube's width.
float Z=z+floor(o/2.)*2.;
return vec3(
x,
floor(
// y
9.*sin(x/30.)*sin(Z/20.)
// Hills and valleys
+99.*sin(x/99.)*sin(Z/299.)
// Random noise, constant for a given (x, Z)
+4.*fract(sin(Z)*99.)),
z-mod(o,2.));
}
void main(){
// The offset of the world
float o=float(n.x)/99.;
// The position of the camera
float y=9.*sin(-o/30.)+30.;
// Yaw
float a=float(n.y)*0.0063;
// Pitch
float b=float(n.z)*0.0016-.8;
f = P * mat4(
cos(a),sin(a)*sin(b),-sin(a)*cos(b),0.,
0.,cos(b),sin(b),0.,
sin(a),-cos(a)*sin(b),cos(a)*cos(b),0.,
0.,-y,0.,1.)*vec4(p+t(float(gl_InstanceID),o),1.);
gl_Position=f;
}
`));
g.attachShader(program, compile_shader(g.FRAGMENT_SHADER, `#version 300 es
precision lowp float;
// Fragment position
in vec4 f;
// Fragment color
out vec4 c;
void main(){
c=mix(
// Normal of the fragment
vec4(normalize(cross(dFdx(f).xyz,dFdy(f).xyz)),1.),
// Fog color
vec4(1.,.7,0.,1.),
// Divide length by max fog distance
clamp(length(f-vec4(0.))/999.,0.,1.));
}
`));
g.linkProgram(program);
uniform_now = g.getUniformLocation(program, "n");
// And make it the only active one.
g.useProgram(program);
// Buffer vertex data for a cube.
g.bindBuffer(g.ARRAY_BUFFER, g.createBuffer());
g.bufferData(g.ARRAY_BUFFER, vertices, g.STATIC_DRAW);
g.enableVertexAttribArray(0);
g.vertexAttribPointer(0, 3, g.FLOAT, g.FALSE, 0, 0);
b.onmousemove = e => {
mousex = e.x;
mousey = e.y;
};
tick(0);