Entity ground collision is fixed and jsdoc is improved.

This commit is contained in:
Zemledelec 2018-07-24 10:30:12 +03:00
parent d50b396493
commit 2a6f08cc67
51 changed files with 665 additions and 483 deletions

View File

@ -6,13 +6,132 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./osm.js" type="module"></script> <script src="./osm.js" type="module"></script>
<link rel="stylesheet" href="../../css/og.css" type="text/css" /> <link rel="stylesheet" href="../../css/og.css" type="text/css" />
<style>
.color-options {
position: absolute;
top: 0;
right: 0;
background-color: white;
padding: 15px;
width: 250px;
}
.caption {
width: 100%;
height: 20px;
position: relative;
}
.option {
width: 100%;
position: relative;
display: flex;
}
.label {
float: left;
}
.slider {
float: left;
width: calc(100% - 50px);
}
.slider input {
width: 100%;
position: relative;
}
.value{
float:left;
}
</style>
</head> </head>
<body> <body>
<div id="earth" style="width:100%;height:100%"/> <div id="earth" style="width:100%;height:100%"></div>
<div id="debug" class="defaultText"/>
<div id="bounds" class="defaultText"/> <div class="color-options">
<div id="curr" class="defaultText"/> <div class="caption">Ambient</div>
<div class="option">
<div class="label">R</div>
<div class="slider">
<input type="range" id="ambient-r" name="ambient-r" value="0.0" min="0.0" max="2.0" step="0.01" />
</div>
<div class="value ambient-r">0.888</div>
</div>
<div class="option">
<div class="label">G</div>
<div class="slider">
<input type="range" id="ambient-g" name="ambient-g" value="0.0" min="0.0" max="2.0" step="0.01" />
</div>
<div class="value ambient-g">0.888</div>
</div>
<div class="option">
<div class="label">B</div>
<div class="slider">
<input type="range" id="ambient-b" name="ambient-b" value="0.0" min="0.0" max="2.0" step="0.01" />
</div>
<div class="value ambient-b">0.888</div>
</div>
<div class="caption">Diffuse</div>
<div class="option">
<div class="label">R</div>
<div class="slider">
<input type="range" id="diffuse-r" name="diffuse-r" value="0.0" min="0.0" max="2.0" step="0.01" />
</div>
<div class="value diffuse-r">0.888</div>
</div>
<div class="option">
<div class="label">G</div>
<div class="slider">
<input type="range" id="diffuse-g" name="diffuse-g" value="0.0" min="0.0" max="2.0" step="0.01" />
</div>
<div class="value diffuse-g">0.888</div>
</div>
<div class="option">
<div class="label">B</div>
<div class="slider">
<input type="range" id="diffuse-b" name="diffuse-b" value="0.0" min="0.0" max="2.0" step="0.01" />
</div>
<div class="value diffuse-b">0.888</div>
</div>
<div class="caption">Specular</div>
<div class="option">
<div class="label">R</div>
<div class="slider">
<input type="range" id="specular-r" name="specular-r" value="0.0" min="0.0" max="1.0" step="0.0001" />
</div>
<div class="value specular-r">0.888</div>
</div>
<div class="option">
<div class="label">G</div>
<div class="slider">
<input type="range" id="specular-g" name="specular-g" value="0.0" min="0.0" max="1.0" step="0.0001" />
</div>
<div class="value specular-g">0.888</div>
</div>
<div class="option">
<div class="label">B</div>
<div class="slider">
<input type="range" id="specular-b" name="specular-b" value="0.0" min="0.0" max="1.0" step="0.0001" />
</div>
<div class="value specular-b">0.888</div>
</div>
<div class="caption">Shininess</div>
<div class="option">
<div class="label">R</div>
<div class="slider">
<input type="range" id="shininess" name="shininess" value="0.0" min="0.0" max="1000.0" step="1" />
</div>
<div class="value shininess">0.888</div>
</div>
</div>
</body> </body>
</html> </html>

View File

@ -11,6 +11,60 @@ import { DebugInfo } from '../../src/og/control/DebugInfo.js';
import { ToggleWireframe } from '../../src/og/control/ToggleWireframe.js'; import { ToggleWireframe } from '../../src/og/control/ToggleWireframe.js';
import * as math from '../../src/og/math.js'; import * as math from '../../src/og/math.js';
document.getElementById("ambient-r").addEventListener("input", function (e) {
osm.ambient.x = this.value;
document.querySelector(".value.ambient-r").innerHTML = this.value;
});
document.getElementById("ambient-g").addEventListener("input", function (e) {
osm.ambient.y = this.value;
document.querySelector(".value.ambient-g").innerHTML = this.value;
});
document.getElementById("ambient-b").addEventListener("input", function (e) {
osm.ambient.z = this.value;
document.querySelector(".value.ambient-b").innerHTML = this.value;
});
document.getElementById("diffuse-r").addEventListener("input", function (e) {
osm.diffuse.x = this.value;
document.querySelector(".value.diffuse-r").innerHTML = this.value;
});
document.getElementById("diffuse-g").addEventListener("input", function (e) {
osm.diffuse.y = this.value;
document.querySelector(".value.diffuse-g").innerHTML = this.value;
});
document.getElementById("diffuse-b").addEventListener("input", function (e) {
osm.diffuse.z = this.value;
document.querySelector(".value.diffuse-b").innerHTML = this.value;
});
document.getElementById("specular-r").addEventListener("input", function (e) {
osm.specular.x = this.value;
document.querySelector(".value.specular-r").innerHTML = this.value;
});
document.getElementById("specular-g").addEventListener("input", function (e) {
osm.specular.y = this.value;
document.querySelector(".value.specular-g").innerHTML = this.value;
});
document.getElementById("specular-b").addEventListener("input", function (e) {
osm.specular.z = this.value;
document.querySelector(".value.specular-b").innerHTML = this.value;
});
document.getElementById("shininess").addEventListener("input", function (e) {
osm.shininess = this.value;
document.querySelector(".value.shininess").innerHTML = this.value;
});
let cnv = document.createElement("canvas"); let cnv = document.createElement("canvas");
let ctx = cnv.getContext("2d"); let ctx = cnv.getContext("2d");
cnv.width = 256; cnv.width = 256;

View File

@ -84,7 +84,7 @@ class Frustum {
/** /**
* Returns true if a point in the frustum. * Returns true if a point in the frustum.
* @public * @public
* @param {og.math.Vec3} point - Cartesian point. * @param {og.Vec3} point - Cartesian point.
* @returns {boolean} * @returns {boolean}
*/ */
containsPoint(point) { containsPoint(point) {

View File

@ -53,7 +53,7 @@ const PLANET_NAME_PREFIX = "globus_planet_";
* @param {string} [options.name] - Planet name. Default is unic identifier. * @param {string} [options.name] - Planet name. Default is unic identifier.
* @param {og.terrain.Terrain} [options.terrain] - Terrain provider. Default no terrain - og.terrain.EmptyTerrain. * @param {og.terrain.Terrain} [options.terrain] - Terrain provider. Default no terrain - og.terrain.EmptyTerrain.
* @param {Array.<og.control.Control>} [options.controls] - Renderer controls array. * @param {Array.<og.control.Control>} [options.controls] - Renderer controls array.
* @param {Array.<og.layer.Layer>} [options.layers] - Planet layers. * @param {Array.<og.Layer>} [options.layers] - Planet layers.
* @param {og.Extent} [options.viewExtent] - Viewable starting extent. * @param {og.Extent} [options.viewExtent] - Viewable starting extent.
* @param {boolean} [options.autoActivate] - Globe rendering auto activation flag. True is default. * @param {boolean} [options.autoActivate] - Globe rendering auto activation flag. True is default.
*/ */

View File

@ -14,7 +14,7 @@ import { Vec3 } from '../math/Vec3.js';
/** /**
* Returns Sun position in the geocentric coordinate system by the time. * Returns Sun position in the geocentric coordinate system by the time.
* @param {Number} jDate - Julian date time. * @param {Number} jDate - Julian date time.
* @returns {og.math.Vector3} - Sun geocentric coordinates. * @returns {og.Vec3} - Sun geocentric coordinates.
*/ */
export function getSunPosition(jDate) { export function getSunPosition(jDate) {
//http://stjarnhimlen.se/comp/tutorial.html //http://stjarnhimlen.se/comp/tutorial.html

View File

@ -15,7 +15,7 @@ class Box {
/** /**
* Vertices array. * Vertices array.
* @public * @public
* @type{Array.<og.math.Vector3>} * @type{Array.<og.Vec3>}
*/ */
this.vertices = [new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3()]; this.vertices = [new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3(), new Vec3()];
} }

View File

@ -10,7 +10,7 @@ import { Vec3 } from '../math/Vec3.js';
* Bounding sphere class. * Bounding sphere class.
* @class * @class
* @param {Number} [radius] - Bounding sphere radius. * @param {Number} [radius] - Bounding sphere radius.
* @param {og.math.Vector3} [center] - Bounding sphere coordiantes. * @param {og.Vec3} [center] - Bounding sphere coordiantes.
*/ */
class Sphere { class Sphere {
constructor(radius, center) { constructor(radius, center) {
@ -25,7 +25,7 @@ class Sphere {
/** /**
* Sphere coordiantes. * Sphere coordiantes.
* @public * @public
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this.center = center ? center.clone() : new Vec3(); this.center = center ? center.clone() : new Vec3();
} }

View File

@ -22,9 +22,9 @@ import { Mat4 } from '../math/Mat4.js';
* @param {number} [options.viewAngle=30] - Camera angle of view. Default is 30.0 * @param {number} [options.viewAngle=30] - Camera angle of view. Default is 30.0
* @param {number} [options.near=1] - Camera near plane distance. Default is 1.0 * @param {number} [options.near=1] - Camera near plane distance. Default is 1.0
* @param {number} [options.far=og.math.MAX] - Camera far plane distance. Deafult is og.math.MAX * @param {number} [options.far=og.math.MAX] - Camera far plane distance. Deafult is og.math.MAX
* @param {og.math.Vector3} [options.eye=[0,0,0]] - Camera eye position. Default (0,0,0) * @param {og.Vec3} [options.eye=[0,0,0]] - Camera eye position. Default (0,0,0)
* @param {og.math.Vector3} [options.look=[0,0,0]] - Camera look position. Default (0,0,0) * @param {og.Vec3} [options.look=[0,0,0]] - Camera look position. Default (0,0,0)
* @param {og.math.Vector3} [options.up=[0,1,0]] - Camera eye position. Default (0,1,0) * @param {og.Vec3} [options.up=[0,1,0]] - Camera eye position. Default (0,1,0)
* *
* @fires og.Camera#viewchange * @fires og.Camera#viewchange
*/ */
@ -48,7 +48,7 @@ class Camera {
/** /**
* Camera position. * Camera position.
* @public * @public
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this.eye = new Vec3(); this.eye = new Vec3();
@ -90,56 +90,56 @@ class Camera {
/** /**
* Camera normal matrix. * Camera normal matrix.
* @protected * @protected
* @type {og.math.Matrix3} * @type {og.Mat3}
*/ */
this._normalMatrix = new Mat3(); this._normalMatrix = new Mat3();
/** /**
* Camera projection matrix. * Camera projection matrix.
* @protected * @protected
* @type {og.math.Matrix4} * @type {og.Mat4}
*/ */
this._projectionMatrix = new Mat4(); this._projectionMatrix = new Mat4();
/** /**
* Camera view matrix. * Camera view matrix.
* @protected * @protected
* @type {og.math.Matrix4} * @type {og.Mat4}
*/ */
this._viewMatrix = new Mat4(); this._viewMatrix = new Mat4();
/** /**
* Product of projection and view matrices. * Product of projection and view matrices.
* @protected * @protected
* @type {og.math.Matrix4} * @type {og.Mat4}
*/ */
this._projectionViewMatrix = new Mat4(); this._projectionViewMatrix = new Mat4();
/** /**
* Inverse projectionView Matrix. * Inverse projectionView Matrix.
* @protected * @protected
* @type {og.math.Matrix4} * @type {og.Mat4}
*/ */
this._inverseProjectionViewMatrix = new Mat4(); this._inverseProjectionViewMatrix = new Mat4();
/** /**
* Camera projection matrix for small near and far distances. * Camera projection matrix for small near and far distances.
* @protected * @protected
* @type {og.math.Matrix4} * @type {og.Mat4}
*/ */
this._projectionMatrixPrecise = new Mat4(); this._projectionMatrixPrecise = new Mat4();
/** /**
* Camera right vector. * Camera right vector.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._u = new Vec3(0, 1, 0); //up x n this._u = new Vec3(0, 1, 0); //up x n
/** /**
* Camera up vector. * Camera up vector.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._v = new Vec3(1, 0, 0); //n x u - UP this._v = new Vec3(1, 0, 0); //n x u - UP
@ -148,7 +148,7 @@ class Camera {
/** /**
* Camera forward vector. * Camera forward vector.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._n = new Vec3(0, 0, 1); //eye - look - FORWARD this._n = new Vec3(0, 0, 1); //eye - look - FORWARD
@ -216,9 +216,9 @@ class Camera {
* @param {number} [options.viewAngle] - Camera angle of view. Default is 30.0 * @param {number} [options.viewAngle] - Camera angle of view. Default is 30.0
* @param {number} [options.near] - Camera near plane distance. Default is 1.0 * @param {number} [options.near] - Camera near plane distance. Default is 1.0
* @param {number} [options.far] - Camera far plane distance. Deafult is og.math.MAX * @param {number} [options.far] - Camera far plane distance. Deafult is og.math.MAX
* @param {og.math.Vector3} [options.eye] - Camera eye position. Default (0,0,0) * @param {og.Vec3} [options.eye] - Camera eye position. Default (0,0,0)
* @param {og.math.Vector3} [options.look] - Camera look position. Default (0,0,0) * @param {og.Vec3} [options.look] - Camera look position. Default (0,0,0)
* @param {og.math.Vector3} [options.up] - Camera eye position. Default (0,1,0) * @param {og.Vec3} [options.up] - Camera eye position. Default (0,1,0)
*/ */
_initialize(options) { _initialize(options) {
@ -399,9 +399,9 @@ class Camera {
/** /**
* Sets camera to eye position. * Sets camera to eye position.
* @public * @public
* @param {og.math.Vector3} eye - Camera position. * @param {og.Vec3} eye - Camera position.
* @param {og.math.Vector3} look - Look point. * @param {og.Vec3} look - Look point.
* @param {og.math.Vector3} up - Camera up vector. * @param {og.Vec3} up - Camera up vector.
* @returns {og.Camera} - This camera. * @returns {og.Camera} - This camera.
*/ */
set(eye, look, up) { set(eye, look, up) {
@ -423,8 +423,8 @@ class Camera {
/** /**
* Sets camera look point. * Sets camera look point.
* @public * @public
* @param {og.math.Vector3} look - Look point. * @param {og.Vec3} look - Look point.
* @param {og.math.Vector3} [up] - Camera up vector otherwise camera current up vector(this._v) * @param {og.Vec3} [up] - Camera up vector otherwise camera current up vector(this._v)
*/ */
look(look, up) { look(look, up) {
this._n.set(this.eye.x - look.x, this.eye.y - look.y, this.eye.z - look.z); this._n.set(this.eye.x - look.x, this.eye.y - look.y, this.eye.z - look.z);
@ -491,7 +491,7 @@ class Camera {
* @public * @public
* @param {number} x - Scren X coordinate. * @param {number} x - Scren X coordinate.
* @param {number} y - Scren Y coordinate. * @param {number} y - Scren Y coordinate.
* @returns {og.math.Vector3} - Direction vector. * @returns {og.Vec3} - Direction vector.
*/ */
unproject(x, y) { unproject(x, y) {
var c = this.renderer.handler.canvas, var c = this.renderer.handler.canvas,
@ -510,8 +510,8 @@ class Camera {
/** /**
* Gets projected 3d point to the 2d screen coordiantes. * Gets projected 3d point to the 2d screen coordiantes.
* @public * @public
* @param {og.math.Vector3} v - Cartesian 3d coordiantes. * @param {og.Vec3} v - Cartesian 3d coordiantes.
* @returns {og.math.Vector2} - Screen point coordinates. * @returns {og.Vec2} - Screen point coordinates.
*/ */
project(v) { project(v) {
var r = this._projectionViewMatrix.mulVec4(v.toVec4()), var r = this._projectionViewMatrix.mulVec4(v.toVec4()),
@ -525,7 +525,7 @@ class Camera {
* @param {number} angle - Rotation angle in radians. * @param {number} angle - Rotation angle in radians.
* @param {boolaen} isArc - If true camera up vector gets from current up vector every frame, * @param {boolaen} isArc - If true camera up vector gets from current up vector every frame,
* otherwise up is always input parameter. * otherwise up is always input parameter.
* @param {og.math.Vector3} center - Point that the camera rotates around. * @param {og.Vec3} center - Point that the camera rotates around.
* @param {og.math.Vecto3} [up] - Camera up vector. * @param {og.math.Vecto3} [up] - Camera up vector.
*/ */
rotateAround(angle, isArc, center, up) { rotateAround(angle, isArc, center, up) {
@ -550,8 +550,8 @@ class Camera {
* @param {number} angle - Rotation angle in radians. * @param {number} angle - Rotation angle in radians.
* @param {boolaen} isArc - If true camera up vector gets from current up vector every frame, * @param {boolaen} isArc - If true camera up vector gets from current up vector every frame,
* otherwise up is always input parameter. * otherwise up is always input parameter.
* @param {og.math.Vector3} center - Point that the camera rotates around. * @param {og.Vec3} center - Point that the camera rotates around.
* @param {og.math.Vector3} [up] - Camera up vector. * @param {og.Vec3} [up] - Camera up vector.
*/ */
rotateHorizontal(angle, isArc, center, up) { rotateHorizontal(angle, isArc, center, up) {
this.rotateAround(angle, isArc, center, up); this.rotateAround(angle, isArc, center, up);
@ -560,7 +560,7 @@ class Camera {
/** /**
* Rotates camera around center point by vecrtical. * Rotates camera around center point by vecrtical.
* @param {number} angle - Rotation angle in radians. * @param {number} angle - Rotation angle in radians.
* @param {og.math.Vector3} center - Point that the camera rotates around. * @param {og.Vec3} center - Point that the camera rotates around.
*/ */
rotateVertical(angle, center) { rotateVertical(angle, center) {
this.rotateAround(angle, false, center, this._u); this.rotateAround(angle, false, center, this._u);
@ -569,8 +569,8 @@ class Camera {
/** /**
* Gets 3d size factor. Uses in LOD distance calculation. * Gets 3d size factor. Uses in LOD distance calculation.
* @public * @public
* @param {og.math.Vector3} p - Far point. * @param {og.Vec3} p - Far point.
* @param {og.math.Vector3} r - Far point. * @param {og.Vec3} r - Far point.
* @returns {number} - Size factor. * @returns {number} - Size factor.
*/ */
projectedSize(p, r) { projectedSize(p, r) {
@ -580,7 +580,7 @@ class Camera {
/** /**
* Returns normal matrix. * Returns normal matrix.
* @public * @public
* @returns {og.math.Matrix3} - Normal matrix. * @returns {og.Mat3} - Normal matrix.
*/ */
getNormalMatrix() { getNormalMatrix() {
return this._normalMatrix; return this._normalMatrix;
@ -589,7 +589,7 @@ class Camera {
/** /**
* Returns projection matrix. * Returns projection matrix.
* @public * @public
* @returns {og.math.Matrix4} - Projection matrix. * @returns {og.Mat4} - Projection matrix.
*/ */
getProjectionMatrix() { getProjectionMatrix() {
return this._projectionMatrix; return this._projectionMatrix;
@ -598,7 +598,7 @@ class Camera {
/** /**
* Returns model matrix. * Returns model matrix.
* @public * @public
* @returns {og.math.Matrix4} - View matrix. * @returns {og.Mat4} - View matrix.
*/ */
getViewMatrix() { getViewMatrix() {
return this._viewMatrix; return this._viewMatrix;
@ -607,7 +607,7 @@ class Camera {
/** /**
* Returns projection and model matrix product. * Returns projection and model matrix product.
* @public * @public
* @return {og.math.Matrix4} - Projection-view matrix. * @return {og.Mat4} - Projection-view matrix.
*/ */
getProjectionViewMatrix() { getProjectionViewMatrix() {
return this._projectionViewMatrix; return this._projectionViewMatrix;
@ -616,7 +616,7 @@ class Camera {
/** /**
* Returns inverse projection and model matrix product. * Returns inverse projection and model matrix product.
* @public * @public
* @returns {og.math.Matrix4} - Inversed projection-view matrix. * @returns {og.Mat4} - Inversed projection-view matrix.
*/ */
getInverseProjecttionViewMatrix() { getInverseProjecttionViewMatrix() {
return this._inverseProjectionViewMatrix; return this._inverseProjectionViewMatrix;

View File

@ -24,9 +24,9 @@ import { Ray } from '../math/Ray.js';
* @param {number} [options.near] - Camera near plane distance. Default is 1.0 * @param {number} [options.near] - Camera near plane distance. Default is 1.0
* @param {number} [options.far] - Camera far plane distance. Deafult is og.math.MAX * @param {number} [options.far] - Camera far plane distance. Deafult is og.math.MAX
* @param {number} [options.minAltitude] - Minimal altitude for the camera. Deafult is 50 * @param {number} [options.minAltitude] - Minimal altitude for the camera. Deafult is 50
* @param {og.math.Vector3} [options.eye] - Camera eye position. Default (0,0,0) * @param {og.Vec3} [options.eye] - Camera eye position. Default (0,0,0)
* @param {og.math.Vector3} [options.look] - Camera look position. Default (0,0,0) * @param {og.Vec3} [options.look] - Camera look position. Default (0,0,0)
* @param {og.math.Vector3} [options.up] - Camera eye position. Default (0,1,0) * @param {og.Vec3} [options.up] - Camera eye position. Default (0,1,0)
*/ */
class PlanetCamera extends Camera { class PlanetCamera extends Camera {
constructor(planet, options) { constructor(planet, options) {
@ -69,7 +69,7 @@ class PlanetCamera extends Camera {
/** /**
* Cartesian coordinates on the terrain. * Cartesian coordinates on the terrain.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._terrainPoint = new Vec3(); this._terrainPoint = new Vec3();
@ -88,7 +88,7 @@ class PlanetCamera extends Camera {
* @protected * @protected
* @type {og.LonLat} * @type {og.LonLat}
*/ */
this._insideSegmentPosition = null; this._insideSegmentPosition = new LonLat();
this._keyLock = new Key(); this._keyLock = new Key();
@ -184,7 +184,7 @@ class PlanetCamera extends Camera {
* @public * @public
* @param {og.LonLat} lonlat - New camera and camera view position. * @param {og.LonLat} lonlat - New camera and camera view position.
* @param {og.LonLat} [lookLonLat] - Look up coordinates. * @param {og.LonLat} [lookLonLat] - Look up coordinates.
* @param {og.math.Vector3} [up] - Camera UP vector. Default (0,1,0) * @param {og.Vec3} [up] - Camera UP vector. Default (0,1,0)
*/ */
setLonLat(lonlat, lookLonLat, up) { setLonLat(lonlat, lookLonLat, up) {
this.stopFlying(); this.stopFlying();
@ -218,7 +218,7 @@ class PlanetCamera extends Camera {
* Gets position by viewable extent. * Gets position by viewable extent.
* @public * @public
* @param {og.Extent} extent - Viewable extent. * @param {og.Extent} extent - Viewable extent.
* @returns {og.math.Vector3} * @returns {og.Vec3}
*/ */
getExtentPosition(extent) { getExtentPosition(extent) {
@ -298,7 +298,7 @@ class PlanetCamera extends Camera {
* Flies to the current extent. * Flies to the current extent.
* @public * @public
* @param {og.Extent} extent - Current extent. * @param {og.Extent} extent - Current extent.
* @param {og.math.Vector3} [up] - Camera UP in the end of flying. Default - (0,1,0) * @param {og.Vec3} [up] - Camera UP in the end of flying. Default - (0,1,0)
* @param {cameraCallback} [completeCallback] - Callback that calls after flying when flying is finished. * @param {cameraCallback} [completeCallback] - Callback that calls after flying when flying is finished.
* @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins. * @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
*/ */
@ -310,9 +310,9 @@ class PlanetCamera extends Camera {
/** /**
* Flies to the cartesian coordinates. * Flies to the cartesian coordinates.
* @public * @public
* @param {og.math.Vector3} cartesian - Finish cartesian coordinates. * @param {og.Vec3} cartesian - Finish cartesian coordinates.
* @param {og.math.Vector3} [look] - Camera LOOK in the end of flying. Default - (0,0,0) * @param {og.Vec3} [look] - Camera LOOK in the end of flying. Default - (0,0,0)
* @param {og.math.Vector3} [up] - Camera UP vector in the end of flying. Default - (0,1,0) * @param {og.Vec3} [up] - Camera UP vector in the end of flying. Default - (0,1,0)
* @param {cameraCallback} [completeCallback] - Callback that calls after flying when flying is finished. * @param {cameraCallback} [completeCallback] - Callback that calls after flying when flying is finished.
* @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins. * @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
*/ */
@ -401,8 +401,8 @@ class PlanetCamera extends Camera {
* Flies to the geo coordiantes. * Flies to the geo coordiantes.
* @public * @public
* @param {og.LonLat} lonlat - Finish coordinates. * @param {og.LonLat} lonlat - Finish coordinates.
* @param {og.math.Vector3} [look] - Camera LOOK in the end of flying. Default - (0,0,0) * @param {og.Vec3} [look] - Camera LOOK in the end of flying. Default - (0,0,0)
* @param {og.math.Vector3} [up] - Camera UP vector in the end of flying. Default - (0,1,0) * @param {og.Vec3} [up] - Camera UP vector in the end of flying. Default - (0,1,0)
* @param {cameraCallback} [completeCallback] - Callback that calls after flying when flying is finished. * @param {cameraCallback} [completeCallback] - Callback that calls after flying when flying is finished.
* @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins. * @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
*/ */
@ -506,7 +506,7 @@ class PlanetCamera extends Camera {
} }
} else { } else {
this._terrainAltitude = this._lonLat.height; this._terrainAltitude = this._lonLat.height;
if (this._lonLat.height < 1000000) { if (this._lonLat.height < 1000000 && this._insideSegment) {
this._terrainAltitude = this._insideSegment.getTerrainPoint(this._terrainPoint, this.eye, this._insideSegmentPosition); this._terrainAltitude = this._insideSegment.getTerrainPoint(this._terrainPoint, this.eye, this._insideSegmentPosition);
if (this._terrainAltitude < this.minAltitude) { if (this._terrainAltitude < this.minAltitude) {
this.setAltitude(this.minAltitude); this.setAltitude(this.minAltitude);

View File

@ -96,7 +96,7 @@ class EarthCoordinates extends Control {
/** /**
* Current position. * Current position.
* @public * @public
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this.position = null; this.position = null;
} }

View File

@ -191,10 +191,10 @@ class TouchNavigation extends Control {
//var targetPointC = this.planet.getCartesianFromPixelTerrain(new og.math.Pixel(center_x, center_y)); //var targetPointC = this.planet.getCartesianFromPixelTerrain(new og.math.Pixel(center_x, center_y));
//var dir0 = cam.unproject(t0.x, t0.y); //var dir0 = cam.unproject(t0.x, t0.y);
//var targetPoint0 = new og.math.Ray(cam.eye, dir0).hitSphere(t0.grabbedSpheroid); //var targetPoint0 = new og.Ray(cam.eye, dir0).hitSphere(t0.grabbedSpheroid);
//var dir1 = cam.unproject(t1.x, t1.y); //var dir1 = cam.unproject(t1.x, t1.y);
//var targetPoint1 = new og.math.Ray(cam.eye, dir1).hitSphere(t1.grabbedSpheroid); //var targetPoint1 = new og.Ray(cam.eye, dir1).hitSphere(t1.grabbedSpheroid);
//print2d("t1", center_x + "," + center_y, 100, 100); //print2d("t1", center_x + "," + center_y, 100, 100);
//print2d("t2", targetPointC.x + "," + targetPointC.y + "," + targetPointC.z, 100, 120); //print2d("t2", targetPointC.x + "," + targetPointC.y + "," + targetPointC.z, 100, 120);

View File

@ -61,7 +61,7 @@ class Ellipsoid {
* Gets cartesian ECEF from Wgs84 geodetic coordiantes. * Gets cartesian ECEF from Wgs84 geodetic coordiantes.
* @public * @public
* @param {og.LonLat} lonlat - Degrees geodetic coordiantes. * @param {og.LonLat} lonlat - Degrees geodetic coordiantes.
* @returns {og.math.Vector3} - * @returns {og.Vec3} -
*/ */
lonLatToCartesian(lonlat) { lonLatToCartesian(lonlat) {
var latrad = math.RADIANS * lonlat.lat, var latrad = math.RADIANS * lonlat.lat,
@ -84,7 +84,7 @@ class Ellipsoid {
* @param {Number} lon - Longitude. * @param {Number} lon - Longitude.
* @param {Number} lat - Latitude. * @param {Number} lat - Latitude.
* @param {Number} height - Height. * @param {Number} height - Height.
* @returns {og.math.Vector3} - * @returns {og.Vec3} -
*/ */
geodeticToCartesian(lon, lat, height) { geodeticToCartesian(lon, lat, height) {
height = height || 0; height = height || 0;
@ -105,7 +105,7 @@ class Ellipsoid {
/** /**
* Gets Wgs84 geodetic coordiantes from cartesian ECEF. * Gets Wgs84 geodetic coordiantes from cartesian ECEF.
* @public * @public
* @param {og.math.Vector3} cartesian - Cartesian coordinates. * @param {og.Vec3} cartesian - Cartesian coordinates.
* @returns {og.LonLat} - * @returns {og.LonLat} -
*/ */
cartesianToLonLat(cartesian) { cartesianToLonLat(cartesian) {
@ -140,8 +140,8 @@ class Ellipsoid {
/** /**
* Gets ellipsoid surface normal. * Gets ellipsoid surface normal.
* @public * @public
* @param {og.math.Vector3} coord - Spatial coordiantes. * @param {og.Vec3} coord - Spatial coordiantes.
* @returns {og.math.Vector3} - * @returns {og.Vec3} -
*/ */
getSurfaceNormal3v(coord) { getSurfaceNormal3v(coord) {
var r2 = this._invRadii2; var r2 = this._invRadii2;
@ -155,9 +155,9 @@ class Ellipsoid {
/** /**
* Gets the cartesian point on the height over the ellipsoid surface. * Gets the cartesian point on the height over the ellipsoid surface.
* @public * @public
* @param {og.math.Vector3} coord - Spatial ellipsoid coordiantes. * @param {og.Vec3} coord - Spatial ellipsoid coordiantes.
* @param {number} h - Height this spatial coordinates. * @param {number} h - Height this spatial coordinates.
* @return {og.math.Vector3} - * @return {og.Vec3} -
*/ */
getSurfaceHeight3v(coord, h) { getSurfaceHeight3v(coord, h) {
var r2 = this._invRadii2; var r2 = this._invRadii2;
@ -352,9 +352,9 @@ class Ellipsoid {
* Returns ray vector hit ellipsoid coordinates. * Returns ray vector hit ellipsoid coordinates.
* If the ray doesn't hit ellipsoid returns null. * If the ray doesn't hit ellipsoid returns null.
* @public * @public
* @param {og.math.Vector3} origin - Ray origin point. * @param {og.Vec3} origin - Ray origin point.
* @param {og.math.Vector3} direction - Ray direction. * @param {og.Vec3} direction - Ray direction.
* @returns {og.math.Vector3} - * @returns {og.Vec3} -
*/ */
hitRay(origin, direction) { hitRay(origin, direction) {

View File

@ -10,11 +10,11 @@ import * as utils from '../utils/shared.js';
* Base prototype for billboard and label classes. * Base prototype for billboard and label classes.
* @class * @class
* @param {Object} [options] - Options: * @param {Object} [options] - Options:
* @param {og.math.Vector3|Array.<number>} [options.position] - Billboard spatial position. * @param {og.Vec3|Array.<number>} [options.position] - Billboard spatial position.
* @param {number} [options.rotation] - Screen angle rotaion. * @param {number} [options.rotation] - Screen angle rotaion.
* @param {og.math.Vector4|string|Array.<number>} [options.color] - Billboard color. * @param {og.Vec4|string|Array.<number>} [options.color] - Billboard color.
* @param {og.math.Vector3|Array.<number>} [options.alignedAxis] - Billboard aligned vector. * @param {og.Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
* @param {og.math.Vector3|Array.<number>} [options.offset] - Billboard center screen offset. * @param {og.Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
* @param {boolean} [options.visibility] - Visibility. * @param {boolean} [options.visibility] - Visibility.
*/ */
class BaseBillboard { class BaseBillboard {
@ -32,7 +32,7 @@ class BaseBillboard {
/** /**
* Billboard center cartesian position. * Billboard center cartesian position.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._position = utils.createVector3(options.position); this._position = utils.createVector3(options.position);
@ -46,14 +46,14 @@ class BaseBillboard {
/** /**
* RGBA color. * RGBA color.
* @protected * @protected
* @type {og.math.Vector4} * @type {og.Vec4}
*/ */
this._color = utils.createColorRGBA(options.color); this._color = utils.createColorRGBA(options.color);
/** /**
* Cartesian aligned axis vector. * Cartesian aligned axis vector.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._alignedAxis = utils.createVector3(options.alignedAxis); this._alignedAxis = utils.createVector3(options.alignedAxis);
@ -128,7 +128,7 @@ class BaseBillboard {
/** /**
* Sets billboard position. * Sets billboard position.
* @public * @public
* @param {og.math.Vector3} position - Cartesian coordinates. * @param {og.Vec3} position - Cartesian coordinates.
*/ */
setPosition3v(position) { setPosition3v(position) {
this._position.x = position.x; this._position.x = position.x;
@ -140,7 +140,7 @@ class BaseBillboard {
/** /**
* Returns billboard position. * Returns billboard position.
* @public * @public
* @returns {og.math.Vector3} * @returns {og.Vec3}
*/ */
getPosition() { getPosition() {
return this._position; return this._position;
@ -182,7 +182,7 @@ class BaseBillboard {
/** /**
* Sets screen space offset. * Sets screen space offset.
* @public * @public
* @param {og.math.Vector2} offset - Offset size. * @param {og.Vec2} offset - Offset size.
*/ */
setOffset3v(offset) { setOffset3v(offset) {
this._offset.x = offset.x; this._offset.x = offset.x;
@ -194,7 +194,7 @@ class BaseBillboard {
/** /**
* Returns billboard screen space offset size. * Returns billboard screen space offset size.
* @public * @public
* @returns {og.math.Vector3} * @returns {og.Vec3}
*/ */
getOffset() { getOffset() {
return this._offset; return this._offset;
@ -248,7 +248,7 @@ class BaseBillboard {
/** /**
* Sets RGBA color. Each channel from 0.0 to 1.0. * Sets RGBA color. Each channel from 0.0 to 1.0.
* @public * @public
* @param {og.math.Vector4} color - RGBA vector. * @param {og.Vec4} color - RGBA vector.
*/ */
setColor4v(color) { setColor4v(color) {
this._color.x = color.x; this._color.x = color.x;
@ -270,7 +270,7 @@ class BaseBillboard {
/** /**
* Returns RGBA color. * Returns RGBA color.
* @public * @public
* @returns {og.math.Vector4} * @returns {og.Vec4}
*/ */
getColor() { getColor() {
return this._color; return this._color;
@ -324,7 +324,7 @@ class BaseBillboard {
/** /**
* Returns aligned vector. * Returns aligned vector.
* @public * @public
* @returns {og.math.Vector3} * @returns {og.Vec3}
*/ */
getAlignedAxis() { getAlignedAxis() {
return this._alignedAxis; return this._alignedAxis;
@ -342,7 +342,7 @@ class BaseBillboard {
/** /**
* Sets billboard picking color. * Sets billboard picking color.
* @public * @public
* @param {og.math.Vector3} color - Picking color. * @param {og.Vec3} color - Picking color.
*/ */
setPickingColor3v(color) { setPickingColor3v(color) {
this._handler && this._handler.setPickingColorArr(this._handlerIndex, color); this._handler && this._handler.setPickingColorArr(this._handlerIndex, color);

View File

@ -12,11 +12,11 @@ import { BaseBillboard } from './BaseBillboard.js';
* @class * @class
* @extends {og.BaseBillboard} * @extends {og.BaseBillboard}
* @param {Object} [options] - Options: * @param {Object} [options] - Options:
* @param {og.math.Vector3|Array.<number>} [options.position] - Billboard spatial position. * @param {og.Vec3|Array.<number>} [options.position] - Billboard spatial position.
* @param {number} [options.rotation] - Screen angle rotaion. * @param {number} [options.rotation] - Screen angle rotaion.
* @param {og.math.Vector4|string|Array.<number>} [options.color] - Billboard color. * @param {og.Vec4|string|Array.<number>} [options.color] - Billboard color.
* @param {og.math.Vector3|Array.<number>} [options.alignedAxis] - Billboard aligned vector. * @param {og.Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
* @param {og.math.Vector3|Array.<number>} [options.offset] - Billboard center screen offset. * @param {og.Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
* @param {boolean} [options.visibility] - Visibility. * @param {boolean} [options.visibility] - Visibility.
* @param {string} [options.src] - Billboard image url source. * @param {string} [options.src] - Billboard image url source.
* @param {Image} [options.image] - Billboard image object. * @param {Image} [options.image] - Billboard image object.

View File

@ -25,7 +25,7 @@ import { Vec3 } from '../math/Vec3.js';
* @class * @class
* @param {Object} [options] - Entity options: * @param {Object} [options] - Entity options:
* @param {string} [options.name] - A human readable name to display to users. It does not have to be unique. * @param {string} [options.name] - A human readable name to display to users. It does not have to be unique.
* @param {og.math.Vector3|Array.<number>} [options.cartesian] - Spatial entities like billboard, label, sphere etc. cartesian position. * @param {og.Vec3|Array.<number>} [options.cartesian] - Spatial entities like billboard, label, sphere etc. cartesian position.
* @param {og.LonLat} [options.lonlat] - Geodetic coordiantes for an entities like billboard, label, sphere etc. * @param {og.LonLat} [options.lonlat] - Geodetic coordiantes for an entities like billboard, label, sphere etc.
* @param {boolean} [options.aground] - True for entities that have to be placed on the relief. * @param {boolean} [options.aground] - True for entities that have to be placed on the relief.
* @param {boolean} [options.visibility] - Entity visibility. * @param {boolean} [options.visibility] - Entity visibility.
@ -83,7 +83,7 @@ class Entity {
/** /**
* Entity cartesian position. * Entity cartesian position.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._cartesian = utils.createVector3(options.cartesian); this._cartesian = utils.createVector3(options.cartesian);
@ -146,7 +146,7 @@ class Entity {
/** /**
* Picking color. * Picking color.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._pickingColor = new Vec3(0, 0, 0); this._pickingColor = new Vec3(0, 0, 0);
@ -291,7 +291,7 @@ class Entity {
/** /**
* Sets entity cartesian position. * Sets entity cartesian position.
* @public * @public
* @param {og.math.Vector3} cartesian - Cartesian position in 3d space. * @param {og.Vec3} cartesian - Cartesian position in 3d space.
*/ */
setCartesian3v(cartesian) { setCartesian3v(cartesian) {
this.setCartesian(cartesian.x, cartesian.y, cartesian.z); this.setCartesian(cartesian.x, cartesian.y, cartesian.z);
@ -344,7 +344,7 @@ class Entity {
/** /**
* Sets entity cartesian position without moveentity event dispatching. * Sets entity cartesian position without moveentity event dispatching.
* @protected * @protected
* @param {og.math.Vector3} cartesian - Cartesian position in 3d space. * @param {og.Vec3} cartesian - Cartesian position in 3d space.
*/ */
_setCartesian3vSilent(cartesian) { _setCartesian3vSilent(cartesian) {
@ -415,7 +415,7 @@ class Entity {
/** /**
* Returns carteain position. * Returns carteain position.
* @public * @public
* @returns {og.math.Vector3} - * @returns {og.Vec3} -
*/ */
getCartesian() { getCartesian() {
return this._cartesian; return this._cartesian;

View File

@ -31,11 +31,11 @@ const STR2ALIGN = {
* @class * @class
* @extends {og.BaseBillboard} * @extends {og.BaseBillboard}
* @param {Object} [options] - Label options: * @param {Object} [options] - Label options:
* @param {og.math.Vector3|Array.<number>} [options.position] - Billboard spatial position. * @param {og.Vec3|Array.<number>} [options.position] - Billboard spatial position.
* @param {number} [options.rotation] - Screen angle rotaion. * @param {number} [options.rotation] - Screen angle rotaion.
* @param {og.math.Vector4|string|Array.<number>} [options.color] - Billboard color. * @param {og.Vec4|string|Array.<number>} [options.color] - Billboard color.
* @param {og.math.Vector3|Array.<number>} [options.alignedAxis] - Billboard aligned vector. * @param {og.Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
* @param {og.math.Vector3|Array.<number>} [options.offset] - Billboard center screen offset. * @param {og.Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
* @param {boolean} [options.visibility] - Visibility. * @param {boolean} [options.visibility] - Visibility.
* @param {string} [options.text] - Text string. * @param {string} [options.text] - Text string.
* @param {string} [options.face] - HTML5 font face. * @param {string} [options.face] - HTML5 font face.
@ -43,7 +43,7 @@ const STR2ALIGN = {
* @param {string} [options.style] - HTML5 font style. Example 'normal', 'italic'. * @param {string} [options.style] - HTML5 font style. Example 'normal', 'italic'.
* @param {string} [options.weight] - HTML5 font weight. Example 'normal', 'bold'. * @param {string} [options.weight] - HTML5 font weight. Example 'normal', 'bold'.
* @param {number} [options.outline] - Text outline size. 0 - no outline, 1 - maximum outline. Default 0.58. * @param {number} [options.outline] - Text outline size. 0 - no outline, 1 - maximum outline. Default 0.58.
* @param {og.math.Vector4|string|Array.<number>} [options.outlineColor] - Outline color. * @param {og.Vec4|string|Array.<number>} [options.outlineColor] - Outline color.
* @param {og.Label.ALIGN} [options.align] - Text horizontal align: "left", "right" and "center". * @param {og.Label.ALIGN} [options.align] - Text horizontal align: "left", "right" and "center".
*/ */
class Label extends BaseBillboard { class Label extends BaseBillboard {
@ -97,7 +97,7 @@ class Label extends BaseBillboard {
/** /**
* Label outline color. * Label outline color.
* @private * @private
* @type {og.math.Vector4} * @type {og.Vec4}
*/ */
this._outlineColor = utils.createColorRGBA(options.outlineColor, new Vec4(0.0, 0.0, 0.0, 1.0)); this._outlineColor = utils.createColorRGBA(options.outlineColor, new Vec4(0.0, 0.0, 0.0, 1.0));
@ -288,7 +288,7 @@ class Label extends BaseBillboard {
/** /**
* Sets text outline color. * Sets text outline color.
* @public * @public
* @param {og.math.Vector4} rgba - Color vector. * @param {og.Vec4} rgba - Color vector.
*/ */
setOutlineColor4v(rgba) { setOutlineColor4v(rgba) {
this._outlineColor.x = rgba.x; this._outlineColor.x = rgba.x;
@ -310,7 +310,7 @@ class Label extends BaseBillboard {
/** /**
* Gets outline color vector. * Gets outline color vector.
* @public * @public
* @returns {og.math.Vector4} * @returns {og.Vec4}
*/ */
getOutlineColor() { getOutlineColor() {
return this._outlineColor; return this._outlineColor;

View File

@ -18,7 +18,7 @@ const INDEX_BUFFER = 1;
* @class * @class
* @param {Object} [options] - Polyline options: * @param {Object} [options] - Polyline options:
* @param {number} [options.thickness] - Thickness in screen pixels 1.5 is default. * @param {number} [options.thickness] - Thickness in screen pixels 1.5 is default.
* @param {og.math.Vector4} [options.color] - RGBA color. * @param {og.Vec4} [options.color] - RGBA color.
* @param {Boolean} [options.visibility] - Polyline visibility. True default. * @param {Boolean} [options.visibility] - Polyline visibility. True default.
* @param {Boolean} [options.isClosed] - Closed geometry type identificator. * @param {Boolean} [options.isClosed] - Closed geometry type identificator.
* @param {Array.<Array.<number,number,number>>} [options.pathLonLat] - Polyline geodetic coordinates array. * @param {Array.<Array.<number,number,number>>} [options.pathLonLat] - Polyline geodetic coordinates array.
@ -49,7 +49,7 @@ class Polyline {
/** /**
* Polyline RGBA color. * Polyline RGBA color.
* @public * @public
* @type {og.math.Vector4} * @type {og.Vec4}
*/ */
this.color = utils.createColorRGBA(options.color, new Vec4(1.0, 1.0, 1.0, 1.0)); this.color = utils.createColorRGBA(options.color, new Vec4(1.0, 1.0, 1.0, 1.0));
@ -70,7 +70,7 @@ class Polyline {
/** /**
* Polyline cartesian coordinates. * Polyline cartesian coordinates.
* @private * @private
* @type {Array.<og.math.Vector3>} * @type {Array.<og.Vec3>}
*/ */
this._path3v = []; this._path3v = [];
@ -712,7 +712,7 @@ class Polyline {
/** /**
* Adds a new cartesian point in the end of the path. * Adds a new cartesian point in the end of the path.
* @public * @public
* @param {og.math.Vector3} point3v - New coordinate. * @param {og.Vec3} point3v - New coordinate.
* @param {number} [multiLineIndex=0] - Path part index, first by default. * @param {number} [multiLineIndex=0] - Path part index, first by default.
*/ */
addPoint3v(point3v, multiLineIndex) { addPoint3v(point3v, multiLineIndex) {
@ -774,7 +774,7 @@ class Polyline {
/** /**
* Sets Polyline RGB color. * Sets Polyline RGB color.
* @public * @public
* @param {og.math.Vector3} color - RGB color. * @param {og.Vec3} color - RGB color.
*/ */
setColor3v(color) { setColor3v(color) {
this.color.x = color.x; this.color.x = color.x;
@ -785,7 +785,7 @@ class Polyline {
/** /**
* Sets Polyline RGBA color. * Sets Polyline RGBA color.
* @public * @public
* @param {og.math.Vector4} color - RGBA color. * @param {og.Vec4} color - RGBA color.
*/ */
setColor4v(color) { setColor4v(color) {
this.color.x = color.x; this.color.x = color.x;
@ -913,7 +913,7 @@ class Polyline {
/** /**
* Returns path cartesian coordinates. * Returns path cartesian coordinates.
* @return {Array.<og.math.Vector3>} Polyline path. * @return {Array.<og.Vec3>} Polyline path.
*/ */
getPath3v() { getPath3v() {
return this._path3v; return this._path3v;

View File

@ -12,7 +12,7 @@ import { LonLat } from '../LonLat.js';
/** /**
* BaseGeoImage layer represents square imagery layer that could be an static image, or animated video or webgl buffer object displayed on the globe. * BaseGeoImage layer represents square imagery layer that could be an static image, or animated video or webgl buffer object displayed on the globe.
* @class * @class
* @extends {og.layer.Layer} * @extends {og.Layer}
*/ */
class BaseGeoImage extends Layer { class BaseGeoImage extends Layer {
constructor(name, options) { constructor(name, options) {

View File

@ -32,7 +32,7 @@ const EVENT_NAMES = [
/** /**
* Layer used to rendering each tile as a separate canvas object. * Layer used to rendering each tile as a separate canvas object.
* @class * @class
* @extends {og.layer.Layer} * @extends {og.Layer}
* //TODO: make asynchronous handler. * //TODO: make asynchronous handler.
* @param {String} [name="noname"] - Layer name. * @param {String} [name="noname"] - Layer name.
* @param {Object} options: * @param {Object} options:

View File

@ -30,14 +30,14 @@ export const FADING_FACTOR = 0.33;
* @param {boolean} [options.isBaseLayer=false] - This is a base layer. * @param {boolean} [options.isBaseLayer=false] - This is a base layer.
* @param {boolean} [options.visibility=true] - Layer visibility. * @param {boolean} [options.visibility=true] - Layer visibility.
* @param {og.Extent} [options.extent=[[-180.0, -90.0], [180.0, 90.0]]] - Visible extent. * @param {og.Extent} [options.extent=[[-180.0, -90.0], [180.0, 90.0]]] - Visible extent.
* @param {og.math.Vector3} [options.ambient=[0.1, 0.1, 0.21]] - Ambient RGB color. * @param {og.Vec3} [options.ambient=[0.1, 0.1, 0.21]] - Ambient RGB color.
* @param {og.math.Vector3} [options.diffuse=[1.0, 1.0, 1.0]] - Diffuse RGB color. * @param {og.Vec3} [options.diffuse=[1.0, 1.0, 1.0]] - Diffuse RGB color.
* @param {og.math.Vector3} [options.specular=[0.00025, 0.00015, 0.0001]] - Specular RGB color. * @param {og.Vec3} [options.specular=[0.00025, 0.00015, 0.0001]] - Specular RGB color.
* @param {Number} [options.shininess=100] - Shininess. * @param {Number} [options.shininess=100] - Shininess.
* *
* @fires og.layer.Layer#visibilitychange * @fires og.Layer#visibilitychange
* @fires og.layer.Layer#add * @fires og.Layer#add
* @fires og.layer.Layer#remove * @fires og.Layer#remove
* @fires og.layer.Vector#mousemove * @fires og.layer.Vector#mousemove
* @fires og.layer.Vector#mouseenter * @fires og.layer.Vector#mouseenter
* @fires og.layer.Vector#mouseleave * @fires og.layer.Vector#mouseleave
@ -193,7 +193,7 @@ class Layer {
/** /**
* Layer picking color. Assign when added to the planet. * Layer picking color. Assign when added to the planet.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._pickingColor = new Vec3(); this._pickingColor = new Vec3();
@ -290,7 +290,7 @@ class Layer {
/** /**
* Compares layers instances. * Compares layers instances.
* @public * @public
* @param {og.layer.Layer} layer - Layer instance to compare. * @param {og.Layer} layer - Layer instance to compare.
* @returns {boolean} - Returns true if the layers is the same instance of the input. * @returns {boolean} - Returns true if the layers is the same instance of the input.
*/ */
isEqual(layer) { isEqual(layer) {
@ -337,7 +337,7 @@ class Layer {
/** /**
* Removes from planet. * Removes from planet.
* @public * @public
* @returns {og.layer.Layer} -This layer. * @returns {og.Layer} -This layer.
*/ */
remove() { remove() {
var p = this._planet; var p = this._planet;
@ -572,169 +572,169 @@ class Layer {
const EVENT_NAMES = [ const EVENT_NAMES = [
/** /**
* Triggered when layer visibilty chanched. * Triggered when layer visibilty chanched.
* @event og.layer.Layer#visibilitychange * @event og.Layer#visibilitychange
*/ */
"visibilitychange", "visibilitychange",
/** /**
* Triggered when layer has added to the planet. * Triggered when layer has added to the planet.
* @event og.layer.Layer#add * @event og.Layer#add
*/ */
"add", "add",
/** /**
* Triggered when layer has removed from the planet. * Triggered when layer has removed from the planet.
* @event og.layer.Layer#remove * @event og.Layer#remove
*/ */
"remove", "remove",
/** /**
* Triggered when mouse moves over the layer. * Triggered when mouse moves over the layer.
* @event og.layer.Layer#mousemove * @event og.Layer#mousemove
*/ */
"mousemove", "mousemove",
/** /**
* Triggered when mouse has entered over the layer. * Triggered when mouse has entered over the layer.
* @event og.layer.Layer#mouseenter * @event og.Layer#mouseenter
*/ */
"mouseenter", "mouseenter",
/** /**
* Triggered when mouse leaves the layer. * Triggered when mouse leaves the layer.
* @event og.layer.Layer#mouseenter * @event og.Layer#mouseenter
*/ */
"mouseleave", "mouseleave",
/** /**
* Mouse left button clicked. * Mouse left button clicked.
* @event og.layer.Layer#lclick * @event og.Layer#lclick
*/ */
"lclick", "lclick",
/** /**
* Mouse right button clicked. * Mouse right button clicked.
* @event og.layer.Layer#rclick * @event og.Layer#rclick
*/ */
"rclick", "rclick",
/** /**
* Mouse right button clicked. * Mouse right button clicked.
* @event og.layer.Layer#mclick * @event og.Layer#mclick
*/ */
"mclick", "mclick",
/** /**
* Mouse left button double click. * Mouse left button double click.
* @event og.layer.Layer#ldblclick * @event og.Layer#ldblclick
*/ */
"ldblclick", "ldblclick",
/** /**
* Mouse right button double click. * Mouse right button double click.
* @event og.layer.Layer#rdblclick * @event og.Layer#rdblclick
*/ */
"rdblclick", "rdblclick",
/** /**
* Mouse middle button double click. * Mouse middle button double click.
* @event og.layer.Layer#mdblclick * @event og.Layer#mdblclick
*/ */
"mdblclick", "mdblclick",
/** /**
* Mouse left button up(stop pressing). * Mouse left button up(stop pressing).
* @event og.layer.Layer#lup * @event og.Layer#lup
*/ */
"lup", "lup",
/** /**
* Mouse right button up(stop pressing). * Mouse right button up(stop pressing).
* @event og.layer.Layer#rup * @event og.Layer#rup
*/ */
"rup", "rup",
/** /**
* Mouse middle button up(stop pressing). * Mouse middle button up(stop pressing).
* @event og.layer.Layer#mup * @event og.Layer#mup
*/ */
"mup", "mup",
/** /**
* Mouse left button is just pressed down(start pressing). * Mouse left button is just pressed down(start pressing).
* @event og.layer.Layer#ldown * @event og.Layer#ldown
*/ */
"ldown", "ldown",
/** /**
* Mouse right button is just pressed down(start pressing). * Mouse right button is just pressed down(start pressing).
* @event og.layer.Layer#rdown * @event og.Layer#rdown
*/ */
"rdown", "rdown",
/** /**
* Mouse middle button is just pressed down(start pressing). * Mouse middle button is just pressed down(start pressing).
* @event og.layer.Layer#mdown * @event og.Layer#mdown
*/ */
"mdown", "mdown",
/** /**
* Mouse left button is pressing. * Mouse left button is pressing.
* @event og.layer.Layer#lhold * @event og.Layer#lhold
*/ */
"lhold", "lhold",
/** /**
* Mouse right button is pressing. * Mouse right button is pressing.
* @event og.layer.Layer#rhold * @event og.Layer#rhold
*/ */
"rhold", "rhold",
/** /**
* Mouse middle button is pressing. * Mouse middle button is pressing.
* @event og.layer.Layer#mhold * @event og.Layer#mhold
*/ */
"mhold", "mhold",
/** /**
* Mouse wheel is rotated. * Mouse wheel is rotated.
* @event og.layer.Layer#mousewheel * @event og.Layer#mousewheel
*/ */
"mousewheel", "mousewheel",
/** /**
* Triggered when touching moves over the layer. * Triggered when touching moves over the layer.
* @event og.layer.Layer#touchmove * @event og.Layer#touchmove
*/ */
"touchmove", "touchmove",
/** /**
* Triggered when layer begins to touch. * Triggered when layer begins to touch.
* @event og.layer.Layer#touchstart * @event og.Layer#touchstart
*/ */
"touchstart", "touchstart",
/** /**
* Triggered when layer has finished touching. * Triggered when layer has finished touching.
* @event og.layer.Layer#touchend * @event og.Layer#touchend
*/ */
"touchend", "touchend",
/** /**
* Triggered layer has double touched. * Triggered layer has double touched.
* @event og.layer.Layer#doubletouch * @event og.Layer#doubletouch
*/ */
"doubletouch", "doubletouch",
/** /**
* Triggered when touching leaves layer borders. * Triggered when touching leaves layer borders.
* @event og.layer.Layer#touchleave * @event og.Layer#touchleave
*/ */
"touchleave", "touchleave",
/** /**
* Triggered when touch enters over the layer. * Triggered when touch enters over the layer.
* @event og.layer.Layer#touchenter * @event og.Layer#touchenter
*/ */
"touchenter" "touchenter"
]; ];

View File

@ -42,7 +42,7 @@ function _entitiesConstructor(entities) {
* Vector layer represents alternative entities store. Used for geospatial data rendering like * Vector layer represents alternative entities store. Used for geospatial data rendering like
* points, lines, polygons, geometry objects etc. * points, lines, polygons, geometry objects etc.
* @class * @class
* @extends {og.layer.Layer} * @extends {og.Layer}
* @param {string} [name="noname"] - Layer name. * @param {string} [name="noname"] - Layer name.
* @param {Object} [options] - Layer options: * @param {Object} [options] - Layer options:
* @param {number} [options.minZoom=0] - Minimal visible zoom. 0 is default * @param {number} [options.minZoom=0] - Minimal visible zoom. 0 is default
@ -573,24 +573,24 @@ class Vector extends Layer {
var visibleExtent = this._planet.getViewExtent(); var visibleExtent = this._planet.getViewExtent();
var e = this._polylineEntityCollection._entities; var e = this._polylineEntityCollection._entities;
var e_i = e.length; var e_i = e.length;
let res = new Vec3();
while (e_i--) { while (e_i--) {
var p = e[e_i].polyline; var p = e[e_i].polyline;
if (visibleExtent.overlaps(p._extent)) { if (visibleExtent.overlaps(p._extent)) {
var coords = p._pathLonLatMerc; let coords = p._pathLonLatMerc,
var c_j = coords.length; c_j = coords.length;
while (c_j--) { while (c_j--) {
var c_j_h = coords[c_j].length; var c_j_h = coords[c_j].length;
while (c_j_h--) { while (c_j_h--) {
var ll = coords[c_j][c_j_h]; let ll = coords[c_j][c_j_h],
var n_k = nodes.length; n_k = nodes.length;
while (n_k--) { while (n_k--) {
var seg = nodes[n_k].segment; var seg = nodes[n_k].segment;
if (seg._extent.isInside(ll)) { if (seg._extent.isInside(ll)) {
var cart = p._path3v[c_j][c_j_h]; let cart = p._path3v[c_j][c_j_h];
var res = new Vec3();
seg.getTerrainPoint(res, cart, ll); seg.getTerrainPoint(res, cart, ll);
p.setPoint3v(res.addA(res.normal().scale(rtg && p.altitude || 1.0)), c_j_h, c_j, true); p.setPoint3v(res.addA(res.normal().scale(rtg && p.altitude || 0.0)), c_j_h, c_j, true);
break; break;
} }
} }
@ -782,7 +782,6 @@ class Vector extends Layer {
update() { update() {
this._geometryHandler.update(); this._geometryHandler.update();
this.collectVisibleCollections(this._planet._frustumEntityCollections);
this.events.dispatch(this.events.draw, this); this.events.dispatch(this.events.draw, this);
} }
}; };

View File

@ -15,7 +15,7 @@ import { RENDERING } from '../quadTree/quadTree.js';
/** /**
* Represents an imagery tiles source provider. * Represents an imagery tiles source provider.
* @class * @class
* @extends {og.layer.Layer} * @extends {og.Layer}
* @param {string} name - Layer name. * @param {string} name - Layer name.
* @param {Object} options: * @param {Object} options:
* @param {number} [options.opacity=1.0] - Layer opacity. * @param {number} [options.opacity=1.0] - Layer opacity.

View File

@ -11,10 +11,10 @@ import { Vec3 } from '../math/Vec3.js';
* @class * @class
* @param {string} [name] - Light source name. * @param {string} [name] - Light source name.
* @param {Object} [params] - Light parameters: * @param {Object} [params] - Light parameters:
* @param {og.math.Vector3} [params.position] - Light source position if it is a point light, otherwise it is a light direction vector. * @param {og.Vec3} [params.position] - Light source position if it is a point light, otherwise it is a light direction vector.
* @param {og.math.Vector3} [params.ambient] - Ambient RGB color. * @param {og.Vec3} [params.ambient] - Ambient RGB color.
* @param {og.math.Vector3} [params.diffuse] - Diffuse RGB color. * @param {og.Vec3} [params.diffuse] - Diffuse RGB color.
* @param {og.math.Vector3} [params.specular] - Specular RGB color. * @param {og.Vec3} [params.specular] - Specular RGB color.
* @param {number} [params.shininess] - Specular shininess. * @param {number} [params.shininess] - Specular shininess.
*/ */
class LightSource { class LightSource {
@ -49,7 +49,7 @@ class LightSource {
/** /**
* Light position. * Light position.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._position = params.position || new Vec3(); this._position = params.position || new Vec3();
@ -63,21 +63,21 @@ class LightSource {
/** /**
* Ambient color. * Ambient color.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._ambient = params.ambient || new Vec3(); this._ambient = params.ambient || new Vec3();
/** /**
* Diffuse color. * Diffuse color.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._diffuse = params.diffuse || new Vec3(0.8, 0.8, 0.8); this._diffuse = params.diffuse || new Vec3(0.8, 0.8, 0.8);
/** /**
* Specular color. * Specular color.
* @protected * @protected
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this._specular = params.specular || new Vec3(0.18, 0.18, 0.18); this._specular = params.specular || new Vec3(0.18, 0.18, 0.18);
@ -158,7 +158,7 @@ class LightSource {
/** /**
* Set light source position, or if it is a directional type sets light direction vector. * Set light source position, or if it is a directional type sets light direction vector.
* @public * @public
* @param {og.math.Vector3} position - Light position or direction vector. * @param {og.Vec3} position - Light position or direction vector.
* @returns {og.LightSource} * @returns {og.LightSource}
*/ */
setPosition(position) { setPosition(position) {
@ -171,7 +171,7 @@ class LightSource {
/** /**
* Returns light source position, or if it is a directional type sets light direction vector. * Returns light source position, or if it is a directional type sets light direction vector.
* @public * @public
* @returns {og.math.Vector3} - Light source position/direction. * @returns {og.Vec3} - Light source position/direction.
*/ */
getPosition() { getPosition() {
return this._position.clone(); return this._position.clone();
@ -180,7 +180,7 @@ class LightSource {
/** /**
* Set ambient color. * Set ambient color.
* @public * @public
* @param {og.math.Vector3} rgb - Ambient color. * @param {og.Vec3} rgb - Ambient color.
* @returns {og.LightSource} * @returns {og.LightSource}
*/ */
setAmbient(rgb) { setAmbient(rgb) {
@ -200,7 +200,7 @@ class LightSource {
/** /**
* Set diffuse color. * Set diffuse color.
* @public * @public
* @param {og.math.Vector3} rgb - Diffuse color. * @param {og.Vec3} rgb - Diffuse color.
* @returns {og.LightSource} * @returns {og.LightSource}
*/ */
setDiffuse(rgb) { setDiffuse(rgb) {
@ -220,7 +220,7 @@ class LightSource {
/** /**
* Set specular color. * Set specular color.
* @public * @public
* @param {og.math.Vector3} rgb - Specular color. * @param {og.Vec3} rgb - Specular color.
* @returns {og.LightSource} * @returns {og.LightSource}
*/ */
setSpecular(rgb) { setSpecular(rgb) {

View File

@ -285,11 +285,11 @@ export function lerp(t, h1, h0) {
* Performs a 3D bezier interpolation. * Performs a 3D bezier interpolation.
* @function * @function
* @param {number} t - Interpolation value. * @param {number} t - Interpolation value.
* @param {og.math.Vector3} p0 - First control point. * @param {og.Vec3} p0 - First control point.
* @param {og.math.Vector3} p1 - Second control point. * @param {og.Vec3} p1 - Second control point.
* @param {og.math.Vector3} p2 - Third control point. * @param {og.Vec3} p2 - Third control point.
* @param {og.math.Vector3} p3 - Fourth control point. * @param {og.Vec3} p3 - Fourth control point.
* @returns {og.math.Vector3} - * @returns {og.Vec3} -
*/ */
export function bezier(t, p0, p1, p2, p3) { export function bezier(t, p0, p1, p2, p3) {
var u = 1 - t; var u = 1 - t;

View File

@ -24,7 +24,7 @@ const Mat3 = function () {
/** /**
* Mat3 factory. * Mat3 factory.
* @static * @static
* @return {og.math.Mat3} * @return {og.Mat3}
*/ */
export function mat3() { export function mat3() {
@ -35,7 +35,7 @@ export function mat3() {
* Sets column-major order array matrix. * Sets column-major order array matrix.
* @public * @public
* @param {Array.<number>} m - Matrix array. * @param {Array.<number>} m - Matrix array.
* @returns {og.math.Mat3} * @returns {og.Mat3}
*/ */
Mat3.prototype.set = function (m) { Mat3.prototype.set = function (m) {
this._m[0] = m[0]; this._m[0] = m[0];
@ -53,7 +53,7 @@ Mat3.prototype.set = function (m) {
/** /**
* Duplicates a Mat3 instance. * Duplicates a Mat3 instance.
* @public * @public
* @returns {og.math.Mat3} * @returns {og.Mat3}
*/ */
Mat3.prototype.clone = function () { Mat3.prototype.clone = function () {
var res = new Mat3(); var res = new Mat3();
@ -64,8 +64,8 @@ Mat3.prototype.clone = function () {
/** /**
* Copy matrix. * Copy matrix.
* @public * @public
* @param {og.math.Mat3} a - Matrix to copy. * @param {og.Mat3} a - Matrix to copy.
* @returns {og.math.Mat3} * @returns {og.Mat3}
*/ */
Mat3.prototype.copy = function (a) { Mat3.prototype.copy = function (a) {
return this.set(a._m); return this.set(a._m);
@ -74,7 +74,7 @@ Mat3.prototype.copy = function (a) {
/** /**
* Creates trasposed matrix from the current. * Creates trasposed matrix from the current.
* @public * @public
* @returns {og.math.Mat3} * @returns {og.Mat3}
*/ */
Mat3.prototype.transposeTo = function () { Mat3.prototype.transposeTo = function () {
var res = new Mat3(); var res = new Mat3();
@ -88,7 +88,7 @@ Mat3.prototype.transposeTo = function () {
/** /**
* Sets matrix to identity. * Sets matrix to identity.
* @public * @public
* @returns {og.math.Mat3} * @returns {og.Mat3}
*/ */
Mat3.prototype.setIdentity = function () { Mat3.prototype.setIdentity = function () {
this._m[0] = 1; this._m[1] = 0; this._m[2] = 0; this._m[0] = 1; this._m[1] = 0; this._m[2] = 0;
@ -100,8 +100,8 @@ Mat3.prototype.setIdentity = function () {
/** /**
* Multiply to 3d vector. * Multiply to 3d vector.
* @public * @public
* @params {og.math.Vector3} p - 3d vector. * @params {og.Vec3} p - 3d vector.
* @returns {og.math.Vector3} * @returns {og.Vec3}
*/ */
Mat3.prototype.mulVec = function (p) { Mat3.prototype.mulVec = function (p) {
var d = p.x, e = p.y, g = p.z; var d = p.x, e = p.y, g = p.z;
@ -116,7 +116,7 @@ Mat3.prototype.mulVec = function (p) {
/** /**
* Converts to 4x4 matrix. * Converts to 4x4 matrix.
* @public * @public
* @returns {og.math.Matrix4} * @returns {og.Mat4}
*/ */
Mat3.prototype.toMatrix4 = function () { Mat3.prototype.toMatrix4 = function () {
var res = new Mat4(); var res = new Mat4();

View File

@ -56,16 +56,16 @@ const Mat4 = function () {
/** /**
* Mat4 factory. * Mat4 factory.
* @static * @static
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
export function mat4() { export function mat4() {
return new og.math.Mat4(); return new og.Mat4();
}; };
/** /**
* Returns identity matrix instance. * Returns identity matrix instance.
* @static * @static
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.identity = function () { Mat4.identity = function () {
var res = new Mat4(); var res = new Mat4();
@ -80,7 +80,7 @@ Mat4.identity = function () {
* Sets column-major order array matrix. * Sets column-major order array matrix.
* @public * @public
* @param {Array.<number>} m - Matrix array. * @param {Array.<number>} m - Matrix array.
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.set = function (m) { Mat4.prototype.set = function (m) {
this._m[0] = m[0]; this._m[0] = m[0];
@ -105,7 +105,7 @@ Mat4.prototype.set = function (m) {
/** /**
* Duplicates a Matrix3 instance. * Duplicates a Matrix3 instance.
* @public * @public
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.clone = function () { Mat4.prototype.clone = function () {
var res = new Mat4(); var res = new Mat4();
@ -116,8 +116,8 @@ Mat4.prototype.clone = function () {
/** /**
* Copy matrix. * Copy matrix.
* @public * @public
* @param {og.math.Matrix3} a - Matrix to copy. * @param {og.Mat3} a - Matrix to copy.
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.copy = function (a) { Mat4.prototype.copy = function (a) {
this.set(a._m); this.set(a._m);
@ -126,7 +126,7 @@ Mat4.prototype.copy = function (a) {
/** /**
* Converts to 3x3 matrix. * Converts to 3x3 matrix.
* @public * @public
* @returns {og.math.Matrix3} * @returns {og.Mat3}
*/ */
Mat4.prototype.toMatrix3 = function () { Mat4.prototype.toMatrix3 = function () {
var res = new Mat3(); var res = new Mat3();
@ -147,8 +147,8 @@ Mat4.prototype.toMatrix3 = function () {
/** /**
* Multiply to 3d vector. * Multiply to 3d vector.
* @public * @public
* @param {og.math.Vector3} p - 3d vector. * @param {og.Vec3} p - 3d vector.
* @returns {og.math.Vector3} * @returns {og.Vec3}
*/ */
Mat4.prototype.mulVec3 = function (p) { Mat4.prototype.mulVec3 = function (p) {
var d = p.x, e = p.y, g = p.z; var d = p.x, e = p.y, g = p.z;
@ -162,8 +162,8 @@ Mat4.prototype.mulVec3 = function (p) {
/** /**
* Multiply to 4d vector. * Multiply to 4d vector.
* @public * @public
* @param {og.math.Vector4} p - 4d vector. * @param {og.Vec4} p - 4d vector.
* @returns {og.math.Vector4} * @returns {og.Vec4}
*/ */
Mat4.prototype.mulVec4 = function (p) { Mat4.prototype.mulVec4 = function (p) {
var d = p.x, e = p.y, g = p.z, f = p.w; var d = p.x, e = p.y, g = p.z, f = p.w;
@ -178,7 +178,7 @@ Mat4.prototype.mulVec4 = function (p) {
/** /**
* Creates an inversed 3x3 matrix of the current. * Creates an inversed 3x3 matrix of the current.
* @public * @public
* @returns {og.math.Matrix3} * @returns {og.Mat3}
*/ */
Mat4.prototype.toInverseMatrix3 = function () { Mat4.prototype.toInverseMatrix3 = function () {
var a = this._m; var a = this._m;
@ -209,7 +209,7 @@ Mat4.prototype.toInverseMatrix3 = function () {
/** /**
* Creates an inversed matrix of the current. * Creates an inversed matrix of the current.
* @public * @public
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.inverseTo = function () { Mat4.prototype.inverseTo = function () {
var c = this._m[0], d = this._m[1], e = this._m[2], g = this._m[3], var c = this._m[0], d = this._m[1], e = this._m[2], g = this._m[3],
@ -241,7 +241,7 @@ Mat4.prototype.inverseTo = function () {
/** /**
* Creates a trasposed matrix of the current. * Creates a trasposed matrix of the current.
* @public * @public
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.transposeTo = function () { Mat4.prototype.transposeTo = function () {
var res = new Mat4(); var res = new Mat4();
@ -255,7 +255,7 @@ Mat4.prototype.transposeTo = function () {
/** /**
* Sets matrix to identity. * Sets matrix to identity.
* @public * @public
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.setIdentity = function () { Mat4.prototype.setIdentity = function () {
this._m[0] = 1; this._m[1] = 0; this._m[2] = 0; this._m[3] = 0; this._m[0] = 1; this._m[1] = 0; this._m[2] = 0; this._m[3] = 0;
@ -268,8 +268,8 @@ Mat4.prototype.setIdentity = function () {
/** /**
* Computes the product of two matrices. * Computes the product of two matrices.
* @public * @public
* @param {og.math.Mat4} mx - Matrix to multiply. * @param {og.Mat4} mx - Matrix to multiply.
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.mul = function (mx) { Mat4.prototype.mul = function (mx) {
let d = this._m[0], e = this._m[1], g = this._m[2], f = this._m[3], let d = this._m[0], e = this._m[1], g = this._m[2], f = this._m[3],
@ -293,8 +293,8 @@ Mat4.prototype.mul = function (mx) {
/** /**
* Add translation vector to the current matrix. * Add translation vector to the current matrix.
* @public * @public
* @param {og.math.Vector3} v - Translate vector. * @param {og.Vec3} v - Translate vector.
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.translate = function (v) { Mat4.prototype.translate = function (v) {
var d = v.x, e = v.y, b = v.z; var d = v.x, e = v.y, b = v.z;
@ -309,8 +309,8 @@ Mat4.prototype.translate = function (v) {
/** /**
* Sets translation matrix to the position. * Sets translation matrix to the position.
* @public * @public
* @param {og.math.Vector3} v - Translate to position. * @param {og.Vec3} v - Translate to position.
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.translateToPosition = function (v) { Mat4.prototype.translateToPosition = function (v) {
var a = this._m; var a = this._m;
@ -323,9 +323,9 @@ Mat4.prototype.translateToPosition = function (v) {
/** /**
* Rotate currrent matrix around the aligned axis and angle. * Rotate currrent matrix around the aligned axis and angle.
* @public * @public
* @param {og.math.Vector3} u - Aligned axis. * @param {og.Vec3} u - Aligned axis.
* @param {number} angle - Aligned axis angle in radians. * @param {number} angle - Aligned axis angle in radians.
* @returns {og.math.Mat4} * @returns {og.Mat4}
* @todo: OPTIMIZE: reveal multiplication * @todo: OPTIMIZE: reveal multiplication
*/ */
Mat4.prototype.rotate = function (u, angle) { Mat4.prototype.rotate = function (u, angle) {
@ -343,9 +343,9 @@ Mat4.prototype.rotate = function (u, angle) {
/** /**
* Sets current rotation matrix around the aligned axis and angle. * Sets current rotation matrix around the aligned axis and angle.
* @public * @public
* @param {og.math.Vector3} u - Aligned axis. * @param {og.Vec3} u - Aligned axis.
* @param {number} angle - Aligned axis angle in radians. * @param {number} angle - Aligned axis angle in radians.
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.setRotation = function (u, angle) { Mat4.prototype.setRotation = function (u, angle) {
var c = Math.cos(angle), var c = Math.cos(angle),
@ -361,9 +361,9 @@ Mat4.prototype.setRotation = function (u, angle) {
/** /**
* Gets the rotation matrix from one vector to another. * Gets the rotation matrix from one vector to another.
* @public * @public
* @param {og.math.Vector3} a - Firtst vector. * @param {og.Vec3} a - Firtst vector.
* @param {og.math.Vector3} b - Second vector. * @param {og.Vec3} b - Second vector.
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.rotateBetweenVectors = function (a, b) { Mat4.prototype.rotateBetweenVectors = function (a, b) {
var q = Quat.getRotationBetweenVectors(a, b); var q = Quat.getRotationBetweenVectors(a, b);
@ -373,8 +373,8 @@ Mat4.prototype.rotateBetweenVectors = function (a, b) {
/** /**
* Scale current matrix to the vector values. * Scale current matrix to the vector values.
* @public * @public
* @param {og.math.Vector3} v - Scale vector. * @param {og.Vec3} v - Scale vector.
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.scale = function (v) { Mat4.prototype.scale = function (v) {
var mx = this._m; var mx = this._m;
@ -394,7 +394,7 @@ Mat4.prototype.scale = function (v) {
* @param {number} top * @param {number} top
* @param {number} near * @param {number} near
* @param {number} far * @param {number} far
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.setFrustum = function (left, right, bottom, top, near, far) { Mat4.prototype.setFrustum = function (left, right, bottom, top, near, far) {
@ -432,7 +432,7 @@ Mat4.prototype.setFrustum = function (left, right, bottom, top, near, far) {
* @param {number} aspect - Screen aspect ratio. * @param {number} aspect - Screen aspect ratio.
* @param {number} near - Near clip plane. * @param {number} near - Near clip plane.
* @param {number} far - Far clip plane. * @param {number} far - Far clip plane.
* @retuns {og.math.Mat4} * @retuns {og.Mat4}
*/ */
Mat4.prototype.setPerspective = function (angle, aspect, near, far) { Mat4.prototype.setPerspective = function (angle, aspect, near, far) {
angle = near * Math.tan(angle * Math.PI / 360); angle = near * Math.tan(angle * Math.PI / 360);
@ -449,7 +449,7 @@ Mat4.prototype.setPerspective = function (angle, aspect, near, far) {
* @param {number} top * @param {number} top
* @param {number} near * @param {number} near
* @param {number} far * @param {number} far
* @retuns {og.math.Mat4} * @retuns {og.Mat4}
*/ */
Mat4.prototype.setOrtho = function (left, right, bottom, top, near, far) { Mat4.prototype.setOrtho = function (left, right, bottom, top, near, far) {
this.left = left; this.left = left;
@ -489,7 +489,7 @@ Mat4.prototype.setOrtho = function (left, right, bottom, top, near, far) {
* @param {number} ax - Rotation angle in radians arond X axis. * @param {number} ax - Rotation angle in radians arond X axis.
* @param {number} ay - Rotation angle in radians arond Y axis. * @param {number} ay - Rotation angle in radians arond Y axis.
* @param {number} az - Rotation angle in radians arond Z axis. * @param {number} az - Rotation angle in radians arond Z axis.
* @returns {og.math.Mat4} * @returns {og.Mat4}
*/ */
Mat4.prototype.eulerToMatrix = function (ax, ay, az) { Mat4.prototype.eulerToMatrix = function (ax, ay, az) {
var a = Math.cos(ax), var a = Math.cos(ax),

View File

@ -58,7 +58,7 @@ const Quat = function (x, y, z, w) {
* @param {Number} [y=0.0] The Y component. * @param {Number} [y=0.0] The Y component.
* @param {Number} [z=0.0] The Z component. * @param {Number} [z=0.0] The Z component.
* @param {Number} [w=0.0] The W component. * @param {Number} [w=0.0] The W component.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
export function quat(x, y, z, w) { export function quat(x, y, z, w) {
return new Quat(x, y, z, w); return new Quat(x, y, z, w);
@ -67,7 +67,7 @@ export function quat(x, y, z, w) {
/** /**
* Identity Quat. * Identity Quat.
* @const * @const
* @type {og.math.Quat} * @type {og.Quat}
*/ */
Quat.IDENTITY = new Quat(0.0, 0.0, 0.0, 1.0); Quat.IDENTITY = new Quat(0.0, 0.0, 0.0, 1.0);
@ -75,7 +75,7 @@ Quat.IDENTITY = new Quat(0.0, 0.0, 0.0, 1.0);
* Returns a Quat represents rotation around X axis. * Returns a Quat represents rotation around X axis.
* @static * @static
* @param {number} a - The angle in radians to rotate around the axis. * @param {number} a - The angle in radians to rotate around the axis.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.xRotation = function (a) { Quat.xRotation = function (a) {
a *= 0.5; a *= 0.5;
@ -86,7 +86,7 @@ Quat.xRotation = function (a) {
* Returns a Quat represents rotation around Y axis. * Returns a Quat represents rotation around Y axis.
* @static * @static
* @param {number} a - The angle in radians to rotate around the axis. * @param {number} a - The angle in radians to rotate around the axis.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.yRotation = function (a) { Quat.yRotation = function (a) {
a *= 0.5; a *= 0.5;
@ -97,7 +97,7 @@ Quat.yRotation = function (a) {
* Returns a Quat represents rotation around Z axis. * Returns a Quat represents rotation around Z axis.
* @static * @static
* @param {number} a - The angle in radians to rotate around the axis. * @param {number} a - The angle in radians to rotate around the axis.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.zRotation = function (a) { Quat.zRotation = function (a) {
a *= 0.5; a *= 0.5;
@ -107,9 +107,9 @@ Quat.zRotation = function (a) {
/** /**
* Computes a Quat representing a rotation around an axis. * Computes a Quat representing a rotation around an axis.
* @static * @static
* @param {og.math.Vector3} axis - The axis of rotation. * @param {og.Vec3} axis - The axis of rotation.
* @param {number} angle The angle in radians to rotate around the axis. * @param {number} angle The angle in radians to rotate around the axis.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.axisAngleToQuat = function (axis, angle) { Quat.axisAngleToQuat = function (axis, angle) {
var res = new Quat(); var res = new Quat();
@ -123,9 +123,9 @@ Quat.axisAngleToQuat = function (axis, angle) {
/** /**
* Computes a rotation from the given heading and up vector. * Computes a rotation from the given heading and up vector.
* @static * @static
* @param {og.math.Vector3} target - Heading target coordinates. * @param {og.Vec3} target - Heading target coordinates.
* @param {og.math.Vector3} up - Up vector. * @param {og.Vec3} up - Up vector.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.getLookAtTargetUp = function (target, up) { Quat.getLookAtTargetUp = function (target, up) {
var forward = target.normal(); var forward = target.normal();
@ -143,9 +143,9 @@ Quat.getLookAtTargetUp = function (target, up) {
/** /**
* Computes a Quat from from source point heading to the destination point. * Computes a Quat from from source point heading to the destination point.
* @static * @static
* @param {og.math.Vector3} sourcePoint - Source coordinate. * @param {og.Vec3} sourcePoint - Source coordinate.
* @param {og.math.Vector3} destPoint - Destination coordinate. * @param {og.Vec3} destPoint - Destination coordinate.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.getLookAtSourceDest = function (sourcePoint, destPoint) { Quat.getLookAtSourceDest = function (sourcePoint, destPoint) {
var forwardVector = destPoint.subA(sourcePoint).normalize(); var forwardVector = destPoint.subA(sourcePoint).normalize();
@ -164,9 +164,9 @@ Quat.getLookAtSourceDest = function (sourcePoint, destPoint) {
/** /**
* Compute rotation between two vectors. * Compute rotation between two vectors.
* @static * @static
* @param {og.math.Vector3} u - First vector. * @param {og.Vec3} u - First vector.
* @param {og.math.Vector3} v - Second vector. * @param {og.Vec3} v - Second vector.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.getRotationBetweenVectors = function (u, v) { Quat.getRotationBetweenVectors = function (u, v) {
var w = u.cross(v); var w = u.cross(v);
@ -177,10 +177,10 @@ Quat.getRotationBetweenVectors = function (u, v) {
/** /**
* Compute rotation between two vectors with around vector up for exactly opposite vectors. If vectors exaclty in the same direction than returns identity Quat. * Compute rotation between two vectors with around vector up for exactly opposite vectors. If vectors exaclty in the same direction than returns identity Quat.
* @static * @static
* @param {og.math.Vector3} source - First vector. * @param {og.Vec3} source - First vector.
* @param {og.math.Vector3} dest - Second vector. * @param {og.Vec3} dest - Second vector.
* @param {og.math.Vector3} up - Up vector. * @param {og.Vec3} up - Up vector.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.getRotationBetweenVectorsUp = function (source, dest, up) { Quat.getRotationBetweenVectorsUp = function (source, dest, up) {
var dot = source.dot(dest); var dot = source.dot(dest);
@ -202,7 +202,7 @@ Quat.getRotationBetweenVectorsUp = function (source, dest, up) {
/** /**
* Clear Quat. Sets zeroes. * Clear Quat. Sets zeroes.
* @public * @public
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.clear = function () { Quat.prototype.clear = function () {
this.x = this.y = this.z = this.w = 0; this.x = this.y = this.z = this.w = 0;
@ -216,7 +216,7 @@ Quat.prototype.clear = function () {
* @param {Number} [y=0.0] The Y component. * @param {Number} [y=0.0] The Y component.
* @param {Number} [z=0.0] The Z component. * @param {Number} [z=0.0] The Z component.
* @param {Number} [w=0.0] The W component. * @param {Number} [w=0.0] The W component.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.set = function (x, y, z, w) { Quat.prototype.set = function (x, y, z, w) {
this.x = x; this.x = x;
@ -229,8 +229,8 @@ Quat.prototype.set = function (x, y, z, w) {
/** /**
* Copy Quat values. * Copy Quat values.
* @public * @public
* @param {og.math.Quat} q - Copy Quat. * @param {og.Quat} q - Copy Quat.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.copy = function (q) { Quat.prototype.copy = function (q) {
this.x = q.x; this.x = q.x;
@ -243,7 +243,7 @@ Quat.prototype.copy = function (q) {
/** /**
* Set current Quat instance to identity Quat. * Set current Quat instance to identity Quat.
* @public * @public
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.setIdentity = function () { Quat.prototype.setIdentity = function () {
this.x = 0.0; this.x = 0.0;
@ -256,7 +256,7 @@ Quat.prototype.setIdentity = function () {
/** /**
* Duplicates a Quat instance. * Duplicates a Quat instance.
* @public * @public
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.clone = function () { Quat.prototype.clone = function () {
return new Quat(this.x, this.y, this.z, this.w); return new Quat(this.x, this.y, this.z, this.w);
@ -265,8 +265,8 @@ Quat.prototype.clone = function () {
/** /**
* Computes the componentwise sum of two Quats. * Computes the componentwise sum of two Quats.
* @public * @public
* @param {og.math.Quat} q - Quat to add. * @param {og.Quat} q - Quat to add.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.add = function (q) { Quat.prototype.add = function (q) {
return new Quat(this.x + q.x, this.y + q.y, this.z + q.z, this.w + q.w); return new Quat(this.x + q.x, this.y + q.y, this.z + q.z, this.w + q.w);
@ -275,8 +275,8 @@ Quat.prototype.add = function (q) {
/** /**
* Computes the componentwise difference of two Quats. * Computes the componentwise difference of two Quats.
* @public * @public
* @param {og.math.Quat} q - Quat to subtract. * @param {og.Quat} q - Quat to subtract.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.sub = function (q) { Quat.prototype.sub = function (q) {
return new Quat(this.x - q.x, this.y - q.y, this.z - q.z, this.w - q.w); return new Quat(this.x - q.x, this.y - q.y, this.z - q.z, this.w - q.w);
@ -286,7 +286,7 @@ Quat.prototype.sub = function (q) {
* Multiplies the provided Quat componentwise by the provided scalar. * Multiplies the provided Quat componentwise by the provided scalar.
* @public * @public
* @param {Number} scale - The scalar to multiply with. * @param {Number} scale - The scalar to multiply with.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.scaleTo = function (scale) { Quat.prototype.scaleTo = function (scale) {
return new Quat(this.x * scale, this.y * scale, this.z * scale, this.w * scale); return new Quat(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
@ -307,7 +307,7 @@ Quat.prototype.toVec = function () {
* @param {number} lat - Latitude. * @param {number} lat - Latitude.
* @param {number} lon - Longitude. * @param {number} lon - Longitude.
* @param {number} angle - Angle in radians. * @param {number} angle - Angle in radians.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.setFromSphericalCoords = function (lat, lon, angle) { Quat.prototype.setFromSphericalCoords = function (lat, lon, angle) {
var sin_a = Math.sin(angle / 2); var sin_a = Math.sin(angle / 2);
@ -352,9 +352,9 @@ Quat.prototype.toSphericalCoords = function () {
/** /**
* Sets current Quat representing a rotation around an axis. * Sets current Quat representing a rotation around an axis.
* @public * @public
* @param {og.math.Vector3} axis - The axis of rotation. * @param {og.Vec3} axis - The axis of rotation.
* @param {number} angle The angle in radians to rotate around the axis. * @param {number} angle The angle in radians to rotate around the axis.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.setFromAxisAngle = function (axis, angle) { Quat.prototype.setFromAxisAngle = function (axis, angle) {
var v = axis.normal(); var v = axis.normal();
@ -392,7 +392,7 @@ Quat.prototype.getAxisAngle = function () {
* @param {number} pitch - Pitch angle in degrees. * @param {number} pitch - Pitch angle in degrees.
* @param {number} yaw - Yaw angle in degrees. * @param {number} yaw - Yaw angle in degrees.
* @param {number} roll - Roll angle in degrees. * @param {number} roll - Roll angle in degrees.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.setFromEulerAngles = function (pitch, yaw, roll) { Quat.prototype.setFromEulerAngles = function (pitch, yaw, roll) {
var ex, ey, ez; var ex, ey, ez;
@ -434,7 +434,7 @@ Quat.prototype.getEulerAngles = function () {
/** /**
* Computes a Quat from the provided 4x4 matrix instance. * Computes a Quat from the provided 4x4 matrix instance.
* @public * @public
* @param {og.math.Matrix4} m - The rotation matrix. * @param {og.Mat4} m - The rotation matrix.
*/ */
Quat.prototype.setFromMatrix4 = function (m) { Quat.prototype.setFromMatrix4 = function (m) {
var tr, s, q = []; var tr, s, q = [];
@ -480,7 +480,7 @@ Quat.prototype.setFromMatrix4 = function (m) {
/** /**
* Converts current Quat to the rotation matrix. * Converts current Quat to the rotation matrix.
* @public * @public
* @returns {og.math.Matrix4} * @returns {og.Mat4}
*/ */
Quat.prototype.getMat4 = function () { Quat.prototype.getMat4 = function () {
var m = new Mat4(); var m = new Mat4();
@ -503,8 +503,8 @@ Quat.prototype.getMat4 = function () {
/** /**
* Returns quatrenion and vector production. * Returns quatrenion and vector production.
* @public * @public
* @param {og.math.Vector3} v - 3d Vector. * @param {og.Vec3} v - 3d Vector.
* @returns {og.math.Vector3} * @returns {og.Vec3}
*/ */
Quat.prototype.mulVec3 = function (v) { Quat.prototype.mulVec3 = function (v) {
var d = v.x, e = v.y, g = v.z; var d = v.x, e = v.y, g = v.z;
@ -522,8 +522,8 @@ Quat.prototype.mulVec3 = function (v) {
/** /**
* Computes the product of two Quats. * Computes the product of two Quats.
* @public * @public
* @param {og.math.Quat} q - Quat to multiply. * @param {og.Quat} q - Quat to multiply.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.mul = function (q) { Quat.prototype.mul = function (q) {
var d = this.x, e = this.y, g = this.z, a = this.w; var d = this.x, e = this.y, g = this.z, a = this.w;
@ -538,7 +538,7 @@ Quat.prototype.mul = function (q) {
/** /**
* Gets the conjugate of the Quat. * Gets the conjugate of the Quat.
* @public * @public
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.conjugate = function () { Quat.prototype.conjugate = function () {
return new Quat(-this.x, -this.y, -this.z, this.w); return new Quat(-this.x, -this.y, -this.z, this.w);
@ -547,7 +547,7 @@ Quat.prototype.conjugate = function () {
/** /**
* Computes the inverse of the Quat. * Computes the inverse of the Quat.
* @public * @public
* @retuns {og.math.Quat} * @retuns {og.Quat}
*/ */
Quat.prototype.inverse = function () { Quat.prototype.inverse = function () {
var n = 1 / this.magnitude2(); var n = 1 / this.magnitude2();
@ -577,7 +577,7 @@ Quat.prototype.magnitude2 = function () {
/** /**
* Computes the dot (scalar) product of two Quats. * Computes the dot (scalar) product of two Quats.
* @public * @public
* @param {og.math.Quat} q - Second quatrnion. * @param {og.Quat} q - Second quatrnion.
* @returns {number} * @returns {number}
*/ */
Quat.prototype.dot = function (q) { Quat.prototype.dot = function (q) {
@ -587,7 +587,7 @@ Quat.prototype.dot = function (q) {
/** /**
* Current Quat normalization. * Current Quat normalization.
* @public * @public
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.normalize = function () { Quat.prototype.normalize = function () {
var c = this.x, d = this.y, e = this.z, g = this.w, var c = this.x, d = this.y, e = this.z, g = this.w,
@ -610,7 +610,7 @@ Quat.prototype.normalize = function () {
/** /**
* Compares two Quats. * Compares two Quats.
* @public * @public
* @param {og.math.Quat} q - Second quatrnion. * @param {og.Quat} q - Second quatrnion.
* @returns {boolean} * @returns {boolean}
*/ */
Quat.prototype.isEqual = function (q) { Quat.prototype.isEqual = function (q) {
@ -624,9 +624,9 @@ Quat.prototype.isEqual = function (q) {
/** /**
* Performs a spherical linear interpolation between two Quats. * Performs a spherical linear interpolation between two Quats.
* @public * @public
* @param {og.math.Quat} b - The end rotation Quat. * @param {og.Quat} b - The end rotation Quat.
* @param {number} t - interpolation amount between the two Quats. * @param {number} t - interpolation amount between the two Quats.
* @returns {og.math.Quat} * @returns {og.Quat}
*/ */
Quat.prototype.slerp = function (b, t) { Quat.prototype.slerp = function (b, t) {

View File

@ -11,22 +11,22 @@ import { Vec3 } from './Vec3.js';
/** /**
* Represents a ray that extends infinitely from the provided origin in the provided direction. * Represents a ray that extends infinitely from the provided origin in the provided direction.
* @class * @class
* @param {og.math.Vec3} origin - The origin of the ray. * @param {og.Vec3} origin - The origin of the ray.
* @param {og.math.Vec3} direction - The direction of the ray. * @param {og.Vec3} direction - The direction of the ray.
*/ */
const Ray = function (origin, direction) { const Ray = function (origin, direction) {
/** /**
* The origin of the ray. * The origin of the ray.
* @public * @public
* @type {og.math.Vec3} * @type {og.Vec3}
*/ */
this.origin = origin.clone(); this.origin = origin.clone();
/** /**
* The direction of the ray. * The direction of the ray.
* @public * @public
* @type {og.math.Vec3} * @type {og.Vec3}
*/ */
this.direction = direction.clone(); this.direction = direction.clone();
}; };
@ -34,9 +34,9 @@ const Ray = function (origin, direction) {
/** /**
* Ray object creator. * Ray object creator.
* @function * @function
* @param {og.math.Vec3} origin - The origin of the ray. * @param {og.Vec3} origin - The origin of the ray.
* @param {og.math.Vec3} direction - The direction of the ray. * @param {og.Vec3} direction - The direction of the ray.
* @returns {og.math.Ray} * @returns {og.Ray}
*/ */
export function ray(origin, direction) { export function ray(origin, direction) {
return new Ray(origin, direction); return new Ray(origin, direction);
@ -54,9 +54,9 @@ Ray.AWAY = 3;
/** /**
* Sets a ray parameters. * Sets a ray parameters.
* @public * @public
* @param {og.math.Vec3} origin - The origin of the ray. * @param {og.Vec3} origin - The origin of the ray.
* @param {og.math.Vec3} direction - The direction of the ray. * @param {og.Vec3} direction - The direction of the ray.
* @returns {og.math.Ray} * @returns {og.Ray}
*/ */
Ray.prototype.set = function (origin, direction) { Ray.prototype.set = function (origin, direction) {
this.origin = origin.clone(); this.origin = origin.clone();
@ -68,7 +68,7 @@ Ray.prototype.set = function (origin, direction) {
* Computes the point along the ray on the distance. * Computes the point along the ray on the distance.
* @public * @public
* @param {number} distance - Point distance. * @param {number} distance - Point distance.
* @returns {og.math.Vec3} * @returns {og.Vec3}
*/ */
Ray.prototype.getPoint = function (distance) { Ray.prototype.getPoint = function (distance) {
return Vec3.add(this.origin, this.direction.scaleTo(distance)); return Vec3.add(this.origin, this.direction.scaleTo(distance));
@ -77,12 +77,12 @@ Ray.prototype.getPoint = function (distance) {
/** /**
* Returns ray hit a triange result. * Returns ray hit a triange result.
* @public * @public
* @param {og.math.Vec3} v0 - First triangle corner coordinate. * @param {og.Vec3} v0 - First triangle corner coordinate.
* @param {og.math.Vec3} v1 - Second triangle corner coordinate. * @param {og.Vec3} v1 - Second triangle corner coordinate.
* @param {og.math.Vec3} v2 - Third triangle corner coordinate. * @param {og.Vec3} v2 - Third triangle corner coordinate.
* @param {og.math.Vec3} res - Hit point object pointer that stores hit result. * @param {og.Vec3} res - Hit point object pointer that stores hit result.
* @returns {number} - Hit code, could 0 - og.math.Ray.OUTSIDE, 1 - og.math.Ray.INSIDE, * @returns {number} - Hit code, could 0 - og.Ray.OUTSIDE, 1 - og.Ray.INSIDE,
* 2 - og.math.Ray.INPLANE and 3 - og.math.Ray.AWAY(ray goes away from triangle). * 2 - og.Ray.INPLANE and 3 - og.Ray.AWAY(ray goes away from triangle).
*/ */
Ray.prototype.hitTriangle = function (v0, v1, v2, res) { Ray.prototype.hitTriangle = function (v0, v1, v2, res) {
var state; var state;
@ -136,12 +136,12 @@ Ray.prototype.hitTriangle = function (v0, v1, v2, res) {
}; };
/** /**
* Gets a ray hit a plane result. If the ray cross the plane returns 1 - og.math.Ray.INSIDE otherwise returns 0 - og.math.Ray.OUTSIDE. * Gets a ray hit a plane result. If the ray cross the plane returns 1 - og.Ray.INSIDE otherwise returns 0 - og.Ray.OUTSIDE.
* @public * @public
* @param {og.math.Vec3} v0 - First plane point. * @param {og.Vec3} v0 - First plane point.
* @param {og.math.Vec3} v1 - Second plane point. * @param {og.Vec3} v1 - Second plane point.
* @param {og.math.Vec3} v2 - Third plane point. * @param {og.Vec3} v2 - Third plane point.
* @param {og.math.Vec3} res - Hit point object pointer that stores hit result. * @param {og.Vec3} res - Hit point object pointer that stores hit result.
* @returns {number} * @returns {number}
*/ */
Ray.prototype.hitPlane = function (v0, v1, v2, res) { Ray.prototype.hitPlane = function (v0, v1, v2, res) {
@ -180,7 +180,7 @@ Ray.prototype.hitPlane = function (v0, v1, v2, res) {
* Returns a ray hit sphere coordiante. If there isn't hit returns null. * Returns a ray hit sphere coordiante. If there isn't hit returns null.
* @public * @public
* @param {og.bv.Sphere} sphere - Sphere object. * @param {og.bv.Sphere} sphere - Sphere object.
* @returns {og.math.Vec3} * @returns {og.Vec3}
*/ */
Ray.prototype.hitSphere = function (sphere) { Ray.prototype.hitSphere = function (sphere) {
var r = sphere.radius, var r = sphere.radius,

View File

@ -152,7 +152,7 @@ Vec2.orthoNormalize = function (normal, tangent) {
/** /**
* Converts to 3d vector, third value is 0.0. * Converts to 3d vector, third value is 0.0.
* @public * @public
* @returns {og.math.Vector3} * @returns {og.Vec3}
*/ */
Vec2.prototype.toVector3 = function () { Vec2.prototype.toVector3 = function () {
return new Vec3(this.x, this.y, 0); return new Vec3(this.x, this.y, 0);

View File

@ -56,7 +56,7 @@ Vec3.ZERO = new Vec3();
* @param {number} [x] - First cvalue. * @param {number} [x] - First cvalue.
* @param {number} [y] - Second value. * @param {number} [y] - Second value.
* @param {number} [z] - Third value. * @param {number} [z] - Third value.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
export function vec3(x, y, z) { export function vec3(x, y, z) {
return new Vec3(x, y, z); return new Vec3(x, y, z);
@ -66,7 +66,7 @@ export function vec3(x, y, z) {
* Creates 3d vector from array. * Creates 3d vector from array.
* @function * @function
* @param {Array.<number,number,number>} * @param {Array.<number,number,number>}
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.fromVec = function (arr) { Vec3.fromVec = function (arr) {
return new Vec3(arr[0], arr[1], arr[2]); return new Vec3(arr[0], arr[1], arr[2]);
@ -75,8 +75,8 @@ Vec3.fromVec = function (arr) {
/** /**
* Gets angle between two vectors. * Gets angle between two vectors.
* @static * @static
* @param {og.math.Vec3} a - First vector. * @param {og.Vec3} a - First vector.
* @param {og.math.Vec3} b - Second vector. * @param {og.Vec3} b - Second vector.
* @returns {number} - * @returns {number} -
*/ */
Vec3.angle = function (a, b) { Vec3.angle = function (a, b) {
@ -86,10 +86,10 @@ Vec3.angle = function (a, b) {
/** /**
* Returns two vectors linear interpolation. * Returns two vectors linear interpolation.
* @static * @static
* @param {og.math.Vec3} v1 - Start vector. * @param {og.Vec3} v1 - Start vector.
* @param {og.math.Vec3} v2 - End vector. * @param {og.Vec3} v2 - End vector.
* @param {number} l - Interpolate value. * @param {number} l - Interpolate value.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.lerp = function (v1, v2, l) { Vec3.lerp = function (v1, v2, l) {
return Vec3(v1.x + (v2.x - v1.x) * l, v1.y + (v2.y - v1.y) * l, v1.z + (v2.z - v1.z) * l); return Vec3(v1.x + (v2.x - v1.x) * l, v1.y + (v2.y - v1.y) * l, v1.z + (v2.z - v1.z) * l);
@ -98,9 +98,9 @@ Vec3.lerp = function (v1, v2, l) {
/** /**
* Returns summary vector. * Returns summary vector.
* @static * @static
* @param {og.math.Vec3} a - First vector. * @param {og.Vec3} a - First vector.
* @param {og.math.Vec3} b - Second vector. * @param {og.Vec3} b - Second vector.
* @returns {og.math.Vec3} - Summary vector. * @returns {og.Vec3} - Summary vector.
*/ */
Vec3.add = function (a, b) { Vec3.add = function (a, b) {
var res = new Vec3(a.x, a.y, a.z); var res = new Vec3(a.x, a.y, a.z);
@ -111,9 +111,9 @@ Vec3.add = function (a, b) {
/** /**
* Returns two vectors subtraction. * Returns two vectors subtraction.
* @static * @static
* @param {og.math.Vec3} a - First vector. * @param {og.Vec3} a - First vector.
* @param {og.math.Vec3} b - Second vector. * @param {og.Vec3} b - Second vector.
* @returns {og.math.Vec3} - Vectors subtraction. * @returns {og.Vec3} - Vectors subtraction.
*/ */
Vec3.sub = function (a, b) { Vec3.sub = function (a, b) {
var res = new Vec3(a.x, a.y, a.z); var res = new Vec3(a.x, a.y, a.z);
@ -124,9 +124,9 @@ Vec3.sub = function (a, b) {
/** /**
* Returns scaled vector. * Returns scaled vector.
* @static * @static
* @param {og.math.Vec3} a - Input vector. * @param {og.Vec3} a - Input vector.
* @param {number} scale - Scale value. * @param {number} scale - Scale value.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.scale = function (a, scale) { Vec3.scale = function (a, scale) {
var res = new Vec3(a.x, a.y, a.z); var res = new Vec3(a.x, a.y, a.z);
@ -137,9 +137,9 @@ Vec3.scale = function (a, scale) {
/** /**
* Returns two vectors production. * Returns two vectors production.
* @static * @static
* @param {og.math.Vec3} a - First vector. * @param {og.Vec3} a - First vector.
* @param {og.math.Vec3} b - Second vector. * @param {og.Vec3} b - Second vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.mul = function (a, b) { Vec3.mul = function (a, b) {
var res = new Vec3(a.x, a.y, a.z); var res = new Vec3(a.x, a.y, a.z);
@ -150,9 +150,9 @@ Vec3.mul = function (a, b) {
/** /**
* Returns true if two vectors are non collinear. * Returns true if two vectors are non collinear.
* @public * @public
* @param {og.math.Vec3} a - First vector. * @param {og.Vec3} a - First vector.
* @param {og.math.Vec3} b - Second vector. * @param {og.Vec3} b - Second vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.noncollinear = function (a, b) { Vec3.noncollinear = function (a, b) {
return a.y * b.z - a.z * b.y || a.z * b.x - a.x * b.z || a.x * b.y - a.y * b.z; return a.y * b.z - a.z * b.y || a.z * b.x - a.x * b.z || a.x * b.y - a.y * b.z;
@ -161,10 +161,10 @@ Vec3.noncollinear = function (a, b) {
/** /**
* Get projection of the vector to plane where n - normal to the plane. * Get projection of the vector to plane where n - normal to the plane.
* @static * @static
* @param {og.math.Vec3} b - Vector to project. * @param {og.Vec3} b - Vector to project.
* @param {og.math.Vec3} n - Plane normal. * @param {og.Vec3} n - Plane normal.
* @param {og.math.Vec3} [def] - Default value for non existed result. * @param {og.Vec3} [def] - Default value for non existed result.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.proj_b_to_plane = function (b, n, def) { Vec3.proj_b_to_plane = function (b, n, def) {
var res = b.sub(n.scaleTo(n.dot(b) / n.dot(n))); var res = b.sub(n.scaleTo(n.dot(b) / n.dot(n)));
@ -177,9 +177,9 @@ Vec3.proj_b_to_plane = function (b, n, def) {
/** /**
* Get projection of the first vector to the second. * Get projection of the first vector to the second.
* @static * @static
* @param {og.math.Vec3} b - First vector. * @param {og.Vec3} b - First vector.
* @param {og.math.Vec3} a - Second vector. * @param {og.Vec3} a - Second vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.proj_b_to_a = function (b, a) { Vec3.proj_b_to_a = function (b, a) {
return a.scaleTo(a.dot(b) / a.dot(a)); return a.scaleTo(a.dot(b) / a.dot(a));
@ -189,9 +189,9 @@ Vec3.proj_b_to_a = function (b, a) {
* Makes vectors normalized and orthogonal to each other. * Makes vectors normalized and orthogonal to each other.
* Normalizes normal. Normalizes tangent and makes sure it is orthogonal to normal (that is, angle between them is 90 degrees). * Normalizes normal. Normalizes tangent and makes sure it is orthogonal to normal (that is, angle between them is 90 degrees).
* @static * @static
* @param {og.math.Vec3} normal - Normal vector. * @param {og.Vec3} normal - Normal vector.
* @param {og.math.Vec3} tangent - Tangent vector. * @param {og.Vec3} tangent - Tangent vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.orthoNormalize = function (normal, tangent) { Vec3.orthoNormalize = function (normal, tangent) {
normal = normal.normal(); normal = normal.normal();
@ -202,9 +202,9 @@ Vec3.orthoNormalize = function (normal, tangent) {
/** /**
* Returns vector components division product one to another. * Returns vector components division product one to another.
* @static * @static
* @param {og.math.Vec3} a - First vector. * @param {og.Vec3} a - First vector.
* @param {og.math.Vec3} b - Second vector. * @param {og.Vec3} b - Second vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.div = function (a, b) { Vec3.div = function (a, b) {
var res = new Vec3(a.x, a.y, a.z); var res = new Vec3(a.x, a.y, a.z);
@ -215,7 +215,7 @@ Vec3.div = function (a, b) {
/** /**
* Converts to 4d vector, Fourth value is 1.0. * Converts to 4d vector, Fourth value is 1.0.
* @public * @public
* @returns {og.math.Vector4} - * @returns {og.Vec4} -
*/ */
Vec3.prototype.toVec4 = function () { Vec3.prototype.toVec4 = function () {
return new Vec4(this.x, this.y, this.z, 1.0); return new Vec4(this.x, this.y, this.z, 1.0);
@ -224,7 +224,7 @@ Vec3.prototype.toVec4 = function () {
/** /**
* Returns clone vector. * Returns clone vector.
* @public * @public
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.clone = function () { Vec3.prototype.clone = function () {
return new Vec3(this.x, this.y, this.z); return new Vec3(this.x, this.y, this.z);
@ -251,8 +251,8 @@ Vec3.prototype.isZero = function () {
/** /**
* Get projection of the first vector to the second. * Get projection of the first vector to the second.
* @static * @static
* @param {og.math.Vec3} a - Project vector. * @param {og.Vec3} a - Project vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.projToVec = function (a) { Vec3.prototype.projToVec = function (a) {
return a.scaleTo(a.dot(this) / a.dot(a)); return a.scaleTo(a.dot(this) / a.dot(a));
@ -261,7 +261,7 @@ Vec3.prototype.projToVec = function (a) {
/** /**
* Compares with vector. Returns true if it equals another. * Compares with vector. Returns true if it equals another.
* @public * @public
* @param {og.math.Vec3} p - Vector to compare. * @param {og.Vec3} p - Vector to compare.
* @returns {boolean} - * @returns {boolean} -
*/ */
Vec3.prototype.equal = function (p) { Vec3.prototype.equal = function (p) {
@ -270,8 +270,8 @@ Vec3.prototype.equal = function (p) {
/** /**
* Copy input vector's values. * Copy input vector's values.
* @param {og.math.Vec3} point3 - Vector to copy. * @param {og.Vec3} point3 - Vector to copy.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.copy = function (point3) { Vec3.prototype.copy = function (point3) {
this.x = point3.x; this.x = point3.x;
@ -301,7 +301,7 @@ Vec3.prototype.length2 = function () {
/** /**
* Converts vector's values to a quaternion object. * Converts vector's values to a quaternion object.
* @public * @public
* @returns {og.math.Quat} - * @returns {og.Quat} -
*/ */
Vec3.prototype.getQuat = function () { Vec3.prototype.getQuat = function () {
return new Quat(this.x, this.y, this.z); return new Quat(this.x, this.y, this.z);
@ -310,8 +310,8 @@ Vec3.prototype.getQuat = function () {
/** /**
* Adds vector to the current. * Adds vector to the current.
* @public * @public
* @param {og.math.Vec3} point3 - Point to add. * @param {og.Vec3} point3 - Point to add.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.addA = function (point3) { Vec3.prototype.addA = function (point3) {
this.x += point3.x; this.x += point3.x;
@ -323,8 +323,8 @@ Vec3.prototype.addA = function (point3) {
/** /**
* Gets two vectors summarization. * Gets two vectors summarization.
* @public * @public
* @param {og.math.Vec3} point3 - Vector to add. * @param {og.Vec3} point3 - Vector to add.
* @returns {og.math.Vec3} Returns a sum vector. * @returns {og.Vec3} Returns a sum vector.
*/ */
Vec3.prototype.add = function (point3) { Vec3.prototype.add = function (point3) {
return new Vec3(this.x + point3.x, this.y + point3.y, this.z + point3.z); return new Vec3(this.x + point3.x, this.y + point3.y, this.z + point3.z);
@ -333,8 +333,8 @@ Vec3.prototype.add = function (point3) {
/** /**
* Subtract vector from the current. * Subtract vector from the current.
* @public * @public
* @param {og.math.Vec3} point3 - Subtract vector. * @param {og.Vec3} point3 - Subtract vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.subA = function (point3) { Vec3.prototype.subA = function (point3) {
this.x -= point3.x; this.x -= point3.x;
@ -346,8 +346,8 @@ Vec3.prototype.subA = function (point3) {
/** /**
* Gets vector subtraction. * Gets vector subtraction.
* @public * @public
* @param {og.math.Vec3} point3 - Subtract vector. * @param {og.Vec3} point3 - Subtract vector.
* @return {og.math.Vec3} Returns new instance of a subtraction * @return {og.Vec3} Returns new instance of a subtraction
*/ */
Vec3.prototype.sub = function (point3) { Vec3.prototype.sub = function (point3) {
return new Vec3(this.x - point3.x, this.y - point3.y, this.z - point3.z); return new Vec3(this.x - point3.x, this.y - point3.y, this.z - point3.z);
@ -357,7 +357,7 @@ Vec3.prototype.sub = function (point3) {
* Scale current vector. * Scale current vector.
* @public * @public
* @param {number} scale - Scale value. * @param {number} scale - Scale value.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.scale = function (scale) { Vec3.prototype.scale = function (scale) {
this.x *= scale; this.x *= scale;
@ -370,7 +370,7 @@ Vec3.prototype.scale = function (scale) {
* Scale current vector to another instance. * Scale current vector to another instance.
* @public * @public
* @param {number} scale - Scale value. * @param {number} scale - Scale value.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.scaleTo = function (scale) { Vec3.prototype.scaleTo = function (scale) {
return new Vec3(this.x * scale, this.y * scale, this.z * scale); return new Vec3(this.x * scale, this.y * scale, this.z * scale);
@ -379,8 +379,8 @@ Vec3.prototype.scaleTo = function (scale) {
/** /**
* Multiply current vector object to another and store result in the current instance. * Multiply current vector object to another and store result in the current instance.
* @public * @public
* @param {og.math.Vec3} vec - Multiply vector. * @param {og.Vec3} vec - Multiply vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.mulA = function (vec) { Vec3.prototype.mulA = function (vec) {
this.x *= vec.x; this.x *= vec.x;
@ -392,8 +392,8 @@ Vec3.prototype.mulA = function (vec) {
/** /**
* Multiply current vector object to another and returns new vector instance. * Multiply current vector object to another and returns new vector instance.
* @public * @public
* @param {og.math.Vec3} vec - Multiply vector. * @param {og.Vec3} vec - Multiply vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.mul = function (vec) { Vec3.prototype.mul = function (vec) {
return new Vec3(this.x * vec.x, this.y * vec.y, this.z * vec.z); return new Vec3(this.x * vec.x, this.y * vec.y, this.z * vec.z);
@ -402,8 +402,8 @@ Vec3.prototype.mul = function (vec) {
/** /**
* Divide current vector's components to another. Results stores in the current vector object. * Divide current vector's components to another. Results stores in the current vector object.
* @public * @public
* @param {og.math.Vec3} vec - Div vector. * @param {og.Vec3} vec - Div vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.divA = function (vec) { Vec3.prototype.divA = function (vec) {
this.x /= vec.x; this.x /= vec.x;
@ -415,8 +415,8 @@ Vec3.prototype.divA = function (vec) {
/** /**
* Divide current vector's components to another and returns new vector instance. * Divide current vector's components to another and returns new vector instance.
* @public * @public
* @param {og.math.Vec3} vec - Div vector. * @param {og.Vec3} vec - Div vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.div = function (vec) { Vec3.prototype.div = function (vec) {
return new Vec3(this.x / vec.x, this.y / vec.y, this.z / vec.z); return new Vec3(this.x / vec.x, this.y / vec.y, this.z / vec.z);
@ -425,7 +425,7 @@ Vec3.prototype.div = function (vec) {
/** /**
* Gets vectors dot production. * Gets vectors dot production.
* @public * @public
* @param {og.math.Vec3} point3 - Another vector. * @param {og.Vec3} point3 - Another vector.
* @returns {number} - * @returns {number} -
*/ */
Vec3.prototype.dot = function (point3) { Vec3.prototype.dot = function (point3) {
@ -446,8 +446,8 @@ Vec3.prototype.dotArr = function (arr) {
/** /**
* Gets vectors cross production. * Gets vectors cross production.
* @public * @public
* @param {og.math.Vec3} point3 - Another vector. * @param {og.Vec3} point3 - Another vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.cross = function (point3) { Vec3.prototype.cross = function (point3) {
return new Vec3( return new Vec3(
@ -460,7 +460,7 @@ Vec3.prototype.cross = function (point3) {
/** /**
* Sets vector to zero. * Sets vector to zero.
* @public * @public
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.clear = function () { Vec3.prototype.clear = function () {
this.x = this.y = this.z = 0; this.x = this.y = this.z = 0;
@ -470,7 +470,7 @@ Vec3.prototype.clear = function () {
/** /**
* Returns normalized vector. * Returns normalized vector.
* @public * @public
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.normal = function () { Vec3.prototype.normal = function () {
var res = new Vec3(); var res = new Vec3();
@ -488,7 +488,7 @@ Vec3.prototype.normal = function () {
/** /**
* Normalize current vector. * Normalize current vector.
* @public * @public
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.normalize = function () { Vec3.prototype.normalize = function () {
var length = 1.0 / this.length(); var length = 1.0 / this.length();
@ -522,7 +522,7 @@ Vec3.prototype.toArray = function () {
/** /**
* Gets distance to point. * Gets distance to point.
* @public * @public
* @param {og.math.Vec3} point3 - Distant point. * @param {og.Vec3} point3 - Distant point.
* @returns {number} - * @returns {number} -
*/ */
Vec3.prototype.distance = function (point3) { Vec3.prototype.distance = function (point3) {
@ -535,7 +535,7 @@ Vec3.prototype.distance = function (point3) {
* @param {number} x - Value X. * @param {number} x - Value X.
* @param {number} y - Value Y. * @param {number} y - Value Y.
* @param {number} z - Value Z. * @param {number} z - Value Z.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.set = function (x, y, z) { Vec3.prototype.set = function (x, y, z) {
this.x = x; this.x = x;
@ -547,7 +547,7 @@ Vec3.prototype.set = function (x, y, z) {
/** /**
* Negate current vector. * Negate current vector.
* @public * @public
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.negate = function () { Vec3.prototype.negate = function () {
this.x = -this.x; this.x = -this.x;
@ -559,7 +559,7 @@ Vec3.prototype.negate = function () {
/** /**
* Negate current vector to another instance. * Negate current vector to another instance.
* @public * @public
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.negateTo = function () { Vec3.prototype.negateTo = function () {
return new Vec3(-this.x, -this.y, -this.z); return new Vec3(-this.x, -this.y, -this.z);
@ -568,9 +568,9 @@ Vec3.prototype.negateTo = function () {
/** /**
* Gets projected point coordinates of the current vector on the ray. * Gets projected point coordinates of the current vector on the ray.
* @public * @public
* @param {og.math.Vec3} pos - Ray position. * @param {og.Vec3} pos - Ray position.
* @param {og.math.Vec3} direction - Ray direction. * @param {og.Vec3} direction - Ray direction.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.projToRay = function (pos, direction) { Vec3.prototype.projToRay = function (pos, direction) {
var v = Vec3.proj_b_to_a(Vec3.sub(this, pos), direction); var v = Vec3.proj_b_to_a(Vec3.sub(this, pos), direction);
@ -581,7 +581,7 @@ Vec3.prototype.projToRay = function (pos, direction) {
/** /**
* Gets angle between two vectors. * Gets angle between two vectors.
* @public * @public
* @param {og.math.Vec3} a - Another vector. * @param {og.Vec3} a - Another vector.
* @returns {number} - * @returns {number} -
*/ */
Vec3.prototype.angle = function (a) { Vec3.prototype.angle = function (a) {
@ -591,9 +591,9 @@ Vec3.prototype.angle = function (a) {
/** /**
* Returns two vectors linear interpolation. * Returns two vectors linear interpolation.
* @public * @public
* @param {og.math.Vec3} v2 - End vector. * @param {og.Vec3} v2 - End vector.
* @param {number} l - Interpolate value. * @param {number} l - Interpolate value.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.lerp = function (v2, l) { Vec3.prototype.lerp = function (v2, l) {
return new Vec3(this.x + (v2.x - this.x) * l, this.y + (v2.y - this.y) * l, this.z + (v2.z - this.z) * l); return new Vec3(this.x + (v2.x - this.x) * l, this.y + (v2.y - this.y) * l, this.z + (v2.z - this.z) * l);
@ -602,9 +602,9 @@ Vec3.prototype.lerp = function (v2, l) {
/** /**
* Returns vector interpolation by v(t) = v1 * t + v2 * (1 - t) * Returns vector interpolation by v(t) = v1 * t + v2 * (1 - t)
* @public * @public
* @param {og.math.Vec3} v2 - End vector. * @param {og.Vec3} v2 - End vector.
* @param {number} t - Interpolate value. * @param {number} t - Interpolate value.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.smerp = function (v2, t) { Vec3.prototype.smerp = function (v2, t) {
var one_d = 1 - t; var one_d = 1 - t;
@ -619,9 +619,9 @@ Vec3.LERP_DELTA = 1e-6;
* the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated * the vectors are treated as directions rather than points in space. The direction of the returned vector is interpolated
* by the angle and its magnitude is interpolated between the magnitudes of from and to. * by the angle and its magnitude is interpolated between the magnitudes of from and to.
* @public * @public
* @param {og.math.Vec3} v2 - * @param {og.Vec3} v2 -
* @param {number} t - The parameter t is clamped to the range [0, 1]. * @param {number} t - The parameter t is clamped to the range [0, 1].
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
Vec3.prototype.slerp = function (v2, t) { Vec3.prototype.slerp = function (v2, t) {
var res = new Vec3(); var res = new Vec3();

View File

@ -74,7 +74,7 @@ Vec4.fromVec = function (arr) {
/** /**
* Converts to 3d vector, without fourth value. * Converts to 3d vector, without fourth value.
* @public * @public
* @returns {og.math.Vector3} * @returns {og.Vec3}
*/ */
Vec4.prototype.toVec3 = function () { Vec4.prototype.toVec3 = function () {
return new Vec3(this.x, this.y, this.z); return new Vec3(this.x, this.y, this.z);
@ -209,7 +209,7 @@ Vec4.prototype.affinity = function () {
* Scale current vector to another instance. * Scale current vector to another instance.
* @public * @public
* @param {number} scale - Scale value. * @param {number} scale - Scale value.
* @returns {og.math.Vector3} * @returns {og.Vec3}
*/ */
Vec4.prototype.scaleTo = function (scale) { Vec4.prototype.scaleTo = function (scale) {
return new Vec4(this.x * scale, this.y * scale, this.z * scale, this.w * scale); return new Vec4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);

View File

@ -10,7 +10,7 @@ import { Vec4 } from './Vec4.js';
/** /**
* Encode 32 bit float value to the RGBA vector. * Encode 32 bit float value to the RGBA vector.
* @function * @function
* @param {nummer} v - 32 bit float value. * @param {number} v - 32 bit float value.
* @returns {og.math.Vec4} - RGBA vector value. * @returns {og.math.Vec4} - RGBA vector value.
*/ */
export function encodeFloatToRGBA(v) { export function encodeFloatToRGBA(v) {
@ -22,7 +22,7 @@ export function encodeFloatToRGBA(v) {
/** /**
* Decode RGBA vector to 32 bit float value. * Decode RGBA vector to 32 bit float value.
* @function * @function
* @param {og.math.Vector4} rgba - RGBA encoded 32 bit float value. * @param {og.Vec4} rgba - RGBA encoded 32 bit float value.
* @returns {number} - Float value. * @returns {number} - Float value.
*/ */
export function decodeFloatFromRGBA(rgba) { export function decodeFloatFromRGBA(rgba) {

View File

@ -50,7 +50,7 @@ const EVENT_NAMES = [
* @class * @class
* @param {String} name - Layer user name. * @param {String} name - Layer user name.
* @param {Object} options: * @param {Object} options:
* @extends {og.layer.Layer} * @extends {og.Layer}
*/ */
class GmxVector extends Layer { class GmxVector extends Layer {
constructor(name, options) { constructor(name, options) {

View File

@ -8,6 +8,6 @@ import { Units, Proj } from './Proj.js';
/** /**
* EPSG:3857 projection object. * EPSG:3857 projection object.
* @type {og.proj.Projection} * @type {og.Proj}
*/ */
export const EPSG3857 = new Proj({ code: "epsg:3857", units: Units.METERS }); export const EPSG3857 = new Proj({ code: "epsg:3857", units: Units.METERS });

View File

@ -8,6 +8,6 @@ import { Units, Proj } from './Proj.js';
/** /**
* EPSG:4326 projection object. * EPSG:4326 projection object.
* @type {og.proj.Proj} * @type {og.Proj}
*/ */
export const EPSG4326 = new Proj({ code: "epsg:4326", units: Units.DEGREES }); export const EPSG4326 = new Proj({ code: "epsg:4326", units: Units.DEGREES });

View File

@ -51,7 +51,7 @@ const Proj = function (options) {
/** /**
* Compare projections. * Compare projections.
* @public * @public
* @param {og.proj.Projection} proj - Projetion object. * @param {og.Proj} proj - Projetion object.
* @returns {boolean} * @returns {boolean}
*/ */
Proj.prototype.equal = function (proj) { Proj.prototype.equal = function (proj) {

View File

@ -317,8 +317,9 @@ EntityCollectionNode.prototype.renderCollection = function (outArr, visibleNodes
}; };
EntityCollectionNode.prototype.alignEntityToTheGround = function (entity, segment) { EntityCollectionNode.prototype.alignEntityToTheGround = function (entity, segment) {
segment.getEntityTerrainPoint(entity, entity._cartesian); var res = new Vec3();
entity._setCartesian3vSilent(entity._cartesian.addA(entity._cartesian.normal().scale(this.layer.relativeToGround && entity._altitude || 1.0))); segment.getEntityTerrainPoint(entity, res);
entity._setCartesian3vSilent(res.addA(res.normal().scale(Number(this.layer.relativeToGround) && entity._altitude || 0.0)));
}; };
EntityCollectionNode.prototype.isVisible = function () { EntityCollectionNode.prototype.isVisible = function () {

View File

@ -4,7 +4,6 @@
'use strict'; 'use strict';
//import * as quadTree from './quadTree.js';
import { Extent } from '../Extent.js'; import { Extent } from '../Extent.js';
import { LonLat } from '../LonLat.js'; import { LonLat } from '../LonLat.js';
import { EPSG4326 } from '../proj/EPSG4326.js'; import { EPSG4326 } from '../proj/EPSG4326.js';
@ -363,10 +362,12 @@ Node.prototype.renderTree = function (maxZoom) {
if (Math.abs(cam._lonLat.lat) <= MAX_LAT && if (Math.abs(cam._lonLat.lat) <= MAX_LAT &&
seg._projection.id === EPSG3857.id) { seg._projection.id === EPSG3857.id) {
inside = seg._extent.isInside(cam._lonLatMerc); inside = seg._extent.isInside(cam._lonLatMerc);
cam._insideSegmentPosition = cam._lonLatMerc; cam._insideSegmentPosition.lon = cam._lonLatMerc.lon;
cam._insideSegmentPosition.lat = cam._lonLatMerc.lat;
} else if (seg._projection.id === EPSG4326.id) { } else if (seg._projection.id === EPSG4326.id) {
inside = seg._extent.isInside(cam._lonLat); inside = seg._extent.isInside(cam._lonLat);
cam._insideSegmentPosition = cam._lonLat; cam._insideSegmentPosition.lon = cam._lonLat.lon;
cam._insideSegmentPosition.lat = cam._lonLat.lat;
} }
if (inside) { if (inside) {
@ -380,9 +381,12 @@ Node.prototype.renderTree = function (maxZoom) {
var inFrustum = cam.frustum.containsSphere(seg.bsphere); var inFrustum = cam.frustum.containsSphere(seg.bsphere);
//TODO: check up *
const altVis = cam.eye.distance(seg.bsphere.center) - seg.bsphere.radius < 3570.0 * Math.sqrt(cam._lonLat.height); const altVis = cam.eye.distance(seg.bsphere.center) - seg.bsphere.radius < 3570.0 * Math.sqrt(cam._lonLat.height);
if (inFrustum && (altVis || cam._lonLat.height > 10000.0) || this._cameraInside) {
seg._collectVisibleNodes();
}
if (inFrustum || this._cameraInside) { if (inFrustum || this._cameraInside) {
//First skip lowest zoom nodes //First skip lowest zoom nodes
@ -410,11 +414,6 @@ Node.prototype.renderTree = function (maxZoom) {
} else { } else {
this.state = NOTRENDERING; this.state = NOTRENDERING;
} }
//TODO: check up * and this
if (this.state !== NOTRENDERING && inFrustum && (altVis || cam._lonLat.height > 10000.0)) {
seg._collectVisibleNodes();
}
}; };
Node.prototype.traverseNodes = function (maxZoom) { Node.prototype.traverseNodes = function (maxZoom) {

View File

@ -22,7 +22,7 @@ class BaseNode {
/** /**
* Top scene tree node pointer. * Top scene tree node pointer.
* @public * @public
* @type {og.scene.Node} * @type {og.RenderNode}
*/ */
this.topNode = this; this.topNode = this;
@ -32,14 +32,14 @@ class BaseNode {
/** /**
* Children nodes. * Children nodes.
* @public * @public
* @type {Array.<og.scene.Node>} * @type {Array.<og.RenderNode>}
*/ */
this.childNodes = []; this.childNodes = [];
/** /**
* Parent node pointer. * Parent node pointer.
* @public * @public
* @type {og.scene.Node} * @type {og.RenderNode}
*/ */
this.parentNode = null; this.parentNode = null;
@ -61,7 +61,7 @@ class BaseNode {
/** /**
* Adds node to the current hierarchy. * Adds node to the current hierarchy.
* @public * @public
* @type {og.scene.Node} * @type {og.RenderNode}
*/ */
addNode(node) { addNode(node) {
if (this.parentNode == null) { if (this.parentNode == null) {
@ -91,7 +91,7 @@ class BaseNode {
* Gets node by name in the current. * Gets node by name in the current.
* @public * @public
* @param {string} name - Node name. * @param {string} name - Node name.
* @return {og.scene.Node} Node object in the current node. * @return {og.RenderNode} Node object in the current node.
*/ */
getNodeByName(name) { getNodeByName(name) {
return this._dictionary[name]; return this._dictionary[name];

View File

@ -112,14 +112,14 @@ class Planet extends RenderNode {
/** /**
* All layers array. * All layers array.
* @public * @public
* @type {Array.<og.layer.Layer>} * @type {Array.<og.Layer>}
*/ */
this.layers = []; this.layers = [];
/** /**
* Current visible imagery tile layers array. * Current visible imagery tile layers array.
* @public * @public
* @type {Array.<og.layer.Layer>} * @type {Array.<og.Layer>}
*/ */
this.visibleTileLayers = []; this.visibleTileLayers = [];
@ -142,7 +142,7 @@ class Planet extends RenderNode {
/** /**
* There is only one base layer on the globe when layer.isBaseLayer is true. * There is only one base layer on the globe when layer.isBaseLayer is true.
* @public * @public
* @type {og.layer.Layer} * @type {og.Layer}
*/ */
this.baseLayer = null; this.baseLayer = null;
@ -163,7 +163,7 @@ class Planet extends RenderNode {
/** /**
* Screen mouse pointer projected to planet cartesian position. * Screen mouse pointer projected to planet cartesian position.
* @public * @public
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this.mousePositionOnEarth = new Vec3(); this.mousePositionOnEarth = new Vec3();
@ -418,9 +418,9 @@ class Planet extends RenderNode {
/** /**
* Return layer by it name * Return layer by it name
* @param {string} name - Name of the layer. og.layer.Layer.prototype.name * @param {string} name - Name of the layer. og.Layer.prototype.name
* @public * @public
* @returns {og.layer.Layer} - * @returns {og.Layer} -
*/ */
getLayerByName(name) { getLayerByName(name) {
var i = this.layers.length; var i = this.layers.length;
@ -432,7 +432,7 @@ class Planet extends RenderNode {
/** /**
* Adds the given layer to the planet. * Adds the given layer to the planet.
* @param {og.layer.Layer} layer - Layer object. * @param {og.Layer} layer - Layer object.
* @public * @public
*/ */
addLayer(layer) { addLayer(layer) {
@ -441,7 +441,7 @@ class Planet extends RenderNode {
/** /**
* Dispatch layer visibility changing event. * Dispatch layer visibility changing event.
* @param {og.layer.Layer} layer - Changed layer. * @param {og.Layer} layer - Changed layer.
* @protected * @protected
*/ */
_onLayerVisibilityChanged(layer) { _onLayerVisibilityChanged(layer) {
@ -450,7 +450,7 @@ class Planet extends RenderNode {
/** /**
* Adds the given layers array to the planet. * Adds the given layers array to the planet.
* @param {Array.<og.layer.Layer>} layers - Layers array. * @param {Array.<og.Layer>} layers - Layers array.
* @public * @public
*/ */
addLayers(layers) { addLayers(layers) {
@ -461,8 +461,8 @@ class Planet extends RenderNode {
/** /**
* Removes the given layer from the planet. * Removes the given layer from the planet.
* @param {og.layer.Layer} layer - Layer to remove. * @param {og.Layer} layer - Layer to remove.
* @return {og.layer.Layer|undefined} The removed layer or undefined if the layer was not found. * @return {og.Layer|undefined} The removed layer or undefined if the layer was not found.
* @public * @public
*/ */
removeLayer(layer) { removeLayer(layer) {
@ -472,7 +472,7 @@ class Planet extends RenderNode {
/** /**
* *
* @protected * @protected
* @param {og.layer.Layer} layer - Material layer. * @param {og.Layer} layer - Material layer.
*/ */
_clearLayerMaterial(layer) { _clearLayerMaterial(layer) {
var lid = layer._id; var lid = layer._id;
@ -487,7 +487,7 @@ class Planet extends RenderNode {
/** /**
* Get the collection of layers associated with this planet. * Get the collection of layers associated with this planet.
* @return {Array.<og.layer.Layer>} Layers array. * @return {Array.<og.Layer>} Layers array.
* @public * @public
*/ */
getLayers() { getLayers() {
@ -496,7 +496,7 @@ class Planet extends RenderNode {
/** /**
* Sets base layer coverage to the planet. * Sets base layer coverage to the planet.
* @param {og.layer.Layer} layer - Layer object. * @param {og.Layer} layer - Layer object.
* @public * @public
*/ */
setBaseLayer(layer) { setBaseLayer(layer) {
@ -859,6 +859,8 @@ class Planet extends RenderNode {
this._quadTree.renderTree(); this._quadTree.renderTree();
//this.renderer.activeCamera._insideSegment.node.renderNode(true);
if (this.renderer.activeCamera.slope > 0.72 && this.renderer.activeCamera._lonLat.height < 850000) { if (this.renderer.activeCamera.slope > 0.72 && this.renderer.activeCamera._lonLat.height < 850000) {
this.minCurrZoom = this.maxCurrZoom; this.minCurrZoom = this.maxCurrZoom;
@ -890,13 +892,13 @@ class Planet extends RenderNode {
this._lodRatio = math.lerp(this.camera.slope, this._maxLodRatio, this._minLodRatio); this._lodRatio = math.lerp(this.camera.slope, this._maxLodRatio, this._minLodRatio);
this.renderer.activeCamera.prepareFrame();
this._collectRenderNodes(); this._collectRenderNodes();
//Here is the planet node dispatches a draw event before rendering begins. //Here is the planet node dispatches a draw event before rendering begins.
this.events.dispatch(this.events.draw, this); this.events.dispatch(this.events.draw, this);
this.renderer.activeCamera.prepareFrame();
this.transformLights(); this.transformLights();
this._normalMapCreator.frame(); this._normalMapCreator.frame();
@ -1269,6 +1271,7 @@ class Planet extends RenderNode {
var i = this.visibleVectorLayers.length; var i = this.visibleVectorLayers.length;
while (i--) { while (i--) {
this.visibleVectorLayers[i].collectVisibleCollections(this._frustumEntityCollections);
this.visibleVectorLayers[i].update(); this.visibleVectorLayers[i].update();
} }
@ -1318,8 +1321,8 @@ class Planet extends RenderNode {
* Returns ray vector hit ellipsoid coordinates. * Returns ray vector hit ellipsoid coordinates.
* If the ray doesn't hit ellipsoit returns null. * If the ray doesn't hit ellipsoit returns null.
* @public * @public
* @param {og.math.Ray} ray - Ray 3d. * @param {og.Ray} ray - Ray 3d.
* @returns {og.math.Vector3} - * @returns {og.Vec3} -
*/ */
getRayIntersectionEllipsoid(ray) { getRayIntersectionEllipsoid(ray) {
return this.ellipsoid.hitRay(ray.origin, ray.direction); return this.ellipsoid.hitRay(ray.origin, ray.direction);
@ -1329,7 +1332,7 @@ class Planet extends RenderNode {
* Returns 2d screen coordanates projection point to the planet ellipsoid 3d coordinates. * Returns 2d screen coordanates projection point to the planet ellipsoid 3d coordinates.
* @public * @public
* @param {og.math.Pixel} px - 2D sreen coordinates. * @param {og.math.Pixel} px - 2D sreen coordinates.
* @returns {og.math.Vector3} - * @returns {og.Vec3} -
*/ */
getCartesianFromPixelEllipsoid(px) { getCartesianFromPixelEllipsoid(px) {
var cam = this.renderer.activeCamera; var cam = this.renderer.activeCamera;
@ -1355,7 +1358,7 @@ class Planet extends RenderNode {
* position or null if mouse cursor is outside the planet. * position or null if mouse cursor is outside the planet.
* @public * @public
* @param {Boolean} [force=false] - Force framebuffer rendering. * @param {Boolean} [force=false] - Force framebuffer rendering.
* @returns {og.math.Vector3} - * @returns {og.Vec3} -
*/ */
getCartesianFromMouseTerrain(force) { getCartesianFromMouseTerrain(force) {
var ms = this.renderer.events.mouseState; var ms = this.renderer.events.mouseState;
@ -1370,9 +1373,9 @@ class Planet extends RenderNode {
* Returns 3d cartesian coordinates on the relief planet by 2d screen coordinates. * Returns 3d cartesian coordinates on the relief planet by 2d screen coordinates.
* position or null if input coordinates is outside the planet. * position or null if input coordinates is outside the planet.
* @public * @public
* @param {og.math.Vector2} px - Pixel screen 2d coordinates. * @param {og.Vec2} px - Pixel screen 2d coordinates.
* @param {Boolean} [force=false] - Force framebuffer rendering. * @param {Boolean} [force=false] - Force framebuffer rendering.
* @returns {og.math.Vector3} - * @returns {og.Vec3} -
*/ */
getCartesianFromPixelTerrain(px, force) { getCartesianFromPixelTerrain(px, force) {
var distance = this.getDistanceFromPixel(px, force); var distance = this.getDistanceFromPixel(px, force);
@ -1387,7 +1390,7 @@ class Planet extends RenderNode {
* Returns geographical coordinates on the relief planet by 2d screen coordinates. * Returns geographical coordinates on the relief planet by 2d screen coordinates.
* position or null if input coordinates is outside the planet. * position or null if input coordinates is outside the planet.
* @public * @public
* @param {og.math.Vector2} px - Pixel screen 2d coordinates. * @param {og.Vec2} px - Pixel screen 2d coordinates.
* @param {Boolean} [force=false] - Force framebuffer rendering. * @param {Boolean} [force=false] - Force framebuffer rendering.
* @returns {og.LonLat} - * @returns {og.LonLat} -
*/ */
@ -1402,8 +1405,8 @@ class Planet extends RenderNode {
/** /**
* Returns projected 2d screen coordinates by 3d cartesian coordiantes. * Returns projected 2d screen coordinates by 3d cartesian coordiantes.
* @public * @public
* @param {og.math.Vector3} coords - Cartesian coordinates. * @param {og.Vec3} coords - Cartesian coordinates.
* @returns {og.math.Vector2} - * @returns {og.Vec2} -
*/ */
getPixelFromCartesian(coords) { getPixelFromCartesian(coords) {
return this.renderer.activeCamera.project(coords); return this.renderer.activeCamera.project(coords);
@ -1413,7 +1416,7 @@ class Planet extends RenderNode {
* Returns projected 2d screen coordinates by geographical coordinates. * Returns projected 2d screen coordinates by geographical coordinates.
* @public * @public
* @param {og.LonLat} lonlat - Geographical coordinates. * @param {og.LonLat} lonlat - Geographical coordinates.
* @returns {og.math.Vector2} - * @returns {og.Vec2} -
*/ */
getPixelFromLonLat(lonlat) { getPixelFromLonLat(lonlat) {
var coords = this.ellipsoid.lonLatToCartesian(lonlat); var coords = this.ellipsoid.lonLatToCartesian(lonlat);
@ -1426,7 +1429,7 @@ class Planet extends RenderNode {
* Returns distance from active camera to the the planet ellipsoid * Returns distance from active camera to the the planet ellipsoid
* coordiantes unprojected by 2d screen coordiantes, or null if screen coordinates outside the planet. * coordiantes unprojected by 2d screen coordiantes, or null if screen coordinates outside the planet.
* @public * @public
* @param {og.math.Vector2} px - Screen coordinates. * @param {og.Vec2} px - Screen coordinates.
* @returns {number} - * @returns {number} -
*/ */
getDistanceFromPixelEllipsoid(px) { getDistanceFromPixelEllipsoid(px) {
@ -1440,7 +1443,7 @@ class Planet extends RenderNode {
* If screen coordinates inside the planet but relief is not exists in the * If screen coordinates inside the planet but relief is not exists in the
* point than function returns distance to the planet ellipsoid. * point than function returns distance to the planet ellipsoid.
* @public * @public
* @param {og.math.Vector2} px - Screen coordinates. * @param {og.Vec2} px - Screen coordinates.
* @param {Boolean} [force=false] - Force framebuffer rendering. * @param {Boolean} [force=false] - Force framebuffer rendering.
* @returns {number} - * @returns {number} -
*/ */
@ -1518,7 +1521,7 @@ class Planet extends RenderNode {
* Sets camera to the planet geographical position. * Sets camera to the planet geographical position.
* @public * @public
* @param {og.LonLat} lonlat - New geographical position. * @param {og.LonLat} lonlat - New geographical position.
* @param {og.math.Vector3} [up] - Camera UP vector. * @param {og.Vec3} [up] - Camera UP vector.
*/ */
viewLonLat(lonlat, up) { viewLonLat(lonlat, up) {
this.renderer.activeCamera.setLonLat(lonlat, up); this.renderer.activeCamera.setLonLat(lonlat, up);
@ -1528,7 +1531,7 @@ class Planet extends RenderNode {
* Fly camera to the planet geographical extent. * Fly camera to the planet geographical extent.
* @public * @public
* @param {og.Extent} extent - Geographical extent. * @param {og.Extent} extent - Geographical extent.
* @param {og.math.Vector3} [up] - Camera UP vector on the end of a flying. * @param {og.Vec3} [up] - Camera UP vector on the end of a flying.
*/ */
flyExtent(extent, up) { flyExtent(extent, up) {
this.renderer.activeCamera.flyExtent(extent, up); this.renderer.activeCamera.flyExtent(extent, up);
@ -1537,9 +1540,9 @@ class Planet extends RenderNode {
/** /**
* Fly camera to the new point. * Fly camera to the new point.
* @public * @public
* @param {og.math.Vector3} cartesian - Fly coordiantes. * @param {og.Vec3} cartesian - Fly coordiantes.
* @param {og.math.Vector3} [look] - Camera "look at" point. * @param {og.Vec3} [look] - Camera "look at" point.
* @param {og.math.Vector3} [up] - Camera UP vector on the end of a flying. * @param {og.Vec3} [up] - Camera UP vector on the end of a flying.
*/ */
flyCartesian(cartesian, look, up) { flyCartesian(cartesian, look, up) {
this.renderer.activeCamera.flyCartesian(cartesian, look, up); this.renderer.activeCamera.flyCartesian(cartesian, look, up);
@ -1549,8 +1552,8 @@ class Planet extends RenderNode {
* Fly camera to the new geographical position. * Fly camera to the new geographical position.
* @public * @public
* @param {og.LonLat} lonlat - Fly geographical coordiantes. * @param {og.LonLat} lonlat - Fly geographical coordiantes.
* @param {og.math.Vector3} [look] - Camera "look at" point on the end of a flying. * @param {og.Vec3} [look] - Camera "look at" point on the end of a flying.
* @param {og.math.Vector3} [up] - Camera UP vector on the end of a flying. * @param {og.Vec3} [up] - Camera UP vector on the end of a flying.
*/ */
flyLonLat(lonlat, look, up) { flyLonLat(lonlat, look, up) {
this.renderer.activeCamera.flyLonLat(lonlat, look, up); this.renderer.activeCamera.flyLonLat(lonlat, look, up);

View File

@ -16,7 +16,7 @@ import { TextureAtlas } from '../utils/TextureAtlas.js';
* There are collections of ligh sources, entities and so on in the node. * There are collections of ligh sources, entities and so on in the node.
* Access to the node is renderer.renderNodes["Earth"] * Access to the node is renderer.renderNodes["Earth"]
* @class * @class
* @extends {og.scene.Node} * @extends {og.RenderNode}
* @param {string} name - Node name. * @param {string} name - Node name.
*/ */
class RenderNode extends BaseNode { class RenderNode extends BaseNode {

View File

@ -86,12 +86,6 @@ const Segment = function (node, planet, tileZoom, extent) {
this._seNorm = null; this._seNorm = null;
this._neNorm = null; this._neNorm = null;
/**
* experimental
*/
this._deltaHeight = 0;
/** /**
* Geographical extent. * Geographical extent.
* @type {og.Extent} * @type {og.Extent}
@ -231,7 +225,7 @@ Segment.prototype.acceptForRendering = function (camera) {
* @public * @public
* @param {og.Entity} entity - Entity. * @param {og.Entity} entity - Entity.
* @param {og.Vec3} res - Point coordinates. * @param {og.Vec3} res - Point coordinates.
* @returns {og.math.Vector3} - * @returns {og.Vec3} -
*/ */
Segment.prototype.getEntityTerrainPoint = function (entity, res) { Segment.prototype.getEntityTerrainPoint = function (entity, res) {
return this.getTerrainPoint(res, entity._cartesian, entity._lonlatMerc); return this.getTerrainPoint(res, entity._cartesian, entity._lonlatMerc);
@ -244,8 +238,8 @@ Segment.prototype.isEntityInside = function (e) {
/** /**
* Returns distance from object to terrain coordinates and terrain point that calculates out in the res parameter. * Returns distance from object to terrain coordinates and terrain point that calculates out in the res parameter.
* @public * @public
* @param {og.math.Vector3} res - Result cartesian coordiantes on the terrain. * @param {og.Vec3} res - Result cartesian coordiantes on the terrain.
* @param {og.math.Vector3} xyz - Cartesian object position. * @param {og.Vec3} xyz - Cartesian object position.
* @param {og.LonLat} insideSegmentPosition - Geodetic object position. * @param {og.LonLat} insideSegmentPosition - Geodetic object position.
* @returns {number} - * @returns {number} -
*/ */
@ -287,9 +281,16 @@ Segment.prototype.getTerrainPoint = function (res, xyz, insideSegmentPosition) {
v1 = new Vec3(verts[ind_v0 + 3], verts[ind_v0 + 4], verts[ind_v0 + 5]), v1 = new Vec3(verts[ind_v0 + 3], verts[ind_v0 + 4], verts[ind_v0 + 5]),
v2 = new Vec3(verts[ind_v2], verts[ind_v2 + 1], verts[ind_v2 + 2]); v2 = new Vec3(verts[ind_v2], verts[ind_v2 + 1], verts[ind_v2 + 2]);
var d = ray.hitTriangle(v0, v1, v2, res); let d = ray.hitTriangle(v0, v1, v2, res);
if (d === Ray.INSIDE) { if (d === Ray.INSIDE) {
return xyz.distance(res); return xyz.distance(res);
} else if (d === Ray.AWAY) {
let ray = new Ray(xyz, xyz);
let d = ray.hitTriangle(v0, v1, v2, res);
if (d === Ray.INSIDE) {
return -xyz.distance(res);
}
} }
var v3 = new Vec3(verts[ind_v2 + 3], verts[ind_v2 + 4], verts[ind_v2 + 5]); var v3 = new Vec3(verts[ind_v2 + 3], verts[ind_v2 + 4], verts[ind_v2 + 5]);
@ -297,6 +298,12 @@ Segment.prototype.getTerrainPoint = function (res, xyz, insideSegmentPosition) {
d = ray.hitTriangle(v1, v3, v2, res); d = ray.hitTriangle(v1, v3, v2, res);
if (d === Ray.INSIDE) { if (d === Ray.INSIDE) {
return xyz.distance(res); return xyz.distance(res);
} else if (d === Ray.AWAY) {
let ray = new Ray(xyz, xyz);
let d = ray.hitTriangle(v1, v3, v2, res);
if (d === Ray.INSIDE) {
return -xyz.distance(res);
}
} }
if (d === Ray.AWAY) { if (d === Ray.AWAY) {
@ -1163,7 +1170,7 @@ Segment.prototype._createPlainVertices = function () {
/** /**
* Gets specific layer material. * Gets specific layer material.
* @public * @public
* @param {og.layer.Layer} layer - Layer object. * @param {og.Layer} layer - Layer object.
* @returns {og.planetSegment.Material} - Segment material. * @returns {og.planetSegment.Material} - Segment material.
*/ */
Segment.prototype.getMaterialByLayer = function (layer) { Segment.prototype.getMaterialByLayer = function (layer) {

View File

@ -12,9 +12,9 @@ import { Mat4 } from '../math/Mat4.js';
* Base geometry shape class. * Base geometry shape class.
* @class * @class
* @param {Object} options - Shape parameters: * @param {Object} options - Shape parameters:
* @param {og.math.Vector3} [options.position] - Shape position. * @param {og.Vec3} [options.position] - Shape position.
* @param {og.math.Quaternion} [options.orientation] - Shape orientation(rotation). * @param {og.Quat} [options.orientation] - Shape orientation(rotation).
* @param {og.math.Vector3} [options.scale] - Scale vector. * @param {og.Vec3} [options.scale] - Scale vector.
* @param {Array.<number,number,number,number>} [options.color] - Shape RGBA color. * @param {Array.<number,number,number,number>} [options.color] - Shape RGBA color.
* @param {string} [options.src] - Texture image url source. * @param {string} [options.src] - Texture image url source.
* @param {boolean} [options.visibility] - Shape visibility. * @param {boolean} [options.visibility] - Shape visibility.
@ -36,21 +36,21 @@ class BaseShape {
/** /**
* Shape position. * Shape position.
* @public * @public
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this.position = options.position || new Vec3(); this.position = options.position || new Vec3();
/** /**
* Shape orientation(rotation) * Shape orientation(rotation)
* @public * @public
* @type {og.math.Quaternion} * @type {og.Quat}
*/ */
this.orientation = options.orientation || new Quat(0.0, 0.0, 0.0, 1.0); this.orientation = options.orientation || new Quat(0.0, 0.0, 0.0, 1.0);
/** /**
* Scale. * Scale.
* @public * @public
* @type {og.math.Vector3} * @type {og.Vec3}
*/ */
this.scale = options.scale || new Vec3(1.0, 1.0, 1.0); this.scale = options.scale || new Vec3(1.0, 1.0, 1.0);
@ -130,21 +130,21 @@ class BaseShape {
/** /**
* Scale matrix. * Scale matrix.
* @protected * @protected
* @type {og.math.Matrix4} * @type {og.Mat4}
*/ */
this._mxScale = new Mat4().setIdentity(); this._mxScale = new Mat4().setIdentity();
/** /**
* Translation matrix. * Translation matrix.
* @protected * @protected
* @type {og.math.Matrix4} * @type {og.Mat4}
*/ */
this._mxTranslation = new Mat4().setIdentity(); this._mxTranslation = new Mat4().setIdentity();
/** /**
* Model matrix. * Model matrix.
* @protected * @protected
* @type {og.math.Matrix4} * @type {og.Mat4}
*/ */
this._mxModel = new Mat4().setIdentity(); this._mxModel = new Mat4().setIdentity();
@ -240,7 +240,7 @@ class BaseShape {
/** /**
* Sets shape color. * Sets shape color.
* @public * @public
* @param {og.math.Vector4} color - RGBA color vector. * @param {og.Vec4} color - RGBA color vector.
*/ */
setColor4v(color) { setColor4v(color) {
this.color[0] = color.x; this.color[0] = color.x;
@ -314,7 +314,7 @@ class BaseShape {
/** /**
* Sets shape position. * Sets shape position.
* @public * @public
* @param {og.math.Vector3} position - Shape position. * @param {og.Vec3} position - Shape position.
*/ */
setPosition3v(position) { setPosition3v(position) {
this.position.copy(position); this.position.copy(position);
@ -325,7 +325,7 @@ class BaseShape {
/** /**
* Translate shape position to vector. * Translate shape position to vector.
* @public * @public
* @param {og.math.Vector3} vec - Translation vector. * @param {og.Vec3} vec - Translation vector.
*/ */
translate3v(vec) { translate3v(vec) {
this.position.addA(vec); this.position.addA(vec);
@ -334,7 +334,7 @@ class BaseShape {
/** /**
* Sets shape scale. * Sets shape scale.
* @param {og.math.Vector3} scale - Scale vector. * @param {og.Vec3} scale - Scale vector.
*/ */
setScale3v(scale) { setScale3v(scale) {
this.scale.copy(scale); this.scale.copy(scale);
@ -353,7 +353,7 @@ class BaseShape {
/** /**
* Assign picking color. * Assign picking color.
* @protected * @protected
* @param {og.math.Vector3} color - Picking RGB color. * @param {og.Vec3} color - Picking RGB color.
*/ */
setPickingColor3v(color) { setPickingColor3v(color) {
//... //...

View File

@ -10,9 +10,9 @@ import { BaseShape } from './BaseShape.js';
* @class * @class
* @extends {og.shape.BaseShape} * @extends {og.shape.BaseShape}
* @param {Object} options - Icosphere parameters: * @param {Object} options - Icosphere parameters:
* @param {og.math.Vector3} [options.position] - Icosphere position. * @param {og.Vec3} [options.position] - Icosphere position.
* @param {og.math.Quaternion} [options.orientation] - Icosphere orientation(rotation). * @param {og.Quat} [options.orientation] - Icosphere orientation(rotation).
* @param {og.math.Vector3} [options.scale] - Scale vector. * @param {og.Vec3} [options.scale] - Scale vector.
* @param {Array.<number,number,number,number>} [options.color] - Icosphere RGBA color. * @param {Array.<number,number,number,number>} [options.color] - Icosphere RGBA color.
* @param {string} [options.src] - Texture image url source. * @param {string} [options.src] - Texture image url source.
* @param {boolean} [options.visibility] - Icosphere visibility. * @param {boolean} [options.visibility] - Icosphere visibility.

View File

@ -10,9 +10,9 @@ import { BaseShape } from './BaseShape.js';
* @class * @class
* @extends {og.shape.BaseShape} * @extends {og.shape.BaseShape}
* @param {Object} options - Sphere parameters: * @param {Object} options - Sphere parameters:
* @param {og.math.Vector3} [options.position] - Sphere position. * @param {og.Vec3} [options.position] - Sphere position.
* @param {og.math.Quaternion} [options.orientation] - Sphere orientation(rotation). * @param {og.Quat} [options.orientation] - Sphere orientation(rotation).
* @param {og.math.Vector3} [options.scale] - Scale vector. * @param {og.Vec3} [options.scale] - Scale vector.
* @param {Array.<number,number,number,number>} [options.color] - Sphere RGBA color. * @param {Array.<number,number,number,number>} [options.color] - Sphere RGBA color.
* @param {string} [options.src] - Texture image url source. * @param {string} [options.src] - Texture image url source.
* @param {boolean} [options.visibility] - Sphere visibility. * @param {boolean} [options.visibility] - Sphere visibility.

View File

@ -29,14 +29,14 @@ class EmptyTerrain {
* @public * @public
* @type {number} * @type {number}
*/ */
this.minZoom = 50; this.minZoom = 1000000;
/** /**
* Maximal z-index value for segment elevation data handling. * Maximal z-index value for segment elevation data handling.
* @public * @public
* @type {number} * @type {number}
*/ */
this.maxZoom = 50; this.maxZoom = 21;
/** /**
* @public * @public

View File

@ -15,13 +15,13 @@ import { stringTemplate } from '../utils/shared.js';
const EVENT_NAMES = [ const EVENT_NAMES = [
/** /**
* Triggered when current elevation tile has loaded but before rendereing. * Triggered when current elevation tile has loaded but before rendereing.
* @event og.terrainProvider.TerrainProvider#load * @event og.terrain.GlobusTerrain#load
*/ */
"load", "load",
/** /**
* Triggered when all elevation tiles have loaded or loading has stopped. * Triggered when all elevation tiles have loaded or loading has stopped.
* @event og.terrainProvider.TerrainProvider#loadend * @event og.terrain.GlobusTerrain#loadend
*/ */
"loadend" "loadend"
]; ];
@ -29,7 +29,7 @@ const EVENT_NAMES = [
/** /**
* Class that loads segment elevation data, converts it to the array and passes it to the planet segment. * Class that loads segment elevation data, converts it to the array and passes it to the planet segment.
* @class * @class
* @extends {og.terrainProvider.EmptyTerrainProvider} * @extends {og.terrain.EmptyTerrain}
* @param {string} [name=""] - Terrain provider name. * @param {string} [name=""] - Terrain provider name.
* @param {Object} [options] - Provider options: * @param {Object} [options] - Provider options:
* @param {number} [options.minZoom=3] - Minimal visible zoom index when terrain handler works. * @param {number} [options.minZoom=3] - Minimal visible zoom index when terrain handler works.
@ -39,8 +39,8 @@ const EVENT_NAMES = [
* @param {number} [options.fileGridSize=32] - Elevation tile grid size. Default is 32x32. * @param {number} [options.fileGridSize=32] - Elevation tile grid size. Default is 32x32.
* @param {string} [options.responseType="arraybuffer"] - Ajax responce type. * @param {string} [options.responseType="arraybuffer"] - Ajax responce type.
* @param {number} [options.MAX_LOADING_TILES] - Maximum at one time loading tiles. * @param {number} [options.MAX_LOADING_TILES] - Maximum at one time loading tiles.
* @fires og.terrainProvider.TerrainProvider#load * @fires og.terrain.GlobusTerrain#load
* @fires og.terrainProvider.TerrainProvider#loadend * @fires og.terrain.GlobusTerrain#loadend
*/ */
class GlobusTerrain extends EmptyTerrain { class GlobusTerrain extends EmptyTerrain {
constructor(name, options) { constructor(name, options) {
@ -109,7 +109,7 @@ class GlobusTerrain extends EmptyTerrain {
/** /**
* Rewrites elevation storage url query. * Rewrites elevation storage url query.
* @private * @private
* @callback og.terrainProvider.TerrainProvider~_urlRewriteCallback * @callback og.terrain.GlobusTerrain~_urlRewriteCallback
* @param {og.planetSegment.Segment} segment - Segment to load. * @param {og.planetSegment.Segment} segment - Segment to load.
* @param {string} url - Created url. * @param {string} url - Created url.
* @returns {string} - Url query string. * @returns {string} - Url query string.
@ -217,7 +217,7 @@ class GlobusTerrain extends EmptyTerrain {
/** /**
* Sets url rewrite callback, used for custom url rewriting for every tile laoding. * Sets url rewrite callback, used for custom url rewriting for every tile laoding.
* @public * @public
* @param {og.terrainProvider.TerrainProvider~_urlRewriteCallback} ur - The callback that returns tile custom created url. * @param {og.terrain.GlobusTerrain~_urlRewriteCallback} ur - The callback that returns tile custom created url.
*/ */
setUrlRewriteCallback(ur) { setUrlRewriteCallback(ur) {
this._urlRewriteCallback = ur; this._urlRewriteCallback = ur;

View File

@ -91,7 +91,7 @@ export function htmlColorToRgba(htmlColor, opacity) {
* Convert html color string to the RGB number vector. * Convert html color string to the RGB number vector.
* @param {string} htmlColor - HTML string("#C6C6C6" or "#EF5" or "rgb(8,8,8)" or "rgba(8,8,8)") color. * @param {string} htmlColor - HTML string("#C6C6C6" or "#EF5" or "rgb(8,8,8)" or "rgba(8,8,8)") color.
* @param {number} [opacity] - Opacity for the output vector. * @param {number} [opacity] - Opacity for the output vector.
* @returns {og.math.Vec3} - * @returns {og.Vec3} -
*/ */
export function htmlColorToRgb(htmlColor) { export function htmlColorToRgb(htmlColor) {
var hColor = colorTable[htmlColor]; var hColor = colorTable[htmlColor];

View File

@ -421,7 +421,7 @@ Handler.prototype.loadCubeMapTexture = function (params) {
/** /**
* Adds shader program to the handler. * Adds shader program to the handler.
* @public * @public
* @param {og.shaderProgram.ShaderProgram} program - Shader program. * @param {og.webgl.ShaderProgram} program - Shader program.
* @param {boolean} [notActivate] - If it's true program will not compile. * @param {boolean} [notActivate] - If it's true program will not compile.
*/ */
Handler.prototype.addShaderProgram = function (program, notActivate) { Handler.prototype.addShaderProgram = function (program, notActivate) {
@ -449,7 +449,7 @@ Handler.prototype.removeShaderProgram = function (name) {
/** /**
* Adds shader programs to the handler. * Adds shader programs to the handler.
* @public * @public
* @param {Array.<og.shaderProgram.ShaderProgram>} programsArr - Shader program array. * @param {Array.<og.webgl.ShaderProgram>} programsArr - Shader program array.
*/ */
Handler.prototype.addShaderPrograms = function (programsArr) { Handler.prototype.addShaderPrograms = function (programsArr) {
for (var i = 0; i < programsArr.length; i++) { for (var i = 0; i < programsArr.length; i++) {

View File

@ -10,14 +10,14 @@
* Get access to the program from ...handler.shaderPrograms.<program name> etc. * Get access to the program from ...handler.shaderPrograms.<program name> etc.
* @class * @class
* @param {og.webgl.Handler} handler - Handler. * @param {og.webgl.Handler} handler - Handler.
* @param {og.shaderProgram.ShaderProgram} shaderProgram - Shader program. * @param {og.webgl.ShaderProgram} shaderProgram - Shader program.
*/ */
const ShaderController = function (handler, shaderProgram) { const ShaderController = function (handler, shaderProgram) {
/** /**
* Shader program. * Shader program.
* @private * @private
* @type {og.shaderProgram.ShaderProgram} * @type {og.webgl.ShaderProgram}
*/ */
this._program = shaderProgram; this._program = shaderProgram;
@ -48,7 +48,7 @@ ShaderController.prototype.initialize = function () {
/** /**
* Returns controller's shader program. * Returns controller's shader program.
* @public * @public
* @return {og.shaderProgram.ShaderProgram} - * @return {og.webgl.ShaderProgram} -
*/ */
ShaderController.prototype.getProgram = function () { ShaderController.prototype.getProgram = function () {
return this._program; return this._program;

View File

@ -329,7 +329,7 @@ class ShaderProgram {
/** /**
* Bind program buffer. * Bind program buffer.
* @function * @function
* @param {og.shaderProgram.ShaderProgram} program - Used program. * @param {og.webgl.ShaderProgram} program - Used program.
* @param {Object} variable - Variable represents buffer data. * @param {Object} variable - Variable represents buffer data.
*/ */
static bindBuffer(program, variable) { static bindBuffer(program, variable) {