Skip to content
This repository was archived by the owner on Jan 26, 2023. It is now read-only.

Real/currents #28

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3bff3d9
update box def
dancingfrog Mar 21, 2020
3530d6b
flatten array of verts in box def
dancingfrog Mar 21, 2020
e5dedd2
define box dimensions with input args
dancingfrog Mar 21, 2020
22a23f5
define box dimensions with input args
dancingfrog Mar 21, 2020
1f83a9b
debug box args
dancingfrog Mar 21, 2020
d30abb4
debug box args
dancingfrog Mar 21, 2020
a05367d
debug box args
dancingfrog Mar 21, 2020
d6f5536
finish box definition
dancingfrog Mar 21, 2020
b628f83
debug box input arg
dancingfrog Mar 21, 2020
c66dd31
debug box input arg
dancingfrog Mar 21, 2020
fb90b9c
fix box definition defaults
dancingfrog Mar 21, 2020
bc988e7
use WebGL2RenderingContext and expose gl
dancingfrog Apr 1, 2020
4f8d9c2
upgrade shaders to GLSL ES 3.00
dancingfrog Apr 1, 2020
f3b0a1c
allow more with custom shaders
dancingfrog Apr 2, 2020
2e26560
move orbital camera closer to target
dancingfrog Apr 4, 2020
6bde74d
add terrain
dancingfrog Apr 5, 2020
78f6928
add sprite
dancingfrog Apr 5, 2020
5b4c1c2
add sprite
dancingfrog Apr 5, 2020
351369e
add point sprite
dancingfrog Apr 5, 2020
80601e4
add point sprite
dancingfrog Apr 5, 2020
a3f21a7
reduce logging
dancingfrog Apr 6, 2020
6cac05e
udpate texture binding routine
dancingfrog Apr 6, 2020
2ac3782
update texture routine
dancingfrog Apr 6, 2020
6341913
set flip y to false before binding texture
dancingfrog Apr 6, 2020
08ced6e
Merge branch 'terrain' into real/currents
dancingfrog Apr 6, 2020
aa035cf
simple terrain
dancingfrog Apr 6, 2020
1ee1613
simple terrain
dancingfrog Apr 6, 2020
b28c332
bigger terrain
dancingfrog Apr 6, 2020
7626122
shader needed another fix for GLSL 3.00
dancingfrog Apr 8, 2020
5a8c016
ignore idea project config
dancingfrog Apr 10, 2020
a2a05a2
fix formatting of box custom coords
dancingfrog Jul 6, 2021
730ecfb
fix formatting of box custom coords
dancingfrog Jul 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
.DS_Store
/node_modules
node_modules
9 changes: 5 additions & 4 deletions abstract/Texture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class TextureInstance {

bind(gl, texture, data) {
gl.bindTexture(constants.TEXTURE_2D, this._);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);

if (ArrayBuffer.isView(data)) {
// TODO figure out where this goes
Expand All @@ -35,13 +36,13 @@ class TextureInstance {
} else {
gl.texImage2D(constants.TEXTURE_2D, 0, constants.RGBA, constants.RGBA, constants.UNSIGNED_BYTE, data);
}


gl.generateMipmap(constants.TEXTURE_2D);

const width = 'naturalWidth' in data ? data.naturalWidth : data.width;
const height = 'naturalHeight' in data ? data.naturalHeight : data.height;

if (is_power_of_two(width) && is_power_of_two(height)) {
gl.generateMipmap(constants.TEXTURE_2D);

gl.texParameteri(constants.TEXTURE_2D, constants.TEXTURE_WRAP_S, texture.opts.wrapS);
gl.texParameteri(constants.TEXTURE_2D, constants.TEXTURE_WRAP_T, texture.opts.wrapT);
gl.texParameteri(constants.TEXTURE_2D, constants.TEXTURE_MIN_FILTER, texture.opts.minFilter);
Expand Down Expand Up @@ -92,4 +93,4 @@ export default class Texture {
if (!b.has(this.hash)) b.set(this.hash, new TextureInstance(scene, this, index));
return b.get(this.hash);
}
}
}
4 changes: 2 additions & 2 deletions controls/OrbitControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// TODO check we're not inside a group?
const scene = get_scene();

export let location = new Float32Array([1, 3, 5]);
export let location = new Float32Array([1, 3, 1]);
export let target = new Float32Array([0, 1, 0]);
// export let up = new Float32Array([0, 1, 0]);

Expand Down Expand Up @@ -275,4 +275,4 @@
});
</script>

<slot {location} {target}></slot>
<slot {location} {target}></slot>
13 changes: 10 additions & 3 deletions geometry/Geometry.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,25 @@ class GeometryInstance {
const attribute = attributes[key];

this.locations[key] = gl.getAttribLocation(program, key);
if (this.primitive === 'POINTS') console.log(key, ":", attribute);

const buffer = gl.createBuffer();
this.buffers[key] = buffer;

gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, attribute.data, attribute.dynamic ? gl.DYNAMIC_DRAW : gl.STATIC_DRAW);
this.buffers[key] = buffer;
}

if (index) {
const buffer = gl.createBuffer();
this.buffers.__index = buffer;
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, index, gl.STATIC_DRAW);
this.buffers.__index = buffer;
}

// Un-bind buffers
gl.bindBuffer(gl.ARRAY_BUFFER, null);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
}

set_attributes(gl) {
Expand All @@ -48,6 +53,8 @@ class GeometryInstance {

// Bind the position buffer.
const buffer = this.buffers[key];

// if (this.primitive = 'POINTS') console.log("enableVertexAttribArray on location ", key);

gl.bindBuffer(gl.ARRAY_BUFFER, buffer);

Expand Down Expand Up @@ -131,4 +138,4 @@ function get_count(attributes) {
}

return min;
}
}
Loading