itowns 2.44.3-next.1 → 2.44.3-next.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.
@@ -170,6 +170,8 @@ let previous;
170
170
  * @property {boolean} enableDamping Enable damping or not (simulates the lag that a real camera
171
171
  * operator introduces while operating a heavy physical camera). Default is true.
172
172
  * @property {boolean} dampingMoveFactor the damping move factor. Default is 0.25.
173
+ * @property {StateControl~State} stateControl redefining which controls state is triggered by the keyboard/mouse
174
+ * event (For example, rewrite the PAN movement to be triggered with the 'left' mouseButton instead of 'right').
173
175
  */
174
176
  class GlobeControls extends THREE.EventDispatcher {
175
177
  constructor(view, placement) {
@@ -180,7 +182,7 @@ class GlobeControls extends THREE.EventDispatcher {
180
182
  this.camera = view.camera3D;
181
183
 
182
184
  // State control
183
- this.states = new StateControl(this.view);
185
+ this.states = new StateControl(this.view, options.stateControl);
184
186
 
185
187
  // this.enabled property has moved to StateControl
186
188
  Object.defineProperty(this, 'enabled', {
@@ -290,7 +290,7 @@ class StreetControls extends FirstPersonControls {
290
290
  this.end.lookAt(position);
291
291
  this.tween = new TWEEN.Tween({
292
292
  t: 0
293
- }, this.tweenGroup).to({
293
+ }).to({
294
294
  t: 1
295
295
  }, time).easing(TWEEN.Easing.Quadratic.Out).onComplete(() => {
296
296
  this.stopAnimations();
@@ -298,6 +298,7 @@ class StreetControls extends FirstPersonControls {
298
298
  // 'manually' slerp the Quaternion to avoid rotation issues
299
299
  this.camera.quaternion.slerpQuaternions(startQuaternion, this.end.quaternion, d.t);
300
300
  }).start();
301
+ this.tweenGroup.add(this.tween);
301
302
  this.animationFrameRequester = () => {
302
303
  this.tweenGroup.update();
303
304
  // call reset from super class FirsPersonControls to make mouse rotation managed by FirstPersonControl still aligned
@@ -325,12 +326,13 @@ class StreetControls extends FirstPersonControls {
325
326
  resolve = r;
326
327
  });
327
328
  this.stopAnimations();
328
- this.tween = new TWEEN.Tween(this.camera.position, this.tweenGroup) // Create a new tween that modifies camera position
329
+ this.tween = new TWEEN.Tween(this.camera.position) // Create a new tween that modifies camera position
329
330
  .to(position.clone(), time).easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
330
331
  .onComplete(() => {
331
332
  this.stopAnimations();
332
333
  resolve();
333
334
  }).start();
335
+ this.tweenGroup.add(this.tween);
334
336
  this.animationFrameRequester = () => {
335
337
  this.tweenGroup.update();
336
338
  this.view.notifyChange(this.camera);
@@ -343,6 +345,7 @@ class StreetControls extends FirstPersonControls {
343
345
  if (this.tween) {
344
346
  this.tween.stop();
345
347
  this.tween = undefined;
348
+ this.tweenGroup.removeAll();
346
349
  }
347
350
  if (this.animationFrameRequester) {
348
351
  this.view.removeFrameRequester(MAIN_LOOP_EVENTS.BEFORE_RENDER, this.animationFrameRequester);
@@ -27,8 +27,8 @@ const crsWGS84 = 'EPSG:4326';
27
27
  class FeatureMesh extends THREE.Group {
28
28
  #currentCrs;
29
29
  #originalCrs;
30
- #collection = new THREE.Group();
31
- #place = new THREE.Group();
30
+ #collection = (() => new THREE.Group())();
31
+ #place = (() => new THREE.Group())();
32
32
  constructor(meshes, collection) {
33
33
  super();
34
34
  this.meshes = new THREE.Group().add(...meshes);
@@ -332,8 +332,8 @@ const alignYtoEast = new THREE.Quaternion();
332
332
  */
333
333
 
334
334
  export class FeatureCollection extends THREE.Object3D {
335
- #transformToLocalSystem = transformToLocalSystem2D;
336
- #setLocalSystem = doNothing;
335
+ #transformToLocalSystem = (() => transformToLocalSystem2D)();
336
+ #setLocalSystem = (() => doNothing)();
337
337
  /**
338
338
  * @param {FeatureBuildingOptions|Layer} options The building options .
339
339
  */
package/lib/Core/Style.js CHANGED
@@ -198,8 +198,8 @@ function defineStyleProperty(style, category, parameter, userValue, defaultValue
198
198
  * @property {FeatureGeometry} geometry @private The FeatureGeometry to compute the style.
199
199
  */
200
200
  export class StyleContext {
201
- #worldCoord = new Coordinates('EPSG:4326', 0, 0, 0);
202
- #localCoordinates = new Coordinates('EPSG:4326', 0, 0, 0);
201
+ #worldCoord = (() => new Coordinates('EPSG:4326', 0, 0, 0))();
202
+ #localCoordinates = (() => new Coordinates('EPSG:4326', 0, 0, 0))();
203
203
  #worldCoordsComputed = true;
204
204
  #feature = {};
205
205
  #geometry = {};
@@ -12,7 +12,7 @@ import { geoidLayerIsVisible } from "../Layer/GeoidLayer.js";
12
12
  * @param {?number} level - the tile level (default = 0)
13
13
  */
14
14
  class TileMesh extends THREE.Mesh {
15
- #_tms = new Map();
15
+ #_tms = (() => new Map())();
16
16
  #visible = true;
17
17
  constructor(geometry, material, layer, extent) {
18
18
  let level = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
package/lib/Core/View.js CHANGED
@@ -121,7 +121,7 @@ let screenMeters;
121
121
  */
122
122
  class View extends THREE.EventDispatcher {
123
123
  #layers = [];
124
- #pixelDepthBuffer = new Uint8Array(4);
124
+ #pixelDepthBuffer = (() => new Uint8Array(4))();
125
125
  #fullSizeDepthBuffer;
126
126
  /**
127
127
  * Constructs an Itowns View instance
@@ -32,7 +32,7 @@ class CopcLayer extends PointCloudLayer {
32
32
  super(id, config);
33
33
  this.isCopcLayer = true;
34
34
  const resolve = () => this;
35
- this.whenReady = this.source.whenReady.then(( /** @type {CopcSource} */source) => {
35
+ this.whenReady = this.source.whenReady.then((/** @type {CopcSource} */source) => {
36
36
  const {
37
37
  cube,
38
38
  rootHierarchyPage
@@ -139,7 +139,7 @@ class LabelsNode extends THREE.Group {
139
139
  * internally for optimisation.
140
140
  */
141
141
  class LabelLayer extends GeometryLayer {
142
- #filterGrid = new ScreenGrid();
142
+ #filterGrid = (() => new ScreenGrid())();
143
143
  /**
144
144
  * @extends Layer
145
145
  *
@@ -122,11 +122,13 @@ class OGC3DTilesLayer extends GeometryLayer {
122
122
  if (config.source.isOGC3DTilesIonSource) {
123
123
  this.tilesRenderer.registerPlugin(new CesiumIonAuthPlugin({
124
124
  apiToken: config.source.accessToken,
125
- assetId: config.source.assetId
125
+ assetId: config.source.assetId,
126
+ autoRefreshToken: true
126
127
  }));
127
128
  } else if (config.source.isOGC3DTilesGoogleSource) {
128
129
  this.tilesRenderer.registerPlugin(new GoogleCloudAuthPlugin({
129
- apiToken: config.source.key
130
+ apiToken: config.source.key,
131
+ autoRefreshToken: true
130
132
  }));
131
133
  }
132
134
  this.tilesRenderer.registerPlugin(new ImplicitTilingPlugin());
@@ -274,7 +276,7 @@ class OGC3DTilesLayer extends GeometryLayer {
274
276
 
275
277
  // Setup classification bufferAttribute
276
278
  if (model.isPoints) {
277
- const classificationData = batchTable?.getData('Classification');
279
+ const classificationData = batchTable?.getPropertyArray('Classification');
278
280
  if (classificationData) {
279
281
  geometry.setAttribute('classification', new THREE.BufferAttribute(classificationData, 1));
280
282
  }
@@ -3,7 +3,7 @@ import { spawn, Thread, Transfer } from 'threads';
3
3
  let _lazPerf;
4
4
  let _thread;
5
5
  function workerInstance() {
6
- return new Worker( /* webpackChunkName: "itowns_lasparser" */
6
+ return new Worker(/* webpackChunkName: "itowns_lasparser" */
7
7
  new URL('../Worker/LASLoaderWorker.js', import.meta.url), {
8
8
  type: 'module'
9
9
  });
@@ -2,7 +2,7 @@ import * as THREE from 'three';
2
2
  import { spawn, Thread, Transfer } from 'threads';
3
3
  let _thread;
4
4
  function workerInstance() {
5
- return new Worker( /* webpackChunkName: "itowns_potree2worker" */
5
+ return new Worker(/* webpackChunkName: "itowns_potree2worker" */
6
6
  new URL('../Worker/Potree2Worker.js', import.meta.url), {
7
7
  type: 'module'
8
8
  });
@@ -77,7 +77,7 @@ function updatePreSse(camera, height, fov) {
77
77
  */
78
78
  class Camera {
79
79
  #_viewMatrixNeedsUpdate = true;
80
- #_viewMatrix = new THREE.Matrix4();
80
+ #_viewMatrix = (() => new THREE.Matrix4())();
81
81
 
82
82
  /**
83
83
  * @param {string} crs The camera's coordinate projection system.
@@ -12,7 +12,7 @@ const defaultTex = new THREE.Texture();
12
12
 
13
13
  // from three.js packDepthToRGBA
14
14
  const UnpackDownscale = 255 / 256; // 0..1 -> fraction (excluding 1)
15
- const bitSh = new THREE.Vector4(UnpackDownscale / (256.0 * 256.0 * 256.0), UnpackDownscale / (256.0 * 256.0), UnpackDownscale / 256.0, UnpackDownscale);
15
+ const bitSh = new THREE.Vector4(UnpackDownscale, UnpackDownscale / 256.0, UnpackDownscale / (256.0 * 256.0), UnpackDownscale / (256.0 * 256.0 * 256.0));
16
16
  export function unpack1K(color, factor) {
17
17
  return factor ? bitSh.dot(color) * factor : bitSh.dot(color);
18
18
  }
@@ -91,7 +91,7 @@ class CopcSource extends Source {
91
91
  this.parser = LASParser.parseChunk;
92
92
  this.fetcher = Fetcher.arrayBuffer;
93
93
  this.colorDepth = config.colorDepth ?? 16;
94
- const get = ( /** @type {number} */begin, /** @type {number} */end) => this.fetcher(this.url, {
94
+ const get = (/** @type {number} */begin, /** @type {number} */end) => this.fetcher(this.url, {
95
95
  ...this.networkOptions,
96
96
  headers: {
97
97
  ...this.networkOptions.headers,
@@ -1,12 +1,4 @@
1
1
  class WebGL {
2
- static isWebGLAvailable() {
3
- try {
4
- const canvas = document.createElement('canvas');
5
- return !!(window.WebGLRenderingContext && (canvas.getContext('webgl') || canvas.getContext('experimental-webgl')));
6
- } catch (e) {
7
- return false;
8
- }
9
- }
10
2
  static isWebGL2Available() {
11
3
  try {
12
4
  const canvas = document.createElement('canvas');
@@ -25,9 +17,6 @@ class WebGL {
25
17
  return false;
26
18
  }
27
19
  }
28
- static getWebGLErrorMessage() {
29
- return this.getErrorMessage(1);
30
- }
31
20
  static getWebGL2ErrorMessage() {
32
21
  return this.getErrorMessage(2);
33
22
  }
@@ -60,5 +49,21 @@ class WebGL {
60
49
  element.innerHTML = message;
61
50
  return element;
62
51
  }
52
+
53
+ // @deprecated, r168
54
+
55
+ static isWebGLAvailable() {
56
+ console.warn('isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead.');
57
+ try {
58
+ const canvas = document.createElement('canvas');
59
+ return !!(window.WebGLRenderingContext && (canvas.getContext('webgl') || canvas.getContext('experimental-webgl')));
60
+ } catch (e) {
61
+ return false;
62
+ }
63
+ }
64
+ static getWebGLErrorMessage() {
65
+ console.warn('getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead.');
66
+ return this.getErrorMessage(1);
67
+ }
63
68
  }
64
69
  export default WebGL;
@@ -1564,14 +1564,18 @@ class GLTFParser {
1564
1564
  // expensive work of uploading a texture to the GPU off the main thread.
1565
1565
 
1566
1566
  let isSafari = false;
1567
+ let safariVersion = -1;
1567
1568
  let isFirefox = false;
1568
1569
  let firefoxVersion = -1;
1569
1570
  if (typeof navigator !== 'undefined') {
1570
- isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) === true;
1571
- isFirefox = navigator.userAgent.indexOf('Firefox') > -1;
1572
- firefoxVersion = isFirefox ? navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1] : -1;
1573
- }
1574
- if (typeof createImageBitmap === 'undefined' || isSafari || isFirefox && firefoxVersion < 98) {
1571
+ const userAgent = navigator.userAgent;
1572
+ isSafari = /^((?!chrome|android).)*safari/i.test(userAgent) === true;
1573
+ const safariMatch = userAgent.match(/Version\/(\d+)/);
1574
+ safariVersion = isSafari && safariMatch ? parseInt(safariMatch[1], 10) : -1;
1575
+ isFirefox = userAgent.indexOf('Firefox') > -1;
1576
+ firefoxVersion = isFirefox ? userAgent.match(/Firefox\/([0-9]+)\./)[1] : -1;
1577
+ }
1578
+ if (typeof createImageBitmap === 'undefined' || isSafari && safariVersion < 17 || isFirefox && firefoxVersion < 98) {
1575
1579
  this.textureLoader = new TextureLoader(this.options.manager);
1576
1580
  } else {
1577
1581
  this.textureLoader = new ImageBitmapLoader(this.options.manager);
@@ -2135,7 +2139,7 @@ class GLTFParser {
2135
2139
  }
2136
2140
  mesh.material = material;
2137
2141
  }
2138
- getMaterialType( /* materialIndex */
2142
+ getMaterialType(/* materialIndex */
2139
2143
  ) {
2140
2144
  return MeshStandardMaterial;
2141
2145
  }
@@ -120,15 +120,22 @@ class KTX2Loader extends Loader {
120
120
  loader.setResponseType('arraybuffer');
121
121
  loader.setWithCredentials(this.withCredentials);
122
122
  loader.load(url, buffer => {
123
- // Check for an existing task using this buffer. A transferred buffer cannot be transferred
124
- // again from this thread.
125
- if (_taskCache.has(buffer)) {
126
- const cachedTask = _taskCache.get(buffer);
127
- return cachedTask.promise.then(onLoad).catch(onError);
128
- }
129
- this._createTexture(buffer).then(texture => onLoad ? onLoad(texture) : null).catch(onError);
123
+ this.parse(buffer, onLoad, onError);
130
124
  }, onProgress, onError);
131
125
  }
126
+ parse(buffer, onLoad, onError) {
127
+ if (this.workerConfig === null) {
128
+ throw new Error('THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.');
129
+ }
130
+
131
+ // Check for an existing task using this buffer. A transferred buffer cannot be transferred
132
+ // again from this thread.
133
+ if (_taskCache.has(buffer)) {
134
+ const cachedTask = _taskCache.get(buffer);
135
+ return cachedTask.promise.then(onLoad).catch(onError);
136
+ }
137
+ this._createTexture(buffer).then(texture => onLoad ? onLoad(texture) : null).catch(onError);
138
+ }
132
139
  _createTextureFrom(transcodeResult, container) {
133
140
  const {
134
141
  faces,
@@ -231,7 +231,7 @@ class CameraRig extends THREE.Object3D {
231
231
  if (Math.abs(difference) > Math.PI) {
232
232
  this.end.target.rotation.z = this.start.target.rotation.z + difference - Math.sign(difference) * 2 * Math.PI;
233
233
  }
234
- animations.push(new TWEEN.Tween(factor, tweenGroup).to({
234
+ animations.push(new TWEEN.Tween(factor).to({
235
235
  t: 1
236
236
  }, time).easing(params.easing).onUpdate(d => {
237
237
  // rotate to coord destination in geocentric projection
@@ -248,14 +248,15 @@ class CameraRig extends THREE.Object3D {
248
248
 
249
249
  // translate to coordinate destination in planar projection
250
250
  if (view.referenceCrs != 'EPSG:4978') {
251
- animations.push(new TWEEN.Tween(this.position, tweenGroup).to(this.end.position, time).easing(params.easing));
251
+ animations.push(new TWEEN.Tween(this.position).to(this.end.position, time).easing(params.easing));
252
252
  }
253
253
 
254
254
  // translate to altitude zero
255
- animations.push(new TWEEN.Tween(this.seaLevel.position, tweenGroup).to(this.end.seaLevel.position, time).easing(params.easing));
255
+ animations.push(new TWEEN.Tween(this.seaLevel.position).to(this.end.seaLevel.position, time).easing(params.easing));
256
256
 
257
257
  // translate camera position
258
- animations.push(new TWEEN.Tween(this.camera.position, tweenGroup).to(this.end.camera.position, time).easing(params.easing));
258
+ animations.push(new TWEEN.Tween(this.camera.position).to(this.end.camera.position, time).easing(params.easing));
259
+ tweenGroup.add(...animations);
259
260
 
260
261
  // update animations, transformation and view
261
262
  this.animationFrameRequester = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itowns",
3
- "version": "2.44.3-next.1",
3
+ "version": "2.44.3-next.3",
4
4
  "description": "A JS/WebGL framework for 3D geospatial data visualization",
5
5
  "type": "module",
6
6
  "main": "lib/Main.js",
@@ -60,30 +60,30 @@
60
60
  "@mapbox/mapbox-gl-style-spec": "^13.28.0",
61
61
  "@mapbox/vector-tile": "^2.0.3",
62
62
  "@tmcw/togeojson": "^5.8.1",
63
- "@tweenjs/tween.js": "^23.1.2",
64
- "3d-tiles-renderer": "^0.3.37",
63
+ "@tweenjs/tween.js": "^25.0.0",
64
+ "3d-tiles-renderer": "^0.3.38",
65
65
  "brotli-compress": "^1.3.3",
66
66
  "copc": "^0.0.6",
67
67
  "earcut": "^3.0.0",
68
68
  "js-priority-queue": "^0.1.5",
69
69
  "pbf": "^4.0.1",
70
- "shpjs": "^6.0.1",
70
+ "shpjs": "^6.1.0",
71
71
  "threads": "^1.7.0"
72
72
  },
73
73
  "peerDependencies": {
74
- "proj4": "^2.11.0",
75
- "three": "^0.165.0"
74
+ "proj4": "^2.12.1",
75
+ "three": "^0.168.0"
76
76
  },
77
77
  "devDependencies": {
78
- "@babel/cli": "^7.24.8",
79
- "@babel/core": "^7.24.9",
80
- "@babel/plugin-transform-runtime": "^7.24.7",
81
- "@babel/preset-env": "^7.24.8",
78
+ "@babel/cli": "^7.25.6",
79
+ "@babel/core": "^7.25.2",
80
+ "@babel/plugin-transform-runtime": "^7.25.4",
81
+ "@babel/preset-env": "^7.25.4",
82
82
  "@babel/register": "^7.24.6",
83
- "@types/three": "^0.165.0",
84
- "@xmldom/xmldom": "^0.8.10",
83
+ "@types/three": "^0.168.0",
84
+ "@xmldom/xmldom": "^0.9.2",
85
85
  "babel-inline-import-loader": "^1.0.1",
86
- "babel-loader": "^9.1.3",
86
+ "babel-loader": "^9.2.1",
87
87
  "babel-plugin-inline-import": "^3.0.0",
88
88
  "babel-plugin-minify-dead-code-elimination": "^0.5.2",
89
89
  "babel-plugin-minify-replace": "^0.5.0",
@@ -91,34 +91,33 @@
91
91
  "babel-plugin-module-resolver": "^5.0.2",
92
92
  "c8": "^10.1.2",
93
93
  "chalk": "^5.3.0",
94
- "chart.js": "^4.4.3",
94
+ "chart.js": "^4.4.4",
95
95
  "compare-func": "^2.0.0",
96
96
  "conventional-changelog-cli": "^4.1.0",
97
97
  "copyfiles": "^2.4.1",
98
- "core-js": "^3.37.1",
98
+ "core-js": "^3.38.1",
99
99
  "cross-env": "^7.0.3",
100
100
  "eslint": "^8.55.0",
101
101
  "eslint-config-airbnb-base": "^15.0.0",
102
102
  "eslint-import-resolver-babel-module": "^5.3.2",
103
- "eslint-plugin-import": "^2.29.0",
104
- "eslint-webpack-plugin": "^4.0.1",
103
+ "eslint-plugin-import": "^2.30.0",
104
+ "eslint-webpack-plugin": "^4.2.0",
105
105
  "github-url-from-git": "^1.5.0",
106
106
  "grunt": "^1.6.1",
107
107
  "grunt-bump": "^0.8.0",
108
108
  "https-proxy-agent": "^7.0.5",
109
109
  "jsdoc": "^4.0.3",
110
- "mocha": "^10.2.0",
111
- "node-fetch": "^2.7.0",
112
- "proj4": "^2.11.0",
113
- "puppeteer": "^22.13.1",
110
+ "mocha": "^10.7.3",
111
+ "proj4": "^2.12.1",
112
+ "puppeteer": "^23.3.1",
114
113
  "q": "^1.5.1",
115
- "replace-in-file": "^7.2.0",
116
- "sinon": "^18.0.0",
117
- "three": "^0.165.0",
118
- "typescript": "^5.5.2",
114
+ "replace-in-file": "^8.1.0",
115
+ "sinon": "^19.0.2",
116
+ "three": "^0.168.0",
117
+ "typescript": "^5.6.2",
119
118
  "webgl-mock": "^0.1.7",
120
- "webpack": "^5.93.0",
119
+ "webpack": "^5.94.0",
121
120
  "webpack-cli": "^5.1.4",
122
- "webpack-dev-server": "^5.0.4"
121
+ "webpack-dev-server": "^5.1.0"
123
122
  }
124
123
  }