Sorting triangles
This commit is contained in:
parent
4768a3056c
commit
59518eb702
|
@ -153,7 +153,6 @@ function loop() {
|
||||||
|
|
||||||
if (!testDistance(old, camera) && !finished && !forceFinished) {
|
if (!testDistance(old, camera) && !finished && !forceFinished) {
|
||||||
process.nextTick(loop);
|
process.nextTick(loop);
|
||||||
finish();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +167,7 @@ function loop() {
|
||||||
|
|
||||||
let score = 0;
|
let score = 0;
|
||||||
|
|
||||||
|
var totalPixel = 0;
|
||||||
for (let i = 0; i < width; i++) {
|
for (let i = 0; i < width; i++) {
|
||||||
|
|
||||||
buf[i] = [];
|
buf[i] = [];
|
||||||
|
@ -186,11 +186,15 @@ function loop() {
|
||||||
let intersects = raycaster.intersectObject(loader.obj, true);
|
let intersects = raycaster.intersectObject(loader.obj, true);
|
||||||
|
|
||||||
if (intersectsProg.length === 0 && intersects.length === 0) {
|
if (intersectsProg.length === 0 && intersects.length === 0) {
|
||||||
score++;
|
// Not good
|
||||||
} else if (intersectsProg.length !== intersects.length) {
|
} else if (intersectsProg.length !== intersects.length) {
|
||||||
// Not good
|
// Not good
|
||||||
|
totalPixel++;
|
||||||
} else if (equalFaces(intersectsProg[0].face, intersects[0].face)) {
|
} else if (equalFaces(intersectsProg[0].face, intersects[0].face)) {
|
||||||
score++;
|
score++;
|
||||||
|
totalPixel++;
|
||||||
|
} else {
|
||||||
|
totalPixel++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intersectsProg.length > 0) {
|
if (intersectsProg.length > 0) {
|
||||||
|
@ -202,7 +206,7 @@ function loop() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
score /= width * height;
|
score /= totalPixel;
|
||||||
|
|
||||||
// for (let i = 0; i < 255; i++) {
|
// for (let i = 0; i < 255; i++) {
|
||||||
// colorsOccurence[i+1] += colorsOccurence[i];
|
// colorsOccurence[i+1] += colorsOccurence[i];
|
||||||
|
@ -237,9 +241,4 @@ function loop() {
|
||||||
|
|
||||||
if (!finished && !forceFinished)
|
if (!finished && !forceFinished)
|
||||||
setTimeout(loop,50);
|
setTimeout(loop,50);
|
||||||
else
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function finish() { console.log('];') }
|
|
||||||
|
|
||||||
|
|
|
@ -343,15 +343,15 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
|
||||||
|
|
||||||
var mightBeCompletetlyFinished = true;
|
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
|
var currentFace = this.mesh.faces[faceIndex];
|
||||||
// if (camera !== undefined && camera !== null)
|
|
||||||
// currentMesh.faces.sort(this.faceComparator(camera))
|
|
||||||
|
|
||||||
if (this.isFinished(meshIndex)) {
|
if (this.faces[currentFace.index] === true) {
|
||||||
|
|
||||||
continue;
|
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 vertex1 = this.mesh.vertices[currentFace.a];
|
||||||
var vertex2 = this.mesh.vertices[currentFace.b];
|
var vertex2 = this.mesh.vertices[currentFace.b];
|
||||||
var vertex3 = this.mesh.vertices[currentFace.c];
|
var vertex3 = this.mesh.vertices[currentFace.c];
|
||||||
|
@ -507,9 +497,9 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
|
||||||
|
|
||||||
data.push(currentFace.toList());
|
data.push(currentFace.toList());
|
||||||
// this.meshFaces[meshIndex] = this.meshFaces[meshIndex] || [];
|
// this.meshFaces[meshIndex] = this.meshFaces[meshIndex] || [];
|
||||||
this.meshFaces[meshIndex].array[faceIndex] = true;
|
this.faces[currentFace.index] = true;
|
||||||
this.meshFaces[meshIndex].counter++;
|
// this.meshFaces[meshIndex].counter++;
|
||||||
currentMesh.faceIndex++;
|
// currentMesh.faceIndex++;
|
||||||
|
|
||||||
sent++;
|
sent++;
|
||||||
|
|
||||||
|
@ -519,7 +509,6 @@ geo.MeshStreamer.prototype.nextElements = function(_camera, force) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return {data: data, finished: mightBeCompletetlyFinished};
|
return {data: data, finished: mightBeCompletetlyFinished};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue