eslint rules

This commit is contained in:
Thibaut Lassalle 2021-10-16 04:20:59 -07:00
parent e06268fe6f
commit bf95fc3ec6
90 changed files with 498 additions and 496 deletions

View File

@ -9,6 +9,5 @@ module.exports = {
"sourceType": "module"
},
"rules": {
"no-extra-semi": "off"
}
};

5
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint"
]
}

View File

@ -189,6 +189,6 @@ class Clock {
equal(clock) {
return this._id === clock._id;
}
};
}
export { Clock };

View File

@ -8,4 +8,4 @@ export function Deferred() {
this.reject = reject;
}.bind(this));
Object.freeze(this);
};
}

View File

@ -181,6 +181,6 @@ class Events {
this._eventNames.length = 0;
this._eventNames = [];
}
};
}
export { Events };

View File

@ -57,7 +57,7 @@ export class Extent {
*/
static createFromArray(arr) {
return new Extent(new LonLat(arr[0], arr[1]), new LonLat(arr[2], arr[3]));
};
}
/**
* Creates bound extent instance by coordinate array.
@ -76,7 +76,7 @@ export class Extent {
if (vi.lat > latmax) latmax = vi.lat;
}
return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
};
}
/**
* Creates bound extent instance by coordinate array.
@ -95,7 +95,7 @@ export class Extent {
if (vi[1] > latmax) latmax = vi[1];
}
return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
};
}
/**
* Creates extent by meractor grid tile coordinates.
@ -121,7 +121,7 @@ export class Extent {
right = left + lnSize;
return new Extent(new LonLat(left, bottom), new LonLat(right, top));
};
}
/**
* Sets current bounding extent object by coordinate array.
@ -144,7 +144,7 @@ export class Extent {
this.northEast.lon = lonmax;
this.northEast.lat = latmax;
return this;
};
}
/**
* Determines if point inside extent.
@ -157,7 +157,7 @@ export class Extent {
ne = this.northEast;
return lonlat.lon >= sw.lon && lonlat.lon <= ne.lon &&
lonlat.lat >= sw.lat && lonlat.lat <= ne.lat;
};
}
/**
* Returns true if two extent overlap each other.
@ -170,7 +170,7 @@ export class Extent {
ne = this.northEast;
return sw.lon <= e.northEast.lon && ne.lon >= e.southWest.lon &&
sw.lat <= e.northEast.lat && ne.lat >= e.southWest.lat;
};
}
/**
* Gets extent width.
@ -179,7 +179,7 @@ export class Extent {
*/
getWidth() {
return this.northEast.lon - this.southWest.lon;
};
}
/**
* Gets extent height.
@ -188,7 +188,7 @@ export class Extent {
*/
getHeight() {
return this.northEast.lat - this.southWest.lat;
};
}
/**
* Creates clone instance of the current extent.
@ -197,7 +197,7 @@ export class Extent {
*/
clone() {
return new Extent(this.southWest.clone(), this.northEast.clone());
};
}
/**
* Gets the center coordinate of the extent.
@ -207,57 +207,57 @@ export class Extent {
getCenter() {
const sw = this.southWest, ne = this.northEast;
return new LonLat(sw.lon + (ne.lon - sw.lon) * 0.5, sw.lat + (ne.lat - sw.lat) * 0.5);
};
}
/**
* @public
*/
getNorthWest() {
return new LonLat(this.southWest.lon, this.northEast.lat);
};
}
/**
* @public
*/
getNorthEast() {
return new LonLat(this.northEast.lon, this.northEast.lat);
};
}
getSouthWest() {
return new LonLat(this.southWest.lon, this.southWest.lat);
};
}
/**
* @public
*/
getSouthEast() {
return new LonLat(this.northEast.lon, this.southWest.lat);
};
}
/**
* @public
*/
getNorth() {
return this.northEast.lat;
};
}
getEast() {
return this.northEast.lon;
};
}
/**
* @public
*/
getWest() {
return this.southWest.lon;
};
}
/**
* @public
*/
getSouth() {
return this.southWest.lat;
};
}
/**
* Returns extents are equals.
@ -267,7 +267,7 @@ export class Extent {
equals(extent) {
return this.southWest.lon === extent.southWest.lon && this.southWest.lat === extent.southWest.lat &&
this.northEast.lon === extent.northEast.lon && this.northEast.lat === extent.northEast.lat;
};
}
/**
* Converts extent coordinates to mercator projection coordinates.
@ -276,7 +276,7 @@ export class Extent {
*/
forwardMercator() {
return new Extent(this.southWest.forwardMercator(), this.northEast.forwardMercator());
};
}
/**
* Converts extent coordinates from mercator projection to degrees.
@ -285,7 +285,7 @@ export class Extent {
*/
inverseMercator() {
return new Extent(this.southWest.inverseMercator(), this.northEast.inverseMercator());
};
}
/**
* Gets cartesian bounding bounds of the current ellipsoid.
@ -314,10 +314,10 @@ export class Extent {
}
return [xmin, ymin, zmin, xmax, ymax, zmax];
};
}
toString() {
return "[" + this.southWest.lon + ", " + this.southWest.lat + ", " + this.northEast.lon + ", " + this.northEast.lat + "]";
};
}
}

View File

@ -4,21 +4,19 @@
"use strict";
import { EmptyTerrain } from "./terrain/EmptyTerrain.js";
import { Handler } from "./webgl/Handler.js";
import { Planet } from "./scene/Planet.js";
import { Renderer } from "./renderer/Renderer.js";
import { wgs84 } from "./ellipsoid/wgs84.js";
import { isEmpty } from "./utils/shared.js";
import { EarthCoordinates } from "./control/EarthCoordinates.js";
import { MouseNavigation } from "./control/MouseNavigation.js";
import { EarthNavigation } from "./control/EarthNavigation.js";
import { TouchNavigation } from "./control/TouchNavigation.js";
import { Sun } from "./control/Sun.js";
import { ZoomControl } from "./control/ZoomControl.js";
import { ScaleControl } from "./control/ScaleControl.js";
import { CompassButton } from "./control/CompassButton.js";
import { EarthCoordinates } from "./control/EarthCoordinates.js";
import { EarthNavigation } from "./control/EarthNavigation.js";
import { MouseNavigation } from "./control/MouseNavigation.js";
import { ScaleControl } from "./control/ScaleControl.js";
import { Sun } from "./control/Sun.js";
import { TouchNavigation } from "./control/TouchNavigation.js";
import { ZoomControl } from "./control/ZoomControl.js";
import { Renderer } from "./renderer/Renderer.js";
import { Planet } from "./scene/Planet.js";
import { EmptyTerrain } from "./terrain/EmptyTerrain.js";
import { isEmpty } from "./utils/shared.js";
import { Handler } from "./webgl/Handler.js";
/** @const {string} */
const CANVAS_ID_PREFIX = "globus_viewport_";
@ -183,8 +181,8 @@ class Globe {
options.useEarthNavigation
? new EarthNavigation()
: new MouseNavigation({
minSlope: options.minSlope
}),
minSlope: options.minSlope
}),
new TouchNavigation(),
new EarthCoordinates(),
new ScaleControl(),

View File

@ -78,7 +78,7 @@ class ImageCanvas {
fillColor(color) {
this._context.fillStyle = color;
this._context.fillRect(0, 0, this._canvas.width, this._canvas.height);
};
}
/**
* Sets RGBA pixel data.
@ -218,6 +218,6 @@ class ImageCanvas {
this._canvas = null;
this._context = null;
}
};
}
export { ImageCanvas };

View File

@ -25,7 +25,7 @@ class Lock {
isLocked() {
return this._lock !== 0;
}
};
}
class Key {
@ -43,6 +43,6 @@ class Key {
constructor() {
this._id = Key._staticCounter++;
}
};
}
export { Lock, Key };

View File

@ -48,11 +48,11 @@ export class LonLat {
* @type {number}
*/
this.height = height || 0;
};
}
isZero() {
return this.lon === 0.0 && this.lat === 0.0 && this.height === 0.0;
};
}
/**
* Creates coordinates array.
@ -67,7 +67,7 @@ export class LonLat {
res[i] = new LonLat(ai[0], ai[1], ai[2]);
}
return res;
};
}
/**
* Creates an object by coordinate array.
@ -77,7 +77,7 @@ export class LonLat {
*/
static createFromArray(arr) {
return new LonLat(arr[0], arr[1], arr[2]);
};
}
/**
* Converts degrees to mercator coordinates.
@ -91,7 +91,7 @@ export class LonLat {
return new LonLat(lon * mercator.POLE_BY_180,
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI,
height);
};
}
/**
* Converts mercator to degrees coordinates.
@ -105,7 +105,7 @@ export class LonLat {
return new LonLat(x * mercator.INV_POLE_BY_180,
INV_PI_BY_360 * Math.atan(Math.exp(y * mercator.PI_BY_POLE)) - INV_PI_BY_180_HALF_PI,
height);
};
}
/**
* Sets coordinates.
@ -120,7 +120,7 @@ export class LonLat {
this.lat = lat || 0;
this.height = height || 0;
return this;
};
}
/**
* Copy coordinates.
@ -133,7 +133,7 @@ export class LonLat {
this.lat = lonLat.lat;
this.height = lonLat.height;
return this;
};
}
/**
* Clone the coordiante.
@ -142,7 +142,7 @@ export class LonLat {
*/
clone() {
return new LonLat(this.lon, this.lat, this.height);
};
}
/**
* Converts to mercator coordinates.
@ -151,7 +151,7 @@ export class LonLat {
*/
forwardMercator() {
return LonLat.forwardMercator(this.lon, this.lat, this.height);
};
}
forwardMercatorEPS01() {
var lat = this.lat;
@ -163,7 +163,7 @@ export class LonLat {
return new LonLat(
this.lon * mercator.POLE_BY_180,
Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * mercator.POLE_BY_PI);
};
}
/**
* Converts from mercator coordinates.
@ -172,7 +172,7 @@ export class LonLat {
*/
inverseMercator() {
return LonLat.inverseMercator(this.lon, this.lat, this.height);
};
}
/**
* Compares coordinates.
@ -186,5 +186,5 @@ export class LonLat {
} else {
return this.lon === b.lon && this.lat === b.lat;
}
};
}
}

View File

@ -104,7 +104,7 @@ class Popup {
this.setTitle(this._title);
this.setLonLat(this._lonLat);
this.setVisibility(this._visibility);
this.el.querySelector(".og-popup-close").addEventListener("click", (e) => {
this.el.querySelector(".og-popup-close").addEventListener("click", () => {
this.hide();
});
return this;

View File

@ -66,6 +66,6 @@ class QueueArray {
callback(this._array[i]);
}
}
};
}
export { QueueArray };

View File

@ -10,7 +10,7 @@ class Node {
this.prev = null;
this.data = null;
}
};
}
class Stack {
constructor(size = 256) {
@ -34,7 +34,7 @@ class Stack {
push(data) {
this._current = this._current.next;
this._current.data = data;
};
}
pop(data) {
this._current = this._current.prev;
@ -45,6 +45,6 @@ class Stack {
this._current = this._current.prev;
return this._current.data;
}
};
}
export { Stack };

View File

@ -104,7 +104,7 @@ function createXMLHttp() {
}
}
}
};
}
/**
* Send an ajax request.

View File

@ -48,4 +48,4 @@ export function TAItoTDB(tai) {
tai += og.astro.TDT_TAI * jd.ONE_BY_SECONDS_PER_DAY;
var g = 6.239996 + 0.0172019696544 * (tai - jd.J2000);
return tai + 0.001658 * Math.sin(g + 1.671e-2 * Math.sin(g)) * jd.ONE_BY_SECONDS_PER_DAY;
};
}

View File

@ -107,4 +107,4 @@ export function getSunPosition(jDate) {
// Convert to RA and Decl
// var RA = Math.atan2(yequat, xequat) * math.DEGREES;
// var Decl = Math.atan2(zequat, Math.sqrt(xequat * xequat + yequat * yequat)) * math.DEGREES;
};
}

View File

@ -160,7 +160,7 @@ export const J2000 = 2451545.0;
*/
export function T(jd) {
return (jd - J2000) / DAYS_PER_JULIAN_CENTURY;
};
}
/**
* Gets the date's julian day.
@ -174,7 +174,7 @@ export function getDayNumber(year, month, day) {
var b = year + 4800 + a;
return (((1461 * b) / 4) | 0) + (((367 * (month - 2 - 12 * a)) / 12) | 0) -
(((3 * (((b + 100) / 100) | 0)) / 4) | 0) + day - 32075;
};
}
/**
* Converts javascript date to the universal(UTC) julian date.
@ -208,7 +208,7 @@ export function DateToUTC(date) {
}
return dayNumber + secondsOfDay * ONE_BY_SECONDS_PER_DAY;
};
}
/**
* Converts javascript date to the atomic(TAI) julian date.
@ -217,7 +217,7 @@ export function DateToUTC(date) {
*/
export function DateToTAI(date) {
return UTCtoTAI(DateToUTC(date));
};
}
/**
* Converts coordinated universal(UTC) julian date to atomic(TAI) julian date.
@ -248,7 +248,7 @@ export function UTCtoTAI(jd) {
}
return jd + offset * ONE_BY_SECONDS_PER_DAY;
};
}
/**
* Converts atomic julian date(TAI) to the coordinated universal(UTC) julian date.
@ -284,7 +284,7 @@ export function TAItoUTC(tai) {
}
return tai - leapSeconds[index - 1].leapSeconds * ONE_BY_SECONDS_PER_DAY;
};
}
/**
* Converts UTC julian date to the javascript date object.
@ -323,7 +323,7 @@ export function UTCtoDate(utc) {
}
return new Date(Date.UTC(year, month - 1, day, hour, minute, second, millisecond));
};
}
/**
* Converts TAI julian date to the javascript date object.
@ -339,7 +339,7 @@ export function TAItoDate(tai) {
}
return UTCtoDate(utc);
};
}
/**
* Adds milliseconds to the julian date.
@ -349,7 +349,7 @@ export function TAItoDate(tai) {
*/
export function addMilliseconds(jd, milliseconds) {
return jd + milliseconds * ONE_BY_MILLISECONDS_PER_DAY;
};
}
/**
* Adds seconds to the julian date.
@ -359,7 +359,7 @@ export function addMilliseconds(jd, milliseconds) {
*/
export function addSeconds(jd, seconds) {
return jd + seconds * ONE_BY_SECONDS_PER_DAY;
};
}
/**
* Adds hours to the julian date.
@ -369,7 +369,7 @@ export function addSeconds(jd, seconds) {
*/
export function addHours(jd, hours) {
return jd + hours * ONE_BY_HOURS_PER_DAY;
};
}
/**
* Adds minutes to the julian date.
@ -379,7 +379,7 @@ export function addHours(jd, hours) {
*/
export function addMinutes(jd, minutes) {
return jd + minutes * MINUTES_PER_DAY;
};
}
/**
* Adds days to the julian date.
@ -389,7 +389,7 @@ export function addMinutes(jd, minutes) {
*/
export function addDays(jd, days) {
return jd + days;
};
}
/**
* Gets milliseconds of a julian date.
@ -400,7 +400,7 @@ export function getMilliseconds(jd) {
var s = jd - (jd | 0);
s *= SECONDS_PER_DAY;
return (s - (s | 0)) * MILLISECONDS_PER_SECOND | 0;
};
}
/**
* Gets seconds of a julian date.
@ -410,7 +410,7 @@ export function getMilliseconds(jd) {
export function getSeconds(jd) {
var s = jd - (jd | 0);
return s * SECONDS_PER_DAY;
};
}
/**
* Gets hours of a julian date.
@ -434,7 +434,7 @@ export function getHours(jd) {
}
return hour;
};
}
/**
* Gets minutes of a julian date.
@ -444,7 +444,7 @@ export function getHours(jd) {
export function getMinutes(jd) {
var s = jd - (jd | 0);
return s * MINUTES_PER_DAY | 0;
};
}
/**
* Gets days of a julian date.
@ -453,7 +453,7 @@ export function getMinutes(jd) {
*/
export function getDays(jd) {
return jd | 0;
};
}
/**
* Returns days in seconds.
@ -462,7 +462,7 @@ export function getDays(jd) {
*/
export function secondsToDays(s) {
return s * ONE_BY_SECONDS_PER_DAY;
};
}
/**
* Returns seconds in days.
@ -471,14 +471,14 @@ export function secondsToDays(s) {
*/
export function daysToSeconds(d) {
return d * SECONDS_PER_DAY;
};
}
function __ls(jd, leapSeconds) {
return {
jd: jd,
leapSeconds: leapSeconds
};
};
}
const leapSecondsTable = [
__ls(2441317.5, 10.0), // 1972-01-01T00:00:00.000Z

View File

@ -32,14 +32,14 @@ export function getEccentricAnomaly(M, ecc) {
let E = log(2 * M / ecc + 1.85);
return math.solve_iteration_fixed(solveKeplerLaguerreConwayHyp(ecc, M), E, 30);
}
};
}
// Standard iteration for solving Kepler's Equation
function solveKeplerFunc1(ecc, M) {
return function (x) {
return M + ecc * Math.sin(x);
};
};
}
// Faster converging iteration for Kepler's Equation; more efficient
// than above for orbits with eccentricities greater than 0.3. This
@ -48,7 +48,7 @@ function solveKeplerFunc2(ecc, M) {
return function (x) {
return x + (M + ecc * Math.sin(x) - x) / (1 - ecc * Math.cos(x));
};
};
}
function solveKeplerLaguerreConway(ecc, M) {
return function (x) {
@ -60,7 +60,7 @@ function solveKeplerLaguerreConway(ecc, M) {
x += -5 * f / (f1 + Math.sign(f1) * Math.sqrt(abs(16 * f1 * f1 - 20 * f * f2)));
return x;
};
};
}
function solveKeplerLaguerreConwayHyp(ecc, M) {
return function (x) {
@ -72,7 +72,7 @@ function solveKeplerLaguerreConwayHyp(ecc, M) {
x += -5 * f / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
return x;
};
};
}
export function getEllipticalEccentricAnomaly(meanAnomaly, eccentricity) {
var tol = 0.00000001745;
@ -86,7 +86,7 @@ export function getEllipticalEccentricAnomaly(meanAnomaly, eccentricity) {
iterations--;
}
return e;
};
}
export function getTrueAnomaly(eccentricAnomaly, eccentricity) {
var revs = Math.floor(eccentricAnomaly / math.TWO_PI);
@ -98,7 +98,7 @@ export function getTrueAnomaly(eccentricAnomaly, eccentricity) {
trueAnomaly -= math.TWO_PI;
}
return trueAnomaly + revs * math.TWO_PI;
};
}
export function getPerifocalToCartesianMatrix(argumentOfPeriapsis, inclination, rightAscension) {
var res = new Mat3();
@ -118,4 +118,4 @@ export function getPerifocalToCartesianMatrix(argumentOfPeriapsis, inclination,
res._m[7] = -cosraan * sini;
res._m[8] = cosi;
return res;
};
}

View File

@ -28,4 +28,4 @@ export function getRotationMatrix(rightAscension, declination) {
res._m[8] = zAxis.z;
return result;
};
}

View File

@ -53,6 +53,6 @@ class Sphere {
setFromExtent(ellipsoid, extent) {
this.setFromBounds(extent.getCartesianBounds(ellipsoid));
}
};
}
export { Sphere };

View File

@ -315,6 +315,6 @@ class Frustum {
return result;
}
};
}
export { Frustum };

View File

@ -181,6 +181,6 @@ class Control {
isEqual(control) {
return control._id === this._id;
}
};
}
export { Control };

View File

@ -15,7 +15,7 @@ function dec2deg(base) {
return (numToFixedString(degrees, 3) + "\u00B0" +
numToFixedString(minutes, 2) + "\u0027" +
numToFixedString(seconds.toFixed(2), 2) + "\u0022");
};
}
function numToFixedString(num, fixed) {
var dl = num.toString().split('.')[0].length;
@ -24,20 +24,20 @@ function numToFixedString(num, fixed) {
white += '&nbsp;&nbsp;';
}
return white + num.toString();
};
}
function toDecimal(ll) {
return ll.lat.toFixed(5) + ", " + ll.lon.toFixed(5);
};
}
function toDegrees(ll) {
return dec2deg(ll.lat) + ", " + dec2deg(ll.lon);
};
}
function toMercator(ll) {
var m = ll.forwardMercator();
return m.lat.toFixed(5) + ", " + m.lon.toFixed(5);
};
}
const DisplayTypesConverters = [
toDecimal,
@ -121,7 +121,7 @@ class EarthCoordinates extends Control {
}
that._converter = DisplayTypesConverters[that._displayType];
that._showPosition();
};
}
this._display.onclick = function (e) {
that._displayType += 1;
@ -192,10 +192,10 @@ class EarthCoordinates extends Control {
this._showPosition();
}
}
};
}
export function earthCoordinates(options) {
return new EarthCoordinates(options);
};
}
export { EarthCoordinates };

View File

@ -71,6 +71,6 @@ class GeoImageDragControl extends Control {
}, this);
}
}
};
}
export { GeoImageDragControl };

View File

@ -113,10 +113,10 @@ class KeyboardNavigation extends Control {
this.renderer.activeCamera.roll(15 / this.renderer.handler.deltaTime);
this.renderer.activeCamera.update();
}
};
}
export function keyboardNavigation(options) {
return new KeyboardNavigation(options);
};
}
export { KeyboardNavigation };

View File

@ -48,7 +48,7 @@ class LayerSwitcher extends Control {
this.addSwitcher("checkbox", layer, this.overlaysDiv, this._id);
}
}
};
}
onLayerRemoved(layer) {
layer._removeCallback();
@ -153,6 +153,6 @@ class LayerSwitcher extends Control {
};
this.renderer.div.appendChild(button);
}
};
}
export { LayerSwitcher };

View File

@ -46,10 +46,10 @@ class SegmentBoundVisualization extends Control {
this._boundingSphereCollection.add(si._sphereEntity);
}
}
};
}
export function segmentBoundVisualization(options) {
return new SegmentBoundVisualization(options);
};
}
export { SegmentBoundVisualization };

View File

@ -29,10 +29,10 @@ class ShowFps extends Control {
_draw() {
print2d("ogShowFpsControl", (1000.0 / this.renderer.handler.deltaTime).toFixed(1), this.renderer.handler.canvas.clientWidth - 60, 0);
}
};
}
export function showFps(options) {
return new ShowFps(options);
};
}
export { ShowFps };

View File

@ -117,13 +117,13 @@ class SimpleNavigation extends Control {
cam.update();
}
}
};
}
/**
* Creates simple navigation control instance.
*/
export function simpleNavigation(options) {
return new SimpleNavigation(options);
};
}
export { SimpleNavigation };

View File

@ -33,6 +33,6 @@ class ToggleWireframe extends Control {
this.planet.setDrawMode(this.renderer.handler.gl.LINE_STRIP);
}
}
};
}
export { ToggleWireframe };

View File

@ -245,7 +245,7 @@ class TouchNavigation extends Control {
}
}
}
};
}
onDraw(e) {
@ -301,6 +301,6 @@ class TouchNavigation extends Control {
this.planet._normalMapCreator.free(this._keyLock);
}
}
};
}
export { TouchNavigation };

View File

@ -389,7 +389,7 @@ class Ellipsoid {
deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
sigmaP = sigma;
sigma = s / (b * A) + deltaSigma;
};
}
var tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1,
lat2 = Math.atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1, (1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp)),
lambda = Math.atan2(sinSigma * sinAlpha1, cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1),
@ -467,6 +467,6 @@ class Ellipsoid {
return null;
}
}
};
}
export { Ellipsoid };

View File

@ -330,6 +330,6 @@ class BaseBillboard {
setPickingColor3v(color) {
this._handler && this._handler.setPickingColorArr(this._handlerIndex, color);
}
};
}
export { BaseBillboard };

View File

@ -156,6 +156,6 @@ class Billboard extends BaseBillboard {
getHeight() {
return this._height;
}
};
}
export { Billboard };

View File

@ -352,7 +352,7 @@ class BillboardHandler {
gl.vertexAttribPointer(sha.a_alignedAxis, this._alignedAxisBuffer.itemSize, gl.FLOAT, false, 0, 0);
gl.drawArrays(gl.TRIANGLES, 0, this._vertexBuffer.numItems);
};
}
draw() {
if (this._billboards.length) {
@ -790,6 +790,6 @@ class BillboardHandler {
}
}
}
};
}
export { BillboardHandler };

View File

@ -705,6 +705,6 @@ class Entity {
isEqual(entity) {
return this.id === entity.id;
}
};
}
export { Entity };

View File

@ -631,7 +631,7 @@ class EntityCollection {
this._clearEntity(entity.childrenNodes[i]);
}
}
};
}
const EVENT_NAMES = [
/**

View File

@ -311,6 +311,6 @@ class Geometry {
getType() {
return this._type;
}
};
}
export { Geometry, GeometryType };

View File

@ -47,7 +47,7 @@ function doubleToTwoFloats(v, high, low) {
high.y = Math.fround(-doubleHigh);
low.y = Math.fround(y + doubleHigh);
}
};
}
let tempHigh = new Vec2(),
tempLow = new Vec2(),
@ -860,6 +860,6 @@ class GeometryHandler {
h.gl.deleteBuffer(this._lineStrokeColorsBuffer);
this._lineStrokeColorsBuffer = h.createArrayBuffer(new Float32Array(this._lineStrokeColors), 4, this._lineStrokeColors.length / 4);
}
};
}
export { GeometryHandler };

View File

@ -136,7 +136,7 @@ class Label extends BaseBillboard {
setAlign(align) {
this._align = STR2ALIGN[align.trim().toLowerCase()];
this._handler && this._handler.setText(this._handlerIndex, this._text, this._fontIndex, this._align);
};
}
/**
* Gets label text current alignment.
@ -252,7 +252,7 @@ class Label extends BaseBillboard {
*/
setOutlineColorHTML(color) {
this.setOutlineColor4v(utils.htmlColorToRgba(color));
};
}
/**
* Gets outline color vector.
@ -311,6 +311,6 @@ class Label extends BaseBillboard {
!this._fontAtlas && (this._fontAtlas = fontAtlas);
this.update();
}
};
}
export { Label, ALIGN };

View File

@ -121,6 +121,6 @@ class PointCloudHandler {
this._pointClouds.length = 0;
this._pointClouds = [];
}
};
}
export { PointCloudHandler };

View File

@ -235,6 +235,6 @@ class Ray {
setPickingColor3v(color) {
this._handler && this._handler.setPickingColorArr(this._handlerIndex, color);
}
};
}
export { Ray };

View File

@ -94,6 +94,6 @@ class ShapeHandler {
this._shapes.length = 0;
this._shapes = [];
}
};
}
export { ShapeHandler };

View File

@ -153,6 +153,6 @@ class StripHandler {
this._strips.length = 0;
this._strips = [];
}
};
}
export { StripHandler };

View File

@ -5,4 +5,4 @@
export function inherits(childCtor, parentCtor) {
childCtor.prototype = Object.create(parentCtor.prototype);
childCtor.prototype.constructor = childCtor;
};
}

View File

@ -276,6 +276,6 @@ class BaseGeoImage extends Layer {
get getFrameHeight() {
return this._frameHeight;
}
};
}
export { BaseGeoImage };

View File

@ -218,6 +218,6 @@ class GeoImage extends BaseGeoImage {
this._creationProceeding = false;
}
};
}
export { GeoImage };

View File

@ -146,6 +146,6 @@ class GeoTexture2d extends BaseGeoImage {
this._creationProceeding = false;
}
};
}
export { GeoTexture2d };

View File

@ -85,7 +85,7 @@ export class KML extends Vector {
fileReader.onload = async i => resolve((new DOMParser()).parseFromString(i.target.result, 'text/xml'));
fileReader.readAsText(file);
});
};
}
/**
* @private
@ -140,7 +140,7 @@ export class KML extends Vector {
};
request.send();
});
};
}
/**
* @public
@ -156,4 +156,4 @@ export class KML extends Vector {
return { entities, extent };
}
};
}

View File

@ -32,7 +32,7 @@ function _entitiesConstructor(entities) {
}
}
return res;
};
}
/**
* Vector layer represents alternative entities store. Used for geospatial data rendering like
@ -933,7 +933,7 @@ class Vector extends Layer {
this._geometryHandler.update();
this.events.dispatch(this.events.draw, this);
}
};
}
const EVENT_NAMES = [
/**

View File

@ -154,6 +154,6 @@ class WMS extends XYZ {
em.southWest.lon = -ENLARGE_MERCATOR_LON;
}
}
};
}
export { WMS };

View File

@ -343,8 +343,8 @@ class XYZ extends Layer {
if (e.northEast.lat <= mercator.MIN_LAT) {
e.northEast.lat = mercator.MIN_LAT;
}
};
};
}
}
const EVENT_NAMES = [
/**

View File

@ -351,6 +351,6 @@ class LightSource {
}
this._renderNode = null;
}
};
}
export { LightSource };

View File

@ -15,18 +15,18 @@ export class Line2 {
static get(p0, p1) {
return new Line2(p1.y - p0.y, p0.x - p1.x, p1.x * p0.y - p0.x * p1.y);
};
}
static getParallel(l, p) {
return new Line2(l.a, l.b, -l.a * p.x - l.b * p.y);
};
}
static getIntersection(L0, L1) {
var x = (L1.b * L0.c - L0.b * L1.c) / (L0.b * L1.a - L1.b * L0.a);
return new Vec2(x, -(L0.c + L0.a * x) / L0.b);
};
}
intersects(l) {
return Line2.getIntersection(this, l);
};
}
}

View File

@ -7,11 +7,11 @@ export class Line3 {
constructor(p0, p1) {
this.p0 = p0 || new Vec3();
this.p1 = p1 || new Vec3();
};
}
getMagnitude() {
return this.p0.distance(this.p1);
};
}
getSphereIntersection(sphere) {
var p0 = this.p0,
@ -62,7 +62,7 @@ export class Line3 {
}
return [solution2, solution1];
};
}
intersects(line, res, res2) {
@ -109,7 +109,7 @@ export class Line3 {
}
return true;
};
}
getNearestDistancePoint(point, res) {
@ -135,6 +135,6 @@ export class Line3 {
}
return true;
};
}
}

View File

@ -20,7 +20,7 @@ export class Mat3 {
* @type {Array.<number>}
*/
this._m = new Array(9);
};
}
/**
* Sets column-major order array matrix.
@ -39,7 +39,7 @@ export class Mat3 {
this._m[7] = m[7];
this._m[8] = m[8];
return this;
};
}
/**
* Duplicates a Mat3 instance.
@ -50,7 +50,7 @@ export class Mat3 {
var res = new Mat3();
res.set(this);
return res;
};
}
/**
* Copy matrix.
@ -60,7 +60,7 @@ export class Mat3 {
*/
copy(a) {
return this.set(a._m);
};
}
/**
* Creates trasposed matrix from the current.
@ -74,7 +74,7 @@ export class Mat3 {
res._m[3] = m[1]; res._m[4] = m[4]; res._m[5] = m[7];
res._m[6] = m[2]; res._m[7] = m[5]; res._m[8] = m[8];
return res;
};
}
/**
* Sets matrix to identity.
@ -86,7 +86,7 @@ export class Mat3 {
this._m[3] = 0; this._m[4] = 1; this._m[5] = 0;
this._m[6] = 0; this._m[7] = 0; this._m[8] = 1;
return this;
};
}
/**
* Multiply to 3d vector.
@ -102,7 +102,7 @@ export class Mat3 {
m[1] * d + m[4] * e + m[7] * g,
m[2] * d + m[5] * e + m[8] * g
);
};
}
/**
* Converts to 4x4 matrix.
@ -130,7 +130,7 @@ export class Mat3 {
b[14] = 0;
b[15] = 1;
return res;
};
}
}
@ -141,4 +141,4 @@ export class Mat3 {
*/
export function mat3() {
return new Mat3();
};
}

View File

@ -17,7 +17,7 @@ export class Mat4 {
* @type {Array.<number>}
*/
this._m = new Array(16);
};
}
/**
* Returns identity matrix instance.
@ -31,7 +31,7 @@ export class Mat4 {
res._m[8] = 0; res._m[9] = 0; res._m[10] = 1; res._m[11] = 0;
res._m[12] = 0; res._m[13] = 0; res._m[14] = 0; res._m[15] = 1;
return res;
};
}
/**
* Sets column-major order array matrix.
@ -57,7 +57,7 @@ export class Mat4 {
this._m[14] = m[14];
this._m[15] = m[15];
return this;
};
}
/**
* Duplicates a Matrix3 instance.
@ -68,7 +68,7 @@ export class Mat4 {
var res = new Mat4();
res.set(this);
return res;
};
}
/**
* Copy matrix.
@ -77,7 +77,7 @@ export class Mat4 {
*/
copy(a) {
this.set(a._m);
};
}
/**
* Converts to 3x3 matrix.
@ -98,7 +98,7 @@ export class Mat4 {
b[7] = a[9];
b[8] = a[10];
return res;
};
}
/**
* Multiply to 3d vector.
@ -113,7 +113,7 @@ export class Mat4 {
this._m[1] * d + this._m[5] * e + this._m[9] * g + this._m[13],
this._m[2] * d + this._m[6] * e + this._m[10] * g + this._m[14]
);
};
}
/**
* Multiply to 4d vector.
@ -129,7 +129,7 @@ export class Mat4 {
this._m[2] * d + this._m[6] * e + this._m[10] * g + this._m[14] * f,
this._m[3] * d + this._m[7] * e + this._m[11] * g + this._m[15] * f
);
};
}
/**
* Creates an inversed 3x3 matrix of the current.
@ -163,7 +163,7 @@ export class Mat4 {
res._m[7] = (-j * c + d * i) * n;
res._m[8] = (f * c - d * g) * n;
return res;
};
}
/**
* Creates an inversed matrix of the current.
@ -195,7 +195,7 @@ export class Mat4 {
res._m[8] = (f * D - h * z + j * x) * q; res._m[9] = (-c * D + d * z - g * x) * q; res._m[10] = (n * v - p * t + s * A) * q; res._m[11] = (-k * v + l * t - m * A) * q;
res._m[12] = (-f * C + h * y - i * x) * q; res._m[13] = (c * C - d * y + e * x) * q; res._m[14] = (-n * u + p * B - r * A) * q; res._m[15] = (k * u - l * B + o * A) * q;
return res;
};
}
/**
* Creates a trasposed matrix of the current.
@ -209,7 +209,7 @@ export class Mat4 {
res._m[8] = this._m[2]; res._m[9] = this._m[6]; res._m[10] = this._m[10]; res._m[11] = this._m[14];
res._m[12] = this._m[3]; res._m[13] = this._m[7]; res._m[14] = this._m[11]; res._m[15] = this._m[15];
return res;
};
}
/**
* Sets matrix to identity.
@ -222,7 +222,7 @@ export class Mat4 {
this._m[8] = 0; this._m[9] = 0; this._m[10] = 1; this._m[11] = 0;
this._m[12] = 0; this._m[13] = 0; this._m[14] = 0; this._m[15] = 1;
return this;
};
}
/**
* Computes the product of two matrices.
@ -247,7 +247,7 @@ export class Mat4 {
res._m[8] = z * d + C * h + D * l + E * p; res._m[9] = z * e + C * i + D * o + E * r; res._m[10] = z * g + C * j + D * m + E * s; res._m[11] = z * f + C * k + D * n + E * a;
res._m[12] = q * d + F * h + G * l + b * p; res._m[13] = q * e + F * i + G * o + b * r; res._m[14] = q * g + F * j + G * m + b * s; res._m[15] = q * f + F * k + G * n + b * a;
return res;
};
}
/**
* Add translation vector to the current matrix.
@ -263,7 +263,7 @@ export class Mat4 {
a[14] = a[2] * d + a[6] * e + a[10] * b + a[14];
a[15] = a[3] * d + a[7] * e + a[11] * b + a[15];
return this;
};
}
/**
* Sets translation matrix to the position.
@ -277,7 +277,7 @@ export class Mat4 {
a[13] = v.y;
a[14] = v.z;
return this;
};
}
/**
* Rotate currrent matrix around the aligned axis and angle.
@ -297,7 +297,7 @@ export class Mat4 {
mx[8] = (1 - c) * u.x * u.z - s * u.y; mx[9] = (1 - c) * u.y * u.z + s * u.x; mx[10] = c + (1 - c) * u.z * u.z; mx[11] = 0;
mx[12] = 0; mx[13] = 0; mx[14] = 0; mx[15] = 1;
return this.mul(rot);
};
}
/**
* Sets current rotation matrix around the aligned axis and angle.
@ -315,7 +315,7 @@ export class Mat4 {
mx[8] = (1 - c) * u.x * u.z - s * u.y; mx[9] = (1 - c) * u.y * u.z + s * u.x; mx[10] = c + (1 - c) * u.z * u.z; mx[11] = 0;
mx[12] = 0; mx[13] = 0; mx[14] = 0; mx[15] = 1;
return this;
};
}
/**
* Gets the rotation matrix from one vector to another.
@ -327,7 +327,7 @@ export class Mat4 {
rotateBetweenVectors(a, b) {
var q = Quat.getRotationBetweenVectors(a, b);
return q.getMat4();
};
}
/**
* Scale current matrix to the vector values.
@ -341,7 +341,7 @@ export class Mat4 {
mx[4] = mx[4] * v.y; mx[5] = mx[5] * v.y; mx[6] = mx[6] * v.y; mx[7] = mx[7] * v.y;
mx[8] = mx[8] * v.z; mx[9] = mx[9] * v.z; mx[10] = mx[10] * v.z; mx[11] = mx[11] * v.z;
return this;
};
}
/**
* Sets perspective projection matrix frustum values.
@ -373,7 +373,7 @@ export class Mat4 {
this._m[14] = -(far * near * 2) / j;
this._m[15] = 0;
return this;
};
}
/**
* Creates current orthographic projection matrix.
@ -410,7 +410,7 @@ export class Mat4 {
m[14] = (far + near) * nf;
m[15] = 1.0;
return this;
};
}
/**
* Sets current rotation matrix by euler's angles.
@ -446,7 +446,7 @@ export class Mat4 {
mat[15] = 1;
return this;
};
}
}
/**
@ -456,4 +456,4 @@ export class Mat4 {
*/
export function mat4() {
return new og.Mat4();
};
}

View File

@ -53,7 +53,7 @@ export class Quat {
* @default 0.0
*/
this.w = w || 0.0;
};
}
/**
* Identity Quat.
@ -73,7 +73,7 @@ export class Quat {
static xRotation(a) {
a *= 0.5;
return new Quat(Math.sin(a), 0.0, 0.0, Math.cos(a));
};
}
/**
* Returns a Quat represents rotation around Y axis.
@ -84,7 +84,7 @@ export class Quat {
static yRotation(a) {
a *= 0.5;
return new Quat(0.0, Math.sin(a), 0.0, Math.cos(a));
};
}
/**
* Returns a Quat represents rotation around Z axis.
@ -95,7 +95,7 @@ export class Quat {
static zRotation(a) {
a *= 0.5;
return new Quat(0.0, 0.0, Math.sin(a), Math.cos(a));
};
}
/**
* Computes a Quat representing a rotation around an axis.
@ -114,7 +114,7 @@ export class Quat {
v.y * sin_a,
v.z * sin_a,
Math.cos(half_angle));
};
}
/**
* Computes a rotation from the given heading and up vector.
@ -168,7 +168,7 @@ export class Quat {
0.25 / fd,
(u.x - s.y) * fd
);
};
}
/**
* Computes a Quat from from source point heading to the destination point.
@ -189,7 +189,7 @@ export class Quat {
var rotAngle = Math.acos(dot);
var rotAxis = Vec3.FORWARD.cross(forwardVector).normalize();
return Quat.axisAngleToQuat(rotAxis, rotAngle);
};
}
/**
* Compute rotation between two vectors.
@ -202,7 +202,7 @@ export class Quat {
var w = u.cross(v);
var q = new Quat(w.x, w.y, w.z, 1.0 + u.dot(v));
return q.normalize();
};
}
/**
* Compute rotation between two vectors.
@ -216,7 +216,7 @@ export class Quat {
var w = u.cross(v);
res.set(w.x, w.y, w.z, 1.0 + u.dot(v));
return res.normalize();
};
}
/**
* Compute rotation between two vectors with around vector up
@ -243,7 +243,7 @@ export class Quat {
var rotAngle = Math.acos(dot);
var rotAxis = source.cross(dest).normalize();
return Quat.axisAngleToQuat(rotAxis, rotAngle);
};
}
/**
* Returns true if the components are zero.
@ -253,7 +253,7 @@ export class Quat {
*/
isZero() {
return this.x === 0.0 && this.y === 0.0 && this.z === 0.0 && this.w === 0.0;
};
}
/**
* Clear Quat. Sets zeroes.
@ -263,7 +263,7 @@ export class Quat {
clear() {
this.x = this.y = this.z = this.w = 0;
return this;
};
}
/**
* Sets Quat values.
@ -280,7 +280,7 @@ export class Quat {
this.z = z;
this.w = w;
return this;
};
}
/**
* Copy Quat values.
@ -294,7 +294,7 @@ export class Quat {
this.z = q.z;
this.w = q.w;
return this;
};
}
/**
* Set current Quat instance to identity Quat.
@ -307,7 +307,7 @@ export class Quat {
this.z = 0.0;
this.w = 1.0;
return this;
};
}
/**
* Duplicates a Quat instance.
@ -316,7 +316,7 @@ export class Quat {
*/
clone() {
return new Quat(this.x, this.y, this.z, this.w);
};
}
/**
* Computes the componentwise sum of two Quats.
@ -326,7 +326,7 @@ export class Quat {
*/
add(q) {
return new Quat(this.x + q.x, this.y + q.y, this.z + q.z, this.w + q.w);
};
}
/**
* Computes the componentwise difference of two Quats.
@ -336,7 +336,7 @@ export class Quat {
*/
sub(q) {
return new Quat(this.x - q.x, this.y - q.y, this.z - q.z, this.w - q.w);
};
}
/**
* Multiplies the provided Quat componentwise by the provided scalar.
@ -346,7 +346,7 @@ export class Quat {
*/
scaleTo(scale) {
return new Quat(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
};
}
/**
* Multiplies the provided Quat componentwise.
@ -357,7 +357,7 @@ export class Quat {
scale(scale) {
this.x *= scale; this.y *= scale; this.z *= scale; this.w *= scale;
return this;
};
}
/**
* Converts Quat values to array.
@ -366,7 +366,7 @@ export class Quat {
*/
toVec() {
return [this.x, this.y, this.z, this.w];
};
}
/**
* Sets current quaternion by spherical coordinates.
@ -388,7 +388,7 @@ export class Quat {
this.z = sin_a * sin_lat * cos_long;
this.w = cos_a;
return this;
};
}
/**
* Sets rotation with the given heading and up vectors.
@ -432,7 +432,7 @@ export class Quat {
}
return this;
};
}
/**
* Gets spherical coordinates.
@ -461,7 +461,7 @@ export class Quat {
}
return { lat: lat, lon: lon, alpha: Math.acos(cos_a) };
};
}
/**
* Sets current Quat representing a rotation around an axis.
@ -476,7 +476,7 @@ export class Quat {
var sin_a = Math.sin(half_angle);
this.set(v.x * sin_a, v.y * sin_a, v.z * sin_a, Math.cos(half_angle));
return this;
};
}
/**
* Returns axis and angle of the current Quat.
@ -499,7 +499,7 @@ export class Quat {
angle = 0;
}
return { axis: axis, angle: angle };
};
}
/**
* Sets current Quat by Euler's angles.
@ -531,7 +531,7 @@ export class Quat {
this.z = cr * cp * sy - sr * sp * cy;
return this.normalize();
};
}
/**
* Returns Euler's angles of the current Quat.
@ -558,7 +558,7 @@ export class Quat {
let yaw = Math.atan2(2.0 * (w * z + x * y), 1.0 - 2.0 * (sqy + z * z));
return { roll, pitch, yaw };
};
}
/**
* Computes a Quat from the provided 4x4 matrix instance.
@ -605,7 +605,7 @@ export class Quat {
this.w = q[3];
}
return this;
};
}
/**
* Converts current Quat to the rotation 4x4 matrix.
@ -627,7 +627,7 @@ export class Quat {
var zz = this.z * zs;
var m = out || new Mat4();
return m.set([1 - (yy + zz), xy - wz, xz + wy, 0, xy + wz, 1 - (xx + zz), yz - wx, 0, xz - wy, yz + wx, 1 - (xx + yy), 0, 0, 0, 0, 1]);
};
}
/**
* Converts current Quat to the rotation 3x3 matrix.
@ -663,7 +663,7 @@ export class Quat {
mx[6] = c - h; mx[7] = d + f; mx[8] = 1 - (j + l);
return m;
};
}
/**
* Returns quatrenion and vector production.
@ -695,7 +695,7 @@ export class Quat {
i * a + d * -b + j * -h - k * -f,
j * a + d * -f + k * -b - i * -h,
k * a + d * -h + i * -f - j * -b);
};
}
/**
* Computes the product of two Quats.
@ -711,7 +711,7 @@ export class Quat {
e * b + a * h + g * f - d * i,
g * b + a * i + d * h - e * f,
a * b - d * f - e * h - g * i);
};
}
/**
* Computes the product of two Quats.
@ -727,7 +727,7 @@ export class Quat {
this.z = g * b + a * i + d * h - e * f;
this.w = a * b - d * f - e * h - g * i;
return this;
};
}
/**
* Gets the conjugate of the Quat.
@ -736,7 +736,7 @@ export class Quat {
*/
conjugate() {
return new Quat(-this.x, -this.y, -this.z, this.w);
};
}
/**
* Computes the inverse of the Quat.
@ -746,7 +746,7 @@ export class Quat {
inverse() {
var n = 1 / this.magnitude2();
return new Quat(-this.x * n, -this.y * n, -this.z * n, this.w * n);
};
}
/**
* Computes a magnitude of the Quat.
@ -756,7 +756,7 @@ export class Quat {
magnitude() {
var b = this.x, c = this.y, d = this.z, a = this.w;
return Math.sqrt(b * b + c * c + d * d + a * a);
};
}
/**
* Computes a squared magnitude of the Quat.
@ -766,7 +766,7 @@ export class Quat {
magnitude2() {
var b = this.x, c = this.y, d = this.z, a = this.w;
return b * b + c * c + d * d + a * a;
};
}
/**
* Computes the dot (scalar) product of two Quats.
@ -776,7 +776,7 @@ export class Quat {
*/
dot(q) {
return this.x * q.x + this.y * q.y + this.z * q.z;
};
}
/**
* Current Quat normalization.
@ -799,7 +799,7 @@ export class Quat {
this.z = e * f;
this.w = g * f;
return this;
};
}
/**
* Compares two Quats.
@ -813,7 +813,7 @@ export class Quat {
return true;
}
return false;
};
}
/**
* Performs a spherical linear interpolation between two Quats.
@ -855,7 +855,7 @@ export class Quat {
scale0 * az + scale1 * bz,
scale0 * aw + scale1 * bw
);
};
}
/**
* Returns a roll angle in radians.
@ -876,7 +876,7 @@ export class Quat {
} else {
return Math.atan2(2 * (x * y + w * z), w * w + x * x - y * y - z * z);
}
};
}
/**
* Returns a pitch angle in radians.
@ -897,7 +897,7 @@ export class Quat {
} else {
return Math.atan2(2 * (y * z + w * x), w * w - x * x - y * y + z * z);
}
};
}
/**
* Returns a yaw angle in radians.
@ -919,7 +919,7 @@ export class Quat {
} else {
return Math.asin(-2 * (x * z - w * y));
}
};
}
}
/**
@ -933,5 +933,5 @@ export class Quat {
*/
export function quat(x, y, z, w) {
return new Quat(x, y, z, w);
};
}

View File

@ -29,7 +29,7 @@ export class Ray {
* @type {og.Vec3}
*/
this.direction = direction || new Vec3();
};
}
/** @const */
static get OUTSIDE() { return 0; }
@ -52,7 +52,7 @@ export class Ray {
this.origin = origin;
this.direction = direction;
return this;
};
}
/**
* Computes the point along the ray on the distance.
@ -62,7 +62,7 @@ export class Ray {
*/
getPoint(distance) {
return Vec3.add(this.origin, this.direction.scaleTo(distance));
};
}
/**
* Returns ray hit a triange result.
@ -125,7 +125,7 @@ export class Ray {
}
return Ray.INSIDE;
};
}
/**
* Gets a ray hit a plane result. If the ray cross the plane returns 1 - og.Ray.INSIDE otherwise returns 0 - og.Ray.OUTSIDE.
@ -166,7 +166,7 @@ export class Ray {
res.z = this.origin.z + d.z;
return Ray.INSIDE;
};
}
/**
* Returns a ray hit sphere coordiante. If there isn't hit returns null.
@ -211,13 +211,13 @@ export class Ray {
return intersection;
}
}
};
}
hitBox(box) {
//
// TODO
//
};
}
}
@ -230,5 +230,5 @@ export class Ray {
*/
export function ray(origin, direction) {
return new Ray(origin, direction);
};
}

View File

@ -27,17 +27,17 @@ export class Vec2 {
* @type {number}
*/
this.y = y || 0.0;
};
}
/** @const */
static get UP() { return new Vec2(0, 1) };
static get UP() { return new Vec2(0, 1) }
/** @const */
static get DOWN() { return new Vec2(0, -1) };
static get DOWN() { return new Vec2(0, -1) }
/** @const */
static get RIGHT() { return new Vec2(1, 0) };
static get RIGHT() { return new Vec2(1, 0) }
/** @const */
static get LEFT() { return new Vec2(-1, 0) };
static get LEFT() { return new Vec2(-1, 0) }
/** @const */
static get ZERO() { return new Vec2() };
static get ZERO() { return new Vec2() }
/**
* Returns summary vector.
@ -50,7 +50,7 @@ export class Vec2 {
var res = new Vec2(a.x, a.y);
res.addA(b);
return res;
};
}
/**
* Returns two vectors subtraction.
@ -63,7 +63,7 @@ export class Vec2 {
var res = new Vec2(a.x, a.y);
res.subA(b);
return res;
};
}
/**
* Returns scaled vector.
@ -76,7 +76,7 @@ export class Vec2 {
var res = new Vec2(a.x, a.y);
res.scale(scale);
return res;
};
}
/**
* Returns two vectors production.
@ -89,7 +89,7 @@ export class Vec2 {
var res = new Vec2(a.x, a.y);
res.mulA(b);
return res;
};
}
/**
* Returns vector components division product one to another.
@ -102,7 +102,7 @@ export class Vec2 {
var res = new Vec2(a.x, a.y);
res.divA(b);
return res;
};
}
/**
* Get projection of the first vector to the second.
@ -113,7 +113,7 @@ export class Vec2 {
*/
static proj_b_to_a(b, a) {
return a.scaleTo(a.dot(b) / a.dot(a));
};
}
/**
* Gets angle between two vectors.
@ -124,7 +124,7 @@ export class Vec2 {
*/
static angle(a, b) {
return Math.acos(a.dot(b) / Math.sqrt(a.length2() * b.length2()));
};
}
/**
* Makes vectors normalized and orthogonal to each other.
@ -137,7 +137,7 @@ export class Vec2 {
normal = normal.norm();
normal.scale(tangent.dot(normal));
return tangent.sub(normal).normalize();
};
}
/**
* Converts to 3d vector, third value is 0.0.
@ -146,7 +146,7 @@ export class Vec2 {
*/
toVector3() {
return new Vec3(this.x, this.y, 0);
};
}
/**
* Returns clone vector.
@ -155,7 +155,7 @@ export class Vec2 {
*/
clone() {
return new Vec2(this.x, this.y);
};
}
/**
* Compares with vector. Returns true if it equals another.
@ -165,7 +165,7 @@ export class Vec2 {
*/
equal(p) {
return this.x === p.x && this.y === p.y;
};
}
/**
* Copy input vector's values.
@ -176,7 +176,7 @@ export class Vec2 {
this.x = point2.x;
this.y = point2.y;
return this;
};
}
/**
* Gets vector's length.
@ -185,7 +185,7 @@ export class Vec2 {
*/
length() {
return Math.sqrt(this.x * this.x + this.y * this.y);
};
}
/**
* Returns squared vector's length.
@ -194,7 +194,7 @@ export class Vec2 {
*/
length2() {
return this.x * this.x + this.y * this.y;
};
}
/**
* Adds vector to the current.
@ -206,7 +206,7 @@ export class Vec2 {
this.x += v.x;
this.y += v.y;
return this;
};
}
/**
* Summarize two vectors.
@ -216,7 +216,7 @@ export class Vec2 {
*/
add(v) {
return new Vec2(this.x + v.x, this.y + v.y);
};
}
/**
* Subtract vector from the current where results saved on the current instance.
@ -228,7 +228,7 @@ export class Vec2 {
this.x -= v.x;
this.y -= v.y;
return this;
};
}
/**
* Subtract vector from the current.
@ -238,7 +238,7 @@ export class Vec2 {
*/
sub(v) {
return new Vec2(this.x - v.x, this.y - v.y);
};
}
/**
* Scale current vector.
@ -250,7 +250,7 @@ export class Vec2 {
this.x *= scale;
this.y *= scale;
return this;
};
}
/**
* Scale current vector to another instance.
@ -260,7 +260,7 @@ export class Vec2 {
*/
scaleTo(scale) {
return new Vec2(this.x * scale, this.y * scale);
};
}
/**
* Multiply current vector object to another and store result in the current instance.
@ -272,7 +272,7 @@ export class Vec2 {
this.x *= vec.x;
this.y *= vec.y;
return this;
};
}
/**
* Multiply current vector object to another and returns new vector instance.
@ -282,7 +282,7 @@ export class Vec2 {
*/
mul(vec) {
return new Vec2(this.x * vec.x, this.y * vec.y);
};
}
/**
* Divide current vector's components to another. Results stores in the current vector object.
@ -294,7 +294,7 @@ export class Vec2 {
this.x /= vec.x;
this.y /= vec.y;
return this;
};
}
/**
* Gets vectors dot production.
@ -304,7 +304,7 @@ export class Vec2 {
*/
dot(v) {
return v.x * this.x + v.y * this.y;
};
}
/**
* Gets vectors dot production.
@ -314,7 +314,7 @@ export class Vec2 {
*/
dotArr(arr) {
return arr[0] * this.x + arr[1] * this.y;
};
}
/**
* Gets vectors cross production.
@ -324,7 +324,7 @@ export class Vec2 {
*/
cross(v) {
return this.x * v.y - this.y * v.x;
};
}
/**
* Sets vector to zero.
@ -334,7 +334,7 @@ export class Vec2 {
clear() {
this.x = this.y = 0;
return this;
};
}
/**
* Returns normalized vector.
@ -351,7 +351,7 @@ export class Vec2 {
res.y *= length;
return res;
};
}
/**
* Normalize current vector.
@ -365,7 +365,7 @@ export class Vec2 {
this.y *= length;
return this;
};
}
/**
* Converts vector to a number array.
@ -374,7 +374,7 @@ export class Vec2 {
*/
toVec() {
return [this.x, this.y];
};
}
/**
* Gets distance to point.
@ -385,7 +385,7 @@ export class Vec2 {
distance(p) {
var vec = Vec2.sub(this, p);
return vec.length();
};
}
/**
* Sets vector's values.
@ -398,7 +398,7 @@ export class Vec2 {
this.x = x;
this.y = y;
return this;
};
}
/**
* Negate current vector.
@ -409,7 +409,7 @@ export class Vec2 {
this.x = -this.x;
this.y = -this.y;
return this;
};
}
/**
* Negate current vector to another instance.
@ -418,7 +418,7 @@ export class Vec2 {
*/
negateTo() {
return new Vec2(-this.x, -this.y);
};
}
/**
* Gets projected point coordinates of the current vector on the ray.
@ -431,7 +431,7 @@ export class Vec2 {
var v = Vec2.proj_b_to_a(Vec2.sub(this, pos), direction);
v.add(pos);
return v;
};
}
/**
* Gets angle between two vectors.
@ -441,7 +441,7 @@ export class Vec2 {
*/
angle(a) {
return Vec2.angle(this, a);
};
}
/**
* Returns two vectors linear interpolation.
@ -460,9 +460,9 @@ export class Vec2 {
res = Vec2.add(v1, Vec2.sub(v2, v1).scale(l));
}
return res;
};
}
static get LERP_DELTA() { return 1e-6 };
static get LERP_DELTA() { return 1e-6 }
/**
* Spherically interpolates between two vectors.
@ -499,7 +499,7 @@ export class Vec2 {
}
return Vec2.add(this.scale(scale0), v2.scale(scale1));
};
}
}
/**
@ -511,4 +511,4 @@ export class Vec2 {
*/
export function vec2(x, y) {
return new Vec2(x, y);
};
}

View File

@ -35,28 +35,28 @@ export class Vec3 {
* @type {number}
*/
this.z = z || 0.0;
};
}
/** @const */
static get UP() { return new Vec3(0, 1, 0) };
static get UP() { return new Vec3(0, 1, 0) }
/** @const */
static get DOWN() { return new Vec3(0, -1, 0) };
static get DOWN() { return new Vec3(0, -1, 0) }
/** @const */
static get RIGHT() { return new Vec3(1, 0, 0) };
static get RIGHT() { return new Vec3(1, 0, 0) }
/** @const */
static get LEFT() { return new Vec3(-1, 0, 0) };
static get LEFT() { return new Vec3(-1, 0, 0) }
/** @const */
static get FORWARD() { return new Vec3(0, 0, -1) };
static get FORWARD() { return new Vec3(0, 0, -1) }
/** @const */
static get BACKWARD() { return new Vec3(0, 0, 1) };
static get BACKWARD() { return new Vec3(0, 0, 1) }
/** @const */
static get ZERO() { return new Vec3() };
static get ZERO() { return new Vec3() }
/** @const */
static get UNIT_X() { return new Vec3(1, 0, 0) };
static get UNIT_X() { return new Vec3(1, 0, 0) }
/** @const */
static get UNIT_Y() { return new Vec3(0, 1, 0) };
static get UNIT_Y() { return new Vec3(0, 1, 0) }
/** @const */
static get UNIT_Z() { return new Vec3(0, 0, 1) };
static get UNIT_Z() { return new Vec3(0, 0, 1) }
/**
* Separate 63 bit Vec3 to two Vec3 32 bit float values.
@ -99,7 +99,7 @@ export class Vec3 {
high.z = Math.fround(-doubleHigh);
low.z = Math.fround(z + doubleHigh);
}
};
}
/**
* Separate 63 bit Vec3 to two Vec3 32 bit float values.
@ -142,7 +142,7 @@ export class Vec3 {
high[2] = Math.fround(-doubleHigh);
low[2] = Math.fround(z + doubleHigh);
}
};
}
/**
* Creates 3d vector from array.
@ -152,7 +152,7 @@ export class Vec3 {
*/
static fromVec(arr) {
return new Vec3(arr[0], arr[1], arr[2]);
};
}
/**
* Gets angle between two vectors.
@ -163,7 +163,7 @@ export class Vec3 {
*/
static angle(a, b) {
return Math.acos(a.dot(b) / Math.sqrt(a.length2() * b.length2()));
};
}
/**
* Returns two vectors linear interpolation.
@ -175,7 +175,7 @@ export class Vec3 {
*/
static lerp(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);
};
}
/**
* Returns summary vector.
@ -188,7 +188,7 @@ export class Vec3 {
var res = new Vec3(a.x, a.y, a.z);
res.addA(b);
return res;
};
}
/**
* Returns two vectors subtraction.
@ -201,7 +201,7 @@ export class Vec3 {
var res = new Vec3(a.x, a.y, a.z);
res.subA(b);
return res;
};
}
/**
* Returns scaled vector.
@ -214,7 +214,7 @@ export class Vec3 {
var res = new Vec3(a.x, a.y, a.z);
res.scale(scale);
return res;
};
}
/**
* Returns two vectors production.
@ -227,7 +227,7 @@ export class Vec3 {
var res = new Vec3(a.x, a.y, a.z);
res.mulA(b);
return res;
};
}
/**
* Returns true if two vectors are non collinear.
@ -238,7 +238,7 @@ export class Vec3 {
*/
static noncollinear(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;
};
}
/**
* Get projection of the vector to plane where n - normal to the plane.
@ -254,7 +254,7 @@ export class Vec3 {
return new Vec3(def.x, def.y, def.z);
}
return res;
};
}
/**
* Get projection of the first vector to the second.
@ -265,7 +265,7 @@ export class Vec3 {
*/
static proj_b_to_a(b, a) {
return a.scaleTo(a.dot(b) / a.dot(a));
};
}
/**
* Makes vectors normalized and orthogonal to each other.
@ -279,7 +279,7 @@ export class Vec3 {
normal = normal.normal();
normal.scale(tangent.dot(normal));
return tangent.subA(normal).normalize();
};
}
/**
* Returns vector components division product one to another.
@ -292,7 +292,7 @@ export class Vec3 {
var res = new Vec3(a.x, a.y, a.z);
res.divA(b);
return res;
};
}
/**
* Converts to 4d vector, Fourth value is 1.0.
@ -301,7 +301,7 @@ export class Vec3 {
*/
toVec4() {
return new Vec4(this.x, this.y, this.z, 1.0);
};
}
/**
* Returns clone vector.
@ -310,7 +310,7 @@ export class Vec3 {
*/
clone() {
return new Vec3(this.x, this.y, this.z);
};
}
/**
* Converts vector to text string.
@ -319,7 +319,7 @@ export class Vec3 {
*/
toString() {
return "(" + this.x + "," + this.y + "," + this.z + ")";
};
}
/**
* Returns true if vector's values are zero.
@ -328,7 +328,7 @@ export class Vec3 {
*/
isZero() {
return !(this.x || this.y || this.z);
};
}
/**
* Get projection of the first vector to the second.
@ -338,7 +338,7 @@ export class Vec3 {
*/
projToVec(a) {
return a.scaleTo(a.dot(this) / a.dot(a));
};
}
/**
* Compares with vector. Returns true if it equals another.
@ -348,7 +348,7 @@ export class Vec3 {
*/
equal(p) {
return this.x === p.x && this.y === p.y && this.z === p.z;
};
}
/**
* Copy input vector's values.
@ -360,7 +360,7 @@ export class Vec3 {
this.y = point3.y;
this.z = point3.z;
return this;
};
}
/**
* Gets vector's length.
@ -369,7 +369,7 @@ export class Vec3 {
*/
length() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
};
}
/**
* Returns squared vector's length.
@ -378,7 +378,7 @@ export class Vec3 {
*/
length2() {
return this.x * this.x + this.y * this.y + this.z * this.z;
};
}
/**
* Converts vector's values to a quaternion object.
@ -387,7 +387,7 @@ export class Vec3 {
*/
getQuat() {
return new Quat(this.x, this.y, this.z);
};
}
/**
* Adds vector to the current.
@ -400,7 +400,7 @@ export class Vec3 {
this.y += point3.y;
this.z += point3.z;
return this;
};
}
/**
* Gets two vectors summarization.
@ -410,7 +410,7 @@ export class Vec3 {
*/
add(point3) {
return new Vec3(this.x + point3.x, this.y + point3.y, this.z + point3.z);
};
}
/**
* Subtract vector from the current.
@ -423,7 +423,7 @@ export class Vec3 {
this.y -= point3.y;
this.z -= point3.z;
return this;
};
}
/**
* Gets vector subtraction.
@ -433,7 +433,7 @@ export class Vec3 {
*/
sub(point3) {
return new Vec3(this.x - point3.x, this.y - point3.y, this.z - point3.z);
};
}
/**
* Scale current vector.
@ -446,7 +446,7 @@ export class Vec3 {
this.y *= scale;
this.z *= scale;
return this;
};
}
/**
* Scale current vector to another instance.
@ -456,7 +456,7 @@ export class Vec3 {
*/
scaleTo(scale) {
return new Vec3(this.x * scale, this.y * scale, this.z * scale);
};
}
/**
* Multiply current vector object to another and store result in the current instance.
@ -469,7 +469,7 @@ export class Vec3 {
this.y *= vec.y;
this.z *= vec.z;
return this;
};
}
/**
* Multiply current vector object to another and returns new vector instance.
@ -479,7 +479,7 @@ export class Vec3 {
*/
mul(vec) {
return new Vec3(this.x * vec.x, this.y * vec.y, this.z * vec.z);
};
}
/**
* Divide current vector's components to another. Results stores in the current vector object.
@ -492,7 +492,7 @@ export class Vec3 {
this.y /= vec.y;
this.z /= vec.z;
return this;
};
}
/**
* Divide current vector's components to another and returns new vector instance.
@ -502,7 +502,7 @@ export class Vec3 {
*/
div(vec) {
return new Vec3(this.x / vec.x, this.y / vec.y, this.z / vec.z);
};
}
/**
* Gets vectors dot production.
@ -512,7 +512,7 @@ export class Vec3 {
*/
dot(point3) {
return point3.x * this.x + point3.y * this.y + point3.z * this.z;
};
}
/**
* Gets vectors dot production.
@ -522,7 +522,7 @@ export class Vec3 {
*/
dotArr(arr) {
return arr[0] * this.x + arr[1] * this.y + arr[2] * this.z;
};
}
/**
* Gets vectors cross production.
@ -536,7 +536,7 @@ export class Vec3 {
this.z * point3.x - this.x * point3.z,
this.x * point3.y - this.y * point3.x
);
};
}
/**
* Sets vector to zero.
@ -546,7 +546,7 @@ export class Vec3 {
clear() {
this.x = this.y = this.z = 0;
return this;
};
}
/**
* Returns normalized vector.
@ -564,7 +564,7 @@ export class Vec3 {
res.z *= length;
return res;
};
}
/**
* Returns normalized vector.
@ -583,7 +583,7 @@ export class Vec3 {
res.z *= length;
return res;
};
}
/**
* Returns normalized negate vector.
@ -601,7 +601,7 @@ export class Vec3 {
res.z *= length;
return res;
};
}
/**
* Returns normalized negate scale vector.
@ -619,7 +619,7 @@ export class Vec3 {
res.z *= length;
return res;
};
}
/**
* Returns normalized scale vector.
@ -637,7 +637,7 @@ export class Vec3 {
res.z *= length;
return res;
};
}
/**
* Normalize current vector.
@ -652,7 +652,7 @@ export class Vec3 {
this.z *= length;
return this;
};
}
/**
* Converts vector to a number array.
@ -662,7 +662,7 @@ export class Vec3 {
*/
toVec() {
return [this.x, this.y, this.z];
};
}
/**
* Converts vector to a number array.
@ -671,7 +671,7 @@ export class Vec3 {
*/
toArray() {
return [this.x, this.y, this.z];
};
}
/**
* Gets distance to point.
@ -681,7 +681,7 @@ export class Vec3 {
*/
distance(point3) {
return Vec3.sub(this, point3).length();
};
}
/**
* Sets vector's values.
@ -696,7 +696,7 @@ export class Vec3 {
this.y = y;
this.z = z;
return this;
};
}
/**
* Negate current vector.
@ -708,7 +708,7 @@ export class Vec3 {
this.y = -this.y;
this.z = -this.z;
return this;
};
}
/**
* Negate current vector to another instance.
@ -717,7 +717,7 @@ export class Vec3 {
*/
negateTo() {
return new Vec3(-this.x, -this.y, -this.z);
};
}
/**
* Gets projected point coordinates of the current vector on the ray.
@ -730,7 +730,7 @@ export class Vec3 {
var v = Vec3.proj_b_to_a(Vec3.sub(this, pos), direction);
v.addA(pos);
return v;
};
}
/**
* Gets angle between two vectors.
@ -740,7 +740,7 @@ export class Vec3 {
*/
angle(a) {
return Vec3.angle(this, a);
};
}
/**
* Returns two vectors linear interpolation.
@ -751,7 +751,7 @@ export class Vec3 {
*/
lerp(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);
};
}
/**
* Returns vector interpolation by v(t) = v1 * t + v2 * (1 - t)
@ -763,9 +763,9 @@ export class Vec3 {
smerp(v2, t) {
var one_d = 1 - t;
return new Vec3(this.x * t + v2.x * one_d, this.y * t + v2.y * one_d, this.z * t + v2.z * one_d);
};
}
static get LERP_DELTA() { return 1e-6 };
static get LERP_DELTA() { return 1e-6 }
/**
* Spherically interpolates between two vectors.
@ -802,7 +802,7 @@ export class Vec3 {
}
return Vec3.add(this.scaleTo(scale0), v2.scale(scale1));
};
}
/**
* Gets the shortest arc quaternion to rotate this vector to the destination vector.
@ -848,7 +848,7 @@ export class Vec3 {
q.normalise();
return q;
}
};
}
}
/**
@ -861,5 +861,5 @@ export class Vec3 {
*/
export function vec3(x, y, z) {
return new Vec3(x, y, z);
};
}

View File

@ -41,14 +41,14 @@ export class Vec4 {
* @type {number}
*/
this.w = w || 0.0;
};
}
/**
* Identity vector [0,0,0,1].
* @const
* @type {og.math.Vec4}
*/
static get identity() { return new Vec4(0, 0, 0, 1) };
static get identity() { return new Vec4(0, 0, 0, 1) }
/**
* Creates 4d vector from array.
@ -58,7 +58,7 @@ export class Vec4 {
*/
static fromVec(arr) {
return new Vec4(arr[0], arr[1], arr[2], arr[3]);
};
}
/**
* Converts to 3d vector, without fourth value.
@ -67,7 +67,7 @@ export class Vec4 {
*/
toVec3() {
return new Vec3(this.x, this.y, this.z);
};
}
/**
* Returns clone vector.
@ -76,7 +76,7 @@ export class Vec4 {
*/
clone(v) {
return new Vec4(this.x, this.y, this.z, this.w);
};
}
/**
* Compares with vector. Returns true if it equals another.
@ -86,7 +86,7 @@ export class Vec4 {
*/
equal(v) {
return this.x === v.x && this.y === v.y && this.z === v.z && this.w === v.w;
};
}
/**
* Copy input vector's values.
@ -99,7 +99,7 @@ export class Vec4 {
this.z = v.z;
this.w = v.w;
return this;
};
}
/**
* Converts vector to a number array.
@ -109,7 +109,7 @@ export class Vec4 {
*/
toVec() {
return [this.x, this.y, this.z, this.w];
};
}
/**
* Converts vector to a number array.
@ -118,7 +118,7 @@ export class Vec4 {
*/
toArray() {
return [this.x, this.y, this.z, this.w];
};
}
/**
* Sets vector's values.
@ -135,7 +135,7 @@ export class Vec4 {
this.z = z;
this.w = w;
return this;
};
}
/**
* Adds vector to the current.
@ -149,7 +149,7 @@ export class Vec4 {
this.z += v.z;
this.w += v.w;
return this;
};
}
/**
* Subtract vector from the current.
@ -163,7 +163,7 @@ export class Vec4 {
this.z -= v.z;
this.w -= v.w;
return this;
};
}
/**
* Scale current vector.
@ -177,7 +177,7 @@ export class Vec4 {
this.z *= scale;
this.w *= scale;
return this;
};
}
/**
* Makes vector affinity. Thereby fourh component becomes to 1.0.
@ -191,7 +191,7 @@ export class Vec4 {
this.z *= iw;
this.w = 1.0;
return this;
};
}
/**
* Scale current vector to another instance.
@ -201,7 +201,7 @@ export class Vec4 {
*/
scaleTo(scale) {
return new Vec4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
};
}
/**
* Vector's edge function that returns vector where each component is 0.0 if it's smaller then edge and otherwise 1.0.
@ -215,7 +215,7 @@ export class Vec4 {
this.z < edge ? 0.0 : 1.0,
this.w < edge ? 0.0 : 1.0
);
};
}
/**
* The vector fract function returns the vector of fractional parts of each value, i.e. x minus floor(x).
@ -229,7 +229,7 @@ export class Vec4 {
og.math.frac(v.z),
og.math.frac(v.w)
);
};
}
/**
* Gets vectors dot production.
@ -239,7 +239,7 @@ export class Vec4 {
*/
dot(v) {
return v.x * this.x + v.y * this.y + v.z * this.z + v.w * this.w;
};
}
/**
* Returns true if vector's values are zero.
@ -248,7 +248,7 @@ export class Vec4 {
*/
isZero() {
return !(this.x || this.y || this.z || this.w);
};
}
}
/**
@ -262,4 +262,4 @@ export class Vec4 {
*/
export function vec4(x, y, z, w) {
return new og.math.Vec4(x, y, z, w);
};
}

View File

@ -17,7 +17,7 @@ export function encodeFloatToRGBA(v) {
var enc = new Vec4(1.0 * v % 1, 255.0 * v % 1, 65025.0 * v % 1, 160581375.0 * v % 1);
var yzww = new Vec4(enc.y / 255, enc.z / 255, enc.w / 255, 0);
return enc.subA(yzww);
};
}
/**
* Decode RGBA vector to 32 bit float value.
@ -30,7 +30,7 @@ export function decodeFloatFromRGBA(rgba) {
var e = 2.0 * math.mod(rgba.x, 128.0) + math.step(128.0, rgba.y) - 127.0;
var m = math.mod(rgba.y, 128.0) * 65536.0 + rgba.z * 256.0 + rgba.w + 8388608.00;
return s * math.exp2(e) * (m * 1.1920928955078125e-7);
};
}
/**
* Decode RGBA vector to 32 bit float value.
@ -43,7 +43,7 @@ export function decodeFloatFromRGBAArr(arr, use32) {
var e = 2.0 * math.mod(arr[0], 128.0) + math.step(128.0, arr[1]) - 127.0;
var m = math.mod(arr[1], 128.0) * 65536.0 + arr[2] * 256.0 + (use32 ? arr[3] : 0.0) + 8388608.00;
return s * math.exp2(e) * (m * 1.1920928955078125e-7);
};
}
/**
* Separate 64 bit value to two 32 bit float values.
@ -63,7 +63,7 @@ export function doubleToTwoFloats(value) {
low = Math.fround(value + doubleHigh);
}
return new Float32Array([high, low]);
};
}
/**
* Separate 64 bit value to two 32 bit float values.
@ -82,7 +82,7 @@ export function doubleToTwoFloats2(value, highLowArr) {
highLowArr[1] = Math.fround(value + doubleHigh);
}
return highLowArr;
};
}
/**
* Separate 64 bit value to two 32 bit float values.
@ -101,4 +101,4 @@ export function doubleToTwoFloatsV2(value, highLowVec) {
highLowVec.y = Math.fround(value + doubleHigh);
}
return highLowVec;
};
}

View File

@ -48,7 +48,7 @@ export const ONE_BY_POLE_DOUBLE = 1.0 / POLE_DOUBLE;
export function forward(lonLat) {
return new LonLat(lonLat.lon * POLE / 180.0, Math.log(Math.tan((90.0 + lonLat.lat) * PI_BY_360)) * POLE_BY_PI, lonLat.height);
};
}
/**
* Converts degrees longitude to mercator coordinate.
@ -58,7 +58,7 @@ export function forward(lonLat) {
*/
export function forward_lon(lon) {
return lon * POLE / 180.0;
};
}
/**
* Converts degrees latitude to mercator coordinate.
@ -68,7 +68,7 @@ export function forward_lon(lon) {
*/
export function forward_lat(lat) {
return Math.log(Math.tan((90.0 + lat) * PI_BY_360)) * POLE_BY_PI;
};
}
/**
* Converts mercator longitude to degrees coordinate.
@ -78,7 +78,7 @@ export function forward_lat(lat) {
*/
export function inverse_lon(lon) {
return 180 * lon / POLE;
};
}
/**
* Converts mercator latitude to degrees coordinate.
@ -88,7 +88,7 @@ export function inverse_lon(lon) {
*/
export function inverse_lat(lat) {
return INV_PI_BY_180 * (2.0 * Math.atan(Math.exp(lat * PI_BY_POLE)) - HALF_PI);
};
}
/**
* Returns mercator map tile grid horizontal coordinate index by geodetic
@ -100,7 +100,7 @@ export function inverse_lat(lat) {
*/
export function getTileX(lon, zoom) {
return Math.floor((lon + 180) / 360.0 * Math.pow(2, zoom));
};
}
/**
* Returns mercator map tile grid vertical coordinate index by geodetic
@ -112,7 +112,7 @@ export function getTileX(lon, zoom) {
*/
export function getTileY(lat, zoom) {
return Math.floor((1.0 - Math.log(Math.tan(lat * PI_BY_180) + 1.0 / Math.cos(lat * PI_BY_180)) / Math.PI) * 0.5 * Math.pow(2, zoom));
};
}
/**
* Converts geodetic coordinate array to mercator coordinate array.
@ -126,13 +126,13 @@ export function forwardArray(lonlatArr) {
res.push(lonlatArr[i].forwardMercator());
}
return res;
};
}
export function getTileExtent(x, y, z) {
let size = POLE2 / Math.pow(2, z),
sw = new LonLat(-POLE + x * size, POLE - y * size - size);
return new Extent(sw, new LonLat(sw.lon + size, sw.lat + size));
};
}
/**
* Max mercator latitude.

View File

@ -73,6 +73,6 @@ class Axes extends RenderNode {
this.axisBuffer = this.renderer.handler.createArrayBuffer(new Float32Array(vertices), 3, 6);
this.axisColorBuffer = this.renderer.handler.createArrayBuffer(new Float32Array(colors), 4, 6);
}
};
}
export { Axes };

View File

@ -109,6 +109,6 @@ class BaseNode {
isEqual(node) {
return node.__staticId === this.__staticId;
}
};
}
export { BaseNode };

View File

@ -342,6 +342,6 @@ class RenderNode extends BaseNode {
_entityCollectionPickingCallback() {
this.drawPickingEntityCollections(this.entityCollections);
}
};
}
export { RenderNode };

View File

@ -103,6 +103,6 @@ class SkyBox extends RenderNode {
this.vertexPositionBuffer = this.renderer.handler.createArrayBuffer(vertices, 3, vertices.length / 3);
}
};
}
export { SkyBox };

View File

@ -4,7 +4,7 @@ import { N, W, S, E } from '../quadTree/quadTree.js';
function NewIndexesTypedArray(arr) {
return new Uint32Array(arr);
};
}
function createCenterBodyIndexes(size) {
@ -29,7 +29,7 @@ function createCenterBodyIndexes(size) {
indexes.push(indexes[indexes.length - 1], size * size - size);
return NewIndexesTypedArray(indexes);
};
}
function createWestNeighborSkirt(size, deltaGr) {
let indexes = [];
@ -51,7 +51,7 @@ function createWestNeighborSkirt(size, deltaGr) {
}
return NewIndexesTypedArray(indexes);
};
}
function createNorthNeighborSkirt(size, deltaGr) {
let indexes = [];
@ -72,7 +72,7 @@ function createNorthNeighborSkirt(size, deltaGr) {
}
return NewIndexesTypedArray(indexes);
};
}
function createEastNeighborSkirt(size, deltaGr) {
let indexes = [];
@ -93,7 +93,7 @@ function createEastNeighborSkirt(size, deltaGr) {
}
return NewIndexesTypedArray(indexes);
};
}
function createSouthNeighborSkirt(size, deltaGr) {
let indexes = [];
@ -116,7 +116,7 @@ function createSouthNeighborSkirt(size, deltaGr) {
indexes.push(size * size - size);
return NewIndexesTypedArray(indexes);
};
}
function initIndexesBodySkirts(pow) {
var table = [];
@ -145,7 +145,7 @@ function initIndexesBodySkirts(pow) {
}
}
return table;
};
}
function initIndexBodiesTable(pow) {
var table = [];
@ -154,7 +154,7 @@ function initIndexBodiesTable(pow) {
table[i] = createCenterBodyIndexes(d + 1);
}
return table;
};
}
function createTextureCoords(size) {
var texCoords = new Uint16Array((size + 1) * (size + 1) * 2);
@ -166,7 +166,7 @@ function createTextureCoords(size) {
}
}
return texCoords;
};
}
class SegmentHelper {
constructor(maxGridSize = 0) {
@ -217,10 +217,10 @@ class SegmentHelper {
}
return table;
}
};
}
let instance = new SegmentHelper();
export function getInstance() {
return instance;
};
}

View File

@ -34,4 +34,4 @@ export function bloom() {
gl_FragColor = vOriginal + vT1 + vT2;
}`
});
};
}

View File

@ -24,7 +24,7 @@ export function buildKernel(sigma) {
for (i = 0; i < kernelSize; ++i) values[i] /= sum;
return values;
};
}
export function blur() {
@ -76,4 +76,4 @@ export function blur() {
gl_FragColor = sum;
}`
});
};
}

View File

@ -45,4 +45,4 @@ export function depth() {
fragColor = vec4(c, c, c, 1.0);
}`
});
};
}

View File

@ -454,4 +454,4 @@ export function label_screen() {
gl_FragColor = vec4(v_rgba.rgb, opacity * v_rgba.a);
}`
});
};
}

View File

@ -38,4 +38,4 @@ export function lumFilter() {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
}`
});
};
}

View File

@ -39,4 +39,4 @@ export function pointCloud() {
gl_FragColor = color;
}`
});
};
}

View File

@ -28,4 +28,4 @@ export function screenFrame() {
gl_FragColor = texture2D( texture, tc );
}`
});
};
}

View File

@ -76,7 +76,7 @@ export function shape_wl() {
gl_FragColor = vec4(lightWeighting, uColor.a) * cc * uColor;
}`
});
};
}
export function shape_nl() {
return new Program("shape_nl", {
@ -110,7 +110,7 @@ export function shape_nl() {
gl_FragColor = uColor*texture2D( uSampler, vTextureCoord.st );
}`
});
};
}
export function shape_picking() {
return new Program("shape_picking", {
@ -138,4 +138,4 @@ export function shape_picking() {
gl_FragColor = uColor;
}`
});
};
}

View File

@ -34,4 +34,4 @@ export function skybox() {
gl_FragColor = textureCube(uSampler, vTextureCoord);
}`
});
};
}

View File

@ -86,4 +86,4 @@ export function toneMapping() {
fragColor = vec4(mapped, 1.0);
}`
});
};
}

View File

@ -96,7 +96,7 @@ class Geoid {
}
if ((j > start) && (rawfile[j - 1] === 13)) j--;
return String.fromCharCode.apply(null, rawfile.slice(start, j));
};
}
var m, s;
for (; ;) {
@ -237,6 +237,6 @@ class Geoid {
return model.offset + model.scale * h;
}
};
}
export { Geoid };

View File

@ -19,12 +19,12 @@ export class GeoImageCreator {
this._queue = [];
this._animate = [];
this._initialize();
};
}
_initialize() {
this._initShaders();
this._initBuffers();
};
}
/**
* Creates geoImage corners coordinates grid buffer.
@ -62,7 +62,7 @@ export class GeoImageCreator {
}
}
return this._planet.renderer.handler.createArrayBuffer(grid, 2, grid.length / 2);
};
}
frame() {
var i = this.MAX_FRAMES;
@ -76,7 +76,7 @@ export class GeoImageCreator {
while (i--) {
this._animate[i].rendering();
}
};
}
add(geoImage) {
if (!geoImage._isRendering) {
@ -87,7 +87,7 @@ export class GeoImageCreator {
this._queue.push(geoImage);
}
}
};
}
remove(geoImage) {
if (geoImage._isRendering) {
@ -106,7 +106,7 @@ export class GeoImageCreator {
}
}
}
};
}
_initBuffers() {
@ -126,7 +126,7 @@ export class GeoImageCreator {
this._quadTexCoordsBuffer = h.createArrayBuffer(new Float32Array([0, 1, 1, 1, 0, 0, 1, 0]), 2, 4);
this._quadVertexBuffer = h.createArrayBuffer(new Float32Array([-1, 1, 1, 1, -1, -1, 1, -1]), 2, 4);
};
}
_initShaders() {
@ -155,6 +155,6 @@ export class GeoImageCreator {
gl_FragColor = texture2D(sourceTexture, v_texCoords);
}`
}));
};
}
}

View File

@ -12,7 +12,7 @@ if (window && !('createImageBitmap' in window)) {
img.src = URL.createObjectURL(blob);
});
};
};
}
export class Loader {
@ -33,12 +33,12 @@ export class Loader {
'imageBitmap': r => r.blob().then(createImageBitmap),
'text': r => r.text()
};
};
}
load(params, callback) {
this._queue.push({ 'params': params, 'callback': callback });
this._exec();
};
}
fetch(params) {
return fetch(
@ -60,7 +60,7 @@ export class Loader {
.catch(err => {
return { 'status': "error", 'msg': err.toString() };
});
};
}
_exec() {
@ -98,7 +98,7 @@ export class Loader {
} else if (this._loading === 0) {
this.events.dispatch(this.events.loadend);
}
};
}
abort() {
//this._queue.each(e => e.callback({ 'status': "abort" }));
@ -109,5 +109,5 @@ export class Loader {
this._queue[i] = null;
}
this._queue = [];
};
}
}

View File

@ -35,7 +35,7 @@ export class NormalMapCreator {
this._lock = new Lock();
this._init();
};
}
_init() {
var isWebkit = false; //('WebkitAppearance' in document.documentElement.style) && !/^((?!chrome).)*safari/i.test(navigator.userAgent);
@ -161,7 +161,7 @@ export class NormalMapCreator {
var positions = new Float32Array([-1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0]);
this._positionBuffer = this._handler.createArrayBuffer(positions, 2, positions.length / 2);
};
}
_drawNormalMapBlur(segment) {
var normals = segment.normalMapNormals;
@ -242,7 +242,7 @@ export class NormalMapCreator {
}
}
return false;
};
}
_drawNormalMapNoBlur(segment) {
var normals = segment.normalMapNormals;
@ -302,7 +302,7 @@ export class NormalMapCreator {
}
}
return false;
};
}
_drawNormalMap(segment) {
let t = segment.planet.terrain;
@ -312,7 +312,7 @@ export class NormalMapCreator {
} else {
return this._drawNormalMapNoBlur(segment);
}
};
}
drawSingle(segment) {
var h = this._handler,
@ -337,7 +337,7 @@ export class NormalMapCreator {
gl.enable(gl.CULL_FACE);
this._framebuffer.deactivate();
};
}
frame() {
if (this._queue.length) {
@ -371,28 +371,28 @@ export class NormalMapCreator {
this._framebuffer.deactivate();
}
};
}
queue(segment) {
segment._inTheQueue = true;
this._queue.push(segment);
};
}
unshift(segment) {
segment._inTheQueue = true;
this._queue.unshift(segment);
};
}
remove(segment) {
//...
};
}
clear() {
while (this._queue.length) {
var s = this._queue.pop();
s._inTheQueue = false;
}
};
}
/**
* Set activity off
@ -400,7 +400,7 @@ export class NormalMapCreator {
*/
lock(key) {
this._lock.lock(key);
};
}
/**
* Set activity on
@ -408,6 +408,6 @@ export class NormalMapCreator {
*/
free(key) {
this._lock.free(key);
};
}
}

View File

@ -84,7 +84,7 @@ class TerrainWorker {
this.check();
}
}
};
}
const _programm =
`'use strict';

View File

@ -24,7 +24,7 @@ export class VectorTileCreator {
this._currentFrame = 0;
this._queue = [];
this._initialize();
};
}
_initialize() {
@ -189,7 +189,7 @@ export class VectorTileCreator {
useDepth: false
});
this._framebuffer.init();
};
}
frame() {
if (this._planet.layerLock.isFree() && this._queue.length) {
@ -404,13 +404,13 @@ export class VectorTileCreator {
f.deactivate();
}
};
}
add(material) {
this._queue.push(material);
};
}
remove(material) {
//...
};
}
}

View File

@ -629,7 +629,7 @@ function deviation(data, holeIndices, dim, triangles) {
return polygonArea === 0 && trianglesArea === 0 ? 0 :
Math.abs((trianglesArea - polygonArea) / polygonArea);
};
}
function signedArea(data, start, end, dim) {
var sum = 0;

View File

@ -97,7 +97,7 @@ export class Framebuffer {
* @type {number}
*/
this.textures = options.textures || new Array(this._size);
};
}
static blit(sourceFramebuffer, destFramebuffer, glAttachment, glMask, glFilter) {
@ -118,7 +118,7 @@ export class Framebuffer {
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
gl.bindFramebuffer(gl.READ_FRAMEBUFFER, null);
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);
};
}
destroy() {
var gl = this.handler.gl;
@ -135,7 +135,7 @@ export class Framebuffer {
this._fbo = null;
this._active = false;
};
}
/**
* Framebuffer initialization.
@ -186,7 +186,7 @@ export class Framebuffer {
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
return this;
};
}
/**
* Bind buffer texture.
@ -199,7 +199,7 @@ export class Framebuffer {
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.framebufferTexture2D(gl.FRAMEBUFFER, glAttachment || gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
gl.bindTexture(gl.TEXTURE_2D, null);
};
}
/**
* Sets framebuffer viewport size.
@ -219,7 +219,7 @@ export class Framebuffer {
this.destroy();
this.init();
}
};
}
/**
* Returns framebuffer completed.
@ -232,7 +232,7 @@ export class Framebuffer {
return true;
}
return false;
};
}
/**
* Gets pixel RBGA color from framebuffer by coordinates.
@ -250,7 +250,7 @@ export class Framebuffer {
gl.readBuffer && gl.readBuffer(gl.COLOR_ATTACHMENT0 + index || 0);
gl.readPixels(nx * this._width, ny * this._height, w, h, gl.RGBA, gl[this._typeArr[index]], res);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
};
}
/**
* Reads all pixels(RGBA colors) from framebuffer.
@ -264,7 +264,7 @@ export class Framebuffer {
gl.readBuffer && gl.readBuffer(gl.COLOR_ATTACHMENT0 + attachmentIndex);
gl.readPixels(0, 0, this._width, this._height, gl.RGBA, gl[this._typeArr[attachmentIndex]], res);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
};
}
/**
* Activate framebuffer frame to draw.
@ -281,7 +281,7 @@ export class Framebuffer {
c && (c._active = false);
this.handler.framebufferStack.push(this);
return this;
};
}
/**
* Deactivate framebuffer frame.
@ -301,7 +301,7 @@ export class Framebuffer {
} else {
gl.viewport(0, 0, h.canvas.width, h.canvas.height);
}
};
}
/**
* Gets JavaScript image object that framebuffer has drawn.
@ -314,7 +314,7 @@ export class Framebuffer {
var imageCanvas = new ImageCanvas(this._width, this._height);
imageCanvas.setData(data);
return imageCanvas.getImage();
};
}
/**
* Open dialog window with framebuffer image.
@ -335,5 +335,5 @@ export class Framebuffer {
printWin.document.write(windowContent);
printWin.document.close();
printWin.focus();
};
}
}

View File

@ -78,7 +78,7 @@ export class Multisample {
this._glFilter = null;
this.renderbuffers = new Array(this._size);
};
}
destroy() {
var gl = this.handler.gl;
@ -95,7 +95,7 @@ export class Multisample {
this._fbo = null;
this._active = false;
};
}
/**
* Framebuffer initialization.
@ -134,7 +134,7 @@ export class Multisample {
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
return this;
};
}
blitTo(framebuffer, attachmentIndex = 0) {
@ -155,7 +155,7 @@ export class Multisample {
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
gl.bindFramebuffer(gl.READ_FRAMEBUFFER, null);
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);
};
}
/**
* Sets framebuffer viewport size.
@ -175,7 +175,7 @@ export class Multisample {
this.destroy();
this.init();
}
};
}
/**
* Returns framebuffer completed.
@ -188,7 +188,7 @@ export class Multisample {
return true;
}
return false;
};
}
/**
* Activate framebuffer frame to draw.
@ -205,7 +205,7 @@ export class Multisample {
c && (c._active = false);
this.handler.framebufferStack.push(this);
return this;
};
}
/**
* Deactivate framebuffer frame.
@ -228,5 +228,5 @@ export class Multisample {
} else {
gl.viewport(0, 0, h.canvas.width, h.canvas.height);
}
};
}
}

View File

@ -346,6 +346,6 @@ class Program {
gl.deleteShader(fs);
gl.deleteShader(vs);
}
};
}
export { Program };

View File

@ -32,7 +32,7 @@ export class ProgramController {
* @type {boolean}
*/
this._activated = false;
};
}
/**
* Lazy create program call.
@ -40,7 +40,7 @@ export class ProgramController {
*/
initialize() {
this._program.createProgram(this._handler.gl);
};
}
/**
* Returns controller's shader program.
@ -49,7 +49,7 @@ export class ProgramController {
*/
getProgram() {
return this._program;
};
}
/**
* Activates current shader program.
@ -66,7 +66,7 @@ export class ProgramController {
p.use();
}
return this;
};
}
/**
* Remove program from handler
@ -82,7 +82,7 @@ export class ProgramController {
p[this._program.name] = null;
delete p[this._program.name];
}
};
}
/**
* Deactivate shader program. This is not necessary while activae function used.
@ -91,7 +91,7 @@ export class ProgramController {
deactivate() {
this._program.disableAttribArrays();
this._activated = false;
};
}
/**
* Returns program activity.
@ -100,7 +100,7 @@ export class ProgramController {
*/
isActive() {
return this._activated;
};
}
/**
* Sets program uniforms and attributes values and return controller instance.
@ -112,7 +112,7 @@ export class ProgramController {
this.activate();
this._program.set(params);
return this;
};
}
/**
* Draw index buffer with this program.
@ -124,7 +124,7 @@ export class ProgramController {
drawIndexBuffer(mode, buffer) {
this._program.drawIndexBuffer(mode, buffer);
return this;
};
}
/**
* Calls Gl drawArray function.
@ -135,5 +135,5 @@ export class ProgramController {
drawArrays(mode, numItems) {
this._program.drawArrays(mode, numItems);
return this;
};
}
}