@jdultra/threedtiles 8.0.1 → 9.0.1
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 +6 -2
- package/dist/threedtiles.min.js +2 -0
- package/package.json +17 -13
- package/.babelrc +0 -8
- package/.vscode/settings.json +0 -2
- package/index.html +0 -56
- package/src/decoder/B3DMDecoder.js +0 -125
- package/src/decoder/FeatureTable.js +0 -169
- package/src/decoder/LegacyGLTFLoader.js +0 -2216
- package/src/geometry/obb.js +0 -47
- package/src/images/skybox/back.png +0 -0
- package/src/images/skybox/bottom.png +0 -0
- package/src/images/skybox/front.png +0 -0
- package/src/images/skybox/left.png +0 -0
- package/src/images/skybox/right.png +0 -0
- package/src/images/skybox/top.png +0 -0
- package/src/index.js +0 -331
- package/src/tileset/OGC3DTile.js +0 -676
- package/src/tileset/OcclusionCullingService.js +0 -79
- package/src/tileset/TileLoader.js +0 -381
- package/src/tileset/instanced/InstancedOGC3DTile.js +0 -55
- package/src/tileset/instanced/InstancedTile.js +0 -588
- package/src/tileset/instanced/InstancedTileLoader.js +0 -396
- package/src/tileset/instanced/JsonTile.js +0 -41
- package/src/tileset/instanced/MeshTile.js +0 -81
- package/threedtiles.js +0 -82894
- package/threedtiles.js.map +0 -1
- package/webpack.config.js +0 -142
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ NPM dependency: "@jdultra/threedtiles": "^8.0.0"
|
|
|
19
19
|
Adding a tileset to a scene is as easy as :
|
|
20
20
|
|
|
21
21
|
```
|
|
22
|
-
import { OGC3DTile } from
|
|
22
|
+
import { OGC3DTile } from '@jdultra/threedtiles';
|
|
23
23
|
|
|
24
24
|
...
|
|
25
25
|
|
|
@@ -166,7 +166,7 @@ The TileLoader takes an optional object as argument:
|
|
|
166
166
|
@param {renderer} [options.renderer] - The renderer, this is required for KTX2 support.
|
|
167
167
|
|
|
168
168
|
```
|
|
169
|
-
import { TileLoader } from
|
|
169
|
+
import { TileLoader } from '@jdultra/threedtiles';
|
|
170
170
|
|
|
171
171
|
const tileLoader = new TileLoader({
|
|
172
172
|
renderer: renderer,
|
|
@@ -213,6 +213,8 @@ It will be most beneficial on interior scenes where most of the data is occluded
|
|
|
213
213
|
|
|
214
214
|
First, instantiate an OcclusionCullingService:
|
|
215
215
|
```
|
|
216
|
+
import { OcclusionCullingService } from '@jdultra/threedtiles';
|
|
217
|
+
|
|
216
218
|
const occlusionCullingService = new OcclusionCullingService();
|
|
217
219
|
```
|
|
218
220
|
|
|
@@ -252,6 +254,8 @@ Each Tileset is independent in terms of it's position, orientation and level of
|
|
|
252
254
|
higher performance when displaying the same Tileset many times.
|
|
253
255
|
|
|
254
256
|
```
|
|
257
|
+
import { InstancedOGC3DTile, InstancedTileLoader } from '@jdultra/threedtiles';
|
|
258
|
+
|
|
255
259
|
// First create the InstancedTileLoader that will manage caching
|
|
256
260
|
const instancedTileLoader = new InstancedTileLoader(
|
|
257
261
|
scene,
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.threedtiles=t():e.threedtiles=t()}(this,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{InstancedOGC3DTile:()=>ge,InstancedTileLoader:()=>Ve,OGC3DTile:()=>Q,OcclusionCullingService:()=>a,TileLoader:()=>A});const n=require("three"),r=require("three/src/math/MathUtils");function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(i=r.key,a=void 0,a=function(e,t){if("object"!==o(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(i,"string"),"symbol"===o(a)?a:String(a)),r)}var i,a}var a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.cullMap=[],this.cullMaterial=new n.MeshBasicMaterial({vertexColors:!0}),this.cullMaterial.side=n.FrontSide,this.cullTarget=this.createCullTarget(),this.cullPixels=new Uint8Array(4*this.cullTarget.width*this.cullTarget.height)}var t,o,a;return t=e,(o=[{key:"setSide",value:function(e){this.cullMaterial.side=e}},{key:"createCullTarget",value:function(){var e=new n.WebGLRenderTarget(Math.floor(.05*window.innerWidth),Math.floor(.05*window.innerHeight));return e.texture.format=n.RGBAFormat,e.texture.encoding=n.LinearEncoding,e.texture.minFilter=n.NearestFilter,e.texture.magFilter=n.NearestFilter,e.texture.generateMipmaps=!1,e.stencilBuffer=!1,e.depthBuffer=!0,e.depthTexture=new n.DepthTexture,e.depthTexture.format=n.DepthFormat,e.depthTexture.type=n.UnsignedShortType,e}},{key:"update",value:function(e,t,n){var o=t.getRenderTarget(),i=e.overrideMaterial;e.overrideMaterial=this.cullMaterial,t.setRenderTarget(this.cullTarget),t.render(e,n),e.overrideMaterial=i,t.setRenderTarget(o),t.readRenderTargetPixels(this.cullTarget,0,0,this.cullTarget.width,this.cullTarget.height,this.cullPixels),this.cullMap=[];for(var a=0;a<this.cullPixels.length;a+=4){var s=(0,r.clamp)(this.cullPixels[a],0,255)<<16^(0,r.clamp)(this.cullPixels[a+1],0,255)<<8^(0,r.clamp)(this.cullPixels[a+2],0,255)<<0;this.cullMap[s]=!0}}},{key:"hasID",value:function(e){return this.cullMap[e]}}])&&i(t.prototype,o),a&&i(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}();function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(o=r.key,i=void 0,i=function(e,t){if("object"!==s(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==s(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===s(i)?i:String(i)),r)}var o,i}var u=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.center=new n.Vector3(t[0],t[1],t[2]);var r=new n.Vector3(t[3],t[4],t[4]),o=new n.Vector3(t[6],t[7],t[8]),i=new n.Vector3(t[9],t[10],t[11]);this.halfWidth=r.length(),this.halfHeight=o.length(),this.halfDepth=i.length(),r.normalize(),o.normalize(),i.normalize(),this.sphere=new n.Sphere(this.center,Math.sqrt(this.halfWidth*this.halfWidth+this.halfHeight*this.halfHeight+this.halfDepth*this.halfDepth)),this.matrixToOBBCoordinateSystem=new n.Matrix3,this.matrixToOBBCoordinateSystem.set(r.x,r.y,r.z,o.x,o.y,o.z,i.x,i.y,i.z)}var t,r,o;return t=e,(r=[{key:"inFrustum",value:function(e){return e.intersectsSphere(this.sphere)}},{key:"distanceToPoint",value:function(e){var t=e.clone();t.sub(this.center),t.applyMatrix3(this.matrixToOBBCoordinateSystem);var n=Math.max(0,Math.max(-this.halfWidth-t.x,t.x-this.halfWidth)),r=Math.max(0,Math.max(-this.halfHeight-t.y,t.y-this.halfHeight)),o=Math.max(0,Math.max(-this.halfDepth-t.z,t.z-this.halfDepth));return Math.sqrt(n*n+r*r+o*o)}}])&&l(t.prototype,r),o&&l(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}();const c=require("js-utils-z"),h=require("three/examples/jsm/loaders/GLTFLoader.js"),d=require("three/examples/jsm/loaders/DRACOLoader.js"),f=require("three/examples/jsm/loaders/KTX2Loader");function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function m(){return m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=g(e)););return e}(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(arguments.length<3?e:n):o.value}},m.apply(this,arguments)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function b(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=g(e);if(t){var o=g(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return function(e,t){if(t&&("object"===p(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}function g(e){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},g(e)}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(o=r.key,i=void 0,i=function(e,t){if("object"!==p(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===p(i)?i:String(i)),r)}var o,i}function j(e,t,n){return t&&w(e.prototype,t),n&&w(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var C=new TextDecoder,M=function(){function e(t,n,r,o){v(this,e),this.buffer=t,this.binOffset=n+r,this.binLength=o;var i=null;if(0!==r)try{var a=new Uint8Array(t,n,r);i=JSON.parse(C.decode(a))}catch(e){i={}}else i={};this.header=i}return j(e,[{key:"getKeys",value:function(){return Object.keys(this.header)}},{key:"getData",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=this.header;if(!(e in o))return null;var i=o[e];if(i instanceof Object){if(Array.isArray(i))return i;var a,s,l=this.buffer,u=this.binOffset,c=this.binLength,h=i.byteOffset||0,d=i.type||r,f=i.componentType||n;if("type"in i&&r&&i.type!==r)throw new Error("FeatureTable: Specified type does not match expected type.");switch(d){case"SCALAR":a=1;break;case"VEC2":a=2;break;case"VEC3":a=3;break;case"VEC4":a=4;break;default:throw new Error('FeatureTable : Feature type not provided for "'.concat(e,'".'))}var p=u+h,m=t*a;switch(f){case"BYTE":s=new Int8Array(l,p,m);break;case"UNSIGNED_BYTE":s=new Uint8Array(l,p,m);break;case"SHORT":s=new Int16Array(l,p,m);break;case"UNSIGNED_SHORT":s=new Uint16Array(l,p,m);break;case"INT":s=new Int32Array(l,p,m);break;case"UNSIGNED_INT":s=new Uint32Array(l,p,m);break;case"FLOAT":s=new Float32Array(l,p,m);break;case"DOUBLE":s=new Float64Array(l,p,m);break;default:throw new Error('FeatureTable : Feature component type not provided for "'.concat(e,'".'))}if(p+m*s.BYTES_PER_ELEMENT>u+c)throw new Error("FeatureTable: Feature data read outside binary body length.");return s}return i}}]),e}(),x=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}(n,e);var t=b(n);function n(e,r,o,i,a){var s;return v(this,n),(s=t.call(this,e,o,i,a)).batchSize=r,s}return j(n,[{key:"getData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return m(g(n.prototype),"getData",this).call(this,e,this.batchSize,t,r)}}]),n}(M);function T(e){return T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},T(e)}function S(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(o=r.key,i=void 0,i=function(e,t){if("object"!==T(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==T(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===T(i)?i:String(i)),r)}var o,i}var k=new n.Matrix4;k.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);var O=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.gltfLoader=new h.GLTFLoader;var r=new d.DRACOLoader;if(r.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),this.gltfLoader.setDRACOLoader(r),t){var o=new f.KTX2Loader;o.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(t),this.gltfLoader.setKTX2Loader(o)}this.tempMatrix=new n.Matrix4}var t,r,o;return t=e,(r=[{key:"parseB3DM",value:function(e,t,n,r){var o=this,i=new DataView(e),a=String.fromCharCode(i.getUint8(0))+String.fromCharCode(i.getUint8(1))+String.fromCharCode(i.getUint8(2))+String.fromCharCode(i.getUint8(3));console.assert("b3dm"===a);var s=i.getUint32(8,!0);console.assert(s===e.byteLength);var l=i.getUint32(12,!0),u=i.getUint32(16,!0),c=i.getUint32(20,!0),h=i.getUint32(24,!0),d=new M(e,28,l,u),f=28+l+u,p=(new x(e,d.getData("BATCH_LENGTH"),f,c,h),f+c+h),m=new Uint8Array(e,p,s-p).slice().buffer;return new Promise((function(e,i){o.gltfLoader.parse(m,null,(function(i){var a=d.getData("RTC_CENTER");a?(o.tempMatrix.makeTranslation(a[0],a[1],a[2]),i.scene.applyMatrix4(o.tempMatrix)):i.userData.gltfExtensions&&i.userData.gltfExtensions.CESIUM_RTC&&(o.tempMatrix.makeTranslation(i.userData.gltfExtensions.CESIUM_RTC.center[0],i.userData.gltfExtensions.CESIUM_RTC.center[1],i.userData.gltfExtensions.CESIUM_RTC.center[2]),i.scene.applyMatrix4(o.tempMatrix)),r||i.scene.applyMatrix4(k),i.scene.traverse((function(e){e.isMesh&&(e.geometricError=n,r&&e.applyMatrix4(k),t&&t(e))})),e(i.scene)}),(function(e){console.error(e)}))}))}},{key:"parseB3DMInstanced",value:function(e,t,r,o){return this.parseB3DM(e,t,o).then((function(e){var t;return e.updateWorldMatrix(!1,!0),e.traverse((function(e){e.isMesh&&((t=new n.InstancedMesh(e.geometry,e.material,r)).baseMatrix=e.matrixWorld)})),t}))}}])&&S(t.prototype,r),o&&S(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}();const E=require("set-interval-async/dynamic"),V=require("three/examples/jsm/loaders/GLTFLoader");function P(e){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P(e)}function D(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(o=r.key,i=void 0,i=function(e,t){if("object"!==P(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==P(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===P(i)?i:String(i)),r)}var o,i}var L=0,R=new n.Matrix4;R.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);var A=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.maxCachedItems=100,t&&(this.meshCallback=t.meshCallback,this.pointsCallback=t.pointsCallback,t.maxCachedItems&&(this.maxCachedItems=t.maxCachedItems)),this.gltfLoader=new V.GLTFLoader;var n=new d.DRACOLoader;if(n.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),this.gltfLoader.setDRACOLoader(n),t&&t.renderer){var r=new f.KTX2Loader;r.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(t.renderer),this.gltfLoader.setKTX2Loader(r),this.b3dmDecoder=new O(t.renderer)}else this.b3dmDecoder=new O(null);this.cache=new c.LinkedHashMap,this.register={},this.ready=[],this.downloads=[],this.nextReady=[],this.nextDownloads=[],this.init()}var t,n,r;return t=e,(n=[{key:"init",value:function(){var e=this;(0,E.setIntervalAsync)((function(){e.download()}),10),(0,E.setIntervalAsync)((function(){var t=Date.now(),n=0;do{n=e.loadBatch()}while(n>0&&Date.now()-t<=0)}),10)}},{key:"scheduleDownload",value:function(e){this.downloads.unshift(e)}},{key:"download",value:function(){if(0!=this.nextDownloads.length||(this.getNextDownloads(),0!=this.nextDownloads.length))for(;this.nextDownloads.length>0&&L<500;){var e=this.nextDownloads.shift();e&&e.shouldDoDownload()&&e.doDownload()}}},{key:"meshReceived",value:function(e,t,n,r,o,i,a){this.ready.unshift([e,t,n,r,o,i,a])}},{key:"loadBatch",value:function(){if(0==this.nextReady.length&&(this.getNextReady(),0==this.nextReady.length))return 0;var e=this.nextReady.shift();if(!e)return 0;var t=e[0],n=e[1],r=e[2],o=t.get(r);return o&&n[r]&&Object.keys(n[r]).forEach((function(e){var t=n[r][e];t&&(t(o),n[r][e]=null)})),1}},{key:"getNextDownloads",value:function(){for(var e=Number.MAX_VALUE,t=-1,n=this.downloads.length-1;n>=0;n--)this.downloads[n].shouldDoDownload()?this.downloads[n].distanceFunction||this.nextDownloads.push(this.downloads.splice(n,1)[0]):this.downloads.splice(n,1);if(!(this.nextDownloads.length>0)){for(var r=this.downloads.length-1;r>=0;r--){var o=this.downloads[r].distanceFunction()*this.downloads[r].level;o<e&&(e=o,t=r)}if(t>=0){var i=this.downloads.splice(t,1).pop();this.nextDownloads.push(i);for(var a=i.getSiblings(),s=this.downloads.length-1;s>=0;s--)a.includes(this.downloads[s].uuid)&&this.nextDownloads.push(this.downloads.splice(s,1).pop())}}}},{key:"getNextReady",value:function(){for(var e=Number.MAX_VALUE,t=-1,n=this.ready.length-1;n>=0;n--)this.ready[n][3]||this.nextReady.push(this.ready.splice(n,1)[0]);if(!(this.nextReady.length>0)){for(var r=this.ready.length-1;r>=0;r--){var o=this.ready[r][3]()*this.ready[r][5];o<e&&(e=o,t=r)}if(t>=0){var i=this.ready.splice(t,1).pop();this.nextReady.push(i);for(var a=i[4](),s=this.ready.length-1;s>=0;s--)a.includes(this.ready[s][6])&&this.nextready.push(this.ready.splice(s,1).pop())}}}},{key:"get",value:function(e,t,n,r,o,i,a,s,l){var u=this,c=this,h=U(n),d=new AbortController;if(e.signal.addEventListener("abort",(function(){c.register[h]&&0!=Object.keys(c.register[h]).length||d.abort()})),n.includes(".b3dm")||n.includes(".json")||n.includes(".gltf")||n.includes(".glb")){if(c.register[h]||(c.register[h]={}),c.register[h][t]&&console.error(" a tile should only be loaded once"),c.register[h][t]=r,c.cache.get(h))this.meshReceived(c.cache,c.register,h,o,i,a,t);else if(1==Object.keys(c.register[h]).length){var f;n.includes(".b3dm")?f=function(){L++,fetch(n,{signal:d.signal}).then((function(e){if(L--,!e.ok)throw console.error("could not load tile with path : "+n),new Error("couldn't load \"".concat(n,'". Request failed with status ').concat(e.status," : ").concat(e.statusText));return e.arrayBuffer()})).then((function(e){return u.b3dmDecoder.parseB3DM(e,c.meshCallback,l,s)})).then((function(e){c.cache.put(h,e),c.checkSize(),u.meshReceived(c.cache,c.register,h,o,i,a,t)})).catch((function(){}))}:n.includes(".glb")||n.includes(".gltf")?f=function(){L++,u.gltfLoader.load(n,(function(e){e.scene.traverse((function(e){e.geometricError=l,e.isMesh&&(s&&e.applyMatrix4(R),c.meshCallback&&c.meshCallback(e)),e.isPoints&&(s&&e.applyMatrix4(R),c.pointsCallback&&c.pointsCallback(e))})),c.cache.put(h,e.scene),c.checkSize(),c.meshReceived(c.cache,c.register,h,o,i,a,t)}))}:n.includes(".json")&&(f=function(){L++,fetch(n,{signal:d.signal}).then((function(e){if(L--,!e.ok)throw console.error("could not load tile with path : "+n),new Error("couldn't load \"".concat(n,'". Request failed with status ').concat(e.status," : ").concat(e.statusText));return e.json()})).then((function(e){c.cache.put(h,e),c.checkSize(),c.meshReceived(c.cache,c.register,h)})).catch((function(e){return console.error("tile download aborted")}))}),this.scheduleDownload({shouldDoDownload:function(){return!e.signal.aborted&&!!c.register[h]&&Object.keys(c.register[h]).length>0},doDownload:f,distanceFunction:o,getSiblings:i,level:a,uuid:t})}}else console.error("the 3DTiles cache can only be used to load B3DM, gltf and json data")}},{key:"invalidate",value:function(e,t){var n=U(e);this.register[n]&&delete this.register[n][t]}},{key:"checkSize",value:function(){for(var e=this,t=0;e.cache.size()>e.maxCachedItems&&t<e.cache.size();){t++;var n=e.cache.head(),r=e.register[n.key];r&&(Object.keys(r).length>0?(e.cache.remove(n.key),e.cache.put(n.key,n.value)):(e.cache.remove(n.key),delete e.register[n.key],n.value.traverse((function(e){if(e.material)if(e.material.length)for(var t=0;t<e.material.length;++t)e.material[t].dispose();else e.material.dispose();e.geometry&&e.geometry.dispose()}))))}}}])&&D(t.prototype,n),r&&D(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function U(e){for(var t=e.split("/"),n=[],r=0,o=0;o<t.length;o++){var i=t[o];"."!==i&&""!==i&&".."!==i?n[r++]=i:".."===i&&r>0&&r--}if(0===r)return"/";var a="";for(o=0;o<r;o++)a+="/"+n[o];return a}const _=require("uuid"),F=require("path-browserify");function I(e){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I(e)}function B(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(o=r.key,i=void 0,i=function(e,t){if("object"!==I(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==I(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===I(i)?i:String(i)),r)}var o,i}function N(e,t){return N=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},N(e,t)}function W(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=G(e);if(t){var o=G(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return function(e,t){if(t&&("object"===I(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return z(e)}(this,n)}}function z(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function G(e){return G=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},G(e)}var q=new n.Sphere(new n.Vector3(0,0,0),1),H=new n.Vector3(0,0,0),J=new n.Vector3(0,0,0),X=new n.Vector3(0,1,0),K=new n.Vector2(1e3,1e3),Y=new n.Quaternion,Q=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&N(e,t)}(s,e);var t,o,i,a=W(s);function s(e){var t;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s);var o=z(t=a.call(this));if(t.uuid=(0,_.v4)(),e.tileLoader)t.tileLoader=e.tileLoader;else{var i={};i.meshCallback=e.meshCallback?e.meshCallback:function(e){e.material.wireframe=!1,e.material.side=n.DoubleSide},i.pointsCallback=e.pointsCallback?e.pointsCallback:function(e){e.material.size=.1,e.material.sizeAttenuation=!0},t.tileLoader=new A(i)}return t.geometricErrorMultiplier=e.geometricErrorMultiplier?e.geometricErrorMultiplier:1,t.renderer=e.renderer,t.meshCallback=e.meshCallback,t.loadOutsideView=e.loadOutsideView,t.cameraOnLoad=e.cameraOnLoad,t.parentTile=e.parentTile,t.occlusionCullingService=e.occlusionCullingService,t.static=e.static,t.occlusionCullingService&&(t.color=new n.Color,t.color.setHex(16777215*Math.random()),t.colorID=(0,r.clamp)(255*o.color.r,0,255)<<16^(0,r.clamp)(255*o.color.g,0,255)<<8^(0,r.clamp)(255*o.color.b,0,255)<<0),t.static&&(t.matrixAutoUpdate=!1),t.childrenTiles=[],t.meshContent,t.tileContent,t.refinement,t.rootPath,t.geometricError,t.boundingVolume,t.json,t.materialVisibility=!1,t.inFrustum=!0,t.level=e.level?e.level:0,t.hasMeshContent=!1,t.hasUnloadedJSONContent=!1,t.centerModel=e.centerModel,t.abortController=new AbortController,t.layers.disable(0),e.json?(o.setup(e),e.onLoadCallback&&e.onLoadCallback(o)):e.url&&fetch(e.url,{signal:o.abortController.signal}).then((function(r){if(!r.ok)throw new Error("couldn't load \"".concat(e.url,'". Request failed with status ').concat(r.status," : ").concat(r.statusText));r.json().then((function(r){if(o.setup({rootPath:F.dirname(e.url),json:r}),e.onLoadCallback&&e.onLoadCallback(o),o.centerModel){var i=new n.Sphere;o.boundingVolume instanceof u?i.copy(o.boundingVolume.sphere):o.boundingVolume instanceof n.Sphere&&i.copy(o.boundingVolume),t.json.boundingVolume.region&&(t.transformWGS84ToCartesian(.5*(t.json.boundingVolume.region[0]+t.json.boundingVolume.region[2]),.5*(t.json.boundingVolume.region[1]+t.json.boundingVolume.region[3]),.5*(t.json.boundingVolume.region[4]+t.json.boundingVolume.region[5]),H),Y.setFromUnitVectors(H.normalize(),X.normalize()),o.applyQuaternion(Y)),o.translateX(-i.center.x*o.scale.x),o.translateY(-i.center.y*o.scale.y),o.translateZ(-i.center.z*o.scale.z)}}))})),t}return t=s,(o=[{key:"setup",value:function(e){if(e.json.root?(this.json=e.json.root,this.json.refinement||(this.json.refinement=e.json.refinement),this.json.geometricError||(this.json.geometricError=e.json.geometricError),this.json.transform||(this.json.transform=e.json.transform),this.json.boundingVolume||(this.json.boundingVolume=e.json.boundingVolume)):this.json=e.json,this.rootPath=e.json.rootPath?e.json.rootPath:e.rootPath,this.json.refinement?this.refinement=this.json.refinement:this.refinement=e.parentRefinement,this.json.geometricError?this.geometricError=this.json.geometricError:this.geometricError=e.parentGeometricError,this.json.transform&&!this.centerModel){var t=new n.Matrix4;t.elements=this.json.transform,this.applyMatrix4(t)}if(this.json.boundingVolume)if(this.json.boundingVolume.box)this.boundingVolume=new u(this.json.boundingVolume.box);else if(this.json.boundingVolume.region){var r=this.json.boundingVolume.region;this.transformWGS84ToCartesian(r[0],r[1],r[4],H),this.transformWGS84ToCartesian(r[2],r[3],r[5],J),H.lerp(J,.5),this.boundingVolume=new n.Sphere(new n.Vector3(H.x,H.y,H.z),H.distanceTo(J))}else if(this.json.boundingVolume.sphere){var o=this.json.boundingVolume.sphere;this.boundingVolume=new n.Sphere(new n.Vector3(o[0],o[1],o[2]),o[3])}else this.boundingVolume=e.parentBoundingVolume;else this.boundingVolume=e.parentBoundingVolume;this.json.content&&(this.json.content.uri&&this.json.content.uri.includes("json")||this.json.content.url&&this.json.content.url.includes("json")?this.hasUnloadedJSONContent=!0:this.hasMeshContent=!0,this.load())}},{key:"isAbsolutePathOrURL",value:function(e){var t=/^(?:http|https|ftp|tcp|udp):\/\/\S+/.test(e),n=e.startsWith("/")&&!e.startsWith("//");return t||n}},{key:"load",value:function(){var e,t=this;t.deleted||t.json.content&&(t.json.content.uri?e=F.isAbsolute(t.json.content.uri)||t.isAbsolutePathOrURL(t.json.content.uri)?t.json.content.uri:t.rootPath+F.sep+t.json.content.uri:t.json.content.url&&(e=F.isAbsolute(t.json.content.url)||t.isAbsolutePathOrURL(t.json.content.url)?t.json.content.url:t.rootPath+F.sep+t.json.content.url),e&&(e.includes(".b3dm")||e.includes(".glb")||e.includes(".gltf")?(t.contentURL=e,t.tileLoader.get(t.abortController,this.uuid,e,(function(e){t.deleted||(e.traverse((function(e){if(e.isMesh){if(e.layers.disable(0),t.occlusionCullingService){for(var r=e.geometry.attributes.position,o=[],i=0;i<r.count;i++)o.push(t.color.r,t.color.g,t.color.b);e.geometry.setAttribute("color",new n.Float32BufferAttribute(o,3))}t.static&&(e.matrixAutoUpdate=!1)}})),t.add(e),t.updateWorldMatrix(!1,!0),t.meshContent=e)}),t.cameraOnLoad?function(){return t.calculateDistanceToCamera(t.cameraOnLoad)}:function(){return 0},(function(){return t.getSiblings()}),t.level,!!t.json.boundingVolume.region,t.geometricError)):e.includes(".json")&&t.tileLoader.get(t.abortController,this.uuid,e,(function(n){t.deleted||(t.json.children||(t.json.children=[]),n.rootPath=F.dirname(e),t.json.children.push(n),delete t.json.content,t.hasUnloadedJSONContent=!1)}))))}},{key:"dispose",value:function(){var e=this;e.childrenTiles.forEach((function(e){return e.dispose()})),e.deleted=!0,this.traverse((function(t){t.contentURL&&e.tileLoader.invalidate(t.contentURL,t.uuid),t.abortController&&t.abortController.abort()})),this.parent=null,this.parentTile=null,this.dispatchEvent({type:"removed"})}},{key:"disposeChildren",value:function(){var e=this;e.childrenTiles.forEach((function(e){return e.dispose()})),e.childrenTiles=[],e.children=[],e.meshContent&&e.children.push(e.meshContent)}},{key:"update",value:function(e){var t=new n.Frustum;t.setFromProjectionMatrix((new n.Matrix4).multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse)),this._update(e,t)}},{key:"_update",value:function(e,t){var n,r=this,o=r.materialVisibility;function i(e){if(r.hasMeshContent&&r.meshContent){if(e<0)return r.inFrustum=!1,void r.changeContentVisibility(!!r.loadOutsideView);if(r.inFrustum=!0,0!=r.childrenTiles.length){if(e>=r.geometricErrorMultiplier*r.geometricError)r.changeContentVisibility(!0);else if(e<r.geometricErrorMultiplier*r.geometricError){var t=!0;r.childrenTiles.every((function(e){return!!e.isReady()||(t=!1,!1)})),t&&r.changeContentVisibility(!1)}}else r.changeContentVisibility(!0)}}r.boundingVolume&&r.geometricError&&(r.metric=r.calculateUpdateMetric(e,t)),r.childrenTiles.forEach((function(n){return n._update(e,t)})),i(r.metric),(n=r.metric)<0&&r.hasMeshContent||r.occlusionCullingService&&r.hasMeshContent&&!r.occlusionCullingService.hasID(r.colorID)||(!r.hasMeshContent||n<r.geometricErrorMultiplier*r.geometricError&&r.meshContent)&&r.json&&r.json.children&&r.childrenTiles.length!=r.json.children.length&&r.json.children.forEach((function(t){var n=new s({parentTile:r,parentGeometricError:r.geometricError,parentBoundingVolume:r.boundingVolume,parentRefinement:r.refinement,json:t,rootPath:r.rootPath,geometricErrorMultiplier:r.geometricErrorMultiplier,loadOutsideView:r.loadOutsideView,level:r.level+1,tileLoader:r.tileLoader,cameraOnLoad:e,occlusionCullingService:r.occlusionCullingService,renderer:r.renderer,static:r.static,centerModel:!1});r.childrenTiles.push(n),r.add(n)})),function(e,t){if(r.hasMeshContent)r.inFrustum?r.occlusionCullingService&&!t&&r.hasMeshContent&&r.meshContent&&r.meshDisplayed&&r.areAllChildrenLoadedAndHidden()?(r.disposeChildren(),i(e)):e>=r.geometricErrorMultiplier*r.geometricError&&(r.disposeChildren(),i()):(r.disposeChildren(),i(e))}(r.metric,o)}},{key:"areAllChildrenLoadedAndHidden",value:function(){var e=!0,t=this;return this.childrenTiles.every((function(n){if(n.hasMeshContent){if(n.childrenTiles.length>0)return e=!1,!1;if(!n.inFrustum)return!0;if(!n.materialVisibility||n.meshDisplayed)return e=!1,!1;if(t.occlusionCullingService.hasID(n.colorID))return e=!1,!1}else if(!n.areAllChildrenLoadedAndHidden())return e=!1,!1;return!0})),e}},{key:"isReady",value:function(){if(!this.inFrustum)return!0;if(this.hasUnloadedJSONContent)return!1;if((!this.hasMeshContent||!this.meshContent||!this.materialVisibility)&&this.childrenTiles.length>0){var e=!0;return this.childrenTiles.every((function(t){return!!t.isReady()||(e=!1,!1)})),e}return!this.hasMeshContent||!!this.meshContent&&!!this.materialVisibility&&!!this.meshDisplayed}},{key:"changeContentVisibility",value:function(e){var t=this;function n(e,n){e.material.visible=n,n&&(e.onAfterRender=function(){delete e.onAfterRender,t.meshDisplayed=!0})}t.hasMeshContent&&t.meshContent&&(e?t.meshContent.traverse((function(e){e.isMesh&&e.layers.enable(0)})):t.meshContent.traverse((function(e){e.isMesh&&e.layers.disable(0)}))),t.materialVisibility!=e&&(t.materialVisibility=e,t.meshDisplayed=!0,t.meshContent.traverse?t.meshContent.traverse((function(t){t.material&&n(t,e)})):t.meshContent.scenes&&t.meshContent.scenes.forEach((function(t){return t.traverse((function(t){t.material&&n(t,e)}))})))}},{key:"calculateUpdateMetric",value:function(e,t){if(this.boundingVolume instanceof u){if(q.copy(this.boundingVolume.sphere),q.applyMatrix4(this.matrixWorld),!t.intersectsSphere(q))return-1}else{if(!(this.boundingVolume instanceof n.Sphere))return console.error("unsupported shape"),-1;if(q.copy(this.boundingVolume),q.applyMatrix4(this.matrixWorld),!t.intersectsSphere(q))return-1}var r=Math.max(0,e.position.distanceTo(q.center)-q.radius);if(0==r)return 0;var o=this.matrixWorld.getMaxScaleOnAxis();this.renderer&&this.renderer.getDrawingBufferSize(K);var i=K.y,a=e.fov;e.aspect<1&&(a*=e.aspect,i=K.x);var s=2*Math.tan(.5*a*.017453292519943295)*r;return 16*window.devicePixelRatio*s/(i*o)}},{key:"getSiblings",value:function(){var e=this,t=[];if(!e.parentTile)return t;for(var n=e.parentTile;!n.hasMeshContent&&n.parentTile;)n=n.parentTile;return n.childrenTiles.forEach((function(n){if(n&&n!=e){for(;!n.hasMeshContent&&n.childrenTiles[0];)n=n.childrenTiles[0];t.push(n)}})),t}},{key:"calculateDistanceToCamera",value:function(e){return this.boundingVolume instanceof u?(q.copy(this.boundingVolume.sphere),q.applyMatrix4(this.matrixWorld)):this.boundingVolume instanceof n.Sphere?(q.copy(this.boundingVolume),q.applyMatrix4(this.matrixWorld)):console.error("unsupported shape"),Math.max(0,e.position.distanceTo(q.center)-q.radius)}},{key:"setGeometricErrorMultiplier",value:function(e){this.geometricErrorMultiplier=e,this.childrenTiles.forEach((function(t){return t.setGeometricErrorMultiplier(e)}))}},{key:"transformWGS84ToCartesian",value:function(e,t,n,r){var o=6378137/Math.sqrt(1-.006694384442042*Math.pow(Math.sin(t),2)),i=Math.cos(t),a=Math.cos(e),s=Math.sin(t),l=o+n,u=l*i*a,c=l*i*Math.sin(e),h=(.993305615557957*o+n)*s;r.set(u,c,h)}}])&&B(t.prototype,o),i&&B(t,i),Object.defineProperty(t,"prototype",{writable:!1}),s}(n.Object3D);function Z(e){return Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Z(e)}function $(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(o=r.key,i=void 0,i=function(e,t){if("object"!==Z(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==Z(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===Z(i)?i:String(i)),r)}var o,i}function ee(e,t){return ee=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ee(e,t)}function te(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=re(e);if(t){var o=re(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return function(e,t){if(t&&("object"===Z(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return ne(e)}(this,n)}}function ne(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(e){return re=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},re(e)}var oe=new n.Sphere(new n.Vector3(0,0,0),1),ie=new n.Vector3(0,0,0),ae=new n.Vector3(0,0,0),se=new n.Vector3(0,1,0),le=new n.Vector2,ue=new n.Quaternion,ce=new n.Matrix4,he=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ee(e,t)}(a,e);var t,r,o,i=te(a);function a(e){var t;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a);var r=ne(t=i.call(this));return t.uuid=(0,_.v4)(),e.tileLoader?t.tileLoader=e.tileLoader:console.error("an instanced tileset must be provided an InstancedTilesetLoader"),t.master=e.master,t.meshCallback=e.meshCallback,t.loadOutsideView=e.loadOutsideView,t.cameraOnLoad=e.cameraOnLoad,t.parentTile=e.parentTile,t.childrenTiles=[],t.jsonChildren=[],t.meshContent,t.tileContent,t.refinement,t.rootPath,t.geometricError,t.boundingVolume,t.json,t.materialVisibility=!1,t.inFrustum=!0,t.level=e.level?e.level:0,t.hasMeshContent=!1,t.hasUnloadedJSONContent=!1,t.centerModel=e.centerModel,t.deleted=!1,t.abortController=new AbortController,e.json?(t.rootPath=e.json.rootPath?e.json.rootPath:e.rootPath,e.json.children&&(t.jsonChildren=e.json.children),r.setup(e),e.onLoadCallback&&e.onLoadCallback(r)):e.url&&(t.loadJson=function(o,i){var a=F.dirname(i);if(r.setup({rootPath:a,json:o}),r.centerModel){var s=new n.Sphere;r.boundingVolume instanceof u?s.copy(r.boundingVolume.sphere):r.boundingVolume instanceof n.Sphere&&s.copy(r.boundingVolume),t.json.boundingVolume.region&&(r.transformWGS84ToCartesian(.5*(r.json.boundingVolume.region[0]+r.json.boundingVolume.region[2]),.5*(r.json.boundingVolume.region[1]+r.json.boundingVolume.region[3]),.5*(r.json.boundingVolume.region[4]+r.json.boundingVolume.region[5]),ie),ue.setFromUnitVectors(ie.normalize(),se.normalize()),r.master.applyQuaternion(ue),r.master.updateWorldMatrix(!1,!1)),ce.makeTranslation(-s.center.x*r.scale.x,-s.center.y*r.scale.y,-s.center.z*r.scale.z),r.master.matrix.multiply(ce),r.master.matrix.decompose(r.master.position,r.master.quaternion,r.master.scale)}e.onLoadCallback&&e.onLoadCallback(r)},r.tileLoader.get(r.abortController,e.url,r.uuid,r)),t}return t=a,(r=[{key:"setup",value:function(e){if(this.isSetup=!0,e.json.root?(this.json=e.json.root,this.jsonChildren=this.json.children,this.json.refinement||(this.json.refinement=e.json.refinement),this.json.geometricError||(this.json.geometricError=e.json.geometricError),this.json.transform||(this.json.transform=e.json.transform),this.json.boundingVolume||(this.json.boundingVolume=e.json.boundingVolume)):this.json=e.json,this.rootPath=e.json.rootPath?e.json.rootPath:e.rootPath,this.json.refinement?this.refinement=this.json.refinement:this.refinement=e.parentRefinement,this.json.geometricError?this.geometricError=this.json.geometricError:this.geometricError=e.parentGeometricError,this.json.transform&&!this.centerModel){var t=new n.Matrix4;t.elements=this.json.transform,this.master.applyMatrix4(t)}if(this.json.boundingVolume)if(this.json.boundingVolume.box)this.boundingVolume=new u(this.json.boundingVolume.box);else if(this.json.boundingVolume.region){var r=this.json.boundingVolume.region;this.transformWGS84ToCartesian(r[0],r[1],r[4],ie),this.transformWGS84ToCartesian(r[2],r[3],r[5],ae),ie.lerp(ae,.5),this.boundingVolume=new n.Sphere(new n.Vector3(ie.x,ie.y,ie.z),ie.distanceTo(ae))}else if(this.json.boundingVolume.sphere){var o=this.json.boundingVolume.sphere;this.boundingVolume=new n.Sphere(new n.Vector3(o[0],o[2],-o[1]),o[3])}else this.boundingVolume=e.parentBoundingVolume;else this.boundingVolume=e.parentBoundingVolume;this.json.content&&(this.json.content.uri&&this.json.content.uri.includes("json")||this.json.content.url&&this.json.content.url.includes("json")?this.hasUnloadedJSONContent=!0:this.hasMeshContent=!0,this.load())}},{key:"isAbsolutePathOrURL",value:function(e){var t=/^(?:http|https|ftp|tcp|udp):\/\/\S+/.test(e),n=e.startsWith("/")&&!e.startsWith("//");return t||n}},{key:"load",value:function(){var e,t=this;t.deleted||(t.json.content&&(t.json.content.uri?e=F.isAbsolute(t.json.content.uri)||t.isAbsolutePathOrURL(t.json.content.uri)?t.json.content.uri:t.rootPath+F.sep+t.json.content.uri:t.json.content.url&&(e=F.isAbsolute(t.json.content.url)||t.isAbsolutePathOrURL(t.json.content.url)?t.json.content.url:t.rootPath+F.sep+t.json.content.url),e&&(e.includes(".b3dm")||e.includes(".glb")||e.includes(".gltf")?(t.contentURL=e,t.tileLoader.get(t.abortController,e,t.uuid,t,t.cameraOnLoad?function(){return t.calculateDistanceToCamera(t.cameraOnLoad)}:function(){return 0},(function(){return t.getSiblings()}),t.level,!!t.json.boundingVolume.region,t.geometricError)):e.includes(".json")&&t.tileLoader.get(t.abortController,e,t.uuid,t))),t.matrixWorldNeedsUpdate=!0,t.updateWorldMatrix(!0,!0))}},{key:"loadMesh",value:function(e){this.deleted||(this.meshContent=e)}},{key:"loadJson",value:function(e,t){this.deleted||(this.json.children&&(this.jsonChildren=this.json.children),e.rootPath=F.dirname(t),this.jsonChildren.push(e),this.hasUnloadedJSONContent=!1)}},{key:"dispose",value:function(){var e=this;e.childrenTiles.forEach((function(e){return e.dispose()})),e.deleted=!0,e.abortController&&e.abortController.abort(),this.parent=null,this.parentTile=null,this.dispatchEvent({type:"removed"})}},{key:"disposeChildren",value:function(){this.childrenTiles.forEach((function(e){return e.dispose()})),this.childrenTiles=[]}},{key:"_update",value:function(e,t){var n,r=this;function o(e){if(r.hasMeshContent&&r.meshContent){if(e<0)return r.inFrustum=!1,void r.changeContentVisibility(!!r.loadOutsideView);if(r.inFrustum=!0,0!=r.childrenTiles.length){if(e>=r.master.geometricErrorMultiplier*r.geometricError)r.changeContentVisibility(!0);else if(e<r.master.geometricErrorMultiplier*r.geometricError){var t=!0;r.childrenTiles.every((function(e){return!!e.isReady()||(t=!1,!1)})),t&&r.changeContentVisibility(!1)}}else r.changeContentVisibility(!0)}}r.materialVisibility,r.boundingVolume&&r.geometricError&&(r.metric=r.calculateUpdateMetric(e,t)),r.childrenTiles.forEach((function(n){return n._update(e,t)})),o(r.metric),(n=r.metric)<0&&r.hasMeshContent||(!r.hasMeshContent&&r.rootPath||n<r.master.geometricErrorMultiplier*r.geometricError&&r.meshContent)&&r.json&&r.jsonChildren&&r.childrenTiles.length!=r.jsonChildren.length&&r.jsonChildren.forEach((function(t){var n=new a({parentTile:r,parentGeometricError:r.geometricError,parentBoundingVolume:r.boundingVolume,parentRefinement:r.refinement,json:t,rootPath:r.rootPath,loadOutsideView:r.loadOutsideView,level:r.level+1,tileLoader:r.tileLoader,cameraOnLoad:e,master:r.master,centerModel:!1});r.childrenTiles.push(n)})),function(e,t){if(r.hasMeshContent)r.inFrustum?e>=r.master.geometricErrorMultiplier*r.geometricError&&(r.disposeChildren(),o(e)):(r.disposeChildren(),o(e))}(r.metric)}},{key:"areAllChildrenLoadedAndHidden",value:function(){var e=!0;return this.childrenTiles.every((function(t){if(t.hasMeshContent){if(t.childrenTiles.length>0)return e=!1,!1;if(!t.inFrustum)return!0;if(!t.materialVisibility||t.meshesToDisplay!=t.meshesDisplayed)return e=!1,!1}else if(!t.areAllChildrenLoadedAndHidden())return e=!1,!1;return!0})),e}},{key:"isReady",value:function(){if(!this.inFrustum)return!0;if(this.hasUnloadedJSONContent)return!1;if((!this.hasMeshContent||!this.meshContent||!this.materialVisibility)&&this.childrenTiles.length>0){var e=!0;return this.childrenTiles.every((function(t){return!!t.isReady()||(e=!1,!1)})),e}return!this.hasMeshContent||!!this.meshContent&&!!this.materialVisibility&&!!this.meshContent.displayedOnce}},{key:"changeContentVisibility",value:function(e){this.materialVisibility=e}},{key:"calculateUpdateMetric",value:function(e,t){if(this.boundingVolume instanceof u){if(oe.copy(this.boundingVolume.sphere),oe.applyMatrix4(this.master.matrixWorld),!t.intersectsSphere(oe))return-1}else{if(!(this.boundingVolume instanceof n.Sphere))return console.error("unsupported shape"),-1;if(oe.copy(this.boundingVolume),oe.applyMatrix4(this.master.matrixWorld),!t.intersectsSphere(oe))return-1}if(this.boundingVolume instanceof u||this.boundingVolume instanceof n.Sphere){var r=Math.max(0,e.position.distanceTo(oe.center)-oe.radius);if(0==r)return 0;var o=this.master.matrixWorld.getMaxScaleOnAxis();this.master.renderer.getDrawingBufferSize(le);var i=le.y,a=e.fov;e.aspect<1&&(a*=e.aspect,i=le.x);var s=2*Math.tan(.5*a*.017453292519943295)*r;return 16*window.devicePixelRatio*s/(i*o)}if(this.boundingVolume instanceof n.Box3)return-1}},{key:"getSiblings",value:function(){var e=this,t=[];if(!e.parentTile)return t;for(var n=e.parentTile;!n.hasMeshContent&&n.parentTile;)n=n.parentTile;return n.childrenTiles.forEach((function(n){if(n&&n!=e){for(;!n.hasMeshContent&&n.childrenTiles[0];)n=n.childrenTiles[0];t.push(n)}})),t}},{key:"calculateDistanceToCamera",value:function(e){return this.boundingVolume instanceof u?(oe.copy(this.boundingVolume.sphere),oe.applyMatrix4(this.master.matrixWorld)):this.boundingVolume instanceof n.Sphere?(oe.copy(this.boundingVolume),oe.applyMatrix4(this.master.matrixWorld)):console.error("unsupported shape"),Math.max(0,e.position.distanceTo(oe.center)-oe.radius)}},{key:"getWorldMatrix",value:function(){return this.master.matrixWorld}},{key:"transformWGS84ToCartesian",value:function(e,t,n,r){var o=6378137/Math.sqrt(1-.006694384442042*Math.pow(Math.sin(t),2)),i=Math.cos(t),a=Math.cos(e),s=Math.sin(t),l=o+n,u=l*i*a,c=l*i*Math.sin(e),h=(.993305615557957*o+n)*s;r.set(u,c,h)}}])&&$(t.prototype,r),o&&$(t,o),Object.defineProperty(t,"prototype",{writable:!1}),a}(n.Object3D);function de(e){return de="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},de(e)}function fe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(o=r.key,i=void 0,i=function(e,t){if("object"!==de(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==de(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===de(i)?i:String(i)),r)}var o,i}function pe(e,t){return pe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},pe(e,t)}function me(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=be(e);if(t){var o=be(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return function(e,t){if(t&&("object"===de(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return ye(e)}(this,n)}}function ye(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function be(e){return be=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},be(e)}var ge=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&pe(e,t)}(a,e);var t,r,o,i=me(a);function a(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),t=i.call(this),e.master=ye(t),t.renderer=e.renderer,t.geometricErrorMultiplier=e.geometricErrorMultiplier?e.geometricErrorMultiplier:1,t.tileset=new he(e),e.static&&(t.matrixAutoUpdate=!1),t}return t=a,(r=[{key:"update",value:function(e,t){if(t)this.tileset._update(e,t);else{var r=new n.Frustum;r.setFromProjectionMatrix((new n.Matrix4).multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse)),this.tileset._update(e,r)}}},{key:"updateWithFrustum",value:function(e,t){this.tileset._update(e,t)}},{key:"setGeometricErrorMultiplier",value:function(e){this.geometricErrorMultiplier=e||1}}])&&fe(t.prototype,r),o&&fe(t,o),Object.defineProperty(t,"prototype",{writable:!1}),a}(n.Object3D);function ve(e){return ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ve(e)}function we(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(o=r.key,i=void 0,i=function(e,t){if("object"!==ve(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==ve(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===ve(i)?i:String(i)),r)}var o,i}var je=new n.Matrix4,Ce=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var r=this;r.scene=t,r.instancedTiles=[],r.instancedMesh,r.reuseableMatrix=new n.Matrix4}var t,r,o;return t=e,(r=[{key:"addInstance",value:function(e){var t=this;e.added=!0,e.listOMesh=t.instancedTiles,t.instancedTiles.push(e),t.instancedMesh&&e.loadMesh(t.instancedMesh)}},{key:"addToScene",value:function(){var e=this;e.instancedMesh.setMatrixAt(0,new n.Matrix4),e.instancedMesh.instanceMatrix.needsUpdate=!0,e.instancedMesh.count=1,e.scene.add(e.instancedMesh),e.instancedMesh.onAfterRender=function(){delete e.instancedMesh.onAfterRender,e.instancedMesh.displayedOnce=!0}}},{key:"setObject",value:function(e){var t=this;t.instancedMesh=e;for(var n=0;n<t.instancedTiles.length;n++)t.instancedTiles[n].loadMesh(t.instancedMesh)}},{key:"update",value:function(){for(var e=this,t=e.instancedTiles.length-1;t>=0;t--)e.instancedTiles[t].deleted&&e.instancedTiles.splice(t,1);if(e.instancedMesh){e.instancedMesh.count=0;for(var n=0;n<e.instancedTiles.length;n++)e.instancedTiles[n].meshContent=e.instancedMesh,e.instancedTiles[n].materialVisibility&&e.instancedTiles[n].meshContent&&(e.instancedMesh.count++,e.reuseableMatrix.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),e.reuseableMatrix.multiply(e.instancedTiles[n].master.matrixWorld),e.reuseableMatrix.multiply(e.instancedMesh.baseMatrix),e.instancedMesh.setMatrixAt(e.instancedMesh.count-1,e.reuseableMatrix),e.instancedMesh.getMatrixAt(0,je),console.log());e.instancedMesh.instanceMatrix.needsUpdate=!0}}},{key:"getCount",value:function(){return this.instancedTiles.length}}])&&we(t.prototype,r),o&&we(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Me(e){return Me="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Me(e)}function xe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(o=r.key,i=void 0,i=function(e,t){if("object"!==Me(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==Me(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===Me(i)?i:String(i)),r)}var o,i}var Te=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var t=this;t.count=0,t.json,t.instancedTiles=[]}var t,n,r;return t=e,(n=[{key:"addInstance",value:function(e){this.instancedTiles.push(e),this.json&&e.loadJson(this.json,this.url)}},{key:"setObject",value:function(e,t){var n=this;n.json=e,n.url=t;for(var r=0;r<n.instancedTiles.length;r++)n.instancedTiles[r].loadJson(n.json,n.url)}},{key:"getCount",value:function(){return this.instancedTiles.length}},{key:"update",value:function(){for(var e=this,t=e.instancedTiles.length-1;t>=0;t--)e.instancedTiles[t].deleted&&e.instancedTiles.splice(t,1)}}])&&xe(t.prototype,n),r&&xe(t,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function Se(e){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Se(e)}function ke(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(o=r.key,i=void 0,i=function(e,t){if("object"!==Se(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==Se(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===Se(i)?i:String(i)),r)}var o,i}var Oe=0,Ee=new n.Matrix4;Ee.set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1);var Ve=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.maxCachedItems=100,this.maxInstances=1,n&&(this.meshCallback=n.meshCallback,this.pointsCallback=n.pointsCallback,n.maxCachedItems&&(this.maxCachedItems=n.maxCachedItems),n.maxInstances&&(this.maxInstances=n.maxInstances)),this.gltfLoader=new V.GLTFLoader;var r=new d.DRACOLoader;if(r.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),this.gltfLoader.setDRACOLoader(r),n&&n.renderer){var o=new f.KTX2Loader;o.setTranscoderPath("https://storage.googleapis.com/ogc-3d-tiles/basis/").detectSupport(n.renderer),this.gltfLoader.setKTX2Loader(o),this.b3dmDecoder=new O(n.renderer)}else this.b3dmDecoder=new O(null);this.cache=new c.LinkedHashMap,this.scene=t,this.ready=[],this.downloads=[],this.nextReady=[],this.nextDownloads=[],this.init()}var t,r,o;return t=e,(r=[{key:"update",value:function(){this.cache._data.forEach((function(e){e.update()}))}},{key:"init",value:function(){var e=this;(0,E.setIntervalAsync)((function(){e.download()}),10),(0,E.setIntervalAsync)((function(){var t=Date.now(),n=0;do{n=e.loadBatch()}while(n>0&&Date.now()-t<=0)}),10)}},{key:"download",value:function(){var e=this,t=this;if(0!=t.nextDownloads.length||(t.getNextDownloads(),0!=t.nextDownloads.length))for(var r=function(){var r=t.nextDownloads.shift();r&&r.shouldDoDownload()&&(Oe++,r.path.includes(".b3dm")&&fetch(r.path,{signal:r.abortController.signal}).then((function(e){if(Oe--,!e.ok)throw console.error("could not load tile with path : "+path),new Error("couldn't load \"".concat(path,'". Request failed with status ').concat(e.status," : ").concat(e.statusText));return e.arrayBuffer()})).then((function(n){return e.b3dmDecoder.parseB3DMInstanced(n,t.meshCallback,t.maxInstances,r.zUpToYUp)})).then((function(e){r.tile.setObject(e),t.ready.unshift(r)})).catch((function(e){return console.error(e)})),r.path.includes(".glb")||r.path.includes(".gltf")?e.gltfLoader.load(r.path,(function(e){var o;e.scene.traverse((function(e){e.geometricError=r.geometricError,e.isMesh&&(r.zUpToYUp&&e.applyMatrix4(Ee),t.meshCallback&&t.meshCallback(e)),e.isPoints&&console.error("instanced point cloud is not supported")})),e.scene.updateWorldMatrix(!1,!0),e.scene.traverse((function(e){e.isMesh&&((o=new n.InstancedMesh(e.geometry,e.material,t.maxInstances)).baseMatrix=e.matrixWorld)})),t.ready.unshift(r),o?r.tile.setObject(o):e.scene.traverse((function(e){e.dispose&&e.dispose(),e.material&&e.material.dispose()}))})):r.path.includes(".json")&&(Oe++,fetch(r.path,{signal:r.abortController.signal}).then((function(e){if(Oe--,!e.ok)throw console.error("could not load tile with path : "+path),new Error("couldn't load \"".concat(path,'". Request failed with status ').concat(e.status," : ").concat(e.statusText));return e.json()})).then((function(e){r.tile.setObject(e,r.path),t.ready.unshift(r)})).catch((function(e){return console.error(e)}))))};t.nextDownloads.length>0&&Oe<500;)r()}},{key:"loadBatch",value:function(){if(0==this.nextReady.length&&(this.getNextReady(),0==this.nextReady.length))return 0;var e=this.nextReady.shift();return e?(e.tile.addToScene&&e.tile.addToScene(),1):0}},{key:"getNextReady",value:function(){for(var e=Number.MAX_VALUE,t=-1,n=this.ready.length-1;n>=0;n--)this.ready[n].distanceFunction||this.nextReady.push(this.ready.splice(n,1)[0]);if(!(this.nextReady.length>0)){for(var r=this.ready.length-1;r>=0;r--){var o=this.ready[r].distanceFunction()*this.ready[r].level;o<e&&(e=o,t=r)}if(t>=0){var i=this.ready.splice(t,1).pop();this.nextReady.push(i);for(var a=i.getSiblings(),s=this.ready.length-1;s>=0;s--)a.includes(this.ready[s].uuid)&&this.nextready.push(this.ready.splice(s,1).pop())}}}},{key:"get",value:function(e,t,n,r,o,i,a,s,l){var u=this,c=function(e){for(var t=e.split("/"),n=[],r=0,o=0;o<t.length;o++){var i=t[o];"."!==i&&""!==i&&".."!==i?n[r++]=i:".."===i&&r>0&&r--}if(0===r)return"/";var a="";for(o=0;o<r;o++)a+="/"+n[o];return a}(t);if(t.includes(".b3dm")||t.includes(".json")||t.includes(".glb")||t.includes(".gltf")){var h=u.cache.get(c);if(h)h.addInstance(r);else if(t.includes(".b3dm")||t.includes(".glb")||t.includes(".gltf")){var d=new Ce(u.scene);d.addInstance(r),u.cache.put(c,d);var f=new AbortController;e.signal.addEventListener("abort",(function(){0==d.getCount()&&f.abort()})),this.downloads.push({abortController:f,tile:d,key:c,path:t,distanceFunction:o,getSiblings:i,level:a,uuid:n,zUpToYUp:s,geometricError:l,shouldDoDownload:function(){return!0}})}else if(t.includes(".json")){var p=new Te;p.addInstance(r),u.cache.put(c,p);var m=new AbortController;e.signal.addEventListener("abort",(function(){0==p.getCount()&&m.abort()})),this.downloads.push({abortController:m,tile:p,key:c,path:t,distanceFunction:o,getSiblings:i,level:a,shouldDoDownload:function(){return!0}})}}else console.error("the 3DTiles cache can only be used to load B3DM, gltf and json data")}},{key:"getNextDownloads",value:function(){for(var e=Number.MAX_VALUE,t=-1,n=this.downloads.length-1;n>=0;n--){var r=this.downloads[n];r.shouldDoDownload()?r.distanceFunction||this.nextDownloads.push(this.downloads.splice(n,1)[0]):this.downloads.splice(n,1)}if(!(this.nextDownloads.length>0)){for(var o=this.downloads.length-1;o>=0;o--){var i=this.downloads[o],a=i.distanceFunction()*i.level;a<e&&(e=a,t=o)}if(t>=0){var s=this.downloads.splice(t,1).pop();this.nextDownloads.push(s);for(var l=s.getSiblings(),u=this.downloads.length-1;u>=0;u--)l.includes(this.downloads[u].uuid)&&this.nextDownloads.push(this.downloads.splice(u,1).pop())}}}},{key:"checkSize",value:function(){for(var e=this,t=0;e.cache.size()>e.maxCachedItems&&t<e.cache.size();){t++;var n=e.cache.head();n.value.getCount()>0?(e.cache.remove(n.key),e.cache.put(n.key,n.value)):(e.cache.remove(n.key),n.value.instancedMesh&&n.value.instancedMesh.traverse((function(e){if(e.material)if(e.material.length)for(var t=0;t<e.material.length;++t)e.material[t].dispose();else e.material.dispose();e.geometry&&e.geometry.dispose()})))}}}])&&ke(t.prototype,r),o&&ke(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}();return t})()));
|
|
2
|
+
//# sourceMappingURL=threedtiles.min.js.map
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jdultra/threedtiles",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "An OGC 3DTiles viewer for Three.js",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "dist/threedtiles.min.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/threedtiles.min.js",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE"
|
|
10
|
+
],
|
|
6
11
|
"scripts": {
|
|
7
|
-
"build": "webpack",
|
|
8
|
-
"watch": "webpack --watch",
|
|
9
|
-
"dev": "webpack-dev-server"
|
|
12
|
+
"build": "webpack --config webpack.prod.config.js",
|
|
13
|
+
"watch": "webpack --watch --config webpack.dev.config.js",
|
|
14
|
+
"dev": "webpack-dev-server --config webpack.dev.config.js"
|
|
10
15
|
},
|
|
11
16
|
"repository": {
|
|
12
17
|
"type": "git",
|
|
@@ -22,16 +27,14 @@
|
|
|
22
27
|
],
|
|
23
28
|
"author": "Emeric Beaufays",
|
|
24
29
|
"license": "MIT",
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"lru-cache": "^7.14.1",
|
|
30
|
-
"mnemonist": "^0.39.5",
|
|
30
|
+
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
|
|
33
|
+
"js-utils-z": "^1.2.1",
|
|
31
34
|
"path-browserify": "^1.0.1",
|
|
32
35
|
"regenerator-runtime": "^0.13.11",
|
|
33
36
|
"set-interval-async": "^2.0.3",
|
|
34
|
-
"three": "0.148.0",
|
|
37
|
+
"three": "^0.148.0",
|
|
35
38
|
"uuid": "^8.3.2"
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
@@ -48,6 +51,7 @@
|
|
|
48
51
|
"webpack-cli": "^5.0.1",
|
|
49
52
|
"webpack-dev-server": "^4.13.2",
|
|
50
53
|
"webpack-glsl-loader": "^1.0.1",
|
|
54
|
+
"webpack-node-externals": "^3.0.0",
|
|
51
55
|
"whatwg-fetch": "^3.5.0"
|
|
52
56
|
}
|
|
53
|
-
}
|
|
57
|
+
}
|
package/.babelrc
DELETED
package/.vscode/settings.json
DELETED
package/index.html
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8" />
|
|
6
|
-
<title>Three 3DTiles viewer sample</title>
|
|
7
|
-
<style>
|
|
8
|
-
.slidecontainer {
|
|
9
|
-
width: 100%;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.slider {
|
|
13
|
-
-webkit-appearance: none;
|
|
14
|
-
width: 100%;
|
|
15
|
-
height: 15px;
|
|
16
|
-
border-radius: 5px;
|
|
17
|
-
background: #d3d3d3;
|
|
18
|
-
outline: none;
|
|
19
|
-
opacity: 0.7;
|
|
20
|
-
-webkit-transition: .2s;
|
|
21
|
-
transition: opacity .2s;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.slider:hover {
|
|
25
|
-
opacity: 1;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.slider::-webkit-slider-thumb {
|
|
29
|
-
-webkit-appearance: none;
|
|
30
|
-
appearance: none;
|
|
31
|
-
width: 25px;
|
|
32
|
-
height: 25px;
|
|
33
|
-
border-radius: 50%;
|
|
34
|
-
background: #0439aa;
|
|
35
|
-
cursor: pointer;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.slider::-moz-range-thumb {
|
|
39
|
-
width: 25px;
|
|
40
|
-
height: 25px;
|
|
41
|
-
border-radius: 50%;
|
|
42
|
-
background: #04AA6D;
|
|
43
|
-
cursor: pointer;
|
|
44
|
-
}
|
|
45
|
-
</style>
|
|
46
|
-
</head>
|
|
47
|
-
|
|
48
|
-
<body>
|
|
49
|
-
<div id="screen"></div>
|
|
50
|
-
<!-- <div style="position: absolute; top: 1%; z-index: 100; right:1%; ">
|
|
51
|
-
<input type="range" min="0.0" max="1.0" value="0.5", step="0.001" class="slider" id="lodMultiplier" >
|
|
52
|
-
<p style="color: #0439aa;">LOD multiplier: <span id="multiplierValue"></span></p>
|
|
53
|
-
</div> -->
|
|
54
|
-
</body>
|
|
55
|
-
|
|
56
|
-
</html>
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
2
|
-
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
|
|
3
|
-
import { KTX2Loader } from "three/examples/jsm/loaders/KTX2Loader";
|
|
4
|
-
import * as THREE from 'three';
|
|
5
|
-
import { FeatureTable, BatchTable } from './FeatureTable';
|
|
6
|
-
|
|
7
|
-
const zUpToYUpMatrix = new THREE.Matrix4();
|
|
8
|
-
zUpToYUpMatrix.set(
|
|
9
|
-
1, 0, 0, 0,
|
|
10
|
-
0, 0, -1, 0,
|
|
11
|
-
0, 1, 0, 0,
|
|
12
|
-
0, 0, 0, 1);
|
|
13
|
-
|
|
14
|
-
export class B3DMDecoder {
|
|
15
|
-
constructor(renderer) {
|
|
16
|
-
this.gltfLoader = new GLTFLoader();
|
|
17
|
-
const dracoLoader = new DRACOLoader();
|
|
18
|
-
dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.4.3/');
|
|
19
|
-
this.gltfLoader.setDRACOLoader(dracoLoader);
|
|
20
|
-
if (renderer) {
|
|
21
|
-
const ktx2Loader = new KTX2Loader();
|
|
22
|
-
ktx2Loader.setTranscoderPath('https://storage.googleapis.com/ogc-3d-tiles/basis/').detectSupport(renderer);
|
|
23
|
-
this.gltfLoader.setKTX2Loader(ktx2Loader)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
this.tempMatrix = new THREE.Matrix4();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
parseB3DM(arrayBuffer, meshCallback, geometricError, zUpToYUp) {
|
|
30
|
-
const dataView = new DataView(arrayBuffer);
|
|
31
|
-
|
|
32
|
-
const magic =
|
|
33
|
-
String.fromCharCode(dataView.getUint8(0)) +
|
|
34
|
-
String.fromCharCode(dataView.getUint8(1)) +
|
|
35
|
-
String.fromCharCode(dataView.getUint8(2)) +
|
|
36
|
-
String.fromCharCode(dataView.getUint8(3));
|
|
37
|
-
console.assert(magic === 'b3dm');
|
|
38
|
-
|
|
39
|
-
const byteLength = dataView.getUint32(8, true);
|
|
40
|
-
console.assert(byteLength === arrayBuffer.byteLength);
|
|
41
|
-
|
|
42
|
-
const featureTableJSONByteLength = dataView.getUint32(12, true);
|
|
43
|
-
const featureTableBinaryByteLength = dataView.getUint32(16, true);
|
|
44
|
-
const batchTableJSONByteLength = dataView.getUint32(20, true);
|
|
45
|
-
const batchTableBinaryByteLength = dataView.getUint32(24, true);
|
|
46
|
-
|
|
47
|
-
const featureTableStart = 28;
|
|
48
|
-
const featureTable = new FeatureTable(arrayBuffer, featureTableStart, featureTableJSONByteLength, featureTableBinaryByteLength);
|
|
49
|
-
|
|
50
|
-
const batchTableStart = featureTableStart + featureTableJSONByteLength + featureTableBinaryByteLength;
|
|
51
|
-
const batchTable = new BatchTable(arrayBuffer, featureTable.getData('BATCH_LENGTH'), batchTableStart, batchTableJSONByteLength, batchTableBinaryByteLength);
|
|
52
|
-
|
|
53
|
-
const glbStart = batchTableStart + batchTableJSONByteLength + batchTableBinaryByteLength;
|
|
54
|
-
const glbBytes = new Uint8Array(arrayBuffer, glbStart, byteLength - glbStart);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const gltfBuffer = glbBytes.slice().buffer;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return new Promise((resolve, reject) => {
|
|
61
|
-
|
|
62
|
-
this.gltfLoader.parse(gltfBuffer, null, model => {
|
|
63
|
-
|
|
64
|
-
////TODO
|
|
65
|
-
|
|
66
|
-
//model.batchTable = b3dm.batchTable;
|
|
67
|
-
//model.featureTable = b3dm.featureTable;
|
|
68
|
-
|
|
69
|
-
//model.scene.batchTable = b3dm.batchTable;
|
|
70
|
-
//model.scene.featureTable = b3dm.featureTable;
|
|
71
|
-
|
|
72
|
-
//const scene = mergeColoredObject(model.scene);
|
|
73
|
-
|
|
74
|
-
//model.scene.applyMatrix4(ytozUpMatrix);
|
|
75
|
-
|
|
76
|
-
const rtcCenter = featureTable.getData('RTC_CENTER');
|
|
77
|
-
if (rtcCenter) {
|
|
78
|
-
this.tempMatrix.makeTranslation(rtcCenter[0], rtcCenter[1], rtcCenter[2])
|
|
79
|
-
model.scene.applyMatrix4(this.tempMatrix);
|
|
80
|
-
} else if (!!model.userData.gltfExtensions && !!model.userData.gltfExtensions.CESIUM_RTC) {
|
|
81
|
-
this.tempMatrix.makeTranslation(model.userData.gltfExtensions.CESIUM_RTC.center[0], model.userData.gltfExtensions.CESIUM_RTC.center[1], model.userData.gltfExtensions.CESIUM_RTC.center[2])
|
|
82
|
-
model.scene.applyMatrix4(this.tempMatrix);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (!zUpToYUp) {
|
|
86
|
-
model.scene.applyMatrix4(zUpToYUpMatrix);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
model.scene.traverse((o) => {
|
|
90
|
-
|
|
91
|
-
if (o.isMesh) {
|
|
92
|
-
o.geometricError = geometricError
|
|
93
|
-
if (zUpToYUp) {
|
|
94
|
-
o.applyMatrix4(zUpToYUpMatrix);
|
|
95
|
-
}
|
|
96
|
-
if (!!meshCallback) {
|
|
97
|
-
meshCallback(o);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
resolve(model.scene);
|
|
103
|
-
}, error => {
|
|
104
|
-
console.error(error);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
parseB3DMInstanced(arrayBuffer, meshCallback, maxCount, zUpToYUp) { // expects GLTF with one node level
|
|
110
|
-
|
|
111
|
-
return this.parseB3DM(arrayBuffer, meshCallback, zUpToYUp).then(mesh => {
|
|
112
|
-
// todo several meshes in a single gltf
|
|
113
|
-
let instancedMesh;
|
|
114
|
-
mesh.updateWorldMatrix(false, true)
|
|
115
|
-
mesh.traverse(child => {
|
|
116
|
-
if (child.isMesh) {
|
|
117
|
-
instancedMesh = new THREE.InstancedMesh(child.geometry, child.material, maxCount);
|
|
118
|
-
instancedMesh.baseMatrix = child.matrixWorld;
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
return instancedMesh;
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This class is taken straight from NASA-AMMOS library.
|
|
3
|
-
* https://github.com/NASA-AMMOS/3DTilesRendererJS/blob/master/src/utilities/FeatureTable.js
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const utf8decoder = new TextDecoder();
|
|
7
|
-
export class FeatureTable {
|
|
8
|
-
|
|
9
|
-
constructor(buffer, start, headerLength, binLength) {
|
|
10
|
-
|
|
11
|
-
this.buffer = buffer;
|
|
12
|
-
this.binOffset = start + headerLength;
|
|
13
|
-
this.binLength = binLength;
|
|
14
|
-
|
|
15
|
-
let header = null;
|
|
16
|
-
if (headerLength !== 0) {
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
const headerData = new Uint8Array(buffer, start, headerLength);
|
|
20
|
-
header = JSON.parse(utf8decoder.decode(headerData));
|
|
21
|
-
} catch (e) {
|
|
22
|
-
header = {};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
} else {
|
|
26
|
-
|
|
27
|
-
header = {};
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
this.header = header;
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
getKeys() {
|
|
35
|
-
|
|
36
|
-
return Object.keys(this.header);
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
getData(key, count, defaultComponentType = null, defaultType = null) {
|
|
41
|
-
|
|
42
|
-
const header = this.header;
|
|
43
|
-
|
|
44
|
-
if (!(key in header)) {
|
|
45
|
-
|
|
46
|
-
return null;
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const feature = header[key];
|
|
51
|
-
if (!(feature instanceof Object)) {
|
|
52
|
-
|
|
53
|
-
return feature;
|
|
54
|
-
|
|
55
|
-
} else if (Array.isArray(feature)) {
|
|
56
|
-
|
|
57
|
-
return feature;
|
|
58
|
-
|
|
59
|
-
} else {
|
|
60
|
-
|
|
61
|
-
const { buffer, binOffset, binLength } = this;
|
|
62
|
-
const byteOffset = feature.byteOffset || 0;
|
|
63
|
-
const featureType = feature.type || defaultType;
|
|
64
|
-
const featureComponentType = feature.componentType || defaultComponentType;
|
|
65
|
-
|
|
66
|
-
if ('type' in feature && defaultType && feature.type !== defaultType) {
|
|
67
|
-
|
|
68
|
-
throw new Error('FeatureTable: Specified type does not match expected type.');
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
let stride;
|
|
73
|
-
switch (featureType) {
|
|
74
|
-
|
|
75
|
-
case 'SCALAR':
|
|
76
|
-
stride = 1;
|
|
77
|
-
break;
|
|
78
|
-
|
|
79
|
-
case 'VEC2':
|
|
80
|
-
stride = 2;
|
|
81
|
-
break;
|
|
82
|
-
|
|
83
|
-
case 'VEC3':
|
|
84
|
-
stride = 3;
|
|
85
|
-
break;
|
|
86
|
-
|
|
87
|
-
case 'VEC4':
|
|
88
|
-
stride = 4;
|
|
89
|
-
break;
|
|
90
|
-
|
|
91
|
-
default:
|
|
92
|
-
throw new Error(`FeatureTable : Feature type not provided for "${key}".`);
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
let data;
|
|
97
|
-
const arrayStart = binOffset + byteOffset;
|
|
98
|
-
const arrayLength = count * stride;
|
|
99
|
-
|
|
100
|
-
switch (featureComponentType) {
|
|
101
|
-
|
|
102
|
-
case 'BYTE':
|
|
103
|
-
data = new Int8Array(buffer, arrayStart, arrayLength);
|
|
104
|
-
break;
|
|
105
|
-
|
|
106
|
-
case 'UNSIGNED_BYTE':
|
|
107
|
-
data = new Uint8Array(buffer, arrayStart, arrayLength);
|
|
108
|
-
break;
|
|
109
|
-
|
|
110
|
-
case 'SHORT':
|
|
111
|
-
data = new Int16Array(buffer, arrayStart, arrayLength);
|
|
112
|
-
break;
|
|
113
|
-
|
|
114
|
-
case 'UNSIGNED_SHORT':
|
|
115
|
-
data = new Uint16Array(buffer, arrayStart, arrayLength);
|
|
116
|
-
break;
|
|
117
|
-
|
|
118
|
-
case 'INT':
|
|
119
|
-
data = new Int32Array(buffer, arrayStart, arrayLength);
|
|
120
|
-
break;
|
|
121
|
-
|
|
122
|
-
case 'UNSIGNED_INT':
|
|
123
|
-
data = new Uint32Array(buffer, arrayStart, arrayLength);
|
|
124
|
-
break;
|
|
125
|
-
|
|
126
|
-
case 'FLOAT':
|
|
127
|
-
data = new Float32Array(buffer, arrayStart, arrayLength);
|
|
128
|
-
break;
|
|
129
|
-
|
|
130
|
-
case 'DOUBLE':
|
|
131
|
-
data = new Float64Array(buffer, arrayStart, arrayLength);
|
|
132
|
-
break;
|
|
133
|
-
|
|
134
|
-
default:
|
|
135
|
-
throw new Error(`FeatureTable : Feature component type not provided for "${key}".`);
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const dataEnd = arrayStart + arrayLength * data.BYTES_PER_ELEMENT;
|
|
140
|
-
if (dataEnd > binOffset + binLength) {
|
|
141
|
-
|
|
142
|
-
throw new Error('FeatureTable: Feature data read outside binary body length.');
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return data;
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export class BatchTable extends FeatureTable {
|
|
155
|
-
|
|
156
|
-
constructor(buffer, batchSize, start, headerLength, binLength) {
|
|
157
|
-
|
|
158
|
-
super(buffer, start, headerLength, binLength);
|
|
159
|
-
this.batchSize = batchSize;
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
getData(key, componentType = null, type = null) {
|
|
164
|
-
|
|
165
|
-
return super.getData(key, this.batchSize, componentType, type);
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
}
|