* Parse the batch table hierarchy from the * 3DTILES_batch_table_hierarchy extension. * * @param {BatchTableHierarchy} hierarchy The hierarchy instance * @param {object} hierarchyJson The JSON of the extension * @param {Uint8Array} [binaryBody] The binary body of the batch table fo
(hierarchy, hierarchyJson, binaryBody)
| 60 | * @private |
| 61 | */ |
| 62 | function initialize(hierarchy, hierarchyJson, binaryBody) { |
| 63 | let i; |
| 64 | let classId; |
| 65 | let binaryAccessor; |
| 66 | |
| 67 | const instancesLength = hierarchyJson.instancesLength; |
| 68 | const classes = hierarchyJson.classes; |
| 69 | let classIds = hierarchyJson.classIds; |
| 70 | let parentCounts = hierarchyJson.parentCounts; |
| 71 | let parentIds = hierarchyJson.parentIds; |
| 72 | let parentIdsLength = instancesLength; |
| 73 | let byteLength = 0; |
| 74 | |
| 75 | if (defined(classIds.byteOffset)) { |
| 76 | classIds.componentType = |
| 77 | classIds.componentType ?? ComponentDatatype.UNSIGNED_SHORT; |
| 78 | classIds.type = AttributeType.SCALAR; |
| 79 | binaryAccessor = getBinaryAccessor(classIds); |
| 80 | classIds = binaryAccessor.createArrayBufferView( |
| 81 | binaryBody.buffer, |
| 82 | binaryBody.byteOffset + classIds.byteOffset, |
| 83 | instancesLength, |
| 84 | ); |
| 85 | byteLength += classIds.byteLength; |
| 86 | } |
| 87 | |
| 88 | let parentIndexes; |
| 89 | if (defined(parentCounts)) { |
| 90 | if (defined(parentCounts.byteOffset)) { |
| 91 | parentCounts.componentType = |
| 92 | parentCounts.componentType ?? ComponentDatatype.UNSIGNED_SHORT; |
| 93 | parentCounts.type = AttributeType.SCALAR; |
| 94 | binaryAccessor = getBinaryAccessor(parentCounts); |
| 95 | parentCounts = binaryAccessor.createArrayBufferView( |
| 96 | binaryBody.buffer, |
| 97 | binaryBody.byteOffset + parentCounts.byteOffset, |
| 98 | instancesLength, |
| 99 | ); |
| 100 | byteLength += parentCounts.byteLength; |
| 101 | } |
| 102 | parentIndexes = new Uint16Array(instancesLength); |
| 103 | parentIdsLength = 0; |
| 104 | for (i = 0; i < instancesLength; ++i) { |
| 105 | parentIndexes[i] = parentIdsLength; |
| 106 | parentIdsLength += parentCounts[i]; |
| 107 | } |
| 108 | |
| 109 | byteLength += parentIndexes.byteLength; |
| 110 | } |
| 111 | |
| 112 | if (defined(parentIds) && defined(parentIds.byteOffset)) { |
| 113 | parentIds.componentType = |
| 114 | parentIds.componentType ?? ComponentDatatype.UNSIGNED_SHORT; |
| 115 | parentIds.type = AttributeType.SCALAR; |
| 116 | binaryAccessor = getBinaryAccessor(parentIds); |
| 117 | parentIds = binaryAccessor.createArrayBufferView( |
| 118 | binaryBody.buffer, |
| 119 | binaryBody.byteOffset + parentIds.byteOffset, |
no test coverage detected
searching dependent graphs…