Skip to content

Commit

Permalink
fix(loader): fix unnecessary copy #233 (#235)
Browse files Browse the repository at this point in the history
fix unnecessary copy
  • Loading branch information
jiangheng90 committed Jun 26, 2023
1 parent 722abe1 commit 7ad1581
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
16 changes: 4 additions & 12 deletions src/loader/parser/b3dm/B3DMLoaderBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,19 @@ export class B3DMLoaderBase {

// Feature Table
const featureTableStart = 28;
const featureTableBuffer = buffer.slice(
featureTableStart,
featureTableStart + featureTableJSONByteLength + featureTableBinaryByteLength,
);
const featureTable = new FeatureTable(
featureTableBuffer,
0,
buffer,
featureTableStart,
featureTableJSONByteLength,
featureTableBinaryByteLength,
);

// Batch Table
const batchTableStart = featureTableStart + featureTableJSONByteLength + featureTableBinaryByteLength;
const batchTableBuffer = buffer.slice(
batchTableStart,
batchTableStart + batchTableJSONByteLength + batchTableBinaryByteLength,
);
const batchTable = new BatchTable(
batchTableBuffer,
buffer,
featureTable.getData( 'BATCH_LENGTH' ),
0,
batchTableStart,
batchTableJSONByteLength,
batchTableBinaryByteLength,
);
Expand Down
16 changes: 4 additions & 12 deletions src/loader/parser/i3dm/I3DMLoaderBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,19 @@ export class I3DMLoaderBase {

// Feature Table
const featureTableStart = 32;
const featureTableBuffer = buffer.slice(
featureTableStart,
featureTableStart + featureTableJSONByteLength + featureTableBinaryByteLength,
);
const featureTable = new FeatureTable(
featureTableBuffer,
0,
buffer,
featureTableStart,
featureTableJSONByteLength,
featureTableBinaryByteLength,
);

// Batch Table
const batchTableStart = featureTableStart + featureTableJSONByteLength + featureTableBinaryByteLength;
const batchTableBuffer = buffer.slice(
batchTableStart,
batchTableStart + batchTableJSONByteLength + batchTableBinaryByteLength,
);
const batchTable = new BatchTable(
batchTableBuffer,
buffer,
featureTable.getData('INSTANCES_LENGTH'),
0,
batchTableStart,
batchTableJSONByteLength,
batchTableBinaryByteLength,
);
Expand Down

0 comments on commit 7ad1581

Please sign in to comment.