itowns 2.44.3-next.32 → 2.44.3-next.33
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.
|
@@ -33,20 +33,24 @@ export function newTileGeometry(builder, params) {
|
|
|
33
33
|
// Read previously cached values (index and uv.wgs84 only
|
|
34
34
|
// depend on the # of triangles)
|
|
35
35
|
let cachedBuffers = cacheBuffer.get(bufferKey);
|
|
36
|
-
params.buildIndexAndUv_0 = !cachedBuffers;
|
|
37
36
|
let buffers;
|
|
38
37
|
try {
|
|
39
|
-
buffers = computeBuffers(builder, params
|
|
38
|
+
buffers = computeBuffers(builder, params, cachedBuffers !== undefined ? {
|
|
39
|
+
index: cachedBuffers.index.array,
|
|
40
|
+
uv: cachedBuffers.uv.array
|
|
41
|
+
} : undefined);
|
|
40
42
|
} catch (e) {
|
|
41
43
|
return Promise.reject(e);
|
|
42
44
|
}
|
|
43
45
|
if (!cachedBuffers) {
|
|
44
|
-
cachedBuffers = {};
|
|
45
46
|
// We know the fields will exist due to the condition
|
|
46
47
|
// matching with the one for buildIndexAndUv_0.
|
|
47
48
|
// TODO: Make this brain-based check compiler-based.
|
|
48
|
-
|
|
49
|
-
cachedBuffers
|
|
49
|
+
|
|
50
|
+
cachedBuffers = {
|
|
51
|
+
index: new THREE.BufferAttribute(buffers.index, 1),
|
|
52
|
+
uv: new THREE.BufferAttribute(buffers.uvs[0], 2)
|
|
53
|
+
};
|
|
50
54
|
|
|
51
55
|
// Update cacheBuffer
|
|
52
56
|
cacheBuffer.set(bufferKey, cachedBuffers);
|
|
@@ -16,14 +16,17 @@ function getUintArrayConstructor(highestValue) {
|
|
|
16
16
|
}
|
|
17
17
|
return picked;
|
|
18
18
|
}
|
|
19
|
-
function allocateIndexBuffer(nVertex, nSeg, params) {
|
|
20
|
-
if (!params.buildIndexAndUv_0) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
19
|
+
function allocateIndexBuffer(nVertex, nSeg, params, cache) {
|
|
23
20
|
const indexBufferSize = getBufferIndexSize(nSeg, params.disableSkirt);
|
|
24
21
|
const indexConstructor = getUintArrayConstructor(nVertex);
|
|
25
22
|
const tileLen = indexBufferSize;
|
|
26
23
|
const skirtLen = 4 * nSeg;
|
|
24
|
+
if (cache !== undefined) {
|
|
25
|
+
return {
|
|
26
|
+
index: cache,
|
|
27
|
+
skirt: cache.subarray(tileLen, tileLen + skirtLen)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
27
30
|
const indexBuffer = new ArrayBuffer((
|
|
28
31
|
// Tile
|
|
29
32
|
tileLen
|
|
@@ -36,11 +39,11 @@ function allocateIndexBuffer(nVertex, nSeg, params) {
|
|
|
36
39
|
skirt
|
|
37
40
|
};
|
|
38
41
|
}
|
|
39
|
-
function allocateBuffers(nVertex, nSeg, builder, params) {
|
|
42
|
+
function allocateBuffers(nVertex, nSeg, builder, params, cache) {
|
|
40
43
|
const {
|
|
41
44
|
index,
|
|
42
45
|
skirt
|
|
43
|
-
} = allocateIndexBuffer(nVertex, nSeg, params)
|
|
46
|
+
} = allocateIndexBuffer(nVertex, nSeg, params, cache?.index);
|
|
44
47
|
return {
|
|
45
48
|
index,
|
|
46
49
|
skirt,
|
|
@@ -62,7 +65,7 @@ function allocateBuffers(nVertex, nSeg, builder, params) {
|
|
|
62
65
|
// +-------------------------+
|
|
63
66
|
// * u = wgs84.u
|
|
64
67
|
// * v = textureid + v in builder texture
|
|
65
|
-
uvs: [
|
|
68
|
+
uvs: [cache?.uv ?? new Float32Array(nVertex * 2), builder.computeExtraOffset !== undefined ? new Float32Array(nVertex) : undefined]
|
|
66
69
|
};
|
|
67
70
|
}
|
|
68
71
|
function computeUv0(uv, id, u, v) {
|
|
@@ -76,7 +79,7 @@ function initComputeUv1(value) {
|
|
|
76
79
|
}
|
|
77
80
|
/** Compute buffers describing a tile according to a builder and its params. */
|
|
78
81
|
// TODO: Split this even further into subfunctions
|
|
79
|
-
export function computeBuffers(builder, params) {
|
|
82
|
+
export function computeBuffers(builder, params, cache) {
|
|
80
83
|
// n seg, n+1 vert + <- skirt, n verts per side
|
|
81
84
|
// <---------------> / |
|
|
82
85
|
// +---+---+---+---+ |
|
|
@@ -98,8 +101,8 @@ export function computeBuffers(builder, params) {
|
|
|
98
101
|
if (nTotalVertex > 2 ** 32) {
|
|
99
102
|
throw new Error('Tile segments count is too big');
|
|
100
103
|
}
|
|
101
|
-
const outBuffers = allocateBuffers(nTotalVertex, nSeg, builder, params);
|
|
102
|
-
const computeUvs = [
|
|
104
|
+
const outBuffers = allocateBuffers(nTotalVertex, nSeg, builder, params, cache);
|
|
105
|
+
const computeUvs = [cache === undefined ? computeUv0 : () => {}];
|
|
103
106
|
params = builder.prepare(params);
|
|
104
107
|
for (let y = 0; y <= nSeg; y++) {
|
|
105
108
|
const v = y / nSeg;
|
|
@@ -135,7 +138,7 @@ export function computeBuffers(builder, params) {
|
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
// Fill skirt index buffer
|
|
138
|
-
if (
|
|
141
|
+
if (cache === undefined && !params.disableSkirt) {
|
|
139
142
|
for (let x = 0; x < nVertex; x++) {
|
|
140
143
|
// -------->
|
|
141
144
|
// 0---1---2
|
|
@@ -174,7 +177,7 @@ export function computeBuffers(builder, params) {
|
|
|
174
177
|
outBuffers.index[id + 1] = vb;
|
|
175
178
|
outBuffers.index[id + 2] = vc;
|
|
176
179
|
}
|
|
177
|
-
if (
|
|
180
|
+
if (cache === undefined) {
|
|
178
181
|
for (let y = 0; y < nSeg; y++) {
|
|
179
182
|
for (let x = 0; x < nSeg; x++) {
|
|
180
183
|
const v1 = y * nVertex + (x + 1);
|
|
@@ -192,11 +195,11 @@ export function computeBuffers(builder, params) {
|
|
|
192
195
|
// INFO: The size of the skirt is now a ratio of the size of the tile.
|
|
193
196
|
// To be perfect it should depend on the real elevation delta but too heavy
|
|
194
197
|
// to compute
|
|
195
|
-
if (
|
|
198
|
+
if (!params.disableSkirt) {
|
|
196
199
|
// We compute the actual size of tile segment to use later for
|
|
197
200
|
// the skirt.
|
|
198
201
|
const segmentSize = new THREE.Vector3().fromArray(outBuffers.position).distanceTo(new THREE.Vector3().fromArray(outBuffers.position, 3));
|
|
199
|
-
const buildSkirt = {
|
|
202
|
+
const buildSkirt = cache === undefined ? {
|
|
200
203
|
index: (id, v1, v2, v3, v4) => {
|
|
201
204
|
bufferizeTri(id, v1, v2, v3);
|
|
202
205
|
bufferizeTri(id + 3, v1, v3, v4);
|
|
@@ -206,6 +209,9 @@ export function computeBuffers(builder, params) {
|
|
|
206
209
|
buf[idTo * 2 + 0] = buf[idFrom * 2 + 0];
|
|
207
210
|
buf[idTo * 2 + 1] = buf[idFrom * 2 + 1];
|
|
208
211
|
}
|
|
212
|
+
} : {
|
|
213
|
+
index: () => {},
|
|
214
|
+
uv: () => {}
|
|
209
215
|
};
|
|
210
216
|
|
|
211
217
|
// Alias for readability
|
|
@@ -141,24 +141,39 @@ class OGC3DTilesLayer extends GeometryLayer {
|
|
|
141
141
|
* @param {String} id - unique layer id.
|
|
142
142
|
* @param {Object} config - layer specific configuration
|
|
143
143
|
* @param {OGC3DTilesSource} config.source - data source configuration
|
|
144
|
-
* @param {String} [config.pntsMode= PNTS_MODE.COLOR] Point cloud coloring mode (passed to {@link PointsMaterial}).
|
|
144
|
+
* @param {String} [config.pntsMode = PNTS_MODE.COLOR] Point cloud coloring mode (passed to {@link PointsMaterial}).
|
|
145
145
|
* Only 'COLOR' or 'CLASSIFICATION' are possible. COLOR uses RGB colors of the points,
|
|
146
146
|
* CLASSIFICATION uses a classification property of the batch table to color points.
|
|
147
|
-
* @param {ClassificationScheme} [config.classificationScheme] {@link PointsMaterial} classification scheme
|
|
148
|
-
* @param {String} [config.pntsShape= PNTS_SHAPE.CIRCLE] Point cloud point shape. Only 'CIRCLE' or 'SQUARE' are possible.
|
|
147
|
+
* @param {ClassificationScheme} [config.classificationScheme = ClassificationScheme.DEFAULT] {@link PointsMaterial} classification scheme
|
|
148
|
+
* @param {String} [config.pntsShape = PNTS_SHAPE.CIRCLE] Point cloud point shape. Only 'CIRCLE' or 'SQUARE' are possible.
|
|
149
149
|
* (passed to {@link PointsMaterial}).
|
|
150
|
-
* @param {String} [config.pntsSizeMode= PNTS_SIZE_MODE.VALUE] {@link PointsMaterial} Point cloud size mode (passed to {@link PointsMaterial}).
|
|
150
|
+
* @param {String} [config.pntsSizeMode = PNTS_SIZE_MODE.VALUE] {@link PointsMaterial} Point cloud size mode (passed to {@link PointsMaterial}).
|
|
151
151
|
* Only 'VALUE' or 'ATTENUATED' are possible. VALUE use constant size, ATTENUATED compute size depending on distance
|
|
152
152
|
* from point to camera.
|
|
153
|
-
* @param {Number} [config.pntsMinAttenuatedSize=3] Minimum scale used by 'ATTENUATED' size mode.
|
|
154
|
-
* @param {Number} [config.pntsMaxAttenuatedSize=10] Maximum scale used by 'ATTENUATED' size mode.
|
|
153
|
+
* @param {Number} [config.pntsMinAttenuatedSize = 3] Minimum scale used by 'ATTENUATED' size mode.
|
|
154
|
+
* @param {Number} [config.pntsMaxAttenuatedSize = 10] Maximum scale used by 'ATTENUATED' size mode.
|
|
155
155
|
*/
|
|
156
156
|
constructor(id, config) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
const {
|
|
158
|
+
pntsMode = PNTS_MODE.COLOR,
|
|
159
|
+
pntsShape = PNTS_SHAPE.CIRCLE,
|
|
160
|
+
classification = ClassificationScheme.DEFAULT,
|
|
161
|
+
pntsSizeMode = PNTS_SIZE_MODE.VALUE,
|
|
162
|
+
pntsMinAttenuatedSize = 3,
|
|
163
|
+
pntsMaxAttenuatedSize = 10,
|
|
164
|
+
...geometryLayerConfig
|
|
165
|
+
} = config;
|
|
166
|
+
super(id, new THREE.Group(), geometryLayerConfig);
|
|
160
167
|
this.isOGC3DTilesLayer = true;
|
|
161
|
-
|
|
168
|
+
// Store points material config so they can be used later to substitute points tiles material
|
|
169
|
+
// by our own PointsMaterial. These properties should eventually be managed through the Style API
|
|
170
|
+
// (see https://github.com/iTowns/itowns/issues/2336)
|
|
171
|
+
this.pntsMode = pntsMode;
|
|
172
|
+
this.pntsShape = pntsShape;
|
|
173
|
+
this.classification = classification;
|
|
174
|
+
this.pntsSizeMode = pntsSizeMode;
|
|
175
|
+
this.pntsMinAttenuatedSize = pntsMinAttenuatedSize;
|
|
176
|
+
this.pntsMaxAttenuatedSize = pntsMaxAttenuatedSize;
|
|
162
177
|
this.tilesRenderer = new TilesRenderer(this.source.url);
|
|
163
178
|
if (config.source.isOGC3DTilesIonSource) {
|
|
164
179
|
this.tilesRenderer.registerPlugin(new CesiumIonAuthPlugin({
|
|
@@ -197,21 +212,6 @@ class OGC3DTilesLayer extends GeometryLayer {
|
|
|
197
212
|
}
|
|
198
213
|
}
|
|
199
214
|
|
|
200
|
-
/**
|
|
201
|
-
* Store points material config so they can be used later to substitute points tiles material by our own PointsMaterial
|
|
202
|
-
* These properties should eventually be managed through the Style API (see https://github.com/iTowns/itowns/issues/2336)
|
|
203
|
-
* @param {Object} config - points material configuration as passed to the layer constructor.
|
|
204
|
-
* @private
|
|
205
|
-
*/
|
|
206
|
-
_handlePointsMaterialConfig(config) {
|
|
207
|
-
this.pntsMode = config.pntsMode ?? PNTS_MODE.COLOR;
|
|
208
|
-
this.pntsShape = config.pntsShape ?? PNTS_SHAPE.CIRCLE;
|
|
209
|
-
this.classification = config.classification ?? ClassificationScheme.DEFAULT;
|
|
210
|
-
this.pntsSizeMode = config.pntsSizeMode ?? PNTS_SIZE_MODE.VALUE;
|
|
211
|
-
this.pntsMinAttenuatedSize = config.pntsMinAttenuatedSize || 3;
|
|
212
|
-
this.pntsMaxAttenuatedSize = config.pntsMaxAttenuatedSize || 10;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
215
|
/**
|
|
216
216
|
* Sets the lruCache and download and parse queues so they are shared amongst
|
|
217
217
|
* all tilesets from a same {@link View} view.
|