Created
December 22, 2015 18:46
-
-
Save MagnusThor/669fc286d153a0ea5f09 to your computer and use it in GitHub Desktop.
Perfa..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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