|
|
@ -28,6 +28,7 @@ let config = { |
|
|
|
limit: -1, |
|
|
|
limit: -1, |
|
|
|
zoom_delta: 0.05, |
|
|
|
zoom_delta: 0.05, |
|
|
|
raster_texture_size: 4096, |
|
|
|
raster_texture_size: 4096, |
|
|
|
|
|
|
|
max_zoom_level: 0, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let canvas = null; |
|
|
|
let canvas = null; |
|
|
@ -42,6 +43,7 @@ let zoom_screenp = { 'x': 0, 'y': 0 }; |
|
|
|
let last_frame_dt = 0; |
|
|
|
let last_frame_dt = 0; |
|
|
|
let last_frame_ts = 0; |
|
|
|
let last_frame_ts = 0; |
|
|
|
let raster_tile = { 'x': 0, 'y': 0 }; |
|
|
|
let raster_tile = { 'x': 0, 'y': 0 }; |
|
|
|
|
|
|
|
let spacedown = false; |
|
|
|
|
|
|
|
|
|
|
|
const tquad_vs_src = `#version 300 es
|
|
|
|
const tquad_vs_src = `#version 300 es
|
|
|
|
in vec2 a_pos; |
|
|
|
in vec2 a_pos; |
|
|
@ -149,17 +151,24 @@ function draw(ts, animation) { |
|
|
|
quads = traces['0'].geo; |
|
|
|
quads = traces['0'].geo; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (quads.count > 0) { |
|
|
|
const clipped = clip(quads); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (clipped.count > 0) { |
|
|
|
const program = programs['quad']; |
|
|
|
const program = programs['quad']; |
|
|
|
const fade = Math.max(0, Math.min(1.25 * zoom - 0.25, 1)); |
|
|
|
const fade = Math.max(0, Math.min(1.25 * zoom - 0.25, 1)); |
|
|
|
|
|
|
|
|
|
|
|
gl.useProgram(program.program); |
|
|
|
gl.useProgram(program.program); |
|
|
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffers['b_packed']); |
|
|
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffers['b_packed']); |
|
|
|
gl.bufferData(gl.ARRAY_BUFFER, quads.count * config.bytes_per_quad, gl.STATIC_DRAW); |
|
|
|
|
|
|
|
gl.bufferSubData(gl.ARRAY_BUFFER, 0, quads.pos); |
|
|
|
if (!clipped.uploaded) { |
|
|
|
gl.bufferSubData(gl.ARRAY_BUFFER, quads.pos.byteLength, quads.size); |
|
|
|
gl.bufferData(gl.ARRAY_BUFFER, clipped.count * config.bytes_per_quad, gl.STATIC_DRAW); |
|
|
|
gl.bufferSubData(gl.ARRAY_BUFFER, quads.pos.byteLength + quads.size.byteLength, quads.color); |
|
|
|
gl.bufferSubData(gl.ARRAY_BUFFER, 0, clipped.pos); |
|
|
|
gl.bufferSubData(gl.ARRAY_BUFFER, quads.pos.byteLength + quads.size.byteLength + quads.color.byteLength, quads.uv); |
|
|
|
gl.bufferSubData(gl.ARRAY_BUFFER, clipped.pos.byteLength, clipped.size); |
|
|
|
|
|
|
|
gl.bufferSubData(gl.ARRAY_BUFFER, clipped.pos.byteLength + clipped.size.byteLength, clipped.color); |
|
|
|
|
|
|
|
gl.bufferSubData(gl.ARRAY_BUFFER, clipped.pos.byteLength + clipped.size.byteLength + clipped.color.byteLength, clipped.uv); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clipped.uploaded = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
gl.uniform2f(program.locations['u_res'], canvas.width, canvas.height); |
|
|
|
gl.uniform2f(program.locations['u_res'], canvas.width, canvas.height); |
|
|
|
gl.uniform2f(program.locations['u_translation'], offset.x, offset.y); |
|
|
|
gl.uniform2f(program.locations['u_translation'], offset.x, offset.y); |
|
|
@ -175,9 +184,9 @@ function draw(ts, animation) { |
|
|
|
gl.enableVertexAttribArray(program.locations['a_uv']); |
|
|
|
gl.enableVertexAttribArray(program.locations['a_uv']); |
|
|
|
|
|
|
|
|
|
|
|
gl.vertexAttribPointer(program.locations['a_pos'], 2, gl.FLOAT, false, 2 * 4, 0); |
|
|
|
gl.vertexAttribPointer(program.locations['a_pos'], 2, gl.FLOAT, false, 2 * 4, 0); |
|
|
|
gl.vertexAttribPointer(program.locations['a_size'], 2, gl.FLOAT, false, 2 * 4, quads.pos.byteLength); |
|
|
|
gl.vertexAttribPointer(program.locations['a_size'], 2, gl.FLOAT, false, 2 * 4, clipped.pos.byteLength); |
|
|
|
gl.vertexAttribPointer(program.locations['a_color'], 4, gl.UNSIGNED_BYTE, true, 4 * 1, quads.pos.byteLength + quads.size.byteLength); |
|
|
|
gl.vertexAttribPointer(program.locations['a_color'], 4, gl.UNSIGNED_BYTE, true, 4 * 1, clipped.pos.byteLength + clipped.size.byteLength); |
|
|
|
gl.vertexAttribPointer(program.locations['a_uv'], 2, gl.FLOAT, false, 2 * 4, quads.pos.byteLength + quads.size.byteLength + quads.color.byteLength); |
|
|
|
gl.vertexAttribPointer(program.locations['a_uv'], 2, gl.FLOAT, false, 2 * 4, clipped.pos.byteLength + clipped.size.byteLength + clipped.color.byteLength); |
|
|
|
|
|
|
|
|
|
|
|
gl.vertexAttribDivisor(program.locations['a_pos'], 1); |
|
|
|
gl.vertexAttribDivisor(program.locations['a_pos'], 1); |
|
|
|
gl.vertexAttribDivisor(program.locations['a_size'], 1); |
|
|
|
gl.vertexAttribDivisor(program.locations['a_size'], 1); |
|
|
@ -185,7 +194,7 @@ function draw(ts, animation) { |
|
|
|
gl.vertexAttribDivisor(program.locations['a_uv'], 1); |
|
|
|
gl.vertexAttribDivisor(program.locations['a_uv'], 1); |
|
|
|
|
|
|
|
|
|
|
|
gl.bindTexture(gl.TEXTURE_2D, textures['raster']); |
|
|
|
gl.bindTexture(gl.TEXTURE_2D, textures['raster']); |
|
|
|
gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, quads.count); |
|
|
|
gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, clipped.count); |
|
|
|
|
|
|
|
|
|
|
|
gl.vertexAttribDivisor(program.locations['a_pos'], 0); |
|
|
|
gl.vertexAttribDivisor(program.locations['a_pos'], 0); |
|
|
|
gl.vertexAttribDivisor(program.locations['a_size'], 0); |
|
|
|
gl.vertexAttribDivisor(program.locations['a_size'], 0); |
|
|
|