itowns 2.44.3-next.36 → 2.44.3-next.38

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.
@@ -50,8 +50,8 @@
50
50
  <script type="importmap">
51
51
  {
52
52
  "imports": {
53
- "three": "https://cdn.jsdelivr.net/npm/three@0.165.0/build/three.module.js",
54
- "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.165.0/examples/jsm/"
53
+ "three": "https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js",
54
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"
55
55
  }
56
56
  }
57
57
  </script>
@@ -19,7 +19,7 @@
19
19
  </head>
20
20
  <body>
21
21
  <div id="description">Specify the URL of a COPC file to load:
22
- <input type="text" id="url" />
22
+ <input type="text" id="copc_url" />
23
23
  <button onclick="readURL()">Load</button>
24
24
  <div>
25
25
  <button onClick="loadAutzen()">Load Autzen Stadium (80mb)</button>
@@ -71,7 +71,7 @@
71
71
 
72
72
 
73
73
  function readURL() {
74
- const url = document.getElementById('url').value;
74
+ const url = document.getElementById('copc_url').value;
75
75
 
76
76
  if (url) {
77
77
  setUrl(url);
@@ -81,7 +81,7 @@
81
81
  function setUrl(url) {
82
82
  if (!url) return;
83
83
 
84
- const input_url = document.getElementById('url');
84
+ const input_url = document.getElementById('copc_url');
85
85
  if (!input_url) return;
86
86
 
87
87
  uri.searchParams.set('copc', url);
@@ -93,6 +93,13 @@
93
93
 
94
94
 
95
95
  function load(url) {
96
+ const options = {};
97
+ const urlParams = uri.searchParams
98
+ urlParams.keys().forEach(key => {
99
+ if (key !== 'copc') {
100
+ options[key] = parseInt(urlParams.get(key), 10);
101
+ }
102
+ });
96
103
  const source = new itowns.CopcSource({ url });
97
104
 
98
105
  if (layer) {
@@ -102,12 +109,15 @@
102
109
  layer.delete();
103
110
  }
104
111
 
105
- layer = new itowns.CopcLayer('COPC', {
112
+ const config = {
106
113
  source,
107
114
  crs: view.referenceCrs,
108
115
  sseThreshold: 2,
109
116
  pointBudget: 3000000,
110
- });
117
+ ...options,
118
+ };
119
+
120
+ layer = new itowns.CopcLayer('COPC', config);
111
121
  view.addLayer(layer).then(onLayerReady);
112
122
  layer.whenReady
113
123
  .then(() => debug.PointCloudDebug.initTools(view, layer, gui));
@@ -23,8 +23,8 @@
23
23
  <script type="importmap">
24
24
  {
25
25
  "imports": {
26
- "three": "https://cdn.jsdelivr.net/npm/three@0.159.0/build/three.module.js",
27
- "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.159.0/examples/jsm/"
26
+ "three": "https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js",
27
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"
28
28
  }
29
29
  }
30
30
  </script>
@@ -25,8 +25,8 @@
25
25
  <script type="importmap">
26
26
  {
27
27
  "imports": {
28
- "three": "https://cdn.jsdelivr.net/npm/three@0.159.0/build/three.module.js",
29
- "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.159.0/examples/jsm/"
28
+ "three": "https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js",
29
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"
30
30
  }
31
31
  }
32
32
  </script>
@@ -14,7 +14,7 @@
14
14
  <script type="importmap">
15
15
  {
16
16
  "imports": {
17
- "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.159.0/examples/jsm/"
17
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"
18
18
  }
19
19
  }
20
20
  </script>
@@ -43,6 +43,8 @@
43
43
  const view = new itowns.GlobeView(viewerDiv, placement, {
44
44
  webXR: { scale: 0.005 },
45
45
  });
46
+ // Temporary workaround to https://github.com/iTowns/itowns/issues/2473
47
+ view.scene.matrixWorldAutoUpdate = true;
46
48
 
47
49
  // Instantiate three's VR Button
48
50
  const vrButton = VRButton.createButton(view.renderer);
@@ -17,8 +17,8 @@
17
17
  <script type="importmap">
18
18
  {
19
19
  "imports": {
20
- "three": "https://cdn.jsdelivr.net/npm/three@0.159.0/build/three.module.js",
21
- "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.159.0/examples/jsm/"
20
+ "three": "https://cdn.jsdelivr.net/npm/three@0.170.0/build/three.module.js",
21
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.170.0/examples/jsm/"
22
22
  }
23
23
  }
24
24
  </script>
@@ -49,8 +49,8 @@ class CopcLayer extends PointCloudLayer {
49
49
  this.root = new CopcNode(0, 0, 0, 0, pageOffset, pageLength, this, -1);
50
50
  this.root.bbox.min.fromArray(cube, 0);
51
51
  this.root.bbox.max.fromArray(cube, 3);
52
- this.minElevationRange = source.header.min[2];
53
- this.maxElevationRange = source.header.max[2];
52
+ this.minElevationRange = this.minElevationRange ?? source.header.min[2];
53
+ this.maxElevationRange = this.maxElevationRange ?? source.header.max[2];
54
54
  this.scale = new THREE.Vector3(1.0, 1.0, 1.0);
55
55
  this.offset = new THREE.Vector3(0.0, 0.0, 0.0);
56
56
  return this.root.loadOctree().then(resolve);
@@ -58,8 +58,8 @@ class EntwinePointTileLayer extends PointCloudLayer {
58
58
  this.root = new EntwinePointTileNode(0, 0, 0, 0, this, -1);
59
59
  this.root.bbox.min.fromArray(this.source.boundsConforming, 0);
60
60
  this.root.bbox.max.fromArray(this.source.boundsConforming, 3);
61
- this.minElevationRange = this.source.boundsConforming[2];
62
- this.maxElevationRange = this.source.boundsConforming[5];
61
+ this.minElevationRange = this.minElevationRange ?? this.source.boundsConforming[2];
62
+ this.maxElevationRange = this.maxElevationRange ?? this.source.boundsConforming[5];
63
63
  this.extent = Extent.fromBox3(config.crs || 'EPSG:4326', this.root.bbox);
64
64
  return this.root.loadOctree().then(resolve);
65
65
  });
@@ -1,5 +1,8 @@
1
1
  import * as THREE from 'three';
2
- import { TilesRenderer, GLTFStructuralMetadataExtension, GLTFMeshFeaturesExtension, GLTFCesiumRTCExtension, CesiumIonAuthPlugin, GoogleCloudAuthPlugin, ImplicitTilingPlugin } from '3d-tiles-renderer';
2
+ import { TilesRenderer } from '3d-tiles-renderer';
3
+ import { GLTFStructuralMetadataExtension, GLTFMeshFeaturesExtension, GLTFCesiumRTCExtension, CesiumIonAuthPlugin, GoogleCloudAuthPlugin, ImplicitTilingPlugin
4
+ // eslint-disable-next-line import/no-unresolved
5
+ } from '3d-tiles-renderer/plugins';
3
6
  import GeometryLayer from "./GeometryLayer.js";
4
7
  import iGLTFLoader from "../Parser/iGLTFLoader.js";
5
8
  import { DRACOLoader } from "../ThreeExtended/loaders/DRACOLoader.js";
@@ -130,7 +130,9 @@ class PointCloudLayer extends GeometryLayer {
130
130
  * contains three elements `name, protocol, extent`, these elements will be
131
131
  * available using `layer.name` or something else depending on the property
132
132
  * name. See the list of properties to know which one can be specified.
133
- * @param {Source} config.source - Description and options of the source.
133
+ * @param {Source} config.source - Description and options of the source See @Layer.
134
+ * @param {number} [options.minElevationRange] - Min value for the elevation range (default value will be taken from the source.metadata).
135
+ * @param {number} [options.maxElevationRange] - Max value for the elevation range (default value will be taken from the source.metadata).
134
136
  */
135
137
  constructor(id) {
136
138
  let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -144,8 +146,8 @@ class PointCloudLayer extends GeometryLayer {
144
146
  sseThreshold = 2,
145
147
  minIntensityRange = 1,
146
148
  maxIntensityRange = 65536,
147
- minElevationRange = 0,
148
- maxElevationRange = 1000,
149
+ minElevationRange,
150
+ maxElevationRange,
149
151
  minAngleRange = -90,
150
152
  maxAngleRange = 90,
151
153
  material = {},
@@ -154,6 +154,8 @@ class Potree2Layer extends PointCloudLayer {
154
154
  const root = new Potree2Node(0, 0, this);
155
155
  root.bbox = boundingBox;
156
156
  root.boundingSphere = boundingBox.getBoundingSphere(new THREE.Sphere());
157
+ this.minElevationRange = this.minElevationRange ?? metadata.boundingBox.min[2];
158
+ this.maxElevationRange = this.maxElevationRange ?? metadata.boundingBox.max[2];
157
159
  root.id = 'r';
158
160
  root.depth = 0;
159
161
  root.nodeType = 2;
@@ -62,6 +62,8 @@ class PotreeLayer extends PointCloudLayer {
62
62
  this.root = new PotreeNode(0, 0, this);
63
63
  this.root.bbox.min.set(cloud.boundingBox.lx, cloud.boundingBox.ly, cloud.boundingBox.lz);
64
64
  this.root.bbox.max.set(cloud.boundingBox.ux, cloud.boundingBox.uy, cloud.boundingBox.uz);
65
+ this.minElevationRange = this.minElevationRange ?? cloud.boundingBox.lz;
66
+ this.maxElevationRange = this.maxElevationRange ?? cloud.boundingBox.uz;
65
67
  this.extent = Extent.fromBox3(this.source.crs || 'EPSG:4326', this.root.bbox);
66
68
  return this.root.loadOctree().then(resolve);
67
69
  });
@@ -262,10 +262,7 @@ class PointsMaterial extends THREE.ShaderMaterial {
262
262
  * @param {number} [options.mode=PNTS_MODE.COLOR] display mode.
263
263
  * @param {number} [options.shape=PNTS_SHAPE.CIRCLE] rendered points shape.
264
264
  * @param {THREE.Vector4} [options.overlayColor=new THREE.Vector4(0, 0, 0, 0)] overlay color.
265
- * @param {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range.
266
- * @param {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range.
267
- * @param {THREE.Vector2} [options.angleRange=new THREE.Vector2(-90, 90)] scan angle range.
268
- * @param {Scheme} [options.classificationScheme] LUT for point classification colorization.
265
+ * @param {Scheme} [options.classificationScheme] LUT for point classification colorization.
269
266
  * @param {Scheme} [options.discreteScheme] LUT for other discret point values colorization.
270
267
  * @param {string} [options.gradient] Descrition of the gradient to use for continuous point values.
271
268
  * (Default value will be the 'SPECTRAL' gradient from Utils/Gradients)
@@ -273,6 +270,9 @@ class PointsMaterial extends THREE.ShaderMaterial {
273
270
  * @param {number} [options.minAttenuatedSize=3] minimum scale used by 'ATTENUATED' size mode
274
271
  * @param {number} [options.maxAttenuatedSize=10] maximum scale used by 'ATTENUATED' size mode
275
272
  *
273
+ * @property {THREE.Vector2} [options.intensityRange=new THREE.Vector2(1, 65536)] intensity range (default value will be [1, 65536] if not defined at Layer level).
274
+ * @property {THREE.Vector2} [options.elevationRange=new THREE.Vector2(0, 1000)] elevation range (default value will be [0, 1000] if not defined at Layer level).
275
+ * @property {THREE.Vector2} [options.angleRange=new THREE.Vector2(-90, 90)] scan angle range (default value will be [-90, 90] if not defined at Layer level).
276
276
  * @property {Scheme} classificationScheme - Color scheme for point classification values.
277
277
  * @property {Scheme} discreteScheme - Color scheme for all other discrete values.
278
278
  * @property {object} gradients - Descriptions of all available gradients.