@loaders.gl/tiles-3d 5.0.0-beta.10 → 5.0.0-beta.11
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/3d-tiles/3d-tiles-archive-loader.js +1 -1
- package/dist/3d-tiles/dist.dev.js +169 -581
- package/dist/3d-tiles/dist.min.js +16 -16
- package/dist/3d-tiles/index.cjs +115 -390
- package/dist/3d-tiles/index.cjs.map +3 -3
- package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.d.ts +1 -2
- package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.d.ts.map +1 -1
- package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.js +3 -4
- package/dist/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
- package/dist/3d-tiles/lib/classes/helpers/tile-component-types.d.ts +4 -0
- package/dist/3d-tiles/lib/classes/helpers/tile-component-types.d.ts.map +1 -0
- package/dist/3d-tiles/lib/classes/helpers/tile-component-types.js +36 -0
- package/dist/3d-tiles/lib/classes/helpers/tile-component-types.js.map +1 -0
- package/dist/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.d.ts.map +1 -1
- package/dist/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.js +3 -4
- package/dist/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
- package/dist/3d-tiles/lib/classes/tile-3d-batch-table.d.ts +1 -1
- package/dist/3d-tiles/lib/classes/tile-3d-feature-table.d.ts +9 -5
- package/dist/3d-tiles/lib/classes/tile-3d-feature-table.d.ts.map +1 -1
- package/dist/3d-tiles/lib/classes/tile-3d-feature-table.js +15 -12
- package/dist/3d-tiles/lib/classes/tile-3d-feature-table.js.map +1 -1
- package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.d.ts +0 -1
- package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.d.ts.map +1 -1
- package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.js +2 -4
- package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
- package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.d.ts +1 -2
- package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.d.ts.map +1 -1
- package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.js +7 -7
- package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
- package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.d.ts.map +1 -1
- package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -2
- package/dist/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-batched-model.d.ts.map +1 -1
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-batched-model.js +1 -2
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js +13 -13
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.js +22 -23
- package/dist/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/3d-tiles/lib/utils/version.js +1 -1
- package/dist/3d-tiles/types.d.ts +7 -3
- package/dist/3d-tiles/types.d.ts.map +1 -1
- package/dist/3d-tiles-archive-writer.cjs +1 -1
- package/dist/copc/copc-loader.d.ts.map +1 -1
- package/dist/copc/copc-loader.js +10 -7
- package/dist/copc/copc-loader.js.map +1 -1
- package/dist/copc/copc-writer.d.ts +5 -4
- package/dist/copc/copc-writer.d.ts.map +1 -1
- package/dist/copc/copc-writer.js +1 -1
- package/dist/copc/copc-writer.js.map +1 -1
- package/dist/copc/index.cjs +809 -124
- package/dist/copc/index.cjs.map +3 -3
- package/dist/dist.dev.js +45 -77
- package/dist/dist.min.js +10 -10
- package/dist/i3s/arcgis-webscene-loader.js +1 -1
- package/dist/i3s/dist.dev.js +11915 -12119
- package/dist/i3s/dist.min.js +25 -25
- package/dist/i3s/i3s-attribute-loader.js +1 -1
- package/dist/i3s/i3s-building-scene-layer-loader.js +1 -1
- package/dist/i3s/i3s-content-loader.js +1 -1
- package/dist/i3s/i3s-lepcc-loader-types.js +1 -1
- package/dist/i3s/i3s-loader.js +1 -1
- package/dist/i3s/i3s-mesh-attributes.d.ts +2 -2
- package/dist/i3s/i3s-mesh-attributes.d.ts.map +1 -1
- package/dist/i3s/i3s-mesh-attributes.js +6 -11
- package/dist/i3s/i3s-mesh-attributes.js.map +1 -1
- package/dist/i3s/i3s-mesh-writer.js +2 -3
- package/dist/i3s/i3s-mesh-writer.js.map +1 -1
- package/dist/i3s/i3s-node-page-loader.js +1 -1
- package/dist/i3s/i3s-slpk-loader.js +1 -1
- package/dist/i3s/i3s-slpk-writer.js +1 -1
- package/dist/i3s/index.cjs +314 -442
- package/dist/i3s/index.cjs.map +3 -3
- package/dist/i3s/lib/parsers/constants.d.ts +0 -3
- package/dist/i3s/lib/parsers/constants.d.ts.map +1 -1
- package/dist/i3s/lib/parsers/constants.js +0 -8
- package/dist/i3s/lib/parsers/constants.js.map +1 -1
- package/dist/i3s/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
- package/dist/i3s/lib/parsers/parse-i3s-tile-content.js +1 -2
- package/dist/i3s/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/i3s/types.d.ts +0 -1
- package/dist/i3s/types.d.ts.map +1 -1
- package/dist/i3s-content-worker-node.js +11 -11
- package/dist/i3s-content-worker-node.js.map +4 -4
- package/dist/i3s-content-worker.js +485 -879
- package/dist/i3s-lepcc-worker-node.js +2 -2
- package/dist/i3s-lepcc-worker.js +2 -2
- package/dist/i3s-mesh-writer.cjs +87 -206
- package/dist/i3s-mesh-writer.cjs.map +3 -3
- package/dist/i3s-slpk-writer.cjs +1 -1
- package/dist/index.cjs +44 -41
- package/dist/index.cjs.map +1 -1
- package/dist/point-cloud-tile-loader-types.js +1 -1
- package/dist/point-cloud-tile-loader.cjs +17 -28
- package/dist/point-cloud-tile-loader.cjs.map +1 -1
- package/dist/point-cloud-tile-source.cjs +16 -27
- package/dist/point-cloud-tile-source.cjs.map +1 -1
- package/dist/point-cloud-tile-source.js +2 -2
- package/dist/point-cloud-tile-source.js.map +1 -1
- package/dist/potree/dist.dev.js +985 -139
- package/dist/potree/dist.min.js +28 -28
- package/dist/potree/index.cjs +813 -140
- package/dist/potree/index.cjs.map +3 -3
- package/dist/potree/lib/potree-node-source.d.ts.map +1 -1
- package/dist/potree/lib/potree-node-source.js +2 -14
- package/dist/potree/lib/potree-node-source.js.map +1 -1
- package/dist/potree/parsers/parse-potree-bin.js +3 -3
- package/dist/potree/parsers/parse-potree-bin.js.map +1 -1
- package/dist/potree/potree-bin-loader.js +1 -1
- package/dist/potree/potree-hierarchy-chunk-loader.js +1 -1
- package/dist/potree/potree-loader-types.js +1 -1
- package/dist/potree/potree-writer.d.ts +3 -3
- package/dist/potree/potree-writer.d.ts.map +1 -1
- package/dist/potree/potree-writer.js +2 -2
- package/dist/potree/potree-writer.js.map +1 -1
- package/dist/potree/potree2-source.d.ts +1 -1
- package/dist/potree/potree2-source.d.ts.map +1 -1
- package/dist/potree/potree2-source.js +6 -3
- package/dist/potree/potree2-source.js.map +1 -1
- package/dist/potree-loader.cjs +817 -153
- package/dist/potree-loader.cjs.map +3 -3
- package/dist/tileset-3d/helpers/frame-state.d.ts +2 -1
- package/dist/tileset-3d/helpers/frame-state.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/frame-state.js +41 -15
- package/dist/tileset-3d/helpers/frame-state.js.map +1 -1
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/3d-tiles/lib/classes/helpers/tile-3d-accessor-utils.ts +3 -4
- package/src/3d-tiles/lib/classes/helpers/tile-component-types.ts +39 -0
- package/src/3d-tiles/lib/classes/tile-3d-batch-table-hierarchy.ts +3 -4
- package/src/3d-tiles/lib/classes/tile-3d-feature-table.ts +38 -14
- package/src/3d-tiles/lib/parsers/helpers/normalize-3d-tile-colors.ts +2 -5
- package/src/3d-tiles/lib/parsers/helpers/normalize-3d-tile-normals.ts +10 -10
- package/src/3d-tiles/lib/parsers/helpers/normalize-3d-tile-positions.ts +0 -2
- package/src/3d-tiles/lib/parsers/parse-3d-tile-batched-model.ts +1 -2
- package/src/3d-tiles/lib/parsers/parse-3d-tile-instanced-model.ts +19 -19
- package/src/3d-tiles/lib/parsers/parse-3d-tile-point-cloud.ts +22 -23
- package/src/3d-tiles/types.ts +4 -3
- package/src/copc/copc-loader.ts +8 -8
- package/src/copc/copc-writer.ts +6 -5
- package/src/i3s/i3s-mesh-attributes.ts +9 -17
- package/src/i3s/i3s-mesh-writer.ts +4 -3
- package/src/i3s/lib/parsers/constants.ts +0 -9
- package/src/i3s/lib/parsers/parse-i3s-tile-content.ts +1 -2
- package/src/i3s/types.ts +0 -1
- package/src/point-cloud-tile-source.ts +2 -2
- package/src/potree/lib/potree-node-source.ts +2 -15
- package/src/potree/parsers/parse-potree-bin.ts +3 -3
- package/src/potree/potree-writer.ts +6 -11
- package/src/potree/potree2-source.ts +6 -3
- package/src/tileset-3d/helpers/frame-state.ts +43 -15
- package/src/types.ts +15 -0
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import {Vector3, Matrix3, Matrix4, Quaternion} from '@math.gl/core';
|
|
9
9
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
10
10
|
import {eastNorthUpToFixedFrame} from '@math.gl/geospatial';
|
|
11
|
-
import {
|
|
11
|
+
import {octDecodeInRange} from '@math.gl/geometry';
|
|
12
12
|
import Tile3DFeatureTable from '../classes/tile-3d-feature-table';
|
|
13
13
|
import Tile3DBatchTable from '../classes/tile-3d-batch-table';
|
|
14
14
|
|
|
@@ -70,7 +70,7 @@ function parseInstancedModel(
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
tile.eastNorthUp = featureTable.getGlobalProperty('EAST_NORTH_UP');
|
|
73
|
-
tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER',
|
|
73
|
+
tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', Float32Array, 3);
|
|
74
74
|
|
|
75
75
|
const batchTable = new Tile3DBatchTable(
|
|
76
76
|
tile.batchTableJson,
|
|
@@ -111,11 +111,11 @@ function extractInstancedAttributes(
|
|
|
111
111
|
|
|
112
112
|
// Get the instance position
|
|
113
113
|
if (featureTable.hasProperty('POSITION')) {
|
|
114
|
-
position = featureTable.getProperty('POSITION',
|
|
114
|
+
position = featureTable.getProperty('POSITION', Float32Array, 3, i, instancePosition);
|
|
115
115
|
} else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
|
|
116
116
|
position = featureTable.getProperty(
|
|
117
117
|
'POSITION_QUANTIZED',
|
|
118
|
-
|
|
118
|
+
Uint16Array,
|
|
119
119
|
3,
|
|
120
120
|
i,
|
|
121
121
|
instancePosition
|
|
@@ -123,7 +123,7 @@ function extractInstancedAttributes(
|
|
|
123
123
|
|
|
124
124
|
const quantizedVolumeOffset = featureTable.getGlobalProperty(
|
|
125
125
|
'QUANTIZED_VOLUME_OFFSET',
|
|
126
|
-
|
|
126
|
+
Float32Array,
|
|
127
127
|
3
|
|
128
128
|
);
|
|
129
129
|
if (!quantizedVolumeOffset) {
|
|
@@ -134,7 +134,7 @@ function extractInstancedAttributes(
|
|
|
134
134
|
|
|
135
135
|
const quantizedVolumeScale = featureTable.getGlobalProperty(
|
|
136
136
|
'QUANTIZED_VOLUME_SCALE',
|
|
137
|
-
|
|
137
|
+
Float32Array,
|
|
138
138
|
3
|
|
139
139
|
);
|
|
140
140
|
if (!quantizedVolumeScale) {
|
|
@@ -159,8 +159,8 @@ function extractInstancedAttributes(
|
|
|
159
159
|
instanceTranslationRotationScale.translation = instancePosition;
|
|
160
160
|
|
|
161
161
|
// Get the instance rotation
|
|
162
|
-
const normalUp = featureTable.getProperty('NORMAL_UP',
|
|
163
|
-
const normalRight = featureTable.getProperty('NORMAL_RIGHT',
|
|
162
|
+
const normalUp = featureTable.getProperty('NORMAL_UP', Float32Array, 3, i, scratch1);
|
|
163
|
+
const normalRight = featureTable.getProperty('NORMAL_RIGHT', Float32Array, 3, i, scratch2);
|
|
164
164
|
tile.normalUp = normalUp;
|
|
165
165
|
tile.normalRight = normalRight;
|
|
166
166
|
|
|
@@ -174,16 +174,10 @@ function extractInstancedAttributes(
|
|
|
174
174
|
tile.hasCustomOrientation = true;
|
|
175
175
|
hasCustomOrientation = true;
|
|
176
176
|
} else {
|
|
177
|
-
const octNormalUp = featureTable.getProperty(
|
|
178
|
-
'NORMAL_UP_OCT32P',
|
|
179
|
-
GL.UNSIGNED_SHORT,
|
|
180
|
-
2,
|
|
181
|
-
i,
|
|
182
|
-
scratch1
|
|
183
|
-
);
|
|
177
|
+
const octNormalUp = featureTable.getProperty('NORMAL_UP_OCT32P', Uint16Array, 2, i, scratch1);
|
|
184
178
|
const octNormalRight = featureTable.getProperty(
|
|
185
179
|
'NORMAL_RIGHT_OCT32P',
|
|
186
|
-
|
|
180
|
+
Uint16Array,
|
|
187
181
|
2,
|
|
188
182
|
i,
|
|
189
183
|
scratch2
|
|
@@ -224,11 +218,17 @@ function extractInstancedAttributes(
|
|
|
224
218
|
|
|
225
219
|
// Get the instance scale
|
|
226
220
|
instanceScale.set(1.0, 1.0, 1.0);
|
|
227
|
-
const scale = featureTable.getProperty('SCALE',
|
|
221
|
+
const scale = featureTable.getProperty('SCALE', Float32Array, 1, i, scratch3);
|
|
228
222
|
if (Number.isFinite(scale)) {
|
|
229
223
|
instanceScale.multiplyByScalar(scale);
|
|
230
224
|
}
|
|
231
|
-
const nonUniformScale = featureTable.getProperty(
|
|
225
|
+
const nonUniformScale = featureTable.getProperty(
|
|
226
|
+
'SCALE_NON_UNIFORM',
|
|
227
|
+
Float32Array,
|
|
228
|
+
3,
|
|
229
|
+
i,
|
|
230
|
+
scratch1
|
|
231
|
+
);
|
|
232
232
|
if (nonUniformScale) {
|
|
233
233
|
instanceScale.scale(nonUniformScale);
|
|
234
234
|
}
|
|
@@ -237,7 +237,7 @@ function extractInstancedAttributes(
|
|
|
237
237
|
instanceTranslationRotationScale.scale = instanceScale;
|
|
238
238
|
|
|
239
239
|
// Get the batchId
|
|
240
|
-
let batchId = featureTable.getProperty('BATCH_ID',
|
|
240
|
+
let batchId = featureTable.getProperty('BATCH_ID', Uint16Array, 1, i, scratch4);
|
|
241
241
|
if (batchId === undefined) {
|
|
242
242
|
// If BATCH_ID semantic is undefined, batchId is just the instance number
|
|
243
243
|
batchId = i;
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
import {DracoLoader} from '@loaders.gl/scene';
|
|
9
9
|
import type {DracoMesh} from '@loaders.gl/scene';
|
|
10
10
|
import {LoaderContext, parseFromContext} from '@loaders.gl/core/loader-utils';
|
|
11
|
-
import {GL} from '@math.gl/geometry';
|
|
12
11
|
import {Vector3} from '@math.gl/core';
|
|
13
12
|
|
|
14
13
|
import Tile3DFeatureTable from '../classes/tile-3d-feature-table';
|
|
@@ -46,7 +45,7 @@ export async function parsePointCloud3DTile(
|
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
function initializeTile(tile: Tiles3DTileContent): void {
|
|
49
|
-
|
|
48
|
+
tile.topology = 'point-list';
|
|
50
49
|
tile.attributes = {
|
|
51
50
|
positions: null,
|
|
52
51
|
colors: null,
|
|
@@ -75,7 +74,7 @@ function parsePointCloudTables(tile: Tiles3DTileContent): {
|
|
|
75
74
|
tile.pointsLength = pointsLength;
|
|
76
75
|
tile.pointCount = pointsLength;
|
|
77
76
|
|
|
78
|
-
tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER',
|
|
77
|
+
tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', Float32Array, 3);
|
|
79
78
|
|
|
80
79
|
const batchTable = parseBatchIds(tile, featureTable);
|
|
81
80
|
|
|
@@ -95,16 +94,16 @@ function parsePositions(
|
|
|
95
94
|
};
|
|
96
95
|
if (!tile.attributes.positions) {
|
|
97
96
|
if (featureTable.hasProperty('POSITION')) {
|
|
98
|
-
tile.attributes.positions = featureTable.getPropertyArray('POSITION',
|
|
97
|
+
tile.attributes.positions = featureTable.getPropertyArray('POSITION', Float32Array, 3);
|
|
99
98
|
} else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
|
|
100
|
-
const positions = featureTable.getPropertyArray('POSITION_QUANTIZED',
|
|
99
|
+
const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', Uint16Array, 3);
|
|
101
100
|
|
|
102
101
|
tile.isQuantized = true;
|
|
103
102
|
tile.quantizedRange = (1 << 16) - 1;
|
|
104
103
|
|
|
105
104
|
tile.quantizedVolumeScale = featureTable.getGlobalProperty(
|
|
106
105
|
'QUANTIZED_VOLUME_SCALE',
|
|
107
|
-
|
|
106
|
+
Float32Array,
|
|
108
107
|
3
|
|
109
108
|
);
|
|
110
109
|
if (!tile.quantizedVolumeScale) {
|
|
@@ -113,7 +112,7 @@ function parsePositions(
|
|
|
113
112
|
|
|
114
113
|
tile.quantizedVolumeOffset = featureTable.getGlobalProperty(
|
|
115
114
|
'QUANTIZED_VOLUME_OFFSET',
|
|
116
|
-
|
|
115
|
+
Float32Array,
|
|
117
116
|
3
|
|
118
117
|
);
|
|
119
118
|
if (!tile.quantizedVolumeOffset) {
|
|
@@ -144,12 +143,12 @@ function parseColors(
|
|
|
144
143
|
if (!tile.attributes.colors) {
|
|
145
144
|
let colors = null;
|
|
146
145
|
if (featureTable.hasProperty('RGBA')) {
|
|
147
|
-
colors = featureTable.getPropertyArray('RGBA',
|
|
146
|
+
colors = featureTable.getPropertyArray('RGBA', Uint8Array, 4);
|
|
148
147
|
tile.isTranslucent = true;
|
|
149
148
|
} else if (featureTable.hasProperty('RGB')) {
|
|
150
|
-
colors = featureTable.getPropertyArray('RGB',
|
|
149
|
+
colors = featureTable.getPropertyArray('RGB', Uint8Array, 3);
|
|
151
150
|
} else if (featureTable.hasProperty('RGB565')) {
|
|
152
|
-
colors = featureTable.getPropertyArray('RGB565',
|
|
151
|
+
colors = featureTable.getPropertyArray('RGB565', Uint16Array, 1);
|
|
153
152
|
tile.isRGB565 = true;
|
|
154
153
|
}
|
|
155
154
|
|
|
@@ -157,7 +156,7 @@ function parseColors(
|
|
|
157
156
|
}
|
|
158
157
|
|
|
159
158
|
if (featureTable.hasProperty('CONSTANT_RGBA')) {
|
|
160
|
-
tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA',
|
|
159
|
+
tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', Uint8Array, 4);
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
162
|
|
|
@@ -171,9 +170,9 @@ function parseNormals(tile: Tiles3DTileContent, featureTable: Tile3DFeatureTable
|
|
|
171
170
|
if (!tile.attributes.normals) {
|
|
172
171
|
let normals = null;
|
|
173
172
|
if (featureTable.hasProperty('NORMAL')) {
|
|
174
|
-
normals = featureTable.getPropertyArray('NORMAL',
|
|
173
|
+
normals = featureTable.getPropertyArray('NORMAL', Float32Array, 3);
|
|
175
174
|
} else if (featureTable.hasProperty('NORMAL_OCT16P')) {
|
|
176
|
-
normals = featureTable.getPropertyArray('NORMAL_OCT16P',
|
|
175
|
+
normals = featureTable.getPropertyArray('NORMAL_OCT16P', Uint8Array, 2);
|
|
177
176
|
tile.isOctEncoded16P = true;
|
|
178
177
|
}
|
|
179
178
|
|
|
@@ -187,7 +186,7 @@ function parseBatchIds(
|
|
|
187
186
|
): Tile3DBatchTable | null {
|
|
188
187
|
let batchTable: Tile3DBatchTable | null = null;
|
|
189
188
|
if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {
|
|
190
|
-
tile.batchIds = featureTable.getPropertyArray('BATCH_ID',
|
|
189
|
+
tile.batchIds = featureTable.getPropertyArray('BATCH_ID', Uint16Array, 1);
|
|
191
190
|
|
|
192
191
|
if (tile.batchIds) {
|
|
193
192
|
const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');
|
|
@@ -351,35 +350,35 @@ export async function loadDraco(
|
|
|
351
350
|
|
|
352
351
|
if (!tile.attributes.positions) {
|
|
353
352
|
if (featureTable.hasProperty('POSITION')) {
|
|
354
|
-
tile.attributes.positions = featureTable.getPropertyArray('POSITION',
|
|
353
|
+
tile.attributes.positions = featureTable.getPropertyArray('POSITION', Float32Array, 3);
|
|
355
354
|
} else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
|
|
356
|
-
tile.attributes.positions = featureTable.getPropertyArray('POSITION_QUANTIZED',
|
|
355
|
+
tile.attributes.positions = featureTable.getPropertyArray('POSITION_QUANTIZED', Uint16Array, 3);
|
|
357
356
|
|
|
358
357
|
|
|
359
358
|
if (!tile.colors) {
|
|
360
359
|
if (featureTable.hasProperty('RGBA')) {
|
|
361
|
-
tile.colors = featureTable.getPropertyArray('RGBA',
|
|
360
|
+
tile.colors = featureTable.getPropertyArray('RGBA', Uint8Array, 4);
|
|
362
361
|
tile.isTranslucent = true;
|
|
363
362
|
} else if (featureTable.hasProperty('RGB')) {
|
|
364
|
-
tile.colors = featureTable.getPropertyArray('RGB',
|
|
363
|
+
tile.colors = featureTable.getPropertyArray('RGB', Uint8Array, 3);
|
|
365
364
|
} else if (featureTable.hasPropertry('RGB565')) {
|
|
366
|
-
tile.colors = featureTable.getPropertyArray('RGB565',
|
|
365
|
+
tile.colors = featureTable.getPropertyArray('RGB565', Uint16Array, 1);
|
|
367
366
|
tile.isRGB565 = true;
|
|
368
367
|
}
|
|
369
368
|
}
|
|
370
369
|
|
|
371
370
|
if (!tile.attributes.normals) {
|
|
372
371
|
if (featureTable.getPropertry('NORMAL')) {
|
|
373
|
-
tile.attributes.normals = featureTable.getPropertyArray('NORMAL',
|
|
372
|
+
tile.attributes.normals = featureTable.getPropertyArray('NORMAL', Float32Array, 3);
|
|
374
373
|
} else if (featureTable.getProperty('NORMAL_OCT16P')) {
|
|
375
|
-
tile.attributes.normals = featureTable.getPropertyArray('NORMAL_OCT16P',
|
|
374
|
+
tile.attributes.normals = featureTable.getPropertyArray('NORMAL_OCT16P', Uint8Array, 2);
|
|
376
375
|
tile.isOctEncoded16P = true;
|
|
377
376
|
}
|
|
378
377
|
}
|
|
379
378
|
|
|
380
379
|
if (!tile.batchIds) {
|
|
381
380
|
if (featureTable.hasProperty('BATCH_ID')) {
|
|
382
|
-
tile.batchIds = featureTable.getPropertyArray('BATCH_ID',
|
|
381
|
+
tile.batchIds = featureTable.getPropertyArray('BATCH_ID', Uint16Array, 1);
|
|
383
382
|
}
|
|
384
383
|
}
|
|
385
384
|
|
|
@@ -388,7 +387,7 @@ export async function loadDraco(
|
|
|
388
387
|
}
|
|
389
388
|
|
|
390
389
|
if (featureTable.getPropertry('CONSTANT_RGBA')) {
|
|
391
|
-
tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA',
|
|
390
|
+
tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', Uint8Array, 4);
|
|
392
391
|
}
|
|
393
392
|
|
|
394
393
|
if (tile.batchIds) {
|
package/src/3d-tiles/types.ts
CHANGED
|
@@ -360,20 +360,21 @@ export type Tiles3DTileContent = {
|
|
|
360
360
|
batchId: number;
|
|
361
361
|
}[];
|
|
362
362
|
|
|
363
|
+
/** Primitive topology of decoded point cloud tiles. */
|
|
364
|
+
topology?: 'point-list';
|
|
363
365
|
/** For Pointcloud tiles */
|
|
364
366
|
attributes?: {
|
|
365
|
-
positions: null | number[] | TypedArray;
|
|
367
|
+
positions: null | number[] | TypedArray | {value: Uint16Array; size: number; normalized: true};
|
|
366
368
|
colors:
|
|
367
369
|
| null
|
|
368
370
|
| number[]
|
|
369
371
|
| {
|
|
370
|
-
type: number;
|
|
371
372
|
value: TypedArray | number[];
|
|
372
373
|
size: number;
|
|
373
374
|
normalized: boolean;
|
|
374
375
|
componentType?: 'float16';
|
|
375
376
|
};
|
|
376
|
-
normals: null | number[] | TypedArray | {
|
|
377
|
+
normals: null | number[] | TypedArray | {size: number; value: TypedArray};
|
|
377
378
|
batchIds: null | number[] | TypedArray;
|
|
378
379
|
};
|
|
379
380
|
constantRGBA?: number[];
|
package/src/copc/copc-loader.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
makeMeshArrowTable,
|
|
11
11
|
type MeshArrowAttributes
|
|
12
12
|
} from '@loaders.gl/core/schema-utils';
|
|
13
|
-
import {
|
|
13
|
+
import {deserializeNativeArrowWorkerResult} from '@loaders.gl/core/arrow-worker-transport';
|
|
14
14
|
import type {
|
|
15
15
|
CoreAPI,
|
|
16
16
|
SourceLoader,
|
|
@@ -499,7 +499,7 @@ export class COPCTileSource
|
|
|
499
499
|
const columns = Object.fromEntries(
|
|
500
500
|
columnNames.map(columnName => [columnName, [] as unknown[]])
|
|
501
501
|
);
|
|
502
|
-
const positionVector = content.data.
|
|
502
|
+
const positionVector = content.data.getChild('POSITION');
|
|
503
503
|
for (let pointIndex = 0; pointIndex < content.pointCount; pointIndex++) {
|
|
504
504
|
const offsetPosition = readArrowListValue(positionVector?.get(pointIndex));
|
|
505
505
|
const projectedPosition = [
|
|
@@ -1123,7 +1123,9 @@ export class COPCTileSource
|
|
|
1123
1123
|
undefined,
|
|
1124
1124
|
signal
|
|
1125
1125
|
);
|
|
1126
|
-
const
|
|
1126
|
+
const nativeTable = deserializeNativeArrowWorkerResult((result as {columns: unknown}).columns);
|
|
1127
|
+
if (!('batches' in nativeTable)) throw new Error('COPC LAS worker must return an Arrow table');
|
|
1128
|
+
const mesh = convertTableToMesh(nativeTable);
|
|
1127
1129
|
const nativePositions = mesh.attributes.POSITION?.value;
|
|
1128
1130
|
const colors = mesh.attributes.COLOR_0?.value || null;
|
|
1129
1131
|
if (
|
|
@@ -1355,7 +1357,7 @@ export class COPCTileSource
|
|
|
1355
1357
|
attributes[attribute.name] = {value: attribute.value, size: attribute.size};
|
|
1356
1358
|
}
|
|
1357
1359
|
|
|
1358
|
-
return makeMeshArrowTable(attributes, {topology: 'point-list'
|
|
1360
|
+
return makeMeshArrowTable(attributes, {topology: 'point-list'});
|
|
1359
1361
|
}
|
|
1360
1362
|
|
|
1361
1363
|
protected async ensureHierarchyLoaded(tileId: string): Promise<void> {
|
|
@@ -1712,13 +1714,11 @@ function getCOPCScanValue(
|
|
|
1712
1714
|
if (columnName === 'Z') return sourcePosition[2];
|
|
1713
1715
|
|
|
1714
1716
|
if (columnName === 'Red' || columnName === 'Green' || columnName === 'Blue') {
|
|
1715
|
-
const color = readArrowListValue(data.
|
|
1717
|
+
const color = readArrowListValue(data.getChild('COLOR_0')?.get(pointIndex));
|
|
1716
1718
|
return color[columnName === 'Red' ? 0 : columnName === 'Green' ? 1 : 2];
|
|
1717
1719
|
}
|
|
1718
1720
|
const decoderColumn = COPC_SCAN_COLUMN_MAP[columnName];
|
|
1719
|
-
const value = normalizeArrowValue(
|
|
1720
|
-
data.data.getChild(decoderColumn || columnName)?.get(pointIndex)
|
|
1721
|
-
);
|
|
1721
|
+
const value = normalizeArrowValue(data.getChild(decoderColumn || columnName)?.get(pointIndex));
|
|
1722
1722
|
if (COPC_BOOLEAN_COLUMN_NAMES.has(columnName) && typeof value === 'number') {
|
|
1723
1723
|
return value !== 0;
|
|
1724
1724
|
}
|
package/src/copc/copc-writer.ts
CHANGED
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
type WriterWithEncoder
|
|
12
12
|
} from '@loaders.gl/core/loader-utils';
|
|
13
13
|
import {LASWriter, type LASExtraBytesWriter} from '@loaders.gl/pointclouds/las';
|
|
14
|
-
import type {Mesh
|
|
14
|
+
import type {Mesh} from '@loaders.gl/core/schema';
|
|
15
|
+
import type {Table} from 'apache-arrow';
|
|
15
16
|
import type {WKTCRSDefinition} from '@math.gl/geospatial/crs';
|
|
16
17
|
import {COPCFormat} from './copc-format';
|
|
17
18
|
|
|
@@ -57,7 +58,7 @@ export type COPCWriterOptions = WriterOptions & {
|
|
|
57
58
|
/** Writer metadata for COPC point cloud output. */
|
|
58
59
|
export const COPCWriter = {
|
|
59
60
|
...COPCFormat,
|
|
60
|
-
dataType: null as unknown as Mesh |
|
|
61
|
+
dataType: null as unknown as Mesh | Table,
|
|
61
62
|
batchType: null as never,
|
|
62
63
|
version: VERSION,
|
|
63
64
|
extensions: ['copc.laz', 'laz'],
|
|
@@ -66,10 +67,10 @@ export const COPCWriter = {
|
|
|
66
67
|
},
|
|
67
68
|
encode: async (data, options) => encodeCOPCSync(data, options),
|
|
68
69
|
encodeSync: encodeCOPCSync
|
|
69
|
-
} as const satisfies WriterWithEncoder<Mesh |
|
|
70
|
+
} as const satisfies WriterWithEncoder<Mesh | Table, never, COPCWriterOptions>;
|
|
70
71
|
|
|
71
72
|
/** Encode a mesh or Arrow table as COPC. */
|
|
72
|
-
function encodeCOPCSync(data: Mesh |
|
|
73
|
+
function encodeCOPCSync(data: Mesh | Table, options: COPCWriterOptions = {}): ArrayBuffer {
|
|
73
74
|
const nodePointLimit = options.copc?.nodePointLimit ?? DEFAULT_NODE_POINT_LIMIT;
|
|
74
75
|
const maximumDepth = options.copc?.maximumDepth ?? DEFAULT_MAXIMUM_DEPTH;
|
|
75
76
|
const hierarchyPageDepth = options.copc?.hierarchyPageDepth ?? DEFAULT_HIERARCHY_PAGE_DEPTH;
|
|
@@ -240,7 +241,7 @@ type OctreeContext = {
|
|
|
240
241
|
};
|
|
241
242
|
|
|
242
243
|
/** Encode input data once as uncompressed LAS 1.4 point records. */
|
|
243
|
-
function encodeRawLAS(data: Mesh |
|
|
244
|
+
function encodeRawLAS(data: Mesh | Table, options: COPCWriterOptions): RawLASData {
|
|
244
245
|
const arrayBuffer = LASWriter.encodeSync(data, {
|
|
245
246
|
las: {
|
|
246
247
|
version: '1.4',
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {convertArrowToSchema} from '@loaders.gl/core/schema-utils';
|
|
6
|
-
import type {
|
|
6
|
+
import type {Field} from '@loaders.gl/core/schema';
|
|
7
|
+
import type {RecordBatch} from 'apache-arrow';
|
|
7
8
|
|
|
8
9
|
/** One feature table with an explicit triangle-to-row association. */
|
|
9
10
|
export interface I3SMeshFeatures {
|
|
10
11
|
/** Explicit-schema Arrow batches for a single metadata class, in row order. */
|
|
11
|
-
readonly batches: readonly
|
|
12
|
+
readonly batches: readonly RecordBatch[];
|
|
12
13
|
/** One zero-based table row per triangle, in the original index/vertex order. */
|
|
13
14
|
readonly triangleFeatureIndices: Uint32Array;
|
|
14
15
|
/** Non-null stable identifier column; geometry uses separate local OIDs. */
|
|
@@ -37,8 +38,8 @@ export function encodeI3SMeshAttributes(
|
|
|
37
38
|
maxResourceBytes: number
|
|
38
39
|
): EncodedI3SMeshAttributes {
|
|
39
40
|
const batches = features?.batches || [];
|
|
40
|
-
const schema = batches[0]?.schema;
|
|
41
|
-
const count = batches.reduce((total, batch) => total + batch.
|
|
41
|
+
const schema = batches[0]?.schema && convertArrowToSchema(batches[0].schema);
|
|
42
|
+
const count = batches.reduce((total, batch) => total + batch.numRows, 0);
|
|
42
43
|
if (features && (!schema || count === 0 || !schema.fields.length)) {
|
|
43
44
|
throw new Error('I3S features require nonempty explicit-schema Arrow batches');
|
|
44
45
|
}
|
|
@@ -67,19 +68,10 @@ export function encodeI3SMeshAttributes(
|
|
|
67
68
|
}
|
|
68
69
|
const identifiers = new Set<string | number | bigint>();
|
|
69
70
|
for (const batch of batches) {
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
batch.length !== batch.data.numRows
|
|
73
|
-
) {
|
|
74
|
-
throw new Error('I3S feature batches must share an explicit schema and correct row counts');
|
|
71
|
+
if (JSON.stringify(convertArrowToSchema(batch.schema)) !== JSON.stringify(schema)) {
|
|
72
|
+
throw new Error('I3S feature batches must share an explicit schema');
|
|
75
73
|
}
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
JSON.stringify(actualFields.map(field => [field.name, field.type])) !==
|
|
79
|
-
JSON.stringify(schema.fields.map(field => [field.name, field.type]))
|
|
80
|
-
)
|
|
81
|
-
throw new Error('I3S declared feature schema must match the Arrow column types');
|
|
82
|
-
const column = batch.data.getChild(features.featureIdField);
|
|
74
|
+
const column = batch.getChild(features.featureIdField);
|
|
83
75
|
if (!column) throw new Error('Missing Arrow feature identifier column');
|
|
84
76
|
for (let index = 0; index < column.length; index++) {
|
|
85
77
|
const identifier = column.get(index);
|
|
@@ -101,7 +93,7 @@ export function encodeI3SMeshAttributes(
|
|
|
101
93
|
throw new Error('I3S fields require unique identifiers other than reserved OBJECTID');
|
|
102
94
|
}
|
|
103
95
|
const values = batches.flatMap(batch => {
|
|
104
|
-
const column = batch.
|
|
96
|
+
const column = batch.getChild(field.name);
|
|
105
97
|
if (!column) throw new Error(`Missing Arrow column ${field.name}`);
|
|
106
98
|
return Array.from({length: column.length}, (_, index) => column.get(index));
|
|
107
99
|
});
|
|
@@ -452,13 +452,14 @@ function prepareMeshLayer(
|
|
|
452
452
|
}
|
|
453
453
|
};
|
|
454
454
|
const material = encodeMaterial(options.material);
|
|
455
|
+
const featureClass = options.features?.batches[0]?.schema.metadata.get(
|
|
456
|
+
'loaders.gl:feature-class'
|
|
457
|
+
);
|
|
455
458
|
const layer = {
|
|
456
459
|
id: 0,
|
|
457
460
|
version: '1',
|
|
458
461
|
name: options.name || 'Converted mesh',
|
|
459
|
-
description:
|
|
460
|
-
? `Source feature metadata class: ${options.features.batches[0].schema!.metadata!['loaders.gl:feature-class']}`
|
|
461
|
-
: undefined,
|
|
462
|
+
description: featureClass ? `Source feature metadata class: ${featureClass}` : undefined,
|
|
462
463
|
layerType: '3DObject',
|
|
463
464
|
spatialReference: {wkid: 4326},
|
|
464
465
|
heightModelInfo: {heightModel: 'ellipsoidal', heightUnit: 'meter'},
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {GL} from '@math.gl/geometry';
|
|
6
|
-
|
|
7
5
|
export function getConstructorForDataFormat(dataType: string) {
|
|
8
6
|
switch (dataType) {
|
|
9
7
|
case 'UInt8':
|
|
@@ -21,13 +19,6 @@ export function getConstructorForDataFormat(dataType: string) {
|
|
|
21
19
|
}
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
export const GL_TYPE_MAP: {[key: string]: number} = {
|
|
25
|
-
UInt8: GL.UNSIGNED_BYTE,
|
|
26
|
-
UInt16: GL.UNSIGNED_SHORT,
|
|
27
|
-
Float32: GL.FLOAT,
|
|
28
|
-
UInt32: GL.UNSIGNED_INT,
|
|
29
|
-
UInt64: GL.DOUBLE
|
|
30
|
-
};
|
|
31
22
|
/**
|
|
32
23
|
* Returns how many bytes a type occupies
|
|
33
24
|
* @param dataType
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
} from '../../types';
|
|
30
30
|
import {getUrlWithSearchParams, getUrlWithToken} from '../utils/url-utils';
|
|
31
31
|
|
|
32
|
-
import {
|
|
32
|
+
import {getConstructorForDataFormat, sizeOf, COORDINATE_SYSTEM} from './constants';
|
|
33
33
|
import {I3SLoaderOptions} from '../../i3s-loader';
|
|
34
34
|
|
|
35
35
|
const scratchVector = new Vector3([0, 0, 0]);
|
|
@@ -717,7 +717,6 @@ function normalizeAttributes(
|
|
|
717
717
|
|
|
718
718
|
attributes[attribute] = {
|
|
719
719
|
value,
|
|
720
|
-
type: GL_TYPE_MAP[valueType],
|
|
721
720
|
size: valuesPerElement
|
|
722
721
|
};
|
|
723
722
|
|
package/src/i3s/types.ts
CHANGED
|
@@ -1036,7 +1036,6 @@ export type I3SMeshAttributes = {
|
|
|
1036
1036
|
[key: string]: I3SMeshAttribute;
|
|
1037
1037
|
};
|
|
1038
1038
|
export interface I3SMeshAttribute extends MeshAttribute {
|
|
1039
|
-
type?: number;
|
|
1040
1039
|
metadata?: any;
|
|
1041
1040
|
}
|
|
1042
1041
|
/** https://github.com/Esri/i3s-spec/blob/master/docs/1.8/heightModelInfo.cmn.md */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import {DataSource, type CoreAPI} from '@loaders.gl/core/loader-utils';
|
|
6
6
|
import {
|
|
7
7
|
PointCloudTiler,
|
|
8
|
-
|
|
8
|
+
convertMeshToArrowTable,
|
|
9
9
|
type PointCloudTilerNode
|
|
10
10
|
} from '@loaders.gl/core/schema-utils';
|
|
11
11
|
import type {
|
|
@@ -75,7 +75,7 @@ export class PointCloudTileSource
|
|
|
75
75
|
const mesh = await this.tiler.getTileMesh(tile.id);
|
|
76
76
|
if (!mesh.header!.vertexCount) return null;
|
|
77
77
|
return {
|
|
78
|
-
data:
|
|
78
|
+
data: convertMeshToArrowTable(mesh),
|
|
79
79
|
pointCount: mesh.header!.vertexCount,
|
|
80
80
|
cartographicOrigin: [0, 0, 0],
|
|
81
81
|
coordinateSystem: 'cartesian',
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from '@loaders.gl/core/loader-utils';
|
|
28
28
|
import {LASLoader} from '@loaders.gl/pointclouds/las';
|
|
29
29
|
import type {DataType, Field, Mesh, MeshArrowTable, Schema} from '@loaders.gl/core/schema';
|
|
30
|
-
import {ArrowTableBuilder,
|
|
30
|
+
import {ArrowTableBuilder, makeMeshArrowTable} from '@loaders.gl/core/schema-utils';
|
|
31
31
|
import {PotreeBoundingBox, PotreeMetadata} from '../types/potree-metadata';
|
|
32
32
|
import {
|
|
33
33
|
POTreeNode,
|
|
@@ -1069,20 +1069,7 @@ export class PotreeNodesSource
|
|
|
1069
1069
|
attributes.NORMAL = mesh.attributes.normals;
|
|
1070
1070
|
}
|
|
1071
1071
|
|
|
1072
|
-
return
|
|
1073
|
-
topology: 'point-list',
|
|
1074
|
-
mode: 0,
|
|
1075
|
-
header: {
|
|
1076
|
-
vertexCount:
|
|
1077
|
-
mesh.header?.vertexCount ||
|
|
1078
|
-
mesh.attributes.positions.value.length / mesh.attributes.positions.size
|
|
1079
|
-
},
|
|
1080
|
-
schema: {
|
|
1081
|
-
fields: [],
|
|
1082
|
-
metadata: {}
|
|
1083
|
-
},
|
|
1084
|
-
attributes
|
|
1085
|
-
});
|
|
1072
|
+
return makeMeshArrowTable(attributes, {topology: 'point-list'});
|
|
1086
1073
|
}
|
|
1087
1074
|
|
|
1088
1075
|
/**
|
|
@@ -6,7 +6,7 @@ import type {LoaderOptions} from '@loaders.gl/core/loader-utils';
|
|
|
6
6
|
import type {Table} from 'apache-arrow';
|
|
7
7
|
import type {Mesh, MeshAttributes} from '@loaders.gl/core/schema';
|
|
8
8
|
import {convertColorArrayToFloat16, convertColorArrayToFloat32} from '@loaders.gl/core/schema';
|
|
9
|
-
import {
|
|
9
|
+
import {convertMeshToArrowTable, convertTableToMesh} from '@loaders.gl/core/schema-utils';
|
|
10
10
|
import {parseVersion} from '../utils/parse-version';
|
|
11
11
|
import type {PotreeAttribute} from '../types/potree-metadata';
|
|
12
12
|
|
|
@@ -228,9 +228,9 @@ export function parsePotreeBin(
|
|
|
228
228
|
};
|
|
229
229
|
|
|
230
230
|
const formattedMesh = formatPotreeMeshColors(mesh, resolvedOptions.colorFormat);
|
|
231
|
-
const table =
|
|
231
|
+
const table = convertMeshToArrowTable(formattedMesh);
|
|
232
232
|
if (options?.potree?.shape === 'arrow') {
|
|
233
|
-
return table
|
|
233
|
+
return table;
|
|
234
234
|
}
|
|
235
235
|
return {
|
|
236
236
|
...convertTableToMesh(table),
|
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
Mesh,
|
|
7
|
-
MeshArrowTable,
|
|
8
|
-
MeshArrowTableData,
|
|
9
|
-
MeshAttribute
|
|
10
|
-
} from '@loaders.gl/core/schema';
|
|
5
|
+
import type {Mesh, MeshArrowTable, MeshAttribute} from '@loaders.gl/core/schema';
|
|
11
6
|
import {convertTableToMesh} from '@loaders.gl/core/schema-utils';
|
|
12
7
|
import type {WriterOptions, WriterWithEncoder} from '@loaders.gl/core/loader-utils';
|
|
13
8
|
import type {PotreeAttribute, PotreeMetadata} from './types/potree-metadata';
|
|
@@ -18,7 +13,7 @@ export type PotreeWriterNode = {
|
|
|
18
13
|
/** Root r followed by XYZ octant digits 4/2/1. */
|
|
19
14
|
readonly id: string;
|
|
20
15
|
/** Decoded rows belonging exclusively to this node. */
|
|
21
|
-
readonly mesh: Mesh | MeshArrowTable
|
|
16
|
+
readonly mesh: Mesh | MeshArrowTable;
|
|
22
17
|
};
|
|
23
18
|
|
|
24
19
|
/** Complete typed file collection; applications own storage or archive packaging. */
|
|
@@ -108,9 +103,9 @@ const WIRE_TYPES: [Potree2AttributeType, new (length: number) => WireArray, numb
|
|
|
108
103
|
];
|
|
109
104
|
|
|
110
105
|
/** Validates decoded rows and layouts before writing any point bytes. */
|
|
111
|
-
function getMesh(input: Mesh | MeshArrowTable
|
|
106
|
+
function getMesh(input: Mesh | MeshArrowTable): Mesh {
|
|
112
107
|
if (!('attributes' in input)) {
|
|
113
|
-
const table =
|
|
108
|
+
const table = input;
|
|
114
109
|
/** Rejects null rows and components before Arrow conversion can replace them. */
|
|
115
110
|
type NullableColumn = {nullCount: number; children: readonly NullableColumn[]};
|
|
116
111
|
const checkNulls = (data: NullableColumn): void => {
|
|
@@ -446,7 +441,7 @@ function getDirectory(id: string, step: number): string {
|
|
|
446
441
|
* Version 2.0 output uses DEFAULT encoding; readers also accept upstream BROTLI data.
|
|
447
442
|
*/
|
|
448
443
|
export async function encodePotreeDataset(
|
|
449
|
-
input: Mesh | MeshArrowTable |
|
|
444
|
+
input: Mesh | MeshArrowTable | readonly PotreeWriterNode[],
|
|
450
445
|
options: PotreeWriterOptions = {}
|
|
451
446
|
): Promise<PotreeDataset> {
|
|
452
447
|
const settings = options.potree || {};
|
|
@@ -477,7 +472,7 @@ export async function encodePotreeDataset(
|
|
|
477
472
|
settings.signal?.throwIfAborted();
|
|
478
473
|
const supplied = Array.isArray(input)
|
|
479
474
|
? (input as readonly PotreeWriterNode[])
|
|
480
|
-
: [{id: 'r', mesh: input as Mesh | MeshArrowTable
|
|
475
|
+
: [{id: 'r', mesh: input as Mesh | MeshArrowTable}];
|
|
481
476
|
if (!supplied.length || supplied.length > maxNodes)
|
|
482
477
|
throw new Error('Potree writer node budget exceeded');
|
|
483
478
|
const nodes = supplied
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {DataSource, readRangeResponse, type CoreAPI} from '@loaders.gl/core/loader-utils';
|
|
6
|
-
import {
|
|
6
|
+
import {makeMeshArrowTable} from '@loaders.gl/core/schema-utils';
|
|
7
7
|
import type {PotreeLoaderOptions} from './potree-source-options';
|
|
8
8
|
import type {Potree2HierarchyNode, Potree2Metadata} from './potree2-types';
|
|
9
9
|
import {
|
|
@@ -152,9 +152,12 @@ export class Potree2Source extends DataSource<string, PotreeLoaderOptions> {
|
|
|
152
152
|
);
|
|
153
153
|
this.signal.throwIfAborted();
|
|
154
154
|
const header = this.createHeader(node);
|
|
155
|
-
mesh.header!.boundingBox = header.boundingVolume.cartographicBounds;
|
|
156
155
|
return {
|
|
157
|
-
data:
|
|
156
|
+
data: makeMeshArrowTable(mesh.attributes, {
|
|
157
|
+
schema: mesh.schema,
|
|
158
|
+
topology: mesh.topology,
|
|
159
|
+
boundingBox: header.boundingVolume.cartographicBounds
|
|
160
|
+
}),
|
|
158
161
|
pointCount: node.pointCount,
|
|
159
162
|
coordinateSystem: 'cartesian' as const,
|
|
160
163
|
cartographicOrigin: [0, 0, 0],
|