@maptalks/3dtiles 0.12.5 → 0.12.6

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @maptalks/3dtiles v0.12.5
2
+ * @maptalks/3dtiles v0.12.6
3
3
  * LICENSE : UNLICENSED
4
4
  * (c) 2016-2022 maptalks.com
5
5
  */
@@ -4722,7 +4722,7 @@
4722
4722
  draw(t, e) {
4723
4723
  const n = this.prepareCanvas();
4724
4724
  if (n && !n.intersects(this.canvasExtent2D)) return void this.completeRender();
4725
- const {root: r, tiles: s} = this.layer.getTiles(), i = s ? Object.keys(s).length : 0;
4725
+ const {root: r, tiles: s} = this.layer.getTiles(), i = s.length;
4726
4726
  if (!s || !i) return void this.completeRender();
4727
4727
  this.Be();
4728
4728
  const {selectedTiles: o, leaves: a, requests: c} = this.Ue(r, s);
@@ -4734,7 +4734,7 @@
4734
4734
  let r = 0;
4735
4735
  const s = this.De(), i = {};
4736
4736
  let o = !1, a = !1;
4737
- for (const t in e) {
4737
+ for (let t = 0; t < e.length; t++) {
4738
4738
  const s = e[t], c = s.node;
4739
4739
  if (i[c.id]) continue;
4740
4740
  i[c.id] = 1;
@@ -4806,13 +4806,13 @@
4806
4806
  for (;r.length > 0; ) {
4807
4807
  const s = r.pop().children;
4808
4808
  for (let i = 0, o = s.length; i < o; i++) {
4809
- if (!this.layer.$e(s[i]) && s[i].children && s[i].children.length) {
4809
+ if ((!s[i].content || !s[i].content.url) && s[i].children && s[i].children.length) {
4810
4810
  r.push(s[i]);
4811
4811
  continue;
4812
4812
  }
4813
4813
  const o = s[i].id;
4814
4814
  if (this.tileCache.has(o)) {
4815
- const n = this.layer.Je(s[i], t);
4815
+ const n = this.layer.$e(s[i], t);
4816
4816
  n.selected = !0, n.data = this.tileCache.get(o), t.children.push(n), e.push(n);
4817
4817
  } else s[i].qe <= n && r.push(s[i]);
4818
4818
  }
@@ -4853,7 +4853,7 @@
4853
4853
  let e = t.content.url;
4854
4854
  if (M(e)) {
4855
4855
  const n = S(e);
4856
- return void this.Ke(e, n, t);
4856
+ return void this.Je(e, n, t);
4857
4857
  }
4858
4858
  t && -1 === e.indexOf("http://") && -1 === e.indexOf("https://") && (e = t.baseUrl + e);
4859
4859
  const n = this.layer.options.services[t.te];
@@ -4863,13 +4863,13 @@
4863
4863
  let s = ft.getArrayBuffer(e + (r || ""), n.ajaxOptions);
4864
4864
  const i = s.xhr;
4865
4865
  s = s.then(n => {
4866
- delete this.bt[e], n ? this.Ke(e, n.data, t) : this.onTileError(null, t);
4866
+ delete this.bt[e], n ? this.Je(e, n.data, t) : this.onTileError(null, t);
4867
4867
  }).catch(n => {
4868
4868
  delete this.bt[e], this.onTileError(n, t);
4869
4869
  }), this.bt[e] = i;
4870
- } else this.Ke(e, null, t);
4870
+ } else this.Je(e, null, t);
4871
4871
  }
4872
- Ke(t, e, r) {
4872
+ Je(t, e, r) {
4873
4873
  let s = this.o;
4874
4874
  s || (s = n.reshader.Util.getSupportedFormats(this.gl.gl || this.gl), this.o = s),
4875
4875
  this.workerConn.loadTile(this.layer.getId(), {
@@ -4894,29 +4894,29 @@
4894
4894
  for (;this.Le.length && (n < e || !t.isInteracting()); ) {
4895
4895
  const {data: t, tile: e} = this.Le.shift(), {magic: r} = t;
4896
4896
  "b3dm" === r ? this.painter.createB3DMMesh(t, e.id, e, (n, {mesh: r}) => {
4897
- this.Xe(t, e, n, r);
4897
+ this.Ke(t, e, n, r);
4898
4898
  }) : "pnts" === r ? this.painter.createPntsMesh(t, e.id, e, (n, {mesh: r}) => {
4899
- this.Xe(t, e, n, r);
4899
+ this.Ke(t, e, n, r);
4900
4900
  }) : "i3dm" === r ? this.painter.createI3DMMesh(t, e.id, e, (n, {mesh: r}) => {
4901
- this.Xe(t, e, n, r);
4901
+ this.Ke(t, e, n, r);
4902
4902
  }) : "cmpt" === r && this.painter.createCMPTMesh(t, e.id, e, (n, {mesh: r}) => {
4903
- this.Xe(t, e, n, r);
4903
+ this.Ke(t, e, n, r);
4904
4904
  }), n++;
4905
4905
  }
4906
4906
  }
4907
- Xe(t, e, n, r) {
4907
+ Ke(t, e, n, r) {
4908
4908
  if (n) this.onTileError(n, e); else {
4909
- const n = this.We(r);
4909
+ const n = this.Xe(r);
4910
4910
  e.memorySize = n, this.onTileLoad(t, e);
4911
4911
  }
4912
4912
  }
4913
- We(t) {
4913
+ Xe(t) {
4914
4914
  let e = 0;
4915
- if (Array.isArray(t)) for (let n = 0; n < t.length; n++) t[n] && (e += this.We(t[n])); else t && (e += t.getMemorySize());
4915
+ if (Array.isArray(t)) for (let n = 0; n < t.length; n++) t[n] && (e += this.Xe(t[n])); else t && (e += t.getMemorySize());
4916
4916
  return e;
4917
4917
  }
4918
4918
  onTileLoad(t, e) {
4919
- this.layer && (delete this.tilesLoading[e.id], this.Ze(e), this.setToRedraw(), this.layer.fire("tileload", {
4919
+ this.layer && (delete this.tilesLoading[e.id], this.We(e), this.setToRedraw(), this.layer.fire("tileload", {
4920
4920
  node: e
4921
4921
  }));
4922
4922
  }
@@ -4927,7 +4927,7 @@
4927
4927
  if (!this.layer) return;
4928
4928
  const n = e.content.url;
4929
4929
  console.warn("failed to load 3d tile: " + n), console.warn(t), delete this.tilesLoading[e.id],
4930
- this.Ze(e), this.setToRedraw(), this.layer.fire("tileerror", {
4930
+ this.We(e), this.setToRedraw(), this.layer.fire("tileerror", {
4931
4931
  node: e,
4932
4932
  error: t
4933
4933
  });
@@ -4935,7 +4935,7 @@
4935
4935
  ke(t) {
4936
4936
  return this.tileCache.get(t);
4937
4937
  }
4938
- Ze(t) {
4938
+ We(t) {
4939
4939
  const e = {
4940
4940
  loadTime: s.Util.now(),
4941
4941
  current: !0,
@@ -4967,7 +4967,7 @@
4967
4967
  antialias: t.options.antialias
4968
4968
  };
4969
4969
  this.canvas.gl && this.canvas.gl.wrap ? (this.gl = this.canvas.gl.wrap(), this.regl = this.canvas.gl.regl) : (this.glOptions = e,
4970
- this.gl = this.Qe(this.canvas, e)), this.regl = this.regl || n.createREGL({
4970
+ this.gl = this.Ze(this.canvas, e)), this.regl = this.regl || n.createREGL({
4971
4971
  gl: this.gl,
4972
4972
  attributes: e,
4973
4973
  extensions: [ "OES_element_index_uint", "WEBGL_compressed_texture_s3tc" ],
@@ -5010,10 +5010,10 @@
5010
5010
  return 0;
5011
5011
  }
5012
5012
  Re(t) {
5013
- this.Ye || (this.Ye = Date.now());
5013
+ this.Qe || (this.Qe = Date.now());
5014
5014
  const e = Date.now();
5015
- if (t || !(e - this.Ye < this.layer.options.retireInterval)) {
5016
- this.Ye = e;
5015
+ if (t || !(e - this.Qe < this.layer.options.retireInterval)) {
5016
+ this.Qe = e;
5017
5017
  for (const e in this.tilesLoading) {
5018
5018
  const n = this.tilesLoading[e];
5019
5019
  !t && n.current || this.abortTileLoading(n);
@@ -5023,7 +5023,7 @@
5023
5023
  De() {
5024
5024
  return this.getMap().isInteracting() ? this.layer.options.loadingLimitOnInteracting : this.layer.options.loadingLimit;
5025
5025
  }
5026
- Qe(t, e) {
5026
+ Ze(t, e) {
5027
5027
  const n = [ "webgl", "experimental-webgl" ];
5028
5028
  let r = null;
5029
5029
  for (let s = 0; s < n.length; ++s) {
@@ -5051,7 +5051,7 @@
5051
5051
  }
5052
5052
  }
5053
5053
  function wn(t, e) {
5054
- return 0 === t.ce && 0 === e.ce ? t.tn - e.tn : t.ce - e.ce;
5054
+ return 0 === t.ce && 0 === e.ce ? t.Ye - e.Ye : t.ce - e.ce;
5055
5055
  }
5056
5056
  function _n(t, e, n) {
5057
5057
  return t[0] = e[n], t[1] = e[n + 3], t[2] = e[n + 6], t;
@@ -5070,14 +5070,14 @@
5070
5070
  }(t, e, n));
5071
5071
  }
5072
5072
  const Tn = [], An = [], On = [], vn = [], Mn = [];
5073
- const Sn = s.projection.EPSG3857, xn = new s.Extent(0, 0, 0, 0), In = [], Nn = [], En = [], Pn = new s.Coordinate(0, 0), Ln = n.mat4.identity([]);
5074
- class Bn extends s.Layer {
5073
+ const Sn = s.projection.EPSG3857, xn = new s.Extent(0, 0, 0, 0), In = new s.Extent(0, 0, 0, 0), Nn = [], En = [], Pn = [], Ln = [], Bn = new s.Point(0, 0), Un = [], Cn = new s.Coordinate(0, 0), Rn = n.mat4.identity([]);
5074
+ class Fn extends s.Layer {
5075
5075
  constructor(t, e) {
5076
- super(t, e), this.en(), this.bt = {}, this.nn = {};
5076
+ super(t, e), this.tn(), this.bt = {}, this.en = {};
5077
5077
  }
5078
- en() {
5078
+ tn() {
5079
5079
  let t = this.options.services.map(t => t.url);
5080
- this.rn = t.map((t, e) => function(t, e) {
5080
+ this.nn = t.map((t, e) => function(t, e) {
5081
5081
  t = w(t);
5082
5082
  return {
5083
5083
  baseUrl: t.substring(0, t.lastIndexOf("/")) + "/",
@@ -5090,22 +5090,22 @@
5090
5090
  qe: 0
5091
5091
  };
5092
5092
  }(t, e)), this.fire("rootready", {
5093
- roots: this.rn.slice(0)
5093
+ roots: this.nn.slice(0)
5094
5094
  });
5095
5095
  }
5096
5096
  getExtent(t) {
5097
5097
  if (!t && 0 !== t) {
5098
5098
  const t = new s.Extent;
5099
- for (let e = 0; e < this.rn.length; e++) if (this.rn[e].boundingVolume) {
5100
- const n = this.boundingVolumeToExtent(this.rn[e]);
5099
+ for (let e = 0; e < this.nn.length; e++) if (this.nn[e].boundingVolume) {
5100
+ const n = this.boundingVolumeToExtent(this.nn[e]);
5101
5101
  t._combine(n);
5102
5102
  }
5103
5103
  return t;
5104
5104
  }
5105
- return this.rn[t] && this.rn[t].boundingVolume ? this.boundingVolumeToExtent(this.rn[t]) : null;
5105
+ return this.nn[t] && this.nn[t].boundingVolume ? this.boundingVolumeToExtent(this.nn[t]) : null;
5106
5106
  }
5107
5107
  boundingVolumeToExtent(t) {
5108
- const e = t.boundingVolume.sn ? Ln : t.matrix, r = this.getMap();
5108
+ const e = t.boundingVolume.rn ? Rn : t.matrix, r = this.getMap();
5109
5109
  if (t.boundingVolume.region) {
5110
5110
  const e = t.boundingVolume.region;
5111
5111
  return new s.Extent(p(e[0]), p(e[1]), p(e[2]), p(e[3]));
@@ -5123,57 +5123,58 @@
5123
5123
  return null;
5124
5124
  }
5125
5125
  getRootTiles() {
5126
- return this.rn;
5126
+ return this.nn;
5127
5127
  }
5128
5128
  getTiles() {
5129
- return this.getRenderer().ready ? this.in() : (this.an(), {
5130
- tiles: null
5129
+ return this.getRenderer().ready ? this.sn() : (this.in(), {
5130
+ tiles: Ln
5131
5131
  });
5132
5132
  }
5133
- in() {
5133
+ sn() {
5134
5134
  const t = this.getMap(), e = t.cameraPosition;
5135
5135
  let r, s;
5136
- if (t.getGLZoom) s = t.pointToDistance(e[2], 0, t.getGLZoom()), Pn.set(e[0], e[1]),
5137
- r = t.pointToCoord(Pn, t.getGLZoom()); else {
5136
+ if (t.getGLZoom) s = t.pointToDistance(e[2], 0, t.getGLZoom()), Cn.set(e[0], e[1]),
5137
+ r = t.pointToCoord(Cn, t.getGLZoom()); else {
5138
5138
  const n = t.getGLRes();
5139
- s = t.pointAtResToDistance(e[2], 0, n), Pn.set(e[0], e[1]), r = t.pointAtResToCoord(Pn, n);
5139
+ s = t.pointAtResToDistance(e[2], 0, n), Cn.set(e[0], e[1]), r = t.pointAtResToCoord(Cn, n);
5140
5140
  }
5141
- this.cn = this.cn || [], n.vec3.set(this.cn, b(r.x), b(r.y), s), this.hn = Kt(this.hn || [], this.cn[0], this.cn[1], this.cn[2]),
5142
- this.un = 2 * Math.tan(.5 * b(t.getFov())), this.ln = Sn.project(r).toArray();
5141
+ this.an = this.an || [], n.vec3.set(this.an, b(r.x), b(r.y), s), this.cn = Kt(this.cn || [], this.an[0], this.an[1], this.an[2]),
5142
+ this.hn = 2 * Math.tan(.5 * b(t.getFov())), this.un = Sn.project(r).toArray();
5143
5143
  const i = t.projViewMatrix, o = {
5144
5144
  children: [],
5145
5145
  level: -1
5146
5146
  };
5147
5147
  let a = o;
5148
- const c = {};
5149
- for (let t = 0; t < this.rn.length; t++) {
5148
+ const c = [];
5149
+ for (let t = 0; t < this.nn.length; t++) {
5150
5150
  let e = 1 / 0;
5151
- const n = [ this.rn[t] ], r = this.dn(t);
5151
+ const n = [ this.nn[t] ], r = this.ln(t);
5152
5152
  for (;n.length > 0; ) {
5153
5153
  const t = n.pop();
5154
- for (this.mn(t); a.level >= t.qe; ) a = a.parent;
5155
- const s = this.yn(t, r, i);
5154
+ for (t.id || this.dn(t); a.level >= t.qe; ) a = a.parent;
5155
+ const s = this.mn(t, r, i);
5156
5156
  if (s < 1) {
5157
5157
  let n = a;
5158
5158
  for (;n && !n.content; ) n = n.parent;
5159
- 0 === s && n && n.content && (t.bn = n, this.pn(c, n));
5159
+ 0 === s && n && n.content && this.yn(c, n);
5160
5160
  if (!1 === this.options.services[t.te].alwaysShow) continue;
5161
5161
  if (!(0 === s && t.qe <= e)) continue;
5162
5162
  t.content && (e = t.qe);
5163
5163
  }
5164
- t.ce < 1 / 0 && this.wn(t);
5165
- const o = this.Je(t, a);
5164
+ t.ce < 1 / 0 && this.bn(t);
5165
+ const o = this.$e(t, a);
5166
5166
  a.children.push(o);
5167
5167
  const h = t.children, u = h && h.length, f = o.content;
5168
- if (!u && f && this.pn(c, o), u) {
5169
- f && "add" === t.refine && this.pn(c, o), a = o;
5170
- for (let e = 0, r = h.length; e < r; e++) {
5171
- if (!h[e].parent) {
5172
- h[e].parent = t, h[e].Te = t.Te, h[e].baseUrl = t.baseUrl;
5173
- const n = h[e].content && (h[e].content.url || h[e].content.uri);
5174
- n && (M(n) ? h[e].baseUrl = t.baseUrl : -1 === n.indexOf("http://") && -1 === n.indexOf("https://") ? h[e].content.url = t.baseUrl + n : h[e].baseUrl = n.substring(0, n.lastIndexOf("/") + 1));
5168
+ if (!u && f && this.yn(c, o), u) {
5169
+ f && "add" === t.refine && this.yn(c, o), a = o;
5170
+ const e = h[0].parent;
5171
+ for (let r = 0, s = h.length; r < s; r++) {
5172
+ if (!e) {
5173
+ h[r].parent = t, h[r].Te = t.Te, h[r].baseUrl = t.baseUrl;
5174
+ const e = h[r].content && (h[r].content.url || h[r].content.uri);
5175
+ e && (M(e) ? h[r].baseUrl = t.baseUrl : -1 === e.indexOf("http://") && -1 === e.indexOf("https://") ? h[r].content.url = t.baseUrl + e : h[r].baseUrl = e.substring(0, e.lastIndexOf("/") + 1));
5175
5176
  }
5176
- n.push(h[e]);
5177
+ n.push(h[r]);
5177
5178
  }
5178
5179
  }
5179
5180
  }
@@ -5183,14 +5184,15 @@
5183
5184
  tiles: c
5184
5185
  };
5185
5186
  }
5186
- pn(t, e) {
5187
- e.node.viewerRequestVolume && !function(t, e, n) {
5187
+ yn(t, e) {
5188
+ const {viewerRequestVolume: n} = e.node;
5189
+ n && !function(t, e, n) {
5188
5190
  if (n.region) {
5189
5191
  const e = n.region;
5190
5192
  if (t[0] >= e[0] && t[0] <= e[2] && t[1] >= e[1] && t[1] <= e[3]) return !0;
5191
5193
  } else {
5192
- if (n.sphere) return Un(n, e);
5193
- if (n.box) return 0 === Cn(n, e);
5194
+ if (n.sphere) return Dn(n, e);
5195
+ if (n.box) return 0 === kn(n, e);
5194
5196
  }
5195
5197
  return !1;
5196
5198
  }
@@ -5198,51 +5200,48 @@
5198
5200
  * @maptalks/gl v0.65.0
5199
5201
  * LICENSE : UNLICENSED
5200
5202
  * (c) 2016-2022 maptalks.com
5201
- */ (this.cn, this.hn, e.node.viewerRequestVolume) || (t[e.node.id] = e);
5203
+ */ (this.an, this.cn, n) || t.push(e);
5202
5204
  }
5203
- Je(t, e) {
5205
+ $e(t, e) {
5204
5206
  return {
5205
5207
  id: t.id,
5206
5208
  node: t,
5207
5209
  children: [],
5208
5210
  level: t.qe,
5209
5211
  parent: e,
5210
- content: this.$e(t)
5212
+ content: t.content && t.content.url
5211
5213
  };
5212
5214
  }
5213
- mn(t) {
5214
- void 0 === t.id && (t.id = s.Util.GUID(), t.matrix = t.transform || n.mat4.identity([]),
5215
- t._n = this.gn(t), t.parent && (t.matrix = n.mat4.multiply(t.matrix, t.parent.matrix, t.matrix),
5216
- t.te = t.parent.te, void 0 === t.qe && (t.qe = t.parent.qe + 1), t.maxExtent = t.parent.maxExtent),
5215
+ dn(t) {
5216
+ t.id = s.Util.GUID(), t.matrix = t.transform || n.mat4.identity([]), t.pn = this.wn(t),
5217
+ t.parent && (t.matrix = n.mat4.multiply(t.matrix, t.parent.matrix, t.matrix), t.te = t.parent.te,
5218
+ void 0 === t.qe && (t.qe = t.parent.qe + 1), t.maxExtent = t.parent.maxExtent),
5217
5219
  t.refine = t.refine && t.refine.toLowerCase() || "replace", t.content && !t.content.url && t.content.uri && (t.content.url = t.content.uri),
5218
- this.Tn(t));
5220
+ this._n(t);
5219
5221
  }
5220
- Tn(t) {
5222
+ _n(t) {
5221
5223
  const e = t.boundingVolume;
5222
- if (!e || e.sn) return;
5224
+ if (!e || e.rn) return;
5223
5225
  const r = this.options.services[t.te].heightOffset || 0, s = this.options.offset, i = y(s) || s[0] || s[1];
5224
- if (!t.boundingVolume || !r && n.mat4.exactEquals(t.matrix, Ln) && !i) return;
5226
+ if (!t.boundingVolume || !r && n.mat4.exactEquals(t.matrix, Rn) && !i) return;
5225
5227
  const {region: o, box: a, sphere: c} = e;
5226
5228
  if (o) {
5227
- const t = this.An([ p(o[0]), p(o[1]) ]);
5229
+ const t = this.gn([ p(o[0]), p(o[1]) ]);
5228
5230
  o[0] = b(t.x), o[1] = b(t.y);
5229
- const e = this.An([ p(o[2]), p(o[3]) ]);
5231
+ const e = this.gn([ p(o[2]), p(o[3]) ]);
5230
5232
  o[2] = b(e.x), o[3] = b(e.y), o[4] += r, o[5] += r;
5231
5233
  } else if (a || c) {
5232
- const e = a || c, s = n.vec3.transformMat4(In, e, t.matrix), i = te(Nn, s), o = this.An([ i[0], i[1] ]);
5234
+ const e = a || c, s = n.vec3.transformMat4(Nn, e, t.matrix), i = te(En, s), o = this.gn([ i[0], i[1] ]);
5233
5235
  i[0] = o.x, i[1] = o.y, i[2] += r, Kt(e, b(i[0]), b(i[1]), i[2]);
5234
5236
  }
5235
- e.sn = !0;
5237
+ e.rn = !0;
5236
5238
  }
5237
- gn(t) {
5239
+ wn(t) {
5238
5240
  return void 0 === t.geometricError || !t.boundingVolume;
5239
5241
  }
5240
- $e(t) {
5241
- return t.content && t.content.url;
5242
- }
5243
- wn(t) {
5242
+ bn(t) {
5244
5243
  let e = t.parent;
5245
- for (;e && e._n && !(e.ce <= t.ce && e.tn <= t.tn); ) e.ce = t.ce, e.tn = t.tn,
5244
+ for (;e && e.pn && !(e.ce <= t.ce && e.Ye <= t.Ye); ) e.ce = t.ce, e.Ye = t.Ye,
5246
5245
  e = t.parent;
5247
5246
  }
5248
5247
  onTilesetLoad(t, e, r) {
@@ -5253,54 +5252,55 @@
5253
5252
  m(e, t.root), e.refine = e.refine && e.refine.toLowerCase() || "replace", r && (e.boundingVolume = r);
5254
5253
  const s = t.root.transform;
5255
5254
  s && (e.parent ? e.matrix = n.mat4.multiply([], e.parent.matrix, s) : e.matrix = s),
5256
- this.Tn(e), e.On = e.content, delete e.content, t.root.content && (e.content = t.root.content),
5257
- e._n = this.gn(e);
5255
+ this._n(e), e.Tn = e.content, delete e.content, t.root.content && (e.content = t.root.content),
5256
+ e.pn = this.wn(e);
5258
5257
  const i = e.content && (e.content.url || e.content.uri);
5259
5258
  i && e.content.uri && (e.content.url = e.content.uri, delete e.content.uri), i && !M(i) && -1 === i.indexOf("http://") && -1 === i.indexOf("https://") && (e.content.url = e.baseUrl + i);
5260
5259
  }
5261
- this.an(), this.fire("loadtileset", {
5260
+ this.in(), this.fire("loadtileset", {
5262
5261
  tileset: t,
5263
5262
  index: e.te,
5264
5263
  url: r
5265
5264
  });
5266
5265
  }
5267
- yn(t, e, n) {
5268
- if (t.ce = 1 / 0, 0 === t.qe || t._n) return 1;
5269
- if (t.vn = 1 / 0, !this.Mn(t, e, n)) return -1;
5266
+ mn(t, e, n) {
5267
+ if (t.ce = 1 / 0, 0 === t.qe || t.pn) return 1;
5268
+ if (!this.An(t, e, n)) return -1;
5270
5269
  if (0 === t.geometricError) return 1;
5271
5270
  let r = this.options.services[t.te].maximumScreenSpaceError;
5272
5271
  null == r && (r = 8);
5273
- let s = this.Sn(t);
5272
+ let s = this.On(t);
5274
5273
  return 0 === s && t.parent && (s = .5 * (t.parent.vn || 0)), s >= r ? 1 : 0;
5275
5274
  }
5276
- ye(t) {
5277
- const e = this.getMap();
5278
- return e.getGLZoom ? e.coordToPoint(t, e.getGLZoom()) : e.coordToPointAtRes(t, e.getGLRes());
5275
+ ye(t, e) {
5276
+ e || (e = new s.Point(0, 0));
5277
+ const n = this.getMap();
5278
+ return n.getGLZoom ? n.coordToPoint(t, n.getGLZoom(), e) : n.coordToPointAtRes(t, n.getGLRes(), e);
5279
5279
  }
5280
- Mn(t, e, r) {
5280
+ An(t, e, r) {
5281
5281
  if (!this.getMap()) return !1;
5282
5282
  const o = t.id;
5283
- let a = this.nn[o];
5283
+ let a = this.en[o];
5284
5284
  const {boundingVolume: f} = t;
5285
5285
  if (!f) return !1;
5286
5286
  const {sphere: d, region: m, box: y} = f;
5287
5287
  if (!a) {
5288
5288
  let e, r, i;
5289
5289
  if (m) {
5290
- e = new s.Extent(p(m[0]), p(m[1]), p(m[2]), p(m[3]));
5291
- const t = e.getCenter(), n = this.xn(t);
5292
- e = e.convertTo(t => this.ye(t)), i = m[4], r = m[5], a = this.nn[o] = [ [ e.xmin, e.ymin, i * n[2] ], [ e.xmax, e.ymax, r * n[2] ] ],
5290
+ e = xn.set(p(m[0]), p(m[1]), p(m[2]), p(m[3]));
5291
+ const t = e.getCenter(), n = this.Mn(t);
5292
+ e = e.convertTo(t => this.ye(t, Bn), In), i = m[4], r = m[5], a = this.en[o] = [ [ e.xmin, e.ymin, i * n[2] ], [ e.xmax, e.ymax, r * n[2] ] ],
5293
5293
  a.center = t;
5294
5294
  } else if (d) {
5295
- const t = te([], d), e = new s.Coordinate(t), n = this.ye(e).toArray(), r = this.xn(e);
5296
- n.push(t[2] * r[2]), a = this.nn[o] = [ n, d[3] * r[2] ], a.center = new s.Coordinate(t);
5295
+ const t = te(Nn, d), e = new s.Coordinate(t), n = this.ye(e, Bn).toArray(), r = this.Mn(e);
5296
+ n.push(t[2] * r[2]), a = this.en[o] = [ n, d[3] * r[2] ], a.center = e;
5297
5297
  } else if (y) {
5298
- const e = te([], y), r = new s.Coordinate(e), i = this.ye(r).toArray(), c = this.xn(r);
5298
+ const e = te(Nn, y), r = new s.Coordinate(e), i = this.ye(r, Bn).toArray(), c = this.Mn(r);
5299
5299
  i.push(e[2] * c[2]);
5300
5300
  const h = y.slice(3);
5301
- n.mat4.exactEquals(t.matrix, Ln) || n.mat3.multiply(h, n.mat3.fromMat4([], t.matrix), h);
5301
+ n.mat4.exactEquals(t.matrix, Rn) || n.mat3.multiply(h, n.mat3.fromMat4(Un, t.matrix), h);
5302
5302
  for (let t = 0; t < h.length; t++) h[t] *= c[t % 3], y[3 + t] = h[t];
5303
- a = this.nn[o] = [ ...i, ...h ], a.center = new s.Coordinate(e);
5303
+ a = this.en[o] = [ ...i, ...h ], a.center = r;
5304
5304
  }
5305
5305
  }
5306
5306
  if (e) {
@@ -5327,11 +5327,11 @@
5327
5327
  return !0;
5328
5328
  }(r, a);
5329
5329
  }
5330
- xn(t) {
5330
+ Mn(t) {
5331
5331
  const e = this.getMap(), r = e.distanceToPointAtRes(100, 100, e.getGLRes(), t);
5332
- return n.vec3.set(En, r.x / 100 * 1.01, r.y / 100 * 1.01, r.y / 100), En;
5332
+ return n.vec3.set(Pn, r.x / 100 * 1.01, r.y / 100 * 1.01, r.y / 100), Pn;
5333
5333
  }
5334
- An(t) {
5334
+ gn(t) {
5335
5335
  Array.isArray(t) && (t = new s.Coordinate(t));
5336
5336
  let e = this.options.offset;
5337
5337
  if (y(e) && (e = e(Array.isArray(t) ? new s.Coordinate(t) : t)), e[0] || e[1]) {
@@ -5340,64 +5340,64 @@
5340
5340
  }
5341
5341
  return t;
5342
5342
  }
5343
- dn(t) {
5343
+ ln(t) {
5344
5344
  const e = this.options.services[t].maxExtent;
5345
5345
  if (!e) return null;
5346
- const n = this.rn[t];
5346
+ const n = this.nn[t];
5347
5347
  return n.maxExtent || (n.maxExtent = new s.Extent(e).convertTo(t => this.ye(t))),
5348
5348
  n.maxExtent;
5349
5349
  }
5350
- Sn(t) {
5351
- const e = this.un, r = t.geometricError;
5350
+ On(t) {
5351
+ const e = this.hn, r = t.geometricError;
5352
5352
  if (0 === r) return 0;
5353
5353
  const s = this.getMap();
5354
5354
  let i, o;
5355
5355
  if (t.boundingVolume.region) {
5356
- const e = this.nn[t.id].center, r = (s.getGLZoom ? s.distanceToPoint(100, 0, s.getGLZoom(), e) : s.distanceToPointAtRes(100, 0, s.getGLRes(), e)).x / 100;
5356
+ const e = this.en[t.id].center, r = (s.getGLZoom ? s.distanceToPoint(100, 0, s.getGLZoom(), e) : s.distanceToPointAtRes(100, 0, s.getGLRes(), e)).x / 100;
5357
5357
  i = function(t, e, n, r) {
5358
5358
  const s = t.boundingVolume.region;
5359
- let i = t.In;
5360
- i || (i = t.In = [ Dn(s[0], s[1]), Dn(s[0], s[3]), Dn(s[2], s[1]), Dn(s[2], s[3]), Dn(s[0], s[1]), Dn(s[0], s[3]), Dn(s[2], s[1]), Dn(s[2], s[3]) ],
5361
- t.Nn = [ Math.min.apply(Math, i.map(t => t[0])), Math.min.apply(Math, i.map(t => t[1])) ],
5362
- t.En = [ Math.max.apply(Math, i.map(t => t[0])), Math.max.apply(Math, i.map(t => t[1])) ]);
5359
+ let i = t.Sn;
5360
+ i || (i = t.Sn = [ Vn(s[0], s[1]), Vn(s[0], s[3]), Vn(s[2], s[1]), Vn(s[2], s[3]), Vn(s[0], s[1]), Vn(s[0], s[3]), Vn(s[2], s[1]), Vn(s[2], s[3]) ],
5361
+ t.xn = [ Math.min.apply(Math, i.map(t => t[0])), Math.min.apply(Math, i.map(t => t[1])) ],
5362
+ t.In = [ Math.max.apply(Math, i.map(t => t[0])), Math.max.apply(Math, i.map(t => t[1])) ]);
5363
5363
  if (n[0] >= s[0] && n[0] <= s[2] && n[1] >= s[1] && n[1] <= s[3]) return n[2] <= s[5] ? 0 : n[2] - s[5];
5364
- const o = (a = t.Nn, c = t.En, h = e, u = Math.max(a[0] - h[0], 0, h[0] - c[0]),
5364
+ const o = (a = t.xn, c = t.In, h = e, u = Math.max(a[0] - h[0], 0, h[0] - c[0]),
5365
5365
  f = Math.max(a[1] - h[1], 0, h[1] - c[1]), Math.sqrt(u * u + f * f) / r);
5366
5366
  var a, c, h, u, f;
5367
5367
  let l = 0;
5368
5368
  n[2] > s[5] && (l = n[2] - s[5]);
5369
5369
  return Math.sqrt(o * o + l * l);
5370
- }(t, this.ln, this.cn, r), o = function(t, e) {
5371
- const r = t.boundingVolume.region, s = Kt(Rn, r[0], r[1], r[4]), i = Kt(Fn, r[2], r[3], r[5]), o = n.vec3.scale(s, n.vec3.add(s, s, i), .5);
5370
+ }(t, this.un, this.an, r), o = function(t, e) {
5371
+ const r = t.boundingVolume.region, s = Kt(zn, r[0], r[1], r[4]), i = Kt(jn, r[2], r[3], r[5]), o = n.vec3.scale(s, n.vec3.add(s, s, i), .5);
5372
5372
  return n.vec3.dist(o, e);
5373
- }(t, this.hn);
5374
- } else t.boundingVolume.sphere ? (i = Un(t.boundingVolume, this.hn), o = function(t, e) {
5373
+ }(t, this.cn);
5374
+ } else t.boundingVolume.sphere ? (i = Dn(t.boundingVolume, this.cn), o = function(t, e) {
5375
5375
  const r = t.boundingVolume.sphere;
5376
5376
  return n.vec3.dist(r, e);
5377
- }(t, this.hn)) : t.boundingVolume.box && (i = Cn(t.boundingVolume, this.hn), o = function(t, e) {
5377
+ }(t, this.cn)) : t.boundingVolume.box && (i = kn(t.boundingVolume, this.cn), o = function(t, e) {
5378
5378
  const r = t.boundingVolume.box;
5379
5379
  return n.vec3.dist(r, e);
5380
- }(t, this.hn));
5380
+ }(t, this.cn));
5381
5381
  const a = Math.max(Math.abs(i), 1e-7), c = r * s.height / (a * e);
5382
- return t.ce = i, t.tn = o, t.vn = c, c;
5382
+ return t.ce = i, t.Ye = o, t.vn = c, c;
5383
5383
  }
5384
- an() {
5384
+ in() {
5385
5385
  const t = this.getRenderer();
5386
5386
  t && t.setToRedraw();
5387
5387
  }
5388
5388
  Me(t) {
5389
- return this.nn[t];
5389
+ return this.en[t];
5390
5390
  }
5391
5391
  }
5392
- function Un(t, e) {
5392
+ function Dn(t, e) {
5393
5393
  const r = t.sphere, s = n.vec3.dist(r, e), i = t.sphere[3];
5394
5394
  return s < i ? 0 : s - i;
5395
5395
  }
5396
- function Cn(t, e) {
5396
+ function kn(t, e) {
5397
5397
  const n = t.box;
5398
5398
  return gn(n.slice(0, 3), n.slice(3), e);
5399
5399
  }
5400
- Bn.mergeOptions({
5400
+ Fn.mergeOptions({
5401
5401
  "maxGPUMemory": 512,
5402
5402
  "retireInterval": 2e3,
5403
5403
  "loadingLimitOnInteracting": 5,
@@ -5413,35 +5413,35 @@
5413
5413
  "sRGBTolinear": !1,
5414
5414
  "optionalExtensions": [ "ANGLE_instanced_arrays", "OES_element_index_uint", "OES_standard_derivatives", "OES_vertex_array_object", "OES_texture_half_float", "OES_texture_half_float_linear", "OES_texture_float", "OES_texture_float_linear", "WEBGL_depth_texture", "EXT_shader_texture_lod", "WEBGL_compressed_texture_astc", "WEBGL_compressed_texture_etc", "WEBGL_compressed_texture_etc1", "WEBGL_compressed_texture_pvrtc", "WEBGL_compressed_texture_s3tc", "WEBGL_compressed_texture_s3tc_srgb" ],
5415
5415
  "offset": [ 0, 0 ]
5416
- }), Bn.registerRenderer("gl", pn);
5417
- const Rn = [], Fn = [];
5418
- function Dn(t, e) {
5416
+ }), Fn.registerRenderer("gl", pn);
5417
+ const zn = [], jn = [];
5418
+ function Vn(t, e) {
5419
5419
  const n = new s.Coordinate(p(t), p(e));
5420
5420
  return Sn.project(n).toArray();
5421
5421
  }
5422
- const kn = function() {
5422
+ const Gn = function() {
5423
5423
  if ("undefined" != typeof self) return self;
5424
5424
  if ("undefined" != typeof window) return window;
5425
5425
  if ("undefined" != typeof global) return global;
5426
5426
  throw new Error("unable to locate global object");
5427
- }, zn = kn(), jn = zn.gl_trans__coders = zn.gl_trans__coders || {};
5428
- jn.inject = function(t) {
5429
- const e = t.toString(), n = e.indexOf("{") + 1, r = e.substring(0, n), s = zn.gl_trans__coders = zn.gl_trans__coders || {};
5430
- let i = `${r}\n const _____getGlobal = ${kn.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;
5427
+ }, Hn = Gn(), qn = Hn.gl_trans__coders = Hn.gl_trans__coders || {};
5428
+ qn.inject = function(t) {
5429
+ const e = t.toString(), n = e.indexOf("{") + 1, r = e.substring(0, n), s = Hn.gl_trans__coders = Hn.gl_trans__coders || {};
5430
+ let i = `${r}\n const _____getGlobal = ${Gn.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;
5431
5431
  for (const t in s) "inject" !== t && "getTranscoder" !== t && "registerTranscoder" !== t && (i += 'tran_____scoders["' + t + '"] =' + s[t].toString() + "\n;");
5432
5432
  return i += "\n" + e.substring(r.length), i;
5433
- }, jn.registerTranscoder = function(t, e) {
5434
- jn[t] = e;
5435
- }, jn.getTranscoder = function(t) {
5436
- return jn[t];
5433
+ }, qn.registerTranscoder = function(t, e) {
5434
+ qn[t] = e;
5435
+ }, qn.getTranscoder = function(t) {
5436
+ return qn[t];
5437
5437
  };
5438
- class Vn {
5438
+ class $n {
5439
5439
  constructor(t, e, n) {
5440
5440
  this.i = t, this.Y = e || Pt, this.o = n, this.tt = {
5441
- "image/crn": jn.crn && jn.crn(),
5442
- "image/ktx2": jn.ktx2 && jn.ktx2(),
5443
- "image/cttf": jn.ktx2 && jn.ktx2(),
5444
- "draco": jn.draco && jn.draco()
5441
+ "image/crn": qn.crn && qn.crn(),
5442
+ "image/ktx2": qn.ktx2 && qn.ktx2(),
5443
+ "image/cttf": qn.ktx2 && qn.ktx2(),
5444
+ "draco": qn.draco && qn.draco()
5445
5445
  };
5446
5446
  }
5447
5447
  static createEmptyB3DM() {
@@ -5530,13 +5530,13 @@
5530
5530
  return null;
5531
5531
  }
5532
5532
  }
5533
- class Gn {
5533
+ class Jn {
5534
5534
  constructor(t, e, n) {
5535
5535
  this.i = t, this.Y = e || Pt, this.o = n, this.tt = {
5536
- "image/crn": jn.crn && jn.crn(),
5537
- "image/ktx2": jn.ktx2 && jn.ktx2(),
5538
- "image/cttf": jn.ktx2 && jn.ktx2(),
5539
- "draco": jn.draco && jn.draco()
5536
+ "image/crn": qn.crn && qn.crn(),
5537
+ "image/ktx2": qn.ktx2 && qn.ktx2(),
5538
+ "image/cttf": qn.ktx2 && qn.ktx2(),
5539
+ "draco": qn.draco && qn.draco()
5540
5540
  };
5541
5541
  }
5542
5542
  load(t, e, n = 0, r = 0) {
@@ -5707,7 +5707,7 @@
5707
5707
  }
5708
5708
  ct(t) {
5709
5709
  const e = t.length / 2, n = new Float32Array(3 * e), r = [];
5710
- for (let s = 0; s < e; s++) Hn(r, t[2 * s], t[2 * s + 1], 65535), n[3 * s] = r[0],
5710
+ for (let s = 0; s < e; s++) Kn(r, t[2 * s], t[2 * s + 1], 65535), n[3 * s] = r[0],
5711
5711
  n[3 * s + 1] = r[1], n[3 * s + 2] = r[2];
5712
5712
  return n;
5713
5713
  }
@@ -5718,15 +5718,15 @@
5718
5718
  return null;
5719
5719
  }
5720
5720
  }
5721
- function Hn(t, e, n, r) {
5722
- if (t[0] = qn(e, r), t[1] = qn(n, r), t[2] = 1 - (Math.abs(t[0]) + Math.abs(t[1])),
5721
+ function Kn(t, e, n, r) {
5722
+ if (t[0] = Xn(e, r), t[1] = Xn(n, r), t[2] = 1 - (Math.abs(t[0]) + Math.abs(t[1])),
5723
5723
  t[2] < 0) {
5724
5724
  const e = t[0];
5725
- t[0] = (1 - Math.abs(t[1])) * $n(e), t[1] = (1 - Math.abs(e)) * $n(t[1]);
5725
+ t[0] = (1 - Math.abs(t[1])) * Wn(e), t[1] = (1 - Math.abs(e)) * Wn(t[1]);
5726
5726
  }
5727
5727
  return D(t, t);
5728
5728
  }
5729
- function qn(t, e) {
5729
+ function Xn(t, e) {
5730
5730
  return function(t, e, n) {
5731
5731
  return t < e ? e : t > n ? n : t;
5732
5732
  }(t, 0, e = function(t, e) {
@@ -5734,10 +5734,10 @@
5734
5734
  return e;
5735
5735
  }(e, 255)) / e * 2 - 1;
5736
5736
  }
5737
- function $n(t) {
5737
+ function Wn(t) {
5738
5738
  return t < 0 ? -1 : 1;
5739
5739
  }
5740
- class Jn {
5740
+ class Zn {
5741
5741
  constructor() {}
5742
5742
  load(t, e, n = 0, r = 0) {
5743
5743
  return e ? (r || (r = e.byteLength), this.et(t, e, n, r)) : ft.getArrayBuffer(t, {}).then(e => {
@@ -5778,7 +5778,7 @@
5778
5778
  attributes: y.properties,
5779
5779
  useUniqueIDs: !1
5780
5780
  };
5781
- return this.ut || (this.ut = jn.draco()), this.ut(m, e).then(e => {
5781
+ return this.ut || (this.ut = qn.draco()), this.ut(m, e).then(e => {
5782
5782
  const n = e.attributes;
5783
5783
  !a.POSITION && !a.POSITION_QUANTIZED || n.POSITION || n.POSITION_QUANTIZED || (n.POSITION = a.POSITION,
5784
5784
  n.POSITION_QUANTIZED = a.POSITION_QUANTIZED), !(a.RGB || a.RGBA || a.RGB565) || n.RGB || n.RGBA || n.RGB565 || (n.RGB = a.RGB,
@@ -5796,7 +5796,7 @@
5796
5796
  array: t
5797
5797
  }, o.push(t.buffer);
5798
5798
  } else if (a.BATCH_ID || Object.keys(h).length) {
5799
- a.BATCH_ID ? r.BATCH_ID = de(a.BATCH_ID, t, c.offset, d) : r.BATCH_ID = Kn(d);
5799
+ a.BATCH_ID ? r.BATCH_ID = de(a.BATCH_ID, t, c.offset, d) : r.BATCH_ID = Qn(d);
5800
5800
  const e = r.BATCH_ID.array && r.BATCH_ID.array.buffer;
5801
5801
  e && o.indexOf(e) < 0 && o.push(e);
5802
5802
  }
@@ -5812,7 +5812,7 @@
5812
5812
  }
5813
5813
  const b = this.ft(t, a, c.offset, d, o, f, l);
5814
5814
  if (a.BATCH_ID || Object.keys(h).length) {
5815
- a.BATCH_ID ? b.BATCH_ID = de(a.BATCH_ID, t, c.offset, d) : b.BATCH_ID = Kn(d);
5815
+ a.BATCH_ID ? b.BATCH_ID = de(a.BATCH_ID, t, c.offset, d) : b.BATCH_ID = Qn(d);
5816
5816
  const e = b.BATCH_ID.array && b.BATCH_ID.array.buffer;
5817
5817
  e && o.indexOf(e) < 0 && o.push(e);
5818
5818
  }
@@ -5947,7 +5947,7 @@
5947
5947
  return null;
5948
5948
  }
5949
5949
  }
5950
- function Kn(t) {
5950
+ function Qn(t) {
5951
5951
  const e = v(t), n = new e(t);
5952
5952
  for (let e = 0; e < t; e++) n[e] = e;
5953
5953
  return {
@@ -5959,7 +5959,7 @@
5959
5959
  array: n
5960
5960
  };
5961
5961
  }
5962
- class Xn {
5962
+ class Yn {
5963
5963
  constructor(t, e) {
5964
5964
  this.i = t, this.Y = e || Pt;
5965
5965
  }
@@ -5974,12 +5974,12 @@
5974
5974
  const s = this.lt(e, t, n, r), i = [];
5975
5975
  for (let n = 0; n < s.length; n++) {
5976
5976
  let r;
5977
- if ("b3dm" === s[n].magic) r = new Vn(this.i, this.Y); else if ("i3dm" === s[n].magic) r = new Gn(this.i, this.Y); else if ("pnts" === s[n].magic) r = new Jn; else {
5977
+ if ("b3dm" === s[n].magic) r = new $n(this.i, this.Y); else if ("i3dm" === s[n].magic) r = new Jn(this.i, this.Y); else if ("pnts" === s[n].magic) r = new Zn; else {
5978
5978
  if ("cmpt" !== s[n].magic) {
5979
5979
  console.warn("Unsupported magic in CMPT tile:", s[n].magic);
5980
5980
  continue;
5981
5981
  }
5982
- r = new Xn(this.i, this.Y);
5982
+ r = new Yn(this.i, this.Y);
5983
5983
  }
5984
5984
  i.push(r.load(t, e, s[n].offset, s[n].byteLength).then(t => t));
5985
5985
  }
@@ -6011,9 +6011,9 @@
6011
6011
  return o;
6012
6012
  }
6013
6013
  }
6014
- t.B3DMLoader = Vn, t.CMPTLoader = Xn, t.Geo3DTilesLayer = Bn, t.Geo3DTilesUtil = x,
6014
+ t.B3DMLoader = $n, t.CMPTLoader = Yn, t.Geo3DTilesLayer = Fn, t.Geo3DTilesUtil = x,
6015
6015
  t.Geo3DTransform = oe, Object.defineProperty(t, "t", {
6016
6016
  value: !0
6017
6017
  });
6018
- })), i.Map.VERSION, o.GroupGLLayer.VERSION, "undefined" != typeof console && console.log("@maptalks/3dtiles v0.12.5");
6018
+ })), i.Map.VERSION, o.GroupGLLayer.VERSION, "undefined" != typeof console && console.log("@maptalks/3dtiles v0.12.6");
6019
6019
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maptalks/3dtiles",
3
- "version": "0.12.5",
3
+ "version": "0.12.6",
4
4
  "description": "3d tiles layer for maptalks",
5
5
  "main": "dist/maptalks.3dtiles.js",
6
6
  "module": "dist/maptalks.3dtiles.es.js",