@openglobus/og 0.11.1 → 0.11.6
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 +18 -20
- package/src/og/Clock.js +11 -11
- package/src/og/Deferred.js +1 -1
- package/src/og/Events.js +9 -7
- package/src/og/Extent.js +117 -72
- package/src/og/Globe.js +35 -22
- package/src/og/ImageCanvas.js +24 -18
- package/src/og/Lock.js +2 -2
- package/src/og/LonLat.js +40 -37
- package/src/og/Popup.js +21 -15
- package/src/og/QueueArray.js +7 -3
- package/src/og/Rectangle.js +11 -6
- package/src/og/Stack.js +8 -5
- package/src/og/ajax.js +21 -33
- package/src/og/astro/astro.js +5 -5
- package/src/og/astro/earth.js +23 -17
- package/src/og/astro/jd.js +44 -39
- package/src/og/astro/orbit.js +20 -18
- package/src/og/astro/rotation.js +17 -8
- package/src/og/bv/Box.js +7 -3
- package/src/og/bv/Sphere.js +17 -9
- package/src/og/camera/Camera.js +137 -86
- package/src/og/camera/Frustum.js +30 -19
- package/src/og/camera/PlanetCamera.js +30 -26
- package/src/og/control/CompassButton.js +8 -2
- package/src/og/control/Control.js +13 -11
- package/src/og/control/DebugInfo.js +4 -1
- package/src/og/control/EarthCoordinates.js +62 -41
- package/src/og/control/EarthNavigation.js +20 -22
- package/src/og/control/GeoImageDragControl.js +1 -1
- package/src/og/control/KeyboardNavigation.js +12 -12
- package/src/og/control/LayerSwitcher.js +24 -23
- package/src/og/control/Lighting.js +1 -1
- package/src/og/control/MouseNavigation.js +1 -1
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/SegmentBoundVisualization.js +8 -9
- package/src/og/control/ShowFps.js +15 -10
- package/src/og/control/SimpleNavigation.js +8 -10
- package/src/og/control/Sun.js +25 -15
- package/src/og/control/ToggleWireframe.js +5 -5
- package/src/og/control/TouchNavigation.js +58 -45
- package/src/og/control/ZoomControl.js +41 -25
- package/src/og/control/index.js +4 -0
- package/src/og/ellipsoid/Ellipsoid.js +181 -85
- package/src/og/ellipsoid/wgs84.js +4 -4
- package/src/og/entity/BaseBillboard.js +97 -44
- package/src/og/entity/Billboard.js +15 -11
- package/src/og/entity/BillboardHandler.js +314 -64
- package/src/og/entity/Entity.js +106 -74
- package/src/og/entity/EntityCollection.js +72 -49
- package/src/og/entity/GeoObject.js +228 -0
- package/src/og/entity/GeoObjectHandler.js +910 -0
- package/src/og/entity/Geometry.js +29 -26
- package/src/og/entity/GeometryHandler.js +598 -126
- package/src/og/entity/Label.js +74 -40
- package/src/og/entity/LabelHandler.js +47 -246
- package/src/og/entity/LabelWorker.js +213 -0
- package/src/og/entity/Object3d.js +504 -0
- package/src/og/entity/PointCloud.js +81 -33
- package/src/og/entity/PointCloudHandler.js +9 -9
- package/src/og/entity/Polyline.js +39 -39
- package/src/og/entity/Ray.js +61 -28
- package/src/og/entity/ShapeHandler.js +1 -1
- package/src/og/entity/Strip.js +77 -48
- package/src/og/entity/StripHandler.js +27 -27
- package/src/og/entity/index.js +8 -16
- package/src/og/input/KeyboardHandler.js +107 -104
- package/src/og/input/MouseHandler.js +81 -78
- package/src/og/input/TouchHandler.js +55 -51
- package/src/og/layer/BaseGeoImage.js +61 -30
- package/src/og/layer/CanvasTiles.js +26 -24
- package/src/og/layer/GeoImage.js +10 -10
- package/src/og/layer/GeoTexture2d.js +1 -1
- package/src/og/layer/GeoVideo.js +3 -3
- package/src/og/layer/KML.js +66 -40
- package/src/og/layer/Layer.js +27 -17
- package/src/og/layer/Material.js +93 -61
- package/src/og/layer/Vector.js +118 -72
- package/src/og/layer/WMS.js +36 -19
- package/src/og/layer/XYZ.js +55 -48
- package/src/og/light/LightSource.js +47 -40
- package/src/og/math/Line2.js +24 -24
- package/src/og/math/Line3.js +103 -102
- package/src/og/math/Mat3.js +134 -121
- package/src/og/math/Mat4.js +603 -459
- package/src/og/math/Plane.js +21 -20
- package/src/og/math/Quat.js +980 -927
- package/src/og/math/Ray.js +195 -187
- package/src/og/math/Vec2.js +127 -117
- package/src/og/math/Vec3.js +206 -176
- package/src/og/math/Vec4.js +49 -53
- package/src/og/math/coder.js +18 -18
- package/src/og/math.js +12 -12
- package/src/og/mercator.js +11 -11
- package/src/og/proj/EPSG3857.js +4 -4
- package/src/og/proj/EPSG4326.js +4 -4
- package/src/og/proj/Proj.js +31 -31
- package/src/og/quadTree/EntityCollectionNode.js +310 -300
- package/src/og/quadTree/Node.js +1008 -993
- package/src/og/renderer/Renderer.js +768 -747
- package/src/og/renderer/RendererEvents.js +9 -6
- package/src/og/scene/Axes.js +1 -1
- package/src/og/scene/BaseNode.js +8 -9
- package/src/og/scene/Planet.js +115 -87
- package/src/og/scene/RenderNode.js +29 -22
- package/src/og/scene/SkyBox.js +1 -1
- package/src/og/segment/Segment.js +1886 -1878
- package/src/og/segment/SegmentLonLat.js +298 -268
- package/src/og/segment/segmentHelper.js +11 -11
- package/src/og/shaders/bloom.js +1 -1
- package/src/og/shaders/blur.js +2 -2
- package/src/og/shaders/depth.js +1 -1
- package/src/og/shaders/geoObject.js +211 -0
- package/src/og/shaders/label.js +1 -1
- package/src/og/shaders/lumFilter.js +1 -1
- package/src/og/shaders/pointCloud.js +42 -42
- package/src/og/shaders/screenFrame.js +1 -1
- package/src/og/shaders/shape.js +15 -21
- package/src/og/shaders/skybox.js +37 -37
- package/src/og/shaders/toneMapping.js +1 -1
- package/src/og/shapes/BaseShape.js +129 -57
- package/src/og/shapes/Icosphere.js +30 -15
- package/src/og/shapes/Sphere.js +13 -16
- package/src/og/terrain/BilTerrain.js +2 -1
- package/src/og/terrain/EmptyTerrain.js +2 -2
- package/src/og/terrain/Geoid.js +2 -2
- package/src/og/terrain/GlobusTerrain.js +10 -10
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/GeoImageCreator.js +9 -9
- package/src/og/utils/Loader.js +6 -6
- package/src/og/utils/NormalMapCreator.js +13 -13
- package/src/og/utils/TerrainWorker.js +1 -1
- package/src/og/utils/TextureAtlas.js +20 -22
- package/src/og/utils/VectorTileCreator.js +5 -5
- package/src/og/utils/earcut.js +1 -1
- package/src/og/utils/shared.js +15 -15
- package/src/og/webgl/Framebuffer.js +101 -53
- package/src/og/webgl/Handler.js +125 -85
- package/src/og/webgl/Multisample.js +55 -27
- package/src/og/webgl/Program.js +80 -35
- package/src/og/webgl/ProgramController.js +27 -23
- package/src/og/webgl/callbacks.js +8 -8
- package/types/Clock.d.ts +6 -2
- package/types/Deferred.d.ts +1 -1
- package/types/Events.d.ts +8 -4
- package/types/Extent.d.ts +37 -33
- package/types/Globe.d.ts +15 -13
- package/types/ImageCanvas.d.ts +5 -3
- package/types/LonLat.d.ts +24 -24
- package/types/Popup.d.ts +4 -0
- package/types/QueueArray.d.ts +6 -2
- package/types/Rectangle.d.ts +10 -4
- package/types/Stack.d.ts +4 -0
- package/types/ajax.d.ts +1 -1
- package/types/astro/earth.d.ts +3 -2
- package/types/bv/Box.d.ts +10 -5
- package/types/bv/Sphere.d.ts +13 -7
- package/types/camera/Camera.d.ts +90 -81
- package/types/camera/Frustum.d.ts +26 -22
- package/types/camera/PlanetCamera.d.ts +49 -53
- package/types/control/CompassButton.d.ts +4 -4
- package/types/control/Control.d.ts +7 -4
- package/types/control/DebugInfo.d.ts +3 -4
- package/types/control/EarthCoordinates.d.ts +6 -6
- package/types/control/EarthNavigation.d.ts +42 -0
- package/types/control/KeyboardNavigation.d.ts +3 -4
- package/types/control/LayerSwitcher.d.ts +3 -5
- package/types/control/Lighting.d.ts +3 -3
- package/types/control/MouseNavigation.d.ts +47 -0
- package/types/control/ScaleControl.d.ts +3 -3
- package/types/control/ShowFps.d.ts +3 -4
- package/types/control/SimpleNavigation.d.ts +3 -6
- package/types/control/Sun.d.ts +8 -10
- package/types/control/ToggleWireframe.d.ts +3 -3
- package/types/control/TouchNavigation.d.ts +48 -0
- package/types/control/ZoomControl.d.ts +3 -4
- package/types/control/index.d.ts +3 -1
- package/types/ellipsoid/Ellipsoid.d.ts +47 -43
- package/types/ellipsoid/wgs84.d.ts +3 -2
- package/types/entity/BaseBillboard.d.ts +41 -34
- package/types/entity/Billboard.d.ts +7 -7
- package/types/entity/BillboardHandler.d.ts +4 -0
- package/types/entity/Entity.d.ts +101 -83
- package/types/entity/EntityCollection.d.ts +57 -43
- package/types/entity/GeoObject.d.ts +111 -0
- package/types/entity/GeoObjectHandler.d.ts +77 -0
- package/types/entity/Geometry.d.ts +9 -7
- package/types/entity/GeometryHandler.d.ts +2 -2
- package/types/entity/Label.d.ts +24 -29
- package/types/entity/LabelHandler.d.ts +9 -2
- package/types/entity/LabelWorker.d.ts +9 -0
- package/types/entity/PointCloud.d.ts +8 -8
- package/types/entity/PointCloudHandler.d.ts +3 -3
- package/types/entity/Polyline.d.ts +58 -55
- package/types/entity/Ray.d.ts +19 -18
- package/types/entity/Strip.d.ts +8 -7
- package/types/entity/StripHandler.d.ts +3 -3
- package/types/entity/index.d.ts +7 -7
- package/types/input/KeyboardHandler.d.ts +10 -0
- package/types/input/MouseHandler.d.ts +5 -0
- package/types/input/TouchHandler.d.ts +5 -0
- package/types/layer/BaseGeoImage.d.ts +23 -35
- package/types/layer/CanvasTiles.d.ts +15 -22
- package/types/layer/GeoImage.d.ts +5 -18
- package/types/layer/GeoVideo.d.ts +5 -30
- package/types/layer/KML.d.ts +20 -15
- package/types/layer/Layer.d.ts +326 -0
- package/types/layer/Material.d.ts +45 -0
- package/types/layer/Vector.d.ts +208 -0
- package/types/layer/WMS.d.ts +4 -7
- package/types/layer/XYZ.d.ts +19 -25
- package/types/light/LightSource.d.ts +54 -53
- package/types/math/Line2.d.ts +11 -0
- package/types/math/Line3.d.ts +10 -0
- package/types/math/Mat3.d.ts +30 -18
- package/types/math/Mat4.d.ts +71 -52
- package/types/math/Plane.d.ts +5 -4
- package/types/math/Quat.d.ts +379 -0
- package/types/math/Ray.d.ts +82 -0
- package/types/math/Vec2.d.ts +102 -101
- package/types/math/Vec3.d.ts +143 -142
- package/types/math/Vec4.d.ts +40 -39
- package/types/math/coder.d.ts +12 -11
- package/types/math.d.ts +8 -8
- package/types/mercator.d.ts +3 -3
- package/types/proj/EPSG3857.d.ts +3 -2
- package/types/proj/EPSG4326.d.ts +3 -2
- package/types/proj/Proj.d.ts +42 -0
- package/types/quadTree/EntityCollectionNode.d.ts +34 -0
- package/types/quadTree/Node.d.ts +61 -0
- package/types/renderer/Renderer.d.ts +300 -0
- package/types/renderer/RendererEvents.d.ts +10 -7
- package/types/scene/BaseNode.d.ts +9 -9
- package/types/scene/Planet.d.ts +131 -126
- package/types/scene/RenderNode.d.ts +22 -23
- package/types/segment/Segment.d.ts +279 -0
- package/types/segment/SegmentLonLat.d.ts +16 -0
- package/types/shaders/geoObject.d.ts +3 -0
- package/types/shapes/BaseShape.d.ts +43 -40
- package/types/shapes/Sphere.d.ts +7 -7
- package/types/terrain/BilTerrain.d.ts +0 -1
- package/types/terrain/EmptyTerrain.d.ts +4 -4
- package/types/terrain/GlobusTerrain.d.ts +17 -54
- package/types/terrain/MapboxTerrain.d.ts +0 -1
- package/types/utils/GeoImageCreator.d.ts +3 -2
- package/types/utils/TextureAtlas.d.ts +8 -8
- package/types/utils/shared.d.ts +25 -24
- package/types/webgl/Framebuffer.d.ts +5 -5
- package/types/webgl/Handler.d.ts +68 -43
- package/types/webgl/Multisample.d.ts +5 -5
- package/types/webgl/Program.d.ts +8 -2
- package/types/webgl/ProgramController.d.ts +18 -13
- package/src/og/inherits.js +0 -8
- package/src/og/utils/polylabel.js +0 -176
- package/types/inherits.d.ts +0 -4
package/src/og/bv/Box.js
CHANGED
|
@@ -11,11 +11,15 @@ import { Vec3 } from "../math/Vec3.js";
|
|
|
11
11
|
* @class
|
|
12
12
|
*/
|
|
13
13
|
class Box {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {*} boundsArr
|
|
17
|
+
*/
|
|
14
18
|
constructor(boundsArr) {
|
|
15
19
|
/**
|
|
16
20
|
* Vertices array.
|
|
17
21
|
* @public
|
|
18
|
-
* @type{Array.<
|
|
22
|
+
* @type{Array.<Vec3>}
|
|
19
23
|
*/
|
|
20
24
|
this.vertices = [
|
|
21
25
|
new Vec3(),
|
|
@@ -65,8 +69,8 @@ class Box {
|
|
|
65
69
|
|
|
66
70
|
/**
|
|
67
71
|
* Sets bounding box coordiantes by ellipsoid geodetic extend.
|
|
68
|
-
* @param {
|
|
69
|
-
* @param {
|
|
72
|
+
* @param {Ellipsoid} ellipsoid - Ellipsoid.
|
|
73
|
+
* @param {Extent} extent - Geodetic extent.
|
|
70
74
|
*/
|
|
71
75
|
setFromExtent(ellipsoid, extent) {
|
|
72
76
|
this.setFromBoundsArr(extent.getCartesianBounds(ellipsoid));
|
package/src/og/bv/Sphere.js
CHANGED
|
@@ -2,19 +2,23 @@
|
|
|
2
2
|
* @module og/bv/Sphere
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
"use strict";
|
|
6
6
|
|
|
7
|
-
import { Vec3 } from
|
|
7
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Bounding sphere class.
|
|
11
11
|
* @class
|
|
12
12
|
* @param {Number} [radius] - Bounding sphere radius.
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {Vec3} [center] - Bounding sphere coordiantes.
|
|
14
14
|
*/
|
|
15
15
|
class Sphere {
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {number} radius
|
|
19
|
+
* @param {Vec3} center
|
|
20
|
+
*/
|
|
16
21
|
constructor(radius, center) {
|
|
17
|
-
|
|
18
22
|
/**
|
|
19
23
|
* Sphere radius.
|
|
20
24
|
* @public
|
|
@@ -25,7 +29,7 @@ class Sphere {
|
|
|
25
29
|
/**
|
|
26
30
|
* Sphere coordiantes.
|
|
27
31
|
* @public
|
|
28
|
-
* @type {
|
|
32
|
+
* @type {Vec3}
|
|
29
33
|
*/
|
|
30
34
|
this.center = center ? center.clone() : new Vec3();
|
|
31
35
|
}
|
|
@@ -36,18 +40,22 @@ class Sphere {
|
|
|
36
40
|
*/
|
|
37
41
|
setFromBounds(bounds) {
|
|
38
42
|
let m = new Vec3(bounds[0], bounds[1], bounds[2]);
|
|
39
|
-
this.center.set(
|
|
43
|
+
this.center.set(
|
|
44
|
+
m.x + (bounds[3] - m.x) * 0.5,
|
|
45
|
+
m.y + (bounds[3] - m.y) * 0.5,
|
|
46
|
+
m.z + (bounds[5] - m.z) * 0.5
|
|
47
|
+
);
|
|
40
48
|
this.radius = this.center.distance(m);
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
/**
|
|
44
52
|
* Sets bounding sphere coordiantes by ellipsoid geodetic extend.
|
|
45
|
-
* @param {
|
|
46
|
-
* @param {
|
|
53
|
+
* @param {Ellipsoid} ellipsoid - Ellipsoid.
|
|
54
|
+
* @param {Extent} extent - Geodetic extent.
|
|
47
55
|
*/
|
|
48
56
|
setFromExtent(ellipsoid, extent) {
|
|
49
57
|
this.setFromBounds(extent.getCartesianBounds(ellipsoid));
|
|
50
58
|
}
|
|
51
|
-
}
|
|
59
|
+
}
|
|
52
60
|
|
|
53
61
|
export { Sphere };
|
package/src/og/camera/Camera.js
CHANGED
|
@@ -1,64 +1,67 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
import * as math from
|
|
4
|
-
import { Events } from
|
|
5
|
-
import { Frustum } from
|
|
6
|
-
import { Vec2 } from
|
|
7
|
-
import { Vec3 } from
|
|
8
|
-
import { Vec4 } from
|
|
9
|
-
import { Mat3 } from
|
|
10
|
-
import { Mat4 } from
|
|
3
|
+
import * as math from "../math.js";
|
|
4
|
+
import { Events } from "../Events.js";
|
|
5
|
+
import { Frustum } from "./Frustum.js";
|
|
6
|
+
import { Vec2 } from "../math/Vec2.js";
|
|
7
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
8
|
+
import { Vec4 } from "../math/Vec4.js";
|
|
9
|
+
import { Mat3 } from "../math/Mat3.js";
|
|
10
|
+
import { Mat4 } from "../math/Mat4.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Camera class.
|
|
14
14
|
* @class
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {Renderer} [renderer] - Renderer uses the camera instance.
|
|
16
16
|
* @param {Object} [options] - Camera options:
|
|
17
17
|
* @param {Object} [options.name] - Camera name.
|
|
18
18
|
* @param {number} [options.viewAngle=38] - Camera angle of view. Default is 30.0
|
|
19
19
|
* @param {number} [options.near=1] - Camera near plane distance. Default is 1.0
|
|
20
20
|
* @param {number} [options.far=og.math.MAX] - Camera far plane distance. Deafult is og.math.MAX
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {
|
|
21
|
+
* @param {Vec3} [options.eye=[0,0,0]] - Camera eye position. Default (0,0,0)
|
|
22
|
+
* @param {Vec3} [options.look=[0,0,0]] - Camera look position. Default (0,0,0)
|
|
23
|
+
* @param {Vec3} [options.up=[0,1,0]] - Camera eye position. Default (0,1,0)
|
|
24
24
|
*
|
|
25
25
|
* @fires og.Camera#viewchange
|
|
26
26
|
*/
|
|
27
27
|
class Camera {
|
|
28
|
+
/**
|
|
29
|
+
* @param {Renderer} [renderer] - Renderer uses the camera instance.
|
|
30
|
+
* @param {Object} [options] - Camera options:
|
|
31
|
+
*/
|
|
28
32
|
constructor(renderer, options) {
|
|
29
|
-
|
|
30
33
|
/**
|
|
31
34
|
* Assigned renderer
|
|
32
35
|
* @public
|
|
33
|
-
* @type {
|
|
36
|
+
* @type {Renderer}
|
|
34
37
|
*/
|
|
35
38
|
this.renderer = renderer;
|
|
36
39
|
|
|
37
40
|
/**
|
|
38
41
|
* Camera events handler
|
|
39
42
|
* @public
|
|
40
|
-
* @type {
|
|
43
|
+
* @type {Events}
|
|
41
44
|
*/
|
|
42
45
|
this.events = new Events(EVENT_NAMES, this);
|
|
43
46
|
|
|
44
47
|
/**
|
|
45
48
|
* Camera position.
|
|
46
49
|
* @public
|
|
47
|
-
* @type {
|
|
50
|
+
* @type {Vec3}
|
|
48
51
|
*/
|
|
49
52
|
this.eye = new Vec3();
|
|
50
53
|
|
|
51
54
|
/**
|
|
52
55
|
* Camera RTE high position
|
|
53
56
|
* @public
|
|
54
|
-
* @type {
|
|
57
|
+
* @type {Vec3}
|
|
55
58
|
*/
|
|
56
59
|
this.eyeHigh = new Float32Array(3);
|
|
57
60
|
|
|
58
61
|
/**
|
|
59
62
|
* Camera RTE low position
|
|
60
63
|
* @public
|
|
61
|
-
* @type {
|
|
64
|
+
* @type {Vec3}
|
|
62
65
|
*/
|
|
63
66
|
this.eyeLow = new Float32Array(3);
|
|
64
67
|
|
|
@@ -79,35 +82,35 @@ class Camera {
|
|
|
79
82
|
/**
|
|
80
83
|
* Camera normal matrix.
|
|
81
84
|
* @protected
|
|
82
|
-
* @type {
|
|
85
|
+
* @type {Mat3}
|
|
83
86
|
*/
|
|
84
87
|
this._normalMatrix = new Mat3();
|
|
85
88
|
|
|
86
89
|
/**
|
|
87
90
|
* Camera view matrix.
|
|
88
91
|
* @protected
|
|
89
|
-
* @type {
|
|
92
|
+
* @type {Mat4}
|
|
90
93
|
*/
|
|
91
94
|
this._viewMatrix = new Mat4();
|
|
92
95
|
|
|
93
96
|
/**
|
|
94
97
|
* Camera right vector.
|
|
95
98
|
* @protected
|
|
96
|
-
* @type {
|
|
99
|
+
* @type {Vec3}
|
|
97
100
|
*/
|
|
98
101
|
this._u = new Vec3(0.0, 1.0, 0.0); // up x n
|
|
99
102
|
|
|
100
103
|
/**
|
|
101
104
|
* Camera up vector.
|
|
102
105
|
* @protected
|
|
103
|
-
* @type {
|
|
106
|
+
* @type {Vec3}
|
|
104
107
|
*/
|
|
105
108
|
this._v = new Vec3(1.0, 0.0, 0.0); // n x u - UP
|
|
106
109
|
|
|
107
110
|
/**
|
|
108
111
|
* Camera forward vector.
|
|
109
112
|
* @protected
|
|
110
|
-
* @type {
|
|
113
|
+
* @type {Vec3}
|
|
111
114
|
*/
|
|
112
115
|
this._n = new Vec3(0.0, 0.0, 1.0); // eye - look - FORWARD
|
|
113
116
|
|
|
@@ -116,7 +119,7 @@ class Camera {
|
|
|
116
119
|
this._pv = this._v.clone();
|
|
117
120
|
this._pn = this._n.clone();
|
|
118
121
|
this._peye = this.eye.clone();
|
|
119
|
-
this.
|
|
122
|
+
this.isMoved = false;
|
|
120
123
|
|
|
121
124
|
this._tanViewAngle_hrad = 0.0;
|
|
122
125
|
this._tanViewAngle_hradOneByHeight = 0.0;
|
|
@@ -136,7 +139,7 @@ class Camera {
|
|
|
136
139
|
aspect: this._aspect,
|
|
137
140
|
near: fi[0],
|
|
138
141
|
far: fi[1]
|
|
139
|
-
})
|
|
142
|
+
});
|
|
140
143
|
|
|
141
144
|
fr._cameraFrustumIndex = this.frustums.length;
|
|
142
145
|
this.frustums.push(fr);
|
|
@@ -145,7 +148,6 @@ class Camera {
|
|
|
145
148
|
this.frustumColors.push.apply(this.frustumColors, fr._pickingColorU);
|
|
146
149
|
}
|
|
147
150
|
} else {
|
|
148
|
-
|
|
149
151
|
let near = 1.0,
|
|
150
152
|
far = 10000.0;
|
|
151
153
|
|
|
@@ -176,18 +178,13 @@ class Camera {
|
|
|
176
178
|
n = this._n,
|
|
177
179
|
eye = this.eye;
|
|
178
180
|
|
|
179
|
-
if (this.
|
|
180
|
-
if (this.
|
|
181
|
-
this.
|
|
182
|
-
this._pv.equal(v) &&
|
|
183
|
-
this._pn.equal(n)) {
|
|
184
|
-
if (this._moved) {
|
|
185
|
-
this.events.dispatch(this.events.moveend, this);
|
|
186
|
-
}
|
|
187
|
-
this._moved = false;
|
|
188
|
-
} else {
|
|
189
|
-
this._moved = true;
|
|
181
|
+
if (this._peye.equal(eye) && this._pu.equal(u) && this._pv.equal(v) && this._pn.equal(n)) {
|
|
182
|
+
if (this.isMoved) {
|
|
183
|
+
this.events.dispatch(this.events.moveend, this);
|
|
190
184
|
}
|
|
185
|
+
this.isMoved = false;
|
|
186
|
+
} else {
|
|
187
|
+
this.isMoved = true;
|
|
191
188
|
}
|
|
192
189
|
|
|
193
190
|
this._pu.copy(u);
|
|
@@ -199,23 +196,23 @@ class Camera {
|
|
|
199
196
|
/**
|
|
200
197
|
* Camera initialization.
|
|
201
198
|
* @public
|
|
202
|
-
* @param {
|
|
199
|
+
* @param {Renderer} renderer - OpenGlobus renderer object.
|
|
203
200
|
* @param {Object} [options] - Camera options:
|
|
204
201
|
* @param {number} [options.viewAngle] - Camera angle of view. Default is 30.0
|
|
205
202
|
* @param {number} [options.near] - Camera near plane distance. Default is 1.0
|
|
206
203
|
* @param {number} [options.far] - Camera far plane distance. Deafult is og.math.MAX
|
|
207
|
-
* @param {
|
|
208
|
-
* @param {
|
|
209
|
-
* @param {
|
|
204
|
+
* @param {Vec3} [options.eye] - Camera eye position. Default (0,0,0)
|
|
205
|
+
* @param {Vec3} [options.look] - Camera look position. Default (0,0,0)
|
|
206
|
+
* @param {Vec3} [options.up] - Camera eye position. Default (0,1,0)
|
|
210
207
|
*/
|
|
211
208
|
_init(options) {
|
|
212
|
-
|
|
213
209
|
this._setProj(this._viewAngle, this._aspect);
|
|
214
210
|
|
|
215
211
|
this.set(
|
|
216
212
|
options.eye || new Vec3(0.0, 0.0, 1.0),
|
|
217
213
|
options.look || new Vec3(),
|
|
218
|
-
options.up || new Vec3(0.0, 1.0, 0.0)
|
|
214
|
+
options.up || new Vec3(0.0, 1.0, 0.0)
|
|
215
|
+
);
|
|
219
216
|
}
|
|
220
217
|
|
|
221
218
|
getUp() {
|
|
@@ -248,18 +245,33 @@ class Camera {
|
|
|
248
245
|
* @virtual
|
|
249
246
|
*/
|
|
250
247
|
update() {
|
|
251
|
-
var u = this._u,
|
|
248
|
+
var u = this._u,
|
|
249
|
+
v = this._v,
|
|
250
|
+
n = this._n,
|
|
251
|
+
eye = this.eye;
|
|
252
252
|
|
|
253
253
|
Vec3.doubleToTwoFloat32Array(eye, this.eyeHigh, this.eyeLow);
|
|
254
254
|
|
|
255
255
|
this._viewMatrix.set([
|
|
256
|
-
u.x,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
256
|
+
u.x,
|
|
257
|
+
v.x,
|
|
258
|
+
n.x,
|
|
259
|
+
0.0,
|
|
260
|
+
u.y,
|
|
261
|
+
v.y,
|
|
262
|
+
n.y,
|
|
263
|
+
0.0,
|
|
264
|
+
u.z,
|
|
265
|
+
v.z,
|
|
266
|
+
n.z,
|
|
267
|
+
0.0,
|
|
268
|
+
-eye.dot(u),
|
|
269
|
+
-eye.dot(v),
|
|
270
|
+
-eye.dot(n),
|
|
271
|
+
1.0
|
|
260
272
|
]);
|
|
261
273
|
|
|
262
|
-
this._normalMatrix = this._viewMatrix.toMatrix3()
|
|
274
|
+
this._normalMatrix = this._viewMatrix.toMatrix3(); // this._viewMatrix.toInverseMatrix3().transposeTo();
|
|
263
275
|
|
|
264
276
|
for (let i = 0, len = this.frustums.length; i < len; i++) {
|
|
265
277
|
this.frustums[i].setViewMatrix(this._viewMatrix);
|
|
@@ -306,11 +318,22 @@ class Camera {
|
|
|
306
318
|
this._viewAngle = angle;
|
|
307
319
|
this._aspect = aspect;
|
|
308
320
|
this._tanViewAngle_hrad = Math.tan(angle * math.RADIANS_HALF);
|
|
309
|
-
this._tanViewAngle_hradOneByHeight =
|
|
321
|
+
this._tanViewAngle_hradOneByHeight =
|
|
322
|
+
this._tanViewAngle_hrad * this.renderer.handler._oneByHeight;
|
|
310
323
|
var c = this.renderer.handler.canvas;
|
|
311
|
-
this._projSizeConst =
|
|
324
|
+
this._projSizeConst =
|
|
325
|
+
Math.min(
|
|
326
|
+
c.clientWidth < 256 ? 256 : c.clientWidth,
|
|
327
|
+
c.clientHeight < 256 ? 256 : c.clientHeight
|
|
328
|
+
) /
|
|
329
|
+
(angle * math.RADIANS);
|
|
312
330
|
for (let i = 0, len = this.frustums.length; i < len; i++) {
|
|
313
|
-
this.frustums[i].setProjectionMatrix(
|
|
331
|
+
this.frustums[i].setProjectionMatrix(
|
|
332
|
+
angle,
|
|
333
|
+
aspect,
|
|
334
|
+
this.frustums[i].near,
|
|
335
|
+
this.frustums[i].far
|
|
336
|
+
);
|
|
314
337
|
}
|
|
315
338
|
}
|
|
316
339
|
|
|
@@ -327,7 +350,7 @@ class Camera {
|
|
|
327
350
|
/**
|
|
328
351
|
* Gets camera view angle in degrees
|
|
329
352
|
* @public
|
|
330
|
-
* @returns {number} angle -
|
|
353
|
+
* @returns {number} angle -
|
|
331
354
|
*/
|
|
332
355
|
getViewAngle() {
|
|
333
356
|
return this._viewAngle;
|
|
@@ -336,10 +359,10 @@ class Camera {
|
|
|
336
359
|
/**
|
|
337
360
|
* Sets camera to eye position
|
|
338
361
|
* @public
|
|
339
|
-
* @param {
|
|
340
|
-
* @param {
|
|
341
|
-
* @param {
|
|
342
|
-
* @returns {
|
|
362
|
+
* @param {Vec3} eye - Camera position
|
|
363
|
+
* @param {Vec3} look - Look point
|
|
364
|
+
* @param {Vec3} up - Camera up vector
|
|
365
|
+
* @returns {Camera} - This camera
|
|
343
366
|
*/
|
|
344
367
|
set(eye, look, up) {
|
|
345
368
|
this.eye.x = eye.x;
|
|
@@ -360,8 +383,8 @@ class Camera {
|
|
|
360
383
|
/**
|
|
361
384
|
* Sets camera look point
|
|
362
385
|
* @public
|
|
363
|
-
* @param {
|
|
364
|
-
* @param {
|
|
386
|
+
* @param {Vec3} look - Look point
|
|
387
|
+
* @param {Vec3} [up] - Camera up vector otherwise camera current up vector(this._v)
|
|
365
388
|
*/
|
|
366
389
|
look(look, up) {
|
|
367
390
|
this._n.set(this.eye.x - look.x, this.eye.y - look.y, this.eye.z - look.z);
|
|
@@ -393,8 +416,16 @@ class Camera {
|
|
|
393
416
|
var cs = Math.cos(math.RADIANS * angle);
|
|
394
417
|
var sn = Math.sin(math.RADIANS * angle);
|
|
395
418
|
var t = this._u.clone();
|
|
396
|
-
this._u.set(
|
|
397
|
-
|
|
419
|
+
this._u.set(
|
|
420
|
+
cs * t.x - sn * this._v.x,
|
|
421
|
+
cs * t.y - sn * this._v.y,
|
|
422
|
+
cs * t.z - sn * this._v.z
|
|
423
|
+
);
|
|
424
|
+
this._v.set(
|
|
425
|
+
sn * t.x + cs * this._v.x,
|
|
426
|
+
sn * t.y + cs * this._v.y,
|
|
427
|
+
sn * t.z + cs * this._v.z
|
|
428
|
+
);
|
|
398
429
|
}
|
|
399
430
|
|
|
400
431
|
/**
|
|
@@ -406,8 +437,16 @@ class Camera {
|
|
|
406
437
|
var cs = Math.cos(math.RADIANS * angle);
|
|
407
438
|
var sn = Math.sin(math.RADIANS * angle);
|
|
408
439
|
var t = this._n.clone();
|
|
409
|
-
this._n.set(
|
|
410
|
-
|
|
440
|
+
this._n.set(
|
|
441
|
+
cs * t.x - sn * this._v.x,
|
|
442
|
+
cs * t.y - sn * this._v.y,
|
|
443
|
+
cs * t.z - sn * this._v.z
|
|
444
|
+
);
|
|
445
|
+
this._v.set(
|
|
446
|
+
sn * t.x + cs * this._v.x,
|
|
447
|
+
sn * t.y + cs * this._v.y,
|
|
448
|
+
sn * t.z + cs * this._v.z
|
|
449
|
+
);
|
|
411
450
|
}
|
|
412
451
|
|
|
413
452
|
/**
|
|
@@ -419,8 +458,16 @@ class Camera {
|
|
|
419
458
|
var cs = Math.cos(math.RADIANS * angle);
|
|
420
459
|
var sn = Math.sin(math.RADIANS * angle);
|
|
421
460
|
var t = this._u.clone();
|
|
422
|
-
this._u.set(
|
|
423
|
-
|
|
461
|
+
this._u.set(
|
|
462
|
+
cs * t.x - sn * this._n.x,
|
|
463
|
+
cs * t.y - sn * this._n.y,
|
|
464
|
+
cs * t.z - sn * this._n.z
|
|
465
|
+
);
|
|
466
|
+
this._n.set(
|
|
467
|
+
sn * t.x + cs * this._n.x,
|
|
468
|
+
sn * t.y + cs * this._n.y,
|
|
469
|
+
sn * t.z + cs * this._n.z
|
|
470
|
+
);
|
|
424
471
|
}
|
|
425
472
|
|
|
426
473
|
/**
|
|
@@ -428,7 +475,7 @@ class Camera {
|
|
|
428
475
|
* @public
|
|
429
476
|
* @param {number} x - Scren X coordinate
|
|
430
477
|
* @param {number} y - Scren Y coordinate
|
|
431
|
-
* @returns {
|
|
478
|
+
* @returns {Vec3} - Direction vector
|
|
432
479
|
*/
|
|
433
480
|
unproject(x, y) {
|
|
434
481
|
var c = this.renderer.handler.canvas,
|
|
@@ -438,8 +485,12 @@ class Camera {
|
|
|
438
485
|
var px = (x - w) / w,
|
|
439
486
|
py = -(y - h) / h;
|
|
440
487
|
|
|
441
|
-
var world1 = this.frustums[0]._inverseProjectionViewMatrix
|
|
442
|
-
|
|
488
|
+
var world1 = this.frustums[0]._inverseProjectionViewMatrix
|
|
489
|
+
.mulVec4(new Vec4(px, py, -1.0, 1.0))
|
|
490
|
+
.affinity(),
|
|
491
|
+
world2 = this.frustums[0]._inverseProjectionViewMatrix
|
|
492
|
+
.mulVec4(new Vec4(px, py, 0.0, 1.0))
|
|
493
|
+
.affinity();
|
|
443
494
|
|
|
444
495
|
return world2.subA(world1).toVec3().normalize();
|
|
445
496
|
}
|
|
@@ -447,8 +498,8 @@ class Camera {
|
|
|
447
498
|
/**
|
|
448
499
|
* Gets projected 3d point to the 2d screen coordiantes
|
|
449
500
|
* @public
|
|
450
|
-
* @param {
|
|
451
|
-
* @returns {
|
|
501
|
+
* @param {Vec3} v - Cartesian 3d coordiantes
|
|
502
|
+
* @returns {Vec2} - Screen point coordinates
|
|
452
503
|
*/
|
|
453
504
|
project(v) {
|
|
454
505
|
var r = this.frustums[0]._projectionViewMatrix.mulVec4(v.toVec4()),
|
|
@@ -462,8 +513,8 @@ class Camera {
|
|
|
462
513
|
* @param {number} angle - Rotation angle in radians
|
|
463
514
|
* @param {boolean} isArc - If true camera up vector gets from current up vector every frame,
|
|
464
515
|
* otherwise up is always input parameter.
|
|
465
|
-
* @param {
|
|
466
|
-
* @param {
|
|
516
|
+
* @param {Vec3} center - Point that the camera rotates around
|
|
517
|
+
* @param {Vecto3} [up] - Camera up vector
|
|
467
518
|
*/
|
|
468
519
|
rotateAround(angle, isArc, center, up) {
|
|
469
520
|
center = center || Vec3.ZERO;
|
|
@@ -487,8 +538,8 @@ class Camera {
|
|
|
487
538
|
* @param {number} angle - Rotation angle in radians.
|
|
488
539
|
* @param {boolaen} isArc - If true camera up vector gets from current up vector every frame,
|
|
489
540
|
* otherwise up is always input parameter.
|
|
490
|
-
* @param {
|
|
491
|
-
* @param {
|
|
541
|
+
* @param {Vec3} center - Point that the camera rotates around.
|
|
542
|
+
* @param {Vec3} [up] - Camera up vector.
|
|
492
543
|
*/
|
|
493
544
|
rotateHorizontal(angle, isArc, center, up) {
|
|
494
545
|
this.rotateAround(angle, isArc, center, up);
|
|
@@ -497,7 +548,7 @@ class Camera {
|
|
|
497
548
|
/**
|
|
498
549
|
* Rotates camera around center point by vecrtical.
|
|
499
550
|
* @param {number} angle - Rotation angle in radians.
|
|
500
|
-
* @param {
|
|
551
|
+
* @param {Vec3} center - Point that the camera rotates around.
|
|
501
552
|
*/
|
|
502
553
|
rotateVertical(angle, center) {
|
|
503
554
|
this.rotateAround(angle, false, center, this._u);
|
|
@@ -506,8 +557,8 @@ class Camera {
|
|
|
506
557
|
/**
|
|
507
558
|
* Gets 3d size factor. Uses in LOD distance calculation.
|
|
508
559
|
* @public
|
|
509
|
-
* @param {
|
|
510
|
-
* @param {
|
|
560
|
+
* @param {Vec3} p - Far point.
|
|
561
|
+
* @param {Vec3} r - Far point.
|
|
511
562
|
* @returns {number} - Size factor.
|
|
512
563
|
*/
|
|
513
564
|
projectedSize(p, r) {
|
|
@@ -517,7 +568,7 @@ class Camera {
|
|
|
517
568
|
/**
|
|
518
569
|
* Returns normal matrix.
|
|
519
570
|
* @public
|
|
520
|
-
* @returns {
|
|
571
|
+
* @returns {Mat3} - Normal matrix.
|
|
521
572
|
*/
|
|
522
573
|
getNormalMatrix() {
|
|
523
574
|
return this._normalMatrix._m;
|
|
@@ -526,7 +577,7 @@ class Camera {
|
|
|
526
577
|
/**
|
|
527
578
|
* Returns model matrix.
|
|
528
579
|
* @public
|
|
529
|
-
* @returns {
|
|
580
|
+
* @returns {Mat4} - View matrix.
|
|
530
581
|
*/
|
|
531
582
|
getViewMatrix() {
|
|
532
583
|
return this._viewMatrix._m;
|
|
@@ -547,7 +598,7 @@ class Camera {
|
|
|
547
598
|
/**
|
|
548
599
|
* Returns projection matrix.
|
|
549
600
|
* @public
|
|
550
|
-
* @returns {
|
|
601
|
+
* @returns {Mat4} - Projection matrix.
|
|
551
602
|
*/
|
|
552
603
|
getProjectionMatrix() {
|
|
553
604
|
return this.frustum._projectionMatrix._m;
|
|
@@ -556,7 +607,7 @@ class Camera {
|
|
|
556
607
|
/**
|
|
557
608
|
* Returns projection and model matrix product.
|
|
558
609
|
* @public
|
|
559
|
-
* @return {
|
|
610
|
+
* @return {Mat4} - Projection-view matrix.
|
|
560
611
|
*/
|
|
561
612
|
getProjectionViewMatrix() {
|
|
562
613
|
return this.frustum._projectionViewMatrix._m;
|
|
@@ -565,7 +616,7 @@ class Camera {
|
|
|
565
616
|
/**
|
|
566
617
|
* Returns inverse projection and model matrix product.
|
|
567
618
|
* @public
|
|
568
|
-
* @returns {
|
|
619
|
+
* @returns {Mat4} - Inversed projection-view matrix.
|
|
569
620
|
*/
|
|
570
621
|
getInverseProjectionViewMatrix() {
|
|
571
622
|
return this.frustum._inverseProjectionViewMatrix._m;
|
|
@@ -574,12 +625,12 @@ class Camera {
|
|
|
574
625
|
/**
|
|
575
626
|
* Returns inverse projection matrix.
|
|
576
627
|
* @public
|
|
577
|
-
* @returns {
|
|
628
|
+
* @returns {Mat4} - Inversed projection-view matrix.
|
|
578
629
|
*/
|
|
579
630
|
getInverseProjectionMatrix() {
|
|
580
631
|
return this.frustum._inverseProjectionMatrix._m;
|
|
581
632
|
}
|
|
582
|
-
}
|
|
633
|
+
}
|
|
583
634
|
|
|
584
635
|
const EVENT_NAMES = [
|
|
585
636
|
/**
|
|
@@ -595,4 +646,4 @@ const EVENT_NAMES = [
|
|
|
595
646
|
"moveend"
|
|
596
647
|
];
|
|
597
648
|
|
|
598
|
-
export { Camera };
|
|
649
|
+
export { Camera };
|