12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package h3d.prim;
- import h3d.col.Point;
- class Cube extends Polygon {
- public function new( x = 1., y = 1., z = 1. )
- {
- var p = [
- new Point(0, 0, 0),
- new Point(x, 0, 0),
- new Point(0, y, 0),
- new Point(0, 0, z),
- new Point(x, y, 0),
- new Point(x, 0, z),
- new Point(0, y, z),
- new Point(x, y, z),
- ];
- var idx = new hxd.IndexBuffer();
- idx.push(0); idx.push(1); idx.push(5);
- idx.push(0); idx.push(5); idx.push(3);
- idx.push(1); idx.push(4); idx.push(7);
- idx.push(1); idx.push(7); idx.push(5);
- idx.push(3); idx.push(5); idx.push(7);
- idx.push(3); idx.push(7); idx.push(6);
- idx.push(0); idx.push(6); idx.push(2);
- idx.push(0); idx.push(3); idx.push(6);
- idx.push(2); idx.push(7); idx.push(4);
- idx.push(2); idx.push(6); idx.push(7);
- idx.push(0); idx.push(4); idx.push(1);
- idx.push(0); idx.push(2); idx.push(4);
- super(p, idx);
- }
- override function addUVs() {
- unindex();
- var z = new UV(0, 0);
- var x = new UV(1, 0);
- var y = new UV(0, 1);
- var o = new UV(1, 1);
- uvs = [
- z, x, o,
- z, o, y,
- x, z, y,
- x, y, o,
- z, x, o,
- z, o, y,
- z, o, x,
- z, y, o,
- x, y, z,
- x, o, y,
- z, o, x,
- z, y, o,
- ];
- }
- }
|