@cognite/reveal 2.2.2 → 2.3.0
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/core/cad.d.ts +4 -4
- package/core/index.d.ts +7 -7
- package/core/src/datamodels/base/SupportedModelTypes.d.ts +4 -4
- package/core/src/datamodels/base/index.d.ts +6 -6
- package/core/src/datamodels/base/types.d.ts +14 -14
- package/core/src/datamodels/cad/CadManager.d.ts +45 -45
- package/core/src/datamodels/cad/CadModelFactory.d.ts +7 -7
- package/core/src/datamodels/cad/CadModelSectorLoadStatistics.d.ts +38 -38
- package/core/src/datamodels/cad/createCadManager.d.ts +9 -9
- package/core/src/datamodels/cad/picking.d.ts +28 -28
- package/core/src/datamodels/cad/rendering/RenderAlreadyLoadedGeometryProvider.d.ts +10 -10
- package/core/src/datamodels/cad/sector/CadModelClipper.d.ts +10 -10
- package/core/src/datamodels/cad/styling/AssetNodeCollection.d.ts +38 -38
- package/core/src/datamodels/cad/styling/InvertedNodeCollection.d.ts +24 -24
- package/core/src/datamodels/cad/styling/NodeCollectionDeserializer.d.ts +26 -26
- package/core/src/datamodels/cad/styling/PopulateIndexSetFromPagedResponseHelper.d.ts +24 -24
- package/core/src/datamodels/cad/styling/PropertyFilterNodeCollection.d.ts +54 -54
- package/core/src/datamodels/cad/styling/SinglePropertyFilterNodeCollection.d.ts +50 -50
- package/core/src/datamodels/cad/styling/index.d.ts +8 -8
- package/core/src/datamodels/pointcloud/PointCloudFactory.d.ts +9 -9
- package/core/src/datamodels/pointcloud/PointCloudManager.d.ts +26 -26
- package/core/src/datamodels/pointcloud/PointCloudMetadata.d.ts +11 -11
- package/core/src/datamodels/pointcloud/PointCloudMetadataRepository.d.ts +13 -13
- package/core/src/datamodels/pointcloud/PointCloudNode.d.ts +62 -62
- package/core/src/datamodels/pointcloud/PotreeGroupWrapper.d.ts +39 -39
- package/core/src/datamodels/pointcloud/PotreeNodeWrapper.d.ts +38 -38
- package/core/src/datamodels/pointcloud/createPointCloudManager.d.ts +6 -6
- package/core/src/datamodels/pointcloud/index.d.ts +5 -5
- package/core/src/datamodels/pointcloud/picking.d.ts +29 -29
- package/core/src/datamodels/pointcloud/types.d.ts +114 -114
- package/core/src/index.d.ts +19 -19
- package/core/src/internals.d.ts +15 -15
- package/core/src/migration.d.ts +8 -8
- package/core/src/public/RevealManager.d.ts +64 -64
- package/core/src/public/createRevealManager.d.ts +23 -23
- package/core/src/public/migration/Cognite3DModel.d.ts +339 -339
- package/core/src/public/migration/Cognite3DViewer.d.ts +566 -611
- package/core/src/public/migration/CogniteModelBase.d.ts +17 -17
- package/core/src/public/migration/CognitePointCloudModel.d.ts +121 -121
- package/core/src/public/migration/NodeIdAndTreeIndexMaps.d.ts +4 -4
- package/core/src/public/migration/NotSupportedInMigrationWrapperError.d.ts +11 -11
- package/core/src/public/migration/RenderController.d.ts +4 -4
- package/core/src/public/migration/types.d.ts +290 -290
- package/core/src/public/types.d.ts +46 -46
- package/core/src/storage/RevealManagerHelper.d.ts +58 -58
- package/core/src/utilities/BoundingBoxClipper.d.ts +23 -23
- package/core/src/utilities/Spinner.d.ts +27 -27
- package/core/src/utilities/ViewStateHelper.d.ts +37 -33
- package/core/src/utilities/callActionWithIndicesAsync.d.ts +4 -4
- package/core/src/utilities/index.d.ts +8 -8
- package/core/src/utilities/reflection.d.ts +7 -7
- package/core/src/utilities/worldToViewport.d.ts +30 -30
- package/core/utilities.d.ts +4 -4
- package/extensions/datasource.d.ts +9 -9
- package/extensions/datasource.js +6 -6
- package/extensions/datasource.map +1 -1
- package/index.d.ts +9 -8
- package/index.js +101 -91
- package/index.map +1 -1
- package/package.json +2 -2
- package/packages/cad-geometry-loaders/index.d.ts +14 -14
- package/packages/cad-geometry-loaders/src/CadLoadingHints.d.ts +11 -11
- package/packages/cad-geometry-loaders/src/CadModelSectorBudget.d.ts +26 -26
- package/packages/cad-geometry-loaders/src/CadModelUpdateHandler.d.ts +44 -44
- package/packages/cad-geometry-loaders/src/sector/CachedRepository.d.ts +25 -25
- package/packages/cad-geometry-loaders/src/sector/ModelStateHandler.d.ts +12 -12
- package/packages/cad-geometry-loaders/src/sector/Repository.d.ts +9 -9
- package/packages/cad-geometry-loaders/src/sector/SectorLoader.d.ts +28 -28
- package/packages/cad-geometry-loaders/src/sector/SimpleAndDetailedToSector3D.d.ts +20 -20
- package/packages/cad-geometry-loaders/src/sector/culling/ByVisibilityGpuSectorCuller.d.ts +53 -53
- package/packages/cad-geometry-loaders/src/sector/culling/OccludingGeometryProvider.d.ts +6 -6
- package/packages/cad-geometry-loaders/src/sector/culling/OrderSectorsByVisibilityCoverage.d.ts +107 -107
- package/packages/cad-geometry-loaders/src/sector/culling/SectorCuller.d.ts +33 -33
- package/packages/cad-geometry-loaders/src/sector/culling/TakenSectorTree.d.ts +24 -24
- package/packages/cad-geometry-loaders/src/sector/culling/types.d.ts +71 -71
- package/packages/cad-geometry-loaders/src/sector/rxSectorUtilities.d.ts +12 -12
- package/packages/cad-geometry-loaders/src/sector/sectorUtilities.d.ts +20 -20
- package/packages/cad-geometry-loaders/src/utilities/PromiseUtils.d.ts +18 -18
- package/packages/cad-geometry-loaders/src/utilities/arrays.d.ts +5 -5
- package/packages/cad-geometry-loaders/src/utilities/groupMeshesByNumber.d.ts +8 -8
- package/packages/cad-geometry-loaders/src/utilities/rxOperations.d.ts +6 -6
- package/packages/cad-geometry-loaders/src/utilities/types.d.ts +25 -25
- package/packages/cad-parsers/index.d.ts +21 -21
- package/packages/cad-parsers/src/cad/CadSectorParser.d.ts +15 -15
- package/packages/cad-parsers/src/cad/LevelOfDetail.d.ts +8 -8
- package/packages/cad-parsers/src/cad/filterInstanceMesh.d.ts +6 -6
- package/packages/cad-parsers/src/cad/filterPrimitives.d.ts +9 -9
- package/packages/cad-parsers/src/cad/primitiveGeometries.d.ts +31 -31
- package/packages/cad-parsers/src/cad/triangleMeshes.d.ts +6 -6
- package/packages/cad-parsers/src/cad/types.d.ts +56 -56
- package/packages/cad-parsers/src/metadata/CadMetadataParser.d.ts +7 -7
- package/packages/cad-parsers/src/metadata/CadModelMetadata.d.ts +44 -44
- package/packages/cad-parsers/src/metadata/CadModelMetadataRepository.d.ts +16 -16
- package/packages/cad-parsers/src/metadata/MetadataRepository.d.ts +7 -7
- package/packages/cad-parsers/src/metadata/parsers/CadMetadataParserV8.d.ts +51 -51
- package/packages/cad-parsers/src/metadata/types.d.ts +41 -41
- package/packages/cad-parsers/src/sector/RootSectorNode.d.ts +12 -12
- package/packages/cad-parsers/src/sector/SectorNode.d.ts +21 -21
- package/packages/cad-parsers/src/utilities/SectorScene.d.ts +21 -21
- package/packages/cad-parsers/src/utilities/SectorSceneFactory.d.ts +9 -9
- package/packages/cad-parsers/src/utilities/computeBoundingBoxFromAttributes.d.ts +9 -9
- package/packages/cad-parsers/src/utilities/float32BufferToMatrix.d.ts +12 -12
- package/packages/cad-parsers/src/utilities/types.d.ts +48 -48
- package/packages/cad-styling/index.d.ts +9 -9
- package/packages/cad-styling/src/CombineNodeCollectionBase.d.ts +31 -31
- package/packages/cad-styling/src/IntersectionNodeCollection.d.ts +15 -15
- package/packages/cad-styling/src/NodeAppearance.d.ts +62 -62
- package/packages/cad-styling/src/NodeAppearanceProvider.d.ts +33 -33
- package/packages/cad-styling/src/NodeCollectionBase.d.ts +47 -47
- package/packages/cad-styling/src/TreeIndexNodeCollection.d.ts +23 -23
- package/packages/cad-styling/src/UnionNodeCollection.d.ts +15 -15
- package/packages/camera-manager/index.d.ts +6 -4
- package/packages/camera-manager/src/CameraManager.d.ts +85 -0
- package/packages/camera-manager/src/ComboControls.d.ts +102 -100
- package/packages/camera-manager/src/Keyboard.d.ts +17 -17
- package/packages/camera-manager/src/types.d.ts +64 -0
- package/packages/data-source/index.d.ts +6 -6
- package/packages/data-source/src/CdfDataSource.d.ts +19 -19
- package/packages/data-source/src/DataSource.d.ts +26 -26
- package/packages/data-source/src/LocalDataSource.d.ts +15 -15
- package/packages/logger/index.d.ts +5 -5
- package/packages/logger/src/Log.d.ts +5 -5
- package/packages/metrics/index.d.ts +5 -5
- package/packages/metrics/src/MetricsLogger.d.ts +21 -21
- package/packages/metrics/src/types.d.ts +7 -7
- package/packages/modeldata-api/index.d.ts +13 -13
- package/packages/modeldata-api/src/CdfModelDataProvider.d.ts +17 -15
- package/packages/modeldata-api/src/CdfModelIdentifier.d.ts +17 -17
- package/packages/modeldata-api/src/CdfModelMetadataProvider.d.ts +19 -19
- package/packages/modeldata-api/src/CdfModelOutputsProvider.d.ts +15 -15
- package/packages/modeldata-api/src/LocalModelDataProvider.d.ts +10 -10
- package/packages/modeldata-api/src/LocalModelIdentifier.d.ts +14 -14
- package/packages/modeldata-api/src/LocalModelMetadataProvider.d.ts +14 -14
- package/packages/modeldata-api/src/Model3DOutputList.d.ts +17 -17
- package/packages/modeldata-api/src/ModelIdentifier.d.ts +12 -12
- package/packages/modeldata-api/src/ModelMetadataProvider.d.ts +17 -17
- package/packages/modeldata-api/src/applyDefaultModelTransformation.d.ts +6 -6
- package/packages/modeldata-api/src/types.d.ts +41 -41
- package/packages/modeldata-api/src/utilities.d.ts +7 -7
- package/packages/nodes-api/index.d.ts +6 -6
- package/packages/nodes-api/src/NodesApiClient.d.ts +52 -52
- package/packages/nodes-api/src/NodesCdfClient.d.ts +24 -24
- package/packages/nodes-api/src/NodesLocalClient.d.ts +30 -30
- package/packages/nodes-api/src/types.d.ts +10 -10
- package/packages/rendering/index.d.ts +17 -17
- package/packages/rendering/src/CadMaterialManager.d.ts +37 -37
- package/packages/rendering/src/InstancedMeshManager.d.ts +20 -20
- package/packages/rendering/src/cameraconfig.d.ts +12 -12
- package/packages/rendering/src/rendering/EffectRenderManager.d.ts +99 -99
- package/packages/rendering/src/rendering/NodeAppearanceTextureBuilder.d.ts +51 -51
- package/packages/rendering/src/rendering/RenderMode.d.ts +15 -15
- package/packages/rendering/src/rendering/createSimpleGeometryMesh.d.ts +6 -6
- package/packages/rendering/src/rendering/matCapTextureData.d.ts +5 -5
- package/packages/rendering/src/rendering/materials.d.ts +23 -23
- package/packages/rendering/src/rendering/primitives.d.ts +12 -12
- package/packages/rendering/src/rendering/shaders.d.ts +101 -101
- package/packages/rendering/src/rendering/types.d.ts +76 -76
- package/packages/rendering/src/sector/CadNode.d.ts +54 -54
- package/packages/rendering/src/transform/NodeTransformProvider.d.ts +13 -13
- package/packages/rendering/src/transform/NodeTransformTextureBuilder.d.ts +23 -23
- package/packages/rendering/src/transform/TransformOverrideBuffer.d.ts +21 -21
- package/packages/rendering/src/utilities/types.d.ts +26 -26
- package/packages/tools/index.d.ts +15 -15
- package/packages/tools/src/AxisView/AxisViewTool.d.ts +32 -32
- package/packages/tools/src/AxisView/types.d.ts +98 -98
- package/packages/tools/src/Cognite3DViewerToolBase.d.ts +25 -25
- package/packages/tools/src/DebugCameraTool.d.ts +20 -20
- package/packages/tools/src/DebugLoadedSectorsTool.d.ts +23 -23
- package/packages/tools/src/ExplodedViewTool.d.ts +12 -12
- package/packages/tools/src/Geomap/Geomap.d.ts +17 -17
- package/packages/tools/src/Geomap/GeomapTool.d.ts +24 -24
- package/packages/tools/src/Geomap/MapConfig.d.ts +195 -195
- package/packages/tools/src/HtmlOverlay/BucketGrid2D.d.ts +28 -28
- package/packages/tools/src/HtmlOverlay/HtmlOverlayTool.d.ts +159 -159
- package/packages/tools/src/Timeline/Keyframe.d.ts +38 -38
- package/packages/tools/src/Timeline/TimelineTool.d.ts +79 -79
- package/packages/tools/src/Timeline/types.d.ts +13 -13
- package/packages/tools/src/types.d.ts +4 -4
- package/packages/utilities/index.d.ts +24 -24
- package/packages/utilities/src/CameraConfiguration.d.ts +10 -10
- package/packages/utilities/src/IndexSet.d.ts +1 -1
- package/packages/utilities/src/NumericRange.d.ts +22 -22
- package/packages/utilities/src/RandomColors.d.ts +34 -34
- package/packages/utilities/src/WebGLRendererStateHelper.d.ts +15 -15
- package/packages/utilities/src/assertNever.d.ts +7 -7
- package/packages/utilities/src/cache/MemoryRequestCache.d.ts +22 -22
- package/packages/utilities/src/cache/MostFrequentlyUsedCache.d.ts +19 -19
- package/packages/utilities/src/cache/RequestCache.d.ts +13 -13
- package/packages/utilities/src/datastructures/DynamicDefragmentedBuffer.d.ts +22 -22
- package/packages/utilities/src/determinePowerOfTwoDimensions.d.ts +11 -11
- package/packages/utilities/src/disposeAttributeArrayOnUpload.d.ts +17 -17
- package/packages/utilities/src/events/EventTrigger.d.ts +13 -13
- package/packages/utilities/src/events/InputHandler.d.ts +34 -0
- package/packages/utilities/src/events/clickOrTouchEventOffset.d.ts +13 -13
- package/packages/utilities/src/events/index.d.ts +6 -5
- package/packages/utilities/src/indexset/IndexSet.d.ts +26 -26
- package/packages/utilities/src/indexset/IntermediateIndexNode.d.ts +26 -26
- package/packages/utilities/src/indexset/LeafIndexNode.d.ts +16 -16
- package/packages/utilities/src/isMobileOrTablet.d.ts +4 -4
- package/packages/utilities/src/networking/isTheSameDomain.d.ts +11 -11
- package/packages/utilities/src/objectTraversal.d.ts +8 -8
- package/packages/utilities/src/packFloat.d.ts +6 -6
- package/packages/utilities/src/revealEnv.d.ts +10 -10
- package/packages/utilities/src/three/AutoDisposeGroup.d.ts +17 -17
- package/packages/utilities/src/three/BoundingBoxLOD.d.ts +27 -27
- package/packages/utilities/src/three/getBox3CornerPoints.d.ts +5 -5
- package/packages/utilities/src/transformCameraConfiguration.d.ts +6 -6
- package/packages/utilities/src/types.d.ts +10 -10
- package/packages/utilities/src/workers/WorkerPool.d.ts +14 -14
- package/tools.d.ts +7 -7
- package/tools.js +62 -58
- package/tools.map +1 -1
package/tools.js
CHANGED
|
@@ -1,95 +1,99 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"!=typeof self?self:this,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="https://apps-cdn.cogniteapp.com/@cognite/reveal-parser-worker/1.3.0/",r(r.s=65)}([function(e,t){e.exports=require("three")},function(e,t,r){"use strict";
|
|
2
2
|
/*!
|
|
3
3
|
* Copyright 2021 Cognite AS
|
|
4
4
|
*/
|
|
5
|
-
function n(e,t){if(t(e))for(let r=0;r<e.children.length;r++)n(e.children[r],t)}function
|
|
5
|
+
function n(e,t){if(t(e))for(let r=0;r<e.children.length;r++)n(e.children[r],t)}function i(e,t){if(void 0===e)return;const{position:r,target:n}=e;return r.applyMatrix4(t),n.applyMatrix4(t),{position:r,target:n}}r.d(t,"u",(function(){return n})),r.d(t,"t",(function(){return i})),r.d(t,"d",(function(){return c})),r.d(t,"f",(function(){return h})),r.d(t,"o",(function(){return u})),r.d(t,"l",(function(){return m})),r.d(t,"i",(function(){return p})),r.d(t,"m",(function(){return f})),r.d(t,"e",(function(){return y})),r.d(t,"r",(function(){return C})),r.d(t,"c",(function(){return P})),r.d(t,"a",(function(){return N})),r.d(t,"b",(function(){return A})),r.d(t,"p",(function(){return F})),r.d(t,"q",(function(){return R})),r.d(t,"j",(function(){return O})),r.d(t,"k",(function(){return $})),r.d(t,"g",(function(){return G})),r.d(t,"h",(function(){return U})),r.d(t,"n",(function(){return W})),r.d(t,"s",(function(){return z}));var o=r(0);
|
|
6
6
|
/*!
|
|
7
7
|
* Copyright 2021 Cognite AS
|
|
8
|
-
*/class s{static color(e){const t=s._colors.get(e);if(void 0!==t)return t;const r=s.generateRandomColor();return s._colors.set(e,r),r}static colorRGB(e){const t=s.color(e);return[Math.floor(255*t.r),Math.floor(255*t.g),Math.floor(255*t.b)]}static colorCSS(e){const[t,r,n]=s.colorRGB(e);return`rgb(${t}, ${r}, ${n})`}static generateRandomColor(){const e=Math.random(),t=.4+.6*Math.random(),r=.3+.4*Math.random();return(new
|
|
8
|
+
*/class s{static color(e){const t=s._colors.get(e);if(void 0!==t)return t;const r=s.generateRandomColor();return s._colors.set(e,r),r}static colorRGB(e){const t=s.color(e);return[Math.floor(255*t.r),Math.floor(255*t.g),Math.floor(255*t.b)]}static colorCSS(e){const[t,r,n]=s.colorRGB(e);return`rgb(${t}, ${r}, ${n})`}static generateRandomColor(){const e=Math.random(),t=.4+.6*Math.random(),r=.3+.4*Math.random();return(new o.Color).setHSL(e,t,r)}}
|
|
9
9
|
/*!
|
|
10
10
|
* Copyright 2021 Cognite AS
|
|
11
11
|
*/
|
|
12
12
|
function a(e,t){const r=t.getBoundingClientRect();if(e instanceof MouseEvent)return{offsetX:e.clientX-r.left,offsetY:e.clientY-r.top};if(e.changedTouches.length>0){const t=e.changedTouches[0];return{offsetX:t.clientX-r.left,offsetY:t.clientY-r.top}}return{offsetX:-1,offsetY:-1}}
|
|
13
13
|
/*!
|
|
14
14
|
* Copyright 2021 Cognite AS
|
|
15
|
-
*/s._colors=new Map;class c{constructor(){this._listeners=[]}subscribe(e){this._listeners.push(e)}unsubscribe(e){const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}unsubscribeAll(){this._listeners.splice(0)}fire(...e){this._listeners.forEach(t=>t(...e))}}
|
|
15
|
+
*/s._colors=new Map;class c{constructor(){this._listeners=[]}subscribe(e){this._listeners.push(e)}unsubscribe(e){const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}unsubscribeAll(){this._listeners.splice(0)}fire(...e){this._listeners.forEach(t=>t(...e))}}var l=r(14),d=r.n(l);
|
|
16
16
|
/*!
|
|
17
17
|
* Copyright 2021 Cognite AS
|
|
18
18
|
*/
|
|
19
|
+
class h{constructor(e){this._events={click:new c,hover:new c},this.onHoverCallback=d()(e=>{this._events.hover.fire(a(e,this.domElement))},100),this.domElement=e,this.setupEventListeners()}on(e,t){switch(e){case"click":this._events.click.subscribe(t);break;case"hover":this._events.hover.subscribe(t);break;default:m(e)}}off(e,t){switch(e){case"click":this._events.click.unsubscribe(t);break;case"hover":this._events.hover.unsubscribe(t);break;default:m(e)}}dispose(){u(this._events)}setupEventListeners(){const{domElement:e}=this;let t=!1,r=0,n=!1;const i=new o.Vector2,s=o=>{this.handleClickEvent(o,i,t,n,r),t=!1,n=!1,e.removeEventListener("mouseup",s),e.removeEventListener("touchend",s),e.addEventListener("mousemove",this.onHoverCallback)},c=o=>{t=!0,n=!0,r=o.timeStamp;const{offsetX:c,offsetY:l}=a(o,e);i.set(c,l),e.addEventListener("mouseup",s),e.addEventListener("touchend",s),e.removeEventListener("mousemove",this.onHoverCallback)};e.addEventListener("mousedown",c),e.addEventListener("touchstart",c),e.addEventListener("mousemove",this.onHoverCallback)}isProperClick(e,t,r,n,i){const{offsetX:o,offsetY:s}=a(e,this.domElement),c=e.timeStamp-i,l=Math.abs(o-t.x)+Math.abs(s-t.y)>h.maxMoveDistance;return r&&n&&c<h.maxClickDuration&&!l}handleClickEvent(e,t,r,n,i){this.isProperClick(e,t,r,n,i)&&this._events.click.fire(a(e,this.domElement))}}function u(e){for(const t of Object.keys(e))e[t].unsubscribeAll()}
|
|
19
20
|
/*!
|
|
20
21
|
* Copyright 2021 Cognite AS
|
|
21
|
-
*/
|
|
22
|
+
*/
|
|
23
|
+
/*!
|
|
24
|
+
* Copyright 2021 Cognite AS
|
|
25
|
+
*/function m(e,t){throw new Error(t||"Unexpected object: "+e)}
|
|
22
26
|
/*!
|
|
23
27
|
* Copyright 2021 Cognite AS
|
|
24
|
-
*/class
|
|
28
|
+
*/h.maxMoveDistance=8,h.maxClickDuration=250;class p{constructor(e,t){if(t<0)throw new Error("Range cannot have negative number of elements");this.from=e,this.count=t,this.toInclusive=e+t-1}static createFromInterval(e,t){return new p(e,t-e+1)}*values(){for(let e=this.from;e<=this.toInclusive;++e)yield e}toArray(){return Array.from(this.values())}equal(e){return this.from===e.from&&this.count===e.count}contains(e){return e>=this.from&&e<=this.toInclusive}intersects(e){return this.from<=e.toInclusive&&this.toInclusive>=e.from}intersectsOrCoinciding(e){return this.from<=e.toInclusive+1&&this.toInclusive+1>=e.from}intersectionWith(e){return this.intersects(e)?p.createFromInterval(Math.max(this.from,e.from),Math.min(this.toInclusive,e.toInclusive)):void 0}isInside(e){return this.from>=e.from&&this.toInclusive<=e.toInclusive}union(e){return p.createFromInterval(Math.min(this.from,e.from),Math.max(this.toInclusive,e.toInclusive))}forEach(e){for(let t=this.from;t<=this.toInclusive;++t)e(t)}toString(){return"("+this.from+", "+this.toInclusive+")"}static isNumericRange(e){if(!e)return!1;const t=e;return void 0!==t.from&&void 0!==t.count&&void 0!==t.toInclusive}}
|
|
25
29
|
/*!
|
|
26
30
|
* Copyright 2021 Cognite AS
|
|
27
|
-
*/function
|
|
31
|
+
*/function f(e){const t=Math.max(1,v(Math.sqrt(e)));return{width:t,height:Math.max(1,v(e/t))}}const g=Math.log(2);function v(e){return Math.pow(2,Math.ceil(Math.log(e)/g))}var w=r(7),x=r.n(w);class _{constructor(e,t){this.left=e,this.right=t,this.maxSubtreeDepth=Math.max(this.left.maxSubtreeDepth,this.right.maxSubtreeDepth)+1,this.range=p.createFromInterval(this.left.range.from,this.right.range.toInclusive),this.count=this.left.count+this.right.count}static fromIndexNodesAndBalance(e,t){return e.range.from>t.range.toInclusive+1?new _(t,e).balance():e.range.toInclusive+1<t.range.from?new _(e,t).balance():void x()(!1,"Internal error in IndexSet: Overlapping nodes")}traverse(e){this.left.traverse(e),this.right.traverse(e)}contains(e){return!!this.range.contains(e)&&(this.left.contains(e)||this.right.contains(e))}addRange(e){if(!e.intersectsOrCoinciding(this.range)){if(e.from<this.range.from){const t=this.left.addRange(e);return _.fromIndexNodesAndBalance(t,this.right)}{const t=this.right.addRange(e);return _.fromIndexNodesAndBalance(this.left,t)}}const t=e.intersectsOrCoinciding(this.left.range),r=e.intersectsOrCoinciding(this.right.range);if(t&&r){const[t,r]=this.left.soak(e),[n,i]=this.right.soak(e),o=r.union(i);if(void 0===t&&void 0===n)return new b(o);if(void 0===t&&void 0!==n)return n.addRange(o);if(void 0===n&&void 0!==t)return t.addRange(o);return _.fromIndexNodesAndBalance(t,n).addRange(o)}return t?_.fromIndexNodesAndBalance(this.left.addRange(e),this.right):r?_.fromIndexNodesAndBalance(this.left,this.right.addRange(e)):this.left.maxSubtreeDepth<this.right.maxSubtreeDepth?_.fromIndexNodesAndBalance(this.left.addRange(e),this.right):_.fromIndexNodesAndBalance(this.left,this.right.addRange(e))}removeRange(e){if(!e.intersects(this.range))return this;const[t,r]=this.soak(e);let n=void 0,i=void 0;if(r.from<e.from&&(n=p.createFromInterval(r.from,e.from-1)),r.toInclusive>e.toInclusive&&(i=p.createFromInterval(e.toInclusive+1,r.toInclusive)),void 0===t)return void 0!==n&&void 0!==i?_.fromIndexNodesAndBalance(new b(n),new b(i)):null!=n?new b(n):null!=i?new b(i):void 0;{let e=t;return void 0!==n&&(e=e.addRange(n)),void 0!==i&&(e=e.addRange(i)),e}}balance(){const e=this.left.maxSubtreeDepth,t=this.right.maxSubtreeDepth;if(t+2<=e){const e=this.left.rotateSmallerRight();return new _(e,this.right).rotateRight().balance()}if(e+2<=t){const e=this.right.rotateSmallerLeft();return new _(this.left,e).rotateLeft().balance()}return this}clone(){return _.fromIndexNodesAndBalance(this.left.clone(),this.right.clone())}hasIntersectionWith(e){return!!e.range.intersects(this.range)&&(this.range.isInside(e.range)?e.hasIntersectionWith(this):!(!this.left.range.intersects(e.range)||!this.left.hasIntersectionWith(e))||!(!this.right.range.intersects(e.range)||!this.right.hasIntersectionWith(e)))}soak(e){let[t,r]=[this.left,e],[n,i]=[this.right,e];if(this.right.range.isInside(e)&&this.left.range.isInside(e))return[void 0,e];this.left.range.intersectsOrCoinciding(e)&&([t,r]=this.left.soak(e)),this.right.range.intersectsOrCoinciding(e)&&([n,i]=this.right.soak(e));const o=r.union(i);if(null==n)return[t,o];if(null==t)return[n,o];return[_.fromIndexNodesAndBalance(t,n),o]}rotateRight(){return"right"in this.left?new _(this.left.left,new _(this.left.right,this.right)):this}rotateLeft(){return"left"in this.right?new _(new _(this.left,this.right.left),this.right.right):this}rotateSmallerLeft(){if(this.left.maxSubtreeDepth>this.right.maxSubtreeDepth){let e=this.rotateRight();return e=e.rotateSmallerLeft(),e}return this}rotateSmallerRight(){if(this.right.maxSubtreeDepth>this.left.maxSubtreeDepth){let e=this.rotateLeft();return e=e.rotateSmallerRight(),e}return this}}
|
|
28
32
|
/*!
|
|
29
33
|
* Copyright 2021 Cognite AS../NumericRange
|
|
30
|
-
*/class
|
|
34
|
+
*/class b{constructor(e){this.range=e,this.maxSubtreeDepth=0,this.count=e.count}static fromInterval(e,t){return new b(p.createFromInterval(e,t))}traverse(e){e(this.range)}contains(e){return this.range.contains(e)}addRange(e){return this.range.intersectsOrCoinciding(e)?new b(this.range.union(e)):_.fromIndexNodesAndBalance(this,new b(e))}removeRange(e){if(!e.intersects(this.range))return this;if(this.range.isInside(e))return;let t=void 0,r=void 0;return this.range.from<e.from&&(t=p.createFromInterval(this.range.from,e.from-1)),this.range.toInclusive>e.toInclusive&&(r=p.createFromInterval(e.toInclusive+1,this.range.toInclusive)),null!=t&&null!=r?_.fromIndexNodesAndBalance(new b(t),new b(r)):null!=t?new b(t):null!=r?new b(r):void 0}hasIntersectionWith(e){return e.range.intersects(this.range)}soak(e){return this.range.intersectsOrCoinciding(e)?[void 0,this.range.union(e)]:[this,e]}clone(){return new b(this.range)}}class y{constructor(e){if(null==e)this.rootNode=void 0;else if(p.isNumericRange(e))this.addRange(e);else for(const t of e)this.add(t)}forEachRange(e){this.rootNode&&this.rootNode.traverse(e)}add(e){const t=new p(e,1);this.addRange(t)}addRange(e){this.rootNode?this.rootNode=this.rootNode.addRange(e):this.rootNode=new b(e)}remove(e){const t=new p(e,1);this.removeRange(t)}removeRange(e){this.rootNode&&(this.rootNode=this.rootNode.removeRange(e))}contains(e){return!!this.rootNode&&this.rootNode.contains(e)}get count(){return this.rootNode?this.rootNode.count:0}toRangeArray(){const e=[];return this.forEachRange(t=>{e.push(t)}),e}toIndexArray(){const e=[];return this.rootNode&&this.forEachRange(t=>{t.forEach(t=>{e.push(t)})}),e}toPlainSet(){const e=this.toIndexArray();return new Set(e)}invertedRanges(){const e=this.toRangeArray(),t=[];for(let r=0;r<e.length-1;r++)e[r].toInclusive+1>=e[r+1].from||t.push(p.createFromInterval(e[r].toInclusive+1,e[r+1].from-1));return t}unionWith(e){return this.rootNode?e.forEachRange(e=>{this.rootNode=this.rootNode.addRange(e)}):this.rootNode=e.rootNode,this}differenceWith(e){return this.rootNode&&e.forEachRange(e=>{var t;this.rootNode=null===(t=this.rootNode)||void 0===t?void 0:t.removeRange(e)}),this}hasIntersectionWith(e){if(e instanceof y)return void 0!==this.rootNode&&void 0!==e.rootNode&&this.rootNode.hasIntersectionWith(e.rootNode);for(const t of e)if(this.contains(t))return!0;return!1}intersectWith(e){if(this.rootNode&&e.rootNode){if(this.rootNode.range.from<e.rootNode.range.from){const t=p.createFromInterval(this.rootNode.range.from,e.rootNode.range.from-1);if(this.rootNode=this.rootNode.removeRange(t),!this.rootNode)return this}if(this.rootNode.range.toInclusive>e.rootNode.range.toInclusive){const t=p.createFromInterval(e.rootNode.range.toInclusive+1,this.rootNode.range.toInclusive);this.rootNode=this.rootNode.removeRange(t)}e.invertedRanges().forEach(e=>{this.rootNode&&(this.rootNode=this.rootNode.removeRange(e))})}else this.rootNode&&(this.rootNode=void 0);return this}clear(){this.rootNode=void 0}clone(){const e=new y;return this.rootNode&&(e.rootNode=this.rootNode.clone()),e}}
|
|
31
35
|
/*!
|
|
32
36
|
* Copyright 2021 Cognite AS
|
|
33
|
-
*/function
|
|
37
|
+
*/function C(e,t,r){const n=I(e);if(0==n)return;const i=M(0,-e);let o=k(E(n));const s=n/B(o);s<1&&(o-=1),o+=127,t[r]=128*i+k(o*B(-1)),t[r+1]=128*S(o,2)+S(k(128*s),128),t[r+2]=k(S(k(s*B(15)),B(8))),t[r+3]=k(B(23)*S(s,B(-15)))}function M(e,t){return t<e?0:1}function B(e){return Math.pow(2,e)}function S(e,t){return e-t*k(e/t)}function k(e){return Math.floor(e)}function E(e){return Math.log(e)/Math.log(2)}function I(e){return Math.abs(e)}
|
|
34
38
|
/*!
|
|
35
39
|
* Copyright 2021 Cognite AS
|
|
36
|
-
*/class
|
|
40
|
+
*/class P{constructor(e,t){this._numFilled=0,this._batchIdCounter=0,this._batchMap=new Map,this._type=t;const r=Math.pow(2,Math.ceil(Math.log2(e)));this._buffer=new t(r)}get length(){return this._numFilled}get buffer(){return this._buffer}add(e){let t=!1;if(this._numFilled+e.length>this._buffer.length){const r=Math.pow(2,Math.ceil(Math.log2(this._numFilled+e.length)));this.allocateNewBuffer(r),t=!0}this._buffer.set(e,this._numFilled);const r=this.createBatch(e);return this._numFilled+=e.length,{batchId:r,bufferIsReallocated:t}}remove(e){const t=this._batchMap.get(e);if(!t)throw new Error("batch does not exist in buffer");this._buffer.copyWithin(t.from,t.from+t.count,this.buffer.length),this._numFilled-=t.count,this._currentTail===t&&(this._currentTail=t.prev);const r=t.prev,n=t.next;r&&(r.next=n),n&&(n.prev=r);let i=n;for(;i;)i.from-=t.count,i=i.next;this._batchMap.delete(e)}createBatch(e){const t={from:this._numFilled,count:e.length,prev:this._currentTail,next:void 0};this._currentTail&&(this._currentTail.next=t),this._currentTail=t;const r=this._batchIdCounter;return this._batchIdCounter++,this._batchMap.set(r,t),r}allocateNewBuffer(e){const t=new this._type(e);t.set(this._buffer),this._buffer=t}}
|
|
37
41
|
/*!
|
|
38
42
|
* Copyright 2021 Cognite AS
|
|
39
|
-
*/const
|
|
43
|
+
*/const D=new o.BufferGeometry;class N extends o.Group{constructor(){super(...arguments),this._isDisposed=!1,this._referenceCount=0}reference(){this.ensureNotDisposed(),this._referenceCount++}dereference(){if(this.ensureNotDisposed(),0===this._referenceCount)throw new Error("No references");0==--this._referenceCount&&this.dispose()}dispose(){this.ensureNotDisposed(),this._isDisposed=!0;const e=this.children.filter(e=>e instanceof o.Mesh).map(e=>e);for(const t of e)void 0!==t.geometry&&(t.geometry.dispose(),t.geometry=D)}ensureNotDisposed(){if(this._isDisposed)throw new Error("Already disposed/dereferenced")}}
|
|
40
44
|
/*!
|
|
41
45
|
* Copyright 2021 Cognite AS
|
|
42
|
-
*/const
|
|
46
|
+
*/const T={camPos:new o.Vector3,bounds:new o.Box3};class A extends o.Object3D{constructor(e){super(),this._activeLevel=0,this._levels=[],this.isLOD=!0,this.autoUpdate=!0,this._boundingBox=e.clone(),this.type="BoundingBoxLOD"}setBoundingBox(e){this._boundingBox.copy(e)}addLevel(e,t=0){this._levels.push({object:e,distance:Math.abs(t)}),this._levels.sort((e,t)=>t.distance-e.distance),e.visible=!1,this.add(e)}getCurrentLevel(){return this._levels.length>0?this._levels.length-this._activeLevel-1:0}update(e){this.updateCurrentLevel(e)}updateCurrentLevel(e){const t=this._levels,{camPos:r,bounds:n}=T;n.copy(this._boundingBox).applyMatrix4(this.matrixWorld);const i=e instanceof o.PerspectiveCamera?e.zoom:1;if(t.length>0){r.setFromMatrixPosition(e.matrixWorld);const o=n.distanceToPoint(r)/i;t[this._activeLevel].object.visible=!1,this._activeLevel=t.findIndex(e=>o>=e.distance),this._activeLevel=this._activeLevel>=0?this._activeLevel:t.length-1,t[this._activeLevel].object.visible=!0}}}
|
|
43
47
|
/*!
|
|
44
48
|
* Copyright 2021 Cognite AS
|
|
45
|
-
*/function
|
|
49
|
+
*/function F(e){return[new o.Vector3(e.min.x,e.min.y,e.min.z),new o.Vector3(e.min.x,e.min.y,e.max.z),new o.Vector3(e.min.x,e.max.y,e.min.z),new o.Vector3(e.min.x,e.max.y,e.max.z),new o.Vector3(e.max.x,e.min.y,e.min.z),new o.Vector3(e.max.x,e.min.y,e.max.z),new o.Vector3(e.max.x,e.max.y,e.min.z),new o.Vector3(e.max.x,e.max.y,e.max.z)]}
|
|
46
50
|
/*!
|
|
47
51
|
* Copyright 2021 Cognite AS
|
|
48
|
-
*/function
|
|
52
|
+
*/function R(){let e=!1;var t;return t=navigator.userAgent||navigator.vendor||window.opera,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0),e}
|
|
49
53
|
/*!
|
|
50
54
|
* Copyright 2021 Cognite AS
|
|
51
|
-
*/class
|
|
55
|
+
*/class O{constructor(e){this._originalState={},this._renderer=e,this._originalState={}}setClearColor(e,t){this._originalState={clearColor:this._renderer.getClearColor(new o.Color),clearAlpha:this._renderer.getClearAlpha(),...this._originalState},this._renderer.setClearColor(e,t)}setSize(e,t){this._originalState={size:this._renderer.getSize(new o.Vector2),...this._originalState},this._renderer.setSize(e,t)}set localClippingEnabled(e){this._originalState={localClippingEnabled:this._renderer.localClippingEnabled,...this._originalState},this._renderer.localClippingEnabled=e}set autoClear(e){this._originalState={autoClear:this._renderer.autoClear,...this._originalState},this._renderer.autoClear=e}setRenderTarget(e){this._originalState={renderTarget:this._renderer.getRenderTarget(),...this._originalState},this._renderer.setRenderTarget(e)}resetState(){void 0!==this._originalState.autoClear&&(this._renderer.autoClear=this._originalState.autoClear),void 0!==this._originalState.clearColor&&this._renderer.setClearColor(this._originalState.clearColor,this._originalState.clearAlpha),void 0!==this._originalState.localClippingEnabled&&(this._renderer.localClippingEnabled=this._originalState.localClippingEnabled),void 0!==this._originalState.size&&this._renderer.setSize(this._originalState.size.width,this._originalState.size.height),void 0!==this._originalState.renderTarget&&this._renderer.setRenderTarget(this._originalState.renderTarget),this._originalState={}}}var V=r(22);
|
|
52
56
|
/*!
|
|
53
57
|
* Copyright 2021 Cognite AS
|
|
54
|
-
*/const
|
|
58
|
+
*/const z={publicPath:""};
|
|
55
59
|
/*!
|
|
56
60
|
* Copyright 2021 Cognite AS
|
|
57
|
-
*/var
|
|
61
|
+
*/var L=r(10);
|
|
58
62
|
/*!
|
|
59
63
|
* Copyright 2021 Cognite AS
|
|
60
|
-
*/class
|
|
64
|
+
*/class ${constructor(){this.workerList=[];const e=this.determineNumberOfWorkers();for(let t=0;t<e;t++){const e={worker:Object(V.wrap)(this.createWorker()),activeJobCount:0,messageIdCounter:0};this.workerList.push(e)}(async function(e){let t;try{t=await e.getVersion()}catch(e){t="1.1.0"}const r="1.3.0",[n,i,o]=r.split(".").map(e=>parseInt(e,10)),[s,a,c]=t.split(".").map(e=>parseInt(e,10)),l=`Update your local copy of @cognite/reveal-parser-worker. Required version is ${r}. Received ${t}.`;if(n!==s)throw new Error(l);if(a<i)throw new Error(l);if(a===i&&c<o)throw new Error(l)}
|
|
61
65
|
/*!
|
|
62
66
|
* Copyright 2021 Cognite AS
|
|
63
|
-
*/)(this.workerList[0].worker).catch(e=>
|
|
67
|
+
*/)(this.workerList[0].worker).catch(e=>L.a.error(e)),this.workerObjUrl&&URL.revokeObjectURL(this.workerObjUrl)}static get defaultPool(){return $._defaultPool=$._defaultPool||new $,$._defaultPool}createWorker(){const e=(z.publicPath||r.p)+"reveal.parser.worker.js",t={name:"reveal.parser #"+this.workerList.length};if(function(e,t=location.origin){const r=e=>!e.match(/^.*\/\//);if(r(t))throw new Error("isTheSameDomain: the second argument must be an absolute url or omitted. Received "+t);if(r(e))return!0;try{const r=[e,t].map(e=>e.startsWith("//")?"https:"+e:e).map(e=>new URL(e));return r[0].host===r[1].host}catch(r){return console.error(`can not create URLs for ${e} and ${t}`,r),!1}}(e))return new Worker(e,t);if(!this.workerObjUrl){const t=new Blob([`importScripts(${JSON.stringify(e)});`],{type:"text/javascript"});this.workerObjUrl=URL.createObjectURL(t)}return new Worker(this.workerObjUrl,t)}async postWorkToAvailable(e){const t=this.workerList.reduce((e,t)=>e.activeJobCount>t.activeJobCount?t:e,this.workerList[0]);t.activeJobCount+=1;return await(async()=>{try{return await e(t.worker)}finally{t.activeJobCount-=1}})()}determineNumberOfWorkers(){return Math.max(2,Math.min(4,window.navigator.hardwareConcurrency||2))}}class j{constructor(e){this._value=e,this._lastAccessTime=Date.now()}get value(){return this.touch(),this._value}get lastAccessTime(){return this._lastAccessTime}touch(){this._lastAccessTime=Date.now()}}class G{constructor(e=50,t,r=10){this._data=new Map,this._maxElementsInCache=e,this._defaultCleanupCount=r,this._removeCallback=t}has(e){return this._data.has(e)}forceInsert(e,t){this.isFull()&&this.cleanCache(this._defaultCleanupCount),this.insert(e,t)}insert(e,t){if(!(this._data.size<this._maxElementsInCache))throw new Error("Cache full, please clean Cache and retry adding data");this._data.set(e,new j(t))}remove(e){if(void 0!==this._removeCallback){const t=this._data.get(e);void 0!==t&&this._removeCallback(t.value)}this._data.delete(e)}get(e){const t=this._data.get(e);if(void 0!==t)return t.value;throw new Error(`Cache element ${e} does not exist`)}isFull(){return!(this._data.size<this._maxElementsInCache)}cleanCache(e){const t=Array.from(this._data.entries());t.sort((e,t)=>t[1].lastAccessTime-e[1].lastAccessTime);for(let r=0;r<e;r++){const e=t.pop();if(void 0===e)return;this.remove(e[0])}}clear(){if(void 0!==this._removeCallback)for(const e of this._data.values())this._removeCallback(e.value);this._data.clear()}}
|
|
64
68
|
/*!
|
|
65
69
|
* Copyright 2021 Cognite AS
|
|
66
|
-
*/class
|
|
70
|
+
*/class U{constructor(e,t){this._cache=new Map,this._retrieves=new Map,this._capacity=e,this._disposeCallback=t}get(e){const t=this._retrieves.get(e)||0;return this._retrieves.set(e,t+1),this._cache.get(e)}set(e,t){return this._cache.has(e)||this._capacity<this._cache.size?(this._cache.set(e,t),!0):(this._cache.set(e,t),this.ensureWithinCapacity(),this._cache.has(e))}remove(e){this._retrieves.delete(e);const t=this._cache.get(e);return void 0!==t&&(void 0!==this._disposeCallback&&this._disposeCallback(t),this._cache.delete(e),!0)}clear(){if(void 0!==this._disposeCallback)for(const e of this._cache.values())this._disposeCallback(e);this._retrieves.clear(),this._cache.clear()}ensureWithinCapacity(){if(this._capacity>=this._cache.size)return;const e=Array.from(this._cache.keys()).map(e=>({key:e,retrivalCount:this._retrieves.get(e)||0})).sort((e,t)=>e.retrivalCount-t.retrivalCount).slice(0,this._cache.size-this._capacity).map(e=>e.key);for(const t of e)this.remove(t)}}
|
|
67
71
|
/*!
|
|
68
72
|
* Copyright 2021 Cognite AS
|
|
69
|
-
*/function
|
|
73
|
+
*/function W(){this.array=null}
|
|
70
74
|
/*!
|
|
71
75
|
* Copyright 2021 Cognite AS
|
|
72
|
-
*/},function(e,t,r){"use strict";r.d(t,"a",(function(){return l})),r.d(t,"b",(function(){return h})),r.d(t,"g",(function(){return f})),r.d(t,"f",(function(){return g})),r.d(t,"e",(function(){return v})),r.d(t,"c",(function(){return w})),r.d(t,"d",(function(){return u})),r.d(t,"n",(function(){return M})),r.d(t,"o",(function(){return B})),r.d(t,"p",(function(){return
|
|
76
|
+
*/},function(e,t,r){"use strict";r.d(t,"a",(function(){return l})),r.d(t,"b",(function(){return h})),r.d(t,"g",(function(){return f})),r.d(t,"f",(function(){return g})),r.d(t,"e",(function(){return v})),r.d(t,"c",(function(){return w})),r.d(t,"d",(function(){return u})),r.d(t,"n",(function(){return M})),r.d(t,"o",(function(){return B})),r.d(t,"p",(function(){return k})),r.d(t,"q",(function(){return S})),r.d(t,"m",(function(){return I})),r.d(t,"i",(function(){return P})),r.d(t,"t",(function(){return N})),r.d(t,"k",(function(){return R})),r.d(t,"w",(function(){return A})),r.d(t,"r",(function(){return z})),r.d(t,"v",(function(){return V})),r.d(t,"j",(function(){return D})),r.d(t,"u",(function(){return T})),r.d(t,"s",(function(){return L})),r.d(t,"h",(function(){return d})),r.d(t,"l",(function(){return $}));var n=r(0),i=r(1),o=r(24),s=r.n(o);
|
|
73
77
|
/*!
|
|
74
78
|
* Copyright 2021 Cognite AS
|
|
75
79
|
*/
|
|
76
|
-
class a{constructor(e,t,r,n,
|
|
80
|
+
class a{constructor(e,t,r,n,i){this.version=e,this.maxTreeIndex=t,this.root=n,this.sectors=i,this.unit=r}get sectorCount(){return this.sectors.size}getSectorById(e){return this.sectors.get(e)}getAllSectors(){return[...this.sectors.values()]}getSectorsContainingPoint(e){const t=[];return Object(i.u)(this.root,r=>!!r.bounds.containsPoint(e)&&(t.push(r),!0)),t}getSectorsIntersectingBox(e){const t=[];return Object(i.u)(this.root,r=>!!r.bounds.intersectsBox(e)&&(t.push(r),!0)),t}getBoundsOfMostGeometry(){if(0===this.root.children.length)return this.root.bounds;const e=[],t=[];Object(i.u)(this.root,r=>(0===r.children.length&&(t.push(r.bounds.min.toArray(),r.bounds.max.toArray()),e.push(r.bounds,r.bounds)),!0));const r=Math.min(t.length,4),o=s()(t,r,"kmpp",10),a=new Array(o.idxs.length).fill(0),c=a.map(e=>new n.Box3);o.idxs.map(e=>a[e]++);const l=a.reduce((e,t,r)=>(t>e.count&&(e.count=t,e.idx=r),e),{count:0,idx:-1}).idx;o.idxs.forEach((t,r)=>{a[t]++,c[t].expandByPoint(e[r].min),c[t].expandByPoint(e[r].max)});const d=c.filter((e,t)=>!(t===l||!e.intersectsBox(c[l])));if(d.length>0){const e=c[l].clone();return d.forEach(t=>{e.expandByPoint(t.min),e.expandByPoint(t.max)}),e}return c[l]}getSectorsIntersectingFrustum(e,t){const r=(new n.Matrix4).multiplyMatrices(e,t),o=(new n.Frustum).setFromProjectionMatrix(r),s=[];return Object(i.u)(this.root,e=>!!o.intersectsBox(e.bounds)&&(s.push(e),!0)),s}}
|
|
77
81
|
/*!
|
|
78
82
|
* Copyright 2021 Cognite AS
|
|
79
|
-
*/function c(e){const t=new Map,r=[];e.sectors.forEach(e=>{const
|
|
83
|
+
*/function c(e){const t=new Map,r=[];e.sectors.forEach(e=>{const i=function(e){const t=function(e){if(!e.facesFile)return{quadSize:-1,coverageFactors:{xy:-1,yz:-1,xz:-1},recursiveCoverageFactors:{xy:-1,yz:-1,xz:-1},fileName:null,downloadSize:e.indexFile.downloadSize};return{...e.facesFile,recursiveCoverageFactors:e.facesFile.recursiveCoverageFactors||e.facesFile.coverageFactors}}(e),r=e.boundingBox,i=r.min.x,o=r.min.y,s=r.min.z,a=r.max.x,c=r.max.y,l=r.max.z;return{id:e.id,path:e.path,depth:e.depth,bounds:new n.Box3(new n.Vector3(i,o,s),new n.Vector3(a,c,l)),estimatedDrawCallCount:e.estimatedDrawCallCount,estimatedRenderCost:e.estimatedTriangleCount||0,indexFile:{...e.indexFile},facesFile:t,children:[]}}(e);t.set(e.id,i),r[e.id]=e.parentId});for(const e of t.values()){const n=r[e.id];if(-1===n)continue;t.get(n).children.push(e)}const i=t.get(0);if(!i)throw new Error("Root sector not found, must have ID 0");!function e(t,r){!function(e){return-1===e.facesFile.coverageFactors.xy}(t)?t.children.forEach(r=>e(r,t.facesFile)):(t.facesFile.coverageFactors.xy=r.recursiveCoverageFactors.xy,t.facesFile.coverageFactors.yz=r.recursiveCoverageFactors.yz,t.facesFile.coverageFactors.xz=r.recursiveCoverageFactors.xz,t.facesFile.recursiveCoverageFactors.xy=r.recursiveCoverageFactors.xy,t.facesFile.recursiveCoverageFactors.yz=r.recursiveCoverageFactors.yz,t.facesFile.recursiveCoverageFactors.xz=r.recursiveCoverageFactors.xz,t.children.forEach(t=>e(t,r)))}
|
|
80
84
|
/*!
|
|
81
85
|
* Copyright 2021 Cognite AS
|
|
82
|
-
*/(
|
|
86
|
+
*/(i,i.facesFile);const o=null!==e.unit?e.unit:"Meters";return new a(e.version,e.maxTreeIndex,o,i,t)}class l{parse(e){const t=e.version;switch(t){case 8:return c(e);case void 0:throw new Error('Metadata must contain a "version"-field');default:throw new Error(`Version ${t} is not supported`)}}}
|
|
83
87
|
/*!
|
|
84
88
|
* Copyright 2021 Cognite AS
|
|
85
89
|
*/const d=new Map([["Meters",1],["Centimeters",.01],["Millimeters",.001],["Micrometers",1e-6],["Kilometers",1e3],["Feet",.3048],["Inches",.0254],["Yards",.9144],["Miles",1609.34],["Mils",254e-7],["Microinches",2.54e-8]]);
|
|
86
90
|
/*!
|
|
87
91
|
* Copyright 2021 Cognite AS
|
|
88
|
-
*/class h{constructor(e,t,r,n="scene.json"){this._currentModelIdentifier=0,this._modelMetadataProvider=e,this._modelDataProvider=t,this._cadSceneParser=r,this._blobFileName=n}async loadData(e){const t=this._modelMetadataProvider.getModelUri(e),r=this._modelMetadataProvider.getModelMatrix(e),
|
|
92
|
+
*/class h{constructor(e,t,r,n="scene.json"){this._currentModelIdentifier=0,this._modelMetadataProvider=e,this._modelDataProvider=t,this._cadSceneParser=r,this._blobFileName=n}async loadData(e){const t=this._modelMetadataProvider.getModelUri(e),r=this._modelMetadataProvider.getModelMatrix(e),o=this._modelMetadataProvider.getModelCamera(e),s=await t,a=await this._modelDataProvider.getJsonFile(s,this._blobFileName),c=this._cadSceneParser.parse(a),l=function(e,t){const r=d.get(e);if(void 0===r)throw new Error(`Unknown model unit '${e}'`);return(new n.Matrix4).makeScale(r,r,r).multiply(t)}(c.unit,await r),h=(new n.Matrix4).copy(l).invert(),u=await o;return{modelIdentifier:""+this._currentModelIdentifier++,modelBaseUrl:s,geometryClipBox:null,modelMatrix:l,inverseModelMatrix:h,cameraConfiguration:Object(i.t)(u,l),scene:c}}}var u,m=r(7),p=r.n(m);
|
|
89
93
|
/*!
|
|
90
94
|
* Copyright 2021 Cognite AS
|
|
91
95
|
*/
|
|
92
|
-
class f{createSectorScene(e,t,r,n){p()(8===e,"Only version 8 is currently supported");const
|
|
96
|
+
class f{createSectorScene(e,t,r,n){p()(8===e,"Only version 8 is currently supported");const o=new Map;return Object(i.u)(n,e=>(o.set(e.id,e),!0)),new a(e,t,r,n,o)}}
|
|
93
97
|
/*!
|
|
94
98
|
* Copyright 2021 Cognite AS
|
|
95
99
|
*/!function(e){e[e.Discarded=0]="Discarded",e[e.Simple=1]="Simple",e[e.Detailed=2]="Detailed"}(u||(u={}));
|
|
@@ -99,47 +103,47 @@ class f{createSectorScene(e,t,r,n){p()(8===e,"Only version 8 is currently suppor
|
|
|
99
103
|
class g extends n.Group{constructor(e,t,r){super(),this._lod=u.Discarded,this._updatedTimestamp=Date.now(),this.name=`Sector ${t} [id=${e}]`,this.sectorId=e,this.sectorPath=t,this.bounds=r,this.depth=function(e){let t=0;for(let r=0;r<e.length;++r)t+="/"===e[r]?1:0;return t-1}
|
|
100
104
|
/*!
|
|
101
105
|
* Copyright 2021 Cognite AS
|
|
102
|
-
*/(t)}get levelOfDetail(){return this._lod}get group(){return this._group}get updatedTimestamp(){return this._updatedTimestamp}updateGeometry(e,t){this.resetGeometry(),this._group=e,void 0!==this._group&&this._group.reference(),this._lod=t,this._updatedTimestamp=Date.now(),this.visible=this._lod!==u.Discarded,this.updateMatrixWorld(!0)}resetGeometry(){void 0!==this._group&&(this._group.dereference(),this.remove(this._group)),this._group=void 0,this._lod=u.Discarded,this._updatedTimestamp=Date.now()}}class v extends g{constructor(e){const t=e.scene.root.bounds.clone();t.applyMatrix4(e.modelMatrix),super(0,"/",t);const{scene:r,modelMatrix:n}=e;this.sectorNodeMap=new Map,function e(t,r,n,
|
|
106
|
+
*/(t)}get levelOfDetail(){return this._lod}get group(){return this._group}get updatedTimestamp(){return this._updatedTimestamp}updateGeometry(e,t){this.resetGeometry(),this._group=e,void 0!==this._group&&this._group.reference(),this._lod=t,this._updatedTimestamp=Date.now(),this.visible=this._lod!==u.Discarded,this.updateMatrixWorld(!0)}resetGeometry(){void 0!==this._group&&(this._group.dereference(),this.remove(this._group)),this._group=void 0,this._lod=u.Discarded,this._updatedTimestamp=Date.now()}}class v extends g{constructor(e){const t=e.scene.root.bounds.clone();t.applyMatrix4(e.modelMatrix),super(0,"/",t);const{scene:r,modelMatrix:n}=e;this.sectorNodeMap=new Map,function e(t,r,n,i){const o=t.bounds.clone();o.applyMatrix4(i);const s=new g(t.id,t.path,o);s.name="Sector "+t.id,r.add(s),s.matrixAutoUpdate=!1,s.updateMatrixWorld(!0),n.set(t.id,s);for(const r of t.children)e(r,s,n,i)}
|
|
103
107
|
/*!
|
|
104
108
|
* Copyright 2021 Cognite AS
|
|
105
|
-
*/(r.root,this,this.sectorNodeMap,n),this.matrixAutoUpdate=!1,this.setModelTransformation(n)}setModelTransformation(e){this.matrix.copy(e),this.updateMatrixWorld(!0)}getModelTransformation(e=new n.Matrix4){return e.copy(this.matrix)}}class w{constructor(e=
|
|
109
|
+
*/(r.root,this,this.sectorNodeMap,n),this.matrixAutoUpdate=!1,this.setModelTransformation(n)}setModelTransformation(e){this.matrix.copy(e),this.updateMatrixWorld(!0)}getModelTransformation(e=new n.Matrix4){return e.copy(this.matrix)}}class w{constructor(e=i.k.defaultPool){this.workerPool=e}parseI3D(e){return this.parseDetailed(e)}parseF3D(e){return this.parseSimple(e)}parseCTM(e){return this.parseCtm(e)}async parseSimple(e){return this.workerPool.postWorkToAvailable(async t=>t.parseQuads(e))}async parseDetailed(e){return this.workerPool.postWorkToAvailable(async t=>t.parseSector(e))}async parseCtm(e){return this.workerPool.postWorkToAvailable(async t=>t.parseCtm(e))}}
|
|
106
110
|
/*!
|
|
107
111
|
* Copyright 2021 Cognite AS
|
|
108
|
-
*/const x={centerA:new n.Vector3,centerB:new n.Vector3,sphere:new n.Sphere,box:new n.Box3};const _={vertex1:new n.Vector3,vertex2:new n.Vector3,vertex3:new n.Vector3,vertex4:new n.Vector3};const
|
|
112
|
+
*/const x={centerA:new n.Vector3,centerB:new n.Vector3,sphere:new n.Sphere,box:new n.Box3};const _={vertex1:new n.Vector3,vertex2:new n.Vector3,vertex3:new n.Vector3,vertex4:new n.Vector3};const b={instanceMatrix:new n.Matrix4};const y={center:new n.Vector3,size:new n.Vector3};
|
|
109
113
|
/*!
|
|
110
114
|
* Copyright 2021 Cognite AS
|
|
111
115
|
*/
|
|
112
|
-
function C(e,t,r,
|
|
116
|
+
function C(e,t,r,i){const o=Array.from(t.values()).reduce((e,t)=>Math.max(e,t.offset+t.size),0),s=e.length/o,a=new Float32Array(e.buffer),c=new n.Box3,l=new Uint8Array(e.length);let d=0;for(let t=0;t<s;++t)if(i(t,o,a,c),r.intersectsBox(c)){const r=e.subarray(t*o,(t+1)*o);l.set(r,d*o),d++}return l.slice(0,d*o)}function M(e,t,r,n){if(null===n)return e;const i=t.get("instanceMatrix");return p()(void 0!==i),C(e,t,n,(e,t,n,o)=>{!function(e,t,r,n,i,o){const{instanceMatrix:s}=b,a=(n*r+e.offset)/t.BYTES_PER_ELEMENT;s.set(t[a+0],t[a+4],t[a+8],t[a+12],t[a+1],t[a+5],t[a+9],t[a+13],t[a+2],t[a+6],t[a+10],t[a+14],t[a+3],t[a+7],t[a+11],t[a+15]),o.copy(i).applyMatrix4(s)}(i,n,t,e,r,o)})}function B(e,t,r,n="radiusA",i="radiusB"){if(null===r)return e;const o=t.get("centerA"),s=t.get("centerB"),a=t.get(n),c=t.get(i);return p()(void 0!==o&&void 0!==s&&void 0!==a&&void 0!==c),C(e,t,r,(e,t,r,n)=>{!function(e,t,r,n,i,o,s,a){const{centerA:c,centerB:l,sphere:d,box:h}=x;function u(e,t=0){const r=(s*o+e.offset)/i.BYTES_PER_ELEMENT;return i[r+t]}c.set(u(e,0),u(e,1),u(e,2)),l.set(u(t,0),u(t,1),u(t,2));const m=u(r),p=u(n);d.set(c,m),d.getBoundingBox(a),d.set(l,p),d.getBoundingBox(h),a.expandByPoint(h.min),a.expandByPoint(h.max)}(o,s,a,c,r,t,e,n)})}function S(e,t,r){if(null===r)return e;const n=t.get("vertex1"),i=t.get("vertex2"),o=t.get("vertex3"),s=t.get("vertex4");return p()(void 0!==n&&void 0!==i&&void 0!==o&&void 0!==s),C(e,t,r,(e,t,r,a)=>{!function(e,t,r,n,i,o,s,a){const{vertex1:c,vertex2:l,vertex3:d,vertex4:h}=_;function u(e,t=0){const r=(s*o+e.offset)/i.BYTES_PER_ELEMENT;return i[r+t]}c.set(u(e,0),u(e,1),u(e,2)),l.set(u(t,0),u(t,1),u(t,2)),d.set(u(r,0),u(r,1),u(r,2)),h.set(u(n,0),u(n,1),u(n,2)),a.setFromPoints([c,l,d,h])}(n,i,o,s,r,t,e,a)})}function k(e,t,r,n="horizontalRadius",i="verticalRadius"){if(null===r)return e;const o=t.get("center"),s=t.get(n),a=t.get(i),c=t.get("height");return p()(void 0!==o&&void 0!==s&&void 0!==a&&void 0!==c),C(e,t,r,(e,t,r,n)=>{!function(e,t,r,n,i,o,s,a){const{center:c,size:l}=y;function d(e,t=0){const r=(s*o+e.offset)/i.BYTES_PER_ELEMENT;return i[r+t]}c.set(d(e,0),d(e,1),d(e,2));const h=d(t),u=d(r),m=d(n),p=2*Math.max(h,u,m);l.set(p,p,p),a.setFromCenterAndSize(c,l)}(o,s,a,c,r,t,e,n)})}
|
|
113
117
|
/*!
|
|
114
118
|
* Copyright 2021 Cognite AS
|
|
115
119
|
*/
|
|
116
|
-
const E={p:new n.Vector3,instanceMatrix:new n.Matrix4,baseBounds:new n.Box3,instanceBounds:new n.Box3};function
|
|
120
|
+
const E={p:new n.Vector3,instanceMatrix:new n.Matrix4,baseBounds:new n.Box3,instanceBounds:new n.Box3};function I(e,t,r,n){if(null===n)return r;const{p:i,instanceMatrix:o,baseBounds:s,instanceBounds:a}=E;s.makeEmpty();for(let n=r.triangleOffset;n<r.triangleOffset+r.triangleCount;++n){const r=t[3*n+0],o=t[3*n+1],a=t[3*n+2];i.set(e[r+0],e[r+1],e[r+2]),s.expandByPoint(i),i.set(e[o+0],e[o+1],e[o+2]),s.expandByPoint(i),i.set(e[a+0],e[a+1],e[a+2]),s.expandByPoint(i)}let c=0;const l=r.treeIndices.length,d=new Float32Array(r.instanceMatrices.length),h=new Float32Array(l),u=new Uint8Array(4*l);for(let e=0;e<l;++e)if(m=r.instanceMatrices,p=e,o.set(m[p+0],m[p+4],m[p+8],m[p+12],m[p+1],m[p+5],m[p+9],m[p+13],m[p+2],m[p+6],m[p+10],m[p+14],m[p+3],m[p+7],m[p+11],m[p+15]),a.copy(s).applyMatrix4(o),n.intersectsBox(a)){const t=r.instanceMatrices.subarray(16*e,16*(e+1)),n=r.colors.subarray(4*e,4*(e+1)),i=r.treeIndices[e];d.set(t,16*c),u.set(n,4*c),h[c]=i,c++}var m,p;if(l===c)return r;return{triangleCount:r.triangleCount,triangleOffset:r.triangleOffset,instanceMatrices:d.slice(0,16*c),colors:u.slice(0,4*c),treeIndices:h.slice(0,c)}}
|
|
117
121
|
/*!
|
|
118
122
|
* Copyright 2021 Cognite AS
|
|
119
|
-
*/const{boxGeometry:P,boxGeometryBoundingBox:D}=(()=>{const e=new n.BoxBufferGeometry(1,1,1,1,1,1);try{const t={index:e.getIndex(),position:e.getAttribute("position"),normal:e.getAttribute("normal")};return e.computeBoundingBox(),{boxGeometry:t,boxGeometryBoundingBox:e.boundingBox}}finally{e.dispose()}})(),{quadGeometry:N,quadGeometryBoundingBox:T}=(()=>{const e=new n.PlaneBufferGeometry(1,1,1,1);try{const t={index:e.getIndex(),position:e.getAttribute("position"),normal:e.getAttribute("normal")};return e.computeBoundingBox(),{quadGeometry:t,quadGeometryBoundingBox:e.boundingBox}}finally{e.dispose()}})(),{trapeziumGeometry:A,trapeziumGeometryBoundingBox:F}=(()=>{const e=[0,0,0,1,1,1,2,2,2,3,3,3];return{trapeziumGeometry:{index:new n.BufferAttribute(new Uint16Array([0,1,3,0,3,2]),1),position:new n.BufferAttribute(new Float32Array(e),3)},trapeziumGeometryBoundingBox:(new n.Box3).setFromArray(e)}})(),{coneGeometry:R,coneGeometryBoundingBox:O}=(()=>{const e=[];e.push(-1,1,-1),e.push(-1,-1,-1),e.push(1,1,-1),e.push(1,-1,-1),e.push(1,1,1),e.push(1,-1,1);const t=new Uint16Array([1,2,0,1,3,2,3,4,2,3,5,4]);return{coneGeometry:{index:new n.BufferAttribute(t,1),position:new n.BufferAttribute(new Float32Array(e),3)},coneGeometryBoundingBox:(new n.Box3).setFromArray(e)}})(),{torusLodGeometries:V
|
|
123
|
+
*/const{boxGeometry:P,boxGeometryBoundingBox:D}=(()=>{const e=new n.BoxBufferGeometry(1,1,1,1,1,1);try{const t={index:e.getIndex(),position:e.getAttribute("position"),normal:e.getAttribute("normal")};return e.computeBoundingBox(),{boxGeometry:t,boxGeometryBoundingBox:e.boundingBox}}finally{e.dispose()}})(),{quadGeometry:N,quadGeometryBoundingBox:T}=(()=>{const e=new n.PlaneBufferGeometry(1,1,1,1);try{const t={index:e.getIndex(),position:e.getAttribute("position"),normal:e.getAttribute("normal")};return e.computeBoundingBox(),{quadGeometry:t,quadGeometryBoundingBox:e.boundingBox}}finally{e.dispose()}})(),{trapeziumGeometry:A,trapeziumGeometryBoundingBox:F}=(()=>{const e=[0,0,0,1,1,1,2,2,2,3,3,3];return{trapeziumGeometry:{index:new n.BufferAttribute(new Uint16Array([0,1,3,0,3,2]),1),position:new n.BufferAttribute(new Float32Array(e),3)},trapeziumGeometryBoundingBox:(new n.Box3).setFromArray(e)}})(),{coneGeometry:R,coneGeometryBoundingBox:O}=(()=>{const e=[];e.push(-1,1,-1),e.push(-1,-1,-1),e.push(1,1,-1),e.push(1,-1,-1),e.push(1,1,1),e.push(1,-1,1);const t=new Uint16Array([1,2,0,1,3,2,3,4,2,3,5,4]);return{coneGeometry:{index:new n.BufferAttribute(t,1),position:new n.BufferAttribute(new Float32Array(e),3)},coneGeometryBoundingBox:(new n.Box3).setFromArray(e)}})(),{torusLodGeometries:V}=(()=>{const e=(e,t)=>[e,2*t*Math.PI];return{torusLodGeometries:[{tubularSegments:9,radialSegments:18},{tubularSegments:5,radialSegments:12},{tubularSegments:4,radialSegments:5}].map(({tubularSegments:t,radialSegments:r})=>function(e,t,r=((e,t)=>[e,t,0])){const i=[],o=[],s=1/e,a=1/t;for(let n=0;n<=t;n++)for(let t=0;t<=e;t++){const[e,o,c]=r(t*s,n*a);i.push(e||0,o||0,c||0)}for(let r=1;r<=t;r++)for(let t=1;t<=e;t++){const n=(e+1)*r+t-1,i=(e+1)*(r-1)+t-1,s=(e+1)*(r-1)+t,a=(e+1)*r+t;o.push(n,i,a),o.push(i,s,a)}return{index:new n.Uint16BufferAttribute(o,1),position:new n.Float32BufferAttribute(i,3)}}(r,t,e))}})(),{nutGeometry:z,nutGeometryBoundingBox:L}=(()=>{const e=new n.CylinderBufferGeometry(.5,.5,1,6);try{e.applyMatrix4((new n.Matrix4).makeRotationX(-Math.PI/2));const t={index:e.getIndex(),position:e.getAttribute("position"),normal:e.getAttribute("normal")};return{nutGeometry:t,nutGeometryBoundingBox:(new n.Box3).setFromArray(t.position.array)}}finally{e.dispose()}})();
|
|
120
124
|
/*!
|
|
121
125
|
* Copyright 2021 Cognite AS
|
|
122
126
|
*/
|
|
123
|
-
function
|
|
127
|
+
function $(e,t,r,o){const s=[],a=e.filter(e=>null===o||function(e,t){const{p:r,box:n}=j;n.makeEmpty();for(let t=0;t<e.vertices.length;t+=3)r.set(e.vertices[t+0],e.vertices[t+1],e.vertices[t+2]),n.expandByPoint(r);return t.intersectsBox(n)}
|
|
124
128
|
/*!
|
|
125
129
|
* Copyright 2021 Cognite AS
|
|
126
|
-
*/(e,
|
|
130
|
+
*/(e,o));for(const e of a){const o=new n.BufferGeometry,a=new n.Uint32BufferAttribute(e.indices.buffer,1).onUpload(i.n),c=new n.Float32BufferAttribute(e.vertices.buffer,3).onUpload(i.n),l=new n.Uint8BufferAttribute(e.colors.buffer,3).onUpload(i.n),d=new n.Float32BufferAttribute(e.treeIndices.buffer,1).onUpload(i.n);o.setIndex(a),o.setAttribute("color",l),o.setAttribute("position",c),o.setAttribute("treeIndex",d),o.boundingBox=t.clone(),o.boundingSphere=new n.Sphere,t.getBoundingSphere(o.boundingSphere);const h=new n.Mesh(o,r);h.name="Triangle mesh "+e.fileId,h.userData.treeIndices=new Set(e.treeIndices),s.push(h)}return s}const j={p:new n.Vector3,box:new n.Box3}},,,,function(e,t,r){"use strict";r.d(t,"a",(function(){return n})),r.d(t,"b",(function(){return i})),r.d(t,"c",(function(){return d})),r.d(t,"d",(function(){return h})),r.d(t,"f",(function(){return p})),r.d(t,"g",(function(){return f})),r.d(t,"h",(function(){return g})),r.d(t,"e",(function(){return o}));class n{constructor(e){this.client=e,this.authenticationPromise=e.authenticate()}get headers(){return this.client.getDefaultRequestHeaders()}async getBinaryFile(e,t){const r=`${e}/${t}`,n={...this.client.getDefaultRequestHeaders(),Accept:"*/*"};return(await this.fetchWithRetry(r,{headers:n,method:"GET"})).arrayBuffer()}async getJsonFile(e,t){return(await this.client.get(`${e}/${t}`)).data}async fetchWithRetry(e,t,r=3){let n;for(let i=0;i<r;i++)try{await this.authenticationPromise;const r=await fetch(e,t);if(401===r.status){this.authenticationPromise=this.client.authenticate();continue}return r}catch(e){void 0!==n&&(n=e)}throw n}}class i{constructor(e,t,r){this.revealInternalId=Symbol(`${e}/${t}[${r}]`),this.modelId=e,this.revisionId=t,this.modelFormat=r}toString(){return`${i.name} (${String(this.revealInternalId)} - ${this.modelFormat})`}}var o,s=r(0);
|
|
127
131
|
/*!
|
|
128
132
|
* Copyright 2021 Cognite AS
|
|
129
|
-
*/!function(e){e.EptPointCloud="ept-pointcloud",e.RevealCadModel="reveal-directory",e.AnyFormat="all-outputs"}(
|
|
133
|
+
*/!function(e){e.EptPointCloud="ept-pointcloud",e.RevealCadModel="reveal-directory",e.AnyFormat="all-outputs"}(o||(o={}));
|
|
130
134
|
/*!
|
|
131
135
|
* Copyright 2021 Cognite AS
|
|
132
136
|
*/
|
|
133
|
-
const a=(new s.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function c(e,t){switch(t){case
|
|
137
|
+
const a=(new s.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function c(e,t){switch(t){case o.RevealCadModel:e.premultiply(a);break;case o.EptPointCloud:break;default:throw new Error("Unknown model format '"+t)}}
|
|
134
138
|
/*!
|
|
135
139
|
* Copyright 2021 Cognite AS
|
|
136
140
|
*/class l{constructor(e,t,r){this.modelId=e,this.revisionId=t,this.outputs=r}findMostRecentOutput(e,t){const r=this.outputs.filter(r=>r.format===e&&(!t||-1!==t.indexOf(r.version)));return r.length>0?r.reduce((e,t)=>t.version>e.version?t:e):void 0}}
|
|
137
141
|
/*!
|
|
138
142
|
* Copyright 2021 Cognite AS
|
|
139
|
-
*/class d{constructor(e){this._client=e}async getModelMatrix(e){if(!(e instanceof
|
|
143
|
+
*/class d{constructor(e){this._client=e}async getModelMatrix(e){if(!(e instanceof i))throw new Error(`Model must be a ${i.name}, but got ${e.toString()}`);const{modelId:t,revisionId:r,modelFormat:n}=e,o=await this._client.revisions3D.retrieve(t,r),a=new s.Matrix4;return o.rotation&&a.makeRotationFromEuler(new s.Euler(...o.rotation)),c(a,n),a}async getModelCamera(e){if(!(e instanceof i))throw new Error(`Model must be a ${i.name}, but got ${e.toString()}`);const{modelId:t,revisionId:r}=e,n=await this._client.revisions3D.retrieve(t,r);if(n.camera&&n.camera.position&&n.camera.target){const{position:e,target:t}=n.camera;return{position:new s.Vector3(e[0],e[1],e[2]),target:new s.Vector3(t[0],t[1],t[2])}}}async getModelUri(e){if(!(e instanceof i))throw new Error(`Model must be a ${i.name}, but got ${e.toString()}`);const{modelId:t,revisionId:r,modelFormat:n}=e,o=(await this.getOutputs(e)).findMostRecentOutput(n);if(!o)throw new Error(`Model '${t}/${r}' is not compatible with this version of Reveal, because no outputs for format '(${n})' was found. If this model works with a previous version of Reveal it must be reprocessed to support this version.`);const s=o.blobId;return`${this._client.getBaseUrl()}${this.getRequestPath(s)}`}async getOutputs(e){const{modelId:t,revisionId:r,modelFormat:n}=e,i=`/api/v1/projects/${this._client.project}/3d/models/${t}/revisions/${r}/outputs`,o=void 0!==n?{params:{format:n}}:void 0,s=await this._client.get(i,o);if(200===s.status)return new l(t,r,s.data.items);throw new Error(`Unexpected response ${s.status} (payload: '${s.data})`)}getRequestPath(e){return`/api/v1/projects/${this._client.project}/3d/files/${e}`}}
|
|
140
144
|
/*!
|
|
141
145
|
* Copyright 2021 Cognite AS
|
|
142
|
-
*/class h{constructor(e){this._client=e}async getOutputs(e){const{modelId:t,revisionId:r,modelFormat:n}=e,
|
|
146
|
+
*/class h{constructor(e){this._client=e}async getOutputs(e){const{modelId:t,revisionId:r,modelFormat:n}=e,i=`/api/v1/projects/${this._client.project}/3d/models/${t}/revisions/${r}/outputs`,o=void 0!==n?{params:{format:n}}:void 0,s=await this._client.get(i,o);if(200===s.status)return new l(t,r,s.data.items);throw new Error(`Unexpected response ${s.status} (payload: '${s.data})`)}}var u=r(18);
|
|
143
147
|
/*!
|
|
144
148
|
* Copyright 2021 Cognite AS
|
|
145
149
|
*/async function m(e){const t=await fetch(e);if(!t.ok){const e={};throw t.headers.forEach((t,r)=>{e[t]=r}),new u.HttpError(t.status,t.body,e)}return t}
|
|
@@ -151,78 +155,78 @@ const a=(new s.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function c(e,t){sw
|
|
|
151
155
|
*/class f{constructor(e){this.revealInternalId=Symbol(e),this.localPath=e}toString(){return`${f.name} (${this.localPath})`}}
|
|
152
156
|
/*!
|
|
153
157
|
* Copyright 2021 Cognite AS
|
|
154
|
-
*/class g{getModelUri(e){if(!(e instanceof f))throw new Error(`Model must be a ${f.name}, but got ${e.toString()}`);return Promise.resolve(`${location.origin}/${e.localPath}`)}async getModelMatrix(e){if(!(e instanceof f))throw new Error(`Model must be a ${f.name}, but got ${e.toString()}`);const t=new s.Matrix4;return c(t,
|
|
158
|
+
*/class g{getModelUri(e){if(!(e instanceof f))throw new Error(`Model must be a ${f.name}, but got ${e.toString()}`);return Promise.resolve(`${location.origin}/${e.localPath}`)}async getModelMatrix(e){if(!(e instanceof f))throw new Error(`Model must be a ${f.name}, but got ${e.toString()}`);const t=new s.Matrix4;return c(t,o.RevealCadModel),t}getModelCamera(e){if(!(e instanceof f))throw new Error(`Model must be a ${f.name}, but got ${e.toString()}`);return Promise.resolve(void 0)}}
|
|
155
159
|
/*!
|
|
156
160
|
* Copyright 2021 Cognite AS
|
|
157
|
-
*/},function(e,t){e.exports=require("assert")},function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(12),
|
|
161
|
+
*/},function(e,t){e.exports=require("assert")},function(e,t,r){"use strict";r.d(t,"a",(function(){return c}));var n=r(12),i=r.n(n),o=r(10);const{VERSION:s,MIXPANEL_TOKEN:a}={VERSION:"2.3.0",WORKER_VERSION:"1.3.0",MIXPANEL_TOKEN:"8c900bdfe458e32b768450c20750853d",IS_DEVELOPMENT_MODE:!1};class c{constructor(e,t,r){i.a.init(a,{disable_cookie:!0,disable_persistence:!0,ip:!1,property_blacklist:["$city","$region","mp_country_code","$geo_source","$timezone","mp_lib","$lib_version","$device_id","$user_id","$current_url","$screen_width","$screen_height","$referrer","$referring_domain","$initial_referrer","$initial_referring_domain"]}),i.a.reset(),i.a.identify("reveal-single-user"),this._sessionProps={VERSION:s,project:"unknown",application:"unknown",sessionId:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},e&&(this._sessionProps.project=e),t&&(this._sessionProps.application=t),this.innerTrackEvent("init",r)}static init(e,t,r,n){if(void 0===globalThis.revealMetricsLogger&&e){const e=new c(t,r,n);globalThis.revealMetricsLogger={metricsLogger:e}}}innerTrackEvent(e,t){const r={...this._sessionProps,...t};i.a.track(e,r)}static trackEvent(e,t){globalThis.revealMetricsLogger&&globalThis.revealMetricsLogger.metricsLogger.innerTrackEvent(e,t)}static trackCreateTool(e){c.trackEvent("toolCreated",{toolName:e})}static trackLoadModel(e,t){c.trackEvent("loadModel",{...e,modelIdentifier:t})}static trackCadModelStyled(e,t){c.trackEvent("cadModelStyleAssigned",{nodeCollectionClassToken:e,style:t})}static trackError(e,t){o.a.error(e),this.trackEvent("error",{message:e.message,name:e.name,stack:e.stack,...t})}static trackCameraNavigation(e){c.trackEvent("cameraNavigated",e)}}
|
|
158
162
|
/*!
|
|
159
163
|
* Copyright 2021 Cognite AS
|
|
160
164
|
*/},,function(e,t,r){"use strict";var n=r(23);
|
|
161
165
|
/*!
|
|
162
166
|
* Copyright 2021 Cognite AS
|
|
163
|
-
*/t.a=n},function(e,t){e.exports=require("@tweenjs/tween.js")},function(e,t){e.exports=require("mixpanel-browser")},function(e,t,r){"use strict";r.d(t,"a",(function(){return
|
|
167
|
+
*/t.a=n},function(e,t){e.exports=require("@tweenjs/tween.js")},function(e,t){e.exports=require("mixpanel-browser")},function(e,t,r){"use strict";r.d(t,"a",(function(){return o})),r.d(t,"b",(function(){return s}));var n=r(0);
|
|
164
168
|
/*!
|
|
165
169
|
* Copyright 2021 Cognite AS
|
|
166
170
|
*/
|
|
167
|
-
const
|
|
171
|
+
const i={renderSize:new n.Vector2,position:new n.Vector3};function o(e,t,r=new n.Vector3){const{position:o}=i;o.copy(t),o.project(e);const s=(o.x+1)/2,a=(1-o.y)/2;return r.set(s,a,o.z)}function s(e,t,r,s=new n.Vector3){o(t,r,s);const{renderSize:a}=i;e.getSize(a);const c=e.domElement,{width:l,height:d}=c.getBoundingClientRect();return s.x=Math.round(s.x*l),s.y=Math.round(s.y*d),s}},function(e,t){e.exports=require("lodash/debounce")},function(e,t){e.exports=require("lodash/cloneDeep")},function(e,t){e.exports=require("lodash/range")},function(e,t){e.exports=require("geo-three")},function(e,t){e.exports=require("@cognite/sdk-core")},function(e,t,r){"use strict";var n=r(13);r.d(t,"d",(function(){return n.b}));var i=r(20);r.d(t,"a",(function(){return i.a}));var o=r(1);r.d(t,"c",(function(){return o.l})),r.d(t,"b",(function(){return o.d}));r(6);
|
|
168
172
|
/*!
|
|
169
173
|
* Copyright 2021 Cognite AS
|
|
170
|
-
*/},function(e,t,r){"use strict";r.d(t,"a",(function(){return
|
|
174
|
+
*/},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n=r(0);
|
|
171
175
|
/*!
|
|
172
176
|
* Copyright 2021 Cognite AS
|
|
173
177
|
*/
|
|
174
|
-
class
|
|
178
|
+
class i{constructor(e){this._clippingPlanes=[new n.Plane,new n.Plane,new n.Plane,new n.Plane,new n.Plane,new n.Plane],this._box=e||new n.Box3,this.updatePlanes()}set minX(e){this._box.min.x=e,this.updatePlanes()}get minX(){return this._box.min.x}set minY(e){this._box.min.y=e,this.updatePlanes()}get minY(){return this._box.min.y}set minZ(e){this._box.min.z=e,this.updatePlanes()}get minZ(){return this._box.min.z}set maxX(e){this._box.max.x=e,this.updatePlanes()}get maxX(){return this._box.max.x}set maxY(e){this._box.max.y=e,this.updatePlanes()}get maxY(){return this._box.max.y}set maxZ(e){this._box.max.z=e,this.updatePlanes()}get maxZ(){return this._box.max.z}updatePlanes(){this._clippingPlanes[0].setFromNormalAndCoplanarPoint(new n.Vector3(1,0,0),new n.Vector3(this.minX,0,0)),this._clippingPlanes[1].setFromNormalAndCoplanarPoint(new n.Vector3(-1,0,0),new n.Vector3(this.maxX,0,0)),this._clippingPlanes[2].setFromNormalAndCoplanarPoint(new n.Vector3(0,1,0),new n.Vector3(0,this.minY,0)),this._clippingPlanes[3].setFromNormalAndCoplanarPoint(new n.Vector3(0,-1,0),new n.Vector3(0,this.maxY,0)),this._clippingPlanes[4].setFromNormalAndCoplanarPoint(new n.Vector3(0,0,1),new n.Vector3(0,0,this.minZ)),this._clippingPlanes[5].setFromNormalAndCoplanarPoint(new n.Vector3(0,0,-1),new n.Vector3(0,0,this.maxZ))}get clippingPlanes(){return this._clippingPlanes}}},,function(e,t){e.exports=require("comlink")},function(e,t){e.exports=require("loglevel")},function(e,t){e.exports=require("skmeans")},,,,,,,,function(e,t){e.exports=require("lodash/merge")},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,r){"use strict";r.r(t),r.d(t,"HtmlOverlayTool",(function(){return u})),r.d(t,"ExplodedViewTool",(function(){return p})),r.d(t,"DebugCameraTool",(function(){return f})),r.d(t,"AxisViewTool",(function(){return S})),r.d(t,"Corner",(function(){return g})),r.d(t,"GeomapTool",(function(){return z})),r.d(t,"MapProviders",(function(){return k})),r.d(t,"MapboxMode",(function(){return E})),r.d(t,"MapboxStyle",(function(){return I})),r.d(t,"MapboxImageFormat",(function(){return D})),r.d(t,"BingMapType",(function(){return N})),r.d(t,"BingMapImageFormat",(function(){return T})),r.d(t,"HereMapType",(function(){return A})),r.d(t,"HereMapScheme",(function(){return F})),r.d(t,"HereMapImageFormat",(function(){return R})),r.d(t,"TimelineTool",(function(){return $})),r.d(t,"Keyframe",(function(){return L})),r.d(t,"Cognite3DViewerToolBase",(function(){return o})),r.d(t,"DebugLoadedSectorsTool",(function(){return G}));var n=r(0),i=r(19);
|
|
175
179
|
/*!
|
|
176
180
|
* Copyright 2021 Cognite AS
|
|
177
181
|
*/
|
|
178
182
|
/*!
|
|
179
183
|
* Copyright 2021 Cognite AS
|
|
180
184
|
*/
|
|
181
|
-
class
|
|
185
|
+
class o{constructor(){this._disposedEvent=new i.b,this._disposed=!1}on(e,t){switch(e){case"disposed":this._disposedEvent.subscribe(t);break;default:Object(i.c)(e)}}off(e,t){switch(e){case"disposed":this._disposedEvent.unsubscribe(t);break;default:Object(i.c)(e)}}dispose(){if(this._disposed)throw new Error("Already disposed");this._disposed=!0,this._disposedEvent.fire(),this._disposedEvent.unsubscribeAll()}ensureNotDisposed(){if(this._disposed)throw new Error("The tool has been disposed")}}var s=r(16),a=r.n(s);
|
|
182
186
|
/*!
|
|
183
187
|
* Copyright 2021 Cognite AS
|
|
184
188
|
*/
|
|
185
|
-
class c{constructor(e,t){this._removedElements=new Set,this._dimensions=t,this._cells=a()(0,t[0]*t[1]).map(()=>new Array),this._bounds=e}insert(e,t){if(!this._bounds.intersectsBox(e))throw new Error("Element to be added must be partially inside grid");if(this._removedElements.has(t))throw new Error("Re-adding previously taken elements is currently not supported");for(const r of this.cellsIntersecting(e))r.push({bounds:e,element:t})}*overlappingElements(e){if(!this._bounds.intersectsBox(e))return;const t=new Set;for(const r of this.cellsIntersecting(e))for(const n of r)t.has(n.element)||this._removedElements.has(n.element)||!e.intersectsBox(n.bounds)||(t.add(n.element),yield n.element)}*removeOverlappingElements(e){if(this._bounds.intersectsBox(e))for(const t of this.cellsIntersecting(e))for(let r=0;r<t.length;r++){const n=t[r];!this._removedElements.has(n.element)&&e.intersectsBox(n.bounds)&&(this._removedElements.add(n.element),yield n.element)}}*cellsIntersecting(e){const{min:t,max:r}=this._bounds,
|
|
189
|
+
class c{constructor(e,t){this._removedElements=new Set,this._dimensions=t,this._cells=a()(0,t[0]*t[1]).map(()=>new Array),this._bounds=e}insert(e,t){if(!this._bounds.intersectsBox(e))throw new Error("Element to be added must be partially inside grid");if(this._removedElements.has(t))throw new Error("Re-adding previously taken elements is currently not supported");for(const r of this.cellsIntersecting(e))r.push({bounds:e,element:t})}*overlappingElements(e){if(!this._bounds.intersectsBox(e))return;const t=new Set;for(const r of this.cellsIntersecting(e))for(const n of r)t.has(n.element)||this._removedElements.has(n.element)||!e.intersectsBox(n.bounds)||(t.add(n.element),yield n.element)}*removeOverlappingElements(e){if(this._bounds.intersectsBox(e))for(const t of this.cellsIntersecting(e))for(let r=0;r<t.length;r++){const n=t[r];!this._removedElements.has(n.element)&&e.intersectsBox(n.bounds)&&(this._removedElements.add(n.element),yield n.element)}}*cellsIntersecting(e){const{min:t,max:r}=this._bounds,i=this._dimensions[0],o=this._dimensions[1],s=(e.min.x-t.x)/(r.x-t.x),a=(e.max.x-t.x)/(r.x-t.x),c=(e.min.y-t.y)/(r.y-t.y),l=(e.max.y-t.y)/(r.y-t.y),d=n.MathUtils.clamp,h=d(Math.floor(i*s),0,i-1),u=d(Math.floor(i*a),0,i-1),m=d(Math.floor(o*c),0,o-1),p=d(Math.floor(o*l),0,o-1);for(let e=m;e<=p;++e)for(let t=h;t<=u;++t)yield this._cells[e*i+t]}}var l=r(8),d=r(14),h=r.n(d);
|
|
186
190
|
/*!
|
|
187
191
|
* Copyright 2021 Cognite AS
|
|
188
192
|
*/
|
|
189
|
-
class u extends
|
|
193
|
+
class u extends o{constructor(e,t){super(),this._htmlOverlays=new Map,this._compositeOverlays=[],this._preallocatedVariables={camPos:new n.Vector3,camNormal:new n.Vector3,point:new n.Vector3,nearPlane:new n.Plane,farPlane:new n.Plane,position2D:new n.Vector2},this._onSceneRenderedHandler=this.onSceneRendered.bind(this),this._onViewerDisposedHandler=this.onViewerDisposed.bind(this),this._options=null!=t?t:{},this._viewer=e,this._viewer.on("sceneRendered",this._onSceneRenderedHandler),this._viewer.on("disposed",this._onViewerDisposedHandler),this.scheduleUpdate=h()(()=>this.forceUpdate(),20),l.a.trackCreateTool("HtmlOverlayTool")}get viewerDomElement(){return this._viewer.domElement}get viewerCamera(){return this._viewer.getCamera()}get viewerRenderer(){return this._viewer.renderer}get elements(){return Array.from(this._htmlOverlays.entries()).map(([e,t])=>({element:e,position3D:t.position3D}))}dispose(){this._viewer.off("sceneRendered",this._onSceneRenderedHandler),this._viewer.off("disposed",this._onViewerDisposedHandler),this.clear(),super.dispose()}add(e,t,r={}){if(this.ensureNotDisposed(),this.viewerDomElement.contains(e))throw new Error("Element is already attached to viewer");e.style.visibility="hidden",this.viewerDomElement.appendChild(e);const i=getComputedStyle(e);if("absolute"!==i.position)throw this.viewerDomElement.removeChild(e),new Error(`htmlElement style must have a position of absolute. but was '${i.position}'`);const o={position3D:t,options:r,state:{position2D:new n.Vector2,width:-1,height:-1,visible:!0}};this._htmlOverlays.set(e,o),this.scheduleUpdate()}remove(e){if(this.ensureNotDisposed(),!this.viewerDomElement.contains(e)||!this._htmlOverlays.has(e))throw new Error("Element is not attached to viewer");this.viewerDomElement.removeChild(e),this._htmlOverlays.delete(e)}clear(){const e=Array.from(this._htmlOverlays.keys());for(const t of e)this.remove(t);this.forceUpdate()}forceUpdate(){if(this.ensureNotDisposed(),this.cleanupClusterElements(),0===this._htmlOverlays.size)return;this.updateNewElementSizes();const e=this.viewerCamera,t=this.viewerRenderer,{camPos:r,camNormal:n,point:o,nearPlane:s,farPlane:a,position2D:c}=this._preallocatedVariables;e.getWorldPosition(r),e.getWorldDirection(n),o.copy(r).addScaledVector(n,e.near),s.setFromNormalAndCoplanarPoint(n,o),o.copy(r).addScaledVector(n,e.far),a.setFromNormalAndCoplanarPoint(n,o),this._htmlOverlays.forEach((n,o)=>{const{position3D:l,options:{positionUpdatedCallback:d,userData:h},state:u}=n,m=s.distanceToPoint(l)>=0&&a.distanceToPoint(l)<=0,{x:p,y:f}=Object(i.d)(t,e,l);if(m?(u.position2D.set(p,f),u.visible=!0):u.visible=!1,d){c.set(p,f);const e=r.distanceTo(l);d(o,c,l,e,h)}}),this.clusterElements(),this.commitDOMChanges()}updateNewElementSizes(){this._htmlOverlays.forEach((e,t)=>{if(-1===e.state.width){const r=t.getBoundingClientRect();e.state.width=r.width,e.state.height=r.height}})}commitDOMChanges(){const e=this.viewerRenderer.domElement,t=e.offsetLeft,r=e.offsetTop;this._htmlOverlays.forEach((e,n)=>{const{state:i}=e;n.style.left=i.position2D.x+t+"px",n.style.top=i.position2D.y+r+"px",i.visible&&"visible"!==n.style.visibility?function(e){e.style.visibility="visible",e.style.opacity="1",e.style.transition="opacity 0.2s linear"}(n):i.visible||"hidden"===n.style.visibility||function(e){e.style.visibility="hidden",e.style.opacity="0",e.style.transition="visibility 0s 0.2s, opacity 0.2s linear"}(n)}),this._compositeOverlays.forEach(e=>{this.viewerDomElement.appendChild(e)})}clusterElements(){const e=this._options.clusteringOptions;if(void 0!==e)switch(e.mode){case"overlapInScreenSpace":this.clusterByOverlapInScreenSpace(e.createClusterElementCallback);break;default:Object(i.c)(e.mode,"Unsupported clustering mode: '"+e.mode)}}cleanupClusterElements(){this._compositeOverlays.forEach(e=>{this.viewerDomElement.removeChild(e)}),this._compositeOverlays.splice(0)}clusterByOverlapInScreenSpace(e){const t=this.viewerRenderer.domElement,r=(i=t.getBoundingClientRect(),(o=null!=o?o:new n.Box2).min.set(i.left,i.top),o.max.set(i.right,i.bottom),o);var i,o;const s=r.getSize(new n.Vector2);r.set(new n.Vector2(0,0),s);const a=new c(r,[10,10]);for(const[e,t]of this._htmlOverlays.entries()){const{state:n}=t,i=m(t);n.visible&&i.intersectsBox(r)&&a.insert(i,{htmlElement:e,...t})}const l=new n.Box2,d=new n.Vector2;for(const t of this._htmlOverlays.values()){const{state:n}=t;if(m(t,l),!n.visible||!l.intersectsBox(r))continue;const i=Array.from(a.removeOverlappingElements(l));if(i.length>1){const t=i.reduce((e,t)=>e.add(t.state.position2D),d.set(0,0)).divideScalar(i.length),r=e(i.map(e=>({htmlElement:e.htmlElement,userData:e.options.userData})));i.forEach(e=>e.state.visible=!1),this.addComposite(r,t)}}}addComposite(e,t){const r=this.viewerRenderer.domElement;e.style.visibility="visible",e.style.left=t.x+r.offsetLeft+"px",e.style.top=t.y+r.offsetTop+"px",this._compositeOverlays.push(e)}onSceneRendered(){this.forceUpdate()}onViewerDisposed(){this.dispose()}}function m(e,t){const{state:r}=e;return(t=null!=t?t:new n.Box2).min.set(r.position2D.x,r.position2D.y),t.max.set(r.position2D.x+r.width,r.position2D.y+r.height),t}
|
|
190
194
|
/*!
|
|
191
195
|
* Copyright 2021 Cognite AS
|
|
192
|
-
*/class p extends
|
|
196
|
+
*/class p extends o{constructor(e,t){super(),this._cadModel=t,this._rootTreeIndex=e,this.preloadBoundingBoxData(t,e),l.a.trackCreateTool("ExplodedViewTool")}get readyPromise(){return this._treeBoundingBoxdata.then()}async expand(e){const t=await this._treeBoundingBoxdata;await Promise.all(t.map(({treeIndex:t,direction:r,transform:n})=>0===e?(this._cadModel.resetNodeTransformByTreeIndex(t),Promise.resolve(0)):(n.setPosition(r.x*e,r.y*e,r.z*e),this._cadModel.setNodeTransformByTreeIndex(t,n))))}reset(){this._cadModel.resetNodeTransformByTreeIndex(this._rootTreeIndex,!0)}preloadBoundingBoxData(e,t){const r=e.getBoundingBoxByTreeIndex(t).then(e=>e.getCenter(new n.Vector3)),i=e.getSubtreeTreeIndices(t).then(e=>{if(e.count>1e3)throw new Error(`Subtree size of ${e.count} is too large (max size = 1000)`);return e}).then(t=>Promise.all(t.toArray().map(async t=>({subTreeIndex:t,subTreeIndexBoundingBoxCenter:(await e.getBoundingBoxByTreeIndex(t)).getCenter(new n.Vector3)}))));this._treeBoundingBoxdata=Promise.all([r,i]).then(e=>{const[t,r]=e;return r.map(({subTreeIndex:e,subTreeIndexBoundingBoxCenter:r})=>({treeIndex:e,direction:(new n.Vector3).subVectors(r,t),transform:new n.Matrix4}))}).then(async t=>(await Promise.all(t.map(t=>e.setNodeTransformByTreeIndex(t.treeIndex,t.transform))),t))}}
|
|
193
197
|
/*!
|
|
194
198
|
* Copyright 2021 Cognite AS
|
|
195
|
-
*/class f extends
|
|
199
|
+
*/class f extends o{constructor(e){super(),this._onViewerDisposedHandler=this.onViewerDisposed.bind(this),this._viewer=e,this._viewer.on("disposed",this._onViewerDisposedHandler)}get viewerCamera(){return this._viewer.getCamera()}dispose(){this._viewer.off("disposed",this._onViewerDisposedHandler),super.dispose()}showCameraHelper(){this.hideCameraHelper(),this._cameraHelper=new n.CameraHelper(this.viewerCamera.clone()),this._viewer.addObject3D(this._cameraHelper)}hideCameraHelper(){void 0!==this._cameraHelper&&(this._viewer.removeObject3D(this._cameraHelper),this._cameraHelper=void 0)}onViewerDisposed(){this.dispose()}}var g,v=r(15),w=r.n(v),x=r(32),_=r.n(x),b=r(11),y=r.n(b);!function(e){e[e.TopRight=0]="TopRight",e[e.TopLeft=1]="TopLeft",e[e.BottomLeft=2]="BottomLeft",e[e.BottomRight=3]="BottomRight"}(g||(g={}));const C={ringLabel:"N",labelDelta:Math.PI,fontSize:void 0,fontColor:new n.Color(16711680),tickColor:new n.Color(9737364)},M={label:"",fontSize:void 0,fontColor:new n.Color(3355443),outlineSize:void 0,outlineColor:new n.Color(3355443),faceColor:new n.Color(9737364)},B={size:128,position:{corner:g.BottomRight,padding:new n.Vector2},animationSpeed:200,faces:{xPositiveFace:{...M,label:"Right"},xNegativeFace:{...M,label:"Left"},yPositiveFace:{...M,label:"Up"},yNegativeFace:{...M,label:"Down"},zPositiveFace:{...M,label:"Front"},zNegativeFace:{...M,label:"Back"}},compass:C};
|
|
196
200
|
/*!
|
|
197
201
|
* Copyright 2021 Cognite AS
|
|
198
202
|
*/
|
|
199
|
-
class S extends
|
|
203
|
+
class S extends o{constructor(e,t){super(),this._dynamicUpdatePosition=()=>{},this._updateClickDiv=()=>{},this._screenPosition=new n.Vector2,this._boxFaceGeometry=new n.PlaneGeometry(.85,.85,1,1),this._raycastCamera=new n.OrthographicCamera(-1,1,1,-1,-1,1),this._raycaster=new n.Raycaster,this._viewer=e,this._layoutConfig=_()(w()(B),t),this._axisGroup=new n.Group,this._interactiveObjects=this.createAxisCross(this._axisGroup),[this._updateClickDiv,this._disposeClickDiv]=this.createClickDiv(e),this.addAxisBoxToViewer(this._axisGroup,this._layoutConfig.position),l.a.trackCreateTool("AxisViewTool")}dispose(){super.dispose(),this._viewer.removeUiObject(this._axisGroup),this._disposeClickDiv()}createClickDiv(e){if(null===e.domElement.querySelector("canvas"))throw new Error("Could not find canvas");const t=document.createElement("div");t.style.position="absolute",t.style.height=this._layoutConfig.size+"px",t.style.width=this._layoutConfig.size+"px",t.style.zIndex="1";let r=0,n=0;return t.addEventListener("mousedown",t=>{const i=new MouseEvent("mousedown",{clientX:t.clientX,clientY:t.clientY,button:t.button});r=t.clientX,n=t.clientY,e.renderer.domElement.dispatchEvent(i)}),t.addEventListener("mousemove",t=>{const r=new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY,button:t.button});e.renderer.domElement.dispatchEvent(r)}),t.addEventListener("contextmenu",e=>e.preventDefault()),t.addEventListener("mouseup",t=>{const i=new MouseEvent("mouseup",{clientX:t.clientX,clientY:t.clientY,button:t.button}),o=e.domElement.getBoundingClientRect(),s=t.clientX-o.left,a=t.clientY-o.top;Math.abs(r-t.clientX)+Math.abs(n-t.clientY)<=10&&!this.handleClick(s,a,o)&&e.renderer.domElement.dispatchEvent(i)}),e.domElement.appendChild(t),[()=>{t.style.left=this._screenPosition.x+"px",t.style.bottom=this._screenPosition.y+"px"},()=>{e.domElement.removeChild(t)}]}addAxisBoxToViewer(e,t){const r=this._layoutConfig.size;if(function(e){return void 0!==e.xAbsolute&&void 0!==e.yAbsolute}(t))this._screenPosition.x=t.xAbsolute,this._screenPosition.y=t.yAbsolute;else{switch(t.corner){case g.BottomRight:this._screenPosition.y=t.padding.y,this._dynamicUpdatePosition=()=>{this._screenPosition.x=this._viewer.renderer.domElement.clientWidth-t.padding.x-r};break;case g.TopRight:this._dynamicUpdatePosition=()=>{this._screenPosition.x=this._viewer.renderer.domElement.clientWidth-t.padding.x-r,this._screenPosition.y=this._viewer.renderer.domElement.clientHeight-t.padding.y-r};break;case g.TopLeft:this._screenPosition.x=t.padding.x,this._dynamicUpdatePosition=()=>{this._screenPosition.y=this._viewer.renderer.domElement.clientHeight-t.padding.y-r};break;case g.BottomLeft:this._screenPosition.x=t.padding.x,this._screenPosition.y=t.padding.y;break;default:throw new Error("Unknown corner position for Axis Cross: Corner = "+t.corner)}this._dynamicUpdatePosition()}this._viewer.addUiObject(e,this._screenPosition,new n.Vector2(r,r))}handleClick(e,t,r){const i=2*(e-this._screenPosition.x)/this._layoutConfig.size-1,o=2*(r.height-t-this._screenPosition.y)/this._layoutConfig.size-1;this._raycaster.setFromCamera({x:i,y:o},this._raycastCamera);const s=new n.Vector3(i,o,1),a=new n.Vector3(0,0,-1).normalize();this._raycaster.set(s,a);const c=this._raycaster.intersectObjects(this._interactiveObjects);if(!(c.length>0))return!1;const l=c[0].object.position.clone().normalize(),d=c[0].object.userData.upVector.clone();return this.moveCameraTo(this._viewer.getCamera(),this._viewer.cameraControls,l,d),!0}createAxisCross(e){const t=this.createBoxFaces();e.add(...t);const r=this.createCompass();return e.add(r),this.setupTransformOnRender(e),t}setupTransformOnRender(e){e.children[0].onBeforeRender=()=>{this._dynamicUpdatePosition(),e.quaternion.copy(this._viewer.getCamera().quaternion).invert(),e.updateMatrixWorld(),this._updateClickDiv()}}createBoxFaces(){const e=this._layoutConfig.faces;return[this.createBoxFace(new n.Vector3(1,0,0),e.xPositiveFace),this.createBoxFace(new n.Vector3(-1,0,0),e.xNegativeFace),this.createBoxFace(new n.Vector3(0,1,0),e.yPositiveFace,new n.Vector3(0,0,-1)),this.createBoxFace(new n.Vector3(0,-1,0),e.yNegativeFace,new n.Vector3(0,0,1)),this.createBoxFace(new n.Vector3(0,0,1),e.zPositiveFace),this.createBoxFace(new n.Vector3(0,0,-1),e.zNegativeFace)]}createCompass(){const e=new n.PlaneGeometry(2.1,2.1,1,1),t=new n.Mesh(e,new n.MeshBasicMaterial({map:this.createCompassTexture(),side:n.DoubleSide,transparent:!0})),r=Math.sin(this._layoutConfig.compass.labelDelta),i=Math.cos(this._layoutConfig.compass.labelDelta);return t.position.y=-.5,t.up.copy(new n.Vector3(r,0,i)),t.lookAt(0,0,0),t}createCompassTexture(){var e;const t=this._layoutConfig.compass,r=this._layoutConfig.size,i=document.createElement("canvas");i.width=r,i.height=r;const o=i.getContext("2d"),s=r/2,a=s-s/4,c=r/32,l=r/8;if(o.strokeStyle=t.tickColor.getStyle(),o.lineWidth=r/16,o.setLineDash([c,l]),o.beginPath(),o.arc(s,s,a,0,2*Math.PI),o.stroke(),t.ringLabel&&t.ringLabel.length>0){const n=null!==(e=t.fontSize)&&void 0!==e?e:r/5;o.font=`bold ${n}px Arial`,o.textAlign="center",o.fillStyle=t.fontColor.getStyle(),o.fillText(t.ringLabel,s,s*(1/4)+n/3)}return new n.CanvasTexture(i)}getFaceTexture(e,t){var r,i;const o=t/2,s=document.createElement("canvas");s.width=o,s.height=o;const a=s.getContext("2d");a.fillStyle=e.outlineColor.getStyle(),a.fillRect(0,0,o,o),a.fillStyle=e.faceColor.getStyle();const c=null!==(r=e.outlineSize)&&void 0!==r?r:o/32;if(a.fillRect(c,c,o-2*c,o-2*c),a.fill(),""!==e.label){const t=null!==(i=e.fontSize)&&void 0!==i?i:o/3;a.font=`bold ${t}px Arial`,a.textAlign="center",a.fillStyle=e.fontColor.getStyle(),a.fillText(e.label,o/2,o/2+t/3)}return new n.CanvasTexture(s)}createBoxFace(e,t,r=new n.Vector3(0,1,0)){const i=new n.Mesh(this._boxFaceGeometry,new n.MeshBasicMaterial({map:this.getFaceTexture(t,this._layoutConfig.size)}));return i.position.copy(e.multiplyScalar(.5*this._boxFaceGeometry.parameters.width)),i.lookAt(e.multiplyScalar(2)),i.userData.upVector=r,i}moveCameraTo(e,t,r,i){const o=e.position.clone(),s=t.getState().target,a=o.clone().sub(s),c=a.length(),l=a.clone().normalize(),d=Math.acos(l.dot(r)),h={t:0},u=new y.a.Tween(h),m=r.clone(),p=e.quaternion.clone(),f=(new n.Quaternion).setFromRotationMatrix((new n.Matrix4).makeBasis(i.clone().cross(m),i,m));if(p.angleTo(f)<1e-6)return;const g=new n.Vector3,v=new n.Quaternion;let w;u.to({t:1},this._layoutConfig.animationSpeed).onUpdate(()=>{g.copy(l).multiplyScalar(Math.sin((1-h.t)*d)/Math.sin(d)).add(r.clone().multiplyScalar(Math.sin(h.t*d)/Math.sin(d))),g.multiplyScalar(c),g.add(s),v.slerpQuaternions(p,f,h.t),e.position.copy(g),e.setRotationFromQuaternion(v)}).start(y.a.now()).onStart(()=>{w=t.enabled,t.enabled=!1}).onComplete(()=>{t.setState(e.position,s),t.enabled=w}).update(y.a.now())}}var k,E,I,P,D,N,T,A,F,R,O=r(17);
|
|
200
204
|
/*!
|
|
201
205
|
* Copyright 2021 Cognite AS
|
|
202
|
-
*/!function(e){e.BingMap="BingMap",e.HereMap="HereMap",e.MapboxMap="MapboxMap",e.OpenStreetMap="OpenStreetMap"}(
|
|
206
|
+
*/!function(e){e.BingMap="BingMap",e.HereMap="HereMap",e.MapboxMap="MapboxMap",e.OpenStreetMap="OpenStreetMap"}(k||(k={})),function(e){e[e.Style=100]="Style",e[e.Map_Id=101]="Map_Id"}(E||(E={})),function(e){e.Streets="mapbox/streets-v10",e.Outdoor="mapbox/outdoors-v10",e.Light="mapbox/light-v9",e.Dark="mapbox/dark-v9",e.Satellite="mapbox/satellite-v9",e.Satellite_Streets="mapbox/satellite-streets-v10",e.Navigation_Day="mapbox/navigation-preview-day-v4",e.Navigation_Night="mapbox/navigation-preview-night-v4",e.Navigation_Guide_Day="mapbox/navigation-guidance-day-v4",e.Navigation_Guide_Night="mapbox/navigation-guidance-night-v4"}(I||(I={})),function(e){e.Streets="mapbox.mapbox-streets-v7",e.Satellite="mapbox.satellite",e.Terrain="mapbox.mapbox-terrain-v2",e.Traffic="mapbox.mapbox-traffic-v1",e.TerrainRGB="mapbox.terrain-rgb"}(P||(P={})),function(e){e.PNG="png",e.PNG32="png32",e.PNG64="png64",e.PNG128="png128",e.PNG256="png256",e.JPG70="jpg70",e.JPG80="jpg80",e.JPG90="jpg90",e.PNGRAW="pngraw"}(D||(D={})),function(e){e.Aerial="a",e.Road="r",e.Aerial_Labels="h",e.Oblique="o",e.Oblique_Labels="b"}(N||(N={})),function(e){e.GIF="gif",e.JPEG="jpeg",e.PNG="png"}(T||(T={})),function(e){e.Aerial="aerial",e.Base="base",e.Pano="pano",e.Traffic="traffic"}(A||(A={})),function(e){e.Day="normal.day",e.Night="normal.night",e.Terrain="terrain.day",e.Satellite="satellite.day"}(F||(F={})),function(e){e.PNG="png",e.PNG8="png8",e.JPG="jpg"}(R||(R={}));
|
|
203
207
|
/*!
|
|
204
208
|
* Copyright 2021 Cognite AS
|
|
205
209
|
*/
|
|
206
|
-
class V{constructor(e,t){this._intervalId=0,this._onCameraChange=this.handleCameraChange.bind(this),this._viewer=e;const r=this.getMapProvider(t);this._map=new O.MapView(O.MapView.PLANAR,r,r),this._viewer.addObject3D(this._map);const n=O.UnitsUtils.datumsToSpherical(t.latlong.latitude,t.latlong.longitude),
|
|
210
|
+
class V{constructor(e,t){this._intervalId=0,this._onCameraChange=this.handleCameraChange.bind(this),this._viewer=e;const r=this.getMapProvider(t);this._map=new O.MapView(O.MapView.PLANAR,r,r),this._viewer.addObject3D(this._map);const n=O.UnitsUtils.datumsToSpherical(t.latlong.latitude,t.latlong.longitude),i=this._viewer.models[0].getModelBoundingBox();this._map.position.set(-n.x,i.min.y,n.y),this._map.updateMatrixWorld(!0),this.requestRedraw(1e4),this._viewer.on("cameraChange",this._onCameraChange)}requestRedraw(e){0==this._intervalId&&(this._intervalId=setInterval(()=>{this._viewer.requestRedraw()},100),setTimeout(()=>{clearInterval(this._intervalId),this._intervalId=0},e))}getMapProvider(e){let t;switch(e.provider){case k.BingMap:t=new O.BingMapsProvider(e.APIKey,e.type);break;case k.HereMap:t=new O.HereMapsProvider(e.APIKey,e.appCode,e.style,e.scheme,e.imageFormat,e.size);break;case k.MapboxMap:t=new O.MapBoxProvider(e.APIKey,e.id,e.mode,e.tileFormat);break;case k.OpenStreetMap:t=new O.OpenStreetMapsProvider;break;default:throw new Error("Unsupported map provider")}return t}latLongToWorldCoordinates(e){return O.UnitsUtils.datumsToSpherical(e.latitude,e.longitude)}handleCameraChange(){this.requestRedraw(1e3)}dispose(){this._viewer.removeObject3D(this._map),this._viewer.off("cameraChange",this._onCameraChange)}}
|
|
207
211
|
/*!
|
|
208
212
|
* Copyright 2021 Cognite AS
|
|
209
|
-
*/class z extends
|
|
213
|
+
*/class z extends o{constructor(e,t){super(),this._viewer=e,this._maps=new V(this._viewer,t),l.a.trackCreateTool("AxisViewTool")}latLongToWorldCoordinates(e){return this._maps.latLongToWorldCoordinates(e)}dispose(){super.dispose(),this._maps.dispose()}}
|
|
210
214
|
/*!
|
|
211
215
|
* Copyright 2021 Cognite AS
|
|
212
|
-
*/class
|
|
216
|
+
*/class L{constructor(e,t){this._nodeCollectionAndAppearance=[],this._model=e,this._date=t}getKeyframeDate(){return this._date}activate(){this._nodeCollectionAndAppearance.forEach((e,t)=>{this._model.assignStyledNodeCollection(e.nodes,e.nodeAppearance)})}deactivate(){this._nodeCollectionAndAppearance.forEach((e,t)=>{this._model.unassignStyledNodeCollection(e.nodes)})}assignStyledNodeCollection(e,t){l.a.trackCadModelStyled(e.classToken,t);if(-1!==this._nodeCollectionAndAppearance.findIndex(t=>t.nodes===e))throw new Error("Node collection as already been assigned, use updateStyledNodeCollection() to update the appearance");this._nodeCollectionAndAppearance.push({nodes:e,nodeAppearance:t})}unassignStyledNodeCollection(e){const t=this._nodeCollectionAndAppearance.findIndex(t=>t.nodes===e);if(-1===t)throw new Error("Node collection has not been assigned to model");this._nodeCollectionAndAppearance.splice(t,1)}}
|
|
213
217
|
/*!
|
|
214
218
|
* Copyright 2021 Cognite AS
|
|
215
|
-
*/class
|
|
219
|
+
*/class $ extends o{constructor(e){super(),this._playback=void 0,this._events={dateChanged:new i.b},this._model=e,this._keyframes=new Array}subscribe(e,t){switch(e){case"dateChanged":this._events.dateChanged.subscribe(t);break;default:Object(i.c)(e,`Unsupported event: '${e}'`)}}unsubscribe(e,t){switch(e){case"dateChanged":this._events.dateChanged.unsubscribe(t);break;default:Object(i.c)(e,`Unsupported event: '${e}'`)}}createKeyframe(e){const t=new L(this._model,e);return this._keyframes.push(t),this.sortKeyframesByDates(),t}getKeyframeByDate(e){return this._keyframes.find(t=>t.getKeyframeDate()===e)}removeKeyframe(e){const t=this._keyframes.findIndex(t=>t===e);t>-1&&this._keyframes.splice(t,1)}removeKeyframeByDate(e){const t=this._keyframes.findIndex(t=>t.getKeyframeDate()===e);t>-1&&this._keyframes.splice(t,1)}play(e,t,r){this.stop();const n={dateInMs:e.getTime()},i={dateInMs:t.getTime()},o=new y.a.Tween(n).to(i,r);let s=-1;o.onUpdate(()=>{const r=new Date(n.dateInMs),i=s;for(;s<this._keyframes.length-1&&this._keyframes[s+1].getKeyframeDate().getTime()<=r.getTime();)s++;s!==i&&(-1!==i&&this._keyframes[i].deactivate(),this._keyframes[s].activate()),this._events.dateChanged.fire({date:r,activeKeyframe:this._keyframes[s],startDate:e,endDate:t})}),this._playback=o,o.start()}stop(){void 0!==this._playback&&(this._playback.stop(),this._playback=void 0)}pause(){void 0!==this._playback&&this._playback.isPlaying()&&this._playback.pause()}resume(){void 0!==this._playback&&this._playback.isPaused()&&this._playback.resume()}getAllKeyframes(){return this._keyframes.slice()}dispose(){super.dispose(),this._events.dateChanged.unsubscribeAll()}sortKeyframesByDates(){this._keyframes.length>1&&this._keyframes.sort((e,t)=>e.getKeyframeDate().getTime()-t.getKeyframeDate().getTime())}}var j=r(2);
|
|
216
220
|
/*!
|
|
217
221
|
* Copyright 2021 Cognite AS
|
|
218
222
|
*/
|
|
219
223
|
/*!
|
|
220
224
|
* Copyright 2021 Cognite AS
|
|
221
|
-
*/class G extends
|
|
225
|
+
*/class G extends o{constructor(e,t={}){super(),this._boundingBoxes=new n.Group,this._viewer=e,this._viewer.addObject3D(this._boundingBoxes),this._options={},this.setOptions(t)}setOptions(e){this._options={showDetailedSectors:!0,showDiscardedSectors:!1,showSimpleSectors:!0,colorBy:"lod",leafsOnly:!1,sectorPathFilterRegex:".*",...e}}dispose(){this._viewer.removeObject3D(this._boundingBoxes)}showSectorBoundingBoxes(e){this._model=e,this.updateBoundingBoxes()}updateBoundingBoxes(){if(this._boundingBoxes.clear(),void 0===this._model)return;this._model.getModelTransformation(this._boundingBoxes.matrix);const e=[];e[j.d.Discarded]=this._options.showDiscardedSectors,e[j.d.Simple]=this._options.showSimpleSectors,e[j.d.Detailed]=this._options.showDetailedSectors;const t=[];this._model.cadNode.traverse(r=>{if(W(r)){const n=r;this.isSectorAcceptedByCurrentFilter(n)&&e[n.levelOfDetail]&&(!this._options.leafsOnly||function(e){return!e.children.some(e=>W(e))}
|
|
222
226
|
/*!
|
|
223
227
|
* Copyright 2021 Cognite AS
|
|
224
228
|
*/
|
|
225
229
|
/*!
|
|
226
230
|
* Copyright 2021 Cognite AS
|
|
227
|
-
*/(n))&&t.push(n)}}),t.forEach(e=>{const r=this.createBboxNodeFor(e,t);this._boundingBoxes.add(r)}),this._boundingBoxes.updateMatrixWorld(!0),this._viewer.requestRedraw()}isSectorAcceptedByCurrentFilter(e){return new RegExp(this._options.sectorPathFilterRegex).test(e.sectorPath)}createBboxNodeFor(e,t){const r=this._options;const
|
|
231
|
+
*/(n))&&t.push(n)}}),t.forEach(e=>{const r=this.createBboxNodeFor(e,t);this._boundingBoxes.add(r)}),this._boundingBoxes.updateMatrixWorld(!0),this._viewer.requestRedraw()}isSectorAcceptedByCurrentFilter(e){return new RegExp(this._options.sectorPathFilterRegex).test(e.sectorPath)}createBboxNodeFor(e,t){const r=this._options;const o=function(){switch(r.colorBy){case"depth":{const t=Math.min(1,e.depth/8);return new n.Color(U.green).lerpHSL(U.red,t)}case"lod":switch(e.levelOfDetail){case j.d.Simple:return U.yellow;case j.d.Detailed:return U.green;case j.d.Discarded:return U.red;default:Object(i.c)(e.levelOfDetail)}case"loadedTimestamp":{const r=[...t].sort((e,t)=>e.updatedTimestamp-t.updatedTimestamp),i=r.findIndex(t=>t===e),o=(r.length-1-i)/Math.max(r.length-1,1);return new n.Color(U.green).lerpHSL(U.red,o)}case"random":return(new n.Color).setHSL(Math.random(),1,.5);default:Object(i.c)(r.colorBy)}}();return new n.Box3Helper(e.bounds,o)}}const U={green:new n.Color("#00ff00"),yellow:new n.Color("yellow"),red:new n.Color("red")};function W(e){return e.name.match(/^Sector \d+$/)}}])}));
|
|
228
232
|
//# sourceMappingURL=tools.map
|