@loaders.gl/ply 4.2.0-alpha.3 → 4.2.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +54 -57
- package/dist/dist.min.js +12 -0
- package/dist/index.cjs +14 -18
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -6
- package/dist/lib/get-ply-schema.d.ts +1 -1
- package/dist/lib/get-ply-schema.d.ts.map +1 -1
- package/dist/lib/get-ply-schema.js +28 -17
- package/dist/lib/normalize-ply.d.ts +1 -1
- package/dist/lib/normalize-ply.d.ts.map +1 -1
- package/dist/lib/normalize-ply.js +68 -77
- package/dist/lib/parse-ply-in-batches.d.ts +1 -1
- package/dist/lib/parse-ply-in-batches.d.ts.map +1 -1
- package/dist/lib/parse-ply-in-batches.js +226 -157
- package/dist/lib/parse-ply.d.ts +1 -1
- package/dist/lib/parse-ply.d.ts.map +1 -1
- package/dist/lib/parse-ply.js +365 -285
- package/dist/lib/ply-types.js +0 -1
- package/dist/ply-loader.d.ts +1 -1
- package/dist/ply-loader.d.ts.map +1 -1
- package/dist/ply-loader.js +22 -15
- package/dist/ply-worker.js +1 -1
- package/dist/workers/ply-worker.js +0 -1
- package/package.json +10 -7
- package/dist/index.js.map +0 -1
- package/dist/lib/get-ply-schema.js.map +0 -1
- package/dist/lib/normalize-ply.js.map +0 -1
- package/dist/lib/parse-ply-in-batches.js.map +0 -1
- package/dist/lib/parse-ply.js.map +0 -1
- package/dist/lib/ply-types.js.map +0 -1
- package/dist/ply-loader.js.map +0 -1
- package/dist/workers/ply-worker.js.map +0 -1
|
@@ -1,86 +1,77 @@
|
|
|
1
1
|
import { getMeshBoundingBox } from '@loaders.gl/schema';
|
|
2
2
|
import { getPLYSchema } from "./get-ply-schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* @param header
|
|
5
|
+
* @param attributes
|
|
6
|
+
* @returns data and header
|
|
7
|
+
*/
|
|
3
8
|
export default function normalizePLY(plyHeader, plyAttributes, options) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
topology
|
|
26
|
-
};
|
|
27
|
-
if (plyAttributes.indices.length > 0) {
|
|
28
|
-
plyMesh.indices = {
|
|
29
|
-
value: new Uint32Array(plyAttributes.indices),
|
|
30
|
-
size: 1
|
|
9
|
+
const attributes = getMeshAttributes(plyAttributes);
|
|
10
|
+
const boundingBox = getMeshBoundingBox(attributes);
|
|
11
|
+
const vertexCount = plyAttributes.indices.length || plyAttributes.vertices.length / 3;
|
|
12
|
+
// TODO - how to detect POINT CLOUDS vs MESHES?
|
|
13
|
+
// TODO - For Meshes, PLY quadrangles must be split?
|
|
14
|
+
const isTriangles = plyAttributes.indices && plyAttributes.indices.length > 0;
|
|
15
|
+
const mode = isTriangles ? 4 : 0; // TRIANGLES vs POINTS
|
|
16
|
+
const topology = isTriangles ? 'triangle-list' : 'point-list';
|
|
17
|
+
const schema = getPLYSchema(plyHeader, attributes);
|
|
18
|
+
const plyMesh = {
|
|
19
|
+
loader: 'ply',
|
|
20
|
+
loaderData: plyHeader,
|
|
21
|
+
header: {
|
|
22
|
+
vertexCount,
|
|
23
|
+
boundingBox
|
|
24
|
+
},
|
|
25
|
+
schema,
|
|
26
|
+
attributes,
|
|
27
|
+
indices: { value: new Uint32Array(0), size: 0 },
|
|
28
|
+
mode,
|
|
29
|
+
topology
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if (plyAttributes.indices.length > 0) {
|
|
32
|
+
plyMesh.indices = { value: new Uint32Array(plyAttributes.indices), size: 1 };
|
|
33
|
+
}
|
|
34
|
+
return plyMesh;
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* @param attributes
|
|
38
|
+
* @returns accessors []
|
|
39
|
+
*/
|
|
40
|
+
// eslint-disable-next-line complexity
|
|
35
41
|
function getMeshAttributes(attributes) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
normalized: true
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
case 'indices':
|
|
73
|
-
break;
|
|
74
|
-
default:
|
|
75
|
-
if (attributes[attributeName].length > 0) {
|
|
76
|
-
accessors[attributeName] = {
|
|
77
|
-
value: new Float32Array(attributes[attributeName]),
|
|
78
|
-
size: 1
|
|
79
|
-
};
|
|
42
|
+
const accessors = {};
|
|
43
|
+
for (const attributeName of Object.keys(attributes)) {
|
|
44
|
+
switch (attributeName) {
|
|
45
|
+
case 'vertices':
|
|
46
|
+
if (attributes.vertices.length > 0) {
|
|
47
|
+
accessors.POSITION = { value: new Float32Array(attributes.vertices), size: 3 };
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
// optional attributes data
|
|
51
|
+
case 'normals':
|
|
52
|
+
if (attributes.normals.length > 0) {
|
|
53
|
+
accessors.NORMAL = { value: new Float32Array(attributes.normals), size: 3 };
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
case 'uvs':
|
|
57
|
+
if (attributes.uvs.length > 0) {
|
|
58
|
+
accessors.TEXCOORD_0 = { value: new Float32Array(attributes.uvs), size: 2 };
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case 'colors':
|
|
62
|
+
if (attributes.colors.length > 0) {
|
|
63
|
+
// TODO - normalized shoud be based on `uchar` flag in source data?
|
|
64
|
+
accessors.COLOR_0 = { value: new Uint8Array(attributes.colors), size: 3, normalized: true };
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
case 'indices':
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
if (attributes[attributeName].length > 0) {
|
|
71
|
+
accessors[attributeName] = { value: new Float32Array(attributes[attributeName]), size: 1 };
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
80
74
|
}
|
|
81
|
-
break;
|
|
82
75
|
}
|
|
83
|
-
|
|
84
|
-
return accessors;
|
|
76
|
+
return accessors;
|
|
85
77
|
}
|
|
86
|
-
//# sourceMappingURL=normalize-ply.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-ply-in-batches.d.ts","sourceRoot":"","sources":["../../src/lib/parse-ply-in-batches.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAC,OAAO,EAAoD,
|
|
1
|
+
{"version":3,"file":"parse-ply-in-batches.d.ts","sourceRoot":"","sources":["../../src/lib/parse-ply-in-batches.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAC,OAAO,EAAoD,uBAAoB;AAIvF;;;;GAIG;AACH,wBAAuB,iBAAiB,CACtC,QAAQ,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EAC5D,OAAO,EAAE,GAAG,GACX,aAAa,CAAC,OAAO,CAAC,CAexB"}
|
|
@@ -1,177 +1,246 @@
|
|
|
1
|
+
// PLY Loader, adapted from THREE.js (MIT license)
|
|
2
|
+
//
|
|
3
|
+
// Attributions per original THREE.js source file:
|
|
4
|
+
//
|
|
5
|
+
// @author Wei Meng / http://about.me/menway
|
|
6
|
+
//
|
|
7
|
+
// Description: A loader for PLY ASCII files (known as the Polygon File Format
|
|
8
|
+
// or the Stanford Triangle Format).
|
|
9
|
+
//
|
|
10
|
+
// Limitations: ASCII decoding assumes file is UTF-8.
|
|
11
|
+
//
|
|
12
|
+
// If the PLY file uses non standard property names, they can be mapped while
|
|
13
|
+
// loading. For example, the following maps the properties
|
|
14
|
+
// “diffuse_(red|green|blue)” in the file to standard color names.
|
|
15
|
+
//
|
|
16
|
+
// parsePLY(data, {
|
|
17
|
+
// propertyNameMapping: {
|
|
18
|
+
// diffuse_red: 'red',
|
|
19
|
+
// diffuse_green: 'green',
|
|
20
|
+
// diffuse_blue: 'blue'
|
|
21
|
+
// }
|
|
22
|
+
// });
|
|
1
23
|
import { makeLineIterator, makeTextDecoderIterator, forEach } from '@loaders.gl/loader-utils';
|
|
2
24
|
import normalizePLY from "./normalize-ply.js";
|
|
3
25
|
let currentElement;
|
|
26
|
+
/**
|
|
27
|
+
* PARSER
|
|
28
|
+
* @param iterator
|
|
29
|
+
* @param options
|
|
30
|
+
*/
|
|
4
31
|
export async function* parsePLYInBatches(iterator, options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
const lineIterator = makeLineIterator(makeTextDecoderIterator(iterator));
|
|
33
|
+
const header = await parsePLYHeader(lineIterator, options);
|
|
34
|
+
let attributes;
|
|
35
|
+
switch (header.format) {
|
|
36
|
+
case 'ascii':
|
|
37
|
+
attributes = await parseASCII(lineIterator, header);
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
throw new Error('Binary PLY can not yet be parsed in streaming mode');
|
|
41
|
+
// attributes = await parseBinary(lineIterator, header);
|
|
42
|
+
}
|
|
43
|
+
yield normalizePLY(header, attributes, options);
|
|
16
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Parses header
|
|
47
|
+
* @param lineIterator
|
|
48
|
+
* @param options
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
17
51
|
async function parsePLYHeader(lineIterator, options) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const lineValues = line.split(/\s+/);
|
|
31
|
-
const lineType = lineValues.shift();
|
|
32
|
-
line = lineValues.join(' ');
|
|
33
|
-
switch (lineType) {
|
|
34
|
-
case 'ply':
|
|
35
|
-
break;
|
|
36
|
-
case 'format':
|
|
37
|
-
header.format = lineValues[0];
|
|
38
|
-
header.version = lineValues[1];
|
|
39
|
-
break;
|
|
40
|
-
case 'comment':
|
|
41
|
-
header.comments.push(line);
|
|
42
|
-
break;
|
|
43
|
-
case 'element':
|
|
44
|
-
if (currentElement) {
|
|
45
|
-
header.elements.push(currentElement);
|
|
52
|
+
const header = {
|
|
53
|
+
comments: [],
|
|
54
|
+
elements: []
|
|
55
|
+
// headerLength
|
|
56
|
+
};
|
|
57
|
+
// Note: forEach does not reset iterator if exiting loop prematurely
|
|
58
|
+
// so that iteration can continue in a second loop
|
|
59
|
+
await forEach(lineIterator, (line) => {
|
|
60
|
+
line = line.trim();
|
|
61
|
+
// End of header
|
|
62
|
+
if (line === 'end_header') {
|
|
63
|
+
return true; // Returning true cancels `forEach`
|
|
46
64
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
// Ignore empty lines
|
|
66
|
+
if (line === '') {
|
|
67
|
+
// eslint-disable-next-line
|
|
68
|
+
return false; // Returning false does not cancel `forEach`
|
|
69
|
+
}
|
|
70
|
+
const lineValues = line.split(/\s+/);
|
|
71
|
+
const lineType = lineValues.shift();
|
|
72
|
+
line = lineValues.join(' ');
|
|
73
|
+
switch (lineType) {
|
|
74
|
+
case 'ply':
|
|
75
|
+
// First line magic characters, ignore
|
|
76
|
+
break;
|
|
77
|
+
case 'format':
|
|
78
|
+
header.format = lineValues[0];
|
|
79
|
+
header.version = lineValues[1];
|
|
80
|
+
break;
|
|
81
|
+
case 'comment':
|
|
82
|
+
header.comments.push(line);
|
|
83
|
+
break;
|
|
84
|
+
case 'element':
|
|
85
|
+
if (currentElement) {
|
|
86
|
+
header.elements.push(currentElement);
|
|
87
|
+
}
|
|
88
|
+
currentElement = {
|
|
89
|
+
name: lineValues[0],
|
|
90
|
+
count: parseInt(lineValues[1], 10),
|
|
91
|
+
properties: []
|
|
92
|
+
};
|
|
93
|
+
break;
|
|
94
|
+
case 'property':
|
|
95
|
+
const property = makePLYElementProperty(lineValues, options.propertyNameMapping);
|
|
96
|
+
currentElement.properties.push(property);
|
|
97
|
+
break;
|
|
98
|
+
default:
|
|
99
|
+
// eslint-disable-next-line
|
|
100
|
+
console.log('unhandled', lineType, lineValues);
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
});
|
|
104
|
+
if (currentElement) {
|
|
105
|
+
header.elements.push(currentElement);
|
|
59
106
|
}
|
|
60
|
-
return
|
|
61
|
-
});
|
|
62
|
-
if (currentElement) {
|
|
63
|
-
header.elements.push(currentElement);
|
|
64
|
-
}
|
|
65
|
-
return header;
|
|
107
|
+
return header;
|
|
66
108
|
}
|
|
67
109
|
function makePLYElementProperty(propertyValues, propertyNameMapping) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
110
|
+
const type = propertyValues[0];
|
|
111
|
+
switch (type) {
|
|
112
|
+
case 'list':
|
|
113
|
+
return {
|
|
114
|
+
type,
|
|
115
|
+
name: propertyValues[3],
|
|
116
|
+
countType: propertyValues[1],
|
|
117
|
+
itemType: propertyValues[2]
|
|
118
|
+
};
|
|
119
|
+
default:
|
|
120
|
+
return {
|
|
121
|
+
type,
|
|
122
|
+
name: propertyValues[1]
|
|
123
|
+
};
|
|
124
|
+
}
|
|
83
125
|
}
|
|
126
|
+
// ASCII PARSING
|
|
127
|
+
/**
|
|
128
|
+
* @param lineIterator
|
|
129
|
+
* @param header
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
84
132
|
async function parseASCII(lineIterator, header) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
line
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
133
|
+
// PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)
|
|
134
|
+
const attributes = {
|
|
135
|
+
indices: [],
|
|
136
|
+
vertices: [],
|
|
137
|
+
normals: [],
|
|
138
|
+
uvs: [],
|
|
139
|
+
colors: []
|
|
140
|
+
};
|
|
141
|
+
let currentElement = 0;
|
|
142
|
+
let currentElementCount = 0;
|
|
143
|
+
for await (let line of lineIterator) {
|
|
144
|
+
line = line.trim();
|
|
145
|
+
if (line !== '') {
|
|
146
|
+
if (currentElementCount >= header.elements[currentElement].count) {
|
|
147
|
+
currentElement++;
|
|
148
|
+
currentElementCount = 0;
|
|
149
|
+
}
|
|
150
|
+
const element = parsePLYElement(header.elements[currentElement].properties, line);
|
|
151
|
+
handleElement(attributes, header.elements[currentElement].name, element);
|
|
152
|
+
currentElementCount++;
|
|
153
|
+
}
|
|
104
154
|
}
|
|
105
|
-
|
|
106
|
-
return attributes;
|
|
155
|
+
return attributes;
|
|
107
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Parses ASCII number
|
|
159
|
+
* @param n
|
|
160
|
+
* @param type
|
|
161
|
+
* @returns ASCII number
|
|
162
|
+
*/
|
|
163
|
+
// eslint-disable-next-line complexity
|
|
108
164
|
function parseASCIINumber(n, type) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
165
|
+
switch (type) {
|
|
166
|
+
case 'char':
|
|
167
|
+
case 'uchar':
|
|
168
|
+
case 'short':
|
|
169
|
+
case 'ushort':
|
|
170
|
+
case 'int':
|
|
171
|
+
case 'uint':
|
|
172
|
+
case 'int8':
|
|
173
|
+
case 'uint8':
|
|
174
|
+
case 'int16':
|
|
175
|
+
case 'uint16':
|
|
176
|
+
case 'int32':
|
|
177
|
+
case 'uint32':
|
|
178
|
+
return parseInt(n, 10);
|
|
179
|
+
case 'float':
|
|
180
|
+
case 'double':
|
|
181
|
+
case 'float32':
|
|
182
|
+
case 'float64':
|
|
183
|
+
return parseFloat(n);
|
|
184
|
+
default:
|
|
185
|
+
throw new Error(type);
|
|
186
|
+
}
|
|
131
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Parses ASCII element
|
|
190
|
+
* @param properties
|
|
191
|
+
* @param line
|
|
192
|
+
* @returns element
|
|
193
|
+
*/
|
|
132
194
|
function parsePLYElement(properties, line) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
195
|
+
const values = line.split(/\s+/);
|
|
196
|
+
const element = {};
|
|
197
|
+
for (let i = 0; i < properties.length; i++) {
|
|
198
|
+
if (properties[i].type === 'list') {
|
|
199
|
+
const list = [];
|
|
200
|
+
const n = parseASCIINumber(values.shift(), properties[i].countType);
|
|
201
|
+
for (let j = 0; j < n; j++) {
|
|
202
|
+
list.push(parseASCIINumber(values.shift(), properties[i].itemType));
|
|
203
|
+
}
|
|
204
|
+
element[properties[i].name] = list;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
element[properties[i].name] = parseASCIINumber(values.shift(), properties[i].type);
|
|
208
|
+
}
|
|
145
209
|
}
|
|
146
|
-
|
|
147
|
-
return element;
|
|
210
|
+
return element;
|
|
148
211
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
212
|
+
/**
|
|
213
|
+
* @param buffer
|
|
214
|
+
* @param elementName
|
|
215
|
+
* @param element
|
|
216
|
+
*/
|
|
217
|
+
// HELPER FUNCTIONS
|
|
218
|
+
// eslint-disable-next-line complexity
|
|
219
|
+
function handleElement(buffer, elementName, element = {}) {
|
|
220
|
+
switch (elementName) {
|
|
221
|
+
case 'vertex':
|
|
222
|
+
buffer.vertices.push(element.x, element.y, element.z);
|
|
223
|
+
if ('nx' in element && 'ny' in element && 'nz' in element) {
|
|
224
|
+
buffer.normals.push(element.nx, element.ny, element.nz);
|
|
225
|
+
}
|
|
226
|
+
if ('s' in element && 't' in element) {
|
|
227
|
+
buffer.uvs.push(element.s, element.t);
|
|
228
|
+
}
|
|
229
|
+
if ('red' in element && 'green' in element && 'blue' in element) {
|
|
230
|
+
buffer.colors.push(element.red / 255.0, element.green / 255.0, element.blue / 255.0);
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case 'face':
|
|
234
|
+
const vertexIndices = element.vertex_indices || element.vertex_index; // issue #9338
|
|
235
|
+
if (vertexIndices.length === 3) {
|
|
236
|
+
buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[2]);
|
|
237
|
+
}
|
|
238
|
+
else if (vertexIndices.length === 4) {
|
|
239
|
+
buffer.indices.push(vertexIndices[0], vertexIndices[1], vertexIndices[3]);
|
|
240
|
+
buffer.indices.push(vertexIndices[1], vertexIndices[2], vertexIndices[3]);
|
|
241
|
+
}
|
|
242
|
+
break;
|
|
243
|
+
default:
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
176
246
|
}
|
|
177
|
-
//# sourceMappingURL=parse-ply-in-batches.js.map
|
package/dist/lib/parse-ply.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-ply.d.ts","sourceRoot":"","sources":["../../src/lib/parse-ply.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACV,OAAO,EAMR,
|
|
1
|
+
{"version":3,"file":"parse-ply.d.ts","sourceRoot":"","sources":["../../src/lib/parse-ply.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACV,OAAO,EAMR,uBAAoB;AAGrB,MAAM,MAAM,eAAe,GAAG;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAc3F"}
|