summaryrefslogtreecommitdiff
path: root/public/gl/model
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2023-01-19 13:39:40 -0500
committerTyler Murphy <tylermurphy534@gmail.com>2023-01-19 13:39:40 -0500
commit76446f179d3de3b5635e8b4c40e1bd49ea99995c (patch)
tree9d79082ecde0866d27062f9b2d940f85caefbb21 /public/gl/model
parentmerge (diff)
downloadwebgl-76446f179d3de3b5635e8b4c40e1bd49ea99995c.tar.gz
webgl-76446f179d3de3b5635e8b4c40e1bd49ea99995c.tar.bz2
webgl-76446f179d3de3b5635e8b4c40e1bd49ea99995c.zip
cube working
Diffstat (limited to 'public/gl/model')
-rw-r--r--public/gl/model/Cube.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/public/gl/model/Cube.js b/public/gl/model/Cube.js
new file mode 100644
index 0000000..824984b
--- /dev/null
+++ b/public/gl/model/Cube.js
@@ -0,0 +1,68 @@
+import { Mesh } from '../core/Mesh.js'
+
+export class Cube {
+
+ constructor() {
+
+ this.data = [
+ -1.0, 1.0, -1.0, 0.5, 0.5, 0.5,
+ -1.0, 1.0, 1.0, 0.5, 0.5, 0.5,
+ 1.0, 1.0, 1.0, 0.5, 0.5, 0.5,
+ 1.0, 1.0, -1.0, 0.5, 0.5, 0.5,
+ -1.0, 1.0, 1.0, 0.75, 0.25, 0.5,
+ -1.0, -1.0, 1.0, 0.75, 0.25, 0.5,
+ -1.0, -1.0, -1.0, 0.75, 0.25, 0.5,
+ -1.0, 1.0, -1.0, 0.75, 0.25, 0.5,
+ 1.0, 1.0, 1.0, 0.25, 0.25, 0.75,
+ 1.0, -1.0, 1.0, 0.25, 0.25, 0.75,
+ 1.0, -1.0, -1.0, 0.25, 0.25, 0.75,
+ 1.0, 1.0, -1.0, 0.25, 0.25, 0.75,
+ 1.0, 1.0, 1.0, 1.0, 0.0, 0.15,
+ 1.0, -1.0, 1.0, 1.0, 0.0, 0.15,
+ -1.0, -1.0, 1.0, 1.0, 0.0, 0.15,
+ -1.0, 1.0, 1.0, 1.0, 0.0, 0.15,
+ 1.0, 1.0, -1.0, 0.0, 1.0, 0.15,
+ 1.0, -1.0, -1.0, 0.0, 1.0, 0.15,
+ -1.0, -1.0, -1.0, 0.0, 1.0, 0.15,
+ -1.0, 1.0, -1.0, 0.0, 1.0, 0.15,
+ -1.0, -1.0, -1.0, 0.5, 0.5, 1.0,
+ -1.0, -1.0, 1.0, 0.5, 0.5, 1.0,
+ 1.0, -1.0, 1.0, 0.5, 0.5, 1.0,
+ 1.0, -1.0, -1.0, 0.5, 0.5, 1.0,
+ ];
+
+ this.indicies = [
+ 0, 1, 2,
+ 0, 2, 3,
+ 5, 4, 6,
+ 6, 4, 7,
+ 8, 9, 10,
+ 8, 10, 11,
+ 13, 12, 14,
+ 15, 14, 12,
+ 16, 17, 18,
+ 16, 18, 19,
+ 21, 20, 22,
+ 22, 20, 23
+ ];
+
+ this.verticies = []
+ this.colors = []
+ for (let x = 0; x < this.indicies.length; x++) {
+ var i = this.indicies[x]
+ this.verticies.push(this.data[i * 6 + 2])
+ this.verticies.push(this.data[i * 6 + 1])
+ this.verticies.push(this.data[i * 6 + 0])
+ this.colors.push(this.data[i * 6 + 3])
+ this.colors.push(this.data[i * 6 + 4])
+ this.colors.push(this.data[i * 6 + 5])
+ }
+
+ this.mesh = new Mesh(this.indicies.length)
+ .store(this.verticies, 3)
+ .store(this.colors, 3)
+ .finish()
+
+ }
+
+} \ No newline at end of file