@jdultra/threedtiles 3.0.6 → 3.0.7
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/package.json +1 -1
- package/src/index.js +0 -1
- package/src/tileset/OGC3DTile.js +23 -21
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -128,7 +128,6 @@ function initTileset(scene) {
|
|
|
128
128
|
const ogc3DTile = new OGC3DTile({
|
|
129
129
|
url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tileset.json",
|
|
130
130
|
//url: "https://storage.googleapis.com/ogc-3d-tiles/castleX/tileset.json",
|
|
131
|
-
//url: "./apartment/tileset.json",
|
|
132
131
|
//url: "https://storage.googleapis.com/ogc-3d-tiles/berlinSubsetTiled/tileset.json",
|
|
133
132
|
//url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tileset.json",
|
|
134
133
|
//url: "https://s3.us-east-2.wasabisys.com/construkted-assets/arkcnfuk9fw/tileset.json",
|
package/src/tileset/OGC3DTile.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { OBB } from "../geometry/obb";
|
|
3
3
|
import { B3DMDecoder } from "../decoder/B3DMDecoder";
|
|
4
|
-
import {Cache} from "../cache/Cache";
|
|
4
|
+
import { Cache } from "../cache/Cache";
|
|
5
5
|
const path = require('path');
|
|
6
6
|
|
|
7
7
|
const tilesToLoad = [];
|
|
@@ -51,7 +51,7 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
51
51
|
this.json; // the json corresponding to this tile
|
|
52
52
|
this.materialVisibility = false;
|
|
53
53
|
this.inFrustum = true;
|
|
54
|
-
this.level = properties.level? properties.level : 0;
|
|
54
|
+
this.level = properties.level ? properties.level : 0;
|
|
55
55
|
this.hasMeshContent = false; // true when the provided json has a content field pointing to a B3DM file
|
|
56
56
|
this.hasUnloadedJSONContent = false; // true when the provided json has a content field pointing to a JSON file that is not yet loaded
|
|
57
57
|
|
|
@@ -220,7 +220,7 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
|
|
223
|
-
update(camera){
|
|
223
|
+
update(camera) {
|
|
224
224
|
const frustum = new THREE.Frustum();
|
|
225
225
|
frustum.setFromProjectionMatrix(new THREE.Matrix4().multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse));
|
|
226
226
|
this._update(camera, frustum);
|
|
@@ -232,15 +232,15 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
232
232
|
var metric = self.calculateUpdateMetric(camera, frustum);
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
+
updateNodeVisibility(metric);
|
|
235
236
|
updateTree(metric);
|
|
236
237
|
self.childrenTiles.forEach(child => child._update(camera, frustum));
|
|
237
|
-
updateNodeVisibility(metric);
|
|
238
238
|
trimTree(metric);
|
|
239
239
|
|
|
240
240
|
|
|
241
241
|
function updateTree(metric) {
|
|
242
242
|
// If this tile does not have mesh content but it has children
|
|
243
|
-
if(metric<0 && self.hasMeshContent) return;
|
|
243
|
+
if (metric < 0 && self.hasMeshContent) return;
|
|
244
244
|
if (!self.hasMeshContent || (metric < self.geometricError && !!self.meshContent)) {
|
|
245
245
|
if (!!self.json && !!self.json.children && self.childrenTiles.length != self.json.children.length) {
|
|
246
246
|
loadJsonChildren();
|
|
@@ -255,7 +255,7 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
255
255
|
if (!self.hasMeshContent) return;
|
|
256
256
|
|
|
257
257
|
// mesh content not yet loaded
|
|
258
|
-
if(!self.meshContent) {
|
|
258
|
+
if (!self.meshContent) {
|
|
259
259
|
return;
|
|
260
260
|
}
|
|
261
261
|
|
|
@@ -264,7 +264,7 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
264
264
|
self.inFrustum = false;
|
|
265
265
|
self.changeContentVisibility(!!self.loadOutsideView);
|
|
266
266
|
return;
|
|
267
|
-
}else{
|
|
267
|
+
} else {
|
|
268
268
|
self.inFrustum = true;
|
|
269
269
|
}
|
|
270
270
|
|
|
@@ -282,7 +282,7 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
282
282
|
// if children are visible and have been displayed, can be hidden
|
|
283
283
|
var allChildrenReady = true;
|
|
284
284
|
self.childrenTiles.every(child => {
|
|
285
|
-
|
|
285
|
+
|
|
286
286
|
if (!child.isReady()) {
|
|
287
287
|
allChildrenReady = false;
|
|
288
288
|
return false;
|
|
@@ -291,8 +291,9 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
291
291
|
});
|
|
292
292
|
if (allChildrenReady) {
|
|
293
293
|
self.changeContentVisibility(false);
|
|
294
|
-
}else{
|
|
295
|
-
self.changeContentVisibility(true);
|
|
294
|
+
} else {
|
|
295
|
+
//self.changeContentVisibility(true);
|
|
296
|
+
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
299
|
}
|
|
@@ -309,7 +310,7 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
309
310
|
return;
|
|
310
311
|
}
|
|
311
312
|
}
|
|
312
|
-
|
|
313
|
+
|
|
313
314
|
}
|
|
314
315
|
|
|
315
316
|
function loadJsonChildren() {
|
|
@@ -323,7 +324,7 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
323
324
|
geometricErrorMultiplier: self.geometricErrorMultiplier,
|
|
324
325
|
meshCallback: self.meshCallback,
|
|
325
326
|
loadOutsideView: self.loadOutsideView,
|
|
326
|
-
level:self.level+1
|
|
327
|
+
level: self.level + 1
|
|
327
328
|
});
|
|
328
329
|
self.childrenTiles.push(childTile);
|
|
329
330
|
self.add(childTile);
|
|
@@ -338,13 +339,13 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
338
339
|
*/
|
|
339
340
|
isReady() {
|
|
340
341
|
// if outside frustum
|
|
341
|
-
if(!this.inFrustum) return true;
|
|
342
|
+
if (!this.inFrustum) return true;
|
|
342
343
|
|
|
343
344
|
// if json is not done loading
|
|
344
345
|
if (this.hasUnloadedJSONContent) return false;
|
|
345
346
|
|
|
346
347
|
// if this tile has no mesh content or if it's marked as visible false, look at children
|
|
347
|
-
if ((!this.hasMeshContent || !this.meshContent || !this.materialVisibility) && this.childrenTiles.length>0) {
|
|
348
|
+
if ((!this.hasMeshContent || !this.meshContent || !this.materialVisibility) && this.childrenTiles.length > 0) {
|
|
348
349
|
var allChildrenReady = true;
|
|
349
350
|
this.childrenTiles.every(child => {
|
|
350
351
|
if (!child.isReady()) {
|
|
@@ -357,11 +358,11 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
357
358
|
}
|
|
358
359
|
|
|
359
360
|
// if this tile has no mesh content
|
|
360
|
-
if(!this.hasMeshContent){
|
|
361
|
+
if (!this.hasMeshContent) {
|
|
361
362
|
return true;
|
|
362
363
|
}
|
|
363
364
|
// if mesh content not yet loaded
|
|
364
|
-
if(!this.meshContent) {
|
|
365
|
+
if (!this.meshContent) {
|
|
365
366
|
return false;
|
|
366
367
|
}
|
|
367
368
|
|
|
@@ -376,10 +377,11 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
376
377
|
}
|
|
377
378
|
|
|
378
379
|
return false;
|
|
379
|
-
|
|
380
|
+
|
|
380
381
|
}
|
|
381
382
|
|
|
382
|
-
|
|
383
|
+
|
|
384
|
+
|
|
383
385
|
|
|
384
386
|
changeContentVisibility(visibility) {
|
|
385
387
|
const self = this;
|
|
@@ -437,8 +439,8 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
437
439
|
if (distance == 0) {
|
|
438
440
|
return 0;
|
|
439
441
|
}
|
|
440
|
-
const scale = this.matrixWorld.getMaxScaleOnAxis
|
|
441
|
-
return ((distance / 100) / this.geometricErrorMultiplier)/scale;
|
|
442
|
+
const scale = this.matrixWorld.getMaxScaleOnAxis();
|
|
443
|
+
return ((distance / 100) / this.geometricErrorMultiplier) / scale;
|
|
442
444
|
} else if (this.boundingVolume instanceof THREE.Box3) {
|
|
443
445
|
// Region
|
|
444
446
|
// Region not supported
|
|
@@ -458,7 +460,7 @@ class OGC3DTile extends THREE.Object3D {
|
|
|
458
460
|
*
|
|
459
461
|
* @param {Integer} size a number of vertices
|
|
460
462
|
*/
|
|
461
|
-
function createMeshCache(size = 5000000, meshCallback = ()=>{}){
|
|
463
|
+
function createMeshCache(size = 5000000, meshCallback = () => { }) {
|
|
462
464
|
/* return new Cache(
|
|
463
465
|
(url, self)=>{
|
|
464
466
|
fetch(url, { signal: self.controller.signal }).then(result => {
|