@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,8 +1,7 @@
|
|
|
1
1
|
import * as math from "../math";
|
|
2
|
-
import {Vec3} from "./Vec3";
|
|
3
|
-
import {Mat4} from "./Mat4";
|
|
4
|
-
import {Mat3} from "./Mat3";
|
|
5
|
-
|
|
2
|
+
import { Vec3 } from "./Vec3";
|
|
3
|
+
import { Mat4 } from "./Mat4";
|
|
4
|
+
import { Mat3 } from "./Mat3";
|
|
6
5
|
/**
|
|
7
6
|
* A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space.
|
|
8
7
|
* @constructor
|
|
@@ -12,87 +11,50 @@ import {Mat3} from "./Mat3";
|
|
|
12
11
|
* @param {Number} [w=0.0] The W component.
|
|
13
12
|
*/
|
|
14
13
|
export class Quat {
|
|
15
|
-
|
|
16
|
-
* The X component.
|
|
17
|
-
* @public
|
|
18
|
-
* @type {Number}
|
|
19
|
-
* @default 0.0
|
|
20
|
-
*/
|
|
21
|
-
public x: number;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The Y component.
|
|
25
|
-
* @public
|
|
26
|
-
* @type {Number}
|
|
27
|
-
* @default 0.0
|
|
28
|
-
*/
|
|
29
|
-
public y: number;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The Z component.
|
|
33
|
-
* @public
|
|
34
|
-
* @type {Number}
|
|
35
|
-
* @default 0.0
|
|
36
|
-
*/
|
|
37
|
-
public z: number;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The W component.
|
|
41
|
-
* @public
|
|
42
|
-
* @type {Number}
|
|
43
|
-
* @default 0.0
|
|
44
|
-
*/
|
|
45
|
-
public w: number;
|
|
46
|
-
|
|
47
|
-
constructor(x: number = 0.0, y: number = 0.0, z: number = 0.0, w: number = 0.0) {
|
|
14
|
+
constructor(x = 0.0, y = 0.0, z = 0.0, w = 0.0) {
|
|
48
15
|
this.x = x;
|
|
49
16
|
this.y = y;
|
|
50
17
|
this.z = z;
|
|
51
18
|
this.w = w;
|
|
52
19
|
}
|
|
53
|
-
|
|
54
20
|
/**
|
|
55
21
|
* Identity Quat.
|
|
56
22
|
* @const
|
|
57
23
|
* @type {Quat}
|
|
58
24
|
*/
|
|
59
|
-
static get IDENTITY()
|
|
25
|
+
static get IDENTITY() {
|
|
60
26
|
return new Quat(0.0, 0.0, 0.0, 1.0);
|
|
61
27
|
}
|
|
62
|
-
|
|
63
28
|
/**
|
|
64
29
|
* Returns a Quat represents rotation around X axis.
|
|
65
30
|
* @static
|
|
66
31
|
* @param {number} a - The angle in radians to rotate around the axis.
|
|
67
32
|
* @returns {Quat} -
|
|
68
33
|
*/
|
|
69
|
-
static xRotation(a
|
|
34
|
+
static xRotation(a) {
|
|
70
35
|
a *= 0.5;
|
|
71
36
|
return new Quat(Math.sin(a), 0.0, 0.0, Math.cos(a));
|
|
72
37
|
}
|
|
73
|
-
|
|
74
38
|
/**
|
|
75
39
|
* Returns a Quat represents rotation around Y axis.
|
|
76
40
|
* @static
|
|
77
41
|
* @param {number} a - The angle in radians to rotate around the axis.
|
|
78
42
|
* @returns {Quat} -
|
|
79
43
|
*/
|
|
80
|
-
static yRotation(a
|
|
44
|
+
static yRotation(a) {
|
|
81
45
|
a *= 0.5;
|
|
82
46
|
return new Quat(0.0, Math.sin(a), 0.0, Math.cos(a));
|
|
83
47
|
}
|
|
84
|
-
|
|
85
48
|
/**
|
|
86
49
|
* Returns a Quat represents rotation around Z axis.
|
|
87
50
|
* @static
|
|
88
51
|
* @param {number} a - The angle in radians to rotate around the axis.
|
|
89
52
|
* @returns {Quat} -
|
|
90
53
|
*/
|
|
91
|
-
static zRotation(a
|
|
54
|
+
static zRotation(a) {
|
|
92
55
|
a *= 0.5;
|
|
93
56
|
return new Quat(0.0, 0.0, Math.sin(a), Math.cos(a));
|
|
94
57
|
}
|
|
95
|
-
|
|
96
58
|
/**
|
|
97
59
|
* Computes a Quat representing a rotation around an axis.
|
|
98
60
|
* @static
|
|
@@ -100,13 +62,12 @@ export class Quat {
|
|
|
100
62
|
* @param {number} [angle=0.0] The angle in radians to rotate around the axis.
|
|
101
63
|
* @returns {Quat} -
|
|
102
64
|
*/
|
|
103
|
-
static axisAngleToQuat(axis
|
|
65
|
+
static axisAngleToQuat(axis, angle = 0) {
|
|
104
66
|
let v = axis.getNormal();
|
|
105
67
|
let half_angle = angle * 0.5;
|
|
106
68
|
let sin_a = Math.sin(half_angle);
|
|
107
69
|
return new Quat(v.x * sin_a, v.y * sin_a, v.z * sin_a, Math.cos(half_angle));
|
|
108
70
|
}
|
|
109
|
-
|
|
110
71
|
/**
|
|
111
72
|
* Computes a rotation from the given heading and up vector.
|
|
112
73
|
* @static
|
|
@@ -114,31 +75,26 @@ export class Quat {
|
|
|
114
75
|
* @param {Vec3} up - Up vector.
|
|
115
76
|
* @returns {Quat} -
|
|
116
77
|
*/
|
|
117
|
-
static getLookRotation(forward
|
|
78
|
+
static getLookRotation(forward, up) {
|
|
118
79
|
let f = forward.getNormal().negate();
|
|
119
80
|
let s = up.cross(f).normalize();
|
|
120
81
|
let u = f.cross(s);
|
|
121
82
|
let z = 1.0 + s.x + u.y + f.z;
|
|
122
|
-
|
|
123
83
|
if (z > 0.000001) {
|
|
124
84
|
let fd = 1.0 / (2.0 * Math.sqrt(z));
|
|
125
85
|
return new Quat((f.y - u.z) * fd, (s.z - f.x) * fd, (u.x - s.y) * fd, 0.25 / fd);
|
|
126
86
|
}
|
|
127
|
-
|
|
128
87
|
if (s.x > u.y && s.x > f.z) {
|
|
129
88
|
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + s.x - u.y - f.z));
|
|
130
89
|
return new Quat(0.25 / fd, (u.x + s.y) * fd, (s.z + f.x) * fd, (f.y - u.z) * fd);
|
|
131
90
|
}
|
|
132
|
-
|
|
133
91
|
if (u.y > f.z) {
|
|
134
92
|
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + u.y - s.x - f.z));
|
|
135
93
|
return new Quat((u.x + s.y) * fd, 0.25 / fd, (f.y + u.z) * fd, (s.z - f.x) * fd);
|
|
136
94
|
}
|
|
137
|
-
|
|
138
95
|
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + f.z - s.x - u.y));
|
|
139
96
|
return new Quat((s.z + f.x) * fd, (f.y + u.z) * fd, 0.25 / fd, (u.x - s.y) * fd);
|
|
140
97
|
}
|
|
141
|
-
|
|
142
98
|
/**
|
|
143
99
|
* Computes a Quat from source point heading to the destination point.
|
|
144
100
|
* @static
|
|
@@ -146,7 +102,7 @@ export class Quat {
|
|
|
146
102
|
* @param {Vec3} destPoint - Destination coordinate.
|
|
147
103
|
* @returns {Quat} -
|
|
148
104
|
*/
|
|
149
|
-
static getLookAtSourceDest(sourcePoint
|
|
105
|
+
static getLookAtSourceDest(sourcePoint, destPoint) {
|
|
150
106
|
let forwardVector = destPoint.subA(sourcePoint).normalize();
|
|
151
107
|
let dot = Vec3.FORWARD.dot(forwardVector);
|
|
152
108
|
if (Math.abs(dot - -1.0) < 0.000001) {
|
|
@@ -159,7 +115,6 @@ export class Quat {
|
|
|
159
115
|
let rotAxis = Vec3.FORWARD.cross(forwardVector).normalize();
|
|
160
116
|
return Quat.axisAngleToQuat(rotAxis, rotAngle);
|
|
161
117
|
}
|
|
162
|
-
|
|
163
118
|
/**
|
|
164
119
|
* Compute rotation between two vectors.
|
|
165
120
|
* @static
|
|
@@ -167,12 +122,11 @@ export class Quat {
|
|
|
167
122
|
* @param {Vec3} v - Second vector.
|
|
168
123
|
* @returns {Quat} -
|
|
169
124
|
*/
|
|
170
|
-
static getRotationBetweenVectors(u
|
|
125
|
+
static getRotationBetweenVectors(u, v) {
|
|
171
126
|
let w = u.cross(v);
|
|
172
127
|
let q = new Quat(w.x, w.y, w.z, 1.0 + u.dot(v));
|
|
173
128
|
return q.normalize();
|
|
174
129
|
}
|
|
175
|
-
|
|
176
130
|
/**
|
|
177
131
|
* Compute rotation between two vectors.
|
|
178
132
|
* @static
|
|
@@ -181,12 +135,11 @@ export class Quat {
|
|
|
181
135
|
* @param {Quat} res
|
|
182
136
|
* @returns {Quat} -
|
|
183
137
|
*/
|
|
184
|
-
static getRotationBetweenVectorsRes(u
|
|
138
|
+
static getRotationBetweenVectorsRes(u, v, res) {
|
|
185
139
|
let w = u.cross(v);
|
|
186
140
|
res.set(w.x, w.y, w.z, 1.0 + u.dot(v));
|
|
187
141
|
return res.normalize();
|
|
188
142
|
}
|
|
189
|
-
|
|
190
143
|
/**
|
|
191
144
|
* Compute rotation between two vectors with around vector up
|
|
192
145
|
* for exactly opposite vectors. If vectors exactly in the same
|
|
@@ -197,7 +150,7 @@ export class Quat {
|
|
|
197
150
|
* @param {Vec3} up - Up vector.
|
|
198
151
|
* @returns {Quat} -
|
|
199
152
|
*/
|
|
200
|
-
static getRotationBetweenVectorsUp(source
|
|
153
|
+
static getRotationBetweenVectorsUp(source, dest, up) {
|
|
201
154
|
let dot = source.dot(dest);
|
|
202
155
|
if (Math.abs(dot + 1.0) < 0.000001) {
|
|
203
156
|
// vector source and dest point exactly in the opposite direction,
|
|
@@ -213,26 +166,23 @@ export class Quat {
|
|
|
213
166
|
let rotAxis = source.cross(dest).normalize();
|
|
214
167
|
return Quat.axisAngleToQuat(rotAxis, rotAngle);
|
|
215
168
|
}
|
|
216
|
-
|
|
217
169
|
/**
|
|
218
170
|
* Returns true if the components are zero.
|
|
219
171
|
* @public
|
|
220
172
|
* @returns {boolean} -
|
|
221
173
|
*/
|
|
222
|
-
|
|
174
|
+
isZero() {
|
|
223
175
|
return this.x === 0.0 && this.y === 0.0 && this.z === 0.0 && this.w === 0.0;
|
|
224
176
|
}
|
|
225
|
-
|
|
226
177
|
/**
|
|
227
178
|
* Clear Quat. Sets zeroes.
|
|
228
179
|
* @public
|
|
229
180
|
* @returns {Quat} -
|
|
230
181
|
*/
|
|
231
|
-
|
|
182
|
+
clear() {
|
|
232
183
|
this.x = this.y = this.z = this.w = 0;
|
|
233
184
|
return this;
|
|
234
185
|
}
|
|
235
|
-
|
|
236
186
|
/**
|
|
237
187
|
* Sets Quat values.
|
|
238
188
|
* @public
|
|
@@ -242,103 +192,94 @@ export class Quat {
|
|
|
242
192
|
* @param {Number} [w=0.0] The W component.
|
|
243
193
|
* @returns {Quat} -
|
|
244
194
|
*/
|
|
245
|
-
|
|
195
|
+
set(x, y, z, w) {
|
|
246
196
|
this.x = x;
|
|
247
197
|
this.y = y;
|
|
248
198
|
this.z = z;
|
|
249
199
|
this.w = w;
|
|
250
200
|
return this;
|
|
251
201
|
}
|
|
252
|
-
|
|
253
202
|
/**
|
|
254
203
|
* Copy Quat values.
|
|
255
204
|
* @public
|
|
256
205
|
* @param {Quat} q - Copy Quat.
|
|
257
206
|
* @returns {Quat} -
|
|
258
207
|
*/
|
|
259
|
-
|
|
208
|
+
copy(q) {
|
|
260
209
|
this.x = q.x;
|
|
261
210
|
this.y = q.y;
|
|
262
211
|
this.z = q.z;
|
|
263
212
|
this.w = q.w;
|
|
264
213
|
return this;
|
|
265
214
|
}
|
|
266
|
-
|
|
267
215
|
/**
|
|
268
216
|
* Set current Quat instance to identity Quat.
|
|
269
217
|
* @public
|
|
270
218
|
* @returns {Quat} -
|
|
271
219
|
*/
|
|
272
|
-
|
|
220
|
+
setIdentity() {
|
|
273
221
|
this.x = 0.0;
|
|
274
222
|
this.y = 0.0;
|
|
275
223
|
this.z = 0.0;
|
|
276
224
|
this.w = 1.0;
|
|
277
225
|
return this;
|
|
278
226
|
}
|
|
279
|
-
|
|
280
227
|
/**
|
|
281
228
|
* Duplicates a Quat instance.
|
|
282
229
|
* @public
|
|
283
230
|
* @returns {Quat} -
|
|
284
231
|
*/
|
|
285
|
-
|
|
232
|
+
clone() {
|
|
286
233
|
return new Quat(this.x, this.y, this.z, this.w);
|
|
287
234
|
}
|
|
288
|
-
|
|
289
235
|
/**
|
|
290
236
|
* Computes the componentwise sum of two Quats.
|
|
291
237
|
* @public
|
|
292
238
|
* @param {Quat} q - Quat to add.
|
|
293
239
|
* @returns {Quat} -
|
|
294
240
|
*/
|
|
295
|
-
|
|
241
|
+
add(q) {
|
|
296
242
|
return new Quat(this.x + q.x, this.y + q.y, this.z + q.z, this.w + q.w);
|
|
297
243
|
}
|
|
298
|
-
|
|
299
244
|
/**
|
|
300
245
|
* Computes the componentwise difference of two Quats.
|
|
301
246
|
* @public
|
|
302
247
|
* @param {Quat} q - Quat to subtract.
|
|
303
248
|
* @returns {Quat} -
|
|
304
249
|
*/
|
|
305
|
-
|
|
250
|
+
sub(q) {
|
|
306
251
|
return new Quat(this.x - q.x, this.y - q.y, this.z - q.z, this.w - q.w);
|
|
307
252
|
}
|
|
308
|
-
|
|
309
253
|
/**
|
|
310
254
|
* Multiplies the provided Quat componentwise by the provided scalar.
|
|
311
255
|
* @public
|
|
312
256
|
* @param {Number} scale - The scalar to multiply with.
|
|
313
257
|
* @returns {Quat} -
|
|
314
258
|
*/
|
|
315
|
-
|
|
259
|
+
scaleTo(scale) {
|
|
316
260
|
return new Quat(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
|
|
317
261
|
}
|
|
318
|
-
|
|
319
262
|
/**
|
|
320
263
|
* Multiplies the provided Quat componentwise.
|
|
321
264
|
* @public
|
|
322
265
|
* @param {Number} scale - The scalar to multiply with.
|
|
323
266
|
* @returns {Quat} -
|
|
324
267
|
*/
|
|
325
|
-
|
|
268
|
+
scale(scale) {
|
|
326
269
|
this.x *= scale;
|
|
327
270
|
this.y *= scale;
|
|
328
271
|
this.z *= scale;
|
|
329
272
|
this.w *= scale;
|
|
330
273
|
return this;
|
|
331
274
|
}
|
|
332
|
-
|
|
333
275
|
/**
|
|
334
276
|
* Converts Quat values to array.
|
|
335
277
|
* @public
|
|
336
278
|
* @returns {Array.<number>} - (exactly 4 entries)
|
|
337
279
|
*/
|
|
338
|
-
|
|
280
|
+
toVec() {
|
|
339
281
|
return [this.x, this.y, this.z, this.w];
|
|
340
282
|
}
|
|
341
|
-
|
|
342
283
|
/**
|
|
343
284
|
* Sets current quaternion by spherical coordinates.
|
|
344
285
|
* @public
|
|
@@ -347,22 +288,19 @@ export class Quat {
|
|
|
347
288
|
* @param {number} angle - Angle in radians.
|
|
348
289
|
* @returns {Quat} -
|
|
349
290
|
*/
|
|
350
|
-
|
|
291
|
+
setFromSphericalCoords(lat, lon, angle) {
|
|
351
292
|
let sin_a = Math.sin(angle / 2);
|
|
352
293
|
let cos_a = Math.cos(angle / 2);
|
|
353
294
|
let sin_lat = Math.sin(lat);
|
|
354
295
|
let cos_lat = Math.cos(lat);
|
|
355
296
|
let sin_long = Math.sin(lon);
|
|
356
297
|
let cos_long = Math.cos(lon);
|
|
357
|
-
|
|
358
298
|
this.x = sin_a * cos_lat * sin_long;
|
|
359
299
|
this.y = sin_a * sin_lat;
|
|
360
300
|
this.z = sin_a * sin_lat * cos_long;
|
|
361
301
|
this.w = cos_a;
|
|
362
|
-
|
|
363
302
|
return this;
|
|
364
303
|
}
|
|
365
|
-
|
|
366
304
|
/**
|
|
367
305
|
* Sets rotation with the given heading and up vectors.
|
|
368
306
|
* @static
|
|
@@ -370,79 +308,72 @@ export class Quat {
|
|
|
370
308
|
* @param {Vec3} up - Up vector.
|
|
371
309
|
* @returns {Quat} -
|
|
372
310
|
*/
|
|
373
|
-
|
|
311
|
+
setLookRotation(forward, up) {
|
|
374
312
|
let f = forward.getNormal().negate();
|
|
375
313
|
let s = up.cross(f).normalize();
|
|
376
314
|
let u = f.cross(s);
|
|
377
315
|
let z = 1.0 + s.x + u.y + f.z;
|
|
378
|
-
|
|
379
316
|
if (z > 0.000001) {
|
|
380
317
|
let fd = 1.0 / (2.0 * Math.sqrt(z));
|
|
381
318
|
this.x = (f.y - u.z) * fd;
|
|
382
319
|
this.y = (s.z - f.x) * fd;
|
|
383
320
|
this.z = (u.x - s.y) * fd;
|
|
384
321
|
this.w = 0.25 / fd;
|
|
385
|
-
}
|
|
322
|
+
}
|
|
323
|
+
else if (s.x > u.y && s.x > f.z) {
|
|
386
324
|
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + s.x - u.y - f.z));
|
|
387
325
|
this.x = 0.25 / fd;
|
|
388
326
|
this.y = (u.x + s.y) * fd;
|
|
389
327
|
this.z = (s.z + f.x) * fd;
|
|
390
328
|
this.w = (f.y - u.z) * fd;
|
|
391
|
-
}
|
|
329
|
+
}
|
|
330
|
+
else if (u.y > f.z) {
|
|
392
331
|
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + u.y - s.x - f.z));
|
|
393
332
|
this.x = (u.x + s.y) * fd;
|
|
394
333
|
this.y = 0.25 / fd;
|
|
395
334
|
this.z = (f.y + u.z) * fd;
|
|
396
335
|
this.w = (s.z - f.x) * fd;
|
|
397
|
-
}
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
398
338
|
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + f.z - s.x - u.y));
|
|
399
339
|
this.x = (s.z + f.x) * fd;
|
|
400
340
|
this.y = (f.y + u.z) * fd;
|
|
401
341
|
this.z = 0.25 / fd;
|
|
402
342
|
this.w = (u.x - s.y) * fd;
|
|
403
343
|
}
|
|
404
|
-
|
|
405
344
|
return this;
|
|
406
345
|
}
|
|
407
|
-
|
|
408
346
|
/**
|
|
409
347
|
* Gets spherical coordinates.
|
|
410
348
|
* @public
|
|
411
349
|
* @returns {Object} Returns object with latitude, longitude and alpha.
|
|
412
350
|
*/
|
|
413
|
-
|
|
414
|
-
|
|
351
|
+
toSphericalCoords() {
|
|
415
352
|
let cos_a = this.w;
|
|
416
353
|
let sin_a = Math.sqrt(1.0 - cos_a * cos_a);
|
|
417
|
-
|
|
418
354
|
// var angle = Math.acos(cos_a) * 2;
|
|
419
355
|
if (Math.abs(sin_a) < 0.0005) {
|
|
420
356
|
sin_a = 1;
|
|
421
357
|
}
|
|
422
|
-
|
|
423
358
|
let tx = this.x / sin_a;
|
|
424
359
|
let ty = this.y / sin_a;
|
|
425
360
|
let tz = this.z / sin_a;
|
|
426
|
-
|
|
427
361
|
let lon, lat = -Math.asin(ty);
|
|
428
|
-
|
|
429
362
|
if (tx * tx + tz * tz < 0.0005) {
|
|
430
363
|
lon = 0;
|
|
431
|
-
}
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
432
366
|
lon = Math.atan2(tx, tz);
|
|
433
367
|
}
|
|
434
|
-
|
|
435
368
|
if (lon < 0) {
|
|
436
369
|
lon += 360.0;
|
|
437
370
|
}
|
|
438
|
-
|
|
439
371
|
return {
|
|
440
372
|
lat: lat,
|
|
441
373
|
lon: lon,
|
|
442
374
|
alpha: Math.acos(cos_a)
|
|
443
375
|
};
|
|
444
376
|
}
|
|
445
|
-
|
|
446
377
|
/**
|
|
447
378
|
* Sets current Quat representing a rotation around an axis.
|
|
448
379
|
* @public
|
|
@@ -450,24 +381,20 @@ export class Quat {
|
|
|
450
381
|
* @param {number} angle The angle in radians to rotate around the axis.
|
|
451
382
|
* @returns {Quat} -
|
|
452
383
|
*/
|
|
453
|
-
|
|
384
|
+
setFromAxisAngle(axis, angle) {
|
|
454
385
|
let v = axis.getNormal();
|
|
455
386
|
let half_angle = angle * 0.5;
|
|
456
387
|
let sin_a = Math.sin(half_angle);
|
|
457
388
|
this.set(v.x * sin_a, v.y * sin_a, v.z * sin_a, Math.cos(half_angle));
|
|
458
389
|
return this;
|
|
459
390
|
}
|
|
460
|
-
|
|
461
391
|
/**
|
|
462
392
|
* Returns axis and angle of the current Quat.
|
|
463
393
|
* @public
|
|
464
394
|
* @returns {Object} -
|
|
465
395
|
*/
|
|
466
|
-
|
|
467
|
-
let x = this.x,
|
|
468
|
-
y = this.y,
|
|
469
|
-
z = this.z,
|
|
470
|
-
w = this.w;
|
|
396
|
+
getAxisAngle() {
|
|
397
|
+
let x = this.x, y = this.y, z = this.z, w = this.w;
|
|
471
398
|
let vl = Math.sqrt(x * x + y * y + z * z);
|
|
472
399
|
let axis, angle;
|
|
473
400
|
if (vl > 0.0000001) {
|
|
@@ -475,20 +402,20 @@ export class Quat {
|
|
|
475
402
|
axis = new Vec3(x * ivl, y * ivl, z * ivl);
|
|
476
403
|
if (w < 0) {
|
|
477
404
|
angle = 2.0 * Math.atan2(-vl, -w); // -PI,0
|
|
478
|
-
}
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
479
407
|
angle = 2.0 * Math.atan2(vl, w); // 0,PI
|
|
480
408
|
}
|
|
481
|
-
}
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
482
411
|
axis = new Vec3(0, 0, 0);
|
|
483
412
|
angle = 0;
|
|
484
413
|
}
|
|
485
|
-
|
|
486
414
|
return {
|
|
487
415
|
axis: axis,
|
|
488
416
|
angle: angle
|
|
489
417
|
};
|
|
490
418
|
}
|
|
491
|
-
|
|
492
419
|
/**
|
|
493
420
|
* Sets current Quat by Euler's angles.
|
|
494
421
|
* @public
|
|
@@ -497,80 +424,53 @@ export class Quat {
|
|
|
497
424
|
* @param {number} roll - Roll angle in degrees.
|
|
498
425
|
* @returns {Quat} -
|
|
499
426
|
*/
|
|
500
|
-
|
|
501
|
-
let ex = pitch * math.RADIANS_HALF,
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
let cr = Math.cos(ex),
|
|
506
|
-
cp = Math.cos(ey),
|
|
507
|
-
cy = Math.cos(ez);
|
|
508
|
-
|
|
509
|
-
let sr = Math.sin(ex),
|
|
510
|
-
sp = Math.sin(ey),
|
|
511
|
-
sy = Math.sin(ez);
|
|
512
|
-
|
|
513
|
-
let cpcy = cp * cy,
|
|
514
|
-
spsy = sp * sy;
|
|
515
|
-
|
|
427
|
+
setFromEulerAngles(pitch, yaw, roll) {
|
|
428
|
+
let ex = pitch * math.RADIANS_HALF, ey = yaw * math.RADIANS_HALF, ez = roll * math.RADIANS_HALF;
|
|
429
|
+
let cr = Math.cos(ex), cp = Math.cos(ey), cy = Math.cos(ez);
|
|
430
|
+
let sr = Math.sin(ex), sp = Math.sin(ey), sy = Math.sin(ez);
|
|
431
|
+
let cpcy = cp * cy, spsy = sp * sy;
|
|
516
432
|
this.w = cr * cpcy + sr * spsy;
|
|
517
433
|
this.x = sr * cpcy - cr * spsy;
|
|
518
434
|
this.y = cr * sp * cy + sr * cp * sy;
|
|
519
435
|
this.z = cr * cp * sy - sr * sp * cy;
|
|
520
|
-
|
|
521
436
|
return this.normalize();
|
|
522
437
|
}
|
|
523
|
-
|
|
524
438
|
/**
|
|
525
439
|
* Returns Euler's angles of the current Quat.
|
|
526
440
|
* @public
|
|
527
441
|
* @returns {Object} -
|
|
528
442
|
*/
|
|
529
|
-
|
|
530
|
-
let x = this.x,
|
|
531
|
-
y = this.y,
|
|
532
|
-
z = this.z,
|
|
533
|
-
w = this.w;
|
|
534
|
-
|
|
443
|
+
getEulerAngles() {
|
|
444
|
+
let x = this.x, y = this.y, z = this.z, w = this.w;
|
|
535
445
|
let sqy = y * y;
|
|
536
|
-
|
|
537
446
|
let roll = Math.atan2(2.0 * (w * x + y * z), 1.0 - 2.0 * (x * x + sqy));
|
|
538
|
-
|
|
539
447
|
let a = w * y - z * x;
|
|
540
|
-
|
|
541
448
|
if (a < -1.0) {
|
|
542
449
|
a = -1.0;
|
|
543
|
-
}
|
|
450
|
+
}
|
|
451
|
+
else if (a > 1.0) {
|
|
544
452
|
a = 1.0;
|
|
545
453
|
}
|
|
546
454
|
let pitch = Math.asin(2.0 * a);
|
|
547
|
-
|
|
548
455
|
let yaw = Math.atan2(2.0 * (w * z + x * y), 1.0 - 2.0 * (sqy + z * z));
|
|
549
|
-
|
|
550
456
|
return {
|
|
551
457
|
roll,
|
|
552
458
|
pitch,
|
|
553
459
|
yaw
|
|
554
460
|
};
|
|
555
461
|
}
|
|
556
|
-
|
|
557
462
|
/**
|
|
558
463
|
* Computes a Quat from the provided 4x4 matrix instance.
|
|
559
464
|
* @public
|
|
560
465
|
* @param {Mat4} mx - The rotation matrix.
|
|
561
466
|
* @returns {Quat} -
|
|
562
467
|
*/
|
|
563
|
-
|
|
564
|
-
let tr,
|
|
565
|
-
s,
|
|
566
|
-
q = [];
|
|
468
|
+
setFromMatrix4(mx) {
|
|
469
|
+
let tr, s, q = [];
|
|
567
470
|
let i, j, k;
|
|
568
471
|
let m = mx._m;
|
|
569
|
-
|
|
570
472
|
let nxt = [1, 2, 0];
|
|
571
|
-
|
|
572
473
|
tr = m[0] + m[5] + m[10];
|
|
573
|
-
|
|
574
474
|
if (tr > 0.0) {
|
|
575
475
|
s = Math.sqrt(tr + 1.0);
|
|
576
476
|
this.w = s / 2.0;
|
|
@@ -578,23 +478,22 @@ export class Quat {
|
|
|
578
478
|
this.x = (m[6] - m[9]) * s;
|
|
579
479
|
this.y = (m[8] - m[2]) * s;
|
|
580
480
|
this.z = (m[1] - m[4]) * s;
|
|
581
|
-
}
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
582
483
|
i = 0;
|
|
583
|
-
if (m[5] > m[0])
|
|
584
|
-
|
|
484
|
+
if (m[5] > m[0])
|
|
485
|
+
i = 1;
|
|
486
|
+
if (m[10] > m[i * 5])
|
|
487
|
+
i = 2;
|
|
585
488
|
j = nxt[i];
|
|
586
489
|
k = nxt[j];
|
|
587
|
-
|
|
588
490
|
s = Math.sqrt(m[i * 5] - (m[j * 5] + m[k * 5]) + 1.0);
|
|
589
|
-
|
|
590
491
|
q[i] = s * 0.5;
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
492
|
+
if (s !== 0.0)
|
|
493
|
+
s = 0.5 / s;
|
|
594
494
|
q[3] = (m[j * 4 + k] - m[k * 4 + j]) * s;
|
|
595
495
|
q[j] = (m[i * 4 + j] + m[j * 4 + i]) * s;
|
|
596
496
|
q[k] = (m[i * 4 + k] + m[k * 4 + i]) * s;
|
|
597
|
-
|
|
598
497
|
this.x = q[0];
|
|
599
498
|
this.y = q[1];
|
|
600
499
|
this.z = q[2];
|
|
@@ -602,14 +501,13 @@ export class Quat {
|
|
|
602
501
|
}
|
|
603
502
|
return this;
|
|
604
503
|
}
|
|
605
|
-
|
|
606
504
|
/**
|
|
607
505
|
* Converts current Quat to the rotation 4x4 matrix.
|
|
608
506
|
* @public
|
|
609
507
|
* @params {Mat4} [out] - Output matrix
|
|
610
508
|
* @returns {Mat4} -
|
|
611
509
|
*/
|
|
612
|
-
|
|
510
|
+
getMat4(out = new Mat4()) {
|
|
613
511
|
let xs = this.x + this.x;
|
|
614
512
|
let ys = this.y + this.y;
|
|
615
513
|
let zs = this.z + this.z;
|
|
@@ -622,7 +520,6 @@ export class Quat {
|
|
|
622
520
|
let yy = this.y * ys;
|
|
623
521
|
let yz = this.y * zs;
|
|
624
522
|
let zz = this.z * zs;
|
|
625
|
-
|
|
626
523
|
return out.set([
|
|
627
524
|
1 - (yy + zz), xy - wz, xz + wy, 0,
|
|
628
525
|
xy + wz, 1 - (xx + zz), yz - wx, 0,
|
|
@@ -630,36 +527,23 @@ export class Quat {
|
|
|
630
527
|
0, 0, 0, 1
|
|
631
528
|
]);
|
|
632
529
|
}
|
|
633
|
-
|
|
634
530
|
/**
|
|
635
531
|
* Converts current Quat to the rotation 3x3 matrix.
|
|
636
532
|
* @public
|
|
637
533
|
* @returns {Mat3} -
|
|
638
534
|
* @todo NOT TESTED
|
|
639
535
|
*/
|
|
640
|
-
|
|
536
|
+
getMat3() {
|
|
641
537
|
let m = new Mat3();
|
|
642
538
|
let mx = m._m;
|
|
643
|
-
let c = this.x,
|
|
644
|
-
d = this.y,
|
|
645
|
-
e = this.z,
|
|
646
|
-
g = this.w,
|
|
647
|
-
f = c + c,
|
|
648
|
-
h = d + d,
|
|
649
|
-
i = e + e,
|
|
650
|
-
j = c * f,
|
|
651
|
-
k = c * h;
|
|
652
|
-
|
|
539
|
+
let c = this.x, d = this.y, e = this.z, g = this.w, f = c + c, h = d + d, i = e + e, j = c * f, k = c * h;
|
|
653
540
|
c = c * i;
|
|
654
|
-
|
|
655
541
|
let l = d * h;
|
|
656
|
-
|
|
657
542
|
d = d * i;
|
|
658
543
|
e = e * i;
|
|
659
544
|
f = g * f;
|
|
660
545
|
h = g * h;
|
|
661
546
|
g = g * i;
|
|
662
|
-
|
|
663
547
|
mx[0] = 1 - (l + e);
|
|
664
548
|
mx[1] = k - g;
|
|
665
549
|
mx[2] = c + h;
|
|
@@ -669,160 +553,100 @@ export class Quat {
|
|
|
669
553
|
mx[6] = c - h;
|
|
670
554
|
mx[7] = d + f;
|
|
671
555
|
mx[8] = 1 - (j + l);
|
|
672
|
-
|
|
673
556
|
return m;
|
|
674
557
|
}
|
|
675
|
-
|
|
676
558
|
/**
|
|
677
559
|
* Returns quaternion and vector production.
|
|
678
560
|
* @public
|
|
679
561
|
* @param {Vec3} v - 3d Vector.
|
|
680
562
|
* @returns {Vec3} -
|
|
681
563
|
*/
|
|
682
|
-
|
|
564
|
+
mulVec3(v) {
|
|
683
565
|
// t = 2 * cross(q.xyz, v)
|
|
684
566
|
// v' = v + q.w * t + cross(q.xyz, t)
|
|
685
|
-
|
|
686
|
-
let
|
|
687
|
-
|
|
688
|
-
g = v.z;
|
|
689
|
-
|
|
690
|
-
let b = this.x,
|
|
691
|
-
f = this.y,
|
|
692
|
-
h = this.z,
|
|
693
|
-
a = this.w;
|
|
694
|
-
|
|
695
|
-
let i = a * d + f * g - h * e,
|
|
696
|
-
j = a * e + h * d - b * g,
|
|
697
|
-
k = a * g + b * e - f * d;
|
|
698
|
-
|
|
567
|
+
let d = v.x, e = v.y, g = v.z;
|
|
568
|
+
let b = this.x, f = this.y, h = this.z, a = this.w;
|
|
569
|
+
let i = a * d + f * g - h * e, j = a * e + h * d - b * g, k = a * g + b * e - f * d;
|
|
699
570
|
d = -b * d - f * e - h * g;
|
|
700
|
-
|
|
701
|
-
return new Vec3(
|
|
702
|
-
i * a + d * -b + j * -h - k * -f,
|
|
703
|
-
j * a + d * -f + k * -b - i * -h,
|
|
704
|
-
k * a + d * -h + i * -f - j * -b
|
|
705
|
-
);
|
|
571
|
+
return new Vec3(i * a + d * -b + j * -h - k * -f, j * a + d * -f + k * -b - i * -h, k * a + d * -h + i * -f - j * -b);
|
|
706
572
|
}
|
|
707
|
-
|
|
708
573
|
/**
|
|
709
574
|
* Computes the product of two Quats.
|
|
710
575
|
* @public
|
|
711
576
|
* @param {Quat} q - Quat to multiply.
|
|
712
577
|
* @returns {Quat} -
|
|
713
578
|
*/
|
|
714
|
-
|
|
715
|
-
let d = this.x,
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
let f = q.x,
|
|
721
|
-
h = q.y,
|
|
722
|
-
i = q.z,
|
|
723
|
-
b = q.w;
|
|
724
|
-
|
|
725
|
-
return new Quat(
|
|
726
|
-
d * b + a * f + e * i - g * h,
|
|
727
|
-
e * b + a * h + g * f - d * i,
|
|
728
|
-
g * b + a * i + d * h - e * f,
|
|
729
|
-
a * b - d * f - e * h - g * i
|
|
730
|
-
);
|
|
731
|
-
}
|
|
732
|
-
|
|
579
|
+
mul(q) {
|
|
580
|
+
let d = this.x, e = this.y, g = this.z, a = this.w;
|
|
581
|
+
let f = q.x, h = q.y, i = q.z, b = q.w;
|
|
582
|
+
return new Quat(d * b + a * f + e * i - g * h, e * b + a * h + g * f - d * i, g * b + a * i + d * h - e * f, a * b - d * f - e * h - g * i);
|
|
583
|
+
}
|
|
733
584
|
/**
|
|
734
585
|
* Computes the product of two Quats.
|
|
735
586
|
* @public
|
|
736
587
|
* @param {Quat} q - Quat to multiply.
|
|
737
588
|
* @returns {Quat} -
|
|
738
589
|
*/
|
|
739
|
-
|
|
740
|
-
let d = this.x,
|
|
741
|
-
|
|
742
|
-
g = this.z,
|
|
743
|
-
a = this.w;
|
|
744
|
-
|
|
745
|
-
let f = q.x,
|
|
746
|
-
h = q.y,
|
|
747
|
-
i = q.z,
|
|
748
|
-
b = q.w;
|
|
749
|
-
|
|
590
|
+
mulA(q) {
|
|
591
|
+
let d = this.x, e = this.y, g = this.z, a = this.w;
|
|
592
|
+
let f = q.x, h = q.y, i = q.z, b = q.w;
|
|
750
593
|
this.x = d * b + a * f + e * i - g * h;
|
|
751
594
|
this.y = e * b + a * h + g * f - d * i;
|
|
752
595
|
this.z = g * b + a * i + d * h - e * f;
|
|
753
596
|
this.w = a * b - d * f - e * h - g * i;
|
|
754
|
-
|
|
755
597
|
return this;
|
|
756
598
|
}
|
|
757
|
-
|
|
758
599
|
/**
|
|
759
600
|
* Gets the conjugate of the Quat.
|
|
760
601
|
* @public
|
|
761
602
|
* @returns {Quat} -
|
|
762
603
|
*/
|
|
763
|
-
|
|
604
|
+
conjugate() {
|
|
764
605
|
return new Quat(-this.x, -this.y, -this.z, this.w);
|
|
765
606
|
}
|
|
766
|
-
|
|
767
607
|
/**
|
|
768
608
|
* Computes the inverse of the Quat.
|
|
769
609
|
* @public
|
|
770
610
|
* @returns {Quat} -
|
|
771
611
|
*/
|
|
772
|
-
|
|
612
|
+
inverse() {
|
|
773
613
|
let n = 1.0 / this.magnitude2();
|
|
774
614
|
return new Quat(-this.x * n, -this.y * n, -this.z * n, this.w * n);
|
|
775
615
|
}
|
|
776
|
-
|
|
777
616
|
/**
|
|
778
617
|
* Computes a magnitude of the Quat.
|
|
779
618
|
* @public
|
|
780
619
|
* @returns {number} -
|
|
781
620
|
*/
|
|
782
|
-
|
|
783
|
-
let b = this.x,
|
|
784
|
-
c = this.y,
|
|
785
|
-
d = this.z,
|
|
786
|
-
a = this.w;
|
|
621
|
+
magnitude() {
|
|
622
|
+
let b = this.x, c = this.y, d = this.z, a = this.w;
|
|
787
623
|
return Math.sqrt(b * b + c * c + d * d + a * a);
|
|
788
624
|
}
|
|
789
|
-
|
|
790
625
|
/**
|
|
791
626
|
* Computes a squared magnitude of the Quat.
|
|
792
627
|
* @public
|
|
793
628
|
* @returns {number} -
|
|
794
629
|
*/
|
|
795
|
-
|
|
796
|
-
let b = this.x,
|
|
797
|
-
c = this.y,
|
|
798
|
-
d = this.z,
|
|
799
|
-
a = this.w;
|
|
630
|
+
magnitude2() {
|
|
631
|
+
let b = this.x, c = this.y, d = this.z, a = this.w;
|
|
800
632
|
return b * b + c * c + d * d + a * a;
|
|
801
633
|
}
|
|
802
|
-
|
|
803
634
|
/**
|
|
804
635
|
* Computes the dot (scalar) product of two Quats.
|
|
805
636
|
* @public
|
|
806
637
|
* @param {Quat} q - Second quaternion.
|
|
807
638
|
* @returns {number} -
|
|
808
639
|
*/
|
|
809
|
-
|
|
640
|
+
dot(q) {
|
|
810
641
|
return this.x * q.x + this.y * q.y + this.z * q.z;
|
|
811
642
|
}
|
|
812
|
-
|
|
813
643
|
/**
|
|
814
644
|
* Current Quat normalization.
|
|
815
645
|
* @public
|
|
816
646
|
* @returns {Quat} -
|
|
817
647
|
*/
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
let c = this.x,
|
|
821
|
-
d = this.y,
|
|
822
|
-
e = this.z,
|
|
823
|
-
g = this.w,
|
|
824
|
-
f = Math.sqrt(c * c + d * d + e * e + g * g);
|
|
825
|
-
|
|
648
|
+
normalize() {
|
|
649
|
+
let c = this.x, d = this.y, e = this.z, g = this.w, f = Math.sqrt(c * c + d * d + e * e + g * g);
|
|
826
650
|
if (f === 0.0) {
|
|
827
651
|
this.x = 0;
|
|
828
652
|
this.y = 0;
|
|
@@ -830,30 +654,26 @@ export class Quat {
|
|
|
830
654
|
this.w = 0;
|
|
831
655
|
return this;
|
|
832
656
|
}
|
|
833
|
-
|
|
834
657
|
f = 1 / f;
|
|
835
658
|
this.x = c * f;
|
|
836
659
|
this.y = d * f;
|
|
837
660
|
this.z = e * f;
|
|
838
661
|
this.w = g * f;
|
|
839
|
-
|
|
840
662
|
return this;
|
|
841
663
|
}
|
|
842
|
-
|
|
843
664
|
/**
|
|
844
665
|
* Compares two Quats.
|
|
845
666
|
* @public
|
|
846
667
|
* @param {Quat} q - Second quaternion.
|
|
847
668
|
* @returns {Boolean} -
|
|
848
669
|
*/
|
|
849
|
-
|
|
670
|
+
isEqual(q) {
|
|
850
671
|
let matching = this.dot(q);
|
|
851
672
|
if (Math.abs(matching - 1.0) < 0.001) {
|
|
852
673
|
return true;
|
|
853
674
|
}
|
|
854
675
|
return false;
|
|
855
676
|
}
|
|
856
|
-
|
|
857
677
|
/**
|
|
858
678
|
* Performs a spherical linear interpolation between two Quats.
|
|
859
679
|
* @public
|
|
@@ -861,21 +681,10 @@ export class Quat {
|
|
|
861
681
|
* @param {number} t - interpolation amount between the two Quats.
|
|
862
682
|
* @returns {Quat} -
|
|
863
683
|
*/
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
let ax = this.x,
|
|
867
|
-
ay = this.y,
|
|
868
|
-
az = this.z,
|
|
869
|
-
aw = this.w,
|
|
870
|
-
bx = b.x,
|
|
871
|
-
by = b.y,
|
|
872
|
-
bz = b.z,
|
|
873
|
-
bw = b.w;
|
|
874
|
-
|
|
684
|
+
slerp(b, t) {
|
|
685
|
+
let ax = this.x, ay = this.y, az = this.z, aw = this.w, bx = b.x, by = b.y, bz = b.z, bw = b.w;
|
|
875
686
|
let omega, cosom, sinom, scale0, scale1;
|
|
876
|
-
|
|
877
687
|
cosom = ax * bx + ay * by + az * bz + aw * bw;
|
|
878
|
-
|
|
879
688
|
if (cosom < 0.0) {
|
|
880
689
|
cosom = -cosom;
|
|
881
690
|
bx = -bx;
|
|
@@ -883,38 +692,26 @@ export class Quat {
|
|
|
883
692
|
bz = -bz;
|
|
884
693
|
bw = -bw;
|
|
885
694
|
}
|
|
886
|
-
|
|
887
695
|
if (1.0 - cosom > 0.000001) {
|
|
888
696
|
omega = Math.acos(cosom);
|
|
889
697
|
sinom = Math.sin(omega);
|
|
890
698
|
scale0 = Math.sin((1.0 - t) * omega) / sinom;
|
|
891
699
|
scale1 = Math.sin(t * omega) / sinom;
|
|
892
|
-
}
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
893
702
|
scale0 = 1.0 - t;
|
|
894
703
|
scale1 = t;
|
|
895
704
|
}
|
|
896
|
-
|
|
897
|
-
return new Quat(
|
|
898
|
-
scale0 * ax + scale1 * bx,
|
|
899
|
-
scale0 * ay + scale1 * by,
|
|
900
|
-
scale0 * az + scale1 * bz,
|
|
901
|
-
scale0 * aw + scale1 * bw
|
|
902
|
-
);
|
|
705
|
+
return new Quat(scale0 * ax + scale1 * bx, scale0 * ay + scale1 * by, scale0 * az + scale1 * bz, scale0 * aw + scale1 * bw);
|
|
903
706
|
}
|
|
904
|
-
|
|
905
707
|
/**
|
|
906
708
|
* Returns a roll angle in radians.
|
|
907
709
|
* @public
|
|
908
710
|
* @param {Boolean} [reprojectAxis] -
|
|
909
711
|
* @returns {Number} -
|
|
910
712
|
*/
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
let x = this.x,
|
|
914
|
-
y = this.y,
|
|
915
|
-
z = this.z,
|
|
916
|
-
w = this.w;
|
|
917
|
-
|
|
713
|
+
getRoll(reprojectAxis = false) {
|
|
714
|
+
let x = this.x, y = this.y, z = this.z, w = this.w;
|
|
918
715
|
if (reprojectAxis) {
|
|
919
716
|
let fTy = 2.0 * y;
|
|
920
717
|
let fTz = 2.0 * z;
|
|
@@ -923,24 +720,19 @@ export class Quat {
|
|
|
923
720
|
let fTyy = fTy * y;
|
|
924
721
|
let fTzz = fTz * z;
|
|
925
722
|
return Math.atan2(fTxy + fTwz, 1.0 - (fTyy + fTzz));
|
|
926
|
-
}
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
927
725
|
return Math.atan2(2 * (x * y + w * z), w * w + x * x - y * y - z * z);
|
|
928
726
|
}
|
|
929
727
|
}
|
|
930
|
-
|
|
931
728
|
/**
|
|
932
729
|
* Returns a pitch angle in radians.
|
|
933
730
|
* @public
|
|
934
731
|
* @param {Boolean} [reprojectAxis] -
|
|
935
732
|
* @returns {number} -
|
|
936
733
|
*/
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
let x = this.x,
|
|
940
|
-
y = this.y,
|
|
941
|
-
z = this.z,
|
|
942
|
-
w = this.w;
|
|
943
|
-
|
|
734
|
+
getPitch(reprojectAxis = false) {
|
|
735
|
+
let x = this.x, y = this.y, z = this.z, w = this.w;
|
|
944
736
|
if (reprojectAxis) {
|
|
945
737
|
let fTx = 2.0 * x;
|
|
946
738
|
let fTz = 2.0 * z;
|
|
@@ -949,24 +741,19 @@ export class Quat {
|
|
|
949
741
|
let fTyz = fTz * y;
|
|
950
742
|
let fTzz = fTz * z;
|
|
951
743
|
return Math.atan2(fTyz + fTwx, 1.0 - (fTxx + fTzz));
|
|
952
|
-
}
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
953
746
|
return Math.atan2(2 * (y * z + w * x), w * w - x * x - y * y + z * z);
|
|
954
747
|
}
|
|
955
748
|
}
|
|
956
|
-
|
|
957
749
|
/**
|
|
958
750
|
* Returns a yaw angle in radians.
|
|
959
751
|
* @public
|
|
960
752
|
* @param {Boolean} [reprojectAxis] -
|
|
961
753
|
* @returns {number} -
|
|
962
754
|
*/
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
let x = this.x,
|
|
966
|
-
y = this.y,
|
|
967
|
-
z = this.z,
|
|
968
|
-
w = this.w;
|
|
969
|
-
|
|
755
|
+
getYaw(reprojectAxis = false) {
|
|
756
|
+
let x = this.x, y = this.y, z = this.z, w = this.w;
|
|
970
757
|
if (reprojectAxis) {
|
|
971
758
|
let fTx = 2.0 * x;
|
|
972
759
|
let fTy = 2.0 * y;
|
|
@@ -976,12 +763,12 @@ export class Quat {
|
|
|
976
763
|
let fTxz = fTz * x;
|
|
977
764
|
let fTyy = fTy * y;
|
|
978
765
|
return Math.atan2(fTxz + fTwy, 1.0 - (fTxx + fTyy));
|
|
979
|
-
}
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
980
768
|
return Math.asin(-2 * (x * z - w * y));
|
|
981
769
|
}
|
|
982
770
|
}
|
|
983
771
|
}
|
|
984
|
-
|
|
985
772
|
/**
|
|
986
773
|
* Creates Quat instance.
|
|
987
774
|
* @function
|
|
@@ -991,6 +778,6 @@ export class Quat {
|
|
|
991
778
|
* @param {Number} [w=0.0] The W component.
|
|
992
779
|
* @returns {Quat} -
|
|
993
780
|
*/
|
|
994
|
-
export function quat(x
|
|
781
|
+
export function quat(x = 0, y = 0, z = 0, w = 0) {
|
|
995
782
|
return new Quat(x, y, z, w);
|
|
996
783
|
}
|