cube test
This commit is contained in:
parent
fcf0ee4b47
commit
7caf01a4ae
4 changed files with 412 additions and 40 deletions
57
docs/js/cube.js
Normal file
57
docs/js/cube.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
var MDN = MDN || {};
|
||||
|
||||
MDN.createCubeData = function (a, b, c) {
|
||||
|
||||
var positions = [
|
||||
// Front face
|
||||
-1.0, -1.0, 1.0,
|
||||
1.0, -1.0, 1.0,
|
||||
1.0, 1.0, 1.0,
|
||||
-1.0, 1.0, 1.0,
|
||||
|
||||
// Back face
|
||||
-1.0, -1.0, -1.0,
|
||||
-1.0, 1.0, -1.0,
|
||||
1.0, 1.0, -1.0,
|
||||
1.0, -1.0, -1.0,
|
||||
|
||||
// Top face
|
||||
-1.0, 1.0, -1.0,
|
||||
-1.0, 1.0, 1.0,
|
||||
1.0, 1.0, 1.0,
|
||||
1.0, 1.0, -1.0,
|
||||
|
||||
// Bottom face
|
||||
-1.0, -1.0, -1.0,
|
||||
1.0, -1.0, -1.0,
|
||||
1.0, -1.0, 1.0,
|
||||
-1.0, -1.0, 1.0,
|
||||
|
||||
// Right face
|
||||
1.0, -1.0, -1.0,
|
||||
1.0, 1.0, -1.0,
|
||||
1.0, 1.0, 1.0,
|
||||
1.0, -1.0, 1.0,
|
||||
|
||||
// Left face
|
||||
-1.0, -1.0, -1.0,
|
||||
-1.0, -1.0, 1.0,
|
||||
-1.0, 1.0, 1.0,
|
||||
-1.0, 1.0, -1.0
|
||||
];
|
||||
var elements = [
|
||||
0, 1, 2, 0, 2, 3, // front
|
||||
4, 5, 6, 4, 6, 7, // back
|
||||
8, 9, 10, 8, 10, 11, // top
|
||||
12, 13, 14, 12, 14, 15, // bottom
|
||||
16, 17, 18, 16, 18, 19, // right
|
||||
20, 21, 22, 20, 22, 23 // left
|
||||
]
|
||||
|
||||
let out = [];
|
||||
for (let i of elements) {
|
||||
out.push(positions[i * 3] * a, positions[i * 3 + 1] * b, positions[i * 3 + 2] * c)
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue