@jdultra/threedtiles 7.0.1 → 7.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jdultra/threedtiles",
3
- "version": "7.0.1",
3
+ "version": "7.0.2",
4
4
  "description": "An OGC 3DTiles viewer for Three.js",
5
5
  "main": "tileset.js",
6
6
  "scripts": {
@@ -43,7 +43,7 @@
43
43
  "html-loader": "^1.3.2",
44
44
  "html-webpack-plugin": "^4.5.0",
45
45
  "mini-css-extract-plugin": "^1.6.2",
46
- "webpack": "^5.75.0",
46
+ "webpack": "^5.76.2",
47
47
  "webpack-cli": "4.9.1",
48
48
  "webpack-dev-server": "^4.11.1",
49
49
  "webpack-glsl-loader": "^1.0.1",
package/src/index.js CHANGED
@@ -80,12 +80,12 @@ function initScene() {
80
80
  scene.matrixAutoUpdate = false;
81
81
  //scene.matrixWorldAutoUpdate = false;
82
82
  scene.background = new THREE.Color(0xE5E3E4);
83
- const dirLight = new THREE.DirectionalLight(0xFFFFFF, 1.0);
84
- dirLight.position.set(100,100,100);
85
- dirLight.lookAt(new THREE.Vector3(0,0,0));
86
- //scene.add(new THREE.AmbientLight(0xFFFFFF, 1.0));
83
+ //const dirLight = new THREE.DirectionalLight(0xFFFFFF, 1.0);
84
+ //dirLight.position.set(100,100,100);
85
+ //dirLight.lookAt(new THREE.Vector3(0,0,0));
86
+ scene.add(new THREE.AmbientLight(0xFFFFFF, 1.0));
87
87
 
88
- scene.add(dirLight)
88
+ //scene.add(dirLight)
89
89
 
90
90
  /* const light = new THREE.PointLight(0xbbbbff, 2, 5000);
91
91
  const sphere = new THREE.SphereGeometry(2, 16, 8);
@@ -162,8 +162,8 @@ function initTileset(scene, gem) {
162
162
 
163
163
  const ogc3DTile = new OGC3DTile({
164
164
  //url: "https://storage.googleapis.com/ogc-3d-tiles/berlinTileset/tileset.json",
165
- //url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tiledWithSkirts/tileset.json",
166
- url: "http://localhost:8080/tileset.json",
165
+ url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tiledWithSkirts/tileset.json",
166
+ //url: "http://localhost:8080/tileset.json",
167
167
  geometricErrorMultiplier: 1,
168
168
  loadOutsideView: true,
169
169
  tileLoader: tileLoader,
@@ -204,19 +204,31 @@ class OGC3DTile extends THREE.Object3D {
204
204
  //scheduleLoadTile(this);
205
205
  }
206
206
  }
207
+
208
+ isAbsolutePathOrURL(input) {
209
+ // Check if it's an absolute URL with various protocols
210
+ const urlRegex = /^(?:http|https|ftp|tcp|udp):\/\/\S+/;
211
+ const absoluteURL = urlRegex.test(input);
212
+
213
+ // Check if it's an absolute path
214
+ const absolutePath = input.startsWith('/') && !input.startsWith('//');
215
+
216
+ return absoluteURL || absolutePath;
217
+ }
218
+
207
219
  load() {
208
220
  var self = this;
209
221
  if (self.deleted) return;
210
222
  if (!!self.json.content) {
211
223
  let url;
212
224
  if (!!self.json.content.uri) {
213
- if (path.isAbsolute(self.json.content.uri)) {
225
+ if (path.isAbsolute(self.json.content.uri) || self.isAbsolutePathOrURL(self.json.content.uri)) {
214
226
  url = self.json.content.uri;
215
227
  } else {
216
228
  url = self.rootPath + path.sep + self.json.content.uri;
217
229
  }
218
230
  } else if (!!self.json.content.url) {
219
- if (path.isAbsolute(self.json.content.url)) {
231
+ if (path.isAbsolute(self.json.content.url) || self.isAbsolutePathOrURL(self.json.content.url)) {
220
232
  url = self.json.content.url;
221
233
  } else {
222
234
  url = self.rootPath + path.sep + self.json.content.url;
@@ -193,19 +193,30 @@ class InstancedTile extends THREE.Object3D {
193
193
  //scheduleLoadTile(this);
194
194
  }
195
195
  }
196
+
197
+ isAbsolutePathOrURL(input) {
198
+ // Check if it's an absolute URL with various protocols
199
+ const urlRegex = /^(?:http|https|ftp|tcp|udp):\/\/\S+/;
200
+ const absoluteURL = urlRegex.test(input);
201
+
202
+ // Check if it's an absolute path
203
+ const absolutePath = input.startsWith('/') && !input.startsWith('//');
204
+
205
+ return absoluteURL || absolutePath;
206
+ }
196
207
  load() {
197
208
  var self = this;
198
209
  if (self.deleted) return;
199
210
  if (!!self.json.content) {
200
211
  let url;
201
212
  if (!!self.json.content.uri) {
202
- if (path.isAbsolute(self.json.content.uri)) {
213
+ if (path.isAbsolute(self.json.content.uri) || self.isAbsolutePathOrURL(self.json.content.uri)) {
203
214
  url = self.json.content.uri;
204
215
  } else {
205
216
  url = self.rootPath + path.sep + self.json.content.uri;
206
217
  }
207
218
  } else if (!!self.json.content.url) {
208
- if (path.isAbsolute(self.json.content.url)) {
219
+ if (path.isAbsolute(self.json.content.url) || self.isAbsolutePathOrURL(self.json.content.url)) {
209
220
  url = self.json.content.url;
210
221
  } else {
211
222
  url = self.rootPath + path.sep + self.json.content.url;
package/threedtiles.js CHANGED
@@ -12551,6 +12551,17 @@ var OGC3DTile = /*#__PURE__*/function (_THREE$Object3D) {
12551
12551
  //scheduleLoadTile(this);
12552
12552
  }
12553
12553
  }
12554
+ }, {
12555
+ key: "isAbsolutePathOrURL",
12556
+ value: function isAbsolutePathOrURL(input) {
12557
+ // Check if it's an absolute URL with various protocols
12558
+ var urlRegex = /^(?:http|https|ftp|tcp|udp):\/\/\S+/;
12559
+ var absoluteURL = urlRegex.test(input);
12560
+
12561
+ // Check if it's an absolute path
12562
+ var absolutePath = input.startsWith('/') && !input.startsWith('//');
12563
+ return absoluteURL || absolutePath;
12564
+ }
12554
12565
  }, {
12555
12566
  key: "load",
12556
12567
  value: function load() {
@@ -12559,13 +12570,13 @@ var OGC3DTile = /*#__PURE__*/function (_THREE$Object3D) {
12559
12570
  if (!!self.json.content) {
12560
12571
  var url;
12561
12572
  if (!!self.json.content.uri) {
12562
- if (path_browserify__WEBPACK_IMPORTED_MODULE_2__.isAbsolute(self.json.content.uri)) {
12573
+ if (path_browserify__WEBPACK_IMPORTED_MODULE_2__.isAbsolute(self.json.content.uri) || self.isAbsolutePathOrURL(self.json.content.uri)) {
12563
12574
  url = self.json.content.uri;
12564
12575
  } else {
12565
12576
  url = self.rootPath + path_browserify__WEBPACK_IMPORTED_MODULE_2__.sep + self.json.content.uri;
12566
12577
  }
12567
12578
  } else if (!!self.json.content.url) {
12568
- if (path_browserify__WEBPACK_IMPORTED_MODULE_2__.isAbsolute(self.json.content.url)) {
12579
+ if (path_browserify__WEBPACK_IMPORTED_MODULE_2__.isAbsolute(self.json.content.url) || self.isAbsolutePathOrURL(self.json.content.url)) {
12569
12580
  url = self.json.content.url;
12570
12581
  } else {
12571
12582
  url = self.rootPath + path_browserify__WEBPACK_IMPORTED_MODULE_2__.sep + self.json.content.url;
@@ -13786,6 +13797,17 @@ var InstancedTile = /*#__PURE__*/function (_THREE$Object3D) {
13786
13797
  //scheduleLoadTile(this);
13787
13798
  }
13788
13799
  }
13800
+ }, {
13801
+ key: "isAbsolutePathOrURL",
13802
+ value: function isAbsolutePathOrURL(input) {
13803
+ // Check if it's an absolute URL with various protocols
13804
+ var urlRegex = /^(?:http|https|ftp|tcp|udp):\/\/\S+/;
13805
+ var absoluteURL = urlRegex.test(input);
13806
+
13807
+ // Check if it's an absolute path
13808
+ var absolutePath = input.startsWith('/') && !input.startsWith('//');
13809
+ return absoluteURL || absolutePath;
13810
+ }
13789
13811
  }, {
13790
13812
  key: "load",
13791
13813
  value: function load() {
@@ -13794,13 +13816,13 @@ var InstancedTile = /*#__PURE__*/function (_THREE$Object3D) {
13794
13816
  if (!!self.json.content) {
13795
13817
  var url;
13796
13818
  if (!!self.json.content.uri) {
13797
- if (path_browserify__WEBPACK_IMPORTED_MODULE_1__.isAbsolute(self.json.content.uri)) {
13819
+ if (path_browserify__WEBPACK_IMPORTED_MODULE_1__.isAbsolute(self.json.content.uri) || self.isAbsolutePathOrURL(self.json.content.uri)) {
13798
13820
  url = self.json.content.uri;
13799
13821
  } else {
13800
13822
  url = self.rootPath + path_browserify__WEBPACK_IMPORTED_MODULE_1__.sep + self.json.content.uri;
13801
13823
  }
13802
13824
  } else if (!!self.json.content.url) {
13803
- if (path_browserify__WEBPACK_IMPORTED_MODULE_1__.isAbsolute(self.json.content.url)) {
13825
+ if (path_browserify__WEBPACK_IMPORTED_MODULE_1__.isAbsolute(self.json.content.url) || self.isAbsolutePathOrURL(self.json.content.url)) {
13804
13826
  url = self.json.content.url;
13805
13827
  } else {
13806
13828
  url = self.rootPath + path_browserify__WEBPACK_IMPORTED_MODULE_1__.sep + self.json.content.url;
@@ -22880,12 +22902,12 @@ function initScene() {
22880
22902
  scene.matrixAutoUpdate = false;
22881
22903
  //scene.matrixWorldAutoUpdate = false;
22882
22904
  scene.background = new three__WEBPACK_IMPORTED_MODULE_7__.Color(0xE5E3E4);
22883
- var dirLight = new three__WEBPACK_IMPORTED_MODULE_7__.DirectionalLight(0xFFFFFF, 1.0);
22884
- dirLight.position.set(100, 100, 100);
22885
- dirLight.lookAt(new three__WEBPACK_IMPORTED_MODULE_7__.Vector3(0, 0, 0));
22886
- //scene.add(new THREE.AmbientLight(0xFFFFFF, 1.0));
22905
+ //const dirLight = new THREE.DirectionalLight(0xFFFFFF, 1.0);
22906
+ //dirLight.position.set(100,100,100);
22907
+ //dirLight.lookAt(new THREE.Vector3(0,0,0));
22908
+ scene.add(new three__WEBPACK_IMPORTED_MODULE_7__.AmbientLight(0xFFFFFF, 1.0));
22887
22909
 
22888
- scene.add(dirLight);
22910
+ //scene.add(dirLight)
22889
22911
 
22890
22912
  /* const light = new THREE.PointLight(0xbbbbff, 2, 5000);
22891
22913
  const sphere = new THREE.SphereGeometry(2, 16, 8);
@@ -22945,8 +22967,8 @@ function initTileset(scene, gem) {
22945
22967
  });
22946
22968
  var ogc3DTile = new _tileset_OGC3DTile__WEBPACK_IMPORTED_MODULE_1__.OGC3DTile({
22947
22969
  //url: "https://storage.googleapis.com/ogc-3d-tiles/berlinTileset/tileset.json",
22948
- //url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tiledWithSkirts/tileset.json",
22949
- url: "http://localhost:8080/tileset.json",
22970
+ url: "https://storage.googleapis.com/ogc-3d-tiles/ayutthaya/tiledWithSkirts/tileset.json",
22971
+ //url: "http://localhost:8080/tileset.json",
22950
22972
  geometricErrorMultiplier: 1,
22951
22973
  loadOutsideView: true,
22952
22974
  tileLoader: tileLoader,