@jdultra/threedtiles 8.0.0 → 8.0.1

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/README.md CHANGED
@@ -14,7 +14,7 @@ The fastest 3DTiles viewer for three.js
14
14
 
15
15
  [Instanced Tileset (pilot a swarm of highly detailed spaceships)](https://www.jdultra.com/instanced/index.html)
16
16
 
17
- NPM dependency: "@jdultra/threedtiles": "^6.0.4"
17
+ NPM dependency: "@jdultra/threedtiles": "^8.0.0"
18
18
 
19
19
  Adding a tileset to a scene is as easy as :
20
20
 
@@ -68,6 +68,7 @@ Contact: emeric.beaufays@jdultra.com
68
68
  - Instanced tilesets
69
69
  - Center tileset and re-orient geolocated data
70
70
  - gltf/glb tiles (OGC3DTiles 1.1)
71
+ - draco and ktx2 compression support
71
72
  - point clouds (only through gltf/glb tiles)
72
73
 
73
74
  Support for OGC3DTiles 1.1 is underway. gltf/glb tiles are already supported but not yet implicit tiling.
@@ -90,7 +91,10 @@ const ogc3DTile = new OGC3DTile({
90
91
  A lower value will result in lower detail tiles being loaded and a higher value results in higher detail tiles being loaded.
91
92
  A value of 1.0 is the default.
92
93
 
93
-
94
+ #### geometricErrorMultiplier vs maxScreenSpaceError
95
+ Many viewers use the maxScreenSpaceError instead of a geometric error multiplier and there is a direct correspondance.
96
+ A geometricErrorMultiplier of 1 corresponds to a maxScreenSpaceError of 16.
97
+ A geometricErrorMultiplier of 0.5 corresponds to a maxScreenSpaceError of 32.
94
98
 
95
99
  ### load tiles outside of view
96
100
  By default, only the tiles that intersect the view frustum are loaded. When the camera moves, the scene will have to load the missing tiles and the user might see some holes in the model.
@@ -154,25 +158,34 @@ If using a shared cache between tilesets, check out the next section.
154
158
  You may instanciate a cache through the TileLoader class and re-use it for several or all your tilesets.
155
159
  The limitation is that all the tilesets using the same cache will have the same callback.
156
160
 
157
- The TileLoader constructor takes 2 arguments. The first is a callback for meshes (see above section) and the second is
158
- the maximum number of items in the cache (default is 1000).
161
+ The TileLoader takes an optional object as argument:
162
+ @param {Object} [options] - Optional configuration object.
163
+ @param {number} [options.maxCachedItems=100] - the cache size.
164
+ @param {function} [options.meshCallback] - A callback to call on newly decoded meshes.
165
+ @param {function} [options.pointsCallback] - A callback to call on newly decoded points.
166
+ @param {renderer} [options.renderer] - The renderer, this is required for KTX2 support.
159
167
 
160
168
  ```
161
169
  import { TileLoader } from "@jdultra/threedtiles/src/tileset/TileLoader";
162
170
 
163
- const ogc3DTile = new OGC3DTile({
164
- url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tileset.json",
171
+ const tileLoader = new TileLoader({
165
172
  renderer: renderer,
166
- tileLoader: new TileLoader(2000, mesh => {
173
+ maxCachedItems: 100,
174
+ meshCallback: mesh => {
167
175
  //// Insert code to be called on every newly decoded mesh e.g.:
168
176
  mesh.material.wireframe = false;
169
177
  mesh.material.side = THREE.DoubleSide;
170
- },
171
- points=>{
172
- points.material.size = 0.1;
173
- points.material.sizeAttenuation = true;
174
- }
175
- ),
178
+ //mesh.material.metalness = 0.0
179
+ },
180
+ pointsCallback: points => {
181
+ points.material.size = Math.min(1.0, 0.5 * Math.sqrt(points.geometricError));
182
+ points.material.sizeAttenuation = true;
183
+ }
184
+ });
185
+ const ogc3DTile = new OGC3DTile({
186
+ url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tileset.json",
187
+ renderer: renderer,
188
+ tileLoader: tileLoader,
176
189
  meshCallback: mesh => { mesh.material.wireframe = true;} // This callback will not be used as the callback provided to the TileLoader takes priority
177
190
  });
178
191
  ```
@@ -242,12 +255,19 @@ higher performance when displaying the same Tileset many times.
242
255
  // First create the InstancedTileLoader that will manage caching
243
256
  const instancedTileLoader = new InstancedTileLoader(
244
257
  scene,
245
- 100, // cache size as in the number of tiles cached in memory
246
- 1, // max number of tilesets from the same source
247
- mesh => {
248
- //// Insert code to be called on every newly decoded mesh e.g.:
249
- mesh.material.wireframe = false;
250
- mesh.material.side = THREE.DoubleSide;
258
+ {
259
+ renderer: renderer,
260
+ maxCachedItems : 100,
261
+ maxInstances : 1,
262
+ meshCallback: mesh => {
263
+ //// Insert code to be called on every newly decoded mesh e.g.:
264
+ mesh.material.wireframe = false;
265
+ mesh.material.side = THREE.DoubleSide;
266
+ },
267
+ pointsCallback: points => {
268
+ points.material.size = Math.min(1.0, 0.5 * Math.sqrt(points.geometricError));
269
+ points.material.sizeAttenuation = true;
270
+ }
251
271
  }
252
272
  );
253
273
 
@@ -321,7 +341,12 @@ scene.matrixWorldAutoUpdate = false;
321
341
  scene.updateMatrixWorld(true);
322
342
 
323
343
  ```
324
- #### tileset update loop
344
+ ### Draco and Ktx2
345
+ Compressed meshes via Draco and compressed textures in Ktx2 format are supported automatically using the threejs plugins.
346
+ KTX uses an external wasm loaded at runtime so if you have trouble packaging your app correctly, check out the
347
+ [Getting started](https://drive.google.com/file/d/1kJ-yfYmy8ShOMMPPXgqW2gMgGkLOIidf/view?usp=share_link) project for a sample webpack configuration.
348
+
349
+ ### tileset update loop
325
350
  Updating a single tileset via OGC3DTile#update or InstancedOGC3DTile#update is quite fast, even when the tree is deep.
326
351
  For a single tileset, it's safe to call it regularly with a setInterval:
327
352
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jdultra/threedtiles",
3
- "version": "8.0.0",
3
+ "version": "8.0.1",
4
4
  "description": "An OGC 3DTiles viewer for Three.js",
5
5
  "main": "tileset.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -25,7 +25,7 @@ const domContainer = initDomContainer("screen");
25
25
  const camera = initCamera(domContainer.offsetWidth, domContainer.offsetHeight);
26
26
  const stats = initStats(domContainer);
27
27
  const renderer = initRenderer(camera, domContainer);
28
- const ogc3DTiles = initTileset(scene, 2.0);
28
+ const ogc3DTiles = initTileset(scene, 1.0);
29
29
  //const instancedTileLoader = createInstancedTileLoader(scene);
30
30
  //const ogc3DTiles = initInstancedTilesets(instancedTileLoader);
31
31
 
@@ -4,8 +4,8 @@ import { TileLoader } from "./TileLoader";
4
4
  import { v4 as uuidv4 } from "uuid";
5
5
  import * as path from "path-browserify"
6
6
  import { clamp } from "three/src/math/MathUtils";
7
- import { Octree } from 'three/addons/math/Octree.js';
8
- import { OctreeHelper } from 'three/addons/helpers/OctreeHelper.js';
7
+ //import { Octree } from 'three/addons/math/Octree.js';
8
+ //import { OctreeHelper } from 'three/addons/helpers/OctreeHelper.js';
9
9
 
10
10
  const tempSphere = new THREE.Sphere(new THREE.Vector3(0, 0, 0), 1);
11
11
  const tempVec1 = new THREE.Vector3(0, 0, 0);
@@ -95,7 +95,7 @@ class OGC3DTile extends THREE.Object3D {
95
95
  this.centerModel = properties.centerModel;
96
96
  this.abortController = new AbortController();
97
97
  this.layers.disable(0);
98
- this.octree = new Octree();
98
+ //this.octree = new Octree();
99
99
 
100
100
  if (!!properties.json) { // If this tile is created as a child of another tile, properties.json is not null
101
101
  self.setup(properties);