@itwin/core-geometry 4.7.0-dev.6 → 4.7.0-dev.8
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/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +7 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +20 -4
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +3 -3
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +4 -3
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts +7 -0
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js +19 -0
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/polyface/AuxData.d.ts +18 -10
- package/lib/cjs/polyface/AuxData.d.ts.map +1 -1
- package/lib/cjs/polyface/AuxData.js +24 -12
- package/lib/cjs/polyface/AuxData.js.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +2 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +2 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/cjs/polyface/Polyface.d.ts +10 -2
- package/lib/cjs/polyface/Polyface.d.ts.map +1 -1
- package/lib/cjs/polyface/Polyface.js +29 -17
- package/lib/cjs/polyface/Polyface.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.d.ts +10 -9
- package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.js +17 -2
- package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +302 -251
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +363 -309
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/serialization/BGFBReader.d.ts +18 -20
- package/lib/cjs/serialization/BGFBReader.d.ts.map +1 -1
- package/lib/cjs/serialization/BGFBReader.js +119 -84
- package/lib/cjs/serialization/BGFBReader.js.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.d.ts +1 -1
- package/lib/cjs/serialization/BGFBWriter.d.ts.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.js +10 -15
- package/lib/cjs/serialization/BGFBWriter.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.d.ts +52 -7
- package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.js +26 -78
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/cjs/serialization/SerializationHelpers.d.ts +17 -0
- package/lib/cjs/serialization/SerializationHelpers.d.ts.map +1 -1
- package/lib/cjs/serialization/SerializationHelpers.js +85 -0
- package/lib/cjs/serialization/SerializationHelpers.js.map +1 -1
- package/lib/cjs/solid/Sphere.d.ts +1 -0
- package/lib/cjs/solid/Sphere.d.ts.map +1 -1
- package/lib/cjs/solid/Sphere.js +4 -2
- package/lib/cjs/solid/Sphere.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +7 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +20 -4
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +3 -3
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +4 -3
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts +7 -0
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js +19 -0
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/polyface/AuxData.d.ts +18 -10
- package/lib/esm/polyface/AuxData.d.ts.map +1 -1
- package/lib/esm/polyface/AuxData.js +24 -12
- package/lib/esm/polyface/AuxData.js.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +2 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js +2 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/esm/polyface/Polyface.d.ts +10 -2
- package/lib/esm/polyface/Polyface.d.ts.map +1 -1
- package/lib/esm/polyface/Polyface.js +29 -17
- package/lib/esm/polyface/Polyface.js.map +1 -1
- package/lib/esm/polyface/PolyfaceData.d.ts +10 -9
- package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceData.js +17 -2
- package/lib/esm/polyface/PolyfaceData.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +302 -251
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +363 -309
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/serialization/BGFBReader.d.ts +18 -20
- package/lib/esm/serialization/BGFBReader.d.ts.map +1 -1
- package/lib/esm/serialization/BGFBReader.js +119 -84
- package/lib/esm/serialization/BGFBReader.js.map +1 -1
- package/lib/esm/serialization/BGFBWriter.d.ts +1 -1
- package/lib/esm/serialization/BGFBWriter.d.ts.map +1 -1
- package/lib/esm/serialization/BGFBWriter.js +10 -15
- package/lib/esm/serialization/BGFBWriter.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.d.ts +52 -7
- package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.js +26 -78
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/serialization/SerializationHelpers.d.ts +17 -0
- package/lib/esm/serialization/SerializationHelpers.d.ts.map +1 -1
- package/lib/esm/serialization/SerializationHelpers.js +85 -0
- package/lib/esm/serialization/SerializationHelpers.js.map +1 -1
- package/lib/esm/solid/Sphere.d.ts +1 -0
- package/lib/esm/solid/Sphere.d.ts.map +1 -1
- package/lib/esm/solid/Sphere.js +4 -2
- package/lib/esm/solid/Sphere.js.map +1 -1
- package/package.json +4 -4
|
@@ -55,30 +55,28 @@ export declare class BGFBReader {
|
|
|
55
55
|
* @param variant read position in the flat buffer.
|
|
56
56
|
*/
|
|
57
57
|
readPointStringFromVariant(variant: BGFBAccessors.VariantGeometry): PointString3d | undefined;
|
|
58
|
-
/**
|
|
59
|
-
* Extract auxData for a mesh
|
|
60
|
-
* @param variant read position in the flat buffer.
|
|
61
|
-
*/
|
|
58
|
+
/** Extract auxData channel data for a mesh */
|
|
62
59
|
readPolyfaceAuxChannelData(channelDataHeader: BGFBAccessors.PolyfaceAuxChannelData | null): AuxChannelData | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* Extract auxData for a mesh
|
|
65
|
-
* @param variant read position in the flat buffer.
|
|
66
|
-
*/
|
|
60
|
+
/** Extract auxData channel for a mesh */
|
|
67
61
|
readPolyfaceAuxChannel(channelHeader: BGFBAccessors.PolyfaceAuxChannel | null): AuxChannel | undefined;
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
/** Compute the number of logical entries in every flat data array in the AuxData */
|
|
63
|
+
private static channelDataLength;
|
|
64
|
+
/** Examine int array for range and zero count */
|
|
65
|
+
private countIntArray;
|
|
66
|
+
/**
|
|
67
|
+
* Extract auxData for a mesh.
|
|
68
|
+
* Typescript object format for Polyface/PolyfaceAuxData indices is 0-based, unterminated.
|
|
69
|
+
* FlatBuffer format for Polyface/PolyfaceAuxData indices is 1-based, 0-terminated/padded.
|
|
70
|
+
* Typescript API previously wrote FlatBuffer PolyfaceAuxData indices as 0-based, unterminated;
|
|
71
|
+
* heuristics are used herein to identify this legacy format so it can still be read.
|
|
72
|
+
*/
|
|
73
|
+
readPolyfaceAuxData(fbPolyface: BGFBAccessors.Polyface | null, fbAuxData: BGFBAccessors.PolyfaceAuxData | null): PolyfaceAuxData | undefined;
|
|
74
|
+
/** Extract tagged numeric data for a mesh */
|
|
77
75
|
readTaggedNumericData(accessor: BGFBAccessors.TaggedNumericData | undefined): TaggedNumericData | undefined;
|
|
78
76
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
* Extract a mesh
|
|
78
|
+
* @param variant read position in the flat buffer.
|
|
79
|
+
*/
|
|
82
80
|
readPolyfaceFromVariant(variant: BGFBAccessors.VariantGeometry): IndexedPolyface | undefined;
|
|
83
81
|
readCurveCollectionFromCurveVectorTable(cvTable: BGFBAccessors.CurveVector): CurveCollection;
|
|
84
82
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BGFBReader.d.ts","sourceRoot":"","sources":["../../../src/serialization/BGFBReader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BGFBReader.d.ts","sourceRoot":"","sources":["../../../src/serialization/BGFBReader.ts"],"names":[],"mappings":"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"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { flatbuffers } from "flatbuffers";
|
|
6
|
+
import { assert } from "@itwin/core-bentley";
|
|
6
7
|
import { AkimaCurve3d, AkimaCurve3dOptions } from "../bspline/AkimaCurve3d";
|
|
7
8
|
import { BSplineCurve3d } from "../bspline/BSplineCurve";
|
|
8
9
|
import { BSplineCurve3dH } from "../bspline/BSplineCurve3dH";
|
|
@@ -250,10 +251,7 @@ export class BGFBReader {
|
|
|
250
251
|
}
|
|
251
252
|
return undefined;
|
|
252
253
|
}
|
|
253
|
-
/**
|
|
254
|
-
* Extract auxData for a mesh
|
|
255
|
-
* @param variant read position in the flat buffer.
|
|
256
|
-
*/
|
|
254
|
+
/** Extract auxData channel data for a mesh */
|
|
257
255
|
readPolyfaceAuxChannelData(channelDataHeader) {
|
|
258
256
|
if (channelDataHeader !== null) {
|
|
259
257
|
const input = channelDataHeader.input();
|
|
@@ -263,10 +261,7 @@ export class BGFBReader {
|
|
|
263
261
|
}
|
|
264
262
|
return undefined;
|
|
265
263
|
}
|
|
266
|
-
/**
|
|
267
|
-
* Extract auxData for a mesh
|
|
268
|
-
* @param variant read position in the flat buffer.
|
|
269
|
-
*/
|
|
264
|
+
/** Extract auxData channel for a mesh */
|
|
270
265
|
readPolyfaceAuxChannel(channelHeader) {
|
|
271
266
|
if (channelHeader) {
|
|
272
267
|
const dataType = channelHeader.dataType();
|
|
@@ -283,36 +278,100 @@ export class BGFBReader {
|
|
|
283
278
|
}
|
|
284
279
|
return undefined;
|
|
285
280
|
}
|
|
281
|
+
/** Compute the number of logical entries in every flat data array in the AuxData */
|
|
282
|
+
static channelDataLength(fbAuxData) {
|
|
283
|
+
if (fbAuxData.channelsLength() <= 0)
|
|
284
|
+
return 0;
|
|
285
|
+
const fbChannel0 = nullToUndefined(fbAuxData.channels(0));
|
|
286
|
+
if (!fbChannel0)
|
|
287
|
+
return 0;
|
|
288
|
+
const numChannel0Data = fbChannel0.dataLength();
|
|
289
|
+
if (numChannel0Data <= 0)
|
|
290
|
+
return 0;
|
|
291
|
+
const fbChannel0Data0 = nullToUndefined(fbChannel0.data(0));
|
|
292
|
+
if (!fbChannel0Data0)
|
|
293
|
+
return 0;
|
|
294
|
+
const numChannelDataValues = fbChannel0Data0.valuesLength();
|
|
295
|
+
if (numChannelDataValues <= 0)
|
|
296
|
+
return 0;
|
|
297
|
+
return numChannelDataValues / AuxChannel.entriesPerValue(fbChannel0.dataType());
|
|
298
|
+
}
|
|
299
|
+
/** Examine int array for range and zero count */
|
|
300
|
+
countIntArray(ints) {
|
|
301
|
+
let min = Infinity;
|
|
302
|
+
let max = -Infinity;
|
|
303
|
+
let numZeroes = 0;
|
|
304
|
+
for (const i of ints) {
|
|
305
|
+
if (min > i)
|
|
306
|
+
min = i;
|
|
307
|
+
if (max < i)
|
|
308
|
+
max = i;
|
|
309
|
+
if (0 === i)
|
|
310
|
+
++numZeroes;
|
|
311
|
+
}
|
|
312
|
+
return { min, max, numZeroes };
|
|
313
|
+
}
|
|
286
314
|
/**
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
315
|
+
* Extract auxData for a mesh.
|
|
316
|
+
* Typescript object format for Polyface/PolyfaceAuxData indices is 0-based, unterminated.
|
|
317
|
+
* FlatBuffer format for Polyface/PolyfaceAuxData indices is 1-based, 0-terminated/padded.
|
|
318
|
+
* Typescript API previously wrote FlatBuffer PolyfaceAuxData indices as 0-based, unterminated;
|
|
319
|
+
* heuristics are used herein to identify this legacy format so it can still be read.
|
|
320
|
+
*/
|
|
321
|
+
readPolyfaceAuxData(fbPolyface, fbAuxData) {
|
|
322
|
+
if (!fbPolyface || !fbAuxData)
|
|
323
|
+
return undefined;
|
|
324
|
+
const fbPointIndices = nullToUndefined(fbPolyface.pointIndexArray());
|
|
325
|
+
const fbAuxIndices = nullToUndefined(fbAuxData.indicesArray());
|
|
326
|
+
const numChannels = fbAuxData.channelsLength();
|
|
327
|
+
const fbNumData = BGFBReader.channelDataLength(fbAuxData);
|
|
328
|
+
if (!fbPointIndices || !fbPointIndices.length || !fbAuxIndices || !fbAuxIndices.length || numChannels <= 0 || fbNumData <= 0)
|
|
329
|
+
return undefined;
|
|
330
|
+
const numPerFace = fbPolyface.numPerFace();
|
|
331
|
+
// HEURISTICS to detect legacy AuxData indices, previously mistakenly serialized by BGFBWriter.writePolyfaceAsFBVariantGeometry as 0-based unblocked indices
|
|
332
|
+
let isLegacy = false;
|
|
333
|
+
const pointIndicesPadCount = fbPointIndices.filter((index) => index === 0).length;
|
|
334
|
+
if (numPerFace > 1) {
|
|
335
|
+
const auxIndexCounts = this.countIntArray(fbAuxIndices);
|
|
336
|
+
if (auxIndexCounts.max > fbNumData) // auxIndices invalid
|
|
337
|
+
return undefined;
|
|
338
|
+
if (auxIndexCounts.max === fbNumData) // auxIndices 1-based
|
|
339
|
+
isLegacy = false;
|
|
340
|
+
else if (auxIndexCounts.max <= 0 || auxIndexCounts.min < 0) // auxIndices 1-based (signed)
|
|
341
|
+
isLegacy = false;
|
|
342
|
+
else if (auxIndexCounts.min === 0) // auxIndices likely legacy 0-based index, but could be modern with padding
|
|
343
|
+
isLegacy = pointIndicesPadCount !== auxIndexCounts.numZeroes;
|
|
344
|
+
else if (auxIndexCounts.min > 0) // auxIndices likely modern without padding, but could be legacy if first datum not indexed
|
|
345
|
+
isLegacy = pointIndicesPadCount > 0;
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
isLegacy = (fbAuxIndices.length < fbPointIndices.length) && (fbAuxIndices.length + pointIndicesPadCount === fbPointIndices.length);
|
|
349
|
+
}
|
|
350
|
+
if (!isLegacy && fbAuxIndices.length !== fbPointIndices.length)
|
|
351
|
+
return undefined; // auxIndices invalid
|
|
352
|
+
const indices = [];
|
|
353
|
+
if (isLegacy)
|
|
354
|
+
SerializationHelpers.announceZeroBasedIndicesWithExternalBlocking(fbAuxIndices, fbPointIndices, numPerFace, (i0) => { indices.push(i0); });
|
|
355
|
+
else
|
|
356
|
+
SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(fbAuxIndices, numPerFace, (i0) => { indices.push(i0); });
|
|
357
|
+
if (indices.length + pointIndicesPadCount !== fbPointIndices.length)
|
|
358
|
+
return undefined;
|
|
359
|
+
const maxIndex = Math.max(...indices);
|
|
360
|
+
const channels = [];
|
|
361
|
+
for (let i = 0; i < numChannels; i++) {
|
|
362
|
+
const channelHeader = fbAuxData.channels(i);
|
|
363
|
+
const channelContent = this.readPolyfaceAuxChannel(channelHeader);
|
|
364
|
+
if (channelContent) {
|
|
365
|
+
if (maxIndex >= channelContent.valueCount)
|
|
366
|
+
return undefined; // invalid index
|
|
367
|
+
channels.push(channelContent);
|
|
307
368
|
}
|
|
308
|
-
return new PolyfaceAuxData(channels, indices);
|
|
309
369
|
}
|
|
310
|
-
|
|
370
|
+
if (!channels.length)
|
|
371
|
+
return undefined;
|
|
372
|
+
return new PolyfaceAuxData(channels, indices);
|
|
311
373
|
}
|
|
312
|
-
/**
|
|
313
|
-
* Extract auxData for a mesh
|
|
314
|
-
* @param variant read position in the flat buffer.
|
|
315
|
-
*/
|
|
374
|
+
/** Extract tagged numeric data for a mesh */
|
|
316
375
|
readTaggedNumericData(accessor) {
|
|
317
376
|
if (accessor) {
|
|
318
377
|
const taggedNumericData = new TaggedNumericData(accessor.tagA(), accessor.tagB());
|
|
@@ -333,9 +392,9 @@ export class BGFBReader {
|
|
|
333
392
|
return undefined;
|
|
334
393
|
}
|
|
335
394
|
/**
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
395
|
+
* Extract a mesh
|
|
396
|
+
* @param variant read position in the flat buffer.
|
|
397
|
+
*/
|
|
339
398
|
readPolyfaceFromVariant(variant) {
|
|
340
399
|
const geometryType = variant.geometryType();
|
|
341
400
|
if (geometryType === BGFBAccessors.VariantGeometryUnion.tagPolyface) {
|
|
@@ -354,59 +413,35 @@ export class BGFBReader {
|
|
|
354
413
|
const normalIndexI32 = nullToUndefined(polyfaceHeader.normalIndexArray());
|
|
355
414
|
const colorIndexI32 = nullToUndefined(polyfaceHeader.colorIndexArray());
|
|
356
415
|
const taggedNumericDataOffset = polyfaceHeader.taggedNumericData();
|
|
416
|
+
assert(meshStyle === 1, "Unrecognized flatbuffer mesh style");
|
|
417
|
+
// The flatbuffer data is one based.
|
|
418
|
+
// If numPerFace is less than 2, facets are variable size and zero terminated
|
|
419
|
+
// If numPerFace is 2 or more, indices are blocked
|
|
357
420
|
if (meshStyle === 1 && pointF64 && pointIndexI32) {
|
|
358
|
-
const polyface = IndexedPolyface.create(
|
|
421
|
+
const polyface = IndexedPolyface.create();
|
|
422
|
+
polyface.twoSided = twoSided;
|
|
359
423
|
polyface.expectedClosure = expectedClosure;
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
polyface.data.param.pushXY(paramF64[i], paramF64[i + 1]);
|
|
424
|
+
if (normalF64 && normalIndexI32) {
|
|
425
|
+
for (let i = 0; i + 2 < normalF64.length; i += 3)
|
|
426
|
+
polyface.addNormalXYZ(normalF64[i], normalF64[i + 1], normalF64[i + 2]);
|
|
427
|
+
SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(normalIndexI32, numPerFace, (i) => { polyface.addNormalIndex(i); });
|
|
365
428
|
}
|
|
366
|
-
if (
|
|
367
|
-
for (let i = 0; i +
|
|
368
|
-
polyface.
|
|
429
|
+
if (paramF64 && paramIndexI32) {
|
|
430
|
+
for (let i = 0; i + 1 < paramF64.length; i += 2)
|
|
431
|
+
polyface.addParamUV(paramF64[i], paramF64[i + 1]);
|
|
432
|
+
SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(paramIndexI32, numPerFace, (i) => { polyface.addParamIndex(i); });
|
|
369
433
|
}
|
|
370
|
-
if (intColorU32) {
|
|
434
|
+
if (intColorU32 && colorIndexI32) {
|
|
371
435
|
for (const c of intColorU32)
|
|
372
|
-
polyface.
|
|
373
|
-
|
|
374
|
-
// The flatbuffer data is one based.
|
|
375
|
-
// If numPerFace is less than 2, facets are variable size and zero terminated
|
|
376
|
-
// If numPerFace is 2 or more, indices are blocked
|
|
377
|
-
const numIndex = pointIndexI32.length;
|
|
378
|
-
const addIndicesInBlock = (k0, k1) => {
|
|
379
|
-
for (let k = k0; k < k1; k++) {
|
|
380
|
-
const q = pointIndexI32[k];
|
|
381
|
-
polyface.addPointIndex(Math.abs(q) - 1, q > 0);
|
|
382
|
-
if (normalF64 && normalIndexI32) {
|
|
383
|
-
polyface.addNormalIndex(Math.abs(normalIndexI32[k]) - 1);
|
|
384
|
-
}
|
|
385
|
-
if (paramF64 && paramIndexI32) {
|
|
386
|
-
polyface.addParamIndex(Math.abs(paramIndexI32[k]) - 1);
|
|
387
|
-
}
|
|
388
|
-
if (intColorU32 && colorIndexI32) {
|
|
389
|
-
polyface.addColorIndex(Math.abs(colorIndexI32[k]) - 1);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
if (numPerFace > 1) {
|
|
394
|
-
for (let i0 = 0; i0 + numPerFace <= numIndex; i0 += numPerFace) {
|
|
395
|
-
addIndicesInBlock(i0, i0 + numPerFace);
|
|
396
|
-
polyface.terminateFacet(true);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
let i0 = 0;
|
|
401
|
-
for (let i1 = i0; i1 < numIndex; i1++) {
|
|
402
|
-
if (pointIndexI32[i1] === 0) {
|
|
403
|
-
addIndicesInBlock(i0, i1);
|
|
404
|
-
polyface.terminateFacet(true);
|
|
405
|
-
i0 = i1 + 1;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
436
|
+
polyface.addColor(c);
|
|
437
|
+
SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(colorIndexI32, numPerFace, (i) => { polyface.addColorIndex(i); });
|
|
408
438
|
}
|
|
409
|
-
|
|
439
|
+
for (let i = 0; i + 2 < pointF64.length; i += 3)
|
|
440
|
+
polyface.addPointXYZ(pointF64[i], pointF64[i + 1], pointF64[i + 2]);
|
|
441
|
+
SerializationHelpers.announceZeroBasedIndicesFromSignedOneBasedIndices(pointIndexI32, numPerFace, (i, v) => { polyface.addPointIndex(i, v); }, () => { polyface.terminateFacet(false); });
|
|
442
|
+
if (!polyface.validateAllIndices())
|
|
443
|
+
return undefined;
|
|
444
|
+
polyface.data.auxData = this.readPolyfaceAuxData(polyfaceHeader, polyfaceHeader.auxData());
|
|
410
445
|
if (taggedNumericDataOffset) {
|
|
411
446
|
const taggedNumericDataAccessor = nullToUndefined(taggedNumericDataOffset);
|
|
412
447
|
if (taggedNumericDataAccessor !== undefined) {
|