Adds vertex prediction
This commit is contained in:
parent
46363f19c9
commit
5281616922
|
@ -98,6 +98,15 @@ function parseLine(line) {
|
||||||
);
|
);
|
||||||
return element;
|
return element;
|
||||||
|
|
||||||
|
case "pv":
|
||||||
|
element.type = Element.PredictVertex;
|
||||||
|
element.value = new THREE.Face3(
|
||||||
|
parseInt(split[2], 10) - 1,
|
||||||
|
parseInt(split[2], 10) - 1,
|
||||||
|
parseInt(split[2], 10) - 1,
|
||||||
|
);
|
||||||
|
return element;
|
||||||
|
|
||||||
case "efv":
|
case "efv":
|
||||||
element.type = Element.EditFaceVertex;
|
element.type = Element.EditFaceVertex;
|
||||||
element.id = parseInt(split[1], 10) - 1;
|
element.id = parseInt(split[1], 10) - 1;
|
||||||
|
@ -140,6 +149,7 @@ Element.EditFace = "EditFace";
|
||||||
Element.EditFaceVertex = "EditFaceVertex";
|
Element.EditFaceVertex = "EditFaceVertex";
|
||||||
Element.TranslateVertex = "TranslateVertex";
|
Element.TranslateVertex = "TranslateVertex";
|
||||||
Element.DeleteFace = "DeleteFace";
|
Element.DeleteFace = "DeleteFace";
|
||||||
|
Element.PredictVertex = "PredictVertex";
|
||||||
|
|
||||||
class Loader {
|
class Loader {
|
||||||
constructor(path, chunkSize = 1024, timeout = 20) {
|
constructor(path, chunkSize = 1024, timeout = 20) {
|
||||||
|
|
26
src/Model.js
26
src/Model.js
|
@ -47,6 +47,25 @@ class Model extends THREE.Mesh {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
checkVertexPrediction(f) {
|
||||||
|
let vertices = this.geometry.vertices;
|
||||||
|
|
||||||
|
if (vertices[f.a] === undefined) {
|
||||||
|
this.throwError("Vertex prediction requires vertex " + (f.a + 1) + " but there is no such vertex");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vertices[f.b] === undefined) {
|
||||||
|
this.throwError("Vertex prediction requires vertex " + (f.b + 1) + " but there is no such vertex");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vertices[f.c] === undefined) {
|
||||||
|
this.throwError("Vertex prediction requires vertex " + (f.c + 1) + " but there is no such vertex");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
manageElement(element) {
|
manageElement(element) {
|
||||||
|
|
||||||
let vertices = this.geometry.vertices;
|
let vertices = this.geometry.vertices;
|
||||||
|
@ -142,6 +161,13 @@ class Model extends THREE.Mesh {
|
||||||
this.geometry.elementsNeedUpdate = true;
|
this.geometry.elementsNeedUpdate = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Element.PredictVertex:
|
||||||
|
this.checkVertexPrediction(element.value);
|
||||||
|
vertices.push(vertices[element.value.a].clone()
|
||||||
|
.add(vertices[element.value.c])
|
||||||
|
.sub(vertices[element.value.b]));
|
||||||
|
this.geometry.verticesNeedUpdate = true;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error("unknown element type: " + element.type);
|
throw new Error("unknown element type: " + element.type);
|
||||||
|
|
Loading…
Reference in New Issue