@openglobus/og 0.11.2 → 0.11.7
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/package.json +13 -13
- package/src/og/Clock.js +10 -10
- package/src/og/Events.js +8 -6
- package/src/og/Extent.js +82 -41
- package/src/og/Globe.js +25 -13
- package/src/og/ImageCanvas.js +22 -16
- package/src/og/LonLat.js +16 -13
- package/src/og/Popup.js +21 -14
- package/src/og/QueueArray.js +6 -2
- package/src/og/Rectangle.js +11 -6
- package/src/og/Stack.js +5 -2
- package/src/og/ajax.js +21 -33
- package/src/og/astro/astro.js +5 -5
- package/src/og/astro/earth.js +22 -16
- package/src/og/astro/jd.js +23 -18
- package/src/og/astro/orbit.js +13 -11
- package/src/og/astro/rotation.js +17 -8
- package/src/og/bv/Box.js +7 -3
- package/src/og/bv/Sphere.js +14 -11
- package/src/og/camera/Camera.js +51 -54
- package/src/og/camera/Frustum.js +29 -18
- package/src/og/camera/PlanetCamera.js +32 -23
- package/src/og/control/CompassButton.js +5 -1
- package/src/og/control/Control.js +12 -10
- package/src/og/control/DebugInfo.js +4 -1
- package/src/og/control/EarthCoordinates.js +54 -33
- package/src/og/control/KeyboardNavigation.js +10 -10
- package/src/og/control/LayerSwitcher.js +22 -21
- package/src/og/control/Lighting.js +34 -3
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/SegmentBoundVisualization.js +6 -7
- package/src/og/control/ShowFps.js +13 -8
- package/src/og/control/SimpleNavigation.js +6 -8
- package/src/og/control/Sun.js +25 -15
- package/src/og/control/ToggleWireframe.js +4 -4
- package/src/og/control/TouchNavigation.js +44 -33
- package/src/og/control/ZoomControl.js +41 -25
- package/src/og/ellipsoid/Ellipsoid.js +162 -66
- package/src/og/ellipsoid/wgs84.js +4 -4
- package/src/og/entity/BaseBillboard.js +100 -56
- package/src/og/entity/Billboard.js +14 -10
- package/src/og/entity/BillboardHandler.js +317 -60
- package/src/og/entity/Entity.js +100 -68
- package/src/og/entity/EntityCollection.js +70 -47
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/Geometry.js +27 -24
- package/src/og/entity/GeometryHandler.js +596 -124
- package/src/og/entity/Label.js +80 -49
- package/src/og/entity/LabelHandler.js +45 -244
- package/src/og/entity/LabelWorker.js +218 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +80 -32
- package/src/og/entity/PointCloudHandler.js +8 -8
- package/src/og/entity/Polyline.js +16 -16
- package/src/og/entity/Ray.js +60 -27
- package/src/og/entity/Strip.js +77 -48
- package/src/og/entity/StripHandler.js +26 -26
- package/src/og/entity/index.js +8 -16
- package/src/og/layer/BaseGeoImage.js +54 -23
- package/src/og/layer/CanvasTiles.js +24 -24
- package/src/og/layer/GeoImage.js +9 -9
- package/src/og/layer/GeoVideo.js +3 -3
- package/src/og/layer/KML.js +63 -37
- package/src/og/layer/Layer.js +44 -21
- package/src/og/layer/Material.js +23 -20
- package/src/og/layer/Vector.js +114 -68
- package/src/og/layer/WMS.js +34 -17
- package/src/og/layer/XYZ.js +48 -46
- package/src/og/light/LightSource.js +46 -39
- package/src/og/math/Mat3.js +34 -22
- package/src/og/math/Mat4.js +603 -459
- package/src/og/math/Plane.js +21 -20
- package/src/og/math/Quat.js +182 -139
- package/src/og/math/Ray.js +38 -33
- package/src/og/math/Vec2.js +85 -75
- package/src/og/math/Vec3.js +142 -112
- package/src/og/math/Vec4.js +27 -31
- package/src/og/math/coder.js +10 -10
- package/src/og/math.js +12 -12
- package/src/og/proj/EPSG3857.js +4 -4
- package/src/og/proj/EPSG4326.js +4 -4
- package/src/og/proj/Proj.js +4 -6
- package/src/og/quadTree/Node.js +8 -8
- package/src/og/renderer/Renderer.js +59 -52
- package/src/og/renderer/RendererEvents.js +50 -27
- package/src/og/scene/BaseNode.js +7 -8
- package/src/og/scene/Planet.js +102 -103
- package/src/og/scene/RenderNode.js +28 -21
- package/src/og/segment/Segment.js +26 -21
- package/src/og/segment/SegmentLonLat.js +5 -5
- package/src/og/shaders/drawnode.js +135 -142
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/pointCloud.js +41 -41
- package/src/og/shaders/shape.js +12 -18
- package/src/og/shaders/skybox.js +36 -36
- package/src/og/shaders/toneMapping.js +1 -0
- package/src/og/shapes/BaseShape.js +126 -54
- package/src/og/shapes/Icosphere.js +29 -14
- package/src/og/shapes/Sphere.js +12 -15
- package/src/og/terrain/BilTerrain.js +1 -0
- package/src/og/terrain/EmptyTerrain.js +2 -2
- package/src/og/terrain/GlobusTerrain.js +9 -9
- package/src/og/utils/FontAtlas.js +6 -2
- package/src/og/utils/TextureAtlas.js +22 -24
- package/src/og/utils/VectorTileCreator.js +1 -3
- package/src/og/utils/shared.js +16 -16
- package/src/og/webgl/Framebuffer.js +88 -40
- package/src/og/webgl/Handler.js +243 -169
- package/src/og/webgl/Multisample.js +47 -19
- package/src/og/webgl/Program.js +79 -34
- package/src/og/webgl/ProgramController.js +17 -13
- package/src/og/webgl/callbacks.js +8 -8
- package/src/og/inherits.js +0 -8
- package/src/og/utils/polylabel.js +0 -176
- package/types/Clock.d.ts +0 -90
- package/types/Deferred.d.ts +0 -6
- package/types/Events.d.ts +0 -73
- package/types/Extent.d.ts +0 -166
- package/types/Globe.d.ts +0 -75
- package/types/ImageCanvas.d.ts +0 -121
- package/types/Lock.d.ts +0 -12
- package/types/LonLat.d.ts +0 -108
- package/types/Popup.d.ts +0 -38
- package/types/QueueArray.d.ts +0 -15
- package/types/Rectangle.d.ts +0 -74
- package/types/Stack.d.ts +0 -15
- package/types/ajax.d.ts +0 -24
- package/types/arial.d.ts +0 -48
- package/types/astro/astro.d.ts +0 -38
- package/types/astro/earth.d.ts +0 -6
- package/types/astro/jd.d.ts +0 -254
- package/types/bv/Box.d.ts +0 -25
- package/types/bv/Sphere.d.ts +0 -38
- package/types/bv/index.d.ts +0 -3
- package/types/camera/Camera.d.ts +0 -303
- package/types/camera/Frustum.d.ts +0 -129
- package/types/camera/PlanetCamera.d.ts +0 -223
- package/types/camera/index.d.ts +0 -3
- package/types/cons.d.ts +0 -40
- package/types/control/CompassButton.d.ts +0 -18
- package/types/control/Control.d.ts +0 -101
- package/types/control/DebugInfo.d.ts +0 -16
- package/types/control/EarthCoordinates.d.ts +0 -47
- package/types/control/EarthNavigation.d.ts +0 -42
- package/types/control/GeoImageDragControl.d.ts +0 -6
- package/types/control/KeyboardNavigation.d.ts +0 -22
- package/types/control/LayerSwitcher.d.ts +0 -23
- package/types/control/Lighting.d.ts +0 -16
- package/types/control/MouseNavigation.d.ts +0 -51
- package/types/control/ScaleControl.d.ts +0 -22
- package/types/control/ShowFps.d.ts +0 -12
- package/types/control/SimpleNavigation.d.ts +0 -28
- package/types/control/Sun.d.ts +0 -52
- package/types/control/ToggleWireframe.d.ts +0 -12
- package/types/control/TouchNavigation.d.ts +0 -50
- package/types/control/ZoomControl.d.ts +0 -28
- package/types/control/index.d.ts +0 -17
- package/types/ellipsoid/Ellipsoid.d.ts +0 -142
- package/types/ellipsoid/index.d.ts +0 -3
- package/types/ellipsoid/wgs84.d.ts +0 -5
- package/types/entity/BaseBillboard.d.ts +0 -208
- package/types/entity/Billboard.d.ts +0 -94
- package/types/entity/BillboardHandler.d.ts +0 -74
- package/types/entity/Entity.d.ts +0 -331
- package/types/entity/EntityCollection.d.ts +0 -303
- package/types/entity/Geometry.d.ts +0 -73
- package/types/entity/GeometryHandler.d.ts +0 -76
- package/types/entity/Label.d.ts +0 -194
- package/types/entity/LabelHandler.d.ts +0 -24
- package/types/entity/PointCloud.d.ts +0 -174
- package/types/entity/PointCloudHandler.d.ts +0 -38
- package/types/entity/Polyline.d.ts +0 -304
- package/types/entity/PolylineHandler.d.ts +0 -18
- package/types/entity/Ray.d.ts +0 -123
- package/types/entity/RayHandler.d.ts +0 -67
- package/types/entity/ShapeHandler.d.ts +0 -22
- package/types/entity/Strip.d.ts +0 -118
- package/types/entity/StripHandler.d.ts +0 -38
- package/types/entity/index.d.ts +0 -8
- package/types/index.core.d.ts +0 -65
- package/types/index.d.ts +0 -45
- package/types/index.webgl.d.ts +0 -7
- package/types/inherits.d.ts +0 -4
- package/types/input/KeyboardHandler.d.ts +0 -10
- package/types/input/MouseHandler.d.ts +0 -5
- package/types/input/TouchHandler.d.ts +0 -5
- package/types/input/input.d.ts +0 -34
- package/types/layer/BaseGeoImage.d.ts +0 -107
- package/types/layer/CanvasTiles.d.ts +0 -75
- package/types/layer/GeoImage.d.ts +0 -65
- package/types/layer/GeoTexture2d.d.ts +0 -8
- package/types/layer/GeoVideo.d.ts +0 -80
- package/types/layer/KML.d.ts +0 -58
- package/types/layer/Layer.d.ts +0 -321
- package/types/layer/Material.d.ts +0 -48
- package/types/layer/Vector.d.ts +0 -228
- package/types/layer/WMS.d.ts +0 -66
- package/types/layer/XYZ.d.ts +0 -130
- package/types/layer/index.d.ts +0 -10
- package/types/light/LightSource.d.ts +0 -177
- package/types/math/Line2.d.ts +0 -11
- package/types/math/Line3.d.ts +0 -10
- package/types/math/Mat3.d.ts +0 -63
- package/types/math/Mat4.d.ts +0 -173
- package/types/math/Plane.d.ts +0 -17
- package/types/math/Quat.d.ts +0 -376
- package/types/math/Ray.d.ts +0 -81
- package/types/math/Vec2.d.ts +0 -308
- package/types/math/Vec3.d.ts +0 -459
- package/types/math/Vec4.d.ts +0 -161
- package/types/math/coder.d.ts +0 -42
- package/types/math/index.d.ts +0 -11
- package/types/math.d.ts +0 -261
- package/types/mercator.d.ts +0 -92
- package/types/proj/EPSG3857.d.ts +0 -5
- package/types/proj/EPSG4326.d.ts +0 -5
- package/types/proj/Proj.d.ts +0 -42
- package/types/quadTree/EntityCollectionNode.d.ts +0 -34
- package/types/quadTree/Node.d.ts +0 -61
- package/types/quadTree/quadTree.d.ts +0 -40
- package/types/renderer/Renderer.d.ts +0 -296
- package/types/renderer/RendererEvents.d.ts +0 -230
- package/types/res/images.d.ts +0 -3
- package/types/scene/Axes.d.ts +0 -11
- package/types/scene/BaseNode.d.ts +0 -60
- package/types/scene/Planet.d.ts +0 -574
- package/types/scene/RenderNode.d.ts +0 -143
- package/types/scene/SkyBox.d.ts +0 -10
- package/types/scene/index.d.ts +0 -4
- package/types/segment/Segment.d.ts +0 -271
- package/types/segment/SegmentLonLat.d.ts +0 -62
- package/types/segment/segmentHelper.d.ts +0 -13
- package/types/shaders/billboard.d.ts +0 -3
- package/types/shaders/depth.d.ts +0 -2
- package/types/shaders/drawnode.d.ts +0 -7
- package/types/shaders/label.d.ts +0 -4
- package/types/shaders/pointCloud.d.ts +0 -2
- package/types/shaders/polyline.d.ts +0 -3
- package/types/shaders/ray.d.ts +0 -2
- package/types/shaders/screenFrame.d.ts +0 -2
- package/types/shaders/shape.d.ts +0 -4
- package/types/shaders/skybox.d.ts +0 -2
- package/types/shaders/toneMapping.d.ts +0 -2
- package/types/shapes/BaseShape.d.ts +0 -247
- package/types/shapes/Sphere.d.ts +0 -41
- package/types/terrain/BilTerrain.d.ts +0 -8
- package/types/terrain/EmptyTerrain.d.ts +0 -72
- package/types/terrain/Geoid.d.ts +0 -26
- package/types/terrain/GlobusTerrain.d.ts +0 -153
- package/types/terrain/MapboxTerrain.d.ts +0 -8
- package/types/terrain/index.d.ts +0 -5
- package/types/utils/FontAtlas.d.ts +0 -14
- package/types/utils/GeoImageCreator.d.ts +0 -30
- package/types/utils/ImagesCacheManager.d.ts +0 -10
- package/types/utils/Loader.d.ts +0 -25
- package/types/utils/NormalMapCreator.d.ts +0 -39
- package/types/utils/PlainSegmentWorker.d.ts +0 -10
- package/types/utils/TerrainWorker.d.ts +0 -9
- package/types/utils/TextureAtlas.d.ts +0 -111
- package/types/utils/VectorTileCreator.d.ts +0 -16
- package/types/utils/colorTable.d.ts +0 -143
- package/types/utils/earcut.d.ts +0 -6
- package/types/utils/shared.d.ts +0 -230
- package/types/webgl/Framebuffer.d.ts +0 -135
- package/types/webgl/Handler.d.ts +0 -372
- package/types/webgl/Multisample.d.ts +0 -89
- package/types/webgl/Program.d.ts +0 -155
- package/types/webgl/ProgramController.d.ts +0 -84
- package/types/webgl/callbacks.d.ts +0 -1
- package/types/webgl/index.d.ts +0 -6
- package/types/webgl/types.d.ts +0 -2
package/src/og/math/Quat.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
import * as math from
|
|
4
|
-
import { Mat3 } from
|
|
5
|
-
import { Mat4 } from
|
|
6
|
-
import { Vec3 } from
|
|
3
|
+
import * as math from "../math.js";
|
|
4
|
+
import { Mat3 } from "./Mat3.js";
|
|
5
|
+
import { Mat4 } from "./Mat4.js";
|
|
6
|
+
import { Vec3 } from "./Vec3.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space.
|
|
@@ -14,7 +14,6 @@ import { Vec3 } from './Vec3.js';
|
|
|
14
14
|
* @param {Number} [w=0.0] The W component.
|
|
15
15
|
*/
|
|
16
16
|
export class Quat {
|
|
17
|
-
|
|
18
17
|
/**
|
|
19
18
|
* @param {Number} [x=0.0] The X component.
|
|
20
19
|
* @param {Number} [y=0.0] The Y component.
|
|
@@ -58,7 +57,7 @@ export class Quat {
|
|
|
58
57
|
/**
|
|
59
58
|
* Identity Quat.
|
|
60
59
|
* @const
|
|
61
|
-
* @type {
|
|
60
|
+
* @type {Quat}
|
|
62
61
|
*/
|
|
63
62
|
static get IDENTITY() {
|
|
64
63
|
return new Quat(0.0, 0.0, 0.0, 1.0);
|
|
@@ -68,7 +67,7 @@ export class Quat {
|
|
|
68
67
|
* Returns a Quat represents rotation around X axis.
|
|
69
68
|
* @static
|
|
70
69
|
* @param {number} a - The angle in radians to rotate around the axis.
|
|
71
|
-
* @returns {
|
|
70
|
+
* @returns {Quat} -
|
|
72
71
|
*/
|
|
73
72
|
static xRotation(a) {
|
|
74
73
|
a *= 0.5;
|
|
@@ -79,7 +78,7 @@ export class Quat {
|
|
|
79
78
|
* Returns a Quat represents rotation around Y axis.
|
|
80
79
|
* @static
|
|
81
80
|
* @param {number} a - The angle in radians to rotate around the axis.
|
|
82
|
-
* @returns {
|
|
81
|
+
* @returns {Quat} -
|
|
83
82
|
*/
|
|
84
83
|
static yRotation(a) {
|
|
85
84
|
a *= 0.5;
|
|
@@ -90,7 +89,7 @@ export class Quat {
|
|
|
90
89
|
* Returns a Quat represents rotation around Z axis.
|
|
91
90
|
* @static
|
|
92
91
|
* @param {number} a - The angle in radians to rotate around the axis.
|
|
93
|
-
* @returns {
|
|
92
|
+
* @returns {Quat} -
|
|
94
93
|
*/
|
|
95
94
|
static zRotation(a) {
|
|
96
95
|
a *= 0.5;
|
|
@@ -100,90 +99,65 @@ export class Quat {
|
|
|
100
99
|
/**
|
|
101
100
|
* Computes a Quat representing a rotation around an axis.
|
|
102
101
|
* @static
|
|
103
|
-
* @param {
|
|
102
|
+
* @param {Vec3} axis - The axis of rotation.
|
|
104
103
|
* @param {number} [angle=0.0] The angle in radians to rotate around the axis.
|
|
105
|
-
* @returns {
|
|
104
|
+
* @returns {Quat} -
|
|
106
105
|
*/
|
|
107
106
|
static axisAngleToQuat(axis, angle) {
|
|
108
107
|
angle = angle || 0.0;
|
|
109
108
|
var v = axis.normal();
|
|
110
109
|
var half_angle = angle * 0.5;
|
|
111
110
|
var sin_a = Math.sin(half_angle);
|
|
112
|
-
return new Quat(
|
|
113
|
-
v.x * sin_a,
|
|
114
|
-
v.y * sin_a,
|
|
115
|
-
v.z * sin_a,
|
|
116
|
-
Math.cos(half_angle));
|
|
111
|
+
return new Quat(v.x * sin_a, v.y * sin_a, v.z * sin_a, Math.cos(half_angle));
|
|
117
112
|
}
|
|
118
113
|
|
|
119
114
|
/**
|
|
120
115
|
* Computes a rotation from the given heading and up vector.
|
|
121
116
|
* @static
|
|
122
|
-
* @param {
|
|
123
|
-
* @param {
|
|
124
|
-
* @returns {
|
|
117
|
+
* @param {Vec3} forward - Heading target coordinates.
|
|
118
|
+
* @param {Vec3} up - Up vector.
|
|
119
|
+
* @returns {Quat} -
|
|
125
120
|
*/
|
|
126
121
|
static getLookRotation(forward, up) {
|
|
127
|
-
|
|
128
122
|
var f = forward.normal().negate();
|
|
129
|
-
var s =
|
|
123
|
+
var s = up.cross(f).normalize();
|
|
130
124
|
var u = f.cross(s);
|
|
131
125
|
|
|
132
126
|
var z = 1.0 + s.x + u.y + f.z;
|
|
133
127
|
|
|
134
128
|
if (z > 0.000001) {
|
|
135
129
|
let fd = 1.0 / (2.0 * Math.sqrt(z));
|
|
136
|
-
return new Quat(
|
|
137
|
-
(f.y - u.z) * fd,
|
|
138
|
-
(s.z - f.x) * fd,
|
|
139
|
-
(u.x - s.y) * fd,
|
|
140
|
-
0.25 / fd
|
|
141
|
-
);
|
|
130
|
+
return new Quat((f.y - u.z) * fd, (s.z - f.x) * fd, (u.x - s.y) * fd, 0.25 / fd);
|
|
142
131
|
}
|
|
143
132
|
|
|
144
133
|
if (s.x > u.y && s.x > f.z) {
|
|
145
134
|
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + s.x - u.y - f.z));
|
|
146
|
-
return new Quat(
|
|
147
|
-
0.25 / fd,
|
|
148
|
-
(u.x + s.y) * fd,
|
|
149
|
-
(s.z + f.x) * fd,
|
|
150
|
-
(f.y - u.z) * fd
|
|
151
|
-
);
|
|
135
|
+
return new Quat(0.25 / fd, (u.x + s.y) * fd, (s.z + f.x) * fd, (f.y - u.z) * fd);
|
|
152
136
|
}
|
|
153
137
|
|
|
154
138
|
if (u.y > f.z) {
|
|
155
139
|
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + u.y - s.x - f.z));
|
|
156
|
-
return new Quat(
|
|
157
|
-
(u.x + s.y) * fd,
|
|
158
|
-
0.25 / fd,
|
|
159
|
-
(f.y + u.z) * fd,
|
|
160
|
-
(s.z - f.x) * fd
|
|
161
|
-
);
|
|
140
|
+
return new Quat((u.x + s.y) * fd, 0.25 / fd, (f.y + u.z) * fd, (s.z - f.x) * fd);
|
|
162
141
|
}
|
|
163
142
|
|
|
164
143
|
let fd = 1.0 / (2.0 * Math.sqrt(1.0 + f.z - s.x - u.y));
|
|
165
|
-
return new Quat(
|
|
166
|
-
(s.z + f.x) * fd,
|
|
167
|
-
(f.y + u.z) * fd,
|
|
168
|
-
0.25 / fd,
|
|
169
|
-
(u.x - s.y) * fd
|
|
170
|
-
);
|
|
144
|
+
return new Quat((s.z + f.x) * fd, (f.y + u.z) * fd, 0.25 / fd, (u.x - s.y) * fd);
|
|
171
145
|
}
|
|
172
146
|
|
|
173
147
|
/**
|
|
174
148
|
* Computes a Quat from from source point heading to the destination point.
|
|
175
149
|
* @static
|
|
176
|
-
* @param {
|
|
177
|
-
* @param {
|
|
178
|
-
* @returns {
|
|
150
|
+
* @param {Vec3} sourcePoint - Source coordinate.
|
|
151
|
+
* @param {Vec3} destPoint - Destination coordinate.
|
|
152
|
+
* @returns {Quat} -
|
|
179
153
|
*/
|
|
180
154
|
static getLookAtSourceDest(sourcePoint, destPoint) {
|
|
181
155
|
var forwardVector = destPoint.subA(sourcePoint).normalize();
|
|
182
156
|
var dot = Vec3.FORWARD.dot(forwardVector);
|
|
183
|
-
if (Math.abs(dot -
|
|
157
|
+
if (Math.abs(dot - -1.0) < 0.000001) {
|
|
184
158
|
return Quat.axisAngleToQuat(Vec3.UP, Math.PI);
|
|
185
159
|
}
|
|
186
|
-
if (Math.abs(dot -
|
|
160
|
+
if (Math.abs(dot - 1.0) < 0.000001) {
|
|
187
161
|
return new Quat(0.0, 0.0, 0.0, 1.0);
|
|
188
162
|
}
|
|
189
163
|
var rotAngle = Math.acos(dot);
|
|
@@ -194,9 +168,9 @@ export class Quat {
|
|
|
194
168
|
/**
|
|
195
169
|
* Compute rotation between two vectors.
|
|
196
170
|
* @static
|
|
197
|
-
* @param {
|
|
198
|
-
* @param {
|
|
199
|
-
* @returns {
|
|
171
|
+
* @param {Vec3} u - First vector.
|
|
172
|
+
* @param {Vec3} v - Second vector.
|
|
173
|
+
* @returns {Quat} -
|
|
200
174
|
*/
|
|
201
175
|
static getRotationBetweenVectors(u, v) {
|
|
202
176
|
var w = u.cross(v);
|
|
@@ -207,10 +181,10 @@ export class Quat {
|
|
|
207
181
|
/**
|
|
208
182
|
* Compute rotation between two vectors.
|
|
209
183
|
* @static
|
|
210
|
-
* @param {
|
|
211
|
-
* @param {
|
|
184
|
+
* @param {Vec3} u - First vector.
|
|
185
|
+
* @param {Vec3} v - Second vector.
|
|
212
186
|
* @param {Quat} res
|
|
213
|
-
* @returns {
|
|
187
|
+
* @returns {Quat} -
|
|
214
188
|
*/
|
|
215
189
|
static getRotationBetweenVectorsRes(u, v, res) {
|
|
216
190
|
var w = u.cross(v);
|
|
@@ -219,19 +193,19 @@ export class Quat {
|
|
|
219
193
|
}
|
|
220
194
|
|
|
221
195
|
/**
|
|
222
|
-
* Compute rotation between two vectors with around vector up
|
|
196
|
+
* Compute rotation between two vectors with around vector up
|
|
223
197
|
* for exactly opposite vectors. If vectors exaclty in the same
|
|
224
198
|
* direction than returns identity Quat.
|
|
225
199
|
* @static
|
|
226
|
-
* @param {
|
|
227
|
-
* @param {
|
|
228
|
-
* @param {
|
|
229
|
-
* @returns {
|
|
200
|
+
* @param {Vec3} source - First vector.
|
|
201
|
+
* @param {Vec3} dest - Second vector.
|
|
202
|
+
* @param {Vec3} up - Up vector.
|
|
203
|
+
* @returns {Quat} -
|
|
230
204
|
*/
|
|
231
205
|
static getRotationBetweenVectorsUp(source, dest, up) {
|
|
232
206
|
var dot = source.dot(dest);
|
|
233
207
|
if (Math.abs(dot + 1.0) < 0.000001) {
|
|
234
|
-
// vector source and dest point exactly in the opposite direction,
|
|
208
|
+
// vector source and dest point exactly in the opposite direction,
|
|
235
209
|
// so it is a 180 degrees turn around the up-axis
|
|
236
210
|
return Quat.axisAngleToQuat(up, Math.PI);
|
|
237
211
|
}
|
|
@@ -244,12 +218,12 @@ export class Quat {
|
|
|
244
218
|
var rotAxis = source.cross(dest).normalize();
|
|
245
219
|
return Quat.axisAngleToQuat(rotAxis, rotAngle);
|
|
246
220
|
}
|
|
247
|
-
|
|
221
|
+
|
|
248
222
|
/**
|
|
249
223
|
* Returns true if the components are zero.
|
|
250
224
|
* @public
|
|
251
|
-
* @param {
|
|
252
|
-
* @returns {
|
|
225
|
+
* @param {Quat} q - Quat to subtract.
|
|
226
|
+
* @returns {Quat} -
|
|
253
227
|
*/
|
|
254
228
|
isZero() {
|
|
255
229
|
return this.x === 0.0 && this.y === 0.0 && this.z === 0.0 && this.w === 0.0;
|
|
@@ -258,7 +232,7 @@ export class Quat {
|
|
|
258
232
|
/**
|
|
259
233
|
* Clear Quat. Sets zeroes.
|
|
260
234
|
* @public
|
|
261
|
-
* @returns {
|
|
235
|
+
* @returns {Quat} -
|
|
262
236
|
*/
|
|
263
237
|
clear() {
|
|
264
238
|
this.x = this.y = this.z = this.w = 0;
|
|
@@ -272,7 +246,7 @@ export class Quat {
|
|
|
272
246
|
* @param {Number} [y=0.0] The Y component.
|
|
273
247
|
* @param {Number} [z=0.0] The Z component.
|
|
274
248
|
* @param {Number} [w=0.0] The W component.
|
|
275
|
-
* @returns {
|
|
249
|
+
* @returns {Quat} -
|
|
276
250
|
*/
|
|
277
251
|
set(x, y, z, w) {
|
|
278
252
|
this.x = x;
|
|
@@ -285,8 +259,8 @@ export class Quat {
|
|
|
285
259
|
/**
|
|
286
260
|
* Copy Quat values.
|
|
287
261
|
* @public
|
|
288
|
-
* @param {
|
|
289
|
-
* @returns {
|
|
262
|
+
* @param {Quat} q - Copy Quat.
|
|
263
|
+
* @returns {Quat} -
|
|
290
264
|
*/
|
|
291
265
|
copy(q) {
|
|
292
266
|
this.x = q.x;
|
|
@@ -299,7 +273,7 @@ export class Quat {
|
|
|
299
273
|
/**
|
|
300
274
|
* Set current Quat instance to identity Quat.
|
|
301
275
|
* @public
|
|
302
|
-
* @returns {
|
|
276
|
+
* @returns {Quat} -
|
|
303
277
|
*/
|
|
304
278
|
setIdentity() {
|
|
305
279
|
this.x = 0.0;
|
|
@@ -312,7 +286,7 @@ export class Quat {
|
|
|
312
286
|
/**
|
|
313
287
|
* Duplicates a Quat instance.
|
|
314
288
|
* @public
|
|
315
|
-
* @returns {
|
|
289
|
+
* @returns {Quat} -
|
|
316
290
|
*/
|
|
317
291
|
clone() {
|
|
318
292
|
return new Quat(this.x, this.y, this.z, this.w);
|
|
@@ -321,8 +295,8 @@ export class Quat {
|
|
|
321
295
|
/**
|
|
322
296
|
* Computes the componentwise sum of two Quats.
|
|
323
297
|
* @public
|
|
324
|
-
* @param {
|
|
325
|
-
* @returns {
|
|
298
|
+
* @param {Quat} q - Quat to add.
|
|
299
|
+
* @returns {Quat} -
|
|
326
300
|
*/
|
|
327
301
|
add(q) {
|
|
328
302
|
return new Quat(this.x + q.x, this.y + q.y, this.z + q.z, this.w + q.w);
|
|
@@ -331,8 +305,8 @@ export class Quat {
|
|
|
331
305
|
/**
|
|
332
306
|
* Computes the componentwise difference of two Quats.
|
|
333
307
|
* @public
|
|
334
|
-
* @param {
|
|
335
|
-
* @returns {
|
|
308
|
+
* @param {Quat} q - Quat to subtract.
|
|
309
|
+
* @returns {Quat} -
|
|
336
310
|
*/
|
|
337
311
|
sub(q) {
|
|
338
312
|
return new Quat(this.x - q.x, this.y - q.y, this.z - q.z, this.w - q.w);
|
|
@@ -342,7 +316,7 @@ export class Quat {
|
|
|
342
316
|
* Multiplies the provided Quat componentwise by the provided scalar.
|
|
343
317
|
* @public
|
|
344
318
|
* @param {Number} scale - The scalar to multiply with.
|
|
345
|
-
* @returns {
|
|
319
|
+
* @returns {Quat} -
|
|
346
320
|
*/
|
|
347
321
|
scaleTo(scale) {
|
|
348
322
|
return new Quat(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
|
|
@@ -352,10 +326,13 @@ export class Quat {
|
|
|
352
326
|
* Multiplies the provided Quat componentwise.
|
|
353
327
|
* @public
|
|
354
328
|
* @param {Number} scale - The scalar to multiply with.
|
|
355
|
-
* @returns {
|
|
329
|
+
* @returns {Quat} -
|
|
356
330
|
*/
|
|
357
331
|
scale(scale) {
|
|
358
|
-
this.x *= scale;
|
|
332
|
+
this.x *= scale;
|
|
333
|
+
this.y *= scale;
|
|
334
|
+
this.z *= scale;
|
|
335
|
+
this.w *= scale;
|
|
359
336
|
return this;
|
|
360
337
|
}
|
|
361
338
|
|
|
@@ -374,7 +351,7 @@ export class Quat {
|
|
|
374
351
|
* @param {number} lat - Latitude.
|
|
375
352
|
* @param {number} lon - Longitude.
|
|
376
353
|
* @param {number} angle - Angle in radians.
|
|
377
|
-
* @returns {
|
|
354
|
+
* @returns {Quat} -
|
|
378
355
|
*/
|
|
379
356
|
setFromSphericalCoords(lat, lon, angle) {
|
|
380
357
|
var sin_a = Math.sin(angle / 2);
|
|
@@ -393,14 +370,13 @@ export class Quat {
|
|
|
393
370
|
/**
|
|
394
371
|
* Sets rotation with the given heading and up vectors.
|
|
395
372
|
* @static
|
|
396
|
-
* @param {
|
|
397
|
-
* @param {
|
|
398
|
-
* @returns {
|
|
373
|
+
* @param {Vec3} forward - Heading target coordinates.
|
|
374
|
+
* @param {Vec3} up - Up vector.
|
|
375
|
+
* @returns {Quat} -
|
|
399
376
|
*/
|
|
400
377
|
setLookRotation(forward, up) {
|
|
401
|
-
|
|
402
378
|
var f = forward.normal().negate();
|
|
403
|
-
var s =
|
|
379
|
+
var s = up.cross(f).normalize();
|
|
404
380
|
var u = f.cross(s);
|
|
405
381
|
|
|
406
382
|
var z = 1.0 + s.x + u.y + f.z;
|
|
@@ -437,7 +413,7 @@ export class Quat {
|
|
|
437
413
|
/**
|
|
438
414
|
* Gets spherical coordinates.
|
|
439
415
|
* @public
|
|
440
|
-
* @returns {Object} Returns object with latitude, longitude and alpha.
|
|
416
|
+
* @returns {Object} Returns object with latitude, longitude and alpha.
|
|
441
417
|
*/
|
|
442
418
|
toSphericalCoords() {
|
|
443
419
|
var cos_a = this.w;
|
|
@@ -450,7 +426,8 @@ export class Quat {
|
|
|
450
426
|
var ty = this.y / sin_a;
|
|
451
427
|
var tz = this.z / sin_a;
|
|
452
428
|
|
|
453
|
-
var lon,
|
|
429
|
+
var lon,
|
|
430
|
+
lat = -Math.asin(ty);
|
|
454
431
|
if (tx * tx + tz * tz < 0.0005) {
|
|
455
432
|
lon = 0;
|
|
456
433
|
} else {
|
|
@@ -466,9 +443,9 @@ export class Quat {
|
|
|
466
443
|
/**
|
|
467
444
|
* Sets current Quat representing a rotation around an axis.
|
|
468
445
|
* @public
|
|
469
|
-
* @param {
|
|
446
|
+
* @param {Vec3} axis - The axis of rotation.
|
|
470
447
|
* @param {number} angle The angle in radians to rotate around the axis.
|
|
471
|
-
* @returns {
|
|
448
|
+
* @returns {Quat} -
|
|
472
449
|
*/
|
|
473
450
|
setFromAxisAngle(axis, angle) {
|
|
474
451
|
var v = axis.normal();
|
|
@@ -484,15 +461,19 @@ export class Quat {
|
|
|
484
461
|
* @returns {Object} -
|
|
485
462
|
*/
|
|
486
463
|
getAxisAngle() {
|
|
487
|
-
|
|
464
|
+
let x = this.x,
|
|
465
|
+
y = this.y,
|
|
466
|
+
z = this.z,
|
|
467
|
+
w = this.w;
|
|
468
|
+
var vl = Math.sqrt(x * x + y * y + z * z);
|
|
488
469
|
var axis, angle;
|
|
489
470
|
if (vl > 0.0000001) {
|
|
490
471
|
var ivl = 1.0 / vl;
|
|
491
472
|
axis = new Vec3(x * ivl, y * ivl, z * ivl);
|
|
492
|
-
if (
|
|
493
|
-
angle = 2.0 * Math.atan2(-vl, -w); // -PI,0
|
|
473
|
+
if (w < 0) {
|
|
474
|
+
angle = 2.0 * Math.atan2(-vl, -w); // -PI,0
|
|
494
475
|
} else {
|
|
495
|
-
angle = 2.0 * Math.atan2(vl, w); // 0,PI
|
|
476
|
+
angle = 2.0 * Math.atan2(vl, w); // 0,PI
|
|
496
477
|
}
|
|
497
478
|
} else {
|
|
498
479
|
axis = new Vec3(0, 0, 0);
|
|
@@ -507,7 +488,7 @@ export class Quat {
|
|
|
507
488
|
* @param {number} pitch - Pitch angle in degrees.
|
|
508
489
|
* @param {number} yaw - Yaw angle in degrees.
|
|
509
490
|
* @param {number} roll - Roll angle in degrees.
|
|
510
|
-
* @returns {
|
|
491
|
+
* @returns {Quat} -
|
|
511
492
|
*/
|
|
512
493
|
setFromEulerAngles(pitch, yaw, roll) {
|
|
513
494
|
var ex = pitch * math.RADIANS_HALF,
|
|
@@ -539,8 +520,10 @@ export class Quat {
|
|
|
539
520
|
* @returns {Object} -
|
|
540
521
|
*/
|
|
541
522
|
getEulerAngles() {
|
|
542
|
-
|
|
543
|
-
|
|
523
|
+
let x = this.x,
|
|
524
|
+
y = this.y,
|
|
525
|
+
z = this.z,
|
|
526
|
+
w = this.w;
|
|
544
527
|
|
|
545
528
|
let sqy = y * y;
|
|
546
529
|
|
|
@@ -563,11 +546,13 @@ export class Quat {
|
|
|
563
546
|
/**
|
|
564
547
|
* Computes a Quat from the provided 4x4 matrix instance.
|
|
565
548
|
* @public
|
|
566
|
-
* @param {
|
|
567
|
-
* @returns {
|
|
549
|
+
* @param {Mat4} m - The rotation matrix.
|
|
550
|
+
* @returns {Quat} -
|
|
568
551
|
*/
|
|
569
552
|
setFromMatrix4(m) {
|
|
570
|
-
var tr,
|
|
553
|
+
var tr,
|
|
554
|
+
s,
|
|
555
|
+
q = [];
|
|
571
556
|
var i, j, k;
|
|
572
557
|
m = m._m;
|
|
573
558
|
|
|
@@ -589,7 +574,7 @@ export class Quat {
|
|
|
589
574
|
j = nxt[i];
|
|
590
575
|
k = nxt[j];
|
|
591
576
|
|
|
592
|
-
s = Math.sqrt(
|
|
577
|
+
s = Math.sqrt(m[i * 5] - (m[j * 5] + m[k * 5]) + 1.0);
|
|
593
578
|
|
|
594
579
|
q[i] = s * 0.5;
|
|
595
580
|
|
|
@@ -610,7 +595,7 @@ export class Quat {
|
|
|
610
595
|
/**
|
|
611
596
|
* Converts current Quat to the rotation 4x4 matrix.
|
|
612
597
|
* @public
|
|
613
|
-
* @returns {
|
|
598
|
+
* @returns {Mat4} -
|
|
614
599
|
*/
|
|
615
600
|
getMat4(out) {
|
|
616
601
|
var xs = this.x + this.x;
|
|
@@ -626,13 +611,30 @@ export class Quat {
|
|
|
626
611
|
var yz = this.y * zs;
|
|
627
612
|
var zz = this.z * zs;
|
|
628
613
|
var m = out || new Mat4();
|
|
629
|
-
return m.set([
|
|
614
|
+
return m.set([
|
|
615
|
+
1 - (yy + zz),
|
|
616
|
+
xy - wz,
|
|
617
|
+
xz + wy,
|
|
618
|
+
0,
|
|
619
|
+
xy + wz,
|
|
620
|
+
1 - (xx + zz),
|
|
621
|
+
yz - wx,
|
|
622
|
+
0,
|
|
623
|
+
xz - wy,
|
|
624
|
+
yz + wx,
|
|
625
|
+
1 - (xx + yy),
|
|
626
|
+
0,
|
|
627
|
+
0,
|
|
628
|
+
0,
|
|
629
|
+
0,
|
|
630
|
+
1
|
|
631
|
+
]);
|
|
630
632
|
}
|
|
631
633
|
|
|
632
634
|
/**
|
|
633
635
|
* Converts current Quat to the rotation 3x3 matrix.
|
|
634
636
|
* @public
|
|
635
|
-
* @returns {
|
|
637
|
+
* @returns {Mat3} -
|
|
636
638
|
* @todo NOT TESTED
|
|
637
639
|
*/
|
|
638
640
|
getMat3() {
|
|
@@ -658,9 +660,15 @@ export class Quat {
|
|
|
658
660
|
h = g * h;
|
|
659
661
|
g = g * i;
|
|
660
662
|
|
|
661
|
-
mx[0] = 1 - (l + e);
|
|
662
|
-
mx[
|
|
663
|
-
mx[
|
|
663
|
+
mx[0] = 1 - (l + e);
|
|
664
|
+
mx[1] = k - g;
|
|
665
|
+
mx[2] = c + h;
|
|
666
|
+
mx[3] = k + g;
|
|
667
|
+
mx[4] = 1 - (j + e);
|
|
668
|
+
mx[5] = d - f;
|
|
669
|
+
mx[6] = c - h;
|
|
670
|
+
mx[7] = d + f;
|
|
671
|
+
mx[8] = 1 - (j + l);
|
|
664
672
|
|
|
665
673
|
return m;
|
|
666
674
|
}
|
|
@@ -668,11 +676,10 @@ export class Quat {
|
|
|
668
676
|
/**
|
|
669
677
|
* Returns quatrenion and vector production.
|
|
670
678
|
* @public
|
|
671
|
-
* @param {
|
|
672
|
-
* @returns {
|
|
679
|
+
* @param {Vec3} v - 3d Vector.
|
|
680
|
+
* @returns {Vec3} -
|
|
673
681
|
*/
|
|
674
682
|
mulVec3(v) {
|
|
675
|
-
|
|
676
683
|
// t = 2 * cross(q.xyz, v)
|
|
677
684
|
// v' = v + q.w * t + cross(q.xyz, t)
|
|
678
685
|
|
|
@@ -694,34 +701,48 @@ export class Quat {
|
|
|
694
701
|
return new Vec3(
|
|
695
702
|
i * a + d * -b + j * -h - k * -f,
|
|
696
703
|
j * a + d * -f + k * -b - i * -h,
|
|
697
|
-
k * a + d * -h + i * -f - j * -b
|
|
704
|
+
k * a + d * -h + i * -f - j * -b
|
|
705
|
+
);
|
|
698
706
|
}
|
|
699
707
|
|
|
700
708
|
/**
|
|
701
709
|
* Computes the product of two Quats.
|
|
702
710
|
* @public
|
|
703
|
-
* @param {
|
|
704
|
-
* @returns {
|
|
711
|
+
* @param {Quat} q - Quat to multiply.
|
|
712
|
+
* @returns {Quat} -
|
|
705
713
|
*/
|
|
706
714
|
mul(q) {
|
|
707
|
-
var d = this.x,
|
|
708
|
-
|
|
715
|
+
var d = this.x,
|
|
716
|
+
e = this.y,
|
|
717
|
+
g = this.z,
|
|
718
|
+
a = this.w;
|
|
719
|
+
var f = q.x,
|
|
720
|
+
h = q.y,
|
|
721
|
+
i = q.z,
|
|
722
|
+
b = q.w;
|
|
709
723
|
return new Quat(
|
|
710
724
|
d * b + a * f + e * i - g * h,
|
|
711
725
|
e * b + a * h + g * f - d * i,
|
|
712
726
|
g * b + a * i + d * h - e * f,
|
|
713
|
-
a * b - d * f - e * h - g * i
|
|
727
|
+
a * b - d * f - e * h - g * i
|
|
728
|
+
);
|
|
714
729
|
}
|
|
715
730
|
|
|
716
731
|
/**
|
|
717
732
|
* Computes the product of two Quats.
|
|
718
733
|
* @public
|
|
719
|
-
* @param {
|
|
720
|
-
* @returns {
|
|
734
|
+
* @param {Quat} q - Quat to multiply.
|
|
735
|
+
* @returns {Quat} -
|
|
721
736
|
*/
|
|
722
737
|
mulA(q) {
|
|
723
|
-
var d = this.x,
|
|
724
|
-
|
|
738
|
+
var d = this.x,
|
|
739
|
+
e = this.y,
|
|
740
|
+
g = this.z,
|
|
741
|
+
a = this.w;
|
|
742
|
+
var f = q.x,
|
|
743
|
+
h = q.y,
|
|
744
|
+
i = q.z,
|
|
745
|
+
b = q.w;
|
|
725
746
|
this.x = d * b + a * f + e * i - g * h;
|
|
726
747
|
this.y = e * b + a * h + g * f - d * i;
|
|
727
748
|
this.z = g * b + a * i + d * h - e * f;
|
|
@@ -732,16 +753,16 @@ export class Quat {
|
|
|
732
753
|
/**
|
|
733
754
|
* Gets the conjugate of the Quat.
|
|
734
755
|
* @public
|
|
735
|
-
* @returns {
|
|
756
|
+
* @returns {Quat} -
|
|
736
757
|
*/
|
|
737
758
|
conjugate() {
|
|
738
759
|
return new Quat(-this.x, -this.y, -this.z, this.w);
|
|
739
760
|
}
|
|
740
761
|
|
|
741
|
-
/**
|
|
762
|
+
/**
|
|
742
763
|
* Computes the inverse of the Quat.
|
|
743
764
|
* @public
|
|
744
|
-
* @returns {
|
|
765
|
+
* @returns {Quat} -
|
|
745
766
|
*/
|
|
746
767
|
inverse() {
|
|
747
768
|
var n = 1 / this.magnitude2();
|
|
@@ -754,7 +775,10 @@ export class Quat {
|
|
|
754
775
|
* @returns {number} -
|
|
755
776
|
*/
|
|
756
777
|
magnitude() {
|
|
757
|
-
var b = this.x,
|
|
778
|
+
var b = this.x,
|
|
779
|
+
c = this.y,
|
|
780
|
+
d = this.z,
|
|
781
|
+
a = this.w;
|
|
758
782
|
return Math.sqrt(b * b + c * c + d * d + a * a);
|
|
759
783
|
}
|
|
760
784
|
|
|
@@ -764,14 +788,17 @@ export class Quat {
|
|
|
764
788
|
* @returns {number} -
|
|
765
789
|
*/
|
|
766
790
|
magnitude2() {
|
|
767
|
-
var b = this.x,
|
|
791
|
+
var b = this.x,
|
|
792
|
+
c = this.y,
|
|
793
|
+
d = this.z,
|
|
794
|
+
a = this.w;
|
|
768
795
|
return b * b + c * c + d * d + a * a;
|
|
769
796
|
}
|
|
770
797
|
|
|
771
798
|
/**
|
|
772
799
|
* Computes the dot (scalar) product of two Quats.
|
|
773
800
|
* @public
|
|
774
|
-
* @param {
|
|
801
|
+
* @param {Quat} q - Second quatrnion.
|
|
775
802
|
* @returns {number} -
|
|
776
803
|
*/
|
|
777
804
|
dot(q) {
|
|
@@ -781,10 +808,13 @@ export class Quat {
|
|
|
781
808
|
/**
|
|
782
809
|
* Current Quat normalization.
|
|
783
810
|
* @public
|
|
784
|
-
* @returns {
|
|
811
|
+
* @returns {Quat} -
|
|
785
812
|
*/
|
|
786
813
|
normalize() {
|
|
787
|
-
var c = this.x,
|
|
814
|
+
var c = this.x,
|
|
815
|
+
d = this.y,
|
|
816
|
+
e = this.z,
|
|
817
|
+
g = this.w,
|
|
788
818
|
f = Math.sqrt(c * c + d * d + e * e + g * g);
|
|
789
819
|
if (f === 0.0) {
|
|
790
820
|
this.x = 0;
|
|
@@ -804,7 +834,7 @@ export class Quat {
|
|
|
804
834
|
/**
|
|
805
835
|
* Compares two Quats.
|
|
806
836
|
* @public
|
|
807
|
-
* @param {
|
|
837
|
+
* @param {Quat} q - Second quatrnion.
|
|
808
838
|
* @returns {Boolean} -
|
|
809
839
|
*/
|
|
810
840
|
isEqual(q) {
|
|
@@ -818,14 +848,19 @@ export class Quat {
|
|
|
818
848
|
/**
|
|
819
849
|
* Performs a spherical linear interpolation between two Quats.
|
|
820
850
|
* @public
|
|
821
|
-
* @param {
|
|
851
|
+
* @param {Quat} b - The end rotation Quat.
|
|
822
852
|
* @param {number} t - interpolation amount between the two Quats.
|
|
823
|
-
* @returns {
|
|
853
|
+
* @returns {Quat} -
|
|
824
854
|
*/
|
|
825
855
|
slerp(b, t) {
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
856
|
+
var ax = this.x,
|
|
857
|
+
ay = this.y,
|
|
858
|
+
az = this.z,
|
|
859
|
+
aw = this.w,
|
|
860
|
+
bx = b.x,
|
|
861
|
+
by = b.y,
|
|
862
|
+
bz = b.z,
|
|
863
|
+
bw = b.w;
|
|
829
864
|
|
|
830
865
|
var omega, cosom, sinom, scale0, scale1;
|
|
831
866
|
|
|
@@ -839,7 +874,7 @@ export class Quat {
|
|
|
839
874
|
bw = -bw;
|
|
840
875
|
}
|
|
841
876
|
|
|
842
|
-
if (
|
|
877
|
+
if (1.0 - cosom > 0.000001) {
|
|
843
878
|
omega = Math.acos(cosom);
|
|
844
879
|
sinom = Math.sin(omega);
|
|
845
880
|
scale0 = Math.sin((1.0 - t) * omega) / sinom;
|
|
@@ -864,7 +899,10 @@ export class Quat {
|
|
|
864
899
|
* @returns {Number} -
|
|
865
900
|
*/
|
|
866
901
|
getRoll(reprojectAxis) {
|
|
867
|
-
var x = this.x,
|
|
902
|
+
var x = this.x,
|
|
903
|
+
y = this.y,
|
|
904
|
+
z = this.z,
|
|
905
|
+
w = this.w;
|
|
868
906
|
if (reprojectAxis) {
|
|
869
907
|
var fTy = 2.0 * y;
|
|
870
908
|
var fTz = 2.0 * z;
|
|
@@ -885,7 +923,10 @@ export class Quat {
|
|
|
885
923
|
* @returns {number} -
|
|
886
924
|
*/
|
|
887
925
|
getPitch(reprojectAxis) {
|
|
888
|
-
var x = this.x,
|
|
926
|
+
var x = this.x,
|
|
927
|
+
y = this.y,
|
|
928
|
+
z = this.z,
|
|
929
|
+
w = this.w;
|
|
889
930
|
if (reprojectAxis) {
|
|
890
931
|
var fTx = 2.0 * x;
|
|
891
932
|
var fTz = 2.0 * z;
|
|
@@ -906,7 +947,10 @@ export class Quat {
|
|
|
906
947
|
* @returns {number} -
|
|
907
948
|
*/
|
|
908
949
|
getYaw(reprojectAxis) {
|
|
909
|
-
var x = this.x,
|
|
950
|
+
var x = this.x,
|
|
951
|
+
y = this.y,
|
|
952
|
+
z = this.z,
|
|
953
|
+
w = this.w;
|
|
910
954
|
if (reprojectAxis) {
|
|
911
955
|
var fTx = 2.0 * x;
|
|
912
956
|
var fTy = 2.0 * y;
|
|
@@ -929,9 +973,8 @@ export class Quat {
|
|
|
929
973
|
* @param {Number} [y=0.0] The Y component.
|
|
930
974
|
* @param {Number} [z=0.0] The Z component.
|
|
931
975
|
* @param {Number} [w=0.0] The W component.
|
|
932
|
-
* @returns {
|
|
976
|
+
* @returns {Quat} -
|
|
933
977
|
*/
|
|
934
978
|
export function quat(x, y, z, w) {
|
|
935
979
|
return new Quat(x, y, z, w);
|
|
936
980
|
}
|
|
937
|
-
|