@openglobus/og 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/lib/@openglobus/og.esm.js +2 -0
- package/lib/@openglobus/og.esm.js.map +1 -0
- package/lib/@openglobus/og.umd.js +2 -0
- package/lib/@openglobus/og.umd.js.map +1 -0
- package/lib/js/Clock.d.ts +106 -0
- package/{src/Clock.ts → lib/js/Clock.js} +31 -126
- package/lib/js/Deferred.d.ts +6 -0
- package/lib/js/Deferred.js +13 -0
- package/lib/js/Events.d.ts +90 -0
- package/{src/Events.ts → lib/js/Events.js} +29 -84
- package/lib/js/Extent.d.ts +145 -0
- package/{src/Extent.ts → lib/js/Extent.js} +74 -120
- package/lib/js/Globe.d.ts +132 -0
- package/{src/Globe.ts → lib/js/Globe.js} +61 -159
- package/lib/js/ImageCanvas.d.ts +128 -0
- package/{src/ImageCanvas.ts → lib/js/ImageCanvas.js} +24 -65
- package/lib/js/Lock.d.ts +15 -0
- package/{src/Lock.ts → lib/js/Lock.js} +7 -21
- package/lib/js/LonLat.d.ts +128 -0
- package/{src/LonLat.ts → lib/js/LonLat.js} +44 -75
- package/lib/js/Object3d.d.ts +49 -0
- package/{src/Object3d.ts → lib/js/Object3d.js} +64 -184
- package/lib/js/Popup.d.ts +46 -0
- package/{src/Popup.ts → lib/js/Popup.js} +42 -110
- package/lib/js/QueueArray.d.ts +16 -0
- package/{src/QueueArray.ts → lib/js/QueueArray.js} +12 -25
- package/lib/js/Rectangle.d.ts +76 -0
- package/{src/Rectangle.ts → lib/js/Rectangle.js} +12 -50
- package/lib/js/Stack.d.ts +20 -0
- package/{src/Stack.ts → lib/js/Stack.js} +13 -29
- package/lib/js/astro/astro.d.ts +39 -0
- package/{src/astro/astro.ts → lib/js/astro/astro.js} +2 -8
- package/lib/js/astro/earth.d.ts +8 -0
- package/{src/astro/earth.ts → lib/js/astro/earth.js} +3 -39
- package/lib/js/astro/jd.d.ts +234 -0
- package/{src/astro/jd.ts → lib/js/astro/jd.js} +55 -134
- package/lib/js/astro/orbit.d.ts +5 -0
- package/{src/astro/orbit.ts → lib/js/astro/orbit.js} +26 -39
- package/lib/js/astro/rotation.d.ts +2 -0
- package/{src/astro/rotation.ts → lib/js/astro/rotation.js} +2 -11
- package/lib/js/bv/Box.d.ts +32 -0
- package/{src/bv/Box.ts → lib/js/bv/Box.js} +7 -35
- package/lib/js/bv/Sphere.d.ts +37 -0
- package/{src/bv/Sphere.ts → lib/js/bv/Sphere.js} +6 -34
- package/{src/bv/index.ts → lib/js/bv/index.d.ts} +0 -1
- package/lib/js/bv/index.js +3 -0
- package/lib/js/camera/Camera.d.ts +314 -0
- package/{src/camera/Camera.ts → lib/js/camera/Camera.js} +77 -326
- package/lib/js/camera/Frustum.d.ts +139 -0
- package/{src/camera/Frustum.ts → lib/js/camera/Frustum.js} +66 -185
- package/lib/js/camera/PlanetCamera.d.ts +234 -0
- package/{src/camera/PlanetCamera.ts → lib/js/camera/PlanetCamera.js} +65 -338
- package/{src/camera/index.ts → lib/js/camera/index.d.ts} +0 -1
- package/lib/js/camera/index.js +3 -0
- package/lib/js/cons.d.ts +40 -0
- package/{src/cons.ts → lib/js/cons.js} +10 -22
- package/lib/js/control/Atmosphere.d.ts +16 -0
- package/{src/control/Atmosphere.ts → lib/js/control/Atmosphere.js} +33 -86
- package/lib/js/control/CompassButton.d.ts +16 -0
- package/{src/control/CompassButton.ts → lib/js/control/CompassButton.js} +18 -43
- package/lib/js/control/Control.d.ts +100 -0
- package/{src/control/Control.ts → lib/js/control/Control.js} +22 -89
- package/lib/js/control/DebugInfo.d.ts +25 -0
- package/{src/control/DebugInfo.ts → lib/js/control/DebugInfo.js} +38 -84
- package/lib/js/control/DrawingSwitcher.d.ts +13 -0
- package/{src/control/DrawingSwitcher.ts → lib/js/control/DrawingSwitcher.js} +13 -30
- package/lib/js/control/EarthCoordinates.d.ts +41 -0
- package/{src/control/EarthCoordinates.ts → lib/js/control/EarthCoordinates.js} +58 -119
- package/lib/js/control/EarthNavigation.d.ts +50 -0
- package/{src/control/EarthNavigation.ts → lib/js/control/EarthNavigation.js} +70 -161
- package/lib/js/control/GeoImageDragControl.d.ts +22 -0
- package/{src/control/GeoImageDragControl.ts → lib/js/control/GeoImageDragControl.js} +26 -49
- package/lib/js/control/KeyboardNavigation.d.ts +28 -0
- package/{src/control/KeyboardNavigation.ts → lib/js/control/KeyboardNavigation.js} +67 -92
- package/lib/js/control/LayerAnimation.d.ts +71 -0
- package/{src/control/LayerAnimation.ts → lib/js/control/LayerAnimation.js} +82 -162
- package/lib/js/control/LayerSwitcher.d.ts +21 -0
- package/{src/control/LayerSwitcher.ts → lib/js/control/LayerSwitcher.js} +16 -41
- package/lib/js/control/Lighting.d.ts +49 -0
- package/{src/control/Lighting.ts → lib/js/control/Lighting.js} +106 -219
- package/lib/js/control/MouseNavigation.d.ts +62 -0
- package/{src/control/MouseNavigation.ts → lib/js/control/MouseNavigation.js} +105 -211
- package/lib/js/control/MouseWheelZoomControl.d.ts +44 -0
- package/lib/js/control/MouseWheelZoomControl.js +181 -0
- package/lib/js/control/RulerSwitcher.d.ts +17 -0
- package/{src/control/RulerSwitcher.ts → lib/js/control/RulerSwitcher.js} +13 -28
- package/lib/js/control/ScaleControl.d.ts +24 -0
- package/lib/js/control/ScaleControl.js +91 -0
- package/lib/js/control/SegmentBoundVisualization.d.ts +12 -0
- package/lib/js/control/SegmentBoundVisualization.js +37 -0
- package/lib/js/control/ShowFps.d.ts +9 -0
- package/lib/js/control/ShowFps.js +20 -0
- package/lib/js/control/SimpleNavigation.d.ts +25 -0
- package/{src/control/SimpleNavigation.ts → lib/js/control/SimpleNavigation.js} +29 -51
- package/lib/js/control/SimpleSkyBackground.d.ts +15 -0
- package/{src/control/SimpleSkyBackground.ts → lib/js/control/SimpleSkyBackground.js} +21 -48
- package/lib/js/control/Sun.d.ts +33 -0
- package/{src/control/Sun.ts → lib/js/control/Sun.js} +34 -85
- package/lib/js/control/ToggleWireframe.d.ts +14 -0
- package/lib/js/control/ToggleWireframe.js +28 -0
- package/lib/js/control/TouchNavigation.d.ts +52 -0
- package/{src/control/TouchNavigation.ts → lib/js/control/TouchNavigation.js} +88 -193
- package/lib/js/control/ZoomControl.d.ts +27 -0
- package/{src/control/ZoomControl.ts → lib/js/control/ZoomControl.js} +25 -50
- package/lib/js/control/drawing/DrawingControl.d.ts +12 -0
- package/{src/control/drawing/DrawingControl.ts → lib/js/control/drawing/DrawingControl.js} +10 -20
- package/lib/js/control/drawing/LineStringDrawingScene.d.ts +15 -0
- package/{src/control/drawing/LineStringDrawingScene.ts → lib/js/control/drawing/LineStringDrawingScene.js} +28 -85
- package/lib/js/control/drawing/PolygonDrawingScene.d.ts +98 -0
- package/{src/control/drawing/PolygonDrawingScene.ts → lib/js/control/drawing/PolygonDrawingScene.js} +190 -388
- package/lib/js/control/elevationProfile/ElevationProfile.d.ts +61 -0
- package/{src/control/elevationProfile/ElevationProfile.ts → lib/js/control/elevationProfile/ElevationProfile.js} +56 -148
- package/lib/js/control/heightRuler/HeightRuler.d.ts +7 -0
- package/{src/control/heightRuler/HeightRuler.ts → lib/js/control/heightRuler/HeightRuler.js} +4 -9
- package/lib/js/control/heightRuler/HeightRulerScene.d.ts +35 -0
- package/{src/control/heightRuler/HeightRulerScene.ts → lib/js/control/heightRuler/HeightRulerScene.js} +47 -99
- package/lib/js/control/heightRuler/HeightRulerSwitcher.d.ts +6 -0
- package/{src/control/heightRuler/HeightRulerSwitcher.ts → lib/js/control/heightRuler/HeightRulerSwitcher.js} +2 -4
- package/{src/control/index.ts → lib/js/control/index.d.ts} +1 -18
- package/lib/js/control/index.js +28 -0
- package/lib/js/control/ruler/Ruler.d.ts +13 -0
- package/lib/js/control/ruler/Ruler.js +23 -0
- package/lib/js/control/ruler/RulerScene.d.ts +88 -0
- package/lib/js/control/ruler/RulerScene.js +324 -0
- package/lib/js/control/selection/Selection.d.ts +55 -0
- package/{src/control/selection/Selection.ts → lib/js/control/selection/Selection.js} +15 -34
- package/lib/js/control/selection/SelectionScene.d.ts +44 -0
- package/{src/control/selection/SelectionScene.ts → lib/js/control/selection/SelectionScene.js} +26 -113
- package/lib/js/control/timeline/TimelineControl.d.ts +18 -0
- package/{src/control/timeline/TimelineControl.ts → lib/js/control/timeline/TimelineControl.js} +13 -43
- package/lib/js/control/timeline/TimelineModel.d.ts +41 -0
- package/{src/control/timeline/TimelineModel.ts → lib/js/control/timeline/TimelineModel.js} +26 -74
- package/lib/js/control/timeline/TimelineView.d.ts +85 -0
- package/{src/control/timeline/TimelineView.ts → lib/js/control/timeline/TimelineView.js} +133 -281
- package/lib/js/control/timeline/timelineUtils.d.ts +12 -0
- package/lib/js/control/timeline/timelineUtils.js +112 -0
- package/lib/js/control/visibleExtent/Segment.d.ts +277 -0
- package/{src → lib/js}/control/visibleExtent/Segment.js +145 -698
- package/lib/js/control/visibleExtent/VisibleExtent.d.ts +5 -0
- package/{src → lib/js}/control/visibleExtent/VisibleExtent.js +1 -18
- package/lib/js/control/visibleExtent/drawnode.d.ts +7 -0
- package/{src/control/visibleExtent/drawnode.ts → lib/js/control/visibleExtent/drawnode.js} +1 -28
- package/lib/js/ellipsoid/Ellipsoid.d.ts +187 -0
- package/{src/ellipsoid/Ellipsoid.ts → lib/js/ellipsoid/Ellipsoid.js} +82 -267
- package/lib/js/ellipsoid/index.d.ts +3 -0
- package/lib/js/ellipsoid/index.js +3 -0
- package/lib/js/ellipsoid/wgs84.d.ts +6 -0
- package/{src/ellipsoid/wgs84.ts → lib/js/ellipsoid/wgs84.js} +1 -2
- package/lib/js/entity/BaseBillboard.d.ts +222 -0
- package/{src/entity/BaseBillboard.ts → lib/js/entity/BaseBillboard.js} +48 -165
- package/lib/js/entity/BaseBillboardHandler.d.ts +81 -0
- package/{src/entity/BaseBillboardHandler.ts → lib/js/entity/BaseBillboardHandler.js} +139 -365
- package/lib/js/entity/Billboard.d.ts +113 -0
- package/{src/entity/Billboard.ts → lib/js/entity/Billboard.js} +19 -83
- package/lib/js/entity/BillboardHandler.d.ts +15 -0
- package/{src/entity/BillboardHandler.ts → lib/js/entity/BillboardHandler.js} +27 -59
- package/lib/js/entity/Entity.d.ts +354 -0
- package/{src/entity/Entity.ts → lib/js/entity/Entity.js} +101 -373
- package/lib/js/entity/EntityCollection.d.ts +364 -0
- package/{src/entity/EntityCollection.ts → lib/js/entity/EntityCollection.js} +51 -353
- package/lib/js/entity/GeoObject.d.ts +138 -0
- package/{src/entity/GeoObject.ts → lib/js/entity/GeoObject.js} +41 -146
- package/lib/js/entity/GeoObjectHandler.d.ts +99 -0
- package/{src/entity/GeoObjectHandler.ts → lib/js/entity/GeoObjectHandler.js} +162 -423
- package/lib/js/entity/Geometry.d.ts +111 -0
- package/lib/js/entity/Geometry.js +283 -0
- package/lib/js/entity/GeometryHandler.d.ts +84 -0
- package/{src/entity/GeometryHandler.ts → lib/js/entity/GeometryHandler.js} +162 -657
- package/lib/js/entity/Label.d.ts +207 -0
- package/{src/entity/Label.ts → lib/js/entity/Label.js} +62 -164
- package/lib/js/entity/LabelHandler.d.ts +65 -0
- package/{src/entity/LabelHandler.ts → lib/js/entity/LabelHandler.js} +175 -408
- package/lib/js/entity/LabelWorker.d.ts +15 -0
- package/{src/entity/LabelWorker.ts → lib/js/entity/LabelWorker.js} +24 -45
- package/lib/js/entity/PointCloud.d.ts +179 -0
- package/{src/entity/PointCloud.ts → lib/js/entity/PointCloud.js} +65 -265
- package/lib/js/entity/PointCloudHandler.d.ts +42 -0
- package/{src/entity/PointCloudHandler.ts → lib/js/entity/PointCloudHandler.js} +19 -62
- package/lib/js/entity/Polyline.d.ts +337 -0
- package/{src/entity/Polyline.ts → lib/js/entity/Polyline.js} +289 -924
- package/lib/js/entity/PolylineHandler.d.ts +22 -0
- package/{src/entity/PolylineHandler.ts → lib/js/entity/PolylineHandler.js} +12 -37
- package/lib/js/entity/Ray.d.ts +133 -0
- package/{src/entity/Ray.ts → lib/js/entity/Ray.js} +26 -146
- package/lib/js/entity/RayHandler.d.ts +70 -0
- package/{src/entity/RayHandler.ts → lib/js/entity/RayHandler.js} +102 -342
- package/lib/js/entity/Strip.d.ts +127 -0
- package/{src/entity/Strip.ts → lib/js/entity/Strip.js} +102 -372
- package/lib/js/entity/StripHandler.d.ts +42 -0
- package/{src/entity/StripHandler.ts → lib/js/entity/StripHandler.js} +22 -74
- package/{src/entity/index.ts → lib/js/entity/index.d.ts} +1 -2
- package/lib/js/entity/index.js +11 -0
- package/lib/js/index.d.ts +33 -0
- package/lib/js/index.js +33 -0
- package/lib/js/input/KeyboardHandler.d.ts +33 -0
- package/{src/input/KeyboardHandler.ts → lib/js/input/KeyboardHandler.js} +45 -84
- package/lib/js/input/MouseHandler.d.ts +16 -0
- package/{src/input/MouseHandler.ts → lib/js/input/MouseHandler.js} +12 -36
- package/lib/js/input/TouchHandler.d.ts +11 -0
- package/{src/input/TouchHandler.ts → lib/js/input/TouchHandler.js} +11 -23
- package/lib/js/input/input.d.ts +3 -0
- package/{src/input/input.ts → lib/js/input/input.js} +1 -1
- package/lib/js/layer/BaseGeoImage.d.ts +145 -0
- package/{src/layer/BaseGeoImage.ts → lib/js/layer/BaseGeoImage.js} +70 -235
- package/lib/js/layer/CanvasTiles.d.ts +103 -0
- package/{src/layer/CanvasTiles.ts → lib/js/layer/CanvasTiles.js} +54 -146
- package/lib/js/layer/GeoImage.d.ts +61 -0
- package/{src/layer/GeoImage.ts → lib/js/layer/GeoImage.js} +24 -54
- package/lib/js/layer/GeoTexture2d.d.ts +17 -0
- package/lib/js/layer/GeoTexture2d.js +37 -0
- package/lib/js/layer/GeoVideo.d.ts +68 -0
- package/{src/layer/GeoVideo.ts → lib/js/layer/GeoVideo.js} +31 -61
- package/lib/js/layer/KML.d.ts +72 -0
- package/{src/layer/KML.ts → lib/js/layer/KML.js} +94 -138
- package/lib/js/layer/Layer.d.ts +401 -0
- package/{src/layer/Layer.ts → lib/js/layer/Layer.js} +92 -443
- package/lib/js/layer/Material.d.ts +34 -0
- package/{src/layer/Material.ts → lib/js/layer/Material.js} +9 -43
- package/lib/js/layer/Vector.d.ts +244 -0
- package/{src/layer/Vector.ts → lib/js/layer/Vector.js} +147 -418
- package/lib/js/layer/WMS.d.ts +75 -0
- package/{src/layer/WMS.ts → lib/js/layer/WMS.js} +18 -100
- package/lib/js/layer/XYZ.d.ts +149 -0
- package/{src/layer/XYZ.ts → lib/js/layer/XYZ.js} +71 -171
- package/lib/js/layer/index.d.ts +11 -0
- package/lib/js/layer/index.js +11 -0
- package/lib/js/light/LightSource.d.ts +174 -0
- package/{src/light/LightSource.ts → lib/js/light/LightSource.js} +22 -131
- package/lib/js/math/Line2.d.ts +11 -0
- package/{src/math/Line2.ts → lib/js/math/Line2.js} +5 -15
- package/lib/js/math/Line3.d.ts +28 -0
- package/lib/js/math/Line3.js +85 -0
- package/lib/js/math/Mat3.d.ts +77 -0
- package/{src/math/Mat3.ts → lib/js/math/Mat3.js} +22 -51
- package/lib/js/math/Mat4.d.ts +195 -0
- package/{src/math/Mat4.ts → lib/js/math/Mat4.js} +53 -219
- package/lib/js/math/Plane.d.ts +20 -0
- package/{src/math/Plane.ts → lib/js/math/Plane.js} +26 -40
- package/lib/js/math/Quat.d.ts +373 -0
- package/{src/math/Quat.ts → lib/js/math/Quat.js} +106 -319
- package/lib/js/math/Ray.d.ts +76 -0
- package/{src/math/Ray.ts → lib/js/math/Ray.js} +21 -66
- package/lib/js/math/Vec2.d.ts +310 -0
- package/{src/math/Vec2.ts → lib/js/math/Vec2.js} +55 -121
- package/lib/js/math/Vec3.d.ts +472 -0
- package/{src/math/Vec3.ts → lib/js/math/Vec3.js} +103 -236
- package/lib/js/math/Vec4.d.ts +163 -0
- package/{src/math/Vec4.ts → lib/js/math/Vec4.js} +23 -79
- package/lib/js/math/coder.d.ts +51 -0
- package/{src/math/coder.ts → lib/js/math/coder.js} +14 -20
- package/lib/js/math/index.d.ts +11 -0
- package/lib/js/math/index.js +11 -0
- package/lib/js/math.d.ts +266 -0
- package/{src/math.ts → lib/js/math.js} +37 -85
- package/lib/js/mercator.d.ts +92 -0
- package/{src/mercator.ts → lib/js/mercator.js} +13 -37
- package/lib/js/proj/EPSG3857.d.ts +9 -0
- package/{src/proj/EPSG3857.ts → lib/js/proj/EPSG3857.js} +0 -2
- package/lib/js/proj/EPSG4326.d.ts +9 -0
- package/{src/proj/EPSG4326.ts → lib/js/proj/EPSG4326.js} +0 -2
- package/lib/js/proj/Proj.d.ts +43 -0
- package/{src/proj/Proj.ts → lib/js/proj/Proj.js} +4 -29
- package/lib/js/quadTree/EPSG4326QuadTreeStrategy.d.ts +6 -0
- package/lib/js/quadTree/EPSG4326QuadTreeStrategy.js +17 -0
- package/lib/js/quadTree/EarthQuadTreeStrategy.d.ts +6 -0
- package/lib/js/quadTree/EarthQuadTreeStrategy.js +19 -0
- package/lib/js/quadTree/EntityCollectionNode.d.ts +54 -0
- package/{src/quadTree/EntityCollectionNode.ts → lib/js/quadTree/EntityCollectionNode.js} +83 -150
- package/lib/js/quadTree/MarsQuadTreeStrategy.d.ts +6 -0
- package/lib/js/quadTree/MarsQuadTreeStrategy.js +17 -0
- package/lib/js/quadTree/Node.d.ts +61 -0
- package/{src/quadTree/Node.ts → lib/js/quadTree/Node.js} +140 -357
- package/lib/js/quadTree/QuadTreeStrategy.d.ts +25 -0
- package/{src/quadTree/QuadTreeStrategy.ts → lib/js/quadTree/QuadTreeStrategy.js} +13 -44
- package/lib/js/quadTree/Wgs84QuadTreeStrategy.d.ts +6 -0
- package/lib/js/quadTree/Wgs84QuadTreeStrategy.js +15 -0
- package/lib/js/quadTree/index.d.ts +12 -0
- package/lib/js/quadTree/index.js +12 -0
- package/lib/js/quadTree/quadTree.d.ts +40 -0
- package/{src/quadTree/quadTree.ts → lib/js/quadTree/quadTree.js} +0 -9
- package/lib/js/renderer/Renderer.d.ts +311 -0
- package/{src/renderer/Renderer.ts → lib/js/renderer/Renderer.js} +169 -611
- package/lib/js/renderer/RendererEvents.d.ts +237 -0
- package/{src/renderer/RendererEvents.ts → lib/js/renderer/RendererEvents.js} +134 -471
- package/lib/js/scene/Axes.d.ts +12 -0
- package/lib/js/scene/Axes.js +59 -0
- package/lib/js/scene/BaseNode.d.ts +61 -0
- package/{src/scene/BaseNode.ts → lib/js/scene/BaseNode.js} +11 -57
- package/lib/js/scene/Planet.d.ts +623 -0
- package/{src/scene/Planet.ts → lib/js/scene/Planet.js} +251 -935
- package/lib/js/scene/RenderNode.d.ts +150 -0
- package/{src/scene/RenderNode.ts → lib/js/scene/RenderNode.js} +33 -138
- package/lib/js/scene/SkyBox.d.ts +13 -0
- package/{src/scene/SkyBox.ts → lib/js/scene/SkyBox.js} +16 -37
- package/{src/scene/index.ts → lib/js/scene/index.d.ts} +0 -1
- package/lib/js/scene/index.js +5 -0
- package/lib/js/segment/Segment.d.ts +278 -0
- package/{src/segment/Segment.ts → lib/js/segment/Segment.js} +242 -913
- package/lib/js/segment/SegmentLonLat.d.ts +48 -0
- package/{src/segment/SegmentLonLat.ts → lib/js/segment/SegmentLonLat.js} +58 -132
- package/lib/js/segment/SegmentLonLatWgs84.d.ts +10 -0
- package/lib/js/segment/SegmentLonLatWgs84.js +23 -0
- package/lib/js/segment/Slice.d.ts +13 -0
- package/{src/segment/Slice.ts → lib/js/segment/Slice.js} +4 -22
- package/lib/js/segment/segmentHelper.d.ts +18 -0
- package/{src/segment/segmentHelper.ts → lib/js/segment/segmentHelper.js} +30 -88
- package/lib/js/shaders/atmos.d.ts +4 -0
- package/{src/shaders/atmos.ts → lib/js/shaders/atmos.js} +8 -26
- package/lib/js/shaders/billboard.d.ts +3 -0
- package/{src/shaders/billboard.ts → lib/js/shaders/billboard.js} +9 -18
- package/lib/js/shaders/bloom.d.ts +2 -0
- package/{src/shaders/bloom.ts → lib/js/shaders/bloom.js} +5 -8
- package/lib/js/shaders/blur.d.ts +3 -0
- package/{src/shaders/blur.ts → lib/js/shaders/blur.js} +11 -19
- package/lib/js/shaders/depth.d.ts +2 -0
- package/{src/shaders/depth.ts → lib/js/shaders/depth.js} +3 -6
- package/lib/js/shaders/drawnode.d.ts +8 -0
- package/{src/shaders/drawnode.ts → lib/js/shaders/drawnode.js} +23 -75
- package/lib/js/shaders/geoObject.d.ts +3 -0
- package/{src/shaders/geoObject.ts → lib/js/shaders/geoObject.js} +51 -63
- package/lib/js/shaders/label.d.ts +4 -0
- package/{src/shaders/label.ts → lib/js/shaders/label.js} +12 -25
- package/lib/js/shaders/lumFilter.d.ts +2 -0
- package/{src/shaders/lumFilter.ts → lib/js/shaders/lumFilter.js} +4 -7
- package/lib/js/shaders/pickingMask.d.ts +2 -0
- package/{src/shaders/pickingMask.ts → lib/js/shaders/pickingMask.js} +5 -8
- package/lib/js/shaders/pointCloud.d.ts +2 -0
- package/{src/shaders/pointCloud.ts → lib/js/shaders/pointCloud.js} +4 -7
- package/lib/js/shaders/polyline.d.ts +3 -0
- package/{src/shaders/polyline.ts → lib/js/shaders/polyline.js} +7 -22
- package/lib/js/shaders/ray.d.ts +2 -0
- package/{src/shaders/ray.ts → lib/js/shaders/ray.js} +4 -7
- package/lib/js/shaders/screenFrame.d.ts +2 -0
- package/{src/shaders/screenFrame.ts → lib/js/shaders/screenFrame.js} +5 -8
- package/lib/js/shaders/skybox.d.ts +2 -0
- package/{src/shaders/skybox.ts → lib/js/shaders/skybox.js} +10 -13
- package/lib/js/shaders/toneMapping.d.ts +2 -0
- package/{src/shaders/toneMapping.ts → lib/js/shaders/toneMapping.js} +5 -8
- package/lib/js/shaders/utils.d.ts +1 -0
- package/{src/shaders/utils.ts → lib/js/shaders/utils.js} +1 -1
- package/lib/js/terrain/BilTerrain.d.ts +18 -0
- package/{src/terrain/BilTerrain.ts → lib/js/terrain/BilTerrain.js} +21 -118
- package/lib/js/terrain/EmptyTerrain.d.ts +106 -0
- package/{src/terrain/EmptyTerrain.ts → lib/js/terrain/EmptyTerrain.js} +20 -144
- package/lib/js/terrain/Geoid.d.ts +33 -0
- package/lib/js/terrain/Geoid.js +191 -0
- package/lib/js/terrain/GlobusTerrain.d.ts +134 -0
- package/{src/terrain/GlobusTerrain.ts → lib/js/terrain/GlobusTerrain.js} +82 -239
- package/lib/js/terrain/MapboxTerrain.d.ts +21 -0
- package/{src/terrain/MapboxTerrain.ts → lib/js/terrain/MapboxTerrain.js} +46 -215
- package/{src/terrain/index.ts → lib/js/terrain/index.d.ts} +0 -1
- package/lib/js/terrain/index.js +5 -0
- package/lib/js/ui/Button.d.ts +32 -0
- package/lib/js/ui/Button.js +78 -0
- package/lib/js/ui/ButtonGroup.d.ts +16 -0
- package/lib/js/ui/ButtonGroup.js +41 -0
- package/lib/js/ui/Dialog.d.ts +55 -0
- package/lib/js/ui/Dialog.js +173 -0
- package/lib/js/ui/Slider.d.ts +38 -0
- package/lib/js/ui/Slider.js +129 -0
- package/lib/js/ui/ToggleButton.d.ts +20 -0
- package/lib/js/ui/ToggleButton.js +42 -0
- package/lib/js/ui/View.d.ts +37 -0
- package/{src/ui/View.ts → lib/js/ui/View.js} +31 -77
- package/lib/js/ui/icons.d.ts +1 -0
- package/{src/ui/icons.ts → lib/js/ui/icons.js} +1 -1
- package/lib/js/utils/BaseWorker.d.ts +14 -0
- package/{src/utils/BaseWorker.ts → lib/js/utils/BaseWorker.js} +15 -28
- package/lib/js/utils/FontAtlas.d.ts +82 -0
- package/{src/utils/FontAtlas.ts → lib/js/utils/FontAtlas.js} +45 -181
- package/lib/js/utils/GeoImageCreator.d.ts +34 -0
- package/{src/utils/GeoImageCreator.ts → lib/js/utils/GeoImageCreator.js} +34 -91
- package/lib/js/utils/ImagesCacheManager.d.ts +22 -0
- package/{src/utils/ImagesCacheManager.ts → lib/js/utils/ImagesCacheManager.js} +16 -38
- package/lib/js/utils/Loader.d.ts +63 -0
- package/lib/js/utils/Loader.js +156 -0
- package/lib/js/utils/NormalMapCreator.d.ts +52 -0
- package/{src/utils/NormalMapCreator.ts → lib/js/utils/NormalMapCreator.js} +64 -195
- package/lib/js/utils/PlainSegmentWorker.d.ts +24 -0
- package/{src/utils/PlainSegmentWorker.ts → lib/js/utils/PlainSegmentWorker.js} +24 -56
- package/lib/js/utils/TerrainWorker.d.ts +28 -0
- package/{src/utils/TerrainWorker.ts → lib/js/utils/TerrainWorker.js} +19 -56
- package/lib/js/utils/TextureAtlas.d.ts +113 -0
- package/{src/utils/TextureAtlas.ts → lib/js/utils/TextureAtlas.js} +40 -131
- package/lib/js/utils/VectorTileCreator.d.ts +18 -0
- package/{src/utils/VectorTileCreator.ts → lib/js/utils/VectorTileCreator.js} +61 -147
- package/lib/js/utils/colorTable.d.ts +3 -0
- package/{src/utils/colorTable.ts → lib/js/utils/colorTable.js} +2 -2
- package/lib/js/utils/earcut.d.ts +7 -0
- package/{src/utils/earcut.ts → lib/js/utils/earcut.js} +95 -223
- package/lib/js/utils/objParser.d.ts +24 -0
- package/{src/utils/objParser.ts → lib/js/utils/objParser.js} +38 -93
- package/lib/js/utils/shared.d.ts +267 -0
- package/{src/utils/shared.ts → lib/js/utils/shared.js} +184 -341
- package/lib/js/utils/units.d.ts +16 -0
- package/lib/js/utils/units.js +61 -0
- package/lib/js/webgl/BaseFramebuffer.d.ts +53 -0
- package/{src/webgl/BaseFramebuffer.ts → lib/js/webgl/BaseFramebuffer.js} +22 -59
- package/lib/js/webgl/Framebuffer.d.ts +69 -0
- package/{src/webgl/Framebuffer.ts → lib/js/webgl/Framebuffer.js} +30 -87
- package/lib/js/webgl/Handler.d.ts +473 -0
- package/{src/webgl/Handler.ts → lib/js/webgl/Handler.js} +175 -586
- package/lib/js/webgl/Multisample.d.ts +27 -0
- package/lib/js/webgl/Multisample.js +77 -0
- package/lib/js/webgl/Program.d.ts +159 -0
- package/{src/webgl/Program.ts → lib/js/webgl/Program.js} +73 -210
- package/lib/js/webgl/ProgramController.d.ts +86 -0
- package/{src/webgl/ProgramController.ts → lib/js/webgl/ProgramController.js} +11 -45
- package/{src/webgl/index.ts → lib/js/webgl/index.d.ts} +1 -8
- package/lib/js/webgl/index.js +6 -0
- package/lib/js/webgl/types.d.ts +9 -0
- package/{src/webgl/types.ts → lib/js/webgl/types.js} +5 -8
- package/lib/js/webgl/variableHandlers.d.ts +22 -0
- package/lib/js/webgl/variableHandlers.js +78 -0
- package/package.json +23 -34
- package/dist/@openglobus/og.esm.js +0 -2
- package/dist/@openglobus/og.esm.js.map +0 -1
- package/dist/@openglobus/og.umd.js +0 -2
- package/dist/@openglobus/og.umd.js.map +0 -1
- package/src/Deferred.ts +0 -17
- package/src/control/MouseWheelZoomControl.ts +0 -269
- package/src/control/ScaleControl.ts +0 -131
- package/src/control/SegmentBoundVisualization.ts +0 -50
- package/src/control/ShowFps.ts +0 -28
- package/src/control/ToggleWireframe.ts +0 -35
- package/src/control/ruler/Ruler.ts +0 -35
- package/src/control/ruler/RulerScene.ts +0 -437
- package/src/control/timeline/timelineUtils.ts +0 -133
- package/src/ellipsoid/index.ts +0 -4
- package/src/entity/Geometry.ts +0 -486
- package/src/index.ts +0 -173
- package/src/layer/GeoTexture2d.ts +0 -56
- package/src/layer/index.ts +0 -12
- package/src/math/Line3.ts +0 -162
- package/src/math/index.ts +0 -26
- package/src/quadTree/EPSG4326QuadTreeStrategy.ts +0 -24
- package/src/quadTree/EarthQuadTreeStrategy.ts +0 -28
- package/src/quadTree/MarsQuadTreeStrategy.ts +0 -25
- package/src/quadTree/Wgs84QuadTreeStrategy.ts +0 -22
- package/src/quadTree/index.ts +0 -14
- package/src/scene/Axes.ts +0 -78
- package/src/segment/SegmentLonLatWgs84.ts +0 -33
- package/src/terrain/Geoid.ts +0 -273
- package/src/ui/Button.ts +0 -121
- package/src/ui/ButtonGroup.ts +0 -63
- package/src/ui/Dialog.ts +0 -244
- package/src/ui/Slider.ts +0 -188
- package/src/ui/ToggleButton.ts +0 -68
- package/src/utils/Loader.ts +0 -247
- package/src/utils/units.ts +0 -78
- package/src/webgl/Multisample.ts +0 -153
- package/src/webgl/variableHandlers.ts +0 -114
- /package/{dist → lib}/@openglobus/og.css +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Karla-Bold.json +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Karla-Bold.ttf.cfg +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Karla-Bold.ttf.png +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Karla-Light.json +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Karla-Light.ttf.cfg +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Karla-Light.ttf.png +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Karla-Medium.json +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Karla-Medium.ttf.cfg +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Karla-Medium.ttf.png +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/NotoSansArabic-Regular.json +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/NotoSansArabic-Regular.ttf.cfg +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/NotoSansArabic-Regular.ttf.png +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Roboto-Regular.json +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Roboto-Regular.ttf.cfg +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/Roboto-Regular.ttf.png +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/arial.js +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/arial.json +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/arial.ttf.cfg +0 -0
- /package/{dist → lib}/@openglobus/res/fonts/arial.ttf.png +0 -0
- /package/{dist → lib}/@openglobus/res/night-4326.png +0 -0
- /package/{dist → lib}/@openglobus/res/night.png +0 -0
- /package/{dist → lib}/@openglobus/res/spec.png +0 -0
|
@@ -1,55 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {Program} from "./Program";
|
|
10
|
-
import {Stack} from "../Stack";
|
|
11
|
-
|
|
12
|
-
export type WebGLContextExt = { type: string } & WebGL2RenderingContext;
|
|
13
|
-
export type WebGLBufferExt = { numItems: number; itemSize: number } & WebGLBuffer;
|
|
14
|
-
export type WebGLTextureExt = { default?: boolean } & WebGLTexture;
|
|
15
|
-
export type ImageSource = HTMLCanvasElement | ImageBitmap | ImageData | HTMLImageElement | HTMLVideoElement;
|
|
16
|
-
type CreateTextureFunc = (image: ImageSource, internalFormat?: number, texture?: WebGLTextureExt) => WebGLTextureExt | null;
|
|
17
|
-
|
|
18
|
-
export interface IHandlerParameters {
|
|
19
|
-
anisotropy?: number;
|
|
20
|
-
width?: number;
|
|
21
|
-
height?: number;
|
|
22
|
-
pixelRatio?: number;
|
|
23
|
-
context?: {
|
|
24
|
-
stencil?: boolean;
|
|
25
|
-
alpha?: boolean;
|
|
26
|
-
antialias?: boolean;
|
|
27
|
-
premultipliedAlpha?: boolean;
|
|
28
|
-
},
|
|
29
|
-
extensions?: string[];
|
|
30
|
-
autoActivate?: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface Texture3DParams {
|
|
34
|
-
nx: string,
|
|
35
|
-
px: string,
|
|
36
|
-
py: string,
|
|
37
|
-
ny: string,
|
|
38
|
-
pz: string,
|
|
39
|
-
nz: string
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface IDefaultTextureParams {
|
|
43
|
-
color?: string;
|
|
44
|
-
url?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
1
|
+
import { Clock } from "../Clock";
|
|
2
|
+
import { cons } from "../cons";
|
|
3
|
+
import { createEvents } from "../Events";
|
|
4
|
+
import { getUrlParam, isEmpty } from "../utils/shared";
|
|
5
|
+
import { ImageCanvas } from "../ImageCanvas";
|
|
6
|
+
import { Vec2 } from "../math/Vec2";
|
|
7
|
+
import { ProgramController } from "./ProgramController";
|
|
8
|
+
import { Stack } from "../Stack";
|
|
47
9
|
const vendorPrefixes = ["", "WEBKIT_", "MOZ_"];
|
|
48
10
|
const CONTEXT_TYPE = ["webgl2", "webgl"];
|
|
49
|
-
|
|
50
11
|
// Maximal mipmap levels
|
|
51
12
|
const MAX_LEVELS = 2;
|
|
52
|
-
|
|
53
13
|
/**
|
|
54
14
|
* A WebGL handler for accessing low-level WebGL capabilities.
|
|
55
15
|
* @class
|
|
@@ -62,153 +22,18 @@ const MAX_LEVELS = 2;
|
|
|
62
22
|
* @param {Array.<string>} [params.extensions] - Additional WebGL extension list. Available by default: EXT_texture_filter_anisotropic.
|
|
63
23
|
*/
|
|
64
24
|
class Handler {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
* @type {EventsHandler<["visibilitychange", "resize"]>}
|
|
70
|
-
*/
|
|
71
|
-
public events: EventsHandler<["visibilitychange", "resize"]>;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Application default timer.
|
|
75
|
-
* @public
|
|
76
|
-
* @type {Clock}
|
|
77
|
-
*/
|
|
78
|
-
public defaultClock: Clock;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Custom timers.
|
|
82
|
-
* @protected
|
|
83
|
-
* @type{Clock[]}
|
|
84
|
-
*/
|
|
85
|
-
protected _clocks: Clock[];
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Draw frame time in milliseconds.
|
|
89
|
-
* @public
|
|
90
|
-
* @type {number}
|
|
91
|
-
*/
|
|
92
|
-
public deltaTime: number;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* WebGL rendering canvas element.
|
|
96
|
-
* @public
|
|
97
|
-
* @type {HTMLCanvasElement | null}
|
|
98
|
-
*/
|
|
99
|
-
public canvas: HTMLCanvasElement | null;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* WebGL context.
|
|
103
|
-
* @public
|
|
104
|
-
* @type {WebGLContextExt | null}
|
|
105
|
-
*/
|
|
106
|
-
public gl: WebGLContextExt | null;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Shader program controller list.
|
|
110
|
-
* @public
|
|
111
|
-
* @type {Record<string, ProgramController>}
|
|
112
|
-
*/
|
|
113
|
-
public programs: Record<string, ProgramController>;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Current active shader program controller.
|
|
117
|
-
* @public
|
|
118
|
-
* @type {ProgramController}
|
|
119
|
-
*/
|
|
120
|
-
public activeProgram: ProgramController | null;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Handler parameters.
|
|
124
|
-
* @private
|
|
125
|
-
* @type {Object}
|
|
126
|
-
*/
|
|
127
|
-
protected _params: {
|
|
128
|
-
anisotropy: number;
|
|
129
|
-
width: number;
|
|
130
|
-
height: number;
|
|
131
|
-
pixelRatio: number;
|
|
132
|
-
context: {
|
|
133
|
-
stencil?: boolean;
|
|
134
|
-
alpha?: boolean;
|
|
135
|
-
antialias?: boolean;
|
|
136
|
-
premultipliedAlpha?: boolean;
|
|
137
|
-
};
|
|
138
|
-
extensions: string[];
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
public _oneByHeight: number;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Current WebGL extensions. Becomes here after context initialization.
|
|
145
|
-
* @public
|
|
146
|
-
* @type {Record<string, any>}
|
|
147
|
-
*/
|
|
148
|
-
public extensions: Record<string, any>;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* HTML Canvas target.
|
|
152
|
-
* @private
|
|
153
|
-
* @type {string | HTMLCanvasElement | undefined}
|
|
154
|
-
*/
|
|
155
|
-
protected _canvasTarget: string | HTMLCanvasElement | undefined;
|
|
156
|
-
|
|
157
|
-
protected _lastAnimationFrameTime: number;
|
|
158
|
-
|
|
159
|
-
protected _initialized: boolean;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Animation frame function assigned from outside(Ex. from Renderer).
|
|
163
|
-
* @private
|
|
164
|
-
* @type {Function}
|
|
165
|
-
*/
|
|
166
|
-
protected _frameCallback: Function;
|
|
167
|
-
|
|
168
|
-
protected _canvasSize: NumberArray2;
|
|
169
|
-
|
|
170
|
-
public transparentTexture: WebGLTextureExt | null;
|
|
171
|
-
|
|
172
|
-
public defaultTexture: WebGLTextureExt | null;
|
|
173
|
-
|
|
174
|
-
public framebufferStack = new Stack<BaseFramebuffer>();
|
|
175
|
-
|
|
176
|
-
public createTexture: Record<string, CreateTextureFunc>;
|
|
177
|
-
|
|
178
|
-
public createTextureDefault: CreateTextureFunc;
|
|
179
|
-
|
|
180
|
-
public ONCANVASRESIZE: Function | null;
|
|
181
|
-
|
|
182
|
-
public createTexture_n: CreateTextureFunc;
|
|
183
|
-
public createTexture_l: CreateTextureFunc;
|
|
184
|
-
public createTexture_mm: CreateTextureFunc;
|
|
185
|
-
public createTexture_a: CreateTextureFunc;
|
|
186
|
-
|
|
187
|
-
public intersectionObserver?: IntersectionObserver;
|
|
188
|
-
public resizeObserver?: ResizeObserver;
|
|
189
|
-
|
|
190
|
-
protected _requestAnimationFrameId: number = 0;
|
|
191
|
-
|
|
192
|
-
constructor(canvasTarget: string | HTMLCanvasElement | undefined, params: IHandlerParameters = {}) {
|
|
193
|
-
|
|
194
|
-
this.events = createEvents<["visibilitychange", "resize"]>(["visibilitychange", "resize"]);
|
|
195
|
-
|
|
25
|
+
constructor(canvasTarget, params = {}) {
|
|
26
|
+
this.framebufferStack = new Stack();
|
|
27
|
+
this._requestAnimationFrameId = 0;
|
|
28
|
+
this.events = createEvents(["visibilitychange", "resize"]);
|
|
196
29
|
this.defaultClock = new Clock();
|
|
197
|
-
|
|
198
30
|
this._clocks = [];
|
|
199
|
-
|
|
200
31
|
this.deltaTime = 0;
|
|
201
|
-
|
|
202
32
|
this.canvas = null;
|
|
203
|
-
|
|
204
33
|
this.gl = null;
|
|
205
|
-
|
|
206
34
|
this.programs = {};
|
|
207
|
-
|
|
208
35
|
this.activeProgram = null;
|
|
209
|
-
|
|
210
36
|
this._canvasSize = [0, 0];
|
|
211
|
-
|
|
212
37
|
this._params = {
|
|
213
38
|
anisotropy: params.anisotropy || 4,
|
|
214
39
|
width: params.width || 256,
|
|
@@ -216,78 +41,61 @@ class Handler {
|
|
|
216
41
|
pixelRatio: getUrlParam('og_dpi') || params.pixelRatio || 1.0,
|
|
217
42
|
extensions: params.extensions || [],
|
|
218
43
|
context: params.context || {}
|
|
219
|
-
}
|
|
220
|
-
|
|
44
|
+
};
|
|
221
45
|
this._oneByHeight = 1.0 / (this._params.height * this._params.pixelRatio);
|
|
222
|
-
|
|
223
46
|
this.extensions = {};
|
|
224
|
-
|
|
225
47
|
this._canvasTarget = canvasTarget;
|
|
226
|
-
|
|
227
48
|
this._lastAnimationFrameTime = 0;
|
|
228
|
-
|
|
229
49
|
this._initialized = false;
|
|
230
|
-
|
|
231
50
|
this._frameCallback = function () {
|
|
232
51
|
};
|
|
233
|
-
|
|
234
52
|
this.transparentTexture = null;
|
|
235
|
-
|
|
236
53
|
this.defaultTexture = null;
|
|
237
|
-
|
|
238
54
|
this.framebufferStack = new Stack();
|
|
239
|
-
|
|
240
55
|
this.createTexture_n = this.createTexture_n_webgl2.bind(this);
|
|
241
56
|
this.createTexture_l = this.createTexture_l_webgl2.bind(this);
|
|
242
57
|
this.createTexture_mm = this.createTexture_mm_webgl2.bind(this);
|
|
243
58
|
this.createTexture_a = this.createTexture_a_webgl2.bind(this);
|
|
244
|
-
|
|
245
59
|
this.createTexture = {
|
|
246
60
|
"NEAREST": this.createTexture_n,
|
|
247
61
|
"LINEAR": this.createTexture_l,
|
|
248
62
|
"MIPMAP": this.createTexture_mm,
|
|
249
63
|
"ANISOTROPIC": this.createTexture_a
|
|
250
64
|
};
|
|
251
|
-
|
|
252
65
|
this.createTextureDefault = this.createTexture_n;
|
|
253
|
-
|
|
254
66
|
this.ONCANVASRESIZE = null;
|
|
255
|
-
|
|
256
67
|
this._createCanvas();
|
|
257
|
-
|
|
258
68
|
if (params.autoActivate || isEmpty(params.autoActivate)) {
|
|
259
69
|
this.initialize();
|
|
260
70
|
}
|
|
261
71
|
}
|
|
262
|
-
|
|
263
|
-
public isInitialized(): boolean {
|
|
72
|
+
isInitialized() {
|
|
264
73
|
return this._initialized;
|
|
265
74
|
}
|
|
266
|
-
|
|
267
|
-
protected _createCanvas() {
|
|
75
|
+
_createCanvas() {
|
|
268
76
|
if (this._canvasTarget) {
|
|
269
77
|
if (this._canvasTarget instanceof HTMLElement) {
|
|
270
78
|
this.canvas = this._canvasTarget;
|
|
271
|
-
} else {
|
|
272
|
-
this.canvas = (document.getElementById(this._canvasTarget) || document.querySelector(this._canvasTarget)) as HTMLCanvasElement;
|
|
273
79
|
}
|
|
274
|
-
|
|
80
|
+
else {
|
|
81
|
+
this.canvas = (document.getElementById(this._canvasTarget) || document.querySelector(this._canvasTarget));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
275
85
|
this.canvas = document.createElement("canvas");
|
|
276
86
|
this.canvas.width = this._params.width;
|
|
277
87
|
this.canvas.height = this._params.height;
|
|
278
88
|
}
|
|
279
89
|
}
|
|
280
|
-
|
|
281
90
|
/**
|
|
282
91
|
* The return value is null if the extension is not supported, or an extension object otherwise.
|
|
283
92
|
* @param {WebGLRenderingContext | WebGL2RenderingContext | null} gl - WebGl context pointer.
|
|
284
93
|
* @param {string} name - Extension name.
|
|
285
94
|
* @returns {any} -
|
|
286
95
|
*/
|
|
287
|
-
static getExtension(gl
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
96
|
+
static getExtension(gl, name) {
|
|
97
|
+
if (!gl)
|
|
98
|
+
return;
|
|
291
99
|
let i, ext;
|
|
292
100
|
for (i in vendorPrefixes) {
|
|
293
101
|
ext = gl.getExtension(vendorPrefixes[i] + name);
|
|
@@ -296,53 +104,49 @@ class Handler {
|
|
|
296
104
|
}
|
|
297
105
|
}
|
|
298
106
|
}
|
|
299
|
-
|
|
300
107
|
/**
|
|
301
108
|
* Returns a drawing context on the canvas, or null if the context identifier is not supported.
|
|
302
109
|
* @param {HTMLCanvasElement} canvas - HTML canvas object.
|
|
303
110
|
* @param {any} [contextAttributes] - See canvas.getContext contextAttributes.
|
|
304
111
|
* @returns {WebGLContextExt | null} -
|
|
305
112
|
*/
|
|
306
|
-
static getContext(canvas
|
|
307
|
-
let ctx
|
|
308
|
-
|
|
113
|
+
static getContext(canvas, contextAttributes) {
|
|
114
|
+
let ctx = null;
|
|
309
115
|
try {
|
|
310
116
|
let urlParams = new URLSearchParams(location.search);
|
|
311
117
|
let ver = urlParams.get('og_ver');
|
|
312
118
|
if (ver) {
|
|
313
|
-
ctx = canvas.getContext(ver, contextAttributes)
|
|
119
|
+
ctx = canvas.getContext(ver, contextAttributes);
|
|
314
120
|
if (ctx) {
|
|
315
121
|
ctx.type = ver;
|
|
316
122
|
}
|
|
317
|
-
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
318
125
|
for (let i = 0; i < CONTEXT_TYPE.length; i++) {
|
|
319
|
-
ctx = canvas.getContext(CONTEXT_TYPE[i], contextAttributes)
|
|
126
|
+
ctx = canvas.getContext(CONTEXT_TYPE[i], contextAttributes);
|
|
320
127
|
if (ctx) {
|
|
321
128
|
ctx.type = CONTEXT_TYPE[i];
|
|
322
129
|
break;
|
|
323
130
|
}
|
|
324
131
|
}
|
|
325
132
|
}
|
|
326
|
-
}
|
|
133
|
+
}
|
|
134
|
+
catch (ex) {
|
|
327
135
|
cons.logErr("exception during the GL context initialization");
|
|
328
136
|
}
|
|
329
|
-
|
|
330
137
|
if (!ctx) {
|
|
331
138
|
cons.logErr("could not initialise WebGL");
|
|
332
139
|
}
|
|
333
|
-
|
|
334
140
|
return ctx;
|
|
335
141
|
}
|
|
336
|
-
|
|
337
142
|
/**
|
|
338
143
|
* Sets animation frame function.
|
|
339
144
|
* @public
|
|
340
145
|
* @param {Function} callback - Frame callback.
|
|
341
146
|
*/
|
|
342
|
-
|
|
147
|
+
setFrameCallback(callback) {
|
|
343
148
|
callback && (this._frameCallback = callback);
|
|
344
149
|
}
|
|
345
|
-
|
|
346
150
|
/**
|
|
347
151
|
* Creates empty texture.
|
|
348
152
|
* @public
|
|
@@ -355,41 +159,19 @@ class Handler {
|
|
|
355
159
|
* @param {number} [level=0] - Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
|
|
356
160
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
357
161
|
*/
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
height: number = 1,
|
|
361
|
-
filter: string = "NEAREST",
|
|
362
|
-
internalFormat: string = "RGBA",
|
|
363
|
-
format: string = "RGBA",
|
|
364
|
-
type: string = "UNSIGNED_BYTE",
|
|
365
|
-
level: number = 0
|
|
366
|
-
): WebGLTexture | null {
|
|
367
|
-
|
|
368
|
-
let gl = this.gl!;
|
|
369
|
-
|
|
162
|
+
createEmptyTexture2DExt(width = 1, height = 1, filter = "NEAREST", internalFormat = "RGBA", format = "RGBA", type = "UNSIGNED_BYTE", level = 0) {
|
|
163
|
+
let gl = this.gl;
|
|
370
164
|
let texture = gl.createTexture();
|
|
371
165
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
372
166
|
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
373
|
-
gl.texImage2D(
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
(gl as any)[internalFormat.toUpperCase()],
|
|
377
|
-
width,
|
|
378
|
-
height,
|
|
379
|
-
0,
|
|
380
|
-
(gl as any)[format.toUpperCase()],
|
|
381
|
-
(gl as any)[type.toUpperCase()],
|
|
382
|
-
null!
|
|
383
|
-
);
|
|
384
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (gl as any)[filter.toUpperCase()]);
|
|
385
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (gl as any)[filter.toUpperCase()]);
|
|
167
|
+
gl.texImage2D(gl.TEXTURE_2D, level, gl[internalFormat.toUpperCase()], width, height, 0, gl[format.toUpperCase()], gl[type.toUpperCase()], null);
|
|
168
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl[filter.toUpperCase()]);
|
|
169
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl[filter.toUpperCase()]);
|
|
386
170
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
387
171
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
388
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
389
|
-
|
|
172
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
390
173
|
return texture;
|
|
391
174
|
}
|
|
392
|
-
|
|
393
175
|
/**
|
|
394
176
|
* Creates Empty NEAREST filtered texture.
|
|
395
177
|
* @public
|
|
@@ -398,36 +180,19 @@ class Handler {
|
|
|
398
180
|
* @param {number} [internalFormat]
|
|
399
181
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
400
182
|
*/
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
height: number,
|
|
404
|
-
internalFormat?: number): WebGLTexture | null {
|
|
405
|
-
|
|
406
|
-
let gl = this.gl!;
|
|
407
|
-
|
|
183
|
+
createEmptyTexture_n(width, height, internalFormat) {
|
|
184
|
+
let gl = this.gl;
|
|
408
185
|
let texture = gl.createTexture();
|
|
409
186
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
410
187
|
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
411
|
-
gl.texImage2D(
|
|
412
|
-
gl.TEXTURE_2D,
|
|
413
|
-
0,
|
|
414
|
-
internalFormat || gl.RGBA,
|
|
415
|
-
width,
|
|
416
|
-
height,
|
|
417
|
-
0,
|
|
418
|
-
gl.RGBA,
|
|
419
|
-
gl.UNSIGNED_BYTE,
|
|
420
|
-
null!
|
|
421
|
-
);
|
|
188
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
422
189
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
423
190
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
424
191
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
425
192
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
426
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
427
|
-
|
|
193
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
428
194
|
return texture;
|
|
429
195
|
}
|
|
430
|
-
|
|
431
196
|
/**
|
|
432
197
|
* Creates empty LINEAR filtered texture.
|
|
433
198
|
* @public
|
|
@@ -436,26 +201,19 @@ class Handler {
|
|
|
436
201
|
* @param {number} [internalFormat]
|
|
437
202
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
438
203
|
*/
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
height: number,
|
|
442
|
-
internalFormat?: number): WebGLTexture | null {
|
|
443
|
-
|
|
444
|
-
let gl = this.gl!;
|
|
445
|
-
|
|
204
|
+
createEmptyTexture_l(width, height, internalFormat) {
|
|
205
|
+
let gl = this.gl;
|
|
446
206
|
let texture = gl.createTexture();
|
|
447
207
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
448
208
|
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
449
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null
|
|
209
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
|
450
210
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
451
211
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
452
212
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
453
213
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
454
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
455
|
-
|
|
214
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
456
215
|
return texture;
|
|
457
216
|
}
|
|
458
|
-
|
|
459
217
|
/**
|
|
460
218
|
* Creates NEAREST filter texture.
|
|
461
219
|
* @public
|
|
@@ -464,13 +222,8 @@ class Handler {
|
|
|
464
222
|
* @param {WebGLTexture | null} [texture=null]
|
|
465
223
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
466
224
|
*/
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
internalFormat?: number,
|
|
470
|
-
texture: WebGLTexture | null = null): WebGLTexture | null {
|
|
471
|
-
|
|
472
|
-
let gl = this.gl!;
|
|
473
|
-
|
|
225
|
+
createTexture_n_webgl1(image, internalFormat, texture = null) {
|
|
226
|
+
let gl = this.gl;
|
|
474
227
|
texture = texture || gl.createTexture();
|
|
475
228
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
476
229
|
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
@@ -479,11 +232,9 @@ class Handler {
|
|
|
479
232
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
480
233
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
481
234
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
482
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
483
|
-
|
|
235
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
484
236
|
return texture;
|
|
485
237
|
}
|
|
486
|
-
|
|
487
238
|
/**
|
|
488
239
|
* Creates LINEAR filter texture.
|
|
489
240
|
* @public
|
|
@@ -492,13 +243,8 @@ class Handler {
|
|
|
492
243
|
* @param {WebGLTexture | null} [texture]
|
|
493
244
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
494
245
|
*/
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
internalFormat?: number,
|
|
498
|
-
texture: WebGLTexture | null = null): WebGLTexture | null {
|
|
499
|
-
|
|
500
|
-
let gl = this.gl!;
|
|
501
|
-
|
|
246
|
+
createTexture_l_webgl1(image, internalFormat, texture = null) {
|
|
247
|
+
let gl = this.gl;
|
|
502
248
|
texture = texture || gl.createTexture();
|
|
503
249
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
504
250
|
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat || gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
|
@@ -506,11 +252,9 @@ class Handler {
|
|
|
506
252
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
507
253
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
508
254
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
509
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
510
|
-
|
|
255
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
511
256
|
return texture;
|
|
512
257
|
}
|
|
513
|
-
|
|
514
258
|
/**
|
|
515
259
|
* Creates MIPMAP filter texture.
|
|
516
260
|
* @public
|
|
@@ -519,13 +263,8 @@ class Handler {
|
|
|
519
263
|
* @param {WebGLTexture | null} [texture]
|
|
520
264
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
521
265
|
*/
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
internalFormat?: number,
|
|
525
|
-
texture: WebGLTexture | null = null): WebGLTexture | null {
|
|
526
|
-
|
|
527
|
-
let gl = this.gl!;
|
|
528
|
-
|
|
266
|
+
createTexture_mm_webgl1(image, internalFormat, texture = null) {
|
|
267
|
+
let gl = this.gl;
|
|
529
268
|
texture = texture || gl.createTexture();
|
|
530
269
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
531
270
|
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
@@ -534,11 +273,9 @@ class Handler {
|
|
|
534
273
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
|
|
535
274
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
536
275
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
537
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
538
|
-
|
|
276
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
539
277
|
return texture;
|
|
540
278
|
}
|
|
541
|
-
|
|
542
279
|
/**
|
|
543
280
|
* Creates ANISOTROPY filter texture.
|
|
544
281
|
* @public
|
|
@@ -547,13 +284,8 @@ class Handler {
|
|
|
547
284
|
* @param {WebGLTexture | null} [texture]
|
|
548
285
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
549
286
|
*/
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
internalFormat?: number,
|
|
553
|
-
texture: WebGLTexture | null = null): WebGLTexture | null {
|
|
554
|
-
|
|
555
|
-
let gl = this.gl!;
|
|
556
|
-
|
|
287
|
+
createTexture_a_webgl1(image, internalFormat, texture = null) {
|
|
288
|
+
let gl = this.gl;
|
|
557
289
|
texture = texture || gl.createTexture();
|
|
558
290
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
559
291
|
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
@@ -563,11 +295,9 @@ class Handler {
|
|
|
563
295
|
gl.texParameterf(gl.TEXTURE_2D, this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT, this._params.anisotropy);
|
|
564
296
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
565
297
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
566
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
567
|
-
|
|
298
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
568
299
|
return texture;
|
|
569
300
|
}
|
|
570
|
-
|
|
571
301
|
/**
|
|
572
302
|
* Creates NEAREST filter texture.
|
|
573
303
|
* @public
|
|
@@ -576,13 +306,8 @@ class Handler {
|
|
|
576
306
|
* @param {WebGLTexture | null} [texture]
|
|
577
307
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
578
308
|
*/
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
internalFormat?: number,
|
|
582
|
-
texture: WebGLTexture | null = null): WebGLTexture | null {
|
|
583
|
-
|
|
584
|
-
let gl = this.gl!;
|
|
585
|
-
|
|
309
|
+
createTexture_n_webgl2(image, internalFormat, texture = null) {
|
|
310
|
+
let gl = this.gl;
|
|
586
311
|
texture = texture || gl.createTexture();
|
|
587
312
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
588
313
|
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
@@ -593,11 +318,9 @@ class Handler {
|
|
|
593
318
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
594
319
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
595
320
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
596
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
597
|
-
|
|
321
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
598
322
|
return texture;
|
|
599
323
|
}
|
|
600
|
-
|
|
601
324
|
/**
|
|
602
325
|
* Creates LINEAR filter texture.
|
|
603
326
|
* @public
|
|
@@ -606,13 +329,8 @@ class Handler {
|
|
|
606
329
|
* @param {WebGLTexture | null} [texture]
|
|
607
330
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
608
331
|
*/
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
internalFormat?: number,
|
|
612
|
-
texture: WebGLTexture | null = null): WebGLTexture | null {
|
|
613
|
-
|
|
614
|
-
let gl = this.gl!;
|
|
615
|
-
|
|
332
|
+
createTexture_l_webgl2(image, internalFormat, texture = null) {
|
|
333
|
+
let gl = this.gl;
|
|
616
334
|
texture = texture || gl.createTexture();
|
|
617
335
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
618
336
|
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
@@ -623,11 +341,9 @@ class Handler {
|
|
|
623
341
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
624
342
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
625
343
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
626
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
627
|
-
|
|
344
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
628
345
|
return texture;
|
|
629
346
|
}
|
|
630
|
-
|
|
631
347
|
/**
|
|
632
348
|
* Creates MIPMAP filter texture.
|
|
633
349
|
* @public
|
|
@@ -636,13 +352,8 @@ class Handler {
|
|
|
636
352
|
* @param {WebGLTexture | null} [texture]
|
|
637
353
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
638
354
|
*/
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
internalFormat?: number,
|
|
642
|
-
texture: WebGLTexture | null = null): WebGLTexture | null {
|
|
643
|
-
|
|
644
|
-
let gl = this.gl!;
|
|
645
|
-
|
|
355
|
+
createTexture_mm_webgl2(image, internalFormat, texture = null) {
|
|
356
|
+
let gl = this.gl;
|
|
646
357
|
texture = texture || gl.createTexture();
|
|
647
358
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
648
359
|
//gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
|
|
@@ -652,11 +363,9 @@ class Handler {
|
|
|
652
363
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
|
|
653
364
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
654
365
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
655
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
656
|
-
|
|
366
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
657
367
|
return texture;
|
|
658
368
|
}
|
|
659
|
-
|
|
660
369
|
/**
|
|
661
370
|
* Creates ANISOTROPY filter texture.
|
|
662
371
|
* @public
|
|
@@ -665,13 +374,8 @@ class Handler {
|
|
|
665
374
|
* @param {WebGLTexture | null} [texture]
|
|
666
375
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
667
376
|
*/
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
internalFormat?: number,
|
|
671
|
-
texture: WebGLTexture | null = null): WebGLTexture | null {
|
|
672
|
-
|
|
673
|
-
let gl = this.gl!;
|
|
674
|
-
|
|
377
|
+
createTexture_a_webgl2(image, internalFormat, texture = null) {
|
|
378
|
+
let gl = this.gl;
|
|
675
379
|
texture = texture || gl.createTexture();
|
|
676
380
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
677
381
|
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
@@ -683,10 +387,9 @@ class Handler {
|
|
|
683
387
|
gl.texParameterf(gl.TEXTURE_2D, this.extensions.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT, this._params.anisotropy);
|
|
684
388
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
685
389
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
686
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
390
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
687
391
|
return texture;
|
|
688
392
|
}
|
|
689
|
-
|
|
690
393
|
/**
|
|
691
394
|
* Creates cube texture.
|
|
692
395
|
* @public
|
|
@@ -699,18 +402,15 @@ class Handler {
|
|
|
699
402
|
* @param {string} params.nz - Negative Z or back image url.
|
|
700
403
|
* @returns {WebGLTexture | null} - WebGL texture object.
|
|
701
404
|
*/
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
let gl = this.gl!;
|
|
705
|
-
|
|
405
|
+
loadCubeMapTexture(params) {
|
|
406
|
+
let gl = this.gl;
|
|
706
407
|
let texture = gl.createTexture();
|
|
707
408
|
gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
|
|
708
409
|
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
709
410
|
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
710
411
|
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
711
412
|
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
712
|
-
|
|
713
|
-
let faces: [string, number][] = [
|
|
413
|
+
let faces = [
|
|
714
414
|
[params.px, gl.TEXTURE_CUBE_MAP_POSITIVE_X],
|
|
715
415
|
[params.nx, gl.TEXTURE_CUBE_MAP_NEGATIVE_X],
|
|
716
416
|
[params.py, gl.TEXTURE_CUBE_MAP_POSITIVE_Y],
|
|
@@ -718,23 +418,20 @@ class Handler {
|
|
|
718
418
|
[params.pz, gl.TEXTURE_CUBE_MAP_POSITIVE_Z],
|
|
719
419
|
[params.nz, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z]
|
|
720
420
|
];
|
|
721
|
-
|
|
722
421
|
let imageCanvas = new ImageCanvas();
|
|
723
422
|
imageCanvas.fillEmpty();
|
|
724
423
|
let emptyImage = imageCanvas.getImage();
|
|
725
|
-
|
|
726
424
|
for (let i = 0; i < faces.length; i++) {
|
|
727
425
|
let face = faces[i][1];
|
|
728
426
|
gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
|
|
729
427
|
//gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
730
428
|
gl.texImage2D(face, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, emptyImage);
|
|
731
429
|
}
|
|
732
|
-
|
|
733
430
|
for (let i = 0; i < faces.length; i++) {
|
|
734
431
|
let face = faces[i][1];
|
|
735
432
|
let image = new Image();
|
|
736
433
|
image.crossOrigin = "";
|
|
737
|
-
image.onload = (function (texture
|
|
434
|
+
image.onload = (function (texture, face, image) {
|
|
738
435
|
return function () {
|
|
739
436
|
if (gl && texture) {
|
|
740
437
|
gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
|
|
@@ -743,12 +440,10 @@ class Handler {
|
|
|
743
440
|
}
|
|
744
441
|
};
|
|
745
442
|
})(texture, face, image);
|
|
746
|
-
|
|
747
443
|
image.src = faces[i][0];
|
|
748
444
|
}
|
|
749
445
|
return texture;
|
|
750
446
|
}
|
|
751
|
-
|
|
752
447
|
/**
|
|
753
448
|
* Adds shader program to the handler.
|
|
754
449
|
* @public
|
|
@@ -756,7 +451,7 @@ class Handler {
|
|
|
756
451
|
* @param {boolean} [notActivate] - If it's true program will not compile.
|
|
757
452
|
* @return {Program} -
|
|
758
453
|
*/
|
|
759
|
-
|
|
454
|
+
addProgram(program, notActivate = false) {
|
|
760
455
|
if (!this.programs[program.name]) {
|
|
761
456
|
let sc = new ProgramController(this, program);
|
|
762
457
|
this.programs[program.name] = sc;
|
|
@@ -764,61 +459,58 @@ class Handler {
|
|
|
764
459
|
if (notActivate) {
|
|
765
460
|
sc._activated = false;
|
|
766
461
|
}
|
|
767
|
-
}
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
768
464
|
console.warn(`Shader program: "${program.name}" already exists.`);
|
|
769
465
|
}
|
|
770
466
|
return program;
|
|
771
467
|
}
|
|
772
|
-
|
|
773
468
|
/**
|
|
774
469
|
* Removes shader program from handler.
|
|
775
470
|
* @public
|
|
776
471
|
* @param {string} name - Shader program name.
|
|
777
472
|
*/
|
|
778
|
-
|
|
473
|
+
removeProgram(name) {
|
|
779
474
|
this.programs[name] && this.programs[name].remove();
|
|
780
475
|
}
|
|
781
|
-
|
|
782
476
|
/**
|
|
783
477
|
* Adds shader programs to the handler.
|
|
784
478
|
* @public
|
|
785
479
|
* @param {Array.<Program>} programsArr - Shader program array.
|
|
786
480
|
*/
|
|
787
|
-
|
|
481
|
+
addPrograms(programsArr) {
|
|
788
482
|
for (let i = 0; i < programsArr.length; i++) {
|
|
789
483
|
this.addProgram(programsArr[i]);
|
|
790
484
|
}
|
|
791
485
|
}
|
|
792
|
-
|
|
793
486
|
/**
|
|
794
487
|
* Used in addProgram
|
|
795
488
|
* @protected
|
|
796
489
|
* @param {ProgramController} sc - Program controller
|
|
797
490
|
*/
|
|
798
|
-
|
|
491
|
+
_initProgramController(sc) {
|
|
799
492
|
if (this._initialized) {
|
|
800
493
|
sc.initialize();
|
|
801
494
|
if (!this.activeProgram) {
|
|
802
495
|
this.activeProgram = sc;
|
|
803
496
|
sc.activate();
|
|
804
|
-
}
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
805
499
|
sc.deactivate();
|
|
806
500
|
this.activeProgram._program.enableAttribArrays();
|
|
807
501
|
this.activeProgram._program.use();
|
|
808
502
|
}
|
|
809
503
|
}
|
|
810
504
|
}
|
|
811
|
-
|
|
812
505
|
/**
|
|
813
506
|
* Used in init function.
|
|
814
507
|
* @private
|
|
815
508
|
*/
|
|
816
|
-
|
|
509
|
+
_initPrograms() {
|
|
817
510
|
for (let p in this.programs) {
|
|
818
511
|
this._initProgramController(this.programs[p]);
|
|
819
512
|
}
|
|
820
513
|
}
|
|
821
|
-
|
|
822
514
|
/**
|
|
823
515
|
* Initialize additional WebGL extensions.
|
|
824
516
|
* @public
|
|
@@ -826,39 +518,33 @@ class Handler {
|
|
|
826
518
|
* @param {boolean} showLog - Show logging.
|
|
827
519
|
* @return {any} -
|
|
828
520
|
*/
|
|
829
|
-
|
|
521
|
+
initializeExtension(extensionStr, showLog = false) {
|
|
830
522
|
if (!(this.extensions && this.extensions[extensionStr])) {
|
|
831
523
|
let ext = Handler.getExtension(this.gl, extensionStr);
|
|
832
524
|
if (ext) {
|
|
833
525
|
this.extensions[extensionStr] = ext;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
);
|
|
526
|
+
}
|
|
527
|
+
else if (showLog) {
|
|
528
|
+
console.warn("og.webgl.Handler: extension '" + extensionStr + "' doesn't initialize.");
|
|
838
529
|
}
|
|
839
530
|
}
|
|
840
531
|
return this.extensions && this.extensions[extensionStr];
|
|
841
532
|
}
|
|
842
|
-
|
|
843
533
|
/**
|
|
844
534
|
* Main function that initialize handler.
|
|
845
535
|
* @public
|
|
846
536
|
*/
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
537
|
+
initialize() {
|
|
538
|
+
if (this._initialized)
|
|
539
|
+
return;
|
|
540
|
+
if (!this.canvas)
|
|
541
|
+
return;
|
|
853
542
|
this.gl = Handler.getContext(this.canvas, this._params.context);
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
543
|
+
if (!this.gl)
|
|
544
|
+
return;
|
|
857
545
|
this._initialized = true;
|
|
858
|
-
|
|
859
546
|
/** Sets default extensions */
|
|
860
547
|
this._params.extensions.push("EXT_texture_filter_anisotropic");
|
|
861
|
-
|
|
862
548
|
if (this.gl.type === "webgl") {
|
|
863
549
|
this._params.extensions.push("OES_standard_derivatives");
|
|
864
550
|
this._params.extensions.push("OES_element_index_uint");
|
|
@@ -866,105 +552,91 @@ class Handler {
|
|
|
866
552
|
this._params.extensions.push("ANGLE_instanced_arrays");
|
|
867
553
|
//this._params.extensions.push("WEBGL_draw_buffers");
|
|
868
554
|
//this._params.extensions.push("EXT_frag_depth");
|
|
869
|
-
}
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
870
557
|
this._params.extensions.push("EXT_color_buffer_float");
|
|
871
558
|
this._params.extensions.push("OES_texture_float_linear");
|
|
872
559
|
//this._params.extensions.push("WEBGL_draw_buffers");
|
|
873
560
|
}
|
|
874
|
-
|
|
875
561
|
let i = this._params.extensions.length;
|
|
876
562
|
while (i--) {
|
|
877
563
|
this.initializeExtension(this._params.extensions[i], true);
|
|
878
564
|
}
|
|
879
|
-
|
|
880
565
|
if (this.gl.type === "webgl") {
|
|
881
566
|
this.createTexture_n = this.createTexture_n_webgl1.bind(this);
|
|
882
567
|
this.createTexture_l = this.createTexture_l_webgl1.bind(this);
|
|
883
568
|
this.createTexture_mm = this.createTexture_mm_webgl1.bind(this);
|
|
884
569
|
this.createTexture_a = this.createTexture_a_webgl1.bind(this);
|
|
885
|
-
}
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
886
572
|
this.createTexture_n = this.createTexture_n_webgl2.bind(this);
|
|
887
573
|
this.createTexture_l = this.createTexture_l_webgl2.bind(this);
|
|
888
574
|
this.createTexture_mm = this.createTexture_mm_webgl2.bind(this);
|
|
889
575
|
this.createTexture_a = this.createTexture_a_webgl2.bind(this);
|
|
890
576
|
}
|
|
891
|
-
|
|
892
577
|
this.createTexture["NEAREST"] = this.createTexture_n;
|
|
893
578
|
this.createTexture["LINEAR"] = this.createTexture_l;
|
|
894
579
|
this.createTexture["MIPMAP"] = this.createTexture_mm;
|
|
895
580
|
this.createTexture["ANISOTROPIC"] = this.createTexture_a;
|
|
896
|
-
|
|
897
581
|
if (!this.extensions.EXT_texture_filter_anisotropic) {
|
|
898
582
|
this.createTextureDefault = this.createTexture_mm;
|
|
899
|
-
}
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
900
585
|
this.createTextureDefault = this.createTexture_a;
|
|
901
586
|
}
|
|
902
|
-
|
|
903
587
|
/** Initializing shaders and rendering parameters*/
|
|
904
588
|
this._initPrograms();
|
|
905
589
|
this._setDefaults();
|
|
906
|
-
|
|
907
590
|
this.intersectionObserver = new IntersectionObserver((entries) => {
|
|
908
591
|
this._toggleVisibilityChange(entries[0].isIntersecting);
|
|
909
|
-
}, {threshold: 0});
|
|
910
|
-
|
|
592
|
+
}, { threshold: 0 });
|
|
911
593
|
this.intersectionObserver.observe(this.canvas);
|
|
912
|
-
|
|
913
594
|
this.resizeObserver = new ResizeObserver(entries => {
|
|
914
595
|
this._toggleVisibilityChange(entries[0].contentRect.width !== 0 && entries[0].contentRect.height !== 0);
|
|
915
596
|
});
|
|
916
|
-
|
|
917
597
|
this.resizeObserver.observe(this.canvas);
|
|
918
|
-
|
|
919
598
|
document.addEventListener("visibilitychange", () => {
|
|
920
599
|
this._toggleVisibilityChange(document.visibilityState === 'visible');
|
|
921
600
|
});
|
|
922
601
|
}
|
|
923
|
-
|
|
924
|
-
protected _toggleVisibilityChange(visibility: boolean) {
|
|
602
|
+
_toggleVisibilityChange(visibility) {
|
|
925
603
|
if (visibility) {
|
|
926
604
|
this.start();
|
|
927
605
|
this.ONCANVASRESIZE && this.ONCANVASRESIZE();
|
|
928
606
|
this.events.dispatch(this.events.visibilitychange, true);
|
|
929
|
-
}
|
|
607
|
+
}
|
|
608
|
+
else {
|
|
930
609
|
this.events.dispatch(this.events.visibilitychange, false);
|
|
931
610
|
this.stop();
|
|
932
611
|
}
|
|
933
612
|
}
|
|
934
|
-
|
|
935
613
|
/**
|
|
936
614
|
* Sets default gl render parameters. Used in init function.
|
|
937
615
|
* @protected
|
|
938
616
|
*/
|
|
939
|
-
|
|
940
|
-
|
|
617
|
+
_setDefaults() {
|
|
941
618
|
let gl = this.gl;
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
if (!this.canvas)
|
|
945
|
-
|
|
619
|
+
if (!gl)
|
|
620
|
+
return;
|
|
621
|
+
if (!this.canvas)
|
|
622
|
+
return;
|
|
946
623
|
gl.depthFunc(gl.LESS);
|
|
947
624
|
gl.enable(gl.DEPTH_TEST);
|
|
948
|
-
this.setSize(
|
|
949
|
-
this.canvas.clientWidth || this._params.width,
|
|
950
|
-
this.canvas.clientHeight || this._params.height
|
|
951
|
-
);
|
|
625
|
+
this.setSize(this.canvas.clientWidth || this._params.width, this.canvas.clientHeight || this._params.height);
|
|
952
626
|
gl.frontFace(gl.CCW);
|
|
953
627
|
gl.cullFace(gl.BACK);
|
|
954
628
|
gl.enable(gl.CULL_FACE);
|
|
955
629
|
gl.disable(gl.BLEND);
|
|
956
|
-
this.createDefaultTexture({color: "rgba(0,0,0,0.0)"}, (t
|
|
630
|
+
this.createDefaultTexture({ color: "rgba(0,0,0,0.0)" }, (t) => {
|
|
957
631
|
this.transparentTexture = t;
|
|
958
632
|
});
|
|
959
|
-
this.createDefaultTexture({color: "rgba(255, 255, 255, 1.0)"}, (t
|
|
633
|
+
this.createDefaultTexture({ color: "rgba(255, 255, 255, 1.0)" }, (t) => {
|
|
960
634
|
this.defaultTexture = t;
|
|
961
635
|
});
|
|
962
636
|
}
|
|
963
|
-
|
|
964
|
-
public getCanvasSize(): NumberArray2 {
|
|
637
|
+
getCanvasSize() {
|
|
965
638
|
return this._canvasSize;
|
|
966
639
|
}
|
|
967
|
-
|
|
968
640
|
/**
|
|
969
641
|
* Creates STREAM_DRAW ARRAY buffer.
|
|
970
642
|
* @public
|
|
@@ -974,21 +646,16 @@ class Handler {
|
|
|
974
646
|
* @param {number} [bytes=4] -
|
|
975
647
|
* @return {WebGLBufferExt} -
|
|
976
648
|
*/
|
|
977
|
-
|
|
978
|
-
let gl = this.gl
|
|
979
|
-
let buffer
|
|
649
|
+
createStreamArrayBuffer(itemSize, numItems, usage, bytes = 4) {
|
|
650
|
+
let gl = this.gl;
|
|
651
|
+
let buffer = gl.createBuffer();
|
|
980
652
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
981
|
-
gl.bufferData(
|
|
982
|
-
|
|
983
|
-
numItems * itemSize * bytes,
|
|
984
|
-
usage || gl.STREAM_DRAW
|
|
985
|
-
);
|
|
986
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null!);
|
|
653
|
+
gl.bufferData(gl.ARRAY_BUFFER, numItems * itemSize * bytes, usage || gl.STREAM_DRAW);
|
|
654
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
987
655
|
buffer.itemSize = itemSize;
|
|
988
656
|
buffer.numItems = numItems;
|
|
989
657
|
return buffer;
|
|
990
658
|
}
|
|
991
|
-
|
|
992
659
|
/**
|
|
993
660
|
* Sets stream buffer.
|
|
994
661
|
* @public
|
|
@@ -997,14 +664,13 @@ class Handler {
|
|
|
997
664
|
* @param {number} [offset=0] -
|
|
998
665
|
* @return {WebGLBufferExt} -
|
|
999
666
|
*/
|
|
1000
|
-
|
|
1001
|
-
let gl = this.gl
|
|
667
|
+
setStreamArrayBuffer(buffer, array, offset = 0) {
|
|
668
|
+
let gl = this.gl;
|
|
1002
669
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
1003
670
|
gl.bufferSubData(gl.ARRAY_BUFFER, offset, array);
|
|
1004
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null
|
|
671
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
1005
672
|
return buffer;
|
|
1006
673
|
}
|
|
1007
|
-
|
|
1008
674
|
/**
|
|
1009
675
|
* Creates ARRAY buffer.
|
|
1010
676
|
* @public
|
|
@@ -1014,17 +680,16 @@ class Handler {
|
|
|
1014
680
|
* @param {number} [usage=STATIC_DRAW] - Parameter of the bufferData call can be one of STATIC_DRAW, DYNAMIC_DRAW, or STREAM_DRAW.
|
|
1015
681
|
* @return {WebGLBufferExt} -
|
|
1016
682
|
*/
|
|
1017
|
-
|
|
1018
|
-
let gl = this.gl
|
|
1019
|
-
let buffer
|
|
683
|
+
createArrayBuffer(array, itemSize, numItems, usage) {
|
|
684
|
+
let gl = this.gl;
|
|
685
|
+
let buffer = gl.createBuffer();
|
|
1020
686
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
1021
687
|
gl.bufferData(gl.ARRAY_BUFFER, array, usage || gl.STATIC_DRAW);
|
|
1022
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null
|
|
688
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
1023
689
|
buffer.itemSize = itemSize;
|
|
1024
690
|
buffer.numItems = numItems;
|
|
1025
691
|
return buffer;
|
|
1026
692
|
}
|
|
1027
|
-
|
|
1028
693
|
/**
|
|
1029
694
|
* Creates ARRAY buffer specific length.
|
|
1030
695
|
* @public
|
|
@@ -1032,17 +697,16 @@ class Handler {
|
|
|
1032
697
|
* @param {number} [usage=STATIC_DRAW] - Parameter of the bufferData call can be one of STATIC_DRAW, DYNAMIC_DRAW, or STREAM_DRAW.
|
|
1033
698
|
* @return {WebGLBufferExt} -
|
|
1034
699
|
*/
|
|
1035
|
-
|
|
1036
|
-
let gl = this.gl
|
|
1037
|
-
let buffer
|
|
700
|
+
createArrayBufferLength(size, usage) {
|
|
701
|
+
let gl = this.gl;
|
|
702
|
+
let buffer = gl.createBuffer();
|
|
1038
703
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
|
1039
704
|
gl.bufferData(gl.ARRAY_BUFFER, size, usage || gl.STATIC_DRAW);
|
|
1040
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null
|
|
705
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
1041
706
|
buffer.itemSize = 1;
|
|
1042
707
|
buffer.numItems = size;
|
|
1043
708
|
return buffer;
|
|
1044
709
|
}
|
|
1045
|
-
|
|
1046
710
|
/**
|
|
1047
711
|
* Creates ELEMENT ARRAY buffer.
|
|
1048
712
|
* @public
|
|
@@ -1052,241 +716,209 @@ class Handler {
|
|
|
1052
716
|
* @param {number} [usage=STATIC_DRAW] - Parameter of the bufferData call can be one of STATIC_DRAW, DYNAMIC_DRAW, or STREAM_DRAW.
|
|
1053
717
|
* @return {Object} -
|
|
1054
718
|
*/
|
|
1055
|
-
|
|
1056
|
-
let gl = this.gl
|
|
1057
|
-
let buffer = gl.createBuffer()
|
|
719
|
+
createElementArrayBuffer(array, itemSize, numItems, usage) {
|
|
720
|
+
let gl = this.gl;
|
|
721
|
+
let buffer = gl.createBuffer();
|
|
1058
722
|
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer);
|
|
1059
723
|
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, array, usage || gl.STATIC_DRAW);
|
|
1060
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null
|
|
724
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
1061
725
|
buffer.itemSize = itemSize;
|
|
1062
726
|
buffer.numItems = numItems || array.length;
|
|
1063
727
|
return buffer;
|
|
1064
728
|
}
|
|
1065
|
-
|
|
1066
729
|
/**
|
|
1067
730
|
* Sets handler canvas size.
|
|
1068
731
|
* @public
|
|
1069
732
|
* @param {number} w - Canvas width.
|
|
1070
733
|
* @param {number} h - Canvas height.
|
|
1071
734
|
*/
|
|
1072
|
-
|
|
735
|
+
setSize(w, h) {
|
|
1073
736
|
this._params.width = w;
|
|
1074
737
|
this._params.height = h;
|
|
1075
738
|
if (this.canvas) {
|
|
1076
739
|
this.canvas.width = w * this._params.pixelRatio;
|
|
1077
740
|
this.canvas.height = h * this._params.pixelRatio;
|
|
1078
|
-
|
|
1079
741
|
this._canvasSize[0] = this.canvas.width;
|
|
1080
742
|
this._canvasSize[1] = this.canvas.height;
|
|
1081
|
-
|
|
1082
743
|
this._oneByHeight = 1.0 / this.canvas.height;
|
|
1083
|
-
|
|
1084
744
|
this.gl && this.gl.viewport(0, 0, w, h);
|
|
1085
745
|
this.ONCANVASRESIZE && this.ONCANVASRESIZE(this.canvas);
|
|
1086
746
|
this.events.dispatch(this.events.resize, this);
|
|
1087
747
|
}
|
|
1088
748
|
}
|
|
1089
|
-
|
|
1090
|
-
public get pixelRatio(): number {
|
|
749
|
+
get pixelRatio() {
|
|
1091
750
|
return this._params.pixelRatio;
|
|
1092
751
|
}
|
|
1093
|
-
|
|
1094
|
-
public set pixelRatio(pr: number) {
|
|
752
|
+
set pixelRatio(pr) {
|
|
1095
753
|
this._params.pixelRatio = pr;
|
|
1096
754
|
this.setSize(this._params.width, this._params.height);
|
|
1097
755
|
}
|
|
1098
|
-
|
|
1099
756
|
/**
|
|
1100
757
|
* Returns context screen width.
|
|
1101
758
|
* @public
|
|
1102
759
|
* @returns {number} -
|
|
1103
760
|
*/
|
|
1104
|
-
|
|
761
|
+
getWidth() {
|
|
1105
762
|
return this.canvas ? this.canvas.width : 0;
|
|
1106
763
|
}
|
|
1107
|
-
|
|
1108
764
|
/**
|
|
1109
765
|
* Returns context screen height.
|
|
1110
766
|
* @public
|
|
1111
767
|
* @returns {number} -
|
|
1112
768
|
*/
|
|
1113
|
-
|
|
769
|
+
getHeight() {
|
|
1114
770
|
return this.canvas ? this.canvas.height : 0;
|
|
1115
771
|
}
|
|
1116
|
-
|
|
1117
772
|
/**
|
|
1118
773
|
* Returns canvas aspect ratio.
|
|
1119
774
|
* @public
|
|
1120
775
|
* @returns {number} -
|
|
1121
776
|
*/
|
|
1122
|
-
|
|
777
|
+
getClientAspect() {
|
|
1123
778
|
return this.canvas ? this.canvas.clientWidth / this.canvas.clientHeight : 0;
|
|
1124
779
|
}
|
|
1125
|
-
|
|
1126
780
|
/**
|
|
1127
781
|
* Returns canvas center coordinates.
|
|
1128
782
|
* @public
|
|
1129
783
|
* @returns {number} -
|
|
1130
784
|
*/
|
|
1131
|
-
|
|
785
|
+
getCenter() {
|
|
1132
786
|
let c = this.canvas;
|
|
1133
787
|
return c ? new Vec2(Math.round(c.width * 0.5), Math.round(c.height * 0.5)) : new Vec2();
|
|
1134
788
|
}
|
|
1135
|
-
|
|
1136
789
|
/**
|
|
1137
790
|
* Draw single frame.
|
|
1138
791
|
* @public
|
|
1139
792
|
*/
|
|
1140
|
-
|
|
793
|
+
drawFrame() {
|
|
1141
794
|
/** Calculating frame time */
|
|
1142
795
|
let now = window.performance.now();
|
|
1143
796
|
this.deltaTime = now - this._lastAnimationFrameTime;
|
|
1144
797
|
this._lastAnimationFrameTime = now;
|
|
1145
|
-
|
|
1146
798
|
this.defaultClock.tick(this.deltaTime);
|
|
1147
|
-
|
|
1148
799
|
for (let i = 0; i < this._clocks.length; i++) {
|
|
1149
800
|
this._clocks[i].tick(this.deltaTime);
|
|
1150
801
|
}
|
|
1151
|
-
|
|
1152
802
|
/** Canvas resize checking */
|
|
1153
|
-
let canvas = this.canvas
|
|
1154
|
-
|
|
803
|
+
let canvas = this.canvas;
|
|
1155
804
|
if (Math.floor(canvas.clientWidth * this._params.pixelRatio) !== canvas.width || Math.floor(canvas.clientHeight * this._params.pixelRatio) !== canvas.height) {
|
|
1156
805
|
if (canvas.clientWidth === 0 || canvas.clientHeight === 0) {
|
|
1157
806
|
this.stop();
|
|
1158
|
-
}
|
|
807
|
+
}
|
|
808
|
+
else if (!document.hidden) {
|
|
1159
809
|
this.start();
|
|
1160
810
|
this.setSize(canvas.clientWidth, canvas.clientHeight);
|
|
1161
811
|
}
|
|
1162
812
|
}
|
|
1163
|
-
|
|
1164
813
|
/** Draw frame */
|
|
1165
814
|
this._frameCallback();
|
|
1166
815
|
}
|
|
1167
|
-
|
|
1168
816
|
/**
|
|
1169
817
|
* Clearing gl frame.
|
|
1170
818
|
* @public
|
|
1171
819
|
*/
|
|
1172
|
-
|
|
1173
|
-
let gl = this.gl
|
|
820
|
+
clearFrame() {
|
|
821
|
+
let gl = this.gl;
|
|
1174
822
|
gl.clearColor(0.0, 0.0, 0.0, 1.0);
|
|
1175
823
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
1176
824
|
}
|
|
1177
|
-
|
|
1178
825
|
/**
|
|
1179
826
|
* Starts animation loop.
|
|
1180
827
|
* @public
|
|
1181
828
|
*/
|
|
1182
|
-
|
|
829
|
+
start() {
|
|
1183
830
|
if (!this._requestAnimationFrameId && this._initialized) {
|
|
1184
831
|
this._animationFrameCallback();
|
|
1185
832
|
}
|
|
1186
833
|
}
|
|
1187
|
-
|
|
1188
|
-
public stop() {
|
|
834
|
+
stop() {
|
|
1189
835
|
if (this._requestAnimationFrameId) {
|
|
1190
836
|
window.cancelAnimationFrame(this._requestAnimationFrameId);
|
|
1191
837
|
this._requestAnimationFrameId = 0;
|
|
1192
838
|
}
|
|
1193
839
|
}
|
|
1194
|
-
|
|
1195
|
-
public isStopped(): boolean {
|
|
840
|
+
isStopped() {
|
|
1196
841
|
return !this._requestAnimationFrameId;
|
|
1197
842
|
}
|
|
1198
|
-
|
|
1199
843
|
/**
|
|
1200
844
|
* Check is gl context type equals webgl2
|
|
1201
845
|
* @public
|
|
1202
846
|
*/
|
|
1203
|
-
|
|
847
|
+
isWebGl2() {
|
|
1204
848
|
return this.gl ? this.gl.type === "webgl2" : false;
|
|
1205
849
|
}
|
|
1206
|
-
|
|
1207
850
|
/**
|
|
1208
851
|
* Make animation.
|
|
1209
852
|
* @protected
|
|
1210
853
|
*/
|
|
1211
|
-
|
|
854
|
+
_animationFrameCallback() {
|
|
1212
855
|
this._requestAnimationFrameId = window.requestAnimationFrame(() => {
|
|
1213
856
|
this.drawFrame();
|
|
1214
857
|
this._requestAnimationFrameId && this._animationFrameCallback();
|
|
1215
858
|
});
|
|
1216
859
|
}
|
|
1217
|
-
|
|
1218
860
|
/**
|
|
1219
861
|
* Creates default texture object
|
|
1220
862
|
* @public
|
|
1221
863
|
* @param {IDefaultTextureParams | null} params - Texture parameters:
|
|
1222
864
|
* @param {(texture: WebGLTextureExt) => void} [success] - Creation callback
|
|
1223
865
|
*/
|
|
1224
|
-
|
|
1225
|
-
|
|
866
|
+
createDefaultTexture(params, success) {
|
|
1226
867
|
let imgCnv;
|
|
1227
868
|
let texture;
|
|
1228
|
-
|
|
1229
869
|
if (params && params.color) {
|
|
1230
870
|
imgCnv = new ImageCanvas(2, 2);
|
|
1231
871
|
imgCnv.fillColor(params.color);
|
|
1232
|
-
texture = this.createTexture_n(imgCnv.getCanvas())
|
|
872
|
+
texture = this.createTexture_n(imgCnv.getCanvas());
|
|
1233
873
|
texture.default = true;
|
|
1234
874
|
success(texture);
|
|
1235
|
-
}
|
|
875
|
+
}
|
|
876
|
+
else if (params && params.url) {
|
|
1236
877
|
let img = new Image();
|
|
1237
878
|
let that = this;
|
|
1238
879
|
img.onload = function () {
|
|
1239
|
-
texture = that.createTextureDefault(img)
|
|
880
|
+
texture = that.createTextureDefault(img);
|
|
1240
881
|
texture.default = true;
|
|
1241
882
|
success(texture);
|
|
1242
883
|
};
|
|
1243
884
|
img.src = params.url;
|
|
1244
|
-
}
|
|
885
|
+
}
|
|
886
|
+
else {
|
|
1245
887
|
imgCnv = new ImageCanvas(2, 2);
|
|
1246
888
|
imgCnv.fillColor("#C5C5C5");
|
|
1247
|
-
texture = this.createTexture_n(imgCnv.getCanvas())
|
|
889
|
+
texture = this.createTexture_n(imgCnv.getCanvas());
|
|
1248
890
|
texture.default = true;
|
|
1249
891
|
success(texture);
|
|
1250
892
|
}
|
|
1251
893
|
}
|
|
1252
|
-
|
|
1253
|
-
public deleteTexture(texture: WebGLTextureExt | null | undefined) {
|
|
894
|
+
deleteTexture(texture) {
|
|
1254
895
|
if (texture && !texture.default) {
|
|
1255
|
-
this.gl
|
|
896
|
+
this.gl.deleteTexture(texture);
|
|
1256
897
|
}
|
|
1257
898
|
}
|
|
1258
|
-
|
|
1259
899
|
/**
|
|
1260
900
|
* @public
|
|
1261
901
|
*/
|
|
1262
|
-
|
|
1263
|
-
|
|
902
|
+
destroy() {
|
|
1264
903
|
this.resizeObserver?.disconnect();
|
|
1265
904
|
this.intersectionObserver?.disconnect();
|
|
1266
|
-
|
|
1267
905
|
this.stop();
|
|
1268
|
-
|
|
1269
906
|
//
|
|
1270
907
|
// Dispose shaders
|
|
1271
908
|
//
|
|
1272
909
|
for (let p in this.programs) {
|
|
1273
910
|
this.removeProgram(p);
|
|
1274
911
|
}
|
|
1275
|
-
|
|
1276
912
|
//
|
|
1277
913
|
// Clear WebGL context
|
|
1278
914
|
//
|
|
1279
915
|
let gl = this.gl;
|
|
1280
|
-
|
|
1281
916
|
if (gl) {
|
|
1282
|
-
gl.deleteTexture(this.transparentTexture
|
|
917
|
+
gl.deleteTexture(this.transparentTexture);
|
|
1283
918
|
this.transparentTexture = null;
|
|
1284
|
-
|
|
1285
|
-
gl.deleteTexture(this.defaultTexture as WebGLTexture);
|
|
919
|
+
gl.deleteTexture(this.defaultTexture);
|
|
1286
920
|
this.defaultTexture = null;
|
|
1287
|
-
|
|
1288
921
|
this.framebufferStack = new Stack();
|
|
1289
|
-
|
|
1290
922
|
//
|
|
1291
923
|
// Clear attrib pointers
|
|
1292
924
|
//
|
|
@@ -1299,26 +931,24 @@ class Handler {
|
|
|
1299
931
|
gl.vertexAttrib1f(ii, 0);
|
|
1300
932
|
}
|
|
1301
933
|
gl.deleteBuffer(tmp);
|
|
1302
|
-
|
|
1303
934
|
//
|
|
1304
935
|
// Clear all possible textures
|
|
1305
936
|
//
|
|
1306
937
|
let numTextureUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
|
|
1307
938
|
for (let ii = 0; ii < numTextureUnits; ++ii) {
|
|
1308
939
|
gl.activeTexture(gl.TEXTURE0 + ii);
|
|
1309
|
-
gl.bindTexture(gl.TEXTURE_CUBE_MAP, null
|
|
1310
|
-
gl.bindTexture(gl.TEXTURE_2D, null
|
|
940
|
+
gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);
|
|
941
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
1311
942
|
}
|
|
1312
|
-
|
|
1313
943
|
//
|
|
1314
944
|
// Hard reset
|
|
1315
945
|
//
|
|
1316
946
|
gl.activeTexture(gl.TEXTURE0);
|
|
1317
|
-
gl.useProgram(null
|
|
1318
|
-
gl.bindBuffer(gl.ARRAY_BUFFER, null
|
|
1319
|
-
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null
|
|
1320
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, null
|
|
1321
|
-
gl.bindRenderbuffer(gl.RENDERBUFFER, null
|
|
947
|
+
gl.useProgram(null);
|
|
948
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
949
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
950
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
951
|
+
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
|
|
1322
952
|
gl.disable(gl.BLEND);
|
|
1323
953
|
gl.disable(gl.CULL_FACE);
|
|
1324
954
|
gl.disable(gl.DEPTH_TEST);
|
|
@@ -1331,7 +961,6 @@ class Handler {
|
|
|
1331
961
|
gl.clearDepth(1);
|
|
1332
962
|
gl.clearStencil(-1);
|
|
1333
963
|
}
|
|
1334
|
-
|
|
1335
964
|
//
|
|
1336
965
|
// Destroy canvas
|
|
1337
966
|
//
|
|
@@ -1343,26 +972,21 @@ class Handler {
|
|
|
1343
972
|
this.canvas.height = 1;
|
|
1344
973
|
this.canvas = null;
|
|
1345
974
|
}
|
|
1346
|
-
|
|
1347
975
|
this.gl = null;
|
|
1348
|
-
|
|
1349
976
|
this._initialized = false;
|
|
1350
977
|
}
|
|
1351
|
-
|
|
1352
|
-
public addClock(clock: Clock) {
|
|
978
|
+
addClock(clock) {
|
|
1353
979
|
if (!clock.__handler) {
|
|
1354
980
|
clock.__handler = this;
|
|
1355
981
|
this._clocks.push(clock);
|
|
1356
982
|
}
|
|
1357
983
|
}
|
|
1358
|
-
|
|
1359
|
-
public addClocks(clockArr: Clock[]) {
|
|
984
|
+
addClocks(clockArr) {
|
|
1360
985
|
for (let i = 0; i < clockArr.length; i++) {
|
|
1361
986
|
this.addClock(clockArr[i]);
|
|
1362
987
|
}
|
|
1363
988
|
}
|
|
1364
|
-
|
|
1365
|
-
public removeClock(clock: Clock) {
|
|
989
|
+
removeClock(clock) {
|
|
1366
990
|
if (clock.__handler) {
|
|
1367
991
|
let c = this._clocks;
|
|
1368
992
|
let i = c.length;
|
|
@@ -1375,40 +999,5 @@ class Handler {
|
|
|
1375
999
|
}
|
|
1376
1000
|
}
|
|
1377
1001
|
}
|
|
1378
|
-
|
|
1379
|
-
// var loadTextureData = function(textureName, callback) {
|
|
1380
|
-
// const xhr = new XMLHttpRequest();
|
|
1381
|
-
// xhr.open('GET', textureName);
|
|
1382
|
-
// xhr.responseType = 'arraybuffer';
|
|
1383
|
-
// xhr.onload = (event) => {
|
|
1384
|
-
// const data = new DataView(xhr.response);
|
|
1385
|
-
// const array =
|
|
1386
|
-
// new Float32Array(data.byteLength / Float32Array.BYTES_PER_ELEMENT);
|
|
1387
|
-
// for (let i = 0; i < array.length; ++i) {
|
|
1388
|
-
// array[i] = data.getFloat32(i * Float32Array.BYTES_PER_ELEMENT, true);
|
|
1389
|
-
// }
|
|
1390
|
-
// callback(array);
|
|
1391
|
-
// };
|
|
1392
|
-
// xhr.send();
|
|
1393
|
-
// }
|
|
1394
|
-
|
|
1395
|
-
// loadTextureData('transmittance.dat', (data) => {
|
|
1396
|
-
//
|
|
1397
|
-
// let gl = this.renderer.handler.gl;
|
|
1398
|
-
//
|
|
1399
|
-
// const texture = gl.createTexture();
|
|
1400
|
-
// gl.activeTexture(gl.TEXTURE0);
|
|
1401
|
-
// gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
1402
|
-
// gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
1403
|
-
// gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
1404
|
-
// gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
1405
|
-
// gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
1406
|
-
// gl.texImage2D(gl.TEXTURE_2D, 0, gl.getExtension('OES_texture_float_linear') ? gl.RGBA32F : gl.RGBA16F,
|
|
1407
|
-
// TRANSMITTANCE_TEXTURE_WIDTH, TRANSMITTANCE_TEXTURE_HEIGHT, 0, gl.RGBA,
|
|
1408
|
-
// gl.FLOAT, data);
|
|
1409
|
-
//
|
|
1410
|
-
// this.transmittanceTextureBrn = texture;
|
|
1411
|
-
// });
|
|
1412
1002
|
}
|
|
1413
|
-
|
|
1414
|
-
export {Handler};
|
|
1003
|
+
export { Handler };
|