Skip to content

Instantly share code, notes, and snippets.

@MagnusThor
Created December 22, 2015 18:46
Show Gist options
  • Save MagnusThor/669fc286d153a0ea5f09 to your computer and use it in GitHub Desktop.
Save MagnusThor/669fc286d153a0ea5f09 to your computer and use it in GitHub Desktop.
Perfa..
verticles = [
new Noc.Point3D(-1, -1, -1), // 0
new Noc.Point3D(1, -1, -1), // 1
new Noc.Point3D(1, 1, -1), // 2
new Noc.Point3D(-1, 1, -1), // 3
new Noc.Point3D(1, -1, 1, 0), // 5
new Noc.Point3D(1, 1, 1), // 6
new Noc.Point3D(-1, 1, 1), // 7
];
var faces = [
[0, 1, 2],
[0, 2, 3],
[4, 5, 6],
//....
];
faces.forEach(function (face,index) {
var squareObject = new Noc.Object3D();
var vrts = Noc.Helpers.getVerticles(face, verticles);
squareObject.verticles = vrts.slice();
vrts.forEach(function(p,vi) {
vrts[vi] = p.project(0, 0, 720, 0);
});
var tris = Noc.Helpers.triangulate(Noc.Helpers.flattenVerticles(vrts));
var faces = Noc.Helpers.getFaces(tris, 3);
trace("tris for #" + index,faces);
faces.forEach(function(face) {
squareObject.faces.push(face);
squareObject.uvs.push(0.5, 0.5);
});
squareObjects.push(squareObject);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment