@jdultra/threedtiles 5.1.1 → 5.1.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jdultra/threedtiles",
3
- "version": "5.1.1",
3
+ "version": "5.1.3",
4
4
  "description": "An OGC 3DTiles viewer for Three.js",
5
5
  "main": "tileset.js",
6
6
  "scripts": {
@@ -8,14 +8,15 @@ const dracoLoader = new DRACOLoader();
8
8
  const tempMatrix = new THREE.Matrix4();
9
9
  dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.4.3/');
10
10
  gltfLoader.setDRACOLoader(dracoLoader);
11
- const zUpToYUp = new THREE.Matrix4();
12
- zUpToYUp.set(1,0,0,0,
11
+ const zUpToYUpMatrix = new THREE.Matrix4();
12
+ zUpToYUpMatrix.set(1,0,0,0,
13
13
  0,0,-1,0,
14
14
  0,1,0,0,
15
15
  0,0,0,1);
16
+
16
17
  //const legacyGLTFLoader = new LegacyGLTFLoader();
17
18
 
18
- function parseB3DM(arrayBuffer, meshCallback) {
19
+ function parseB3DM(arrayBuffer, meshCallback, zUpToYUp) {
19
20
  const dataView = new DataView(arrayBuffer);
20
21
 
21
22
  const magic =
@@ -72,8 +73,11 @@ function parseB3DM(arrayBuffer, meshCallback) {
72
73
  }
73
74
 
74
75
  model.scene.traverse((o) => {
76
+
75
77
  if (o.isMesh) {
76
- o.applyMatrix4(zUpToYUp);
78
+ if(zUpToYUp){
79
+ o.applyMatrix4(zUpToYUpMatrix);
80
+ }
77
81
  if (!!meshCallback) {
78
82
  meshCallback(o);
79
83
  }
@@ -89,9 +93,9 @@ function parseB3DM(arrayBuffer, meshCallback) {
89
93
 
90
94
  const B3DMDecoder = {
91
95
  parseB3DM: parseB3DM,
92
- parseB3DMInstanced: (arrayBuffer, meshCallback, maxCount) => { // expects GLTF with one node level
96
+ parseB3DMInstanced: (arrayBuffer, meshCallback, maxCount, zUpToYUp) => { // expects GLTF with one node level
93
97
 
94
- return parseB3DM(arrayBuffer, meshCallback).then(mesh => {
98
+ return parseB3DM(arrayBuffer, meshCallback, zUpToYUp).then(mesh => {
95
99
  let instancedMesh;
96
100
  mesh.updateWorldMatrix(false, true)
97
101
  mesh.traverse(child => {
package/src/index.js CHANGED
@@ -23,7 +23,7 @@ const domContainer = initDomContainer("screen");
23
23
  const camera = initCamera(domContainer.offsetWidth, domContainer.offsetHeight);
24
24
  const stats = initStats(domContainer);
25
25
  const renderer = initRenderer(camera, domContainer);
26
- const ogc3DTiles = initTileset(scene, 1.0);
26
+ const ogc3DTiles = initTileset(scene, 4.0);
27
27
 
28
28
  //const instancedTileLoader = createInstancedTileLoader(scene);
29
29
  //initInstancedTilesets(instancedTileLoader);
@@ -133,7 +133,7 @@ function initTileset(scene, gem) {
133
133
  //url: "https://sampledata.luciad.com/data/ogc3dtiles/LucerneAirborneMesh/tileset.json",
134
134
  url: "https://sampleservices.luciad.com/ogc/3dtiles/marseille-mesh/tileset.json",
135
135
  //url: "https://storage.googleapis.com/ogc-3d-tiles/baltimore/tileset.json",
136
- //url: "http://localhost:8082/tileset.json",
136
+ //url: "https://storage.googleapis.com/ogc-3d-tiles/berlinTileset/tileset.json",
137
137
  geometricErrorMultiplier: gem,
138
138
  loadOutsideView: false,
139
139
  tileLoader: tileLoader,
@@ -141,13 +141,13 @@ function initTileset(scene, gem) {
141
141
  static: false,
142
142
  centerModel:true,
143
143
  renderer: renderer,
144
- onLoadCallback: (tile)=>{
144
+ /* onLoadCallback: (tile)=>{
145
145
  if (!!tile.json.boundingVolume.region) {
146
146
  const halfHeight = (tile.json.boundingVolume.region[5] - tile.json.boundingVolume.region[4]) * 0.5;
147
147
  ogc3DTile.translateOnAxis(new THREE.Vector3(0, 1, 0), halfHeight);
148
148
  //ogc3DTile.updateWorldMatrix(true, true);
149
149
  }
150
- }
150
+ } */
151
151
 
152
152
  });
153
153
  setIntervalAsync(function () {
@@ -236,8 +236,8 @@ function initLODMultiplierSlider(instancedTilesets) {
236
236
  function initController(camera, dom) {
237
237
  const controller = new OrbitControls(camera, dom);
238
238
 
239
+ //controller.target.set(4629210.73133627, 435359.7901640832, 4351492.357788198);
239
240
  controller.target.set(0,0,0);
240
- //controller.target.set(0,0,0);
241
241
 
242
242
 
243
243
  controller.minDistance = 0.1;
@@ -12,6 +12,7 @@ const upVector = new THREE.Vector3(0, 1, 0);
12
12
  const rendererSize = new THREE.Vector2();
13
13
  const tempQuaternion = new THREE.Quaternion();
14
14
 
15
+
15
16
  class OGC3DTile extends THREE.Object3D {
16
17
 
17
18
  /**
@@ -215,10 +216,14 @@ class OGC3DTile extends THREE.Object3D {
215
216
  if (!!url) {
216
217
  if (url.includes(".b3dm")) {
217
218
  self.contentURL = url;
219
+ if(!!self.json.boundingVolume.region){
220
+ //self.applyMatrix4(zUpToYUp);
221
+ }
218
222
  self.tileLoader.get(self.abortController, this.uuid, url, mesh => {
219
223
  if (!!self.deleted) return;
220
224
  mesh.traverse((o) => {
221
225
  if (o.isMesh) {
226
+
222
227
  o.layers.disable(0);
223
228
  if (self.occlusionCullingService) {
224
229
  const position = o.geometry.attributes.position;
@@ -241,7 +246,10 @@ class OGC3DTile extends THREE.Object3D {
241
246
  self.meshContent = mesh;
242
247
  }, !self.cameraOnLoad ? () => 0 : () => {
243
248
  return self.calculateDistanceToCamera(self.cameraOnLoad);
244
- }, () => self.getSiblings(), self.level);
249
+ }, () => self.getSiblings(),
250
+ self.level,
251
+ !!this.json.boundingVolume.region
252
+ );
245
253
  } else if (url.includes(".json")) {
246
254
  self.tileLoader.get(self.abortController, this.uuid, url, json => {
247
255
  if (!!self.deleted) return;
@@ -142,7 +142,7 @@ class TileLoader {
142
142
  }
143
143
 
144
144
 
145
- get(abortController, tileIdentifier, path, callback, distanceFunction, getSiblings, level) {
145
+ get(abortController, tileIdentifier, path, callback, distanceFunction, getSiblings, level, zUpToYUp) {
146
146
  const self = this;
147
147
  const key = simplifyPath(path);
148
148
 
@@ -183,7 +183,7 @@ class TileLoader {
183
183
 
184
184
  })
185
185
  .then(resultArrayBuffer=>{
186
- return B3DMDecoder.parseB3DM(resultArrayBuffer, self.meshCallback);
186
+ return B3DMDecoder.parseB3DM(resultArrayBuffer, self.meshCallback, zUpToYUp);
187
187
  })
188
188
  .then(mesh=>{
189
189
  self.cache.put(key, mesh);
@@ -217,7 +217,9 @@ class InstancedTile extends THREE.Object3D {
217
217
 
218
218
  self.tileLoader.get(self.abortController, url, self.uuid, self, !self.cameraOnLoad ? () => 0 : () => {
219
219
  return self.calculateDistanceToCamera(self.cameraOnLoad);
220
- }, () => self.getSiblings(), self.level);
220
+ }, () => self.getSiblings(),
221
+ self.level,
222
+ !!self.json.boundingVolume.region);
221
223
  } else if (url.includes(".json")) {
222
224
  self.tileLoader.get(self.abortController, url, self.uuid, self);
223
225
 
@@ -68,7 +68,7 @@ class InstancedTileLoader {
68
68
 
69
69
  })
70
70
  .then(resultArrayBuffer=>{
71
- return B3DMDecoder.parseB3DMInstanced(resultArrayBuffer, self.meshCallback, self.maxInstances);
71
+ return B3DMDecoder.parseB3DMInstanced(resultArrayBuffer, self.meshCallback, self.maxInstances, nextDownload.zUpToYUp);
72
72
  })
73
73
  .then(mesh=>{
74
74
  nextDownload.tile.setObject(mesh);
@@ -138,7 +138,7 @@ class InstancedTileLoader {
138
138
  }
139
139
  }
140
140
 
141
- get(abortController, path, uuid, instancedOGC3DTile, distanceFunction, getSiblings, level) {
141
+ get(abortController, path, uuid, instancedOGC3DTile, distanceFunction, getSiblings, level, zUpToYUp) {
142
142
  const self = this;
143
143
  const key = simplifyPath(path);
144
144
 
@@ -156,9 +156,7 @@ class InstancedTileLoader {
156
156
  if (path.includes(".b3dm")) {
157
157
  const tile = new MeshTile(self.scene);
158
158
  tile.addInstance(instancedOGC3DTile);
159
- if(self.cache.has(key)){
160
- console.log("élkbhj")
161
- }
159
+
162
160
  self.cache.put(key, tile);
163
161
 
164
162
  const realAbortController = new AbortController();
@@ -176,6 +174,7 @@ class InstancedTileLoader {
176
174
  getSiblings: getSiblings,
177
175
  level: level,
178
176
  uuid: uuid,
177
+ zUpToYUp: zUpToYUp,
179
178
  shouldDoDownload: () => {
180
179
  return true;
181
180
  },