@mapxus/mapxus-visual-jp 1.8.1 → 1.9.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/bitbucket-pipelines.yml +50 -0
- package/config/rollup.js +33 -0
- package/config/rollup.serve.config.js +3 -0
- package/debug/circlemarker.html +444 -0
- package/debug/create_tags.html +474 -0
- package/debug/distance.html +220 -0
- package/debug/index.html +92 -0
- package/debug/integration.html +1084 -0
- package/debug/leaflet.html +54 -0
- package/debug/markers.html +115 -0
- package/debug/multi_monitor_sync.html +377 -0
- package/debug/outdoor.html +1026 -0
- package/debug/rect_tags.html +147 -0
- package/debug/rotate.html +236 -0
- package/debug/sample.html +324 -0
- package/debug/sequence.html +75 -0
- package/debug/tags.html +218 -0
- package/package.json +34 -10
- package/rollup.config.js +39 -0
- package/server.js +35 -0
- package/spec/api/APIv3.spec.ts +86 -0
- package/spec/component/Component.spec.ts +68 -0
- package/spec/component/StatsComponent.spec.ts +33 -0
- package/spec/component/direction/DirectionComponent.spec.ts +163 -0
- package/spec/component/direction/DirectionDOMRenderer.spec.ts +233 -0
- package/spec/component/keyboard/KeyZoomHandler.spec.ts +236 -0
- package/spec/component/marker/Marker.spec.ts +104 -0
- package/spec/component/marker/MarkerComponent.spec.ts +88 -0
- package/spec/component/marker/MarkerScene.spec.ts +223 -0
- package/spec/component/marker/MarkerSet.spec.ts +453 -0
- package/spec/component/mouse/DoubleClickZoomHandler.spec.ts +211 -0
- package/spec/component/popup/Popup.spec.ts +479 -0
- package/spec/component/popup/PopupComponent.spec.ts +414 -0
- package/spec/component/tag/CreateHandlerBase.spec.ts +83 -0
- package/spec/component/tag/CreatePointHandler.spec.ts +190 -0
- package/spec/component/tag/OutlineRenderTag.spec.ts +91 -0
- package/spec/component/tag/PointGeometry.spec.ts +131 -0
- package/spec/component/tag/PolygonGeometry.spec.ts +497 -0
- package/spec/component/tag/RectGeometry.spec.ts +1157 -0
- package/spec/component/tag/TagComponent.spec.ts +513 -0
- package/spec/component/tag/TagScene.spec.ts +346 -0
- package/spec/component/tag/TagSet.spec.ts +241 -0
- package/spec/component/utils/HandlerBase.spec.ts +203 -0
- package/spec/geo/Camera.spec.ts +250 -0
- package/spec/geo/GeoCoords.spec.ts +364 -0
- package/spec/geo/Spatial.spec.ts +711 -0
- package/spec/geo/Transform.spec.ts +850 -0
- package/spec/geo/ViewportCoords.spec.ts +534 -0
- package/spec/graph/FilterCreator.spec.ts +892 -0
- package/spec/graph/Graph.spec.ts +2078 -0
- package/spec/graph/GraphCalculator.spec.ts +263 -0
- package/spec/graph/GraphService.spec.ts +663 -0
- package/spec/graph/Node.spec.ts +373 -0
- package/spec/graph/NodeCache.spec.ts +206 -0
- package/spec/graph/Sequence.spec.ts +37 -0
- package/spec/graph/edge/EdgeCalculator.Pano.spec.ts +963 -0
- package/spec/graph/edge/EdgeCalculator.Sequence.spec.ts +108 -0
- package/spec/graph/edge/EdgeCalculator.Similar.spec.ts +272 -0
- package/spec/graph/edge/EdgeCalculator.Step.spec.ts +383 -0
- package/spec/graph/edge/EdgeCalculator.Turn.spec.ts +278 -0
- package/spec/graph/edge/EdgeCalculator.spec.ts +747 -0
- package/spec/helper/ContainerMockCreator.spec.ts +33 -0
- package/spec/helper/DOMRendererMockCreator.spec.ts +22 -0
- package/spec/helper/EdgeCalculatorHelper.spec.ts +96 -0
- package/spec/helper/EventHelper.spec.ts +92 -0
- package/spec/helper/GLRendererMockCreator.spec.ts +23 -0
- package/spec/helper/GeoHelper.spec.ts +16 -0
- package/spec/helper/ImageLoadingServiceMockCreator.spec.ts +24 -0
- package/spec/helper/KeyboardServiceMockCreator.spec.ts +21 -0
- package/spec/helper/LoadingServiceMockCreator.spec.ts +21 -0
- package/spec/helper/MockCreator.spec.ts +18 -0
- package/spec/helper/MockCreatorBase.spec.ts +17 -0
- package/spec/helper/MouseServiceMockCreator.spec.ts +38 -0
- package/spec/helper/NavigatorMockCreator.spec.ts +28 -0
- package/spec/helper/NodeHelper.spec.ts +77 -0
- package/spec/helper/NodeMockCreator.spec.ts +19 -0
- package/spec/helper/RenderServiceMockCreator.spec.ts +25 -0
- package/spec/helper/SpriteServiceMockCreator.spec.ts +22 -0
- package/spec/helper/StateServiceMockCreator.spec.ts +33 -0
- package/spec/helper/TouchServiceMockCreator.spec.ts +29 -0
- package/spec/helper/TransformHelper.spec.ts +17 -0
- package/spec/render/DOMRenderer.spec.ts +112 -0
- package/spec/render/GLRenderer.spec.ts +453 -0
- package/spec/render/RenderCamera.spec.ts +535 -0
- package/spec/render/RenderService.spec.ts +531 -0
- package/spec/state/StateBase.spec.ts +369 -0
- package/spec/state/StateService.spec.ts +9 -0
- package/spec/state/TraversingState.spec.ts +262 -0
- package/spec/state/WaitingState.spec.ts +319 -0
- package/spec/tiles/TextureProvider.spec.ts +653 -0
- package/spec/utils/EventEmitter.spec.ts +71 -0
- package/spec/utils/Support.spec.ts +54 -0
- package/spec/viewer/CacheService.spec.ts +160 -0
- package/spec/viewer/ComponentController.spec.ts +310 -0
- package/spec/viewer/LoadingService.spec.ts +19 -0
- package/spec/viewer/MouseService.spec.ts +1344 -0
- package/spec/viewer/Navigator.spec.ts +970 -0
- package/spec/viewer/Observer.spec.ts +96 -0
- package/spec/viewer/SpriteService.spec.ts +224 -0
- package/src/API.ts +3 -0
- package/src/Component.ts +77 -0
- package/src/Edge.ts +6 -0
- package/src/Error.ts +3 -0
- package/src/FilterRender.ts +27 -0
- package/src/Geo.ts +7 -0
- package/src/Graph.ts +19 -0
- package/src/MapxusVisual.ts +66 -0
- package/src/Render.ts +7 -0
- package/src/State.ts +8 -0
- package/src/Support.ts +35 -0
- package/src/Tiles.ts +5 -0
- package/src/Utils.ts +6 -0
- package/src/Viewer.ts +16 -0
- package/src/api/API.ts +396 -0
- package/src/api/Auth.ts +76 -0
- package/src/api/AuthStore.ts +11 -0
- package/src/api/GraphQLCreator.ts +100 -0
- package/src/api/interfaces/IAuth.ts +7 -0
- package/src/api/interfaces/IBuildingBase.ts +7 -0
- package/src/api/interfaces/IBuildingInfo.ts +19 -0
- package/src/api/interfaces/ICoreNode.ts +28 -0
- package/src/api/interfaces/IFillNode.ts +96 -0
- package/src/api/interfaces/IFloorInfo.ts +10 -0
- package/src/api/interfaces/IFullNode.ts +10 -0
- package/src/api/interfaces/IGPano.ts +38 -0
- package/src/api/interfaces/IImageTagInfo.ts +14 -0
- package/src/api/interfaces/IKey.ts +13 -0
- package/src/api/interfaces/ILatLon.ts +19 -0
- package/src/api/interfaces/IOutdoor.ts +14 -0
- package/src/api/interfaces/IPathNode.ts +37 -0
- package/src/api/interfaces/IProject.ts +8 -0
- package/src/api/interfaces/IQueryBuilding.ts +37 -0
- package/src/api/interfaces/IResponse.ts +7 -0
- package/src/api/interfaces/ISequence.ts +16 -0
- package/src/api/interfaces/IUser.ts +13 -0
- package/src/api/interfaces/interfaces.ts +17 -0
- package/src/component/AttributionComponent.ts +48 -0
- package/src/component/BackgroundComponent.ts +39 -0
- package/src/component/BearingComponent.ts +282 -0
- package/src/component/CacheComponent.ts +295 -0
- package/src/component/Component.ts +130 -0
- package/src/component/ComponentService.ts +150 -0
- package/src/component/CoverComponent.ts +132 -0
- package/src/component/DebugComponent.ts +157 -0
- package/src/component/ImageComponent.ts +96 -0
- package/src/component/LoadingComponent.ts +85 -0
- package/src/component/NavigationComponent.ts +233 -0
- package/src/component/RouteComponent.ts +354 -0
- package/src/component/StatsComponent.ts +100 -0
- package/src/component/direction/DirectionComponent.ts +254 -0
- package/src/component/direction/DirectionDOMCalculator.ts +243 -0
- package/src/component/direction/DirectionDOMRenderer.ts +631 -0
- package/src/component/imageplane/ImagePlaneComponent.ts +497 -0
- package/src/component/imageplane/ImagePlaneFactory.ts +314 -0
- package/src/component/imageplane/ImagePlaneGLRenderer.ts +247 -0
- package/src/component/imageplane/ImagePlaneScene.ts +87 -0
- package/src/component/imageplane/ImagePlaneShaders.ts +16 -0
- package/src/component/imageplane/SliderComponent.ts +697 -0
- package/src/component/imageplane/interfaces/IBBoxShaderMaterial.ts +10 -0
- package/src/component/imageplane/interfaces/IShaderMaterial.ts +9 -0
- package/src/component/imageplane/interfaces/interfaces.ts +2 -0
- package/src/component/imageplane/shaders/equirectangular.fragment.glsl.ts +26 -0
- package/src/component/imageplane/shaders/equirectangular.vertex.glsl.ts +15 -0
- package/src/component/imageplane/shaders/perspective.fragment.glsl.ts +27 -0
- package/src/component/imageplane/shaders/perspective.vertex.glsl.ts +15 -0
- package/src/component/interfaces/ICacheConfiguration.ts +72 -0
- package/src/component/interfaces/IComponentConfiguration.ts +5 -0
- package/src/component/interfaces/ICoverConfiguration.ts +15 -0
- package/src/component/interfaces/IDirectionConfiguration.ts +63 -0
- package/src/component/interfaces/IImagePlaneConfiguration.ts +17 -0
- package/src/component/interfaces/IKeyboardConfiguration.ts +44 -0
- package/src/component/interfaces/IMarkerConfiguration.ts +31 -0
- package/src/component/interfaces/IMouseConfiguration.ts +52 -0
- package/src/component/interfaces/INavigationConfiguration.ts +35 -0
- package/src/component/interfaces/IRouteConfiguration.ts +20 -0
- package/src/component/interfaces/ISequenceConfiguration.ts +72 -0
- package/src/component/interfaces/IShader.ts +6 -0
- package/src/component/interfaces/ISliderConfiguration.ts +61 -0
- package/src/component/interfaces/ITagConfiguration.ts +40 -0
- package/src/component/interfaces/interfaces.ts +17 -0
- package/src/component/keyboard/KeySequenceNavigationHandler.ts +86 -0
- package/src/component/keyboard/KeySpatialNavigationHandler.ts +216 -0
- package/src/component/keyboard/KeyZoomHandler.ts +106 -0
- package/src/component/keyboard/KeyboardComponent.ts +125 -0
- package/src/component/marker/Marker.ts +5 -0
- package/src/component/marker/MarkerComponent.ts +856 -0
- package/src/component/marker/MarkerScene.ts +145 -0
- package/src/component/marker/MarkerSet.ts +142 -0
- package/src/component/marker/interfaces/IArrowMarkerOptions.ts +41 -0
- package/src/component/marker/interfaces/ICircleMarkerOptions.ts +30 -0
- package/src/component/marker/interfaces/IDotMarkerOptions.ts +18 -0
- package/src/component/marker/interfaces/IMarkerEvent.ts +28 -0
- package/src/component/marker/interfaces/ISimpleMarkerOptions.ts +54 -0
- package/src/component/marker/interfaces/interfaces.ts +5 -0
- package/src/component/marker/marker/ArrowMarker.ts +84 -0
- package/src/component/marker/marker/CircleMarker.ts +82 -0
- package/src/component/marker/marker/DotMarker.ts +68 -0
- package/src/component/marker/marker/ImageMarker.ts +45 -0
- package/src/component/marker/marker/Marker.ts +99 -0
- package/src/component/marker/marker/SimpleMarker.ts +187 -0
- package/src/component/mouse/BounceHandler.ts +148 -0
- package/src/component/mouse/DoubleClickZoomHandler.ts +106 -0
- package/src/component/mouse/DragPanHandler.ts +489 -0
- package/src/component/mouse/HandlerTypes.ts +13 -0
- package/src/component/mouse/MouseComponent.ts +170 -0
- package/src/component/mouse/ScrollZoomHandler.ts +137 -0
- package/src/component/mouse/TouchZoomHandler.ts +136 -0
- package/src/component/path/PathComponent.ts +75 -0
- package/src/component/path/PathEvent.ts +245 -0
- package/src/component/path/PathMarker.ts +42 -0
- package/src/component/path/PathRender.ts +163 -0
- package/src/component/popup/Popup.ts +2 -0
- package/src/component/popup/PopupComponent.ts +244 -0
- package/src/component/popup/interfaces/IPopupOffset.ts +37 -0
- package/src/component/popup/interfaces/IPopupOptions.ts +81 -0
- package/src/component/popup/popup/Popup.ts +594 -0
- package/src/component/popup/popup/PopupAlignment.ts +3 -0
- package/src/component/sequence/SequenceComponent.ts +500 -0
- package/src/component/sequence/SequenceDOMInteraction.ts +23 -0
- package/src/component/sequence/SequenceDOMRenderer.ts +179 -0
- package/src/component/tag/Tag.ts +9 -0
- package/src/component/tag/TagComponent.ts +787 -0
- package/src/component/tag/TagCreator.ts +138 -0
- package/src/component/tag/TagDOMRenderer.ts +35 -0
- package/src/component/tag/TagMode.ts +37 -0
- package/src/component/tag/TagOperation.ts +7 -0
- package/src/component/tag/TagScene.ts +216 -0
- package/src/component/tag/TagSet.ts +186 -0
- package/src/component/tag/error/GeometryTagError.ts +11 -0
- package/src/component/tag/geometry/Geometry.ts +62 -0
- package/src/component/tag/geometry/PointGeometry.ts +89 -0
- package/src/component/tag/geometry/PolygonGeometry.ts +349 -0
- package/src/component/tag/geometry/RectGeometry.ts +759 -0
- package/src/component/tag/geometry/VertexGeometry.ts +185 -0
- package/src/component/tag/handlers/CreateHandlerBase.ts +81 -0
- package/src/component/tag/handlers/CreatePointHandler.ts +35 -0
- package/src/component/tag/handlers/CreatePolygonHandler.ts +33 -0
- package/src/component/tag/handlers/CreateRectDragHandler.ts +199 -0
- package/src/component/tag/handlers/CreateRectHandler.ts +57 -0
- package/src/component/tag/handlers/CreateVertexHandler.ts +165 -0
- package/src/component/tag/handlers/EditVertexHandler.ts +275 -0
- package/src/component/tag/handlers/TagHandlerBase.ts +57 -0
- package/src/component/tag/interfaces/IInteraction.ts +14 -0
- package/src/component/tag/interfaces/IOutlineCreateTagOptions.ts +15 -0
- package/src/component/tag/interfaces/IOutlineTagOptions.ts +89 -0
- package/src/component/tag/interfaces/ISpotTagOptions.ts +37 -0
- package/src/component/tag/interfaces/interfaces.ts +4 -0
- package/src/component/tag/tag/OutlineCreateTag.ts +330 -0
- package/src/component/tag/tag/OutlineRenderTag.ts +569 -0
- package/src/component/tag/tag/OutlineTag.ts +380 -0
- package/src/component/tag/tag/RenderTag.ts +50 -0
- package/src/component/tag/tag/SpotRenderTag.ts +160 -0
- package/src/component/tag/tag/SpotTag.ts +170 -0
- package/src/component/tag/tag/Tag.ts +103 -0
- package/src/component/utils/HandlerBase.ts +71 -0
- package/src/error/ArgumentBeeviewError.ts +11 -0
- package/src/error/BeeviewError.ts +9 -0
- package/src/error/GraphBeeviewError.ts +11 -0
- package/src/geo/Camera.ts +149 -0
- package/src/geo/GeoCoords.ts +280 -0
- package/src/geo/GeoRBush.ts +25 -0
- package/src/geo/Spatial.ts +259 -0
- package/src/geo/Transform.ts +543 -0
- package/src/geo/ViewportCoords.ts +518 -0
- package/src/geo/interfaces/ILatLonAlt.ts +7 -0
- package/src/geo/interfaces/interfaces.ts +1 -0
- package/src/graph/FilterCreator.ts +106 -0
- package/src/graph/FilterExpression.ts +16 -0
- package/src/graph/Graph.ts +1516 -0
- package/src/graph/GraphCalculator.ts +197 -0
- package/src/graph/GraphService.ts +516 -0
- package/src/graph/ImageLoadingService.ts +44 -0
- package/src/graph/MeshReader.ts +19 -0
- package/src/graph/Node.ts +622 -0
- package/src/graph/NodeCache.ts +548 -0
- package/src/graph/Sequence.ts +117 -0
- package/src/graph/edge/EdgeCalculator.ts +919 -0
- package/src/graph/edge/EdgeCalculatorCoefficients.ts +43 -0
- package/src/graph/edge/EdgeCalculatorDirections.ts +80 -0
- package/src/graph/edge/EdgeCalculatorSettings.ts +61 -0
- package/src/graph/edge/EdgeDirection.ts +63 -0
- package/src/graph/edge/interfaces/IEdge.ts +26 -0
- package/src/graph/edge/interfaces/IEdgeData.ts +22 -0
- package/src/graph/edge/interfaces/IPano.ts +8 -0
- package/src/graph/edge/interfaces/IPotentialEdge.ts +106 -0
- package/src/graph/edge/interfaces/IStep.ts +7 -0
- package/src/graph/edge/interfaces/ITurn.ts +7 -0
- package/src/graph/edge/interfaces/interfaces.ts +6 -0
- package/src/graph/interfaces/IEdgeStatus.ts +25 -0
- package/src/graph/interfaces/IGraphConfiguration.ts +26 -0
- package/src/graph/interfaces/ILoadStatus.ts +18 -0
- package/src/graph/interfaces/ILoadStatusObject.ts +8 -0
- package/src/graph/interfaces/IMesh.ts +20 -0
- package/src/graph/interfaces/interfaces.ts +5 -0
- package/src/render/DOMRenderer.ts +288 -0
- package/src/render/GLRenderStage.ts +6 -0
- package/src/render/GLRenderer.ts +436 -0
- package/src/render/RenderCamera.ts +212 -0
- package/src/render/RenderMode.ts +34 -0
- package/src/render/RenderService.ts +264 -0
- package/src/render/interfaces/IGLRender.ts +10 -0
- package/src/render/interfaces/IGLRenderFunction.ts +10 -0
- package/src/render/interfaces/IGLRenderHash.ts +8 -0
- package/src/render/interfaces/ISize.ts +6 -0
- package/src/render/interfaces/IVNodeHash.ts +8 -0
- package/src/render/interfaces/interfaces.ts +5 -0
- package/src/state/FrameGenerator.ts +36 -0
- package/src/state/State.ts +6 -0
- package/src/state/StateContext.ts +180 -0
- package/src/state/StateService.ts +600 -0
- package/src/state/StateTransitionMatrix.ts +58 -0
- package/src/state/interfaces/ICurrentState.ts +21 -0
- package/src/state/interfaces/IFrame.ts +9 -0
- package/src/state/interfaces/IRotation.ts +6 -0
- package/src/state/interfaces/IState.ts +11 -0
- package/src/state/interfaces/IStateContext.ts +31 -0
- package/src/state/interfaces/interfaces.ts +5 -0
- package/src/state/states/StateBase.ts +425 -0
- package/src/state/states/TraversingState.ts +861 -0
- package/src/state/states/WaitingState.ts +109 -0
- package/src/tiles/ImageTileLoader.ts +121 -0
- package/src/tiles/ImageTileStore.ts +70 -0
- package/src/tiles/RegionOfInterestCalculator.ts +158 -0
- package/src/tiles/TextureProvider.ts +609 -0
- package/src/tiles/interfaces/IBoundingBox.ts +28 -0
- package/src/tiles/interfaces/IRegionOfInterest.ts +25 -0
- package/src/tiles/interfaces/interfaces.ts +2 -0
- package/src/utils/DOM.ts +28 -0
- package/src/utils/EventEmitter.ts +61 -0
- package/src/utils/Func.ts +3 -0
- package/src/utils/Settings.ts +39 -0
- package/src/utils/Support.ts +70 -0
- package/src/utils/Urls.ts +43 -0
- package/src/viewer/Alignment.ts +53 -0
- package/src/viewer/CacheService.ts +75 -0
- package/src/viewer/ComponentController.ts +237 -0
- package/src/viewer/Container.ts +100 -0
- package/src/viewer/EventNames.ts +192 -0
- package/src/viewer/ImageSize.ts +28 -0
- package/src/viewer/KeyboardService.ts +15 -0
- package/src/viewer/LoadingService.ts +66 -0
- package/src/viewer/MouseService.ts +541 -0
- package/src/viewer/Navigator.ts +362 -0
- package/src/viewer/Observer.ts +441 -0
- package/src/viewer/Projection.ts +162 -0
- package/src/viewer/SpriteService.ts +281 -0
- package/src/viewer/TouchService.ts +336 -0
- package/src/viewer/Viewer.ts +1132 -0
- package/src/viewer/interfaces/IComponentOptions.ts +176 -0
- package/src/viewer/interfaces/IMouseClaim.ts +6 -0
- package/src/viewer/interfaces/IMouseDeferPixels.ts +6 -0
- package/src/viewer/interfaces/IPinch.ts +81 -0
- package/src/viewer/interfaces/ISpriteAtlas.ts +12 -0
- package/src/viewer/interfaces/IUnprojection.ts +9 -0
- package/src/viewer/interfaces/IViewerMouseEvent.ts +56 -0
- package/src/viewer/interfaces/IViewerOptions.ts +88 -0
- package/src/viewer/interfaces/PointOfView.ts +19 -0
- package/src/viewer/interfaces/interfaces.ts +9 -0
- package/styles/AttributionComponent.css +26 -0
- package/styles/BackgroundComponent.css +21 -0
- package/styles/BearingComponent.css +48 -0
- package/styles/CoverComponent.css +169 -0
- package/styles/DebugComponent.css +28 -0
- package/styles/DirectionComponent.css +154 -0
- package/styles/LoadingComponent.css +14 -0
- package/styles/NavigationComponent.css +64 -0
- package/styles/NorthBg.png +0 -0
- package/styles/PopupComponent.css +188 -0
- package/styles/RouteComponent.css +21 -0
- package/styles/SequenceComponent.css +120 -0
- package/styles/SliderComponent.css +82 -0
- package/styles/TagComponent.css +105 -0
- package/styles/cover-logo.png +0 -0
- package/styles/mapillary-js.css +29 -0
- package/styles/pano-indicator.svg +3 -0
- package/styles/pano.svg +20 -0
- package/styles/pointer-wheat.svg +3 -0
- package/styles/pointer-white.svg +3 -0
- package/styles/spinner.svg +1 -0
- package/styles/stepper-left.svg +1 -0
- package/styles/stepper-play.svg +1 -0
- package/styles/stepper-right.svg +1 -0
- package/styles/stepper-stop.svg +1 -0
- package/styles/turn-around.svg +3 -0
- package/styles/turn.svg +3 -0
- package/tsconfig.json +28 -0
- package/tslint.json +81 -0
- package/types/graphql/index.d.ts +28 -0
- package/types/graphql/language/ast/index.d.ts +7 -0
- package/types/images/index.d.ts +7 -0
- package/types/pbf/index.d.ts +16 -0
- package/types/rbush/index.d.ts +28 -0
- package/version/beeview-0.1.0.css +2 -0
- package/version/beeview-0.1.0.js +1 -0
- package/version/beeview-0.1.1.css +2 -0
- package/version/beeview-0.1.1.js +1 -0
- package/version/beeview-0.1.2.css +2 -0
- package/version/beeview-0.1.2.js +1 -0
- package/version/beeview-0.2.0.css +2 -0
- package/version/beeview-0.2.0.js +1 -0
- package/version/beeview-0.2.1.css +2 -0
- package/version/beeview-0.2.1.js +1 -0
- package/version/beeview-0.3.0.css +2 -0
- package/version/beeview-0.3.0.js +1 -0
- package/version/beeview-0.4.0.css +2 -0
- package/version/beeview-0.4.0.js +1 -0
- package/version/beeview-0.4.1.css +2 -0
- package/version/beeview-0.4.1.js +1 -0
- package/version/mapxus-visual-1.0.0.css +2 -0
- package/version/mapxus-visual-1.0.0.js +1 -0
- package/version/mapxus-visual-1.1.0.css +2 -0
- package/version/mapxus-visual-1.1.0.js +1 -0
- package/version/mapxus-visual-1.1.1.css +2 -0
- package/version/mapxus-visual-1.1.1.js +1 -0
- package/version/mapxus-visual-1.1.2.css +2 -0
- package/version/mapxus-visual-1.1.2.js +1 -0
- package/version/mapxus-visual-1.2.0.css +2 -0
- package/version/mapxus-visual-1.2.0.js +1 -0
- package/version/mapxus-visual-1.3.0.css +2 -0
- package/version/mapxus-visual-1.3.0.js +1 -0
- package/LICENSE +0 -11
- package/README.md +0 -28
- package/index.css +0 -2
- package/index.d.ts +0 -163
- package/index.js +0 -1
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { Observable, Subject, Subscription } from "rxjs";
|
|
3
|
+
import {
|
|
4
|
+
ImageTileLoader,
|
|
5
|
+
ImageTileStore,
|
|
6
|
+
IRegionOfInterest,
|
|
7
|
+
} from "../Tiles";
|
|
8
|
+
import { refCount, publishReplay, startWith } from "rxjs/operators";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @class TextureProvider
|
|
12
|
+
*
|
|
13
|
+
* @classdesc Represents a provider of textures.
|
|
14
|
+
*/
|
|
15
|
+
export class TextureProvider {
|
|
16
|
+
private _background: HTMLImageElement;
|
|
17
|
+
private _camera: THREE.OrthographicCamera;
|
|
18
|
+
private _imageTileLoader: ImageTileLoader;
|
|
19
|
+
private _imageTileStore: ImageTileStore;
|
|
20
|
+
private _renderer: THREE.WebGLRenderer;
|
|
21
|
+
private _renderTarget: THREE.WebGLRenderTarget;
|
|
22
|
+
private _roi: IRegionOfInterest;
|
|
23
|
+
|
|
24
|
+
private _abortFunctions: Function[];
|
|
25
|
+
private _tileSubscriptions: { [key: string]: Subscription };
|
|
26
|
+
|
|
27
|
+
private _created$: Observable<THREE.Texture>;
|
|
28
|
+
private _createdSubject$: Subject<THREE.Texture>;
|
|
29
|
+
private _createdSubscription: Subscription;
|
|
30
|
+
private _hasSubject$: Subject<boolean>;
|
|
31
|
+
private _has$: Observable<boolean>;
|
|
32
|
+
private _hasSubscription: Subscription;
|
|
33
|
+
private _updated$: Subject<boolean>;
|
|
34
|
+
|
|
35
|
+
private _disposed: boolean;
|
|
36
|
+
private _height: number;
|
|
37
|
+
private _key: string;
|
|
38
|
+
private _tileSize: number;
|
|
39
|
+
private _maxLevel: number;
|
|
40
|
+
private _currentLevel: number;
|
|
41
|
+
private _renderedCurrentLevelTiles: { [key: string]: boolean };
|
|
42
|
+
private _renderedTiles: { [level: string]: number[][] };
|
|
43
|
+
private _width: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Create a new node texture provider instance.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} key - The identifier of the image for which to request tiles.
|
|
49
|
+
* @param {number} width - The full width of the original image.
|
|
50
|
+
* @param {number} height - The full height of the original image.
|
|
51
|
+
* @param {number} tileSize - The size used when requesting tiles.
|
|
52
|
+
* @param {HTMLImageElement} background - Image to use as background.
|
|
53
|
+
* @param {ImageTileLoader} imageTileLoader - Loader for retrieving tiles.
|
|
54
|
+
* @param {ImageTileStore} imageTileStore - Store for saving tiles.
|
|
55
|
+
* @param {THREE.WebGLRenderer} renderer - Renderer used for rendering tiles to texture.
|
|
56
|
+
*/
|
|
57
|
+
constructor (
|
|
58
|
+
key: string,
|
|
59
|
+
width: number,
|
|
60
|
+
height: number,
|
|
61
|
+
tileSize: number,
|
|
62
|
+
background: HTMLImageElement,
|
|
63
|
+
imageTileLoader: ImageTileLoader,
|
|
64
|
+
imageTileStore: ImageTileStore,
|
|
65
|
+
renderer: THREE.WebGLRenderer) {
|
|
66
|
+
|
|
67
|
+
this._disposed = false;
|
|
68
|
+
|
|
69
|
+
this._key = key;
|
|
70
|
+
|
|
71
|
+
if (width <= 0 || height <= 0) {
|
|
72
|
+
console.warn(`Original image size (${width}, ${height}) is invalid (${key}). Tiles will not be loaded.`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this._width = width;
|
|
76
|
+
this._height = height;
|
|
77
|
+
this._maxLevel = Math.ceil(Math.log(Math.max(height, width)) / Math.log(2));
|
|
78
|
+
this._currentLevel = -1;
|
|
79
|
+
this._tileSize = tileSize;
|
|
80
|
+
|
|
81
|
+
this._updated$ = new Subject<boolean>();
|
|
82
|
+
this._createdSubject$ = new Subject<THREE.Texture>();
|
|
83
|
+
this._created$ = this._createdSubject$.pipe(
|
|
84
|
+
publishReplay(1),
|
|
85
|
+
refCount(),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
this._createdSubscription = this._created$.subscribe(() => { /*noop*/ });
|
|
89
|
+
|
|
90
|
+
this._hasSubject$ = new Subject<boolean>();
|
|
91
|
+
this._has$ = this._hasSubject$.pipe(
|
|
92
|
+
startWith(false),
|
|
93
|
+
publishReplay(1),
|
|
94
|
+
refCount(),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
this._hasSubscription = this._has$.subscribe(() => { /*noop*/ });
|
|
98
|
+
|
|
99
|
+
this._abortFunctions = [];
|
|
100
|
+
this._tileSubscriptions = {};
|
|
101
|
+
this._renderedCurrentLevelTiles = {};
|
|
102
|
+
this._renderedTiles = {};
|
|
103
|
+
|
|
104
|
+
this._background = background;
|
|
105
|
+
this._camera = null;
|
|
106
|
+
this._imageTileLoader = imageTileLoader;
|
|
107
|
+
this._imageTileStore = imageTileStore;
|
|
108
|
+
this._renderer = renderer;
|
|
109
|
+
this._renderTarget = null;
|
|
110
|
+
this._roi = null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Get disposed.
|
|
115
|
+
*
|
|
116
|
+
* @returns {boolean} Value indicating whether provider has
|
|
117
|
+
* been disposed.
|
|
118
|
+
*/
|
|
119
|
+
public get disposed(): boolean {
|
|
120
|
+
return this._disposed;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Get hasTexture$.
|
|
125
|
+
*
|
|
126
|
+
* @returns {Observable<boolean>} Observable emitting
|
|
127
|
+
* values indicating when the existance of a texture
|
|
128
|
+
* changes.
|
|
129
|
+
*/
|
|
130
|
+
public get hasTexture$(): Observable<boolean> {
|
|
131
|
+
return this._has$;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get key.
|
|
136
|
+
*
|
|
137
|
+
* @returns {boolean} The identifier of the image for
|
|
138
|
+
* which to render textures.
|
|
139
|
+
*/
|
|
140
|
+
public get key(): string {
|
|
141
|
+
return this._key;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Get textureUpdated$.
|
|
146
|
+
*
|
|
147
|
+
* @returns {Observable<boolean>} Observable emitting
|
|
148
|
+
* values when an existing texture has been updated.
|
|
149
|
+
*/
|
|
150
|
+
public get textureUpdated$(): Observable<boolean> {
|
|
151
|
+
return this._updated$;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Get textureCreated$.
|
|
156
|
+
*
|
|
157
|
+
* @returns {Observable<boolean>} Observable emitting
|
|
158
|
+
* values when a new texture has been created.
|
|
159
|
+
*/
|
|
160
|
+
public get textureCreated$(): Observable<THREE.Texture> {
|
|
161
|
+
return this._created$;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Abort all outstanding image tile requests.
|
|
166
|
+
*/
|
|
167
|
+
public abort(): void {
|
|
168
|
+
for (let key in this._tileSubscriptions) {
|
|
169
|
+
if (!this._tileSubscriptions.hasOwnProperty(key)) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
this._tileSubscriptions[key].unsubscribe();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
this._tileSubscriptions = {};
|
|
177
|
+
|
|
178
|
+
for (let abort of this._abortFunctions) {
|
|
179
|
+
abort();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
this._abortFunctions = [];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Dispose the provider.
|
|
187
|
+
*
|
|
188
|
+
* @description Disposes all cached assets and
|
|
189
|
+
* aborts all outstanding image tile requests.
|
|
190
|
+
*/
|
|
191
|
+
public dispose(): void {
|
|
192
|
+
if (this._disposed) {
|
|
193
|
+
console.warn(`Texture already disposed (${this._key})`);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
this.abort();
|
|
198
|
+
|
|
199
|
+
if (this._renderTarget != null) {
|
|
200
|
+
this._renderTarget.dispose();
|
|
201
|
+
this._renderTarget = null;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
this._imageTileStore.dispose();
|
|
205
|
+
this._imageTileStore = null;
|
|
206
|
+
|
|
207
|
+
this._background = null;
|
|
208
|
+
this._camera = null;
|
|
209
|
+
this._imageTileLoader = null;
|
|
210
|
+
this._renderer = null;
|
|
211
|
+
this._roi = null;
|
|
212
|
+
|
|
213
|
+
this._createdSubscription.unsubscribe();
|
|
214
|
+
this._hasSubscription.unsubscribe();
|
|
215
|
+
|
|
216
|
+
this._disposed = true;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Set the region of interest.
|
|
221
|
+
*
|
|
222
|
+
* @description When the region of interest is set the
|
|
223
|
+
* the tile level is determined and tiles for the region
|
|
224
|
+
* are fetched from the store or the loader and renderedLevel
|
|
225
|
+
* to the texture.
|
|
226
|
+
*
|
|
227
|
+
* @param {IRegionOfInterest} roi - Spatial edges to cache.
|
|
228
|
+
*/
|
|
229
|
+
public setRegionOfInterest(roi: IRegionOfInterest): void {
|
|
230
|
+
if (this._width <= 0 || this._height <= 0) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
this._roi = roi;
|
|
235
|
+
|
|
236
|
+
let width: number = 1 / this._roi.pixelWidth;
|
|
237
|
+
let height: number = 1 / this._roi.pixelHeight;
|
|
238
|
+
let size: number = Math.max(height, width);
|
|
239
|
+
|
|
240
|
+
let currentLevel: number = Math.max(0, Math.min(this._maxLevel, Math.ceil(Math.log(size) / Math.log(2))));
|
|
241
|
+
if (currentLevel !== this._currentLevel) {
|
|
242
|
+
this.abort();
|
|
243
|
+
|
|
244
|
+
this._currentLevel = currentLevel;
|
|
245
|
+
if (!(this._currentLevel in this._renderedTiles)) {
|
|
246
|
+
this._renderedTiles[this._currentLevel] = [];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
this._renderedCurrentLevelTiles = {};
|
|
250
|
+
for (let tile of this._renderedTiles[this._currentLevel]) {
|
|
251
|
+
this._renderedCurrentLevelTiles[this._tileKey(this._tileSize, tile)] = true;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
let topLeft: number[] = this._getTileCoords([this._roi.bbox.minX, this._roi.bbox.minY]);
|
|
256
|
+
let bottomRight: number[] = this._getTileCoords([this._roi.bbox.maxX, this._roi.bbox.maxY]);
|
|
257
|
+
|
|
258
|
+
let tiles: number[][] = this._getTiles(topLeft, bottomRight);
|
|
259
|
+
|
|
260
|
+
if (this._camera == null) {
|
|
261
|
+
this._camera = new THREE.OrthographicCamera(
|
|
262
|
+
-this._width / 2,
|
|
263
|
+
this._width / 2,
|
|
264
|
+
this._height / 2,
|
|
265
|
+
-this._height / 2,
|
|
266
|
+
-1,
|
|
267
|
+
1);
|
|
268
|
+
|
|
269
|
+
this._camera.position.z = 1;
|
|
270
|
+
|
|
271
|
+
let gl: WebGLRenderingContext = this._renderer.getContext();
|
|
272
|
+
let maxTextureSize: number = gl.getParameter(gl.MAX_TEXTURE_SIZE);
|
|
273
|
+
let backgroundSize: number = Math.max(this._width, this._height);
|
|
274
|
+
let scale: number = maxTextureSize > backgroundSize ? 1 : maxTextureSize / backgroundSize;
|
|
275
|
+
|
|
276
|
+
let targetWidth: number = Math.floor(scale * this._width);
|
|
277
|
+
let targetHeight: number = Math.floor(scale * this._height);
|
|
278
|
+
|
|
279
|
+
this._renderTarget = new THREE.WebGLRenderTarget(
|
|
280
|
+
targetWidth,
|
|
281
|
+
targetHeight,
|
|
282
|
+
{
|
|
283
|
+
depthBuffer: false,
|
|
284
|
+
format: THREE.RGBFormat,
|
|
285
|
+
magFilter: THREE.LinearFilter,
|
|
286
|
+
minFilter: THREE.LinearFilter,
|
|
287
|
+
stencilBuffer: false,
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
this._renderToTarget(0, 0, this._width, this._height, this._background);
|
|
291
|
+
|
|
292
|
+
this._createdSubject$.next((this._renderTarget).texture);
|
|
293
|
+
this._hasSubject$.next(true);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
this._fetchTiles(tiles);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
public setTileSize(tileSize: number): void {
|
|
300
|
+
this._tileSize = tileSize;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Update the image used as background for the texture.
|
|
305
|
+
*
|
|
306
|
+
* @param {HTMLImageElement} background - The background image.
|
|
307
|
+
*/
|
|
308
|
+
public updateBackground(background: HTMLImageElement): void {
|
|
309
|
+
this._background = background;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Retrieve an image tile.
|
|
314
|
+
*
|
|
315
|
+
* @description Retrieve an image tile and render it to the
|
|
316
|
+
* texture. Add the tile to the store and emit to the updated
|
|
317
|
+
* observable.
|
|
318
|
+
*
|
|
319
|
+
* @param {Array<number>} tile - The tile coordinates.
|
|
320
|
+
* @param {number} level - The tile level.
|
|
321
|
+
* @param {number} x - The top left x pixel coordinate of the tile.
|
|
322
|
+
* @param {number} y - The top left y pixel coordinate of the tile.
|
|
323
|
+
* @param {number} w - The pixel width of the tile.
|
|
324
|
+
* @param {number} h - The pixel height of the tile.
|
|
325
|
+
* @param {number} scaledW - The scaled width of the returned tile.
|
|
326
|
+
* @param {number} scaledH - The scaled height of the returned tile.
|
|
327
|
+
*/
|
|
328
|
+
private _fetchTile(
|
|
329
|
+
tile: number[],
|
|
330
|
+
level: number,
|
|
331
|
+
x: number,
|
|
332
|
+
y: number,
|
|
333
|
+
w: number,
|
|
334
|
+
h: number,
|
|
335
|
+
scaledX: number,
|
|
336
|
+
scaledY: number): void {
|
|
337
|
+
|
|
338
|
+
let getTile: [Observable<HTMLImageElement>, Function] =
|
|
339
|
+
this._imageTileLoader.getTile(this._key, x, y, w, h, scaledX, scaledY);
|
|
340
|
+
|
|
341
|
+
let tile$: Observable<HTMLImageElement> = getTile[0];
|
|
342
|
+
let abort: Function = getTile[1];
|
|
343
|
+
|
|
344
|
+
this._abortFunctions.push(abort);
|
|
345
|
+
|
|
346
|
+
let tileKey: string = this._tileKey(this._tileSize, tile);
|
|
347
|
+
|
|
348
|
+
let subscription: Subscription = tile$
|
|
349
|
+
.subscribe(
|
|
350
|
+
(image: HTMLImageElement): void => {
|
|
351
|
+
this._renderToTarget(x, y, w, h, image);
|
|
352
|
+
|
|
353
|
+
this._removeFromDictionary(tileKey, this._tileSubscriptions);
|
|
354
|
+
this._removeFromArray(abort, this._abortFunctions);
|
|
355
|
+
|
|
356
|
+
this._setTileRendered(tile, this._currentLevel);
|
|
357
|
+
|
|
358
|
+
this._imageTileStore.addImage(image, tileKey, level);
|
|
359
|
+
|
|
360
|
+
this._updated$.next(true);
|
|
361
|
+
},
|
|
362
|
+
(error: Error): void => {
|
|
363
|
+
this._removeFromDictionary(tileKey, this._tileSubscriptions);
|
|
364
|
+
this._removeFromArray(abort, this._abortFunctions);
|
|
365
|
+
|
|
366
|
+
console.error(error);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
if (!subscription.closed) {
|
|
370
|
+
this._tileSubscriptions[tileKey] = subscription;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Retrieve image tiles.
|
|
376
|
+
*
|
|
377
|
+
* @description Retrieve a image tiles and render them to the
|
|
378
|
+
* texture. Retrieve from store if it exists, otherwise Retrieve
|
|
379
|
+
* from loader.
|
|
380
|
+
*
|
|
381
|
+
* @param {Array<Array<number>>} tiles - Array of tile coordinates to
|
|
382
|
+
* retrieve.
|
|
383
|
+
*/
|
|
384
|
+
private _fetchTiles(tiles: number[][]): void {
|
|
385
|
+
let tileSize: number = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
|
|
386
|
+
|
|
387
|
+
for (let tile of tiles) {
|
|
388
|
+
let tileKey: string = this._tileKey(this._tileSize, tile);
|
|
389
|
+
if (tileKey in this._renderedCurrentLevelTiles ||
|
|
390
|
+
tileKey in this._tileSubscriptions) {
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
let tileX: number = tileSize * tile[0];
|
|
395
|
+
let tileY: number = tileSize * tile[1];
|
|
396
|
+
let tileWidth: number = tileX + tileSize > this._width ? this._width - tileX : tileSize;
|
|
397
|
+
let tileHeight: number = tileY + tileSize > this._height ? this._height - tileY : tileSize;
|
|
398
|
+
|
|
399
|
+
if (this._imageTileStore.hasImage(tileKey, this._currentLevel)) {
|
|
400
|
+
this._renderToTarget(tileX, tileY, tileWidth, tileHeight, this._imageTileStore.getImage(tileKey, this._currentLevel));
|
|
401
|
+
this._setTileRendered(tile, this._currentLevel);
|
|
402
|
+
|
|
403
|
+
this._updated$.next(true);
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
let scaledX: number = Math.floor(tileWidth / tileSize * this._tileSize);
|
|
408
|
+
let scaledY: number = Math.floor(tileHeight / tileSize * this._tileSize);
|
|
409
|
+
|
|
410
|
+
this._fetchTile(tile, this._currentLevel, tileX, tileY, tileWidth, tileHeight, scaledX, scaledY);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Get tile coordinates for a point using the current level.
|
|
416
|
+
*
|
|
417
|
+
* @param {Array<number>} point - Point in basic coordinates.
|
|
418
|
+
*
|
|
419
|
+
* @returns {Array<number>} x and y tile coodinates.
|
|
420
|
+
*/
|
|
421
|
+
private _getTileCoords(point: number[]): number[] {
|
|
422
|
+
let tileSize: number = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
|
|
423
|
+
|
|
424
|
+
let maxX: number = Math.ceil(this._width / tileSize) - 1;
|
|
425
|
+
let maxY: number = Math.ceil(this._height / tileSize) - 1;
|
|
426
|
+
|
|
427
|
+
return [
|
|
428
|
+
Math.min(Math.floor(this._width * point[0] / tileSize), maxX),
|
|
429
|
+
Math.min(Math.floor(this._height * point[1] / tileSize), maxY),
|
|
430
|
+
];
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Get tile coordinates for all tiles contained in a bounding
|
|
435
|
+
* box.
|
|
436
|
+
*
|
|
437
|
+
* @param {Array<number>} topLeft - Top left tile coordinate of bounding box.
|
|
438
|
+
* @param {Array<number>} bottomRight - Bottom right tile coordinate of bounding box.
|
|
439
|
+
*
|
|
440
|
+
* @returns {Array<Array<number>>} Array of x, y tile coodinates.
|
|
441
|
+
*/
|
|
442
|
+
private _getTiles(topLeft: number[], bottomRight: number[]): number[][] {
|
|
443
|
+
let xs: number[] = [];
|
|
444
|
+
|
|
445
|
+
if (topLeft[0] > bottomRight[0]) {
|
|
446
|
+
let tileSize: number = this._tileSize * Math.pow(2, this._maxLevel - this._currentLevel);
|
|
447
|
+
let maxX: number = Math.ceil(this._width / tileSize) - 1;
|
|
448
|
+
|
|
449
|
+
for (let x: number = topLeft[0]; x <= maxX; x++) {
|
|
450
|
+
xs.push(x);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
for (let x: number = 0; x <= bottomRight[0]; x++) {
|
|
454
|
+
xs.push(x);
|
|
455
|
+
}
|
|
456
|
+
} else {
|
|
457
|
+
for (let x: number = topLeft[0]; x <= bottomRight[0]; x++) {
|
|
458
|
+
xs.push(x);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
let tiles: number[][] = [];
|
|
463
|
+
|
|
464
|
+
for (let x of xs) {
|
|
465
|
+
for (let y: number = topLeft[1]; y <= bottomRight[1]; y++) {
|
|
466
|
+
tiles.push([x, y]);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return tiles;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Remove an item from an array if it exists in array.
|
|
475
|
+
*
|
|
476
|
+
* @param {T} item - Item to remove.
|
|
477
|
+
* @param {Array<T>} array - Array from which item should be removed.
|
|
478
|
+
*/
|
|
479
|
+
private _removeFromArray<T>(item: T, array: T[]): void {
|
|
480
|
+
let index: number = array.indexOf(item);
|
|
481
|
+
if (index !== -1) {
|
|
482
|
+
array.splice(index, 1);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Remove an item from a dictionary.
|
|
488
|
+
*
|
|
489
|
+
* @param {string} key - Key of the item to remove.
|
|
490
|
+
* @param {Object} dict - Dictionary from which item should be removed.
|
|
491
|
+
*/
|
|
492
|
+
private _removeFromDictionary<T>(key: string, dict: { [key: string]: T }): void {
|
|
493
|
+
if (key in dict) {
|
|
494
|
+
delete dict[key];
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Render an image tile to the target texture.
|
|
500
|
+
*
|
|
501
|
+
* @param {number} x - The top left x pixel coordinate of the tile.
|
|
502
|
+
* @param {number} y - The top left y pixel coordinate of the tile.
|
|
503
|
+
* @param {number} w - The pixel width of the tile.
|
|
504
|
+
* @param {number} h - The pixel height of the tile.
|
|
505
|
+
* @param {HTMLImageElement} background - The image tile to render.
|
|
506
|
+
*/
|
|
507
|
+
private _renderToTarget(x: number, y: number, w: number, h: number, image: HTMLImageElement): void {
|
|
508
|
+
let texture: THREE.Texture = new THREE.Texture(image);
|
|
509
|
+
texture.minFilter = THREE.LinearFilter;
|
|
510
|
+
texture.needsUpdate = true;
|
|
511
|
+
|
|
512
|
+
let geometry: THREE.PlaneGeometry = new THREE.PlaneGeometry(w, h);
|
|
513
|
+
let material: THREE.MeshBasicMaterial = new THREE.MeshBasicMaterial({ map: texture, side: THREE.FrontSide });
|
|
514
|
+
|
|
515
|
+
let mesh: THREE.Mesh = new THREE.Mesh(geometry, material);
|
|
516
|
+
mesh.position.x = -this._width / 2 + x + w / 2;
|
|
517
|
+
mesh.position.y = this._height / 2 - y - h / 2;
|
|
518
|
+
|
|
519
|
+
let scene: THREE.Scene = new THREE.Scene();
|
|
520
|
+
scene.add(mesh);
|
|
521
|
+
|
|
522
|
+
const target: THREE.RenderTarget = this._renderer.getRenderTarget();
|
|
523
|
+
|
|
524
|
+
this._renderer.setRenderTarget(this._renderTarget)
|
|
525
|
+
this._renderer.render(scene, this._camera);
|
|
526
|
+
this._renderer.setRenderTarget(target);
|
|
527
|
+
|
|
528
|
+
scene.remove(mesh);
|
|
529
|
+
|
|
530
|
+
geometry.dispose();
|
|
531
|
+
material.dispose();
|
|
532
|
+
texture.dispose();
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Mark a tile as rendered.
|
|
537
|
+
*
|
|
538
|
+
* @description Clears tiles marked as rendered in other
|
|
539
|
+
* levels of the tile pyramid if they were rendered on
|
|
540
|
+
* top of or below the tile.
|
|
541
|
+
*
|
|
542
|
+
* @param {Arrary<number>} tile - The tile coordinates.
|
|
543
|
+
* @param {number} level - Tile level of the tile coordinates.
|
|
544
|
+
*/
|
|
545
|
+
private _setTileRendered(tile: number[], level: number): void {
|
|
546
|
+
let otherLevels: number[] =
|
|
547
|
+
Object.keys(this._renderedTiles)
|
|
548
|
+
.map(
|
|
549
|
+
(key: string): number => {
|
|
550
|
+
return parseInt(key, 10);
|
|
551
|
+
})
|
|
552
|
+
.filter(
|
|
553
|
+
(renderedLevel: number): boolean => {
|
|
554
|
+
return renderedLevel !== level;
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
for (let otherLevel of otherLevels) {
|
|
558
|
+
let scale: number = Math.pow(2, otherLevel - level);
|
|
559
|
+
|
|
560
|
+
if (otherLevel < level) {
|
|
561
|
+
let x: number = Math.floor(scale * tile[0]);
|
|
562
|
+
let y: number = Math.floor(scale * tile[1]);
|
|
563
|
+
|
|
564
|
+
for (let otherTile of this._renderedTiles[otherLevel].slice()) {
|
|
565
|
+
if (otherTile[0] === x && otherTile[1] === y) {
|
|
566
|
+
let index: number = this._renderedTiles[otherLevel].indexOf(otherTile);
|
|
567
|
+
this._renderedTiles[otherLevel].splice(index, 1);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
} else {
|
|
571
|
+
let startX: number = scale * tile[0];
|
|
572
|
+
let endX: number = startX + scale - 1;
|
|
573
|
+
let startY: number = scale * tile[1];
|
|
574
|
+
let endY: number = startY + scale - 1;
|
|
575
|
+
|
|
576
|
+
for (let otherTile of this._renderedTiles[otherLevel].slice()) {
|
|
577
|
+
if (otherTile[0] >= startX && otherTile[0] <= endX &&
|
|
578
|
+
otherTile[1] >= startY && otherTile[1] <= endY) {
|
|
579
|
+
let index: number = this._renderedTiles[otherLevel].indexOf(otherTile);
|
|
580
|
+
this._renderedTiles[otherLevel].splice(index, 1);
|
|
581
|
+
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
if (this._renderedTiles[otherLevel].length === 0) {
|
|
587
|
+
delete this._renderedTiles[otherLevel];
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
this._renderedTiles[level].push(tile);
|
|
592
|
+
this._renderedCurrentLevelTiles[this._tileKey(this._tileSize, tile)] = true;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Create a tile key from a tile coordinates.
|
|
597
|
+
*
|
|
598
|
+
* @description Tile keys are used as a hash for
|
|
599
|
+
* storing the tile in a dictionary.
|
|
600
|
+
*
|
|
601
|
+
* @param {number} tileSize - The tile size.
|
|
602
|
+
* @param {Arrary<number>} tile - The tile coordinates.
|
|
603
|
+
*/
|
|
604
|
+
private _tileKey(tileSize: number, tile: number[]): string {
|
|
605
|
+
return tileSize + "-" + tile[0] + "-" + tile[1];
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
export default TextureProvider;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface that describes a bounding box.
|
|
3
|
+
*
|
|
4
|
+
* @interface IBoundingBox
|
|
5
|
+
*/
|
|
6
|
+
export interface IBoundingBox {
|
|
7
|
+
/**
|
|
8
|
+
* The minimum x value.
|
|
9
|
+
*/
|
|
10
|
+
minX: number;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The minimum y value.
|
|
14
|
+
*/
|
|
15
|
+
minY: number;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The maximum x value.
|
|
19
|
+
*/
|
|
20
|
+
maxX: number;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The maximum y value.
|
|
24
|
+
*/
|
|
25
|
+
maxY: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default IBoundingBox;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {IBoundingBox} from "../../Tiles";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Interface that describes a region of interest..
|
|
5
|
+
*
|
|
6
|
+
* @interface IRegionOfInterest
|
|
7
|
+
*/
|
|
8
|
+
export interface IRegionOfInterest {
|
|
9
|
+
/**
|
|
10
|
+
* The bounding box for the region of interest in basic coordinates.
|
|
11
|
+
*/
|
|
12
|
+
bbox: IBoundingBox;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Width of the footprint of a canvas pixel in basic coordinates.
|
|
16
|
+
*/
|
|
17
|
+
pixelWidth: number;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Height of the footprint of a canvas pixel in basic coordinates.
|
|
21
|
+
*/
|
|
22
|
+
pixelHeight: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default IRegionOfInterest;
|
package/src/utils/DOM.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class DOM {
|
|
2
|
+
private _document: HTMLDocument;
|
|
3
|
+
|
|
4
|
+
constructor(doc?: Node) {
|
|
5
|
+
this._document = !!doc ? <HTMLDocument>doc : document;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public get document(): HTMLDocument {
|
|
9
|
+
return this._document;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public createElement<K extends keyof HTMLElementTagNameMap>(
|
|
13
|
+
tagName: K, className?: string, container?: HTMLElement): HTMLElementTagNameMap[K] {
|
|
14
|
+
const element: HTMLElementTagNameMap[K] = this._document.createElement(tagName);
|
|
15
|
+
|
|
16
|
+
if (!!className) {
|
|
17
|
+
element.className = className;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!!container) {
|
|
21
|
+
container.appendChild(element);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return element;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default DOM;
|