@openglobus/og 0.17.1 → 0.18.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/README.md +75 -46
- package/dist/@openglobus/og.esm.js +1 -20
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +1 -20
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/dist/@openglobus/res/fonts/Karla-Bold.json +5252 -0
- package/dist/@openglobus/res/fonts/Karla-Bold.ttf.cfg +920 -0
- package/dist/@openglobus/res/fonts/Karla-Bold.ttf.png +0 -0
- package/dist/@openglobus/res/fonts/Karla-Light.json +5252 -0
- package/dist/@openglobus/res/fonts/Karla-Light.ttf.cfg +830 -0
- package/dist/@openglobus/res/fonts/Karla-Light.ttf.png +0 -0
- package/dist/@openglobus/res/fonts/Karla-Medium.json +5252 -0
- package/dist/@openglobus/res/fonts/Karla-Medium.ttf.cfg +1196 -0
- package/dist/@openglobus/res/fonts/Karla-Medium.ttf.png +0 -0
- package/dist/@openglobus/res/fonts/NotoSansArabic-Regular.json +3332 -0
- package/dist/@openglobus/res/fonts/NotoSansArabic-Regular.ttf.cfg +1370 -0
- package/dist/@openglobus/res/fonts/NotoSansArabic-Regular.ttf.png +0 -0
- package/dist/@openglobus/res/fonts/Roboto-Regular.json +37147 -0
- package/dist/@openglobus/res/fonts/Roboto-Regular.ttf.cfg +1340 -0
- package/dist/@openglobus/res/fonts/Roboto-Regular.ttf.png +0 -0
- package/dist/@openglobus/res/fonts/arial.json +4321 -0
- package/dist/@openglobus/res/fonts/arial.ttf.cfg +1570 -0
- package/dist/@openglobus/res/fonts/arial.ttf.png +0 -0
- package/dist/@openglobus/res/night-4326.png +0 -0
- package/dist/@openglobus/res/night.png +0 -0
- package/dist/@openglobus/res/spec.png +0 -0
- package/package.json +25 -23
- package/src/{og/Clock.js → Clock.ts} +100 -78
- package/src/Deferred.ts +17 -0
- package/src/Events.ts +200 -0
- package/src/{og/Extent.js → Extent.ts} +324 -352
- package/src/Globe.ts +363 -0
- package/src/{og/ImageCanvas.js → ImageCanvas.ts} +244 -236
- package/src/Lock.ts +41 -0
- package/src/{og/LonLat.js → LonLat.ts} +50 -47
- package/src/{og/Object3d.js → Object3d.ts} +89 -55
- package/src/Popup.ts +228 -0
- package/src/{og/QueueArray.js → QueueArray.ts} +76 -75
- package/src/{og/Rectangle.js → Rectangle.ts} +115 -111
- package/src/Stack.ts +58 -0
- package/src/{og/astro/astro.js → astro/astro.ts} +49 -51
- package/src/{og/astro/earth.js → astro/earth.ts} +8 -9
- package/src/{og/astro/jd.js → astro/jd.ts} +92 -111
- package/src/{og/astro/orbit.js → astro/orbit.ts} +35 -37
- package/src/{og/astro/rotation.js → astro/rotation.ts} +4 -6
- package/src/{og/bv/Box.js → bv/Box.ts} +21 -17
- package/src/{og/bv/Sphere.js → bv/Sphere.ts} +21 -19
- package/src/bv/index.ts +4 -0
- package/src/{og/camera/Camera.js → camera/Camera.ts} +254 -197
- package/src/{og/camera/Frustum.js → camera/Frustum.ts} +137 -111
- package/src/{og/camera/PlanetCamera.js → camera/PlanetCamera.ts} +248 -185
- package/src/camera/index.ts +4 -0
- package/src/{og/cons.js → cons.ts} +14 -18
- package/src/{og/control/Atmosphere.js → control/Atmosphere.ts} +50 -50
- package/src/{og/control/CompassButton.js → control/CompassButton.ts} +27 -30
- package/src/{og/control/Control.js → control/Control.ts} +76 -70
- package/src/{og/control/DebugInfo.js → control/DebugInfo.ts} +130 -62
- package/src/{og/control/DrawingSwitcher.js → control/DrawingSwitcher.ts} +16 -22
- package/src/control/EarthCoordinates.ts +222 -0
- package/src/control/EarthNavigation.ts +293 -0
- package/src/{og/control/GeoImageDragControl.js → control/GeoImageDragControl.ts} +37 -29
- package/src/control/KeyboardNavigation.ts +168 -0
- package/src/{og/control/LayerAnimation.js → control/LayerAnimation.ts} +74 -90
- package/src/control/LayerSwitcher.ts +76 -0
- package/src/{og/control/Lighting.js → control/Lighting.ts} +158 -120
- package/src/control/MouseNavigation.ts +468 -0
- package/src/control/MouseWheelZoomControl.ts +269 -0
- package/src/{og/control/RulerSwitcher.js → control/RulerSwitcher.ts} +18 -20
- package/src/control/ScaleControl.ts +131 -0
- package/src/control/SegmentBoundVisualization.ts +50 -0
- package/src/control/ShowFps.ts +28 -0
- package/src/control/SimpleNavigation.ts +118 -0
- package/src/{og/control/SimpleSkyBackground.js → control/SimpleSkyBackground.ts} +36 -38
- package/src/{og/control/Sun.js → control/Sun.ts} +56 -64
- package/src/control/ToggleWireframe.ts +35 -0
- package/src/control/TouchNavigation.ts +368 -0
- package/src/control/ZoomControl.ts +111 -0
- package/src/control/drawing/DrawingControl.ts +45 -0
- package/src/{og/control/drawing/LineStringDrawingScene.js → control/drawing/LineStringDrawingScene.ts} +28 -35
- package/src/{og/control/drawing/PolygonDrawingScene.js → control/drawing/PolygonDrawingScene.ts} +148 -201
- package/src/{og/control/elevationProfile/ElevationProfile.js → control/elevationProfile/ElevationProfile.ts} +70 -36
- package/src/control/heightRuler/HeightRuler.ts +16 -0
- package/src/{og/control/heightRuler/HeightRulerScene.js → control/heightRuler/HeightRulerScene.ts} +92 -87
- package/src/{og/control/heightRuler/HeightRulerSwitcher.js → control/heightRuler/HeightRulerSwitcher.ts} +3 -3
- package/src/control/index.ts +45 -0
- package/src/control/ruler/Ruler.ts +35 -0
- package/src/{og/control/ruler/RulerScene.js → control/ruler/RulerScene.ts} +163 -121
- package/src/{og/control/selection/Selection.js → control/selection/Selection.ts} +23 -21
- package/src/{og/control/selection/SelectionScene.js → control/selection/SelectionScene.ts} +64 -50
- package/src/{og/control/timeline/TimelineControl.js → control/timeline/TimelineControl.ts} +37 -28
- package/src/{og/control/timeline/TimelineModel.js → control/timeline/TimelineModel.ts} +50 -35
- package/src/{og/control/timeline/TimelineView.js → control/timeline/TimelineView.ts} +162 -113
- package/src/{og/control/timeline/timelineUtils.js → control/timeline/timelineUtils.ts} +11 -10
- package/src/{og/control → control}/visibleExtent/Segment.js +5 -5
- package/src/{og/control → control}/visibleExtent/VisibleExtent.js +8 -15
- package/src/{og/control/visibleExtent/drawnode.js → control/visibleExtent/drawnode.ts} +1 -3
- package/src/{og/ellipsoid/Ellipsoid.js → ellipsoid/Ellipsoid.ts} +113 -59
- package/src/ellipsoid/index.ts +4 -0
- package/src/{og/ellipsoid/wgs84.js → ellipsoid/wgs84.ts} +1 -3
- package/src/{og/entity/BaseBillboard.js → entity/BaseBillboard.ts} +128 -102
- package/src/entity/BaseBillboardHandler.ts +772 -0
- package/src/{og/entity/Billboard.js → entity/Billboard.ts} +77 -47
- package/src/entity/BillboardHandler.ts +135 -0
- package/src/{og/entity/Entity.js → entity/Entity.ts} +285 -226
- package/src/{og/entity/EntityCollection.js → entity/EntityCollection.ts} +340 -247
- package/src/{og/entity/GeoObject.js → entity/GeoObject.ts} +122 -67
- package/src/{og/entity/GeoObjectHandler.js → entity/GeoObjectHandler.ts} +273 -198
- package/src/entity/Geometry.ts +486 -0
- package/src/{og/entity/GeometryHandler.js → entity/GeometryHandler.ts} +383 -541
- package/src/{og/entity/Label.js → entity/Label.ts} +131 -83
- package/src/{og/entity/LabelHandler.js → entity/LabelHandler.ts} +289 -255
- package/src/{og/entity/LabelWorker.js → entity/LabelWorker.ts} +26 -36
- package/src/{og/entity/PointCloud.js → entity/PointCloud.ts} +200 -164
- package/src/entity/PointCloudHandler.ts +125 -0
- package/src/{og/entity/Polyline.js → entity/Polyline.ts} +517 -539
- package/src/{og/entity/PolylineHandler.js → entity/PolylineHandler.ts} +29 -31
- package/src/{og/entity/Ray.js → entity/Ray.ts} +89 -60
- package/src/{og/entity/RayHandler.js → entity/RayHandler.ts} +201 -306
- package/src/{og/entity/Strip.js → entity/Strip.ts} +143 -100
- package/src/{og/entity/StripHandler.js → entity/StripHandler.ts} +76 -72
- package/src/entity/index.ts +12 -0
- package/src/index.ts +173 -0
- package/src/input/KeyboardHandler.ts +196 -0
- package/src/{og/input/MouseHandler.js → input/MouseHandler.ts} +46 -35
- package/src/input/TouchHandler.ts +54 -0
- package/src/{og/input/input.js → input/input.ts} +1 -3
- package/src/{og/layer/BaseGeoImage.js → layer/BaseGeoImage.ts} +174 -107
- package/src/{og/layer/CanvasTiles.js → layer/CanvasTiles.ts} +139 -105
- package/src/{og/layer/GeoImage.js → layer/GeoImage.ts} +62 -52
- package/src/layer/GeoTexture2d.ts +56 -0
- package/src/{og/layer/GeoVideo.js → layer/GeoVideo.ts} +53 -53
- package/src/{og/layer/KML.js → layer/KML.ts} +63 -74
- package/src/{og/layer/Layer.js → layer/Layer.ts} +399 -223
- package/src/{og/layer/Material.js → layer/Material.ts} +40 -35
- package/src/{og/layer/Vector.js → layer/Vector.ts} +319 -267
- package/src/{og/layer/WMS.js → layer/WMS.ts} +76 -64
- package/src/{og/layer/XYZ.js → layer/XYZ.ts} +123 -98
- package/src/layer/index.ts +12 -0
- package/src/{og/light/LightSource.js → light/LightSource.ts} +132 -93
- package/src/{og/math/Line2.js → math/Line2.ts} +11 -8
- package/src/{og/math/Line3.js → math/Line3.ts} +49 -27
- package/src/{og/math/Mat3.js → math/Mat3.ts} +43 -27
- package/src/{og/math/Mat4.js → math/Mat4.ts} +110 -77
- package/src/{og/math/Plane.js → math/Plane.ts} +28 -23
- package/src/{og/math/Quat.js → math/Quat.ts} +238 -222
- package/src/{og/math/Ray.js → math/Ray.ts} +59 -63
- package/src/{og/math/Vec2.js → math/Vec2.ts} +85 -76
- package/src/{og/math/Vec3.js → math/Vec3.ts} +141 -140
- package/src/{og/math/Vec4.js → math/Vec4.ts} +64 -53
- package/src/{og/math/coder.js → math/coder.ts} +30 -27
- package/src/math/index.ts +26 -0
- package/src/{og/math.js → math.ts} +46 -49
- package/src/{og/mercator.js → mercator.ts} +143 -149
- package/src/{og/proj/EPSG3857.js → proj/EPSG3857.ts} +1 -3
- package/src/{og/proj/EPSG4326.js → proj/EPSG4326.ts} +11 -13
- package/src/{og/proj/Proj.js → proj/Proj.ts} +27 -23
- package/src/{og/quadTree/EPSG4326QuadTreeStrategy.js → quadTree/EPSG4326QuadTreeStrategy.ts} +10 -13
- package/src/{og/quadTree/EarthQuadTreeStrategy.js → quadTree/EarthQuadTreeStrategy.ts} +11 -13
- package/src/quadTree/EntityCollectionNode.ts +395 -0
- package/src/{og/quadTree/MarsQuadTreeStrategy.js → quadTree/MarsQuadTreeStrategy.ts} +10 -13
- package/src/{og/quadTree/Node.js → quadTree/Node.ts} +283 -191
- package/src/{og/quadTree/QuadTreeStrategy.js → quadTree/QuadTreeStrategy.ts} +35 -29
- package/src/quadTree/Wgs84QuadTreeStrategy.ts +22 -0
- package/src/quadTree/index.ts +14 -0
- package/src/{og/quadTree/quadTree.js → quadTree/quadTree.ts} +75 -77
- package/src/{og/renderer/Renderer.js → renderer/Renderer.ts} +454 -298
- package/src/{og/renderer/RendererEvents.js → renderer/RendererEvents.ts} +347 -270
- package/src/{og/scene/Axes.js → scene/Axes.ts} +26 -22
- package/src/{og/scene/BaseNode.js → scene/BaseNode.ts} +53 -47
- package/src/{og/scene/Planet.js → scene/Planet.ts} +777 -595
- package/src/{og/scene/RenderNode.js → scene/RenderNode.ts} +105 -91
- package/src/{og/scene/SkyBox.js → scene/SkyBox.ts} +29 -25
- package/src/scene/index.ts +6 -0
- package/src/{og/segment/Segment.js → segment/Segment.ts} +497 -371
- package/src/{og/segment/SegmentLonLat.js → segment/SegmentLonLat.ts} +81 -87
- package/src/{og/segment/SegmentLonLatWgs84.js → segment/SegmentLonLatWgs84.ts} +9 -16
- package/src/{og/segment/Slice.js → segment/Slice.ts} +15 -9
- package/src/{og/segment/segmentHelper.js → segment/segmentHelper.ts} +57 -49
- package/src/{og/shaders/atmos.js → shaders/atmos.ts} +4 -6
- package/src/{og/shaders/billboard.js → shaders/billboard.ts} +3 -5
- package/src/{og/shaders/bloom.js → shaders/bloom.ts} +2 -4
- package/src/{og/shaders/blur.js → shaders/blur.ts} +4 -7
- package/src/{og/shaders/depth.js → shaders/depth.ts} +1 -3
- package/src/{og/shaders/drawnode.js → shaders/drawnode.ts} +19 -21
- package/src/{og/shaders/geoObject.js → shaders/geoObject.ts} +17 -19
- package/src/{og/shaders/label.js → shaders/label.ts} +4 -6
- package/src/{og/shaders/lumFilter.js → shaders/lumFilter.ts} +2 -4
- package/src/{og/shaders/pickingMask.js → shaders/pickingMask.ts} +2 -4
- package/src/{og/shaders/pointCloud.js → shaders/pointCloud.ts} +7 -10
- package/src/{og/shaders/polyline.js → shaders/polyline.ts} +3 -200
- package/src/{og/shaders/ray.js → shaders/ray.ts} +2 -4
- package/src/{og/shaders/screenFrame.js → shaders/screenFrame.ts} +2 -4
- package/src/{og/shaders/skybox.js → shaders/skybox.ts} +7 -9
- package/src/{og/shaders/toneMapping.js → shaders/toneMapping.ts} +2 -4
- package/src/{og/shaders/utils.js → shaders/utils.ts} +0 -2
- package/src/{og/terrain/BilTerrain.js → terrain/BilTerrain.ts} +38 -32
- package/src/terrain/EmptyTerrain.ts +230 -0
- package/src/{og/terrain/Geoid.js → terrain/Geoid.ts} +67 -41
- package/src/{og/terrain/GlobusTerrain.js → terrain/GlobusTerrain.ts} +159 -153
- package/src/{og/terrain/MapboxTerrain.js → terrain/MapboxTerrain.ts} +58 -61
- package/src/terrain/index.ts +6 -0
- package/src/ui/Button.ts +121 -0
- package/src/ui/ButtonGroup.ts +63 -0
- package/src/ui/Dialog.ts +244 -0
- package/src/ui/Slider.ts +188 -0
- package/src/ui/ToggleButton.ts +68 -0
- package/src/{og/ui/View.js → ui/View.ts} +66 -59
- package/src/utils/BaseWorker.ts +60 -0
- package/src/utils/FontAtlas.ts +356 -0
- package/src/{og/utils/GeoImageCreator.js → utils/GeoImageCreator.ts} +45 -29
- package/src/{og/utils/ImagesCacheManager.js → utils/ImagesCacheManager.ts} +85 -70
- package/src/utils/Loader.ts +247 -0
- package/src/{og/utils/NormalMapCreator.js → utils/NormalMapCreator.ts} +114 -77
- package/src/{og/utils/PlainSegmentWorker.js → utils/PlainSegmentWorker.ts} +41 -24
- package/src/{og/utils/TerrainWorker.js → utils/TerrainWorker.ts} +51 -36
- package/src/utils/TextureAtlas.ts +322 -0
- package/src/{og/utils/VectorTileCreator.js → utils/VectorTileCreator.ts} +67 -52
- package/src/{og/utils/colorTable.js → utils/colorTable.ts} +142 -144
- package/src/{og/utils/earcut.js → utils/earcut.ts} +664 -661
- package/src/{og/utils/objParser.js → utils/objParser.ts} +66 -37
- package/src/{og/utils/shared.js → utils/shared.ts} +267 -206
- package/src/utils/units.ts +78 -0
- package/src/webgl/BaseFramebuffer.ts +125 -0
- package/src/webgl/Framebuffer.ts +206 -0
- package/src/webgl/Handler.ts +1414 -0
- package/src/webgl/Multisample.ts +153 -0
- package/src/webgl/Program.ts +451 -0
- package/src/{og/webgl/ProgramController.js → webgl/ProgramController.ts} +44 -43
- package/src/webgl/index.ts +13 -0
- package/src/{og/webgl/types.js → webgl/types.ts} +29 -31
- package/src/webgl/variableHandlers.ts +114 -0
- package/src/og/Deferred.js +0 -11
- package/src/og/Events.js +0 -185
- package/src/og/Globe.js +0 -342
- package/src/og/Lock.js +0 -44
- package/src/og/Popup.js +0 -187
- package/src/og/Stack.js +0 -49
- package/src/og/bv/index.js +0 -4
- package/src/og/camera/index.js +0 -4
- package/src/og/control/EarthCoordinates.js +0 -214
- package/src/og/control/EarthNavigation.js +0 -258
- package/src/og/control/KeyboardNavigation.js +0 -149
- package/src/og/control/LayerSwitcher.js +0 -424
- package/src/og/control/MouseNavigation.js +0 -436
- package/src/og/control/MouseWheelZoomControl.js +0 -253
- package/src/og/control/ScaleControl.js +0 -119
- package/src/og/control/SegmentBoundVisualization.js +0 -54
- package/src/og/control/ShowFps.js +0 -40
- package/src/og/control/SimpleNavigation.js +0 -123
- package/src/og/control/ToggleWireframe.js +0 -35
- package/src/og/control/TouchNavigation.js +0 -350
- package/src/og/control/ZoomControl.js +0 -115
- package/src/og/control/drawing/DrawingControl.js +0 -51
- package/src/og/control/heightRuler/HeightRuler.js +0 -12
- package/src/og/control/index.js +0 -56
- package/src/og/control/ruler/Ruler.js +0 -39
- package/src/og/ellipsoid/index.js +0 -4
- package/src/og/entity/BillboardHandler.js +0 -883
- package/src/og/entity/Geometry.js +0 -320
- package/src/og/entity/PointCloudHandler.js +0 -122
- package/src/og/entity/index.js +0 -9
- package/src/og/index.js +0 -112
- package/src/og/input/KeyboardHandler.js +0 -128
- package/src/og/input/TouchHandler.js +0 -59
- package/src/og/layer/GeoTexture2d.js +0 -50
- package/src/og/layer/index.js +0 -11
- package/src/og/math/index.js +0 -23
- package/src/og/quadTree/EntityCollectionNode.js +0 -391
- package/src/og/quadTree/Wgs84QuadTreeStrategy.js +0 -27
- package/src/og/quadTree/index.js +0 -14
- package/src/og/res/images.js +0 -8
- package/src/og/scene/index.js +0 -5
- package/src/og/terrain/EmptyTerrain.js +0 -174
- package/src/og/terrain/index.js +0 -6
- package/src/og/ui/Button.js +0 -107
- package/src/og/ui/ButtonGroup.js +0 -57
- package/src/og/ui/Dialog.js +0 -239
- package/src/og/ui/Slider.js +0 -170
- package/src/og/ui/ToggleButton.js +0 -51
- package/src/og/ui/UIhelpers.js +0 -155
- package/src/og/utils/BaseWorker.js +0 -46
- package/src/og/utils/FontAtlas.js +0 -218
- package/src/og/utils/Loader.js +0 -188
- package/src/og/utils/TextureAtlas.js +0 -291
- package/src/og/utils/functionComposition.js +0 -13
- package/src/og/utils/units.js +0 -78
- package/src/og/webgl/Framebuffer.js +0 -311
- package/src/og/webgl/Handler.js +0 -1168
- package/src/og/webgl/Multisample.js +0 -275
- package/src/og/webgl/Program.js +0 -407
- package/src/og/webgl/callbacks.js +0 -98
- package/src/og/webgl/index.js +0 -13
- package/src/og.jsdoc +0 -3
- package/types/Clock.d.ts +0 -99
- package/types/Deferred.d.ts +0 -6
- package/types/Events.d.ts +0 -78
- package/types/Extent.d.ts +0 -166
- package/types/Globe.d.ts +0 -108
- package/types/ImageCanvas.d.ts +0 -128
- package/types/Lock.d.ts +0 -12
- package/types/LonLat.d.ts +0 -127
- package/types/Object3d.d.ts +0 -35
- package/types/Popup.d.ts +0 -29
- package/types/QueueArray.d.ts +0 -19
- package/types/Rectangle.d.ts +0 -80
- package/types/Stack.d.ts +0 -19
- package/types/arial.d.ts +0 -49
- package/types/astro/astro.d.ts +0 -38
- package/types/astro/earth.d.ts +0 -7
- package/types/astro/jd.d.ts +0 -254
- package/types/bv/Box.d.ts +0 -30
- package/types/bv/Sphere.d.ts +0 -38
- package/types/bv/index.d.ts +0 -3
- package/types/camera/Camera.d.ts +0 -314
- package/types/camera/Frustum.d.ts +0 -133
- package/types/camera/PlanetCamera.d.ts +0 -219
- package/types/camera/index.d.ts +0 -3
- package/types/cons.d.ts +0 -40
- package/types/control/Atmosphere.d.ts +0 -15
- package/types/control/CompassButton.d.ts +0 -16
- package/types/control/Control.d.ts +0 -104
- package/types/control/DebugInfo.d.ts +0 -19
- package/types/control/DrawingSwitcher.d.ts +0 -13
- package/types/control/EarthCoordinates.d.ts +0 -44
- package/types/control/EarthNavigation.d.ts +0 -43
- package/types/control/GeoImageDragControl.d.ts +0 -14
- package/types/control/KeyboardNavigation.d.ts +0 -24
- package/types/control/LayerAnimation.d.ts +0 -73
- package/types/control/LayerSwitcher.d.ts +0 -64
- package/types/control/Lighting.d.ts +0 -41
- package/types/control/MouseNavigation.d.ts +0 -49
- package/types/control/MouseWheelZoomControl.d.ts +0 -46
- package/types/control/ScaleControl.d.ts +0 -23
- package/types/control/ShowFps.d.ts +0 -11
- package/types/control/SimpleNavigation.d.ts +0 -26
- package/types/control/SimpleSkyBackground.d.ts +0 -15
- package/types/control/Sun.d.ts +0 -53
- package/types/control/ToggleWireframe.d.ts +0 -12
- package/types/control/TouchNavigation.d.ts +0 -54
- package/types/control/ZoomControl.d.ts +0 -26
- package/types/control/drawing/DrawingControl.d.ts +0 -14
- package/types/control/drawing/LineStringDrawingScene.d.ts +0 -5
- package/types/control/drawing/PolygonDrawingScene.d.ts +0 -99
- package/types/control/heightRuler/HeightRuler.d.ts +0 -6
- package/types/control/heightRuler/HeightRulerScene.d.ts +0 -23
- package/types/control/index.d.ts +0 -27
- package/types/control/ruler/Ruler.d.ts +0 -13
- package/types/control/ruler/RulerScene.d.ts +0 -51
- package/types/control/selection/Selection.d.ts +0 -49
- package/types/control/selection/SelectionScene.d.ts +0 -32
- package/types/control/timeline/TimelineControl.d.ts +0 -10
- package/types/control/timeline/TimelineModel.d.ts +0 -33
- package/types/control/timeline/TimelineView.d.ts +0 -57
- package/types/control/timeline/timelineUtils.d.ts +0 -9
- package/types/ellipsoid/Ellipsoid.d.ts +0 -170
- package/types/ellipsoid/index.d.ts +0 -3
- package/types/ellipsoid/wgs84.d.ts +0 -6
- package/types/entity/BaseBillboard.d.ts +0 -215
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -75
- package/types/entity/Entity.d.ts +0 -340
- package/types/entity/EntityCollection.d.ts +0 -303
- package/types/entity/GeoObject.d.ts +0 -117
- package/types/entity/GeoObjectHandler.d.ts +0 -41
- package/types/entity/Geometry.d.ts +0 -79
- package/types/entity/GeometryHandler.d.ts +0 -76
- package/types/entity/Label.d.ts +0 -190
- package/types/entity/LabelHandler.d.ts +0 -31
- package/types/entity/LabelWorker.d.ts +0 -9
- package/types/entity/PointCloud.d.ts +0 -174
- package/types/entity/PointCloudHandler.d.ts +0 -38
- package/types/entity/Polyline.d.ts +0 -307
- package/types/entity/PolylineHandler.d.ts +0 -18
- package/types/entity/Ray.d.ts +0 -122
- package/types/entity/RayHandler.d.ts +0 -63
- package/types/entity/Strip.d.ts +0 -119
- package/types/entity/StripHandler.d.ts +0 -38
- package/types/entity/index.d.ts +0 -8
- package/types/index.d.ts +0 -53
- package/types/input/KeyboardHandler.d.ts +0 -10
- package/types/input/MouseHandler.d.ts +0 -5
- package/types/input/TouchHandler.d.ts +0 -5
- package/types/input/input.d.ts +0 -42
- package/types/layer/BaseGeoImage.d.ts +0 -116
- package/types/layer/CanvasTiles.d.ts +0 -73
- package/types/layer/GeoImage.d.ts +0 -51
- package/types/layer/GeoTexture2d.d.ts +0 -7
- package/types/layer/GeoVideo.d.ts +0 -47
- package/types/layer/KML.d.ts +0 -93
- package/types/layer/Layer.d.ts +0 -320
- package/types/layer/Material.d.ts +0 -45
- package/types/layer/Vector.d.ts +0 -211
- package/types/layer/WMS.d.ts +0 -66
- package/types/layer/XYZ.d.ts +0 -122
- package/types/layer/index.d.ts +0 -10
- package/types/light/LightSource.d.ts +0 -178
- package/types/math/Line2.d.ts +0 -11
- package/types/math/Line3.d.ts +0 -10
- package/types/math/Mat3.d.ts +0 -65
- package/types/math/Mat4.d.ts +0 -176
- package/types/math/Plane.d.ts +0 -18
- package/types/math/Quat.d.ts +0 -379
- package/types/math/Ray.d.ts +0 -82
- package/types/math/Vec2.d.ts +0 -309
- package/types/math/Vec3.d.ts +0 -472
- package/types/math/Vec4.d.ts +0 -161
- package/types/math/coder.d.ts +0 -43
- package/types/math/index.d.ts +0 -11
- package/types/math.d.ts +0 -268
- package/types/mercator.d.ts +0 -92
- package/types/proj/EPSG3857.d.ts +0 -6
- package/types/proj/EPSG4326.d.ts +0 -6
- package/types/proj/Proj.d.ts +0 -42
- package/types/quadTree/EPSG4326QuadTreeStrategy.d.ts +0 -3
- package/types/quadTree/EarthQuadTreeStrategy.d.ts +0 -3
- package/types/quadTree/EntityCollectionNode.d.ts +0 -41
- package/types/quadTree/MarsQuadTreeStrategy.d.ts +0 -3
- package/types/quadTree/Node.d.ts +0 -58
- package/types/quadTree/QuadTreeStrategy.d.ts +0 -21
- package/types/quadTree/Wgs84QuadTreeStrategy.d.ts +0 -3
- package/types/quadTree/index.d.ts +0 -12
- package/types/quadTree/quadTree.d.ts +0 -40
- package/types/renderer/Renderer.d.ts +0 -291
- package/types/renderer/RendererEvents.d.ts +0 -255
- package/types/res/images.d.ts +0 -2
- package/types/scene/Axes.d.ts +0 -10
- package/types/scene/BaseNode.d.ts +0 -60
- package/types/scene/Planet.d.ts +0 -595
- package/types/scene/RenderNode.d.ts +0 -152
- package/types/scene/SkyBox.d.ts +0 -9
- package/types/scene/index.d.ts +0 -4
- package/types/segment/Segment.d.ts +0 -273
- package/types/segment/SegmentLonLat.d.ts +0 -22
- package/types/segment/SegmentLonLatWgs84.d.ts +0 -4
- package/types/segment/Slice.d.ts +0 -10
- package/types/segment/segmentHelper.d.ts +0 -13
- package/types/shaders/atmos.d.ts +0 -4
- package/types/shaders/billboard.d.ts +0 -3
- package/types/shaders/depth.d.ts +0 -2
- package/types/shaders/drawnode.d.ts +0 -8
- package/types/shaders/geoObject.d.ts +0 -3
- package/types/shaders/label.d.ts +0 -4
- package/types/shaders/pickingMask.d.ts +0 -2
- package/types/shaders/pointCloud.d.ts +0 -2
- package/types/shaders/polyline.d.ts +0 -3
- package/types/shaders/ray.d.ts +0 -2
- package/types/shaders/screenFrame.d.ts +0 -2
- package/types/shaders/skybox.d.ts +0 -2
- package/types/shaders/toneMapping.d.ts +0 -2
- package/types/shaders/utils.d.ts +0 -1
- package/types/terrain/BilTerrain.d.ts +0 -14
- package/types/terrain/EmptyTerrain.d.ts +0 -87
- package/types/terrain/Geoid.d.ts +0 -17
- package/types/terrain/GlobusTerrain.d.ts +0 -122
- package/types/terrain/MapboxTerrain.d.ts +0 -14
- package/types/terrain/index.d.ts +0 -5
- package/types/ui/Button.d.ts +0 -21
- package/types/ui/ButtonGroup.d.ts +0 -12
- package/types/ui/Dialog.d.ts +0 -41
- package/types/ui/Slider.d.ts +0 -33
- package/types/ui/ToggleButton.d.ts +0 -10
- package/types/ui/UIhelpers.d.ts +0 -13
- package/types/ui/View.d.ts +0 -33
- package/types/ui/icons.d.ts +0 -1
- package/types/utils/BaseWorker.d.ts +0 -14
- package/types/utils/FontAtlas.d.ts +0 -16
- package/types/utils/GeoImageCreator.d.ts +0 -30
- package/types/utils/ImagesCacheManager.d.ts +0 -10
- package/types/utils/Loader.d.ts +0 -31
- package/types/utils/NormalMapCreator.d.ts +0 -39
- package/types/utils/PlainSegmentWorker.d.ts +0 -8
- package/types/utils/TerrainWorker.d.ts +0 -7
- package/types/utils/TextureAtlas.d.ts +0 -113
- package/types/utils/VectorTileCreator.d.ts +0 -14
- package/types/utils/colorTable.d.ts +0 -143
- package/types/utils/earcut.d.ts +0 -6
- package/types/utils/functionComposition.d.ts +0 -5
- package/types/utils/objParser.d.ts +0 -8
- package/types/utils/shared.d.ts +0 -241
- package/types/utils/units.d.ts +0 -20
- package/types/webgl/Framebuffer.d.ts +0 -134
- package/types/webgl/Handler.d.ts +0 -403
- package/types/webgl/Multisample.d.ts +0 -91
- package/types/webgl/Program.d.ts +0 -163
- package/types/webgl/ProgramController.d.ts +0 -89
- package/types/webgl/callbacks.d.ts +0 -1
- package/types/webgl/index.d.ts +0 -6
- package/types/webgl/types.d.ts +0 -2
- /package/{src/og → dist/@openglobus/res/fonts}/arial.js +0 -0
- /package/src/{og/ui/icons.js → ui/icons.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
1
|
+
import * as mercator from "./mercator";
|
|
2
|
+
import {NumberArray2} from "./math/Vec2";
|
|
3
|
+
import {NumberArray3} from "./math/Vec3";
|
|
4
4
|
|
|
5
5
|
const HALF_PI = Math.PI * 0.5;
|
|
6
6
|
const INV_PI_BY_180 = 180.0 / Math.PI;
|
|
@@ -17,34 +17,37 @@ const INV_PI_BY_180_HALF_PI = INV_PI_BY_180 * HALF_PI;
|
|
|
17
17
|
*/
|
|
18
18
|
export class LonLat {
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
22
|
-
* @
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Longitude.
|
|
27
|
-
* @public
|
|
28
|
-
* @type {number}
|
|
29
|
-
*/
|
|
30
|
-
this.lon = lon;
|
|
20
|
+
* Longitude.
|
|
21
|
+
* @public
|
|
22
|
+
* @type {number}
|
|
23
|
+
*/
|
|
24
|
+
public lon: number = 0;
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Latitude.
|
|
28
|
+
* @public
|
|
29
|
+
* @type {number}
|
|
30
|
+
*/
|
|
31
|
+
public lat: number = 0;
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Height.
|
|
35
|
+
* @public
|
|
36
|
+
* @type {number}
|
|
37
|
+
*/
|
|
38
|
+
public height: number = 0;
|
|
39
|
+
|
|
40
|
+
constructor(lon: number = 0, lat: number = 0, height: number = 0) {
|
|
41
|
+
this.lon = lon;
|
|
42
|
+
this.lat = lat;
|
|
44
43
|
this.height = height;
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Check zero coordinates
|
|
48
|
+
* @returns {boolean} -
|
|
49
|
+
*/
|
|
50
|
+
public isZero(): boolean {
|
|
48
51
|
return this.lon === 0.0 && this.lat === 0.0 && this.height === 0.0;
|
|
49
52
|
}
|
|
50
53
|
|
|
@@ -54,10 +57,10 @@ export class LonLat {
|
|
|
54
57
|
* @param{Array.<Array<number>>} arr - Coordinates array data. (exactly 3 entries)
|
|
55
58
|
* @return{Array.<LonLat>} the same coordinates array but each element is LonLat instance.
|
|
56
59
|
*/
|
|
57
|
-
static join(arr) {
|
|
58
|
-
|
|
60
|
+
static join(arr: NumberArray2[] | NumberArray3[]): LonLat[] {
|
|
61
|
+
let res = [];
|
|
59
62
|
for (let i = 0; i < arr.length; i++) {
|
|
60
|
-
|
|
63
|
+
let ai = arr[i];
|
|
61
64
|
res[i] = new LonLat(ai[0], ai[1], ai[2]);
|
|
62
65
|
}
|
|
63
66
|
return res;
|
|
@@ -66,28 +69,28 @@ export class LonLat {
|
|
|
66
69
|
/**
|
|
67
70
|
* Creates an object by coordinate array.
|
|
68
71
|
* @static
|
|
69
|
-
* @param {Array.<number>} arr -
|
|
72
|
+
* @param {Array.<number>} arr - Coordinates array, where first is longitude, second is latitude and third is a height. (exactly 3 entries)
|
|
70
73
|
* @returns {LonLat} -
|
|
71
74
|
*/
|
|
72
|
-
static createFromArray(arr) {
|
|
75
|
+
static createFromArray(arr: [number, number, number]): LonLat {
|
|
73
76
|
return new LonLat(arr[0], arr[1], arr[2]);
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
/**
|
|
77
|
-
*
|
|
80
|
+
* Create array from lonLat
|
|
78
81
|
* @param lonLat
|
|
79
82
|
* @returns {number[]}
|
|
80
83
|
*/
|
|
81
|
-
static toArray(lonLat) {
|
|
84
|
+
static toArray(lonLat: LonLat): [number, number, number] {
|
|
82
85
|
return [lonLat.lon, lonLat.lat, lonLat.height]
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
/**
|
|
86
|
-
*
|
|
89
|
+
* Create array from lonLat
|
|
87
90
|
* @returns {number[]}
|
|
88
91
|
*/
|
|
89
|
-
toArray() {
|
|
90
|
-
return LonLat.toArray(this)
|
|
92
|
+
public toArray(): [number, number, number] {
|
|
93
|
+
return LonLat.toArray(this);
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
/**
|
|
@@ -98,7 +101,7 @@ export class LonLat {
|
|
|
98
101
|
* @param {number} [height] - Height.
|
|
99
102
|
* @returns {LonLat} -
|
|
100
103
|
*/
|
|
101
|
-
static forwardMercator(lon, lat, height) {
|
|
104
|
+
static forwardMercator(lon: number, lat: number, height: number): LonLat {
|
|
102
105
|
return new LonLat(
|
|
103
106
|
lon * mercator.POLE_BY_180,
|
|
104
107
|
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI,
|
|
@@ -113,7 +116,7 @@ export class LonLat {
|
|
|
113
116
|
* @param {LonLat} res - Output mercator coordinates
|
|
114
117
|
* @returns {LonLat} - Output mercator coordinates
|
|
115
118
|
*/
|
|
116
|
-
static forwardMercatorRes(lonLat, res) {
|
|
119
|
+
static forwardMercatorRes(lonLat: LonLat, res: LonLat): LonLat {
|
|
117
120
|
res.lon = lonLat.lon * mercator.POLE_BY_180;
|
|
118
121
|
res.lat = Math.log(Math.tan((90.0 + lonLat.lat) * PI_BY_360)) * mercator.POLE_BY_PI,
|
|
119
122
|
res.height = lonLat.height;
|
|
@@ -128,7 +131,7 @@ export class LonLat {
|
|
|
128
131
|
* @param {number} [height] - Height.
|
|
129
132
|
* @returns {LonLat} -
|
|
130
133
|
*/
|
|
131
|
-
static inverseMercator(x, y, height = 0) {
|
|
134
|
+
static inverseMercator(x: number, y: number, height: number = 0): LonLat {
|
|
132
135
|
return new LonLat(
|
|
133
136
|
x * mercator.INV_POLE_BY_180,
|
|
134
137
|
INV_PI_BY_360 * Math.atan(Math.exp(y * mercator.PI_BY_POLE)) - INV_PI_BY_180_HALF_PI,
|
|
@@ -144,7 +147,7 @@ export class LonLat {
|
|
|
144
147
|
* @param {number} [height] - Height.
|
|
145
148
|
* @returns {LonLat} -
|
|
146
149
|
*/
|
|
147
|
-
set(lon = 0, lat = 0, height = 0) {
|
|
150
|
+
public set(lon: number = 0, lat: number = 0, height: number = 0): LonLat {
|
|
148
151
|
this.lon = lon;
|
|
149
152
|
this.lat = lat;
|
|
150
153
|
this.height = height;
|
|
@@ -157,7 +160,7 @@ export class LonLat {
|
|
|
157
160
|
* @param {LonLat} [lonLat] - Coordinates to copy.
|
|
158
161
|
* @returns {LonLat} -
|
|
159
162
|
*/
|
|
160
|
-
copy(lonLat) {
|
|
163
|
+
public copy(lonLat: LonLat): LonLat {
|
|
161
164
|
this.lon = lonLat.lon;
|
|
162
165
|
this.lat = lonLat.lat;
|
|
163
166
|
this.height = lonLat.height;
|
|
@@ -169,7 +172,7 @@ export class LonLat {
|
|
|
169
172
|
* @public
|
|
170
173
|
* @returns {LonLat} -
|
|
171
174
|
*/
|
|
172
|
-
clone() {
|
|
175
|
+
public clone(): LonLat {
|
|
173
176
|
return new LonLat(this.lon, this.lat, this.height);
|
|
174
177
|
}
|
|
175
178
|
|
|
@@ -178,12 +181,12 @@ export class LonLat {
|
|
|
178
181
|
* @public
|
|
179
182
|
* @returns {LonLat} -
|
|
180
183
|
*/
|
|
181
|
-
forwardMercator() {
|
|
184
|
+
public forwardMercator(): LonLat {
|
|
182
185
|
return LonLat.forwardMercator(this.lon, this.lat, this.height);
|
|
183
186
|
}
|
|
184
187
|
|
|
185
|
-
forwardMercatorEPS01() {
|
|
186
|
-
|
|
188
|
+
public forwardMercatorEPS01(): LonLat {
|
|
189
|
+
let lat = this.lat;
|
|
187
190
|
if (lat > 89.9) {
|
|
188
191
|
lat = 89.9;
|
|
189
192
|
} else if (lat < -89.9) {
|
|
@@ -200,7 +203,7 @@ export class LonLat {
|
|
|
200
203
|
* @public
|
|
201
204
|
* @returns {LonLat} -
|
|
202
205
|
*/
|
|
203
|
-
inverseMercator() {
|
|
206
|
+
public inverseMercator(): LonLat {
|
|
204
207
|
return LonLat.inverseMercator(this.lon, this.lat, this.height);
|
|
205
208
|
}
|
|
206
209
|
|
|
@@ -210,7 +213,7 @@ export class LonLat {
|
|
|
210
213
|
* @param {LonLat} b - Coordinate to compare with.
|
|
211
214
|
* @returns {boolean} -
|
|
212
215
|
*/
|
|
213
|
-
equal(b) {
|
|
216
|
+
public equal(b: LonLat): boolean {
|
|
214
217
|
if (b.height) {
|
|
215
218
|
return this.lon === b.lon && this.lat === b.lat && this.height === b.height;
|
|
216
219
|
} else {
|
|
@@ -1,22 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {htmlColorToFloat32Array, TypedArray} from './utils/shared';
|
|
2
|
+
import {NumberArray3, Vec3} from './math/Vec3';
|
|
3
|
+
import {MAX, MIN} from './math';
|
|
4
|
+
import {transformLeftToRightCoordinateSystem, objParser} from "./utils/objParser";
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
import { Vec3 } from './math/Vec3.js';
|
|
6
|
-
import { MAX, MIN } from './math.js';
|
|
7
|
-
import { transformLeftToRightCoordinateSystem, objParser } from "./utils/objParser.js";
|
|
8
|
-
|
|
9
|
-
function getColor(color) {
|
|
6
|
+
function getColor(color?: number[] | TypedArray | string): Float32Array {
|
|
10
7
|
if (color instanceof Array) {
|
|
11
|
-
return color;
|
|
8
|
+
return new Float32Array(color);
|
|
12
9
|
} else if (typeof color === 'string') {
|
|
13
10
|
return htmlColorToFloat32Array(color);
|
|
14
11
|
}
|
|
15
|
-
return [1.0, 1.0, 1.0, 1.0];
|
|
12
|
+
return new Float32Array([1.0, 1.0, 1.0, 1.0]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface IObject3dParams {
|
|
16
|
+
name?: string;
|
|
17
|
+
vertices?: number[];
|
|
18
|
+
texCoords?: number[];
|
|
19
|
+
indices?: number[];
|
|
20
|
+
normals?: number[];
|
|
21
|
+
center?: boolean;
|
|
22
|
+
src?: string;
|
|
23
|
+
color?: number[] | TypedArray | string;
|
|
24
|
+
scale?: number;
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
class Object3d {
|
|
19
|
-
|
|
28
|
+
|
|
29
|
+
protected _name: string;
|
|
30
|
+
protected _vertices: number[];
|
|
31
|
+
protected _numVertices: number;
|
|
32
|
+
protected _texCoords: number[];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Image src.
|
|
36
|
+
* @protected
|
|
37
|
+
* @type {string}
|
|
38
|
+
*/
|
|
39
|
+
protected _src: string | null;
|
|
40
|
+
|
|
41
|
+
protected color: Float32Array;
|
|
42
|
+
|
|
43
|
+
protected _indices: number[];
|
|
44
|
+
protected _normals: number[];
|
|
45
|
+
|
|
46
|
+
constructor(data: IObject3dParams = {}) {
|
|
20
47
|
|
|
21
48
|
this._name = data.name || "noname";
|
|
22
49
|
this._vertices = data.vertices || [];
|
|
@@ -41,7 +68,7 @@ class Object3d {
|
|
|
41
68
|
}
|
|
42
69
|
|
|
43
70
|
if (data.indices) {
|
|
44
|
-
this._indices = data.indices
|
|
71
|
+
this._indices = data.indices;
|
|
45
72
|
this._normals = data.normals || [];
|
|
46
73
|
} else {
|
|
47
74
|
this._normals = Object3d.getNormals(this._vertices);
|
|
@@ -52,7 +79,7 @@ class Object3d {
|
|
|
52
79
|
}
|
|
53
80
|
}
|
|
54
81
|
|
|
55
|
-
static centering(verts) {
|
|
82
|
+
static centering(verts: number[]) {
|
|
56
83
|
let min_x = MAX, min_y = MAX, min_z = MAX, max_x = MIN, max_y = MIN, max_z = MIN;
|
|
57
84
|
for (let i = 0, len = verts.length; i < len; i += 3) {
|
|
58
85
|
let x = verts[i], y = verts[i + 1], z = verts[i + 2];
|
|
@@ -75,45 +102,45 @@ class Object3d {
|
|
|
75
102
|
}
|
|
76
103
|
}
|
|
77
104
|
|
|
78
|
-
get src() {
|
|
105
|
+
public get src(): string | null {
|
|
79
106
|
return this._src;
|
|
80
107
|
}
|
|
81
108
|
|
|
82
|
-
set src(src) {
|
|
109
|
+
public set src(src: string | null) {
|
|
83
110
|
this._src = src;
|
|
84
111
|
}
|
|
85
112
|
|
|
86
|
-
get name() {
|
|
113
|
+
public get name(): string {
|
|
87
114
|
return this._name;
|
|
88
115
|
}
|
|
89
116
|
|
|
90
|
-
get vertices() {
|
|
117
|
+
public get vertices(): number[] {
|
|
91
118
|
return this._vertices;
|
|
92
119
|
}
|
|
93
120
|
|
|
94
|
-
get normals() {
|
|
121
|
+
public get normals(): number[] {
|
|
95
122
|
return this._normals;
|
|
96
123
|
}
|
|
97
124
|
|
|
98
|
-
get indices() {
|
|
125
|
+
public get indices(): number[] {
|
|
99
126
|
return this._indices;
|
|
100
127
|
}
|
|
101
128
|
|
|
102
|
-
get texCoords() {
|
|
129
|
+
public get texCoords(): number[] {
|
|
103
130
|
return this._texCoords;
|
|
104
131
|
}
|
|
105
132
|
|
|
106
|
-
get numVertices() {
|
|
133
|
+
public get numVertices(): number {
|
|
107
134
|
return this._numVertices;
|
|
108
135
|
}
|
|
109
136
|
|
|
110
|
-
static scale(vertices, s) {
|
|
137
|
+
static scale(vertices: number[], s: number) {
|
|
111
138
|
for (let i = 0; i < vertices.length; i++) {
|
|
112
139
|
vertices[i] *= s;
|
|
113
140
|
}
|
|
114
141
|
}
|
|
115
142
|
|
|
116
|
-
static centroid(vertices) {
|
|
143
|
+
static centroid(vertices: number[]) {
|
|
117
144
|
let minX = 1000.0, minY = 1000.0, minZ = 1000.0, maxX = -1000.0, maxY = -1000.0, maxZ = -1000.0;
|
|
118
145
|
|
|
119
146
|
for (let i = 0; i < vertices.length; i += 3) {
|
|
@@ -129,7 +156,7 @@ class Object3d {
|
|
|
129
156
|
return [minX + (maxX - minX) * 0.5, minY + (maxY - minY) * 0.5, minZ + (maxZ - minZ) * 0.5];
|
|
130
157
|
}
|
|
131
158
|
|
|
132
|
-
static translate(vertices, v) {
|
|
159
|
+
static translate(vertices: number[], v: NumberArray3) {
|
|
133
160
|
for (let i = 0; i < vertices.length; i += 3) {
|
|
134
161
|
vertices[i] -= v[0];
|
|
135
162
|
vertices[i + 1] -= v[1];
|
|
@@ -137,7 +164,7 @@ class Object3d {
|
|
|
137
164
|
}
|
|
138
165
|
}
|
|
139
166
|
|
|
140
|
-
static getNormals(vertices) {
|
|
167
|
+
static getNormals(vertices: number[]): number[] {
|
|
141
168
|
let res = new Array(vertices.length);
|
|
142
169
|
|
|
143
170
|
for (let i = 0; i < vertices.length; i += 9) {
|
|
@@ -171,22 +198,23 @@ class Object3d {
|
|
|
171
198
|
return res;
|
|
172
199
|
}
|
|
173
200
|
|
|
174
|
-
static createSphere(lonBands = 16, latBands = 16, radius = 1.0,
|
|
201
|
+
static createSphere(lonBands: number = 16, latBands: number = 16, radius: number = 1.0,
|
|
202
|
+
offsetX: number = 0, offsetY: number = 0, offsetZ: number = 0): Object3d {
|
|
175
203
|
|
|
176
204
|
let vertices = [], indices = [], normals = [];
|
|
177
205
|
|
|
178
206
|
for (let latNumber = 0; latNumber <= latBands; latNumber++) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
207
|
+
let theta = latNumber * Math.PI / latBands;
|
|
208
|
+
let sinTheta = Math.sin(theta);
|
|
209
|
+
let cosTheta = Math.cos(theta);
|
|
182
210
|
|
|
183
211
|
for (let longNumber = 0; longNumber <= lonBands; longNumber++) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
212
|
+
let phi = longNumber * 2 * Math.PI / lonBands;
|
|
213
|
+
let sinPhi = Math.sin(phi);
|
|
214
|
+
let cosPhi = Math.cos(phi);
|
|
215
|
+
let x = cosPhi * sinTheta + offsetX;
|
|
216
|
+
let y = cosTheta + offsetY;
|
|
217
|
+
let z = sinPhi * sinTheta + offsetZ;
|
|
190
218
|
//var u = 1 - (longNumber / lonBands);
|
|
191
219
|
//var v = latNumber / latBands;
|
|
192
220
|
normals.push(x);
|
|
@@ -202,8 +230,8 @@ class Object3d {
|
|
|
202
230
|
|
|
203
231
|
for (let latNumber = 0; latNumber < latBands; latNumber++) {
|
|
204
232
|
for (let longNumber = 0; longNumber < lonBands; longNumber++) {
|
|
205
|
-
|
|
206
|
-
|
|
233
|
+
let first = (latNumber * (lonBands + 1)) + longNumber;
|
|
234
|
+
let second = first + lonBands + 1;
|
|
207
235
|
|
|
208
236
|
indices.push(first);
|
|
209
237
|
indices.push(first + 1);
|
|
@@ -220,18 +248,21 @@ class Object3d {
|
|
|
220
248
|
});
|
|
221
249
|
}
|
|
222
250
|
|
|
223
|
-
static createDisc(radius = 1.0, height = 0.0,
|
|
251
|
+
static createDisc(radius: number = 1.0, height: number = 0.0,
|
|
252
|
+
radialSegments: number = 8, isTop: boolean = true, startIndex: number = 0,
|
|
253
|
+
offsetX: number = 0, offsetY: number = 0, offsetZ: number = 0
|
|
254
|
+
): Object3d {
|
|
224
255
|
|
|
225
256
|
let vertices = [], indices = [], normals = [];
|
|
226
257
|
|
|
227
258
|
let thetaStart = 0.0, thetaLength = Math.PI * 2;
|
|
228
259
|
|
|
229
|
-
let sign =
|
|
260
|
+
let sign = isTop ? 1.0 : -1.0;
|
|
230
261
|
|
|
231
262
|
let centerIndexStart = startIndex;
|
|
232
263
|
|
|
233
264
|
for (let x = 1; x <= radialSegments; x++) {
|
|
234
|
-
vertices.push(
|
|
265
|
+
vertices.push(offsetX, height * sign + offsetY, offsetZ);
|
|
235
266
|
normals.push(0, sign, 0);
|
|
236
267
|
//texCoords.push(0.5, 0.5);
|
|
237
268
|
startIndex++;
|
|
@@ -256,7 +287,7 @@ class Object3d {
|
|
|
256
287
|
|
|
257
288
|
for (let x = 0; x < radialSegments; x++) {
|
|
258
289
|
let c = centerIndexStart + x, i = centerIndexEnd + x;
|
|
259
|
-
if (isTop
|
|
290
|
+
if (isTop) {
|
|
260
291
|
indices.push(i, i + 1, c);
|
|
261
292
|
} else {
|
|
262
293
|
indices.push(i + 1, i, c);
|
|
@@ -268,9 +299,13 @@ class Object3d {
|
|
|
268
299
|
});
|
|
269
300
|
}
|
|
270
301
|
|
|
271
|
-
static createCylinder(radiusTop = 1.0, radiusBottom = 1.0, height
|
|
302
|
+
static createCylinder(radiusTop: number = 1.0, radiusBottom: number = 1.0, height: number = 1.0,
|
|
303
|
+
radialSegments: number = 32, heightSegments: number = 1.0, isTop: boolean = true,
|
|
304
|
+
isBottom: boolean = true, offsetX: number = 0, offsetY: number = 0, offsetZ: number = 0): Object3d {
|
|
272
305
|
|
|
273
|
-
let vertices
|
|
306
|
+
let vertices: number[] = [],
|
|
307
|
+
indices: number[] = [],
|
|
308
|
+
normals: number[] = [];
|
|
274
309
|
|
|
275
310
|
let thetaStart = 0.0, thetaLength = Math.PI * 2;
|
|
276
311
|
|
|
@@ -279,7 +314,7 @@ class Object3d {
|
|
|
279
314
|
|
|
280
315
|
let normal = new Vec3();
|
|
281
316
|
|
|
282
|
-
|
|
317
|
+
let slope = (radiusBottom - radiusTop) / height;
|
|
283
318
|
|
|
284
319
|
for (let y = 0; y <= heightSegments; y++) {
|
|
285
320
|
|
|
@@ -335,11 +370,14 @@ class Object3d {
|
|
|
335
370
|
}
|
|
336
371
|
|
|
337
372
|
return new Object3d({
|
|
338
|
-
|
|
373
|
+
vertices: vertices,
|
|
374
|
+
normals: normals,
|
|
375
|
+
indices: indices
|
|
339
376
|
});
|
|
340
377
|
}
|
|
341
378
|
|
|
342
|
-
static createCube(length = 1, height = 1, depth = 1,
|
|
379
|
+
static createCube(length: number = 1, height: number = 1, depth: number = 1,
|
|
380
|
+
xOffset: number = 0, yOffset: number = 0, zOffset: number = 0): Object3d {
|
|
343
381
|
let l = length * 0.5 + xOffset, h = height * 0.5 + yOffset, d = depth * 0.5 + zOffset;
|
|
344
382
|
|
|
345
383
|
return new Object3d({
|
|
@@ -363,28 +401,24 @@ class Object3d {
|
|
|
363
401
|
});
|
|
364
402
|
}
|
|
365
403
|
|
|
366
|
-
static createArrow(back = 0.0, height = 2.1, front = -15) {
|
|
404
|
+
static createArrow(back: number = 0.0, height: number = 2.1, front: number = -15): Object3d {
|
|
367
405
|
return new Object3d({
|
|
368
406
|
vertices: [0, height, 0, 7, 0, 6, 0, 0, front,
|
|
369
|
-
|
|
370
407
|
0, 0, back, 7, 0, 6, 0, height, 0,
|
|
371
|
-
|
|
372
408
|
-7, 0, 6, 0, 0, back, 0, height, 0,
|
|
373
|
-
|
|
374
409
|
-7, 0, 6, 0, height, 0, 0, 0, front,
|
|
375
|
-
|
|
376
410
|
-7, 0, 6, 0, 0, front, 0, 0, back, 0, 0, back, 0, 0, front, 7, 0, 6]
|
|
377
411
|
});
|
|
378
412
|
}
|
|
379
413
|
|
|
380
414
|
|
|
381
|
-
static async loadObj(src) {
|
|
382
|
-
const obj = await fetch(src, {
|
|
415
|
+
static async loadObj(src: string): Promise<Object3d[]> {
|
|
416
|
+
const obj: any = await fetch(src, {mode: "cors",})
|
|
383
417
|
.then((response) => response.text())
|
|
384
418
|
.then((data) => transformLeftToRightCoordinateSystem(objParser(data)))
|
|
385
419
|
.catch(() => []);
|
|
386
420
|
|
|
387
|
-
return obj.geometries.map(({
|
|
421
|
+
return obj.geometries.map(({data: {vertices, normals, textures}}: any) => new Object3d({
|
|
388
422
|
vertices,
|
|
389
423
|
normals,
|
|
390
424
|
texCoords: textures
|
|
@@ -392,4 +426,4 @@ class Object3d {
|
|
|
392
426
|
}
|
|
393
427
|
}
|
|
394
428
|
|
|
395
|
-
export {
|
|
429
|
+
export {Object3d};
|