The obj file format specifies continuous lines and not line segments.
This commit is contained in:
parent
82c5d01a43
commit
8a3c98e658
@ -220,7 +220,7 @@ export class ImporterObj extends ImporterBase
|
||||
));
|
||||
return true;
|
||||
} else if (keyword === 'l') {
|
||||
if (parameters.length < 2 || parameters.length % 2 !== 0) {
|
||||
if (parameters.length < 2) {
|
||||
return true;
|
||||
}
|
||||
this.ProcessLineCommand (parameters);
|
||||
|
||||
@ -27,7 +27,7 @@ export class Line
|
||||
if (this.vertices === null) {
|
||||
return 0;
|
||||
}
|
||||
return parseInt (this.vertices.length / 2, 10);
|
||||
return this.vertices.length - 1;
|
||||
}
|
||||
|
||||
Clone ()
|
||||
|
||||
@ -445,12 +445,16 @@ export function ConvertModelToThreeObject (model, conversionParams, conversionOu
|
||||
for (let i = 0; i < lineIndices.length; i++) {
|
||||
let line = mesh.GetLine (lineIndices[i]);
|
||||
let lineVertices = line.GetVertices ();
|
||||
for (let vertexIndex of lineVertices) {
|
||||
for (let i = 0; i < lineVertices.length; i++) {
|
||||
let vertexIndex = lineVertices[i];
|
||||
let vertex = mesh.GetVertex (vertexIndex);
|
||||
vertices.push (vertex.x, vertex.y, vertex.z);
|
||||
if (i > 0 && i < lineVertices.length - 1) {
|
||||
vertices.push (vertex.x, vertex.y, vertex.z);
|
||||
}
|
||||
}
|
||||
meshMaterialHandler.ProcessItem (segmentCount, line.mat);
|
||||
segmentCount += lineVertices.length / 2;
|
||||
segmentCount += line.SegmentCount ();
|
||||
}
|
||||
meshMaterialHandler.Finalize (segmentCount);
|
||||
|
||||
|
||||
@ -29,12 +29,15 @@ f 1/1/6 4/2/6 3/3/6 2/4/6
|
||||
f 2/1/1 3/2/1 7/3/1 6/4/1
|
||||
f 4/1/2 1/2/2 5/3/2 8/4/2
|
||||
f 5/1/5 6/2/5 7/3/5 8/4/5
|
||||
l 1 4 2 3 6 7 5 8
|
||||
l 1 4
|
||||
l 2 3
|
||||
l 6 7
|
||||
l 5 8
|
||||
|
||||
usemtl Red
|
||||
f 3/1/3 4/2/3 8/3/3 7/4/3
|
||||
l 1 2 2 6 6 5 5 1
|
||||
l 1 2 6 5 1
|
||||
|
||||
usemtl Blue
|
||||
f 1/1/4 2/2/4 6/3/4 5/4/4
|
||||
l 3 4 4 8 8 7 7 3
|
||||
l 3 4 8 7 3
|
||||
|
||||
@ -8,4 +8,4 @@ v 1.0 1.0 1.0
|
||||
v 0.0 1.0 1.0
|
||||
l 1 2
|
||||
l 3 4
|
||||
l 5 6 6 7 7 8 8 5
|
||||
l 5 6 7 8 5
|
||||
|
||||
@ -12,7 +12,7 @@ usemtl Red
|
||||
l 1 2
|
||||
l 3 4
|
||||
usemtl Green
|
||||
l 5 6 6 7 7 8 8 5
|
||||
l 5 6 7 8 5
|
||||
usemtl Blue
|
||||
l 1 5
|
||||
|
||||
|
||||
@ -10,4 +10,4 @@ g Mesh01
|
||||
l 1 2
|
||||
l 3 4
|
||||
g Mesh02
|
||||
l 5 6 6 7 7 8 8 5
|
||||
l 5 6 7 8 5
|
||||
|
||||
@ -13,4 +13,4 @@ v 1.0 1.0 1.0
|
||||
v 0.0 1.0 1.0
|
||||
|
||||
g Mesh02
|
||||
l 5 6 6 7 7 8 8 5
|
||||
l 5 6 7 8 5
|
||||
|
||||
@ -668,7 +668,7 @@ describe ('Obj Importer', function () {
|
||||
mat : 0
|
||||
},
|
||||
{
|
||||
vertices : [0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1],
|
||||
vertices : [0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1],
|
||||
mat : 0
|
||||
}
|
||||
],
|
||||
@ -707,7 +707,7 @@ describe ('Obj Importer', function () {
|
||||
name : 'Mesh02',
|
||||
lines : [
|
||||
{
|
||||
vertices : [0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1],
|
||||
vertices : [0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1],
|
||||
mat : 0
|
||||
}
|
||||
],
|
||||
@ -746,7 +746,7 @@ describe ('Obj Importer', function () {
|
||||
name : 'Mesh02',
|
||||
lines : [
|
||||
{
|
||||
vertices : [0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1],
|
||||
vertices : [0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1],
|
||||
mat : 0
|
||||
}
|
||||
],
|
||||
@ -781,7 +781,7 @@ describe ('Obj Importer', function () {
|
||||
mat : 0
|
||||
},
|
||||
{
|
||||
vertices : [0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1],
|
||||
vertices : [0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1],
|
||||
mat : 1
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user