@openglobus/og 0.15.0 → 0.15.2
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 +10 -4
- package/css/og.css +44 -45
- package/dist/@openglobus/og.css +1 -1
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +12 -12
- package/src/og/Clock.js +1 -1
- package/src/og/Events.js +1 -1
- package/src/og/Extent.js +1 -1
- package/src/og/Globe.js +3 -5
- package/src/og/Popup.js +38 -63
- package/src/og/astro/earth.js +2 -2
- package/src/og/astro/rotation.js +2 -2
- package/src/og/bv/Box.js +1 -0
- package/src/og/bv/index.js +1 -1
- package/src/og/camera/Camera.js +4 -4
- package/src/og/camera/PlanetCamera.js +26 -6
- package/src/og/camera/index.js +1 -1
- package/src/og/control/Atmosphere.js +3 -8
- package/src/og/control/CompassButton.js +4 -5
- package/src/og/control/Control.js +25 -15
- package/src/og/control/EarthCoordinates.js +3 -2
- package/src/og/control/EarthNavigation.js +0 -1
- package/src/og/control/GeoImageDragControl.js +2 -2
- package/src/og/control/KeyboardNavigation.js +3 -2
- package/src/og/control/LayerAnimation.js +2 -2
- package/src/og/control/LayerSwitcher.js +5 -4
- package/src/og/control/Lighting.js +106 -35
- package/src/og/control/MouseNavigation.js +4 -4
- package/src/og/control/MouseWheelZoomControl.js +2 -2
- package/src/og/control/RulerSwitcher.js +4 -3
- package/src/og/control/ScaleControl.js +2 -2
- package/src/og/control/ShowFps.js +2 -1
- package/src/og/control/SimpleNavigation.js +2 -1
- package/src/og/control/SimpleSkyBackground.js +2 -2
- package/src/og/control/Sun.js +9 -2
- package/src/og/control/ToggleWireframe.js +2 -1
- package/src/og/control/TouchNavigation.js +4 -3
- package/src/og/control/ZoomControl.js +6 -5
- package/src/og/control/index.js +10 -10
- package/src/og/control/ruler/RulerScene.js +19 -11
- package/src/og/control/selection/Selection.js +1 -1
- package/src/og/control/selection/SelectionScene.js +5 -8
- package/src/og/control/timeline/TimelineControl.js +3 -4
- package/src/og/control/timeline/TimelineModel.js +2 -2
- package/src/og/control/timeline/TimelineView.js +10 -5
- package/src/og/control/visibleExtent/Segment.js +5 -5
- package/src/og/control/visibleExtent/VisibleExtent.js +1 -1
- package/src/og/ellipsoid/Ellipsoid.js +3 -3
- package/src/og/entity/BaseBillboard.js +2 -2
- package/src/og/entity/BillboardHandler.js +10 -2
- package/src/og/entity/Entity.js +10 -51
- package/src/og/entity/EntityCollection.js +3 -20
- package/src/og/entity/GeoObject.js +2 -4
- package/src/og/entity/GeoObjectHandler.js +12 -11
- package/src/og/entity/Geometry.js +2 -2
- package/src/og/entity/GeometryHandler.js +2 -2
- package/src/og/entity/Label.js +2 -2
- package/src/og/entity/LabelHandler.js +7 -5
- package/src/og/entity/Polyline.js +8 -7
- package/src/og/entity/Ray.js +1 -2
- package/src/og/entity/RayHandler.js +4 -0
- package/src/og/entity/Strip.js +8 -5
- package/src/og/entity/index.js +1 -1
- package/src/og/index.core.js +4 -4
- package/src/og/index.js +7 -5
- package/src/og/index.webgl.js +3 -3
- package/src/og/layer/BaseGeoImage.js +2 -2
- package/src/og/layer/GeoImage.js +2 -2
- package/src/og/layer/GeoTexture2d.js +1 -1
- package/src/og/layer/Layer.js +3 -3
- package/src/og/layer/Vector.js +7 -11
- package/src/og/layer/WMS.js +2 -1
- package/src/og/layer/XYZ.js +2 -4
- package/src/og/math/Line3.js +0 -1
- package/src/og/math/Plane.js +0 -1
- package/src/og/math/Ray.js +0 -1
- package/src/og/math/Vec2.js +62 -62
- package/src/og/math/Vec3.js +1 -1
- package/src/og/math/Vec4.js +1 -1
- package/src/og/math/index.js +1 -1
- package/src/og/proj/EPSG3857.js +1 -1
- package/src/og/proj/EPSG4326.js +1 -1
- package/src/og/quadTree/EarthQuadTreeStrategy.js +4 -4
- package/src/og/quadTree/MarsQuadTreeStrategy.js +4 -4
- package/src/og/quadTree/Node.js +1 -1
- package/src/og/quadTree/Wgs84QuadTreeStrategy.js +4 -4
- package/src/og/quadTree/index.js +2 -2
- package/src/og/renderer/Renderer.js +196 -77
- package/src/og/renderer/RendererEvents.js +35 -10
- package/src/og/scene/Axes.js +2 -2
- package/src/og/scene/Planet.js +52 -80
- package/src/og/scene/RenderNode.js +2 -13
- package/src/og/scene/SkyBox.js +1 -1
- package/src/og/scene/index.js +2 -2
- package/src/og/segment/Segment.js +5 -5
- package/src/og/segment/SegmentLonLatWgs84.js +2 -3
- package/src/og/shaders/drawnode.js +5 -1
- package/src/og/shaders/geoObject.js +2 -6
- package/src/og/shaders/pickingMask.js +31 -0
- package/src/og/terrain/BilTerrain.js +4 -4
- package/src/og/terrain/GlobusTerrain.js +7 -7
- package/src/og/terrain/MapboxTerrain.js +2 -2
- package/src/og/terrain/index.js +2 -2
- package/src/og/ui/Button.js +5 -4
- package/src/og/ui/Dialog.js +3 -6
- package/src/og/ui/Slider.js +29 -3
- package/src/og/ui/View.js +5 -5
- package/src/og/ui/icons.js +3 -0
- package/src/og/utils/FontAtlas.js +2 -2
- package/src/og/utils/GeoImageCreator.js +0 -1
- package/src/og/utils/NormalMapCreator.js +6 -5
- package/src/og/utils/TerrainWorker.js +1 -1
- package/src/og/utils/VectorTileCreator.js +4 -4
- package/src/og/utils/shared.js +1 -1
- package/src/og/webgl/Framebuffer.js +3 -1
- package/src/og/webgl/Handler.js +77 -62
- package/src/og/webgl/Multisample.js +18 -7
- package/src/og/webgl/Program.js +2 -2
- package/src/og/webgl/index.js +2 -2
- package/types/Popup.d.ts +8 -21
- package/types/camera/PlanetCamera.d.ts +1 -0
- package/types/control/Sun.d.ts +1 -0
- package/types/control/ruler/RulerScene.d.ts +4 -3
- package/types/entity/Entity.d.ts +2 -19
- package/types/entity/EntityCollection.d.ts +0 -7
- package/types/index.d.ts +2 -1
- package/types/math/Vec2.d.ts +95 -95
- package/types/renderer/Renderer.d.ts +28 -16
- package/types/scene/Planet.d.ts +2 -7
- package/types/shaders/pickingMask.d.ts +2 -0
- package/types/ui/Slider.d.ts +3 -0
- package/types/ui/View.d.ts +1 -0
- package/types/ui/icons.d.ts +1 -0
- package/types/webgl/Framebuffer.d.ts +1 -0
- package/types/webgl/Handler.d.ts +3 -2
- package/src/og/entity/ShapeHandler.js +0 -99
- package/src/og/shaders/shape.js +0 -135
- package/src/og/shapes/BaseShape.js +0 -557
- package/src/og/shapes/Icosphere.js +0 -179
- package/src/og/shapes/Sphere.js +0 -100
- package/types/entity/ShapeHandler.d.ts +0 -22
- package/types/shaders/shape.d.ts +0 -4
- package/types/shapes/BaseShape.d.ts +0 -250
- package/types/shapes/Sphere.d.ts +0 -41
package/src/og/entity/Strip.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import * as utils from "../utils/shared.js";
|
|
4
|
-
import { Vec3 } from "../math/Vec3.js";
|
|
5
3
|
import { Line3 } from "../math/Line3.js";
|
|
4
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
5
|
+
import * as utils from "../utils/shared.js";
|
|
6
6
|
|
|
7
7
|
let _tempHigh = new Vec3(),
|
|
8
8
|
_tempLow = new Vec3();
|
|
@@ -202,9 +202,10 @@ class Strip {
|
|
|
202
202
|
sha = p.attributes,
|
|
203
203
|
shu = p.uniforms;
|
|
204
204
|
|
|
205
|
-
gl.disable(gl.CULL_FACE);
|
|
206
205
|
sh.activate();
|
|
207
206
|
|
|
207
|
+
gl.disable(gl.CULL_FACE);
|
|
208
|
+
|
|
208
209
|
gl.uniformMatrix4fv(shu.viewMatrix, false, r.activeCamera.getViewMatrix());
|
|
209
210
|
gl.uniformMatrix4fv(shu.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
|
|
210
211
|
|
|
@@ -238,6 +239,7 @@ class Strip {
|
|
|
238
239
|
gl.UNSIGNED_INT,
|
|
239
240
|
0
|
|
240
241
|
);
|
|
242
|
+
|
|
241
243
|
gl.enable(gl.CULL_FACE);
|
|
242
244
|
}
|
|
243
245
|
}
|
|
@@ -253,10 +255,10 @@ class Strip {
|
|
|
253
255
|
sha = p.attributes,
|
|
254
256
|
shu = p.uniforms;
|
|
255
257
|
|
|
256
|
-
gl.disable(gl.CULL_FACE);
|
|
257
|
-
|
|
258
258
|
sh.activate();
|
|
259
259
|
|
|
260
|
+
gl.disable(gl.CULL_FACE);
|
|
261
|
+
|
|
260
262
|
gl.uniformMatrix4fv(shu.viewMatrix, false, r.activeCamera.getViewMatrix());
|
|
261
263
|
gl.uniformMatrix4fv(shu.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
|
|
262
264
|
|
|
@@ -290,6 +292,7 @@ class Strip {
|
|
|
290
292
|
gl.UNSIGNED_INT,
|
|
291
293
|
0
|
|
292
294
|
);
|
|
295
|
+
|
|
293
296
|
gl.enable(gl.CULL_FACE);
|
|
294
297
|
}
|
|
295
298
|
}
|
package/src/og/entity/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Billboard } from "./Billboard.js";
|
|
1
2
|
import { Entity } from "./Entity.js";
|
|
2
3
|
import { EntityCollection } from "./EntityCollection.js";
|
|
3
|
-
import { Billboard } from "./Billboard.js";
|
|
4
4
|
import { Geometry } from "./Geometry.js";
|
|
5
5
|
import { Label } from "./Label.js";
|
|
6
6
|
import { PointCloud } from "./PointCloud.js";
|
package/src/og/index.core.js
CHANGED
|
@@ -9,12 +9,12 @@ import { Sphere } from './bv/Sphere.js';
|
|
|
9
9
|
|
|
10
10
|
import { Control } from './control/Control.js';
|
|
11
11
|
import { DebugInfo } from './control/DebugInfo';
|
|
12
|
-
import { SimpleNavigation } from './control/SimpleNavigation.js';
|
|
13
12
|
import { ShowFps } from './control/ShowFps.js';
|
|
13
|
+
import { SimpleNavigation } from './control/SimpleNavigation.js';
|
|
14
14
|
|
|
15
|
+
import { Billboard } from './entity/Billboard.js';
|
|
15
16
|
import { Entity } from './entity/Entity.js';
|
|
16
17
|
import { EntityCollection } from './entity/EntityCollection.js';
|
|
17
|
-
import { Billboard } from './entity/Billboard.js';
|
|
18
18
|
import { Label } from './entity/Label.js';
|
|
19
19
|
import { PointCloud } from './entity/PointCloud.js';
|
|
20
20
|
import { Polyline } from './entity/Polyline.js';
|
|
@@ -37,8 +37,8 @@ import { Vec4 } from './math/Vec4.js';
|
|
|
37
37
|
import { Framebuffer } from './webgl/Framebuffer.js';
|
|
38
38
|
import { Handler } from './webgl/Handler.js';
|
|
39
39
|
import { Multisample } from './webgl/Multisample.js';
|
|
40
|
-
import { types } from './webgl/types.js';
|
|
41
40
|
import { Program } from './webgl/Program.js';
|
|
41
|
+
import { types } from './webgl/types.js';
|
|
42
42
|
|
|
43
43
|
import { Renderer } from './renderer/Renderer.js';
|
|
44
44
|
|
|
@@ -113,4 +113,4 @@ export {
|
|
|
113
113
|
Vec4,
|
|
114
114
|
entity,
|
|
115
115
|
Entity
|
|
116
|
-
};
|
|
116
|
+
};
|
package/src/og/index.js
CHANGED
|
@@ -5,13 +5,13 @@ import * as math from './math.js';
|
|
|
5
5
|
import * as mercator from './mercator.js';
|
|
6
6
|
import * as utils from './utils/shared.js';
|
|
7
7
|
|
|
8
|
+
import * as bv from './bv/index.js';
|
|
8
9
|
import * as control from './control/index.js';
|
|
10
|
+
import * as entity from './entity/index.js';
|
|
9
11
|
import * as layer from './layer/index.js';
|
|
10
|
-
import * as bv from './bv/index.js';
|
|
11
12
|
import * as scene from './scene/index.js';
|
|
12
|
-
import * as entity from './entity/index.js';
|
|
13
|
-
import * as webgl from './webgl/index.js';
|
|
14
13
|
import * as terrain from './terrain/index.js';
|
|
14
|
+
import * as webgl from './webgl/index.js';
|
|
15
15
|
|
|
16
16
|
import { Globe } from './Globe.js';
|
|
17
17
|
|
|
@@ -47,6 +47,7 @@ import {
|
|
|
47
47
|
|
|
48
48
|
import pkg from "../../package.json";
|
|
49
49
|
|
|
50
|
+
import { Object3d } from './Object3d.js';
|
|
50
51
|
const { Handler } = webgl, { Control } = control;
|
|
51
52
|
const { Layer, Vector, XYZ} = layer;
|
|
52
53
|
const {
|
|
@@ -107,5 +108,6 @@ export {
|
|
|
107
108
|
MarsQuadTreeStrategy,
|
|
108
109
|
EarthQuadTreeStrategy,
|
|
109
110
|
Wgs84QuadTreeStrategy,
|
|
110
|
-
quadTreeStrategyType
|
|
111
|
-
|
|
111
|
+
quadTreeStrategyType,
|
|
112
|
+
Object3d
|
|
113
|
+
};
|
package/src/og/index.webgl.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
import { TextureAtlas } from './utils/TextureAtlas.js';
|
|
3
4
|
import { Framebuffer } from './webgl/Framebuffer.js';
|
|
4
5
|
import { Handler } from './webgl/Handler.js';
|
|
5
6
|
import { Multisample } from './webgl/Multisample.js';
|
|
6
|
-
import { types } from './webgl/types.js';
|
|
7
7
|
import { Program } from './webgl/Program.js';
|
|
8
|
-
import {
|
|
8
|
+
import { types } from './webgl/types.js';
|
|
9
9
|
|
|
10
10
|
export {
|
|
11
11
|
Handler,
|
|
@@ -14,4 +14,4 @@ export {
|
|
|
14
14
|
types,
|
|
15
15
|
Program,
|
|
16
16
|
TextureAtlas
|
|
17
|
-
};
|
|
17
|
+
};
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
|
-
import * as mercator from "../mercator.js";
|
|
8
7
|
import { Extent } from "../Extent.js";
|
|
9
|
-
import { Layer } from "./Layer.js";
|
|
10
8
|
import { LonLat } from "../LonLat.js";
|
|
9
|
+
import * as mercator from "../mercator.js";
|
|
10
|
+
import { Layer } from "./Layer.js";
|
|
11
11
|
|
|
12
12
|
const EVENT_NAMES = [
|
|
13
13
|
/**
|
package/src/og/layer/GeoImage.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
|
-
import { BaseGeoImage } from "./BaseGeoImage.js";
|
|
8
7
|
import { nextHighestPowerOfTwo } from "../math.js";
|
|
8
|
+
import { BaseGeoImage } from "./BaseGeoImage.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Used to load and display a single image over specific corner coordinates on the globe, implements og.layer.BaseGeoImage interface.
|
|
@@ -220,4 +220,4 @@ class GeoImage extends BaseGeoImage {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
export { GeoImage };
|
|
223
|
+
export { GeoImage };
|
package/src/og/layer/Layer.js
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
|
-
import * as utils from "../utils/shared.js";
|
|
8
|
-
import * as mercator from "../mercator.js";
|
|
9
7
|
import { Events } from "../Events.js";
|
|
10
8
|
import { Extent } from "../Extent.js";
|
|
11
9
|
import { LonLat } from "../LonLat.js";
|
|
12
|
-
import { Material } from "./Material.js";
|
|
13
10
|
import { Vec3 } from "../math/Vec3.js";
|
|
11
|
+
import * as mercator from "../mercator.js";
|
|
12
|
+
import * as utils from "../utils/shared.js";
|
|
14
13
|
import { createColorRGB } from "../utils/shared.js";
|
|
14
|
+
import { Material } from "./Material.js";
|
|
15
15
|
|
|
16
16
|
const FADING_RATIO = 15.8;
|
|
17
17
|
|
package/src/og/layer/Vector.js
CHANGED
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
|
-
import * as math from "../math.js";
|
|
8
|
-
import * as mercator from "../mercator.js";
|
|
9
|
-
import * as quadTree from "../quadTree/quadTree.js";
|
|
10
7
|
import { Entity } from "../entity/Entity.js";
|
|
11
8
|
import { EntityCollection } from "../entity/EntityCollection.js";
|
|
9
|
+
import { GeometryHandler } from "../entity/GeometryHandler.js";
|
|
12
10
|
import { Extent } from "../Extent.js";
|
|
11
|
+
import * as math from "../math.js";
|
|
12
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
13
|
+
import * as mercator from "../mercator.js";
|
|
13
14
|
import {
|
|
14
15
|
EntityCollectionNode,
|
|
15
16
|
EntityCollectionNodeWGS84
|
|
16
17
|
} from "../quadTree/EntityCollectionNode.js";
|
|
17
|
-
import
|
|
18
|
-
import { Layer } from "./Layer.js";
|
|
18
|
+
import * as quadTree from "../quadTree/quadTree.js";
|
|
19
19
|
import { QueueArray } from "../QueueArray.js";
|
|
20
|
-
import {
|
|
20
|
+
import { Layer } from "./Layer.js";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Creates entity instance array.
|
|
@@ -280,10 +280,6 @@ class Vector extends Layer {
|
|
|
280
280
|
_proceedEntity(entity, rightNow) {
|
|
281
281
|
let temp = this._hasImageryTiles;
|
|
282
282
|
|
|
283
|
-
//
|
|
284
|
-
// ...pointCloud, shape, model etc.
|
|
285
|
-
//
|
|
286
|
-
|
|
287
283
|
if (entity.strip) {
|
|
288
284
|
this._stripEntityCollection.add(entity);
|
|
289
285
|
}
|
|
@@ -554,7 +550,7 @@ class Vector extends Layer {
|
|
|
554
550
|
this._polylineEntityCollection.add(ei);
|
|
555
551
|
} else if (ei.geoObject) {
|
|
556
552
|
this._geoObjectEntityCollection.add(ei);
|
|
557
|
-
} else if (ei.billboard || ei.label
|
|
553
|
+
} else if (ei.billboard || ei.label) {
|
|
558
554
|
entitiesForTree.push(ei);
|
|
559
555
|
}
|
|
560
556
|
|
package/src/og/layer/WMS.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
|
-
import * as mercator from "../mercator.js";
|
|
8
7
|
import { Extent } from "../Extent.js";
|
|
9
8
|
import { LonLat } from "../LonLat.js";
|
|
9
|
+
import * as mercator from "../mercator.js";
|
|
10
10
|
import { XYZ } from "./XYZ.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -183,3 +183,4 @@ class WMS extends XYZ {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
export { WMS };
|
|
186
|
+
|
package/src/og/layer/XYZ.js
CHANGED
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
7
|
import * as mercator from "../mercator.js";
|
|
8
|
-
import { EPSG3857 } from "../proj/EPSG3857.js";
|
|
9
|
-
import { Layer } from "./Layer.js";
|
|
10
|
-
import { stringTemplate } from "../utils/shared.js";
|
|
11
8
|
import { RENDERING } from "../quadTree/quadTree.js";
|
|
12
|
-
import {
|
|
9
|
+
import { stringTemplate } from "../utils/shared.js";
|
|
10
|
+
import { Layer } from "./Layer.js";
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* Represents an imagery tiles source provider.
|
package/src/og/math/Line3.js
CHANGED
package/src/og/math/Plane.js
CHANGED
package/src/og/math/Ray.js
CHANGED
package/src/og/math/Vec2.js
CHANGED
|
@@ -50,12 +50,12 @@ export class Vec2 {
|
|
|
50
50
|
/**
|
|
51
51
|
* Returns summary vector.
|
|
52
52
|
* @static
|
|
53
|
-
* @param {
|
|
54
|
-
* @param {
|
|
55
|
-
* @returns {
|
|
53
|
+
* @param {Vec2} a - First vector.
|
|
54
|
+
* @param {Vec2} b - Second vector.
|
|
55
|
+
* @returns {Vec2} - Summary vector.
|
|
56
56
|
*/
|
|
57
57
|
static add(a, b) {
|
|
58
|
-
|
|
58
|
+
const res = new Vec2(a.x, a.y);
|
|
59
59
|
res.addA(b);
|
|
60
60
|
return res;
|
|
61
61
|
}
|
|
@@ -63,9 +63,9 @@ export class Vec2 {
|
|
|
63
63
|
/**
|
|
64
64
|
* Returns two vectors subtraction.
|
|
65
65
|
* @static
|
|
66
|
-
* @param {
|
|
67
|
-
* @param {
|
|
68
|
-
* @returns {
|
|
66
|
+
* @param {Vec2} a - First vector.
|
|
67
|
+
* @param {Vec2} b - Second vector.
|
|
68
|
+
* @returns {Vec2} - Vectors subtraction.
|
|
69
69
|
*/
|
|
70
70
|
static sub(a, b) {
|
|
71
71
|
var res = new Vec2(a.x, a.y);
|
|
@@ -76,9 +76,9 @@ export class Vec2 {
|
|
|
76
76
|
/**
|
|
77
77
|
* Returns scaled vector.
|
|
78
78
|
* @static
|
|
79
|
-
* @param {
|
|
79
|
+
* @param {Vec2} a - Input vector.
|
|
80
80
|
* @param {number} scale - Scale value.
|
|
81
|
-
* @returns {
|
|
81
|
+
* @returns {Vec2}
|
|
82
82
|
*/
|
|
83
83
|
static scale(a, scale) {
|
|
84
84
|
var res = new Vec2(a.x, a.y);
|
|
@@ -89,9 +89,9 @@ export class Vec2 {
|
|
|
89
89
|
/**
|
|
90
90
|
* Returns two vectors production.
|
|
91
91
|
* @static
|
|
92
|
-
* @param {
|
|
93
|
-
* @param {
|
|
94
|
-
* @returns {
|
|
92
|
+
* @param {Vec2} a - First vector.
|
|
93
|
+
* @param {Vec2} b - Second vector.
|
|
94
|
+
* @returns {Vec2}
|
|
95
95
|
*/
|
|
96
96
|
static mul(a, b) {
|
|
97
97
|
var res = new Vec2(a.x, a.y);
|
|
@@ -102,9 +102,9 @@ export class Vec2 {
|
|
|
102
102
|
/**
|
|
103
103
|
* Returns vector components division product one to another.
|
|
104
104
|
* @static
|
|
105
|
-
* @param {
|
|
106
|
-
* @param {
|
|
107
|
-
* @returns {
|
|
105
|
+
* @param {Vec2} a - First vector.
|
|
106
|
+
* @param {Vec2} b - Second vector.
|
|
107
|
+
* @returns {Vec2}
|
|
108
108
|
*/
|
|
109
109
|
static div(a, b) {
|
|
110
110
|
var res = new Vec2(a.x, a.y);
|
|
@@ -115,9 +115,9 @@ export class Vec2 {
|
|
|
115
115
|
/**
|
|
116
116
|
* Get projection of the first vector to the second.
|
|
117
117
|
* @static
|
|
118
|
-
* @param {
|
|
119
|
-
* @param {
|
|
120
|
-
* @returns {
|
|
118
|
+
* @param {Vec2} b - First vector.
|
|
119
|
+
* @param {Vec2} a - Second vector.
|
|
120
|
+
* @returns {Vec2}
|
|
121
121
|
*/
|
|
122
122
|
static proj_b_to_a(b, a) {
|
|
123
123
|
return a.scaleTo(a.dot(b) / a.dot(a));
|
|
@@ -126,8 +126,8 @@ export class Vec2 {
|
|
|
126
126
|
/**
|
|
127
127
|
* Gets angle between two vectors.
|
|
128
128
|
* @static
|
|
129
|
-
* @param {
|
|
130
|
-
* @param {
|
|
129
|
+
* @param {Vec2} a - First vector.
|
|
130
|
+
* @param {Vec2} b - Second vector.
|
|
131
131
|
* @returns {number}
|
|
132
132
|
*/
|
|
133
133
|
static angle(a, b) {
|
|
@@ -137,9 +137,9 @@ export class Vec2 {
|
|
|
137
137
|
/**
|
|
138
138
|
* Makes vectors normalized and orthogonal to each other.
|
|
139
139
|
* @static
|
|
140
|
-
* @param {
|
|
141
|
-
* @param {
|
|
142
|
-
* @returns {
|
|
140
|
+
* @param {Vec2} normal - Normal vector.
|
|
141
|
+
* @param {Vec2} tangent - Tangent vector.
|
|
142
|
+
* @returns {Vec2}
|
|
143
143
|
*/
|
|
144
144
|
static orthoNormalize(normal, tangent) {
|
|
145
145
|
normal = normal.norm();
|
|
@@ -159,7 +159,7 @@ export class Vec2 {
|
|
|
159
159
|
/**
|
|
160
160
|
* Returns clone vector.
|
|
161
161
|
* @public
|
|
162
|
-
* @returns {
|
|
162
|
+
* @returns {Vec2}
|
|
163
163
|
*/
|
|
164
164
|
clone() {
|
|
165
165
|
return new Vec2(this.x, this.y);
|
|
@@ -168,7 +168,7 @@ export class Vec2 {
|
|
|
168
168
|
/**
|
|
169
169
|
* Compares with vector. Returns true if it equals another.
|
|
170
170
|
* @public
|
|
171
|
-
* @param {
|
|
171
|
+
* @param {Vec2} p - Vector to compare.
|
|
172
172
|
* @returns {boolean}
|
|
173
173
|
*/
|
|
174
174
|
equal(p) {
|
|
@@ -177,8 +177,8 @@ export class Vec2 {
|
|
|
177
177
|
|
|
178
178
|
/**
|
|
179
179
|
* Copy input vector's values.
|
|
180
|
-
* @param {
|
|
181
|
-
* @returns {
|
|
180
|
+
* @param {Vec2} point2 - Vector to copy.
|
|
181
|
+
* @returns {Vec2}
|
|
182
182
|
*/
|
|
183
183
|
copy(point2) {
|
|
184
184
|
this.x = point2.x;
|
|
@@ -207,8 +207,8 @@ export class Vec2 {
|
|
|
207
207
|
/**
|
|
208
208
|
* Adds vector to the current.
|
|
209
209
|
* @public
|
|
210
|
-
* @param {
|
|
211
|
-
* @returns {
|
|
210
|
+
* @param {Vec2}
|
|
211
|
+
* @returns {Vec2}
|
|
212
212
|
*/
|
|
213
213
|
addA(v) {
|
|
214
214
|
this.x += v.x;
|
|
@@ -219,8 +219,8 @@ export class Vec2 {
|
|
|
219
219
|
/**
|
|
220
220
|
* Summarize two vectors.
|
|
221
221
|
* @public
|
|
222
|
-
* @param {
|
|
223
|
-
* @returns {
|
|
222
|
+
* @param {Vec2}
|
|
223
|
+
* @returns {Vec2}
|
|
224
224
|
*/
|
|
225
225
|
add(v) {
|
|
226
226
|
return new Vec2(this.x + v.x, this.y + v.y);
|
|
@@ -229,8 +229,8 @@ export class Vec2 {
|
|
|
229
229
|
/**
|
|
230
230
|
* Subtract vector from the current where results saved on the current instance.
|
|
231
231
|
* @public
|
|
232
|
-
* @param {
|
|
233
|
-
* @returns {
|
|
232
|
+
* @param {Vec2} v - Subtract vector.
|
|
233
|
+
* @returns {Vec2}
|
|
234
234
|
*/
|
|
235
235
|
subA(v) {
|
|
236
236
|
this.x -= v.x;
|
|
@@ -241,8 +241,8 @@ export class Vec2 {
|
|
|
241
241
|
/**
|
|
242
242
|
* Subtract vector from the current.
|
|
243
243
|
* @public
|
|
244
|
-
* @param {
|
|
245
|
-
* @returns {
|
|
244
|
+
* @param {Vec2} v - Subtract vector.
|
|
245
|
+
* @returns {Vec2}
|
|
246
246
|
*/
|
|
247
247
|
sub(v) {
|
|
248
248
|
return new Vec2(this.x - v.x, this.y - v.y);
|
|
@@ -252,7 +252,7 @@ export class Vec2 {
|
|
|
252
252
|
* Scale current vector.
|
|
253
253
|
* @public
|
|
254
254
|
* @param {number} scale - Scale value.
|
|
255
|
-
* @returns {
|
|
255
|
+
* @returns {Vec2}
|
|
256
256
|
*/
|
|
257
257
|
scale(scale) {
|
|
258
258
|
this.x *= scale;
|
|
@@ -264,7 +264,7 @@ export class Vec2 {
|
|
|
264
264
|
* Scale current vector to another instance.
|
|
265
265
|
* @public
|
|
266
266
|
* @param {number} scale - Scale value.
|
|
267
|
-
* @returns {
|
|
267
|
+
* @returns {Vec2}
|
|
268
268
|
*/
|
|
269
269
|
scaleTo(scale) {
|
|
270
270
|
return new Vec2(this.x * scale, this.y * scale);
|
|
@@ -273,8 +273,8 @@ export class Vec2 {
|
|
|
273
273
|
/**
|
|
274
274
|
* Multiply current vector object to another and store result in the current instance.
|
|
275
275
|
* @public
|
|
276
|
-
* @param {
|
|
277
|
-
* @returns {
|
|
276
|
+
* @param {Vec2} vec - Multiply vector.
|
|
277
|
+
* @returns {Vec2}
|
|
278
278
|
*/
|
|
279
279
|
mulA(vec) {
|
|
280
280
|
this.x *= vec.x;
|
|
@@ -285,8 +285,8 @@ export class Vec2 {
|
|
|
285
285
|
/**
|
|
286
286
|
* Multiply current vector object to another and returns new vector instance.
|
|
287
287
|
* @public
|
|
288
|
-
* @param {
|
|
289
|
-
* @returns {
|
|
288
|
+
* @param {Vec2} vec - Multiply vector.
|
|
289
|
+
* @returns {Vec2}
|
|
290
290
|
*/
|
|
291
291
|
mul(vec) {
|
|
292
292
|
return new Vec2(this.x * vec.x, this.y * vec.y);
|
|
@@ -295,8 +295,8 @@ export class Vec2 {
|
|
|
295
295
|
/**
|
|
296
296
|
* Divide current vector's components to another. Results stores in the current vector object.
|
|
297
297
|
* @public
|
|
298
|
-
* @param {
|
|
299
|
-
* @returns {
|
|
298
|
+
* @param {Vec2}
|
|
299
|
+
* @returns {Vec2}
|
|
300
300
|
*/
|
|
301
301
|
divA(vec) {
|
|
302
302
|
this.x /= vec.x;
|
|
@@ -307,7 +307,7 @@ export class Vec2 {
|
|
|
307
307
|
/**
|
|
308
308
|
* Gets vectors dot production.
|
|
309
309
|
* @public
|
|
310
|
-
* @param {
|
|
310
|
+
* @param {Vec2} v - Another vector.
|
|
311
311
|
* @returns {number}
|
|
312
312
|
*/
|
|
313
313
|
dot(v) {
|
|
@@ -327,8 +327,8 @@ export class Vec2 {
|
|
|
327
327
|
/**
|
|
328
328
|
* Gets vectors cross production.
|
|
329
329
|
* @public
|
|
330
|
-
* @param {
|
|
331
|
-
* @returns {
|
|
330
|
+
* @param {Vec2} v - Another vector.
|
|
331
|
+
* @returns {Vec2}
|
|
332
332
|
*/
|
|
333
333
|
cross(v) {
|
|
334
334
|
return this.x * v.y - this.y * v.x;
|
|
@@ -337,7 +337,7 @@ export class Vec2 {
|
|
|
337
337
|
/**
|
|
338
338
|
* Sets vector to zero.
|
|
339
339
|
* @public
|
|
340
|
-
* @returns {
|
|
340
|
+
* @returns {Vec2}
|
|
341
341
|
*/
|
|
342
342
|
clear() {
|
|
343
343
|
this.x = this.y = 0;
|
|
@@ -347,7 +347,7 @@ export class Vec2 {
|
|
|
347
347
|
/**
|
|
348
348
|
* Returns normalized vector.
|
|
349
349
|
* @public
|
|
350
|
-
* @returns {
|
|
350
|
+
* @returns {Vec2}
|
|
351
351
|
*/
|
|
352
352
|
normal() {
|
|
353
353
|
var res = new Vec2();
|
|
@@ -364,7 +364,7 @@ export class Vec2 {
|
|
|
364
364
|
/**
|
|
365
365
|
* Normalize current vector.
|
|
366
366
|
* @public
|
|
367
|
-
* @returns {
|
|
367
|
+
* @returns {Vec2}
|
|
368
368
|
*/
|
|
369
369
|
normalize() {
|
|
370
370
|
var length = 1.0 / this.length();
|
|
@@ -387,7 +387,7 @@ export class Vec2 {
|
|
|
387
387
|
/**
|
|
388
388
|
* Gets distance to point.
|
|
389
389
|
* @public
|
|
390
|
-
* @param {
|
|
390
|
+
* @param {Vec2} p - Distant point.
|
|
391
391
|
* @returns {number}
|
|
392
392
|
*/
|
|
393
393
|
distance(p) {
|
|
@@ -400,7 +400,7 @@ export class Vec2 {
|
|
|
400
400
|
* @public
|
|
401
401
|
* @param {number} x - Value X.
|
|
402
402
|
* @param {number} y - Value Y.
|
|
403
|
-
* @returns {
|
|
403
|
+
* @returns {Vec2}
|
|
404
404
|
*/
|
|
405
405
|
set(x, y) {
|
|
406
406
|
this.x = x;
|
|
@@ -411,7 +411,7 @@ export class Vec2 {
|
|
|
411
411
|
/**
|
|
412
412
|
* Negate current vector.
|
|
413
413
|
* @public
|
|
414
|
-
* @returns {
|
|
414
|
+
* @returns {Vec2}
|
|
415
415
|
*/
|
|
416
416
|
negate() {
|
|
417
417
|
this.x = -this.x;
|
|
@@ -422,7 +422,7 @@ export class Vec2 {
|
|
|
422
422
|
/**
|
|
423
423
|
* Negate current vector to another instance.
|
|
424
424
|
* @public
|
|
425
|
-
* @returns {
|
|
425
|
+
* @returns {Vec2}
|
|
426
426
|
*/
|
|
427
427
|
negateTo() {
|
|
428
428
|
return new Vec2(-this.x, -this.y);
|
|
@@ -431,9 +431,9 @@ export class Vec2 {
|
|
|
431
431
|
/**
|
|
432
432
|
* Gets projected point coordinates of the current vector on the ray.
|
|
433
433
|
* @public
|
|
434
|
-
* @param {
|
|
435
|
-
* @param {
|
|
436
|
-
* @returns {
|
|
434
|
+
* @param {Vec2} pos - Ray position.
|
|
435
|
+
* @param {Vec2} direction - Ray direction.
|
|
436
|
+
* @returns {Vec2}
|
|
437
437
|
*/
|
|
438
438
|
projToRay(pos, direction) {
|
|
439
439
|
var v = Vec2.proj_b_to_a(Vec2.sub(this, pos), direction);
|
|
@@ -444,7 +444,7 @@ export class Vec2 {
|
|
|
444
444
|
/**
|
|
445
445
|
* Gets angle between two vectors.
|
|
446
446
|
* @public
|
|
447
|
-
* @param {
|
|
447
|
+
* @param {Vec2} a - Another vector.
|
|
448
448
|
* @returns {number}
|
|
449
449
|
*/
|
|
450
450
|
angle(a) {
|
|
@@ -454,9 +454,9 @@ export class Vec2 {
|
|
|
454
454
|
/**
|
|
455
455
|
* Returns two vectors linear interpolation.
|
|
456
456
|
* @public
|
|
457
|
-
* @param {
|
|
457
|
+
* @param {Vec2} v2 - End vector.
|
|
458
458
|
* @param {number} l - Interpolate value.
|
|
459
|
-
* @returns {
|
|
459
|
+
* @returns {Vec2}
|
|
460
460
|
*/
|
|
461
461
|
lerp(v1, v2, l) {
|
|
462
462
|
var res = Vec2.clone(this);
|
|
@@ -480,9 +480,9 @@ export class Vec2 {
|
|
|
480
480
|
* the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated
|
|
481
481
|
* by the angle and its magnitude is interpolated between the magnitudes of from and to.
|
|
482
482
|
* @public
|
|
483
|
-
* @param {
|
|
483
|
+
* @param {Vec2} v2 -
|
|
484
484
|
* @param {number} t - The parameter t is clamped to the range [0, 1].
|
|
485
|
-
* @returns {
|
|
485
|
+
* @returns {Vec2}
|
|
486
486
|
*/
|
|
487
487
|
slerp(v2, t) {
|
|
488
488
|
var res = new Vec2();
|
|
@@ -517,7 +517,7 @@ export class Vec2 {
|
|
|
517
517
|
* @function
|
|
518
518
|
* @param {number} [x] - First cvalue.
|
|
519
519
|
* @param {number} [y] - Second value.
|
|
520
|
-
* @returns {
|
|
520
|
+
* @returns {Vec2}
|
|
521
521
|
*/
|
|
522
522
|
export function vec2(x, y) {
|
|
523
523
|
return new Vec2(x, y);
|
package/src/og/math/Vec3.js
CHANGED