Sorting triangles

This commit is contained in:
Thomas FORGIONE 2015-10-27 08:10:33 +01:00
parent 4768a3056c
commit 59518eb702
2 changed files with 148 additions and 160 deletions

View File

@ -153,7 +153,6 @@ function loop() {
if (!testDistance(old, camera) && !finished && !forceFinished) {
process.nextTick(loop);
finish();
return;
}
@ -168,6 +167,7 @@ function loop() {
let score = 0;
var totalPixel = 0;
for (let i = 0; i < width; i++) {
buf[i] = [];
@ -186,11 +186,15 @@ function loop() {
let intersects = raycaster.intersectObject(loader.obj, true);
if (intersectsProg.length === 0 && intersects.length === 0) {
score++;
// Not good
} else if (intersectsProg.length !== intersects.length) {
// Not good
totalPixel++;
} else if (equalFaces(intersectsProg[0].face, intersects[0].face)) {
score++;
totalPixel++;
} else {
totalPixel++;
}
if (intersectsProg.length > 0) {
@ -202,7 +206,7 @@ function loop() {
}
score /= width * height;
score /= totalPixel;
// for (let i = 0; i < 255; i++) {
// colorsOccurence[i+1] += colorsOccurence[i];
@ -237,9 +241,4 @@ function loop() {
if (!finished && !forceFinished)
setTimeout(loop,50);
else
finish();
}
function finish() { console.log('];') }

View File

@ -343,15 +343,15 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
var mightBeCompletetlyFinished = true;
for (var meshIndex = 0; meshIndex < this.mesh.meshes.length; meshIndex++) {
// BOOM
if (camera != null)
this.mesh.faces.sort(this.faceComparator(camera));
var currentMesh = this.mesh.meshes[meshIndex];
for (var faceIndex = 0; faceIndex < this.mesh.faces.length; faceIndex++) {
// Sort faces
// if (camera !== undefined && camera !== null)
// currentMesh.faces.sort(this.faceComparator(camera))
var currentFace = this.mesh.faces[faceIndex];
if (this.isFinished(meshIndex)) {
if (this.faces[currentFace.index] === true) {
continue;
@ -361,16 +361,6 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
}
for (var faceIndex = 0; faceIndex < currentMesh.faces.length; faceIndex++) {
var currentFace = currentMesh.faces[faceIndex];
if (this.meshFaces[meshIndex].array[faceIndex] === true) {
continue;
}
var vertex1 = this.mesh.vertices[currentFace.a];
var vertex2 = this.mesh.vertices[currentFace.b];
var vertex3 = this.mesh.vertices[currentFace.c];
@ -507,9 +497,9 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
data.push(currentFace.toList());
// this.meshFaces[meshIndex] = this.meshFaces[meshIndex] || [];
this.meshFaces[meshIndex].array[faceIndex] = true;
this.meshFaces[meshIndex].counter++;
currentMesh.faceIndex++;
this.faces[currentFace.index] = true;
// this.meshFaces[meshIndex].counter++;
// currentMesh.faceIndex++;
sent++;
@ -519,7 +509,6 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
}
}
}
return {data: data, finished: mightBeCompletetlyFinished};