@jdultra/threedtiles 3.1.0 → 3.1.2

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 @@ import { OGC3DTile } from "./tileset/OGC3DTile";
14
14
  ...
15
15
 
16
16
  const ogc3DTile = new OGC3DTile({
17
- url: "https://ebeaufay.github.io/ThreedTilesViewer.github.io/momoyama/tileset.json"
17
+ url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tileset.json"
18
18
  });
19
19
 
20
20
  scene.add(ogc3DTile);
@@ -33,6 +33,9 @@ setInterval(function () {
33
33
  - Allows tilesets transformations. Translate, scale and rotate a tilesets in real-time.
34
34
  - callback on loaded geometry to assign a custom material or use the meshes for computations.
35
35
  - Optionally load low detail tiles outside of view frustum for correct shadows and basic mesh present when the camera moves quickly.
36
+ - Share a cache between tileset instances
37
+ - Automatically tune the geometric error multiplier to 60 FPS
38
+ - Automatic scaling of the cache
36
39
 
37
40
  ### geometric Error Multiplier
38
41
  The geometric error multiplier allows you to multiply the geometric error by a factor.
@@ -43,20 +46,43 @@ you may also set this value at initialization:
43
46
 
44
47
  ```
45
48
  const ogc3DTile = new OGC3DTile({
46
- url: "https://ebeaufay.github.io/ThreedTilesViewer.github.io/momoyama/tileset.json",
49
+ url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tileset.json",
47
50
  geometricErrorMultiplier: 2.0
48
51
  });
49
52
  ```
50
53
  A lower value will result in lower detail tiles being loaded and a higher value results in higher detail tiles being loaded.
51
54
  A value of 1.0 is the default.
52
55
 
56
+ #### Automatic Geometric error multiplier
57
+ In order to reach a steady 60 FPS, you can specify a TilesetStats object.
58
+ This object is basically the Stats object from the Three.js samples without the UI component.
59
+ It must be updated in the animate function and given to the tileset at construction.
60
+ ```
61
+ import TilesetStats from '@jdultra/threedtiles/src/tileset/TilesetStats';
62
+
63
+ const tilesetStats = TilesetStats();
64
+
65
+ const ogc3DTile = new OGC3DTile({
66
+ url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tileset.json",
67
+ stats: tilesetStats
68
+ });
69
+
70
+ function animate() {
71
+
72
+ ...
73
+
74
+ tilesetStats.update();
75
+ }
76
+ ```
77
+
78
+
53
79
  ### load tiles outside of view
54
80
  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.
55
81
  Instead of this behaviour, you can force the lowest possible LODs to be loaded for tiles around the view so that there are no gaps in the mesh when the camera moves or when displaying shadows.
56
82
 
57
83
  ```
58
84
  const ogc3DTile = new OGC3DTile({
59
- url: "https://ebeaufay.github.io/ThreedTilesViewer.github.io/momoyama/tileset.json",
85
+ url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tileset.json",
60
86
  loadOutsideView: true
61
87
  });
62
88
  ```
@@ -66,13 +92,33 @@ Add a callback on loaded tiles in order to set a material or do some logic on th
66
92
 
67
93
  ```
68
94
  const ogc3DTile = new OGC3DTile({
69
- url: "https://ebeaufay.github.io/ThreedTilesViewer.github.io/momoyama/tileset.json",
95
+ url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tileset.json",
70
96
  meshCallback: mesh => {
71
97
  mesh.material.wireframe = true;
72
98
  }
73
99
  });
74
100
  ```
75
101
 
102
+ ### Cache
103
+ You may instanciate a cache through the TileLoader class and re-use it for several or all your tilesets.
104
+ The limitation is that all the tilesets using the same cache will have the same callback.
105
+
106
+ If a TilesetStats object is passed, it will be used to monitor the size of the cache when the browser allows it, otherwise, each cache is limitted to 1000 items.
107
+
108
+ ```
109
+ import { TileLoader } from "@jdultra/threedtiles/src/tileset/TileLoader";
110
+
111
+ const ogc3DTile = new OGC3DTile({
112
+ url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tileset.json",
113
+ tileLoader: new TileLoader(mesh => {
114
+ //// Insert code to be called on every newly decoded mesh e.g.:
115
+ mesh.material.wireframe = false;
116
+ mesh.material.side = THREE.DoubleSide;
117
+ }, tilesetStats),
118
+ meshCallback: mesh => { mesh.material.wireframe = true;} // This callback will not be used as the callback provided to the TileLoader takes priority
119
+ });
120
+ ```
121
+
76
122
  ### Transformations
77
123
  The OGC 3DTile object is a regular three.js Object3D so it can be transformed via the standard three.js API:
78
124
 
package/index.html CHANGED
@@ -4,6 +4,7 @@
4
4
  <head>
5
5
  <meta charset="utf-8" />
6
6
  <title>Three 3DTiles viewer sample</title>
7
+ <link rel="manifest" href="manifest.json">
7
8
  </head>
8
9
 
9
10
  <body>
package/manifest.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "display": "fullscreen",
3
+ "orientation": "landscape"
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jdultra/threedtiles",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "An OGC 3DTiles viewer for Three.js",
5
5
  "main": "tileset.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -7,8 +7,6 @@ import { TileLoader } from "./tileset/TileLoader";
7
7
  import { MapControls, OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
8
8
 
9
9
 
10
-
11
-
12
10
  const scene = initScene();
13
11
  const tilesetStats = TilesetStats();
14
12
  const domContainer = initDomContainer("screen");
@@ -21,7 +19,6 @@ const renderer = initRenderer(camera, domContainer);
21
19
 
22
20
  animate();
23
21
 
24
-
25
22
  function initScene() {
26
23
  const scene = new THREE.Scene();
27
24
  scene.background = new THREE.Color(0x000000);
@@ -45,7 +45,9 @@ class OGC3DTile extends THREE.Object3D {
45
45
  if (properties.stats) {
46
46
  // Automatic geometric error multiplier
47
47
  this.stats = properties.stats;
48
+
48
49
  setIntervalAsync(() => {
50
+ if (!!document.hidden) return;
49
51
  const framerate = self.stats.fps();
50
52
  if (framerate < 0) return;
51
53
  if (framerate < 58) {
@@ -53,7 +55,6 @@ class OGC3DTile extends THREE.Object3D {
53
55
  } else if (framerate > 58) {
54
56
  self.setGeometricErrorMultiplier(self.geometricErrorMultiplier + 0.05);
55
57
  }
56
- self.setGeometricErrorMultiplier(self.geometricErrorMultiplier * (self.stats.fps() / 60));
57
58
  }, 1000);
58
59
  }
59
60