#706 docs cleanup

This commit is contained in:
Zemledelec 2023-05-24 09:27:54 +04:00
parent 8f0b76641e
commit 36862fee55
104 changed files with 3881 additions and 4233 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ Release
Debug Debug
eslint eslint
node_modules node_modules
docs
.eslintrc .eslintrc
.csslintrc .csslintrc
.idea .idea

View File

@ -1,7 +1,3 @@
/**
* @module og/Clock
*/
"use strict"; "use strict";
import * as jd from "./astro/jd.js"; import * as jd from "./astro/jd.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/Events
*/
"use strict"; "use strict";
import { binaryInsert, stamp } from "./utils/shared.js"; import { binaryInsert, stamp } from "./utils/shared.js";

View File

@ -1,356 +1,352 @@
/** "use strict";
* @module og/Extent
*/ import { LonLat } from "./LonLat.js";
import * as math from "./math.js";
"use strict"; import * as mercator from "./mercator.js";
import { LonLat } from "./LonLat.js"; /**
import * as math from "./math.js"; * Represents geographical coordinates extent.
import * as mercator from "./mercator.js"; * @class
* @param {LonLat} [sw] - South West extent corner coordiantes.
/** * @param {LonLat} [ne] - North East extent corner coordiantes.
* Represents geographical coordinates extent. */
* @class export class Extent {
* @param {LonLat} [sw] - South West extent corner coordiantes. /**
* @param {LonLat} [ne] - North East extent corner coordiantes. * @param {LonLat} [sw] - South West extent corner coordiantes.
*/ * @param {LonLat} [ne] - North East extent corner coordiantes.
export class Extent { */
/** constructor(sw = new LonLat(), ne = new LonLat()) {
* @param {LonLat} [sw] - South West extent corner coordiantes. /**
* @param {LonLat} [ne] - North East extent corner coordiantes. * @public
*/ */
constructor(sw = new LonLat(), ne = new LonLat()) { this.southWest = sw;
/** /**
* @public * @public
*/ */
this.southWest = sw; this.northEast = ne;
/** }
* @public
*/ /**
this.northEast = ne; * Whole mercator extent.
} * @const
*/
/** static get FULL_MERC() {
* Whole mercator extent. return new Extent(LonLat.SW_MERC, LonLat.NE_MERC);
* @const }
*/
static get FULL_MERC() { /**
return new Extent(LonLat.SW_MERC, LonLat.NE_MERC); * Degrees extent from north mercator limit to north pole.
} * @const
*/
/** static get NORTH_POLE_DEG() {
* Degrees extent from north mercator limit to north pole. return new Extent(LonLat.NW_MERC_DEG, new LonLat(180.0, 90.0));
* @const }
*/
static get NORTH_POLE_DEG() { /**
return new Extent(LonLat.NW_MERC_DEG, new LonLat(180.0, 90.0)); * Degrees extent from south pole to south mercator limit.
} * @const
*/
/** static get SOUTH_POLE_DEG() {
* Degrees extent from south pole to south mercator limit. return new Extent(new LonLat(-180.0, -90.0), LonLat.SE_MERC_DEG);
* @const }
*/
static get SOUTH_POLE_DEG() { /**
return new Extent(new LonLat(-180.0, -90.0), LonLat.SE_MERC_DEG); * Creates extent instance from values in array.
} * @static
* @param {Array.<number>} arr - South west and north east longitude and latidudes packed in array. (exactly 4 entries)
/** * @return {Extent} Extent object.
* Creates extent instance from values in array. */
* @static static createFromArray(arr) {
* @param {Array.<number>} arr - South west and north east longitude and latidudes packed in array. (exactly 4 entries) return new Extent(new LonLat(arr[0], arr[1]), new LonLat(arr[2], arr[3]));
* @return {Extent} Extent object. }
*/
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.
} * @static
* @param {Array.<LonLat>} arr - Coordinate array.
/** * @return {Extent} Extent object.
* Creates bound extent instance by coordinate array. */
* @static static createByCoordinates(arr) {
* @param {Array.<LonLat>} arr - Coordinate array. let lonmin = math.MAX,
* @return {Extent} Extent object. lonmax = math.MIN,
*/ latmin = math.MAX,
static createByCoordinates(arr) { latmax = math.MIN;
let lonmin = math.MAX, for (let i = 0; i < arr.length; i++) {
lonmax = math.MIN, const vi = arr[i];
latmin = math.MAX, if (vi.lon < lonmin) lonmin = vi.lon;
latmax = math.MIN; if (vi.lon > lonmax) lonmax = vi.lon;
for (let i = 0; i < arr.length; i++) { if (vi.lat < latmin) latmin = vi.lat;
const vi = arr[i]; if (vi.lat > latmax) latmax = vi.lat;
if (vi.lon < lonmin) lonmin = vi.lon; }
if (vi.lon > lonmax) lonmax = vi.lon; return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
if (vi.lat < latmin) latmin = vi.lat; }
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.
} * @static
* @param {Array.<Array<number>>} arr - Coordinate array. (exactly 2 entries)
/** * @return {Extent} Extent object.
* Creates bound extent instance by coordinate array. */
* @static static createByCoordinatesArr(arr) {
* @param {Array.<Array<number>>} arr - Coordinate array. (exactly 2 entries) let lonmin = math.MAX,
* @return {Extent} Extent object. lonmax = math.MIN,
*/ latmin = math.MAX,
static createByCoordinatesArr(arr) { latmax = math.MIN;
let lonmin = math.MAX, for (let i = 0; i < arr.length; i++) {
lonmax = math.MIN, const vi = arr[i];
latmin = math.MAX, if (vi[0] < lonmin) lonmin = vi[0];
latmax = math.MIN; if (vi[0] > lonmax) lonmax = vi[0];
for (let i = 0; i < arr.length; i++) { if (vi[1] < latmin) latmin = vi[1];
const vi = arr[i]; if (vi[1] > latmax) latmax = vi[1];
if (vi[0] < lonmin) lonmin = vi[0]; }
if (vi[0] > lonmax) lonmax = vi[0]; return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
if (vi[1] < latmin) latmin = vi[1]; }
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.
} * @static
* @param {number} x -
/** * @param {number} y -
* Creates extent by meractor grid tile coordinates. * @param {number} z -
* @static * @param {number} width -
* @param {number} x - * @param {number} height -
* @param {number} y - * @returns {Extent} -
* @param {number} z - */
* @param {number} width - static fromTile(x, y, z, width, height) {
* @param {number} height - width = width || mercator.POLE_DOUBLE;
* @returns {Extent} - height = height || mercator.POLE_DOUBLE;
*/ const H = Math.pow(2, z),
static fromTile(x, y, z, width, height) { W = Math.pow(2, z),
width = width || mercator.POLE_DOUBLE; lnSize = width / W,
height = height || mercator.POLE_DOUBLE; ltSize = height / H;
const H = Math.pow(2, z),
W = Math.pow(2, z), const left = -width * 0.5 + x * lnSize,
lnSize = width / W, top = height * 0.5 - y * ltSize,
ltSize = height / H; bottom = top - ltSize,
right = left + lnSize;
const left = -width * 0.5 + x * lnSize,
top = height * 0.5 - y * ltSize, return new Extent(new LonLat(left, bottom), new LonLat(right, top));
bottom = top - ltSize, }
right = left + lnSize;
/**
return new Extent(new LonLat(left, bottom), new LonLat(right, top)); * Sets current bounding extent object by coordinate array.
} * @public
* @param {Array.<LonLat>} arr - Coordinate array.
/** * @return {Extent} Current extent.
* Sets current bounding extent object by coordinate array. */
* @public setByCoordinates(arr) {
* @param {Array.<LonLat>} arr - Coordinate array. let lonmin = math.MAX,
* @return {Extent} Current extent. lonmax = math.MIN,
*/ latmin = math.MAX,
setByCoordinates(arr) { latmax = math.MIN;
let lonmin = math.MAX, for (let i = 0; i < arr.length; i++) {
lonmax = math.MIN, const vi = arr[i];
latmin = math.MAX, if (vi.lon < lonmin) lonmin = vi.lon;
latmax = math.MIN; if (vi.lon > lonmax) lonmax = vi.lon;
for (let i = 0; i < arr.length; i++) { if (vi.lat < latmin) latmin = vi.lat;
const vi = arr[i]; if (vi.lat > latmax) latmax = vi.lat;
if (vi.lon < lonmin) lonmin = vi.lon; }
if (vi.lon > lonmax) lonmax = vi.lon; this.southWest.lon = lonmin;
if (vi.lat < latmin) latmin = vi.lat; this.southWest.lat = latmin;
if (vi.lat > latmax) latmax = vi.lat; this.northEast.lon = lonmax;
} this.northEast.lat = latmax;
this.southWest.lon = lonmin; return this;
this.southWest.lat = latmin; }
this.northEast.lon = lonmax;
this.northEast.lat = latmax; /**
return this; * Determines if point inside extent.
} * @public
* @param {LonLat} lonlat - Coordinate point.
/** * @return {boolean} Returns true if point inside extent.
* Determines if point inside extent. */
* @public isInside(lonlat) {
* @param {LonLat} lonlat - Coordinate point. const sw = this.southWest,
* @return {boolean} Returns true if point inside extent. ne = this.northEast;
*/ return (
isInside(lonlat) { lonlat.lon >= sw.lon &&
const sw = this.southWest, lonlat.lon <= ne.lon &&
ne = this.northEast; lonlat.lat >= sw.lat &&
return ( lonlat.lat <= ne.lat
lonlat.lon >= sw.lon && );
lonlat.lon <= ne.lon && }
lonlat.lat >= sw.lat &&
lonlat.lat <= ne.lat /**
); * Returns true if two extent overlap each other.
} * @public
* @param {Extent} e - Another extent.
/** * @return {boolean} -
* Returns true if two extent overlap each other. */
* @public overlaps(e) {
* @param {Extent} e - Another extent. const sw = this.southWest,
* @return {boolean} - ne = this.northEast;
*/ return (
overlaps(e) { sw.lon <= e.northEast.lon &&
const sw = this.southWest, ne.lon >= e.southWest.lon &&
ne = this.northEast; sw.lat <= e.northEast.lat &&
return ( ne.lat >= e.southWest.lat
sw.lon <= e.northEast.lon && );
ne.lon >= e.southWest.lon && }
sw.lat <= e.northEast.lat &&
ne.lat >= e.southWest.lat /**
); * Gets extent width.
} * @public
* @return {number} Extent width.
/** */
* Gets extent width. getWidth() {
* @public return this.northEast.lon - this.southWest.lon;
* @return {number} Extent width. }
*/
getWidth() { /**
return this.northEast.lon - this.southWest.lon; * Gets extent height.
} * @public
* @return {number} Extent height.
/** */
* Gets extent height. getHeight() {
* @public return this.northEast.lat - this.southWest.lat;
* @return {number} Extent height. }
*/
getHeight() { /**
return this.northEast.lat - this.southWest.lat; * Creates clone instance of the current extent.
} * @public
* @return {Extent} Extent clone.
/** */
* Creates clone instance of the current extent. clone() {
* @public return new Extent(this.southWest.clone(), this.northEast.clone());
* @return {Extent} Extent clone. }
*/
clone() { /**
return new Extent(this.southWest.clone(), this.northEast.clone()); * Gets the center coordinate of the extent.
} * @public
* @return {number} Center coordinate.
/** */
* Gets the center coordinate of the extent. getCenter() {
* @public const sw = this.southWest,
* @return {number} Center coordinate. ne = this.northEast;
*/ return new LonLat(sw.lon + (ne.lon - sw.lon) * 0.5, sw.lat + (ne.lat - sw.lat) * 0.5);
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 }
*/
getNorthWest() { /**
return new LonLat(this.southWest.lon, this.northEast.lat); * @public
} */
getNorthEast() {
/** return new LonLat(this.northEast.lon, this.northEast.lat);
* @public }
*/
getNorthEast() { getSouthWest() {
return new LonLat(this.northEast.lon, this.northEast.lat); return new LonLat(this.southWest.lon, this.southWest.lat);
} }
getSouthWest() { /**
return new LonLat(this.southWest.lon, this.southWest.lat); * @public
} */
getSouthEast() {
/** return new LonLat(this.northEast.lon, this.southWest.lat);
* @public }
*/
getSouthEast() { /**
return new LonLat(this.northEast.lon, this.southWest.lat); * @public
} */
getNorth() {
/** return this.northEast.lat;
* @public }
*/
getNorth() { getEast() {
return this.northEast.lat; return this.northEast.lon;
} }
getEast() { /**
return this.northEast.lon; * @public
} */
getWest() {
/** return this.southWest.lon;
* @public }
*/
getWest() { /**
return this.southWest.lon; * @public
} */
getSouth() {
/** return this.southWest.lat;
* @public }
*/
getSouth() { /**
return this.southWest.lat; * Returns extents are equals.
} * @param {Extent} extent - Extent.
* @returns {boolean} -
/** */
* Returns extents are equals. equals(extent) {
* @param {Extent} extent - Extent. return (
* @returns {boolean} - this.southWest.lon === extent.southWest.lon &&
*/ this.southWest.lat === extent.southWest.lat &&
equals(extent) { this.northEast.lon === extent.northEast.lon &&
return ( this.northEast.lat === extent.northEast.lat
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.
} * @public
* @return {Extent} New instance of the current extent.
/** */
* Converts extent coordinates to mercator projection coordinates. forwardMercator() {
* @public return new Extent(this.southWest.forwardMercator(), this.northEast.forwardMercator());
* @return {Extent} New instance of the current extent. }
*/
forwardMercator() { /**
return new Extent(this.southWest.forwardMercator(), this.northEast.forwardMercator()); * Converts extent coordinates from mercator projection to degrees.
} * @public
* @return {Extent} New instance of the current extent.
/** */
* Converts extent coordinates from mercator projection to degrees. inverseMercator() {
* @public return new Extent(this.southWest.inverseMercator(), this.northEast.inverseMercator());
* @return {Extent} New instance of the current extent. }
*/
inverseMercator() { /**
return new Extent(this.southWest.inverseMercator(), this.northEast.inverseMercator()); * Gets cartesian bounding bounds of the current ellipsoid.
} * @public
* @param {Ellipsoid} ellipsoid - Ellipsoid.
/** * @return {Array.<number>} Cartesian 3d coordinate array. (exactly 6 entries)
* Gets cartesian bounding bounds of the current ellipsoid. */
* @public getCartesianBounds(ellipsoid) {
* @param {Ellipsoid} ellipsoid - Ellipsoid. let xmin = math.MAX,
* @return {Array.<number>} Cartesian 3d coordinate array. (exactly 6 entries) xmax = math.MIN,
*/ ymin = math.MAX,
getCartesianBounds(ellipsoid) { ymax = math.MIN,
let xmin = math.MAX, zmin = math.MAX,
xmax = math.MIN, zmax = math.MIN;
ymin = math.MAX,
ymax = math.MIN, const v = [
zmin = math.MAX, new LonLat(this.southWest.lon, this.southWest.lat),
zmax = math.MIN; new LonLat(this.southWest.lon, this.northEast.lat),
new LonLat(this.northEast.lon, this.northEast.lat),
const v = [ new LonLat(this.northEast.lon, this.southWest.lat)
new LonLat(this.southWest.lon, this.southWest.lat), ];
new LonLat(this.southWest.lon, this.northEast.lat),
new LonLat(this.northEast.lon, this.northEast.lat), for (let i = 0; i < v.length; i++) {
new LonLat(this.northEast.lon, this.southWest.lat) const coord = ellipsoid.lonLatToCartesian(v[i]);
]; const x = coord.x,
y = coord.y,
for (let i = 0; i < v.length; i++) { z = coord.z;
const coord = ellipsoid.lonLatToCartesian(v[i]); if (x < xmin) xmin = x;
const x = coord.x, if (x > xmax) xmax = x;
y = coord.y, if (y < ymin) ymin = y;
z = coord.z; if (y > ymax) ymax = y;
if (x < xmin) xmin = x; if (z < zmin) zmin = z;
if (x > xmax) xmax = x; if (z > zmax) zmax = z;
if (y < ymin) ymin = y; }
if (y > ymax) ymax = y;
if (z < zmin) zmin = z; return [xmin, ymin, zmin, xmax, ymax, zmax];
if (z > zmax) zmax = z; }
}
toString() {
return [xmin, ymin, zmin, xmax, ymax, zmax]; return (
} `[${this.southWest.lon.toFixed(5)}, ${this.southWest.lat.toFixed(5)}, ${this.northEast.lon.toFixed(5)}, ${this.northEast.lat.toFixed(5)}]`
);
toString() { }
return ( }
`[${this.southWest.lon.toFixed(5)}, ${this.southWest.lat.toFixed(5)}, ${this.northEast.lon.toFixed(5)}, ${this.northEast.lat.toFixed(5)}]`
);
}
}

View File

@ -1,4 +1,4 @@
// StandWithUkraine // #StandWithUkraine
/** /**
* @module og/Globe * @module og/Globe

View File

@ -1,229 +1,225 @@
/** "use strict";
* @module og/ImageCanvas
*/ /**
* Usefull class for working with JS canvas object.
"use strict"; * @class
*/
/** class ImageCanvas {
* Usefull class for working with JS canvas object. /**
* @class * @param {number} [width] - Canvas width. Default 256.
*/ * @param {number} [height] - Canvas height. Default 256.
class ImageCanvas { */
/** constructor(width = 256, height = 256) {
* @param {number} [width] - Canvas width. Default 256. /**
* @param {number} [height] - Canvas height. Default 256. * Canvas object.
*/ * @protected
constructor(width = 256, height = 256) { * @type {Object}
/** */
* Canvas object. this._canvas = document.createElement("canvas");
* @protected this._canvas.width = width;
* @type {Object} this._canvas.height = height;
*/
this._canvas = document.createElement("canvas"); /**
this._canvas.width = width; * Canvas context.
this._canvas.height = height; * @protected
* @type {Object}
/** */
* Canvas context. this._context = this._canvas.getContext("2d");
* @protected }
* @type {Object}
*/ /**
this._context = this._canvas.getContext("2d"); * Returns canvas object.
} * @public
* @returns {Object}
/** */
* Returns canvas object. getCanvas() {
* @public return this._canvas;
* @returns {Object} }
*/
getCanvas() { /**
return this._canvas; * Returns canvas context pointer.
} * @public
* @returns {Object}
/** */
* Returns canvas context pointer. getContext() {
* @public return this._context;
* @returns {Object} }
*/
getContext() { /**
return this._context; * Fills canvas RGBA with zeroes.
} * @public
*/
/** fillEmpty() {
* Fills canvas RGBA with zeroes. var imgd = this._context.getImageData(0, 0, this._canvas.width, this._canvas.height);
* @public var pixels = imgd.data;
*/ for (var i = 0, n = pixels.length; i < n; i += 4) {
fillEmpty() { pixels[i] = pixels[i + 1] = pixels[i + 2] = pixels[i + 3] = 0;
var imgd = this._context.getImageData(0, 0, this._canvas.width, this._canvas.height); }
var pixels = imgd.data; this._context.putImageData(imgd, 0, 0);
for (var i = 0, n = pixels.length; i < n; i += 4) { }
pixels[i] = pixels[i + 1] = pixels[i + 2] = pixels[i + 3] = 0;
} /**
this._context.putImageData(imgd, 0, 0); * Gets canvas pixels RGBA data.
} * @public
* @returns {Array.<number>}
/** */
* Gets canvas pixels RGBA data. getData() {
* @public var imgd = this._context.getImageData(0, 0, this._canvas.width, this._canvas.height);
* @returns {Array.<number>} return imgd.data;
*/ }
getData() {
var imgd = this._context.getImageData(0, 0, this._canvas.width, this._canvas.height); /**
return imgd.data; * Fill the canvas by color.
} * @public
* @param {string} color - CSS string color.
/** */
* Fill the canvas by color. fillColor(color) {
* @public this._context.fillStyle = color;
* @param {string} color - CSS string color. this._context.fillRect(0, 0, this._canvas.width, this._canvas.height);
*/ }
fillColor(color) {
this._context.fillStyle = color; /**
this._context.fillRect(0, 0, this._canvas.width, this._canvas.height); * Sets RGBA pixel data.
} * @public
* @param {Array.<number>} data - Array RGBA data.
/** */
* Sets RGBA pixel data. setData(data) {
* @public var imageData = this._context.createImageData(this._canvas.width, this._canvas.height);
* @param {Array.<number>} data - Array RGBA data. imageData.data.set(data);
*/ this._context.putImageData(imageData, 0, 0);
setData(data) { }
var imageData = this._context.createImageData(this._canvas.width, this._canvas.height);
imageData.data.set(data); /**
this._context.putImageData(imageData, 0, 0); * Resize canvas.
} * @public
* @param {number} width - Width.
/** * @param {number} height - Height.
* Resize canvas. */
* @public resize(width, height) {
* @param {number} width - Width. this._canvas.width = width;
* @param {number} height - Height. this._canvas.height = height;
*/ this._context = this._canvas.getContext("2d");
resize(width, height) { }
this._canvas.width = width;
this._canvas.height = height; /**
this._context = this._canvas.getContext("2d"); * Draw an image on the canvas.
} * @public
* @param {Image} img - Draw image.
/** * @param {number} [x] - Left top image corner X coordinate on the canvas.
* Draw an image on the canvas. * @param {number} [y] - Left top image corner Y coordinate on the canvas.
* @public * @param {number} [width] - Image width slice. Image width is default.
* @param {Image} img - Draw image. * @param {number} [height] - Image height slice. Image height is default.
* @param {number} [x] - Left top image corner X coordinate on the canvas. */
* @param {number} [y] - Left top image corner Y coordinate on the canvas. drawImage(img, x, y, width, height) {
* @param {number} [width] - Image width slice. Image width is default. this._context = this._canvas.getContext("2d");
* @param {number} [height] - Image height slice. Image height is default. this._context.drawImage(img, x || 0, y || 0, width || img.width, height || img.height);
*/ }
drawImage(img, x, y, width, height) {
this._context = this._canvas.getContext("2d"); /**
this._context.drawImage(img, x || 0, y || 0, width || img.width, height || img.height); * Converts canvas to JS image object.
} * @public
* @returns {Image}
/** */
* Converts canvas to JS image object. getImage() {
* @public var img = new Image();
* @returns {Image} img.width = this.getWidth();
*/ img.height = this.getHeight();
getImage() { img.src = this._canvas.toDataURL("image/png");
var img = new Image(); return img;
img.width = this.getWidth(); }
img.height = this.getHeight();
img.src = this._canvas.toDataURL("image/png"); /**
return img; * Get measured text width.
} * @public
* @param {string} text - Measured text.
/** * @returns {number}
* Get measured text width. */
* @public getTextWidth(text) {
* @param {string} text - Measured text. var metrics = this._context.measureText(text);
* @returns {number} return Math.round(metrics.width);
*/ }
getTextWidth(text) {
var metrics = this._context.measureText(text); /**
return Math.round(metrics.width); * Draw a text on the canvas.
} * @public
* @param {string} text - Text.
/** * @param {number} [x] - Canvas X - coordinate. 0 - default.
* Draw a text on the canvas. * @param {number} [y] - Canvas Y - coordinate. 0 - default.
* @public * @param {string} [font] - Font style. 'normal 14px Verdana' - is default.
* @param {string} text - Text. * @param {string} [color] - Css font color.
* @param {number} [x] - Canvas X - coordinate. 0 - default. */
* @param {number} [y] - Canvas Y - coordinate. 0 - default. drawText(text, x, y, font, color) {
* @param {string} [font] - Font style. 'normal 14px Verdana' - is default. this._context.fillStyle = color || "black";
* @param {string} [color] - Css font color. this._context.font = font || "normal 14px Verdana";
*/ this._context.fillText(text, x || 0, y || 14);
drawText(text, x, y, font, color) { }
this._context.fillStyle = color || "black";
this._context.font = font || "normal 14px Verdana"; /**
this._context.fillText(text, x || 0, y || 14); * Gets canvas width.
} * @public
* @returns {number}
/** */
* Gets canvas width. getWidth() {
* @public return this._canvas.width;
* @returns {number} }
*/
getWidth() { /**
return this._canvas.width; * Gets canvas height.
} * @public
* @returns {number}
/** */
* Gets canvas height. getHeight() {
* @public return this._canvas.height;
* @returns {number} }
*/
getHeight() { /**
return this._canvas.height; * Load image to canvas.
} * @public
* @param {string} url - Image url.
/** * @pararm {imageCallback} [callback] - Image onload callback.
* Load image to canvas. */
* @public load(url, callback) {
* @param {string} url - Image url. var img = new Image();
* @pararm {imageCallback} [callback] - Image onload callback. var that = this;
*/ img.onload = function () {
load(url, callback) { that.resize(img.width, img.height);
var img = new Image(); that._context.drawImage(img, 0, 0, img.width, img.height);
var that = this; callback && callback(img);
img.onload = function () { };
that.resize(img.width, img.height); img.src = url;
that._context.drawImage(img, 0, 0, img.width, img.height); }
callback && callback(img);
}; /**
img.src = url; * Open canvas image in the new window.
} * @public
*/
/** openImage() {
* Open canvas image in the new window. var img = this.getImage();
* @public var dataUrl = img.src;
*/ var windowContent = "<!DOCTYPE html>";
openImage() { windowContent += "<html>";
var img = this.getImage(); windowContent += "<head><title>Print</title></head>";
var dataUrl = img.src; windowContent += "<body>";
var windowContent = "<!DOCTYPE html>"; windowContent += '<img src="' + dataUrl + '">';
windowContent += "<html>"; windowContent += "</body>";
windowContent += "<head><title>Print</title></head>"; windowContent += "</html>";
windowContent += "<body>"; var printWin = window.open(
windowContent += '<img src="' + dataUrl + '">'; "",
windowContent += "</body>"; "",
windowContent += "</html>"; "width=" + img.width + "px ,height=" + img.height + "px"
var printWin = window.open( );
"", printWin.document.open();
"", printWin.document.write(windowContent);
"width=" + img.width + "px ,height=" + img.height + "px" printWin.document.close();
); printWin.focus();
printWin.document.open(); }
printWin.document.write(windowContent);
printWin.document.close(); destroy() {
printWin.focus(); this._canvas.width = 1;
} this._canvas.height = 1;
this._canvas = null;
destroy() { this._context = null;
this._canvas.width = 1; }
this._canvas.height = 1; }
this._canvas = null;
this._context = null; export { ImageCanvas };
}
}
export { ImageCanvas };

View File

@ -1,48 +1,44 @@
/** 'use strict';
* @module og/Lock
*/ class Lock {
'use strict'; constructor() {
this._lock = 0;
class Lock { }
constructor() { lock(key) {
this._lock = 0; this._lock |= (1 << key._id);
} }
lock(key) { free(key) {
this._lock |= (1 << key._id); this._lock &= ~(1 << key._id);
} }
free(key) { isFree() {
this._lock &= ~(1 << key._id); return this._lock === 0;
} }
isFree() { isLocked() {
return this._lock === 0; return this._lock !== 0;
} }
}
isLocked() {
return this._lock !== 0; class Key {
}
} static get _staticCounter() {
if (!this._counter && this._counter !== 0) {
class Key { this._counter = 0;
}
static get _staticCounter() { return this._counter;
if (!this._counter && this._counter !== 0) { }
this._counter = 0;
} static set _staticCounter(n) {
return this._counter; this._counter = n;
} }
static set _staticCounter(n) { constructor() {
this._counter = n; this._id = Key._staticCounter++;
} }
}
constructor() {
this._id = Key._staticCounter++; export { Lock, Key };
}
}
export { Lock, Key };

View File

@ -1,7 +1,3 @@
/**
* @module og/LonLat
*/
"use strict"; "use strict";
import * as mercator from "./mercator.js"; import * as mercator from "./mercator.js";

View File

@ -1,53 +1,49 @@
/** "use strict";
* @module og/Stack
*/ class Node {
constructor() {
"use strict"; this.next = null;
this.prev = null;
class Node { this.data = null;
constructor() { }
this.next = null; }
this.prev = null;
this.data = null; class Stack {
} /**
} *
* @param {number} [size]
class Stack { */
/** constructor(size = 256) {
* this._current = new Node();
* @param {number} [size] this._head = this._current;
*/
constructor(size = 256) { for (var i = 0; i < size; i++) {
this._current = new Node(); var n = new Node();
this._head = this._current; n.prev = this._current;
this._current.next = n;
for (var i = 0; i < size; i++) { this._current = n;
var n = new Node(); }
n.prev = this._current; this._current = this._head;
this._current.next = n; }
this._current = n;
} current() {
this._current = this._head; return this._current;
} }
current() { push(data) {
return this._current; this._current = this._current.next;
} this._current.data = data;
}
push(data) {
this._current = this._current.next; pop(data) {
this._current.data = data; this._current = this._current.prev;
} return this._current.next.data;
}
pop(data) {
this._current = this._current.prev; popPrev(data) {
return this._current.next.data; this._current = this._current.prev;
} return this._current.data;
}
popPrev(data) { }
this._current = this._current.prev;
return this._current.data; export { Stack };
}
}
export { Stack };

View File

@ -1,116 +1,112 @@
/** "use strict";
* @module og/astro/earth
*/ import * as math from "../math.js";
import { Quat } from "../math/Quat.js";
"use strict"; import { Vec3 } from "../math/Vec3.js";
import * as astro from "./astro.js";
import * as math from "../math.js"; import * as jd from "./jd.js";
import { Quat } from "../math/Quat.js";
import { Vec3 } from "../math/Vec3.js"; /**
import * as astro from "./astro.js"; * Returns Sun position in the geocentric coordinate system by the time.
import * as jd from "./jd.js"; * @param {Number} jDate - Julian date time.
* @returns {Vec3} - Sun geocentric coordinates.
/** */
* Returns Sun position in the geocentric coordinate system by the time. export function getSunPosition(jDate) {
* @param {Number} jDate - Julian date time. // http://stjarnhimlen.se/comp/tutorial.html
* @returns {Vec3} - Sun geocentric coordinates. // a Mean distance, or semi-major axis
*/ // e Eccentricity
export function getSunPosition(jDate) { // T Time at perihelion
// http://stjarnhimlen.se/comp/tutorial.html
// a Mean distance, or semi-major axis // q Perihelion distance = a * (1 - e)
// e Eccentricity // Q Aphelion distance = a * (1 + e)
// T Time at perihelion
// i Inclination, i.e. the "tilt" of the orbit relative to the
// q Perihelion distance = a * (1 - e) // ecliptic. The inclination varies from 0 to 180 degrees. If
// Q Aphelion distance = a * (1 + e) // the inclination is larger than 90 degrees, the planet is in
// a retrogade orbit, i.e. it moves "backwards". The most
// i Inclination, i.e. the "tilt" of the orbit relative to the // well-known celestial body with retrogade motion is Comet Halley.
// ecliptic. The inclination varies from 0 to 180 degrees. If
// the inclination is larger than 90 degrees, the planet is in // N (usually written as "Capital Omega") Longitude of Ascending
// a retrogade orbit, i.e. it moves "backwards". The most // Node. This is the angle, along the ecliptic, from the Vernal
// well-known celestial body with retrogade motion is Comet Halley. // Point to the Ascending Node, which is the intersection between
// the orbit and the ecliptic, where the planet moves from south
// N (usually written as "Capital Omega") Longitude of Ascending // of to north of the ecliptic, i.e. from negative to positive
// Node. This is the angle, along the ecliptic, from the Vernal // latitudes.
// Point to the Ascending Node, which is the intersection between
// the orbit and the ecliptic, where the planet moves from south // w (usually written as "small Omega") The angle from the Ascending
// of to north of the ecliptic, i.e. from negative to positive // node to the Perihelion, along the orbit.
// latitudes.
// P Orbital period = 365.256898326 * a**1.5/sqrt(1+m) days,
// w (usually written as "small Omega") The angle from the Ascending // where m = the mass of the planet in solar masses (0 for
// node to the Perihelion, along the orbit. // comets and asteroids). sqrt() is the square root function.
// P Orbital period = 365.256898326 * a**1.5/sqrt(1+m) days, // n Daily motion = 360_deg / P degrees/day
// where m = the mass of the planet in solar masses (0 for
// comets and asteroids). sqrt() is the square root function. // t Some epoch as a day count, e.g. Julian Day Number. The Time
// at Perihelion, T, should then be expressed as the same day count.
// n Daily motion = 360_deg / P degrees/day
// t - T Time since Perihelion, usually in days
// t Some epoch as a day count, e.g. Julian Day Number. The Time
// at Perihelion, T, should then be expressed as the same day count. // M Mean Anomaly = n * (t - T) = (t - T) * 360_deg / P
// Mean Anomaly is 0 at perihelion and 180 degrees at aphelion
// t - T Time since Perihelion, usually in days
// L Mean Longitude = M + w + N
// M Mean Anomaly = n * (t - T) = (t - T) * 360_deg / P
// Mean Anomaly is 0 at perihelion and 180 degrees at aphelion // E Eccentric anomaly, defined by Kepler's equation: M = E - e * sin(E)
// An auxiliary angle to compute the position in an elliptic orbit
// L Mean Longitude = M + w + N
// v True anomaly: the angle from perihelion to the planet, as seen
// E Eccentric anomaly, defined by Kepler's equation: M = E - e * sin(E) // from the Sun
// An auxiliary angle to compute the position in an elliptic orbit
// r Heliocentric distance: the planet's distance from the Sun.
// v True anomaly: the angle from perihelion to the planet, as seen
// from the Sun // x,y,z Rectangular coordinates. Used e.g. when a heliocentric
// position (seen from the Sun) should be converted to a
// r Heliocentric distance: the planet's distance from the Sun. // corresponding geocentric position (seen from the Earth).
// x,y,z Rectangular coordinates. Used e.g. when a heliocentric var d = jDate - jd.J2000;
// position (seen from the Sun) should be converted to a
// corresponding geocentric position (seen from the Earth). var w = 282.9404 + 4.70935e-5 * d; // longitude of perihelion
// var a = 1.000000; // mean distance, a.u.
var d = jDate - jd.J2000; var e = 0.016709 - 1.151e-9 * d; // eccentricity
var M = math.rev(356.047 + 0.9856002585 * d); // mean anomaly
var w = 282.9404 + 4.70935e-5 * d; // longitude of perihelion
// var a = 1.000000; // mean distance, a.u. var oblecl = astro.J2000_OBLIQUITY - 3.563e-7 * d; // obliquity of the ecliptic
var e = 0.016709 - 1.151e-9 * d; // eccentricity
var M = math.rev(356.047 + 0.9856002585 * d); // mean anomaly // var L = math.rev(w + M); // Sun's mean longitude
var oblecl = astro.J2000_OBLIQUITY - 3.563e-7 * d; // obliquity of the ecliptic var E =
M + math.DEGREES * e * Math.sin(M * math.RADIANS) * (1 + e * Math.cos(M * math.RADIANS)); // eccentric anomaly
// var L = math.rev(w + M); // Sun's mean longitude
// Sun rectangular coordiantes, where the X axis points towards the perihelion
var E = var x = Math.cos(E * math.RADIANS) - e;
M + math.DEGREES * e * Math.sin(M * math.RADIANS) * (1 + e * Math.cos(M * math.RADIANS)); // eccentric anomaly var y = Math.sin(E * math.RADIANS) * Math.sqrt(1 - e * e);
// Sun rectangular coordiantes, where the X axis points towards the perihelion var r = Math.sqrt(x * x + y * y); // distance
var x = Math.cos(E * math.RADIANS) - e; var v = Math.atan2(y, x) * math.DEGREES; // true anomaly
var y = Math.sin(E * math.RADIANS) * Math.sqrt(1 - e * e);
var lon = math.rev(v + w); // longitude of the Sun
var r = Math.sqrt(x * x + y * y); // distance
var v = Math.atan2(y, x) * math.DEGREES; // true anomaly // the Sun's ecliptic rectangular coordinates
x = r * Math.cos(lon * math.RADIANS);
var lon = math.rev(v + w); // longitude of the Sun y = r * Math.sin(lon * math.RADIANS);
// the Sun's ecliptic rectangular coordinates // We use oblecl, and rotate these coordinates
x = r * Math.cos(lon * math.RADIANS); var xequat = x;
y = r * Math.sin(lon * math.RADIANS); var yequat = y * Math.cos(oblecl * math.RADIANS);
var zequat = y * Math.sin(oblecl * math.RADIANS);
// We use oblecl, and rotate these coordinates
var xequat = x; var theta = math.TWO_PI * ((d * 24.0) / 23.9344694 - 259.853 / 360.0); // Siderial spin time
var yequat = y * Math.cos(oblecl * math.RADIANS);
var zequat = y * Math.sin(oblecl * math.RADIANS); return Quat.yRotation(-theta).mulVec3(
new Vec3(
var theta = math.TWO_PI * ((d * 24.0) / 23.9344694 - 259.853 / 360.0); // Siderial spin time -yequat * astro.AU_TO_METERS,
zequat * astro.AU_TO_METERS,
return Quat.yRotation(-theta).mulVec3( -xequat * astro.AU_TO_METERS
new Vec3( )
-yequat * astro.AU_TO_METERS, );
zequat * astro.AU_TO_METERS,
-xequat * astro.AU_TO_METERS // 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;
}
// 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;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,123 +1,119 @@
/** "use strict";
* @module og/astro/orbit
*/ import * as math from "../math.js";
import { Mat3 } from "../math/Mat3.js";
"use strict";
export function getEccentricAnomaly(M, ecc) {
import * as math from "../math.js"; if (ecc == 0.0) {
import { Mat3 } from "../math/Mat3.js"; // Circular orbit
return M;
export function getEccentricAnomaly(M, ecc) { } else if (ecc < 0.2) {
if (ecc == 0.0) { // Low eccentricity, so use the standard iteration technique
// Circular orbit return math.solve_iteration_fixed(solveKeplerFunc1(ecc, M), M, 5);
return M; } else if (ecc < 0.9) {
} else if (ecc < 0.2) { // Higher eccentricity elliptical orbit; use a more complex but
// Low eccentricity, so use the standard iteration technique // much faster converging iteration.
return math.solve_iteration_fixed(solveKeplerFunc1(ecc, M), M, 5); return math.solve_iteration_fixed(solveKeplerFunc2(ecc, M), M, 6);
} else if (ecc < 0.9) { } else if (ecc < 1.0) {
// Higher eccentricity elliptical orbit; use a more complex but // Extremely stable Laguerre-Conway method for solving Kepler's
// much faster converging iteration. // equation. Only use this for high-eccentricity orbits, as it
return math.solve_iteration_fixed(solveKeplerFunc2(ecc, M), M, 6); // requires more calcuation.
} else if (ecc < 1.0) { let E = M + 0.85 * ecc * Math.sign(Math.sin(M));
// Extremely stable Laguerre-Conway method for solving Kepler's return math.solve_iteration_fixed(solveKeplerLaguerreConway(ecc, M), E, 8);
// equation. Only use this for high-eccentricity orbits, as it } else if (ecc == 1.0) {
// requires more calcuation. // TODO: Parabolic orbit
let E = M + 0.85 * ecc * Math.sign(Math.sin(M)); return M;
return math.solve_iteration_fixed(solveKeplerLaguerreConway(ecc, M), E, 8); } else {
} else if (ecc == 1.0) { // Laguerre-Conway method for hyperbolic (ecc > 1) orbits.
// TODO: Parabolic orbit let E = Math.log((2 * M) / ecc + 1.85);
return M; return math.solve_iteration_fixed(solveKeplerLaguerreConwayHyp(ecc, M), E, 30);
} else { }
// Laguerre-Conway method for hyperbolic (ecc > 1) orbits. }
let E = Math.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);
// 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
} // is from Jean Meeus's _Astronomical Algorithms_ (2nd ed), p. 199
function solveKeplerFunc2(ecc, M) {
// Faster converging iteration for Kepler's Equation; more efficient return function (x) {
// than above for orbits with eccentricities greater than 0.3. This return x + (M + ecc * Math.sin(x) - x) / (1 - ecc * Math.cos(x));
// is from Jean Meeus's _Astronomical Algorithms_ (2nd ed), p. 199 };
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) {
} var s = ecc * Math.sin(x);
var c = ecc * Math.cos(x);
function solveKeplerLaguerreConway(ecc, M) { var f = x - s - M;
return function (x) { var f1 = 1 - c;
var s = ecc * Math.sin(x); var f2 = s;
var c = ecc * Math.cos(x); x += (-5 * f) / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
var f = x - s - M; return x;
var f1 = 1 - c; };
var f2 = s; }
x += (-5 * f) / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
return x; function solveKeplerLaguerreConwayHyp(ecc, M) {
}; return function (x) {
} var s = ecc * Math.sinh(x);
var c = ecc * Math.cosh(x);
function solveKeplerLaguerreConwayHyp(ecc, M) { var f = s - x - M;
return function (x) { var f1 = c - 1;
var s = ecc * Math.sinh(x); var f2 = s;
var c = ecc * Math.cosh(x); x += (-5 * f) / (f1 + Math.sign(f1) * Math.sqrt(Math.abs(16 * f1 * f1 - 20 * f * f2)));
var f = s - x - M; return x;
var f1 = c - 1; };
var f2 = s; }
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;
} var iterations = 20;
var e = meanAnomaly - 2.0 * Math.PI * ((meanAnomaly / (2.0 * Math.PI)) | 0);
export function getEllipticalEccentricAnomaly(meanAnomaly, eccentricity) { var err = 1;
var tol = 0.00000001745; while (Math.abs(err) > tol && iterations > 0) {
var iterations = 20; err = e - eccentricity * Math.sin(e) - meanAnomaly;
var e = meanAnomaly - 2.0 * Math.PI * ((meanAnomaly / (2.0 * Math.PI)) | 0); var delta = err / (1 - eccentricity * Math.cos(e));
var err = 1; e -= delta;
while (Math.abs(err) > tol && iterations > 0) { iterations--;
err = e - eccentricity * Math.sin(e) - meanAnomaly; }
var delta = err / (1 - eccentricity * Math.cos(e)); return e;
e -= delta; }
iterations--;
} export function getTrueAnomaly(eccentricAnomaly, eccentricity) {
return e; var revs = Math.floor(eccentricAnomaly / math.TWO_PI);
} eccentricAnomaly -= revs * math.TWO_PI;
var trueAnomaly = Math.atan2(
export function getTrueAnomaly(eccentricAnomaly, eccentricity) { Math.sin(eccentricAnomaly) * Math.sqrt(1 - eccentricity * eccentricity),
var revs = Math.floor(eccentricAnomaly / math.TWO_PI); Math.cos(eccentricAnomaly) - eccentricity
eccentricAnomaly -= revs * math.TWO_PI; );
var trueAnomaly = Math.atan2( trueAnomaly = math.zeroTwoPI(trueAnomaly);
Math.sin(eccentricAnomaly) * Math.sqrt(1 - eccentricity * eccentricity), if (eccentricAnomaly < 0) {
Math.cos(eccentricAnomaly) - eccentricity trueAnomaly -= math.TWO_PI;
); }
trueAnomaly = math.zeroTwoPI(trueAnomaly); return trueAnomaly + revs * math.TWO_PI;
if (eccentricAnomaly < 0) { }
trueAnomaly -= math.TWO_PI;
} export function getPerifocalToCartesianMatrix(argumentOfPeriapsis, inclination, rightAscension) {
return trueAnomaly + revs * math.TWO_PI; var res = new Mat3();
} var cosap = Math.cos(argumentOfPeriapsis),
sinap = Math.sin(argumentOfPeriapsis),
export function getPerifocalToCartesianMatrix(argumentOfPeriapsis, inclination, rightAscension) { cosi = Math.cos(inclination),
var res = new Mat3(); sini = Math.sin(inclination),
var cosap = Math.cos(argumentOfPeriapsis), cosraan = Math.cos(rightAscension),
sinap = Math.sin(argumentOfPeriapsis), sinraan = Math.sin(rightAscension);
cosi = Math.cos(inclination), res._m[0] = cosraan * cosap - sinraan * sinap * cosi;
sini = Math.sin(inclination), res._m[1] = sinraan * cosap + cosraan * sinap * cosi;
cosraan = Math.cos(rightAscension), res._m[2] = sinap * sini;
sinraan = Math.sin(rightAscension); res._m[3] = -cosraan * sinap - sinraan * cosap * cosi;
res._m[0] = cosraan * cosap - sinraan * sinap * cosi; res._m[4] = -sinraan * sinap + cosraan * cosap * cosi;
res._m[1] = sinraan * cosap + cosraan * sinap * cosi; res._m[5] = cosap * sini;
res._m[2] = sinap * sini; res._m[6] = sinraan * sini;
res._m[3] = -cosraan * sinap - sinraan * cosap * cosi; res._m[7] = -cosraan * sini;
res._m[4] = -sinraan * sinap + cosraan * cosap * cosi; res._m[8] = cosi;
res._m[5] = cosap * sini; return res;
res._m[6] = sinraan * sini; }
res._m[7] = -cosraan * sini;
res._m[8] = cosi;
return res;
}

View File

@ -1,40 +1,36 @@
/** "use strict";
* @module og/astro/rotation
*/ import { PI_TWO } from "../math.js";
import { Mat3 } from "../math/Mat3.js";
"use strict"; import { Vec3 } from "../math/Vec3.js";
import { PI_TWO } from "../math.js"; export function getRotationMatrix(rightAscension, declination, res) {
import { Mat3 } from "../math/Mat3.js"; let xAxis = new Vec3(),
import { Vec3 } from "../math/Vec3.js"; zAxis = new Vec3();
export function getRotationMatrix(rightAscension, declination, res) { res = res || new Mat3();
let xAxis = new Vec3(),
zAxis = new Vec3(); xAxis.x = Math.cos(rightAscension + PI_TWO);
xAxis.y = Math.sin(rightAscension + PI_TWO);
res = res || new Mat3(); xAxis.z = 0.0;
xAxis.x = Math.cos(rightAscension + PI_TWO); let cosDec = Math.cos(declination);
xAxis.y = Math.sin(rightAscension + PI_TWO);
xAxis.z = 0.0; zAxis.x = cosDec * Math.cos(rightAscension);
zAxis.y = cosDec * Math.sin(rightAscension);
let cosDec = Math.cos(declination); zAxis.z = Math.sin(declination);
zAxis.x = cosDec * Math.cos(rightAscension); let yAxis = zAxis.cross(xAxis);
zAxis.y = cosDec * Math.sin(rightAscension);
zAxis.z = Math.sin(declination); res._m[0] = xAxis.x;
res._m[1] = yAxis.x;
let yAxis = zAxis.cross(xAxis); res._m[2] = zAxis.x;
res._m[3] = xAxis.y;
res._m[0] = xAxis.x; res._m[4] = yAxis.y;
res._m[1] = yAxis.x; res._m[5] = zAxis.y;
res._m[2] = zAxis.x; res._m[6] = xAxis.z;
res._m[3] = xAxis.y; res._m[7] = yAxis.z;
res._m[4] = yAxis.y; res._m[8] = zAxis.z;
res._m[5] = zAxis.y;
res._m[6] = xAxis.z; return res;
res._m[7] = yAxis.z; }
res._m[8] = zAxis.z;
return res;
}

View File

@ -1,81 +1,77 @@
/** "use strict";
* @module og/bv/Box
*/ import { Vec3 } from "../math/Vec3.js";
"use strict"; /**
* Bounding box class.
import { Vec3 } from "../math/Vec3.js"; * @class
*/
/** class Box {
* Bounding box class. /**
* @class *
*/ * @param {*} boundsArr
class Box { */
/** constructor(boundsArr = [0, 0, 0, 0, 0, 0]) {
* /**
* @param {*} boundsArr * Vertices array.
*/ * @public
constructor(boundsArr = [0, 0, 0, 0, 0, 0]) { * @type{Array.<Vec3>}
/** */
* Vertices array. this.vertices = [
* @public new Vec3(),
* @type{Array.<Vec3>} new Vec3(),
*/ new Vec3(),
this.vertices = [ new Vec3(),
new Vec3(), new Vec3(),
new Vec3(), new Vec3(),
new Vec3(), new Vec3(),
new Vec3(), new Vec3()
new Vec3(), ];
new Vec3(),
new Vec3(), if (boundsArr) {
new Vec3() this.setFromBoundsArr(boundsArr);
]; }
}
if (boundsArr) {
this.setFromBoundsArr(boundsArr); copy(bbox) {
} for (let i = 0, len = this.vertices.length; i < len; i++) {
} this.vertices[i].copy(bbox.vertices[i]);
}
copy(bbox) { }
for (let i = 0, len = this.vertices.length; i < len; i++) {
this.vertices[i].copy(bbox.vertices[i]); /**
} * Sets bounding box coordinates by the bounds array.
} * @param {Array.<number>} bounds - Bounds is an array where [minX, minY, minZ, maxX, maxY, maxZ]
*/
/** setFromBoundsArr(bounds) {
* Sets bounding box coordinates by the bounds array. var xmin = bounds[0],
* @param {Array.<number>} bounds - Bounds is an array where [minX, minY, minZ, maxX, maxY, maxZ] xmax = bounds[3],
*/ ymin = bounds[1],
setFromBoundsArr(bounds) { ymax = bounds[4],
var xmin = bounds[0], zmin = bounds[2],
xmax = bounds[3], zmax = bounds[5];
ymin = bounds[1],
ymax = bounds[4], var v = this.vertices;
zmin = bounds[2],
zmax = bounds[5]; v[0].set(xmin, ymin, zmin);
v[1].set(xmax, ymin, zmin);
var v = this.vertices; v[2].set(xmax, ymin, zmax);
v[3].set(xmin, ymin, zmax);
v[0].set(xmin, ymin, zmin); v[4].set(xmin, ymax, zmin);
v[1].set(xmax, ymin, zmin); v[5].set(xmax, ymax, zmin);
v[2].set(xmax, ymin, zmax); v[6].set(xmax, ymax, zmax);
v[3].set(xmin, ymin, zmax); v[7].set(xmin, ymax, zmax);
v[4].set(xmin, ymax, zmin); }
v[5].set(xmax, ymax, zmin);
v[6].set(xmax, ymax, zmax); /**
v[7].set(xmin, ymax, zmax); * Sets bounding box coordiantes by ellipsoid geodetic extend.
} * @param {Ellipsoid} ellipsoid - Ellipsoid.
* @param {Extent} extent - Geodetic extent.
/** */
* Sets bounding box coordiantes by ellipsoid geodetic extend. setFromExtent(ellipsoid, extent) {
* @param {Ellipsoid} ellipsoid - Ellipsoid. this.setFromBoundsArr(extent.getCartesianBounds(ellipsoid));
* @param {Extent} extent - Geodetic extent. }
*/ }
setFromExtent(ellipsoid, extent) {
this.setFromBoundsArr(extent.getCartesianBounds(ellipsoid)); export { Box };
}
}
export { Box };

View File

@ -1,61 +1,57 @@
/** "use strict";
* @module og/bv/Sphere
*/ import { Vec3 } from "../math/Vec3.js";
"use strict"; /**
* Bounding sphere class.
import { Vec3 } from "../math/Vec3.js"; * @class
* @param {Number} [radius] - Bounding sphere radius.
/** * @param {Vec3} [center] - Bounding sphere coordiantes.
* Bounding sphere class. */
* @class class Sphere {
* @param {Number} [radius] - Bounding sphere radius. /**
* @param {Vec3} [center] - Bounding sphere coordiantes. *
*/ * @param {number} radius
class Sphere { * @param {Vec3} center
/** */
* constructor(radius = 0, center = Vec3.ZERO) {
* @param {number} radius /**
* @param {Vec3} center * Sphere radius.
*/ * @public
constructor(radius = 0, center = Vec3.ZERO) { * @type {Number}
/** */
* Sphere radius. this.radius = radius;
* @public
* @type {Number} /**
*/ * Sphere coordiantes.
this.radius = radius; * @public
* @type {Vec3}
/** */
* Sphere coordiantes. this.center = center ? center.clone() : new Vec3();
* @public }
* @type {Vec3}
*/ /**
this.center = center ? center.clone() : new Vec3(); * Sets bounding sphere coordinates by the bounds array.
} * @param {Array.<number>} bounds - Bounds is an array where [minX, minY, minZ, maxX, maxY, maxZ]
*/
/** setFromBounds(bounds) {
* Sets bounding sphere coordinates by the bounds array. let m = new Vec3(bounds[0], bounds[1], bounds[2]);
* @param {Array.<number>} bounds - Bounds is an array where [minX, minY, minZ, maxX, maxY, maxZ] this.center.set(
*/ m.x + (bounds[3] - m.x) * 0.5,
setFromBounds(bounds) { m.y + (bounds[3] - m.y) * 0.5,
let m = new Vec3(bounds[0], bounds[1], bounds[2]); m.z + (bounds[5] - m.z) * 0.5
this.center.set( );
m.x + (bounds[3] - m.x) * 0.5, this.radius = this.center.distance(m);
m.y + (bounds[3] - m.y) * 0.5, }
m.z + (bounds[5] - m.z) * 0.5
); /**
this.radius = this.center.distance(m); * Sets bounding sphere coordiantes by ellipsoid geodetic extend.
} * @param {Ellipsoid} ellipsoid - Ellipsoid.
* @param {Extent} extent - Geodetic extent.
/** */
* Sets bounding sphere coordiantes by ellipsoid geodetic extend. setFromExtent(ellipsoid, extent) {
* @param {Ellipsoid} ellipsoid - Ellipsoid. this.setFromBounds(extent.getCartesianBounds(ellipsoid));
* @param {Extent} extent - Geodetic extent. }
*/ }
setFromExtent(ellipsoid, extent) {
this.setFromBounds(extent.getCartesianBounds(ellipsoid)); export { Sphere };
}
}
export { Sphere };

View File

@ -1,7 +1,3 @@
/**
* @module og/camera/PlanetCamera
*/
"use strict"; "use strict";
import { Key } from "../Lock.js"; import { Key } from "../Lock.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/Atmosphere
*/
"use strict"; "use strict";
import * as atmos from "../shaders/atmos.js"; import * as atmos from "../shaders/atmos.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/Control
*/
"use strict"; "use strict";
/** /**

View File

@ -1,7 +1,3 @@
/**
* @module og/control/DebugInfo
*/
"use strict"; "use strict";
import { Control } from "./Control.js"; import { Control } from "./Control.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/GeoImageDragControl
*/
'use strict'; 'use strict';
import { BaseGeoImage } from '../layer/BaseGeoImage.js'; import { BaseGeoImage } from '../layer/BaseGeoImage.js';

View File

@ -1,7 +1,3 @@
/**
* @module og/control/KeyboardNavigation
*/
"use strict"; "use strict";
import { input } from "../input/input.js"; import { input } from "../input/input.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/LayerAnimation
*/
"use strict"; "use strict";
import { Events } from '../Events.js'; import { Events } from '../Events.js';

View File

@ -1,7 +1,3 @@
/**
* @module og/control/LayerSwitcher
*/
"use strict"; "use strict";
import { Dialog } from "../ui/Dialog.js"; import { Dialog } from "../ui/Dialog.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/Lighting
*/
"use strict"; "use strict";
import { Dialog } from '../ui/Dialog.js'; import { Dialog } from '../ui/Dialog.js';

View File

@ -1,7 +1,3 @@
/**
* @module og/control/MouseNavigation
*/
"use strict"; "use strict";
import { Sphere } from "../bv/Sphere.js"; import { Sphere } from "../bv/Sphere.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/MouseWheelZoomControl
*/
"use strict"; "use strict";
import { Sphere } from "../bv/Sphere.js"; import { Sphere } from "../bv/Sphere.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/Ruler
*/
"use strict"; "use strict";
import { ToggleButton } from "../ui/ToggleButton.js"; import { ToggleButton } from "../ui/ToggleButton.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/ZoomControl
*/
"use strict"; "use strict";
import { RADIANS } from "../math.js"; import { RADIANS } from "../math.js";

View File

@ -1,44 +1,40 @@
/** "use strict";
* @module og/control/ShowFps
*/ import { print2d } from "../utils/shared.js";
import { Control } from "./Control.js";
"use strict";
/**
import { print2d } from "../utils/shared.js"; * Frame per second(FPS) display control.
import { Control } from "./Control.js"; * @class
* @extends {Control}
/** * @param {Object} [options] - Control options.
* Frame per second(FPS) display control. */
* @class class ShowFps extends Control {
* @extends {Control} constructor(options) {
* @param {Object} [options] - Control options. super(options);
*/ }
class ShowFps extends Control {
constructor(options) { oninit() {
super(options); var d = document.createElement("div");
} d.className = "defaultText ";
d.id = "ogShowFpsControl";
oninit() { document.body.appendChild(d);
var d = document.createElement("div"); this.renderer.events.on("draw", this._draw, this);
d.className = "defaultText "; }
d.id = "ogShowFpsControl";
document.body.appendChild(d); _draw() {
this.renderer.events.on("draw", this._draw, this); print2d(
} "ogShowFpsControl",
(1000.0 / this.renderer.handler.deltaTime).toFixed(1),
_draw() { this.renderer.handler.canvas.clientWidth - 60,
print2d( 0
"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 function showFps(options) { export { ShowFps };
return new ShowFps(options);
}
export { ShowFps };

View File

@ -1,7 +1,3 @@
/**
* @module og/control/SimpleSkyBackground
*/
"use strict"; "use strict";
import { htmlColorToRgb } from "../utils/shared.js"; import { htmlColorToRgb } from "../utils/shared.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/Sun
*/
"use strict"; "use strict";
import { getSunPosition } from "../astro/earth.js"; import { getSunPosition } from "../astro/earth.js";

View File

@ -1,39 +1,35 @@
/** "use strict";
* @module og/control/ToggleWireframe
*/ import { input } from "../input/input.js";
import { Control } from "./Control.js";
"use strict";
/**
import { input } from "../input/input.js"; * Planet GL draw mode(TRIANGLE_STRIP/LINE_STRING) changer.
import { Control } from "./Control.js"; * @class
* @extends {Control}
/** * @param {Object} [options] - Control options.
* Planet GL draw mode(TRIANGLE_STRIP/LINE_STRING) changer. */
* @class class ToggleWireframe extends Control {
* @extends {Control} constructor(options = {}) {
* @param {Object} [options] - Control options. super(options);
*/ this._isActive = options.isActive || false;
class ToggleWireframe extends Control { }
constructor(options = {}) {
super(options); oninit() {
this._isActive = options.isActive || false; this.renderer.events.on("charkeypress", input.KEY_X, this.toogleWireframe, this);
} if (this._isActive) {
this.planet.setDrawMode(this.renderer.handler.gl.LINE_STRIP);
oninit() { }
this.renderer.events.on("charkeypress", input.KEY_X, this.toogleWireframe, this); }
if (this._isActive) {
this.planet.setDrawMode(this.renderer.handler.gl.LINE_STRIP); toogleWireframe(e) {
} if (this.planet.drawMode === this.renderer.handler.gl.LINE_STRIP) {
} this.planet.setDrawMode(this.renderer.handler.gl.TRIANGLE_STRIP);
} else {
toogleWireframe(e) { this.planet.setDrawMode(this.renderer.handler.gl.LINE_STRIP);
if (this.planet.drawMode === this.renderer.handler.gl.LINE_STRIP) { }
this.planet.setDrawMode(this.renderer.handler.gl.TRIANGLE_STRIP); }
} else { }
this.planet.setDrawMode(this.renderer.handler.gl.LINE_STRIP);
} export { ToggleWireframe };
}
}
export { ToggleWireframe };

View File

@ -1,341 +1,337 @@
/** "use strict";
* @module og/control/TouchNavigation
*/ import { Sphere } from "../bv/Sphere.js";
import { Key } from "../Lock.js";
"use strict"; import { LonLat } from "../LonLat.js";
import * as math from "../math.js";
import { Sphere } from "../bv/Sphere.js"; import { Quat } from "../math/Quat.js";
import { Key } from "../Lock.js"; import { Ray } from "../math/Ray.js";
import { LonLat } from "../LonLat.js"; import { Vec3 } from "../math/Vec3.js";
import * as math from "../math.js"; import { Control } from "./Control.js";
import { Quat } from "../math/Quat.js";
import { Ray } from "../math/Ray.js"; class Touch {
import { Vec3 } from "../math/Vec3.js"; constructor() {
import { Control } from "./Control.js"; this.x = 0;
this.y = 0;
class Touch { this.prev_x = 0;
constructor() { this.prev_y = 0;
this.x = 0; this.grabbedPoint = new Vec3();
this.y = 0; this.grabbedSpheroid = new Sphere();
this.prev_x = 0; this.dX = function () {
this.prev_y = 0; return this.x - this.prev_x;
this.grabbedPoint = new Vec3(); };
this.grabbedSpheroid = new Sphere(); this.dY = function () {
this.dX = function () { return this.y - this.prev_y;
return this.x - this.prev_x; };
}; }
this.dY = function () { }
return this.y - this.prev_y;
}; /**
} * Touch pad planet camera dragging control.
} * @class
* @extends {Control}
/** * @param {Object} [options] - Control options.
* Touch pad planet camera dragging control. */
* @class class TouchNavigation extends Control {
* @extends {Control} constructor(options) {
* @param {Object} [options] - Control options. super(options);
*/
class TouchNavigation extends Control { this._name = "touchNavigation";
constructor(options) {
super(options); this.grabbedPoint = new Vec3();
this.inertia = 0.007;
this._name = "touchNavigation"; this.grabbedSpheroid = new Sphere();
this.planet = null;
this.grabbedPoint = new Vec3(); this.qRot = new Quat();
this.inertia = 0.007; this.scaleRot = 0;
this.grabbedSpheroid = new Sphere(); this.rot = 1;
this.planet = null; this._eye0 = new Vec3();
this.qRot = new Quat();
this.scaleRot = 0; this.stepsCount = 5;
this.rot = 1; this.stepsForward = null;
this._eye0 = new Vec3(); this.stepIndex = 0;
this.stepsCount = 5; this.pointOnEarth = null;
this.stepsForward = null; this.earthUp = null;
this.stepIndex = 0;
this.touches = [new Touch(), new Touch()];
this.pointOnEarth = null;
this.earthUp = null; this._keyLock = new Key();
}
this.touches = [new Touch(), new Touch()];
oninit() {
this._keyLock = new Key(); this.renderer.events.on("touchstart", this.onTouchStart, this);
} this.renderer.events.on("touchend", this.onTouchEnd, this);
this.renderer.events.on("doubletouch", this.onDoubleTouch, this);
oninit() { this.renderer.events.on("touchcancel", this.onTouchCancel, this);
this.renderer.events.on("touchstart", this.onTouchStart, this); this.renderer.events.on("touchmove", this.onTouchMove, this);
this.renderer.events.on("touchend", this.onTouchEnd, this); this.renderer.events.on("draw", this.onDraw, this);
this.renderer.events.on("doubletouch", this.onDoubleTouch, this); }
this.renderer.events.on("touchcancel", this.onTouchCancel, this);
this.renderer.events.on("touchmove", this.onTouchMove, this); onTouchStart(e) {
this.renderer.events.on("draw", this.onDraw, this); this._touching = true;
}
if (e.sys.touches.length === 2) {
onTouchStart(e) { var t0 = this.touches[0],
this._touching = true; t1 = this.touches[1];
if (e.sys.touches.length === 2) { t0.x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
var t0 = this.touches[0], t0.y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
t1 = this.touches[1]; t0.prev_x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
t0.prev_y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
t0.x = e.sys.touches.item(0).clientX - e.sys.offsetLeft; t0.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true);
t0.y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
t0.prev_x = e.sys.touches.item(0).clientX - e.sys.offsetLeft; t1.x = e.sys.touches.item(1).clientX - e.sys.offsetLeft;
t0.prev_y = e.sys.touches.item(0).clientY - e.sys.offsetTop; t1.y = e.sys.touches.item(1).clientY - e.sys.offsetTop;
t0.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true); t1.prev_x = e.sys.touches.item(1).clientX - e.sys.offsetLeft;
t1.prev_y = e.sys.touches.item(1).clientY - e.sys.offsetTop;
t1.x = e.sys.touches.item(1).clientX - e.sys.offsetLeft; t1.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true);
t1.y = e.sys.touches.item(1).clientY - e.sys.offsetTop;
t1.prev_x = e.sys.touches.item(1).clientX - e.sys.offsetLeft; // this.planet._viewChanged = true;
t1.prev_y = e.sys.touches.item(1).clientY - e.sys.offsetTop; this.pointOnEarth = this.planet.getCartesianFromPixelTerrain(
t1.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true); this.renderer.handler.getCenter(),
true
// this.planet._viewChanged = true; );
this.pointOnEarth = this.planet.getCartesianFromPixelTerrain(
this.renderer.handler.getCenter(), if (this.pointOnEarth) {
true this.earthUp = this.pointOnEarth.normal();
); }
if (this.pointOnEarth) { if (t0.grabbedPoint && t1.grabbedPoint) {
this.earthUp = this.pointOnEarth.normal(); t0.grabbedSpheroid.radius = t0.grabbedPoint.length();
} t1.grabbedSpheroid.radius = t1.grabbedPoint.length();
this.stopRotation();
if (t0.grabbedPoint && t1.grabbedPoint) { }
t0.grabbedSpheroid.radius = t0.grabbedPoint.length(); } else if (e.sys.touches.length === 1) {
t1.grabbedSpheroid.radius = t1.grabbedPoint.length(); this._startTouchOne(e);
this.stopRotation(); }
} }
} else if (e.sys.touches.length === 1) {
this._startTouchOne(e); _startTouchOne(e) {
} var t = this.touches[0];
}
t.x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
_startTouchOne(e) { t.y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
var t = this.touches[0]; t.prev_x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
t.prev_y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
t.x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
t.y = e.sys.touches.item(0).clientY - e.sys.offsetTop; t.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true);
t.prev_x = e.sys.touches.item(0).clientX - e.sys.offsetLeft; this._eye0.copy(this.renderer.activeCamera.eye);
t.prev_y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
if (t.grabbedPoint) {
t.grabbedPoint = this.planet.getCartesianFromPixelTerrain(e, true); t.grabbedSpheroid.radius = t.grabbedPoint.length();
this._eye0.copy(this.renderer.activeCamera.eye); this.stopRotation();
}
if (t.grabbedPoint) { }
t.grabbedSpheroid.radius = t.grabbedPoint.length();
this.stopRotation(); stopRotation() {
} this.qRot.clear();
} this.planet.layerLock.free(this._keyLock);
this.planet.terrainLock.free(this._keyLock);
stopRotation() { this.planet._normalMapCreator.free(this._keyLock);
this.qRot.clear(); }
this.planet.layerLock.free(this._keyLock);
this.planet.terrainLock.free(this._keyLock); onDoubleTouch(e) {
this.planet._normalMapCreator.free(this._keyLock); if (this.stepIndex) {
} return;
}
onDoubleTouch(e) {
if (this.stepIndex) { this.planet.stopFlying();
return; this.stopRotation();
}
var p = this.planet.getCartesianFromPixelTerrain(e);
this.planet.stopFlying(); if (p) {
this.stopRotation(); var g = this.planet.ellipsoid.cartesianToLonLat(p);
this.planet.flyLonLat(
var p = this.planet.getCartesianFromPixelTerrain(e); new LonLat(g.lon, g.lat, this.renderer.activeCamera.eye.distance(p) * 0.57)
if (p) { );
var g = this.planet.ellipsoid.cartesianToLonLat(p); }
this.planet.flyLonLat( }
new LonLat(g.lon, g.lat, this.renderer.activeCamera.eye.distance(p) * 0.57)
); onTouchEnd(e) {
} if (e.sys.touches.length === 0) {
} this._touching = false;
}
onTouchEnd(e) {
if (e.sys.touches.length === 0) { if (e.sys.touches.length === 1) {
this._touching = false; this._startTouchOne(e);
} }
if (e.sys.touches.length === 1) { if (
this._startTouchOne(e); Math.abs(this.touches[0].x - this.touches[0].prev_x) < 3 &&
} Math.abs(this.touches[0].y - this.touches[0].prev_y) < 3
) {
if ( this.scaleRot = 0;
Math.abs(this.touches[0].x - this.touches[0].prev_x) < 3 && }
Math.abs(this.touches[0].y - this.touches[0].prev_y) < 3 }
) {
this.scaleRot = 0; onTouchCancel(e) {}
}
} onTouchMove(e) {
var cam = this.renderer.activeCamera;
onTouchCancel(e) {}
if (e.sys.touches.length === 2) {
onTouchMove(e) { this.renderer.controlsBag.scaleRot = 1;
var cam = this.renderer.activeCamera;
var t0 = this.touches[0],
if (e.sys.touches.length === 2) { t1 = this.touches[1];
this.renderer.controlsBag.scaleRot = 1;
if (!t0.grabbedPoint || !t1.grabbedPoint) {
var t0 = this.touches[0], return;
t1 = this.touches[1]; }
if (!t0.grabbedPoint || !t1.grabbedPoint) { this.planet.stopFlying();
return;
} t0.prev_x = t0.x;
t0.prev_y = t0.y;
this.planet.stopFlying(); t0.x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
t0.y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
t0.prev_x = t0.x;
t0.prev_y = t0.y; t1.prev_x = t1.x;
t0.x = e.sys.touches.item(0).clientX - e.sys.offsetLeft; t1.prev_y = t1.y;
t0.y = e.sys.touches.item(0).clientY - e.sys.offsetTop; t1.x = e.sys.touches.item(1).clientX - e.sys.offsetLeft;
t1.y = e.sys.touches.item(1).clientY - e.sys.offsetTop;
t1.prev_x = t1.x;
t1.prev_y = t1.y; // distance = Math.sqrt((t0.prev_x-t1.prev_x)**2+(t0.prev_y-t1.prev_y)**2) - Math.sqrt((t0.x-t1.x)**2 + (t0.y-t1.y)**2))
t1.x = e.sys.touches.item(1).clientX - e.sys.offsetLeft; // distance < 0 --> zoomIn; distance > 0 --> zoomOut
t1.y = e.sys.touches.item(1).clientY - e.sys.offsetTop; var t0t1Distance = Math.abs(t0.prev_x - t1.prev_x) + Math.abs(t0.prev_y - t1.prev_y) - (Math.abs(t0.x - t1.x) + Math.abs(t0.y - t1.y))
var _move = 0
// distance = Math.sqrt((t0.prev_x-t1.prev_x)**2+(t0.prev_y-t1.prev_y)**2) - Math.sqrt((t0.x-t1.x)**2 + (t0.y-t1.y)**2)) if (t0t1Distance < 0) {
// distance < 0 --> zoomIn; distance > 0 --> zoomOut _move = 1
var t0t1Distance = Math.abs(t0.prev_x - t1.prev_x) + Math.abs(t0.prev_y - t1.prev_y) - (Math.abs(t0.x - t1.x) + Math.abs(t0.y - t1.y)) }
var _move = 0 if (t0t1Distance > 0) {
if (t0t1Distance < 0) { _move = -1
_move = 1 }
} if (_move !== 0) {
if (t0t1Distance > 0) { let pos = this.planet.getCartesianFromPixelTerrain(e);
_move = -1 if (pos) {
} let d = cam.eye.distance(pos) * 0.075;
if (_move !== 0) { cam.eye.addA(cam.getForward().scale(_move * d));
let pos = this.planet.getCartesianFromPixelTerrain(e); cam.checkTerrainCollision();
if (pos) { cam.update();
let d = cam.eye.distance(pos) * 0.075; }
cam.eye.addA(cam.getForward().scale(_move * d)); }
cam.checkTerrainCollision();
cam.update(); if (
} (t0.dY() > 0 && t1.dY() > 0) ||
} (t0.dY() < 0 && t1.dY() < 0) ||
(t0.dX() > 0 && t1.dX() > 0) ||
if ( (t0.dX() < 0 && t1.dX() < 0)
(t0.dY() > 0 && t1.dY() > 0) || ) {
(t0.dY() < 0 && t1.dY() < 0) || var l =
(t0.dX() > 0 && t1.dX() > 0) || (0.5 / cam.eye.distance(this.pointOnEarth)) * cam._lonLat.height * math.RADIANS;
(t0.dX() < 0 && t1.dX() < 0) if (l > 0.007) l = 0.007;
) { cam.rotateHorizontal(l * t0.dX(), false, this.pointOnEarth, this.earthUp);
var l = cam.rotateVertical(l * t0.dY(), this.pointOnEarth, true);
(0.5 / cam.eye.distance(this.pointOnEarth)) * cam._lonLat.height * math.RADIANS; cam.checkTerrainCollision();
if (l > 0.007) l = 0.007; cam.update();
cam.rotateHorizontal(l * t0.dX(), false, this.pointOnEarth, this.earthUp); }
cam.rotateVertical(l * t0.dY(), this.pointOnEarth, true);
cam.checkTerrainCollision(); this.scaleRot = 0;
cam.update(); } else if (e.sys.touches.length === 1) {
} var t = this.touches[0];
this.scaleRot = 0; t.prev_x = t.x;
} else if (e.sys.touches.length === 1) { t.prev_y = t.y;
var t = this.touches[0]; t.x = e.sys.touches.item(0).clientX - e.sys.offsetLeft;
t.y = e.sys.touches.item(0).clientY - e.sys.offsetTop;
t.prev_x = t.x;
t.prev_y = t.y; if (!t.grabbedPoint) {
t.x = e.sys.touches.item(0).clientX - e.sys.offsetLeft; return;
t.y = e.sys.touches.item(0).clientY - e.sys.offsetTop; }
if (!t.grabbedPoint) { this.planet.stopFlying();
return;
} var direction = e.direction
var targetPoint = new Ray(cam.eye, direction).hitSphere(t.grabbedSpheroid);
this.planet.stopFlying();
if (targetPoint) {
var direction = e.direction if (cam.slope > 0.2) {
var targetPoint = new Ray(cam.eye, direction).hitSphere(t.grabbedSpheroid); this.qRot = Quat.getRotationBetweenVectors(
targetPoint.normal(),
if (targetPoint) { t.grabbedPoint.normal()
if (cam.slope > 0.2) { );
this.qRot = Quat.getRotationBetweenVectors( var rot = this.qRot;
targetPoint.normal(), cam.eye = rot.mulVec3(cam.eye);
t.grabbedPoint.normal() cam._r = rot.mulVec3(cam._r);
); cam._u = rot.mulVec3(cam._u);
var rot = this.qRot; cam._b = rot.mulVec3(cam._b);
cam.eye = rot.mulVec3(cam.eye); cam.checkTerrainCollision();
cam._r = rot.mulVec3(cam._r); cam.update();
cam._u = rot.mulVec3(cam._u); this.scaleRot = 1;
cam._b = rot.mulVec3(cam._b); } else {
cam.checkTerrainCollision(); var p0 = t.grabbedPoint,
cam.update(); p1 = Vec3.add(p0, cam._u),
this.scaleRot = 1; p2 = Vec3.add(p0, p0.normal());
} else { var dir = cam.unproject(t.x, t.y);
var p0 = t.grabbedPoint, var px = new Vec3();
p1 = Vec3.add(p0, cam._u), if (new Ray(cam.eye, dir).hitPlane(p0, p1, p2, px) === Ray.INSIDE) {
p2 = Vec3.add(p0, p0.normal()); cam.eye = this._eye0.addA(px.subA(p0).negate());
var dir = cam.unproject(t.x, t.y); cam.checkTerrainCollision();
var px = new Vec3(); cam.update();
if (new Ray(cam.eye, dir).hitPlane(p0, p1, p2, px) === Ray.INSIDE) { this.scaleRot = 0;
cam.eye = this._eye0.addA(px.subA(p0).negate()); }
cam.checkTerrainCollision(); }
cam.update(); }
this.scaleRot = 0; }
} }
}
} onDraw(e) {
} this.renderer.controlsBag.scaleRot = this.scaleRot;
}
if (this._touching) {
onDraw(e) { return;
this.renderer.controlsBag.scaleRot = this.scaleRot; }
if (this._touching) { var r = this.renderer;
return; var cam = r.activeCamera;
} var prevEye = cam.eye.clone();
var r = this.renderer; if (this.stepIndex) {
var cam = r.activeCamera; r.controlsBag.scaleRot = 1;
var prevEye = cam.eye.clone(); var sf = this.stepsForward[this.stepsCount - this.stepIndex--];
cam.eye = sf.eye;
if (this.stepIndex) { cam._r = sf.v;
r.controlsBag.scaleRot = 1; cam._u = sf.u;
var sf = this.stepsForward[this.stepsCount - this.stepIndex--]; cam._b = sf.n;
cam.eye = sf.eye; cam.checkTerrainCollision();
cam._r = sf.v; cam.update();
cam._u = sf.u; }
cam._b = sf.n;
cam.checkTerrainCollision(); if (r.events.mouseState.leftButtonDown || !this.scaleRot) {
cam.update(); return;
} }
if (r.events.mouseState.leftButtonDown || !this.scaleRot) { this.scaleRot -= this.inertia;
return; if (this.scaleRot <= 0) {
} this.scaleRot = 0;
} else {
this.scaleRot -= this.inertia; r.controlsBag.scaleRot = this.scaleRot;
if (this.scaleRot <= 0) { var rot = this.qRot
this.scaleRot = 0; .slerp(Quat.IDENTITY, 1 - this.scaleRot * this.scaleRot * this.scaleRot)
} else { .normalize();
r.controlsBag.scaleRot = this.scaleRot; if (!(rot.x || rot.y || rot.z)) {
var rot = this.qRot this.scaleRot = 0;
.slerp(Quat.IDENTITY, 1 - this.scaleRot * this.scaleRot * this.scaleRot) }
.normalize(); cam.eye = rot.mulVec3(cam.eye);
if (!(rot.x || rot.y || rot.z)) { cam._r = rot.mulVec3(cam._r);
this.scaleRot = 0; cam._u = rot.mulVec3(cam._u);
} cam._b = rot.mulVec3(cam._b);
cam.eye = rot.mulVec3(cam.eye); cam.checkTerrainCollision();
cam._r = rot.mulVec3(cam._r); cam.update();
cam._u = rot.mulVec3(cam._u); }
cam._b = rot.mulVec3(cam._b);
cam.checkTerrainCollision(); if (cam.eye.distance(prevEye) / cam._terrainAltitude > 0.01) {
cam.update(); this.planet.layerLock.lock(this._keyLock);
} this.planet.terrainLock.lock(this._keyLock);
this.planet._normalMapCreator.lock(this._keyLock);
if (cam.eye.distance(prevEye) / cam._terrainAltitude > 0.01) { } else {
this.planet.layerLock.lock(this._keyLock); this.planet.layerLock.free(this._keyLock);
this.planet.terrainLock.lock(this._keyLock); this.planet.terrainLock.free(this._keyLock);
this.planet._normalMapCreator.lock(this._keyLock); this.planet._normalMapCreator.free(this._keyLock);
} else { }
this.planet.layerLock.free(this._keyLock); }
this.planet.terrainLock.free(this._keyLock); }
this.planet._normalMapCreator.free(this._keyLock);
} export { TouchNavigation };
}
}
export { TouchNavigation };

View File

@ -1,7 +1,3 @@
/**
* @module og/control/ZoomControl
*/
"use strict"; "use strict";
import { Key } from "../Lock.js"; import { Key } from "../Lock.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/Ruler
*/
"use strict"; "use strict";
import { Control } from "../Control.js"; import { Control } from "../Control.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/Ruler
*/
"use strict"; "use strict";
import { Control } from "../Control.js"; import { Control } from "../Control.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/control/Selector
*/
"use strict"; "use strict";
import { ToggleButton } from "../../ui/ToggleButton.js"; import { ToggleButton } from "../../ui/ToggleButton.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/shaders/drawnode
*/
"use strict"; "use strict";
import { Program } from "../../webgl/Program.js"; import { Program } from "../../webgl/Program.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/ellipsoid/Ellipsoid
*/
"use strict"; "use strict";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/ellipsoid/wgs84
*/
"use strict"; "use strict";
import { Ellipsoid } from "./Ellipsoid.js"; import { Ellipsoid } from "./Ellipsoid.js";

View File

@ -1,379 +1,375 @@
/** "use strict";
* @module og/entity/BaseBillboard
*/ import { Vec3 } from "../math/Vec3.js";
import * as utils from "../utils/shared.js";
"use strict"; import { LOCK_FREE, LOCK_UPDATE } from "./LabelWorker.js";
import { Vec3 } from "../math/Vec3.js"; /**
import * as utils from "../utils/shared.js"; * Base prototype for billboard and label classes.
import { LOCK_FREE, LOCK_UPDATE } from "./LabelWorker.js"; * @class
* @param {Object} [options] - Options:
/** * @param {Vec3|Array.<number>} [options.position] - Billboard spatial position.
* Base prototype for billboard and label classes. * @param {number} [options.rotation] - Screen angle rotaion.
* @class * @param {Vec4|string|Array.<number>} [options.color] - Billboard color.
* @param {Object} [options] - Options: * @param {Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector.
* @param {Vec3|Array.<number>} [options.position] - Billboard spatial position. * @param {Vec3|Array.<number>} [options.offset] - Billboard center screen offset.
* @param {number} [options.rotation] - Screen angle rotaion. * @param {boolean} [options.visibility] - Visibility.
* @param {Vec4|string|Array.<number>} [options.color] - Billboard color. */
* @param {Vec3|Array.<number>} [options.alignedAxis] - Billboard aligned vector. class BaseBillboard {
* @param {Vec3|Array.<number>} [options.offset] - Billboard center screen offset. constructor(options) {
* @param {boolean} [options.visibility] - Visibility. options = options || {};
*/
class BaseBillboard { /**
constructor(options) { * Object unic identifier.
options = options || {}; * @public
* @readonly
/** * @type {number}
* Object unic identifier. */
* @public this.id = BaseBillboard._staticCounter++;
* @readonly
* @type {number} /**
*/ * Billboard center cartesian position.
this.id = BaseBillboard._staticCounter++; * @protected
* @type {Vec3}
/** */
* Billboard center cartesian position. this._position = utils.createVector3(options.position);
* @protected
* @type {Vec3} this._positionHigh = new Vec3();
*/
this._position = utils.createVector3(options.position); this._positionLow = new Vec3();
this._positionHigh = new Vec3(); Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
this._positionLow = new Vec3(); /**
* Screen space rotation angle.
Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow); * @protected
* @type {number}
/** */
* Screen space rotation angle. this._rotation = options.rotation || 0;
* @protected
* @type {number} /**
*/ * RGBA color.
this._rotation = options.rotation || 0; * @protected
* @type {Vec4}
/** */
* RGBA color. this._color = utils.createColorRGBA(options.color);
* @protected
* @type {Vec4} /**
*/ * Cartesian aligned axis vector.
this._color = utils.createColorRGBA(options.color); * @protected
* @type {Vec3}
/** */
* Cartesian aligned axis vector. this._alignedAxis = utils.createVector3(options.alignedAxis);
* @protected
* @type {Vec3} /**
*/ * Billboard center screen space offset. Where x,y - screen space offset and z - depth offset.
this._alignedAxis = utils.createVector3(options.alignedAxis); * @protected
* @type {math.Vecto3}
/** */
* Billboard center screen space offset. Where x,y - screen space offset and z - depth offset. this._offset = utils.createVector3(options.offset);
* @protected
* @type {math.Vecto3} /**
*/ * Billboard visibility.
this._offset = utils.createVector3(options.offset); * @protected
* @type {boolean}
/** */
* Billboard visibility. this._visibility = options.visibility != undefined ? options.visibility : true;
* @protected
* @type {boolean} /**
*/ * Entity instance that holds this billboard.
this._visibility = options.visibility != undefined ? options.visibility : true; * @protected
* @type {Entity}
/** */
* Entity instance that holds this billboard. this._entity = null;
* @protected
* @type {Entity} /**
*/ * Handler that stores and renders this billboard object.
this._entity = null; * @protected
* @type {BillboardHandler}
/** */
* Handler that stores and renders this billboard object. this._handler = null;
* @protected
* @type {BillboardHandler} /**
*/ * Billboard handler array index.
this._handler = null; * @protected
* @type {number}
/** */
* Billboard handler array index. this._handlerIndex = -1;
* @protected
* @type {number} /**
*/ * An indication that the object is ready to draw
this._handlerIndex = -1; * @protected
* @type {number}
/** */
* An indication that the object is ready to draw this._isReady = false;
* @protected
* @type {number} this._lockId = LOCK_FREE;
*/ }
this._isReady = false;
static get _staticCounter() {
this._lockId = LOCK_FREE; if (!this._counter && this._counter !== 0) {
} this._counter = 0;
}
static get _staticCounter() { return this._counter;
if (!this._counter && this._counter !== 0) { }
this._counter = 0;
} static set _staticCounter(n) {
return this._counter; this._counter = n;
} }
static set _staticCounter(n) { /**
this._counter = n; * Sets billboard position.
} * @public
* @param {number} x - X coordinate.
/** * @param {number} y - Y coordinate.
* Sets billboard position. * @param {number} z - Z coordinate.
* @public */
* @param {number} x - X coordinate. setPosition(x, y, z) {
* @param {number} y - Y coordinate. this._position.x = x;
* @param {number} z - Z coordinate. this._position.y = y;
*/ this._position.z = z;
setPosition(x, y, z) { Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
this._position.x = x; if (this._isReady && this._handler) {
this._position.y = y; this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
this._position.z = z; } else if (this._lockId !== LOCK_FREE) {
Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow); this._lockId = LOCK_UPDATE;
if (this._isReady && this._handler) { }
this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow); }
} else if (this._lockId !== LOCK_FREE) {
this._lockId = LOCK_UPDATE; /**
} * Sets billboard position.
} * @public
* @param {Vec3} position - Cartesian coordinates.
/** */
* Sets billboard position. setPosition3v(position) {
* @public this._position.x = position.x;
* @param {Vec3} position - Cartesian coordinates. this._position.y = position.y;
*/ this._position.z = position.z;
setPosition3v(position) { Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
this._position.x = position.x; if (this._isReady && this._handler) {
this._position.y = position.y; this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
this._position.z = position.z; } else if (this._lockId !== LOCK_FREE) {
Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow); this._lockId = LOCK_UPDATE;
if (this._isReady && this._handler) { }
this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow); }
} else if (this._lockId !== LOCK_FREE) {
this._lockId = LOCK_UPDATE; /**
} * Returns billboard position.
} * @public
* @returns {Vec3}
/** */
* Returns billboard position. getPosition() {
* @public return this._position;
* @returns {Vec3} }
*/
getPosition() { /**
return this._position; * Sets screen space offset.
} * @public
* @param {number} x - X offset.
/** * @param {number} y - Y offset.
* Sets screen space offset. * @param {number} [z] - Z offset.
* @public */
* @param {number} x - X offset. setOffset(x, y, z) {
* @param {number} y - Y offset. this._offset.x = x;
* @param {number} [z] - Z offset. this._offset.y = y;
*/ z != undefined && (this._offset.z = z);
setOffset(x, y, z) { if (this._isReady && this._handler) {
this._offset.x = x; this._handler.setOffsetArr(this._handlerIndex, this._offset);
this._offset.y = y; } else if (this._lockId !== LOCK_FREE) {
z != undefined && (this._offset.z = z); this._lockId = LOCK_UPDATE;
if (this._isReady && this._handler) { }
this._handler.setOffsetArr(this._handlerIndex, this._offset); }
} else if (this._lockId !== LOCK_FREE) {
this._lockId = LOCK_UPDATE; /**
} * Sets screen space offset.
} * @public
* @param {Vec2} offset - Offset size.
/** */
* Sets screen space offset. setOffset3v(offset) {
* @public this.setOffset(offset.x, offset.y, offset.z);
* @param {Vec2} offset - Offset size. }
*/
setOffset3v(offset) { /**
this.setOffset(offset.x, offset.y, offset.z); * Returns billboard screen space offset size.
} * @public
* @returns {Vec3}
/** */
* Returns billboard screen space offset size. getOffset() {
* @public return this._offset;
* @returns {Vec3} }
*/
getOffset() { /**
return this._offset; * Sets billboard screen space rotation in radians.
} * @public
* @param {number} rotation - Screen space rotation in radians.
/** */
* Sets billboard screen space rotation in radians. setRotation(rotation) {
* @public if (rotation !== this._rotation) {
* @param {number} rotation - Screen space rotation in radians. this._rotation = rotation;
*/ if (this._isReady && this._handler) {
setRotation(rotation) { this._handler.setRotationArr(this._handlerIndex, rotation);
if (rotation !== this._rotation) { } else if (this._lockId !== LOCK_FREE) {
this._rotation = rotation; this._lockId = LOCK_UPDATE;
if (this._isReady && this._handler) { }
this._handler.setRotationArr(this._handlerIndex, rotation); }
} else if (this._lockId !== LOCK_FREE) { }
this._lockId = LOCK_UPDATE;
} /**
} * Gets screen space rotation.
} * @public
* @returns {number}
/** */
* Gets screen space rotation. getRotation() {
* @public return this._rotation;
* @returns {number} }
*/
getRotation() { /**
return this._rotation; * Sets billboard opacity.
} * @public
* @param {number} a - Billboard opacity.
/** */
* Sets billboard opacity. setOpacity(a) {
* @public if (a !== this._color.w) {
* @param {number} a - Billboard opacity. a != undefined && (this._color.w = a);
*/ if (this._isReady && this._handler) {
setOpacity(a) { this._handler.setRgbaArr(this._handlerIndex, this._color);
if (a !== this._color.w) { } else if (this._lockId !== LOCK_FREE) {
a != undefined && (this._color.w = a); this._lockId = LOCK_UPDATE;
if (this._isReady && this._handler) { }
this._handler.setRgbaArr(this._handlerIndex, this._color); }
} else if (this._lockId !== LOCK_FREE) { }
this._lockId = LOCK_UPDATE;
} /**
} * Sets RGBA color. Each channel from 0.0 to 1.0.
} * @public
* @param {number} r - Red.
/** * @param {number} g - Green.
* Sets RGBA color. Each channel from 0.0 to 1.0. * @param {number} b - Blue.
* @public * @param {number} a - Alpha.
* @param {number} r - Red. */
* @param {number} g - Green. setColor(r, g, b, a) {
* @param {number} b - Blue. if (a !== this._color.w || r !== this._color.x || g !== this._color.y || this._color.z !== b) {
* @param {number} a - Alpha. this._color.x = r;
*/ this._color.y = g;
setColor(r, g, b, a) { this._color.z = b;
if (a !== this._color.w || r !== this._color.x || g !== this._color.y || this._color.z !== b) { a != undefined && (this._color.w = a);
this._color.x = r; if (this._isReady && this._handler) {
this._color.y = g; this._handler.setRgbaArr(this._handlerIndex, this._color);
this._color.z = b; } else if (this._lockId !== LOCK_FREE) {
a != undefined && (this._color.w = a); this._lockId = LOCK_UPDATE;
if (this._isReady && this._handler) { }
this._handler.setRgbaArr(this._handlerIndex, this._color); }
} else if (this._lockId !== LOCK_FREE) { }
this._lockId = LOCK_UPDATE;
} /**
} * Sets RGBA color. Each channel from 0.0 to 1.0.
} * @public
* @param {Vec4} color - RGBA vector.
/** */
* Sets RGBA color. Each channel from 0.0 to 1.0. setColor4v(color) {
* @public this.setColor(color.x, color.y, color.z, color.w);
* @param {Vec4} color - RGBA vector. }
*/
setColor4v(color) { /**
this.setColor(color.x, color.y, color.z, color.w); * Sets billboard color.
} * @public
* @param {string} color - HTML style color.
/** */
* Sets billboard color. setColorHTML(color) {
* @public this.setColor4v(utils.htmlColorToRgba(color));
* @param {string} color - HTML style color. }
*/
setColorHTML(color) { /**
this.setColor4v(utils.htmlColorToRgba(color)); * Returns RGBA color.
} * @public
* @returns {Vec4}
/** */
* Returns RGBA color. getColor() {
* @public return this._color;
* @returns {Vec4} }
*/
getColor() { /**
return this._color; * Sets billboard visibility.
} * @public
* @param {boolean} visibility - Visibility flag.
/** */
* Sets billboard visibility. setVisibility(visibility) {
* @public if (visibility !== this._visibility) {
* @param {boolean} visibility - Visibility flag. this._visibility = visibility;
*/ if (this._isReady && this._handler) {
setVisibility(visibility) { this._handler.setVisibility(this._handlerIndex, visibility);
if (visibility !== this._visibility) { } else if (this._lockId !== LOCK_FREE) {
this._visibility = visibility; this._lockId = LOCK_UPDATE;
if (this._isReady && this._handler) { }
this._handler.setVisibility(this._handlerIndex, visibility); }
} else if (this._lockId !== LOCK_FREE) { }
this._lockId = LOCK_UPDATE;
} /**
} * Returns billboard visibility.
} * @public
* @returns {boolean}
/** */
* Returns billboard visibility. getVisibility() {
* @public return this._visibility;
* @returns {boolean} }
*/
getVisibility() { /**
return this._visibility; * Sets billboard cartesian aligned vector.
} * @public
* @param {number} x - Aligned vector X coordinate.
/** * @param {number} y - Aligned vector Y coordinate.
* Sets billboard cartesian aligned vector. * @param {number} z - Aligned vector Z coordinate.
* @public */
* @param {number} x - Aligned vector X coordinate. setAlignedAxis(x, y, z) {
* @param {number} y - Aligned vector Y coordinate. this._alignedAxis.x = x;
* @param {number} z - Aligned vector Z coordinate. this._alignedAxis.y = y;
*/ this._alignedAxis.z = z;
setAlignedAxis(x, y, z) { if (this._isReady && this._handler) {
this._alignedAxis.x = x; this._handler.setAlignedAxisArr(this._handlerIndex, this._alignedAxis);
this._alignedAxis.y = y; } else if (this._lockId !== LOCK_FREE) {
this._alignedAxis.z = z; this._lockId = LOCK_UPDATE;
if (this._isReady && this._handler) { }
this._handler.setAlignedAxisArr(this._handlerIndex, this._alignedAxis); }
} else if (this._lockId !== LOCK_FREE) {
this._lockId = LOCK_UPDATE; /**
} * Sets billboard aligned vector.
} * @public
* @param {math.Vecto3} alignedAxis - Vector to align.
/** */
* Sets billboard aligned vector. setAlignedAxis3v(alignedAxis) {
* @public this.setAlignedAxis(alignedAxis.x, alignedAxis.y, alignedAxis.z);
* @param {math.Vecto3} alignedAxis - Vector to align. }
*/
setAlignedAxis3v(alignedAxis) { /**
this.setAlignedAxis(alignedAxis.x, alignedAxis.y, alignedAxis.z); * Returns aligned vector.
} * @public
* @returns {Vec3}
/** */
* Returns aligned vector. getAlignedAxis() {
* @public return this._alignedAxis;
* @returns {Vec3} }
*/
getAlignedAxis() { /**
return this._alignedAxis; * Removes billboard from hander.
} * @public
*/
/** remove() {
* Removes billboard from hander. this._entity = null;
* @public this._handler && this._handler.remove(this);
*/ }
remove() {
this._entity = null; /**
this._handler && this._handler.remove(this); * Sets billboard picking color.
} * @public
* @param {Vec3} color - Picking color.
/** */
* Sets billboard picking color. setPickingColor3v(color) {
* @public if (this._isReady && this._handler) {
* @param {Vec3} color - Picking color. this._handler.setPickingColorArr(this._handlerIndex, color);
*/ } else if (this._lockId !== LOCK_FREE) {
setPickingColor3v(color) { this._lockId = LOCK_UPDATE;
if (this._isReady && this._handler) { }
this._handler.setPickingColorArr(this._handlerIndex, color); }
} else if (this._lockId !== LOCK_FREE) { }
this._lockId = LOCK_UPDATE;
} export { BaseBillboard };
}
}
export { BaseBillboard };

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/Billboard
*/
"use strict"; "use strict";
import { BaseBillboard } from "./BaseBillboard.js"; import { BaseBillboard } from "./BaseBillboard.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/BillboardHandler
*/
"use strict"; "use strict";
import * as shaders from "../shaders/billboard.js"; import * as shaders from "../shaders/billboard.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/Entity
*/
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/EntityCollection
*/
"use strict"; "use strict";
import { Events } from "../Events.js"; import { Events } from "../Events.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/GeoObject
*/
"use strict"; "use strict";
import { Quat, Vec3 } from "../math/index.js"; import { Quat, Vec3 } from "../math/index.js";

View File

@ -1,9 +1,5 @@
"use strict"; "use strict";
/**
* @module og/entity/GeoObjectHandler
*/
import * as shaders from "../shaders/geoObject.js"; import * as shaders from "../shaders/geoObject.js";
import { concatArrays, loadImage, makeArrayTyped, spliceArray } from "../utils/shared.js"; import { concatArrays, loadImage, makeArrayTyped, spliceArray } from "../utils/shared.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/Geometry
*/
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent.js";
@ -193,7 +189,7 @@ class Geometry {
} }
/** /**
* @todo * @todo ASAP need test for this method
* @param geoJson * @param geoJson
* @returns {Geometry} * @returns {Geometry}
*/ */

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/GeometryHandler
*/
"use strict"; "use strict";
import { doubleToTwoFloatsV2 } from "../math/coder.js"; import { doubleToTwoFloatsV2 } from "../math/coder.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/Label
*/
"use strict"; "use strict";
import { Vec4 } from "../math/Vec4.js"; import { Vec4 } from "../math/Vec4.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/LabelHandler
*/
"use strict"; "use strict";
import * as shaders from "../shaders/label.js"; import * as shaders from "../shaders/label.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/PointCloud
*/
"use strict"; "use strict";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3.js";

View File

@ -1,126 +1,122 @@
/** "use strict";
* @module og/entity/PointCloudHandler
*/ import * as shaders from "../shaders/pointCloud.js";
"use strict"; class PointCloudHandler {
constructor(entityCollection) {
import * as shaders from "../shaders/pointCloud.js"; /**
* Picking rendering option.
class PointCloudHandler { * @public
constructor(entityCollection) { * @type {boolean}
/** */
* Picking rendering option. this.pickingEnabled = true;
* @public
* @type {boolean} /**
*/ * Parent collection
this.pickingEnabled = true; * @private
* @type {EntityCollection}
/** */
* Parent collection this._entityCollection = entityCollection;
* @private
* @type {EntityCollection} /**
*/ * Renderer
this._entityCollection = entityCollection; * @private
* @type {Renderer}
/** */
* Renderer this._renderer = null;
* @private
* @type {Renderer} /**
*/ * Point cloud array
this._renderer = null; * @private
* @type {Array.<PointCloud>}
/** */
* Point cloud array this._pointClouds = [];
* @private
* @type {Array.<PointCloud>} this.__staticId = PointCloudHandler._staticCounter++;
*/ }
this._pointClouds = [];
static get _staticCounter() {
this.__staticId = PointCloudHandler._staticCounter++; if (!this._counter && this._counter !== 0) {
} this._counter = 0;
}
static get _staticCounter() { return this._counter;
if (!this._counter && this._counter !== 0) { }
this._counter = 0;
} static set _staticCounter(n) {
return this._counter; this._counter = n;
} }
static set _staticCounter(n) { _initProgram() {
this._counter = n; if (this._renderer.handler) {
} if (!this._renderer.handler.programs.pointCloud) {
this._renderer.handler.addProgram(shaders.pointCloud());
_initProgram() { }
if (this._renderer.handler) { }
if (!this._renderer.handler.programs.pointCloud) { }
this._renderer.handler.addProgram(shaders.pointCloud());
} setRenderNode(renderNode) {
} this._renderer = renderNode.renderer;
} this._initProgram();
for (var i = 0; i < this._pointClouds.length; i++) {
setRenderNode(renderNode) { this._pointClouds[i].setRenderNode(renderNode);
this._renderer = renderNode.renderer; }
this._initProgram(); }
for (var i = 0; i < this._pointClouds.length; i++) {
this._pointClouds[i].setRenderNode(renderNode); add(pointCloud) {
} if (pointCloud._handlerIndex === -1) {
} pointCloud._handler = this;
pointCloud._handlerIndex = this._pointClouds.length;
add(pointCloud) { this._pointClouds.push(pointCloud);
if (pointCloud._handlerIndex === -1) { this._entityCollection &&
pointCloud._handler = this; this._entityCollection.renderNode &&
pointCloud._handlerIndex = this._pointClouds.length; pointCloud.setRenderNode(this._entityCollection.renderNode);
this._pointClouds.push(pointCloud); }
this._entityCollection && }
this._entityCollection.renderNode &&
pointCloud.setRenderNode(this._entityCollection.renderNode); remove(pointCloud) {
} var index = pointCloud._handlerIndex;
} if (index !== -1) {
pointCloud._deleteBuffers();
remove(pointCloud) { pointCloud._handlerIndex = -1;
var index = pointCloud._handlerIndex; pointCloud._handler = null;
if (index !== -1) { this._pointClouds.splice(index, 1);
pointCloud._deleteBuffers(); this.reindexPointCloudArray(index);
pointCloud._handlerIndex = -1; }
pointCloud._handler = null; }
this._pointClouds.splice(index, 1);
this.reindexPointCloudArray(index); reindexPointCloudArray(startIndex) {
} var pc = this._pointClouds;
} for (var i = startIndex; i < pc.length; i++) {
pc[i]._handlerIndex = i;
reindexPointCloudArray(startIndex) { }
var pc = this._pointClouds; }
for (var i = startIndex; i < pc.length; i++) {
pc[i]._handlerIndex = i; draw() {
} var i = this._pointClouds.length;
} while (i--) {
this._pointClouds[i].draw();
draw() { }
var i = this._pointClouds.length; }
while (i--) {
this._pointClouds[i].draw(); drawPicking() {
} if (this.pickingEnabled) {
} var i = this._pointClouds.length;
while (i--) {
drawPicking() { this._pointClouds[i].drawPicking();
if (this.pickingEnabled) { }
var i = this._pointClouds.length; }
while (i--) { }
this._pointClouds[i].drawPicking();
} clear() {
} var i = this._pointClouds.length;
} while (i--) {
this._pointClouds[i]._deleteBuffers();
clear() { this._pointClouds[i]._handler = null;
var i = this._pointClouds.length; this._pointClouds[i]._handlerIndex = -1;
while (i--) { }
this._pointClouds[i]._deleteBuffers(); this._pointClouds.length = 0;
this._pointClouds[i]._handler = null; this._pointClouds = [];
this._pointClouds[i]._handlerIndex = -1; }
} }
this._pointClouds.length = 0;
this._pointClouds = []; export { PointCloudHandler };
}
}
export { PointCloudHandler };

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/Polyline
*/
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent.js";

View File

@ -1,109 +1,105 @@
/** 'use strict';
* @module og/entity/PolylineHandler
*/ import * as shaders from '../shaders/polyline.js';
'use strict'; class PolylineHandler {
constructor(entityCollection) {
import * as shaders from '../shaders/polyline.js';
this._entityCollection = entityCollection;
class PolylineHandler {
constructor(entityCollection) { this._renderer = null;
this._entityCollection = entityCollection; this._polylines = [];
this._renderer = null; this.__staticId = PolylineHandler._staticCounter++;
this._polylines = []; this.pickingEnabled = true;
}
this.__staticId = PolylineHandler._staticCounter++;
static get _staticCounter() {
this.pickingEnabled = true; if (!this._counter && this._counter !== 0) {
} this._counter = 0;
}
static get _staticCounter() { return this._counter;
if (!this._counter && this._counter !== 0) { }
this._counter = 0;
} static set _staticCounter(n) {
return this._counter; this._counter = n;
} }
static set _staticCounter(n) { _initProgram() {
this._counter = n; if (this._renderer.handler) {
} if (!this._renderer.handler.programs.polyline_screen) {
this._renderer.handler.addProgram(shaders.polyline_screen());
_initProgram() { }
if (this._renderer.handler) { if (!this._renderer.handler.programs.polyline_picking) {
if (!this._renderer.handler.programs.polyline_screen) { this._renderer.handler.addProgram(shaders.polyline_picking());
this._renderer.handler.addProgram(shaders.polyline_screen()); }
} }
if (!this._renderer.handler.programs.polyline_picking) { }
this._renderer.handler.addProgram(shaders.polyline_picking());
} setRenderNode(renderNode) {
} this._renderer = renderNode.renderer;
} this._initProgram();
for (var i = 0; i < this._polylines.length; i++) {
setRenderNode(renderNode) { this._polylines[i].setRenderNode(renderNode);
this._renderer = renderNode.renderer; }
this._initProgram(); }
for (var i = 0; i < this._polylines.length; i++) {
this._polylines[i].setRenderNode(renderNode); add(polyline) {
} if (polyline._handlerIndex === -1) {
} polyline._handler = this;
polyline._handlerIndex = this._polylines.length;
add(polyline) { this._polylines.push(polyline);
if (polyline._handlerIndex === -1) { this._entityCollection && this._entityCollection.renderNode &&
polyline._handler = this; polyline.setRenderNode(this._entityCollection.renderNode);
polyline._handlerIndex = this._polylines.length; }
this._polylines.push(polyline); }
this._entityCollection && this._entityCollection.renderNode &&
polyline.setRenderNode(this._entityCollection.renderNode); remove(polyline) {
} var index = polyline._handlerIndex;
} if (index !== -1) {
polyline._deleteBuffers();
remove(polyline) { polyline._handlerIndex = -1;
var index = polyline._handlerIndex; polyline._handler = null;
if (index !== -1) { this._polylines.splice(index, 1);
polyline._deleteBuffers(); this.reindexPolylineArray(index);
polyline._handlerIndex = -1; }
polyline._handler = null; }
this._polylines.splice(index, 1);
this.reindexPolylineArray(index); reindexPolylineArray(startIndex) {
} var ls = this._polylines;
} for (var i = startIndex; i < ls.length; i++) {
ls[i]._handlerIndex = i;
reindexPolylineArray(startIndex) { }
var ls = this._polylines; }
for (var i = startIndex; i < ls.length; i++) {
ls[i]._handlerIndex = i; draw() {
} let i = this._polylines.length;
} while (i--) {
this._polylines[i].draw();
draw() { }
let i = this._polylines.length; }
while (i--) {
this._polylines[i].draw(); drawPicking() {
} if (this.pickingEnabled) {
} let i = this._polylines.length;
while (i--) {
drawPicking() { this._polylines[i].drawPicking();
if (this.pickingEnabled) { }
let i = this._polylines.length; }
while (i--) { }
this._polylines[i].drawPicking();
} clear() {
} var i = this._polylines.length;
} while (i--) {
this._polylines[i]._deleteBuffers();
clear() { this._polylines[i]._handler = null;
var i = this._polylines.length; this._polylines[i]._handlerIndex = -1;
while (i--) { }
this._polylines[i]._deleteBuffers(); this._polylines.length = 0;
this._polylines[i]._handler = null; this._polylines = [];
this._polylines[i]._handlerIndex = -1; }
} }
this._polylines.length = 0;
this._polylines = [];
}
}
export { PolylineHandler }; export { PolylineHandler };

View File

@ -1,7 +1,3 @@
/**
* @module og/entity/BaseBillboard
*/
"use strict"; "use strict";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3.js";

View File

@ -1,132 +1,128 @@
/** 'use strict';
* @module og/input/KeyboardHandler
*/ import { input } from './input.js';
'use strict'; class KeyboardHandler {
import { input } from './input.js'; constructor() {
var _currentlyPressedKeys = {};
class KeyboardHandler { var _pressedKeysCallbacks = {};
var _unpressedKeysCallbacks = {};
constructor() { var _charkeysCallbacks = {};
var _currentlyPressedKeys = {}; var _that = this;
var _pressedKeysCallbacks = {}; var _anykeyCallback = null;
var _unpressedKeysCallbacks = {}; var _event = null;
var _charkeysCallbacks = {};
var _that = this; var _active = true;
var _anykeyCallback = null;
var _event = null; if (KeyboardHandler.prototype._instance) {
return KeyboardHandler.prototype._instance;
var _active = true; } else {
KeyboardHandler.prototype._instance = this;
if (KeyboardHandler.prototype._instance) {
return KeyboardHandler.prototype._instance; document.onkeydown = function (event) { _event = event; _active && _that.handleKeyDown(); };
} else { document.onkeyup = function (event) { _event = event; _active && _that.handleKeyUp(); };
KeyboardHandler.prototype._instance = this; }
document.onkeydown = function (event) { _event = event; _active && _that.handleKeyDown(); }; var _sortByPriority = function (a, b) {
document.onkeyup = function (event) { _event = event; _active && _that.handleKeyUp(); }; return a.priority < b.priority;
} };
var _sortByPriority = function (a, b) { this.removeEvent = function (events, callback) {
return a.priority < b.priority; //
}; // TODO:...
//
this.removeEvent = function (events, callback) { };
//
// TODO:... this.setActivity = function (activity) {
// _active = activity;
}; };
this.setActivity = function (activity) { this.releaseKeys = function () {
_active = activity; _currentlyPressedKeys = {};
}; }
this.releaseKeys = function () { this.addEvent = function (event, sender, callback, keyCode, priority) {
_currentlyPressedKeys = {}; if (priority === undefined) {
} priority = 1600;
}
this.addEvent = function (event, sender, callback, keyCode, priority) { switch (event) {
if (priority === undefined) { case "keyfree":
priority = 1600; if (!_unpressedKeysCallbacks[keyCode]) {
} _unpressedKeysCallbacks[keyCode] = [];
switch (event) { }
case "keyfree": _unpressedKeysCallbacks[keyCode].push({ callback: callback, sender: sender, priority: priority });
if (!_unpressedKeysCallbacks[keyCode]) { _unpressedKeysCallbacks[keyCode].sort(_sortByPriority);
_unpressedKeysCallbacks[keyCode] = []; break;
}
_unpressedKeysCallbacks[keyCode].push({ callback: callback, sender: sender, priority: priority }); case "keypress":
_unpressedKeysCallbacks[keyCode].sort(_sortByPriority); if (keyCode == null) {
break; _anykeyCallback = { callback: callback, sender: sender || _that };
} else {
case "keypress": if (!_pressedKeysCallbacks[keyCode]) {
if (keyCode == null) { _pressedKeysCallbacks[keyCode] = [];
_anykeyCallback = { callback: callback, sender: sender || _that }; }
} else { _pressedKeysCallbacks[keyCode].push({ callback: callback, sender: sender, priority: priority });
if (!_pressedKeysCallbacks[keyCode]) { _pressedKeysCallbacks[keyCode].sort(_sortByPriority);
_pressedKeysCallbacks[keyCode] = []; }
} break;
_pressedKeysCallbacks[keyCode].push({ callback: callback, sender: sender, priority: priority });
_pressedKeysCallbacks[keyCode].sort(_sortByPriority); case "charkeypress":
} if (!_charkeysCallbacks[keyCode]) {
break; _charkeysCallbacks[keyCode] = [];
}
case "charkeypress": _charkeysCallbacks[keyCode].push({ callback: callback, sender: sender, priority: priority });
if (!_charkeysCallbacks[keyCode]) { _charkeysCallbacks[keyCode].sort(_sortByPriority);
_charkeysCallbacks[keyCode] = []; break;
} }
_charkeysCallbacks[keyCode].push({ callback: callback, sender: sender, priority: priority }); };
_charkeysCallbacks[keyCode].sort(_sortByPriority);
break; this.isKeyPressed = function (keyCode) {
} return _currentlyPressedKeys[keyCode];
}; };
this.isKeyPressed = function (keyCode) { this.handleKeyDown = function () {
return _currentlyPressedKeys[keyCode]; _anykeyCallback && _anykeyCallback.callback.call(_anykeyCallback.sender, _event);
}; _currentlyPressedKeys[_event.keyCode] = true;
for (var ch in _charkeysCallbacks) {
this.handleKeyDown = function () { if (String.fromCharCode(_event.keyCode) == String.fromCharCode(ch)) {
_anykeyCallback && _anykeyCallback.callback.call(_anykeyCallback.sender, _event); var ccl = _charkeysCallbacks[ch];
_currentlyPressedKeys[_event.keyCode] = true; for (var i = 0; i < ccl.length; i++) {
for (var ch in _charkeysCallbacks) { ccl[i].callback.call(ccl[i].sender, _event);
if (String.fromCharCode(_event.keyCode) == String.fromCharCode(ch)) { }
var ccl = _charkeysCallbacks[ch]; }
for (var i = 0; i < ccl.length; i++) { }
ccl[i].callback.call(ccl[i].sender, _event);
} if (_event.keyCode == input.KEY_ALT || _event.keyCode == input.KEY_SHIFT) {
} _event.preventDefault();
} }
};
if (_event.keyCode == input.KEY_ALT || _event.keyCode == input.KEY_SHIFT) {
_event.preventDefault(); this.handleKeyUp = function () {
} if (_currentlyPressedKeys[_event.keyCode] || _event.keyCode === input.KEY_PRINTSCREEN) {
}; for (var pk in _unpressedKeysCallbacks) {
if (_currentlyPressedKeys[pk] || _event.keyCode === input.KEY_PRINTSCREEN && pk == input.KEY_PRINTSCREEN) {
this.handleKeyUp = function () { var cpk = _unpressedKeysCallbacks[pk];
if (_currentlyPressedKeys[_event.keyCode] || _event.keyCode === input.KEY_PRINTSCREEN) { for (var i = 0; i < cpk.length; i++) {
for (var pk in _unpressedKeysCallbacks) { cpk[i].callback.call(cpk[i].sender, _event);
if (_currentlyPressedKeys[pk] || _event.keyCode === input.KEY_PRINTSCREEN && pk == input.KEY_PRINTSCREEN) { }
var cpk = _unpressedKeysCallbacks[pk]; }
for (var i = 0; i < cpk.length; i++) { }
cpk[i].callback.call(cpk[i].sender, _event); }
} _currentlyPressedKeys[_event.keyCode] = false;
} };
}
} this.handleEvents = function () {
_currentlyPressedKeys[_event.keyCode] = false; for (var pk in _pressedKeysCallbacks) {
}; if (_currentlyPressedKeys[pk]) {
var cpk = _pressedKeysCallbacks[pk];
this.handleEvents = function () { for (var i = 0; i < cpk.length; i++) {
for (var pk in _pressedKeysCallbacks) { cpk[i].callback.call(cpk[i].sender, _event);
if (_currentlyPressedKeys[pk]) { }
var cpk = _pressedKeysCallbacks[pk]; }
for (var i = 0; i < cpk.length; i++) { }
cpk[i].callback.call(cpk[i].sender, _event); };
} }
} }
}
}; export { KeyboardHandler };
}
}
export { KeyboardHandler };

View File

@ -1,98 +1,94 @@
/** 'use strict';
* @module og/input/MouseHandler
*/ class MouseHandler {
'use strict'; constructor(htmlObject) {
this._htmlObject = htmlObject;
class MouseHandler { }
constructor(htmlObject) { setEvent(event, sender, callback) {
this._htmlObject = htmlObject; switch (event) {
} case "mousewheel":
this._htmlObject.addEventListener('mousewheel', function (evt) {
setEvent(event, sender, callback) { var delta = evt.deltaY || evt.detail || evt.wheelDelta;
switch (event) { if (evt.wheelDelta == undefined) {
case "mousewheel": evt.wheelDelta = delta * (-120);
this._htmlObject.addEventListener('mousewheel', function (evt) { }
var delta = evt.deltaY || evt.detail || evt.wheelDelta; callback.call(sender, evt);
if (evt.wheelDelta == undefined) { evt.preventDefault();
evt.wheelDelta = delta * (-120); }, false);
}
callback.call(sender, evt); this._htmlObject.addEventListener('wheel', function (evt) {
evt.preventDefault(); var delta = evt.deltaY || evt.detail || evt.wheelDelta;
}, false); if (evt.wheelDelta == undefined) {
evt.wheelDelta = delta * (-120);
this._htmlObject.addEventListener('wheel', function (evt) { }
var delta = evt.deltaY || evt.detail || evt.wheelDelta; callback.call(sender, evt);
if (evt.wheelDelta == undefined) { evt.preventDefault();
evt.wheelDelta = delta * (-120); }, false);
} break;
callback.call(sender, evt);
evt.preventDefault(); case "mousedown":
}, false); this._htmlObject.addEventListener('mousedown', function (event) {
break; var rect = this.getBoundingClientRect();
callback.call(sender, {
case "mousedown": button: event.button,
this._htmlObject.addEventListener('mousedown', function (event) { clientX: event.clientX - rect.left,
var rect = this.getBoundingClientRect(); clientY: event.clientY - rect.top
callback.call(sender, { }, event);
button: event.button, });
clientX: event.clientX - rect.left, this._htmlObject.addEventListener('contextmenu', function (event) {
clientY: event.clientY - rect.top event.preventDefault();
}, event); return false;
}); });
this._htmlObject.addEventListener('contextmenu', function (event) { break;
event.preventDefault();
return false; case "mouseup":
}); this._htmlObject.addEventListener('mouseup', function (event) {
break; var rect = this.getBoundingClientRect();
callback.call(sender, {
case "mouseup": button: event.button,
this._htmlObject.addEventListener('mouseup', function (event) { clientX: event.clientX - rect.left,
var rect = this.getBoundingClientRect(); clientY: event.clientY - rect.top
callback.call(sender, { }, event);
button: event.button, });
clientX: event.clientX - rect.left, break;
clientY: event.clientY - rect.top
}, event); case "mousemove":
}); this._htmlObject.addEventListener('mousemove', function (event) {
break; var rect = this.getBoundingClientRect();
callback.call(sender, {
case "mousemove": clientX: event.clientX - rect.left,
this._htmlObject.addEventListener('mousemove', function (event) { clientY: event.clientY - rect.top
var rect = this.getBoundingClientRect(); }, event);
callback.call(sender, { });
clientX: event.clientX - rect.left, break;
clientY: event.clientY - rect.top
}, event); case "mouseleave":
}); this._htmlObject.addEventListener('mouseleave', function (event) {
break; callback.call(sender, event);
});
case "mouseleave": break;
this._htmlObject.addEventListener('mouseleave', function (event) {
callback.call(sender, event); case "mouseout":
}); this._htmlObject.addEventListener('mouseout', function (event) {
break; callback.call(sender, event);
});
case "mouseout": break;
this._htmlObject.addEventListener('mouseout', function (event) {
callback.call(sender, event); case "mouseover":
}); this._htmlObject.addEventListener('mouseover', function (event) {
break; callback.call(sender, event);
});
case "mouseover": break;
this._htmlObject.addEventListener('mouseover', function (event) {
callback.call(sender, event); case "mouseenter":
}); this._htmlObject.addEventListener('mouseenter', function (event) {
break; callback.call(sender, event);
});
case "mouseenter": break;
this._htmlObject.addEventListener('mouseenter', function (event) { }
callback.call(sender, event); }
}); }
break;
} export { MouseHandler };
}
}
export { MouseHandler };

View File

@ -1,63 +1,59 @@
/** 'use strict';
* @module og/input/TouchHandler
*/ class TouchHandler {
'use strict'; constructor(htmlObject) {
this._htmlObject = htmlObject;
class TouchHandler { }
constructor(htmlObject) { setEvent(event, sender, callback) {
this._htmlObject = htmlObject; switch (event) {
} case "touchcancel":
this._htmlObject.addEventListener('touchcancel', function (event) {
setEvent(event, sender, callback) { event.preventDefault();
switch (event) { var rect = this.getBoundingClientRect();
case "touchcancel": event.offsetLeft = rect.left;
this._htmlObject.addEventListener('touchcancel', function (event) { event.offsetTop = rect.top;
event.preventDefault(); callback.call(sender, event);
var rect = this.getBoundingClientRect(); event.preventDefault();
event.offsetLeft = rect.left; });
event.offsetTop = rect.top; break;
callback.call(sender, event);
event.preventDefault(); case "touchstart":
}); this._htmlObject.addEventListener('touchstart', function (event) {
break; event.preventDefault();
var rect = this.getBoundingClientRect();
case "touchstart": event.offsetLeft = rect.left;
this._htmlObject.addEventListener('touchstart', function (event) { event.offsetTop = rect.top;
event.preventDefault(); callback.call(sender, event);
var rect = this.getBoundingClientRect(); event.preventDefault();
event.offsetLeft = rect.left; });
event.offsetTop = rect.top; break;
callback.call(sender, event);
event.preventDefault(); case "touchend":
}); this._htmlObject.addEventListener('touchend', function (event) {
break; event.preventDefault();
var rect = this.getBoundingClientRect();
case "touchend": event.offsetLeft = rect.left;
this._htmlObject.addEventListener('touchend', function (event) { event.offsetTop = rect.top;
event.preventDefault(); callback.call(sender, event);
var rect = this.getBoundingClientRect(); event.preventDefault();
event.offsetLeft = rect.left; });
event.offsetTop = rect.top; break;
callback.call(sender, event);
event.preventDefault(); case "touchmove":
}); this._htmlObject.addEventListener('touchmove', function (event) {
break; event.preventDefault();
var rect = this.getBoundingClientRect();
case "touchmove": event.offsetLeft = rect.left;
this._htmlObject.addEventListener('touchmove', function (event) { event.offsetTop = rect.top;
event.preventDefault(); callback.call(sender, event);
var rect = this.getBoundingClientRect(); event.preventDefault();
event.offsetLeft = rect.left; });
event.offsetTop = rect.top; break;
callback.call(sender, event); }
event.preventDefault(); }
}); }
break;
} export { TouchHandler };
}
}
export { TouchHandler };

View File

@ -1,48 +1,44 @@
/** 'use strict';
* @module og/input/input
*/ export const input = {
KEY_CTRL: 17,
'use strict'; KEY_ALT: 18,
KEY_SHIFT: 16,
export const input = { KEY_SPACE: 32,
KEY_CTRL: 17, KEY_PGUP: 33,
KEY_ALT: 18, KEY_PGDN: 34,
KEY_SHIFT: 16, KEY_LEFT: 37,
KEY_SPACE: 32, KEY_UP: 38,
KEY_PGUP: 33, KEY_RIGHT: 39,
KEY_PGDN: 34, KEY_DOWN: 40,
KEY_LEFT: 37, KEY_PRINTSCREEN: 44,
KEY_UP: 38, KEY_EQUALS: 61,
KEY_RIGHT: 39, KEY_A: 65,
KEY_DOWN: 40, KEY_C: 67,
KEY_PRINTSCREEN: 44, KEY_D: 68,
KEY_EQUALS: 61, KEY_E: 69,
KEY_A: 65, KEY_F: 70,
KEY_C: 67, KEY_H: 72,
KEY_D: 68, KEY_I: 73,
KEY_E: 69, KEY_K: 75,
KEY_F: 70, KEY_L: 76,
KEY_H: 72, KEY_N: 78,
KEY_I: 73, KEY_O: 79,
KEY_K: 75, KEY_P: 80,
KEY_L: 76, KEY_Q: 81,
KEY_N: 78, KEY_R: 82,
KEY_O: 79, KEY_S: 83,
KEY_P: 80, KEY_V: 86,
KEY_Q: 81, KEY_W: 87,
KEY_R: 82, KEY_X: 88,
KEY_S: 83, KEY_Z: 90,
KEY_V: 86, KEY_PLUS: 107,
KEY_W: 87, KEY_F1: 112,
KEY_X: 88, KEY_MINUS: 173,
KEY_Z: 90, KEY_APOSTROPHE: 192,
KEY_PLUS: 107, MB_LEFT: 0,
KEY_F1: 112, MB_RIGHT: 2,
KEY_MINUS: 173, MB_MIDDLE: 1,
KEY_APOSTROPHE: 192, KEY_BACK_SLASH: 220,
MB_LEFT: 0, KEY_SINGLE_QUOTE: 222
MB_RIGHT: 2, };
MB_MIDDLE: 1,
KEY_BACK_SLASH: 220,
KEY_SINGLE_QUOTE: 222
};

View File

@ -1,7 +1,3 @@
/**
* @module og/layer/BaseGeoImage
*/
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/layer/CanvasTiles
*/
"use strict"; "use strict";
import * as quadTree from "../quadTree/quadTree.js"; import * as quadTree from "../quadTree/quadTree.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/layer/GeoImage
*/
"use strict"; "use strict";
import { nextHighestPowerOfTwo } from "../math.js"; import { nextHighestPowerOfTwo } from "../math.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/layer/GeoTexture2d
*/
'use strict'; 'use strict';
import * as math from '../math.js'; import * as math from '../math.js';

View File

@ -1,7 +1,3 @@
/**
* @module og/layer/GeoVideo
*/
"use strict"; "use strict";
import { BaseGeoImage } from "./BaseGeoImage.js"; import { BaseGeoImage } from "./BaseGeoImage.js";

View File

@ -1,8 +1,5 @@
/**
* @module og/layer/KML
*/
"use strict"; "use strict";
import { Billboard } from "../entity/Billboard.js"; import { Billboard } from "../entity/Billboard.js";
import { Entity } from "../entity/Entity.js"; import { Entity } from "../entity/Entity.js";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/layer/Layer
*/
"use strict"; "use strict";
import { Events } from "../Events.js"; import { Events } from "../Events.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/layer/Material
*/
"use strict"; "use strict";
class Material { class Material {

View File

@ -1,7 +1,3 @@
/**
* @module og/layer/Vector
*/
"use strict"; "use strict";
import { Entity } from "../entity/Entity.js"; import { Entity } from "../entity/Entity.js";

View File

@ -1,186 +1,182 @@
/** "use strict";
* @module og/layer/WMS
*/ import { Extent } from "../Extent.js";
import { LonLat } from "../LonLat.js";
"use strict"; import * as mercator from "../mercator.js";
import { XYZ } from "./XYZ.js";
import { Extent } from "../Extent.js";
import { LonLat } from "../LonLat.js"; /**
import * as mercator from "../mercator.js"; * Used to display WMS services as tile layers on the globe.
import { XYZ } from "./XYZ.js"; * @class
* @extends {XYZ}
/** * //TODO: WMS version, format, and custom srs cpecification.
* Used to display WMS services as tile layers on the globe. * @param {string} name - Layer name.
* @class * @param {Object} options - Options:
* @extends {XYZ} * @param {number} [options.opacity=1.0] - Layer opacity.
* //TODO: WMS version, format, and custom srs cpecification. * @param {number} [options.minZoom=0] - Minimal visibility zoom level.
* @param {string} name - Layer name. * @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
* @param {Object} options - Options: * @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
* @param {number} [options.opacity=1.0] - Layer opacity. * @param {boolean} [options.isBaseLayer=false] - Base layer flag.
* @param {number} [options.minZoom=0] - Minimal visibility zoom level. * @param {boolean} [options.visibility=true] - Layer visibility.
* @param {number} [options.maxZoom=0] - Maximal visibility zoom level. * @param {string} options.url - WMS url source.
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen. * @param {number} [options.width=256] - Tile width.
* @param {boolean} [options.isBaseLayer=false] - Base layer flag. * @param {number} [options.height=256] - Tile height.
* @param {boolean} [options.visibility=true] - Layer visibility. * @param {string} options.layers - WMS layers string.
* @param {string} options.url - WMS url source. * @param {string} [options.version="1.1.1"] - WMS version.
* @param {number} [options.width=256] - Tile width. * @param {Object} extra - Extra parameters (by WMS rreference or by WMS service vendors) to pass to WMS service.
* @param {number} [options.height=256] - Tile height. * @example:
* @param {string} options.layers - WMS layers string. * new og.layer.WMS("USA States", {
* @param {string} [options.version="1.1.1"] - WMS version. * isBaseLayer: false,
* @param {Object} extra - Extra parameters (by WMS rreference or by WMS service vendors) to pass to WMS service. * url: "http://openglobus.org/geoserver/",
* @example: * layers: "topp:states",
* new og.layer.WMS("USA States", { * opacity: 0.5,
* isBaseLayer: false, * zIndex: 50,
* url: "http://openglobus.org/geoserver/", * attribution: 'USA states - geoserver WMS example',
* layers: "topp:states", * version: "1.1.1",
* opacity: 0.5, * visibility: false }, {
* zIndex: 50, * transparent: true,
* attribution: 'USA states - geoserver WMS example', * sld: "style.sld"}
* version: "1.1.1", * );
* visibility: false }, { *
* transparent: true, * @fires og.layer.XYZ#load
* sld: "style.sld"} * @fires og.layer.XYZ#loadend
* ); */
* class WMS extends XYZ {
* @fires og.layer.XYZ#load
* @fires og.layer.XYZ#loadend
*/ constructor(name, options, extra) {
class WMS extends XYZ { super(name, options);
this._extra = new URLSearchParams(extra).toString();
constructor(name, options, extra) {
super(name, options);
if (!options.extent) {
this._extra = new URLSearchParams(extra).toString(); this.setExtent(new Extent(new LonLat(-180.0, -90), new LonLat(180.0, 90)));
}
if (!options.extent) { /**
this.setExtent(new Extent(new LonLat(-180.0, -90), new LonLat(180.0, 90))); * WMS layers string.
} * @public
* @type {string}
/** */
* WMS layers string. this.layers = options.layers;
* @public
* @type {string} /**
*/ * WMS tile width.
this.layers = options.layers; * @public
* @type {number}
/** */
* WMS tile width. this.imageWidth = options.imageWidth || 256;
* @public
* @type {number} /**
*/ * WMS tile height.
this.imageWidth = options.imageWidth || 256; * @public
* @type {number}
/** */
* WMS tile height. this.imageHeight = options.imageHeight || 256;
* @public
* @type {number} this._getBbox = WMS.get_bbox_v1_1_1;
*/
this.imageHeight = options.imageHeight || 256; this.setVersion(options.version);
}
this._getBbox = WMS.get_bbox_v1_1_1;
static createRequestUrl(
this.setVersion(options.version); url,
} layers,
format = "image/png",
static createRequestUrl( version = "1.1.1",
url, request = "GetMap",
layers, srs,
format = "image/png", bbox,
version = "1.1.1", width = 256,
request = "GetMap", height = 256,
srs, extra
bbox,
width = 256, ) {
height = 256, return `${url}/?LAYERS=${layers}&FORMAT=${format}&SERVICE=WMS&VERSION=${version}&REQUEST=${request}&SRS=${srs}&BBOX=${bbox}&WIDTH=${width}&HEIGHT=${height}` +
extra (extra ? `&${extra}` : "");
}
) {
return `${url}/?LAYERS=${layers}&FORMAT=${format}&SERVICE=WMS&VERSION=${version}&REQUEST=${request}&SRS=${srs}&BBOX=${bbox}&WIDTH=${width}&HEIGHT=${height}` + static get_bbox_v1_1_1(extent) {
(extra ? `&${extra}` : ""); return (
} extent.getWest() +
"," +
static get_bbox_v1_1_1(extent) { extent.getSouth() +
return ( "," +
extent.getWest() + extent.getEast() +
"," + "," +
extent.getSouth() + extent.getNorth()
"," + );
extent.getEast() + }
"," +
extent.getNorth() static get_bbox_v1_3_0(extent) {
); return (
} extent.getSouth() +
"," +
static get_bbox_v1_3_0(extent) { extent.getWest() +
return ( "," +
extent.getSouth() + extent.getNorth() +
"," + "," +
extent.getWest() + extent.getEast()
"," + );
extent.getNorth() + }
"," +
extent.getEast() _checkSegment(segment) {
); return true;
} }
_checkSegment(segment) { get instanceName() {
return true; return "WMS";
} }
get instanceName() { _createUrl(segment) {
return "WMS"; return WMS.createRequestUrl(
} this.url,
this.layers,
_createUrl(segment) { "image/png",
return WMS.createRequestUrl( this._version,
this.url, "GetMap",
this.layers, segment._projection.code,
"image/png", this._getBbox(segment.getExtent()),
this._version, this.imageWidth,
"GetMap", this.imageHeight,
segment._projection.code, this._extra
this._getBbox(segment.getExtent()), );
this.imageWidth, }
this.imageHeight,
this._extra setVersion(version) {
); if (version) {
} this._version = version;
} else {
setVersion(version) { this._version = "1.1.1";
if (version) { }
this._version = version;
} else { if (this._version === "1.1.1") {
this._version = "1.1.1"; this._getBbox = WMS.get_bbox_v1_1_1;
} } else if (version === "1.3.0") {
this._getBbox = WMS.get_bbox_v1_3_0;
if (this._version === "1.1.1") { }
this._getBbox = WMS.get_bbox_v1_1_1; }
} else if (version === "1.3.0") {
this._getBbox = WMS.get_bbox_v1_3_0; _correctFullExtent() {
} var e = this._extent,
} em = this._extentMerc;
var ENLARGE_MERCATOR_LON = mercator.POLE + 50000;
_correctFullExtent() { var ENLARGE_MERCATOR_LAT = mercator.POLE + 50000;
var e = this._extent, if (e.northEast.lat === 90.0) {
em = this._extentMerc; em.northEast.lat = ENLARGE_MERCATOR_LAT;
var ENLARGE_MERCATOR_LON = mercator.POLE + 50000; }
var ENLARGE_MERCATOR_LAT = mercator.POLE + 50000; if (e.northEast.lon === 180.0) {
if (e.northEast.lat === 90.0) { em.northEast.lon = ENLARGE_MERCATOR_LON;
em.northEast.lat = ENLARGE_MERCATOR_LAT; }
} if (e.southWest.lat === -90.0) {
if (e.northEast.lon === 180.0) { em.southWest.lat = -ENLARGE_MERCATOR_LAT;
em.northEast.lon = ENLARGE_MERCATOR_LON; }
} if (e.southWest.lon === -180.0) {
if (e.southWest.lat === -90.0) { em.southWest.lon = -ENLARGE_MERCATOR_LON;
em.southWest.lat = -ENLARGE_MERCATOR_LAT; }
} }
if (e.southWest.lon === -180.0) { }
em.southWest.lon = -ENLARGE_MERCATOR_LON;
} export { WMS };
}
}
export { WMS };

View File

@ -1,7 +1,3 @@
/**
* @module og/layer/XYZ
*/
"use strict"; "use strict";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/light/LightSource
*/
"use strict"; "use strict";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3.js";

View File

@ -1,6 +1,7 @@
/** /**
* @module og/math * @module og/math
*/ */
"use strict"; "use strict";
/** @const */ /** @const */

View File

@ -1,32 +1,28 @@
/** 'use strict';
* @module og/math/Line2
*/ import { Vec2 } from './Vec2.js';
'use strict'; export class Line2 {
constructor(a = 0, b = 0, c = 0) {
import { Vec2 } from './Vec2.js'; this.a = a;
this.b = b;
export class Line2 { this.c = c;
constructor(a = 0, b = 0, c = 0) { }
this.a = a;
this.b = b; static get(p0, p1) {
this.c = c; return new Line2(p1.y - p0.y, p0.x - p1.x, p1.x * p0.y - p0.x * p1.y);
} }
static get(p0, p1) { static getParallel(l, p) {
return new Line2(p1.y - p0.y, p0.x - p1.x, p1.x * p0.y - p0.x * p1.y); return new Line2(l.a, l.b, -l.a * p.x - l.b * p.y);
} }
static getParallel(l, p) { static getIntersection(L0, L1) {
return new Line2(l.a, l.b, -l.a * p.x - l.b * p.y); 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);
}
static getIntersection(L0, L1) {
var x = (L1.b * L0.c - L0.b * L1.c) / (L0.b * L1.a - L1.b * L0.a); intersects(l) {
return new Vec2(x, -(L0.c + L0.a * x) / L0.b); return Line2.getIntersection(this, l);
} }
}
intersects(l) {
return Line2.getIntersection(this, l);
}
}

View File

@ -1,156 +1,152 @@
/** "use strict";
* @module og/math/Mat3
*/ import { Mat4 } from "./Mat4.js";
import { Vec3 } from "./Vec3.js";
"use strict";
/**
import { Mat4 } from "./Mat4.js"; * Class represents a 3x3 matrix.
import { Vec3 } from "./Vec3.js"; * @class
*/
/** export class Mat3 {
* Class represents a 3x3 matrix. constructor() {
* @class /**
*/ * A 3x3 matrix, indexable as a column-major order array.
export class Mat3 { * @public
constructor() { * @type {Array.<number>}
/** */
* A 3x3 matrix, indexable as a column-major order array. this._m = new Array(9);
* @public }
* @type {Array.<number>}
*/ /**
this._m = new Array(9); * Sets column-major order array matrix.
} * @public
* @param {Array.<number>} m - Matrix array.
/** * @returns {Mat3}
* Sets column-major order array matrix. */
* @public set(m) {
* @param {Array.<number>} m - Matrix array. this._m[0] = m[0];
* @returns {Mat3} this._m[1] = m[1];
*/ this._m[2] = m[2];
set(m) { this._m[3] = m[3];
this._m[0] = m[0]; this._m[4] = m[4];
this._m[1] = m[1]; this._m[5] = m[5];
this._m[2] = m[2]; this._m[6] = m[6];
this._m[3] = m[3]; this._m[7] = m[7];
this._m[4] = m[4]; this._m[8] = m[8];
this._m[5] = m[5]; return this;
this._m[6] = m[6]; }
this._m[7] = m[7];
this._m[8] = m[8]; /**
return this; * Duplicates a Mat3 instance.
} * @public
* @returns {Mat3}
/** */
* Duplicates a Mat3 instance. clone() {
* @public var res = new Mat3();
* @returns {Mat3} res.set(this);
*/ return res;
clone() { }
var res = new Mat3();
res.set(this); /**
return res; * Copy matrix.
} * @public
* @param {Mat3} a - Matrix to copy.
/** * @returns {Mat3}
* Copy matrix. */
* @public copy(a) {
* @param {Mat3} a - Matrix to copy. return this.set(a._m);
* @returns {Mat3} }
*/
copy(a) { /**
return this.set(a._m); * Creates trasposed matrix from the current.
} * @public
* @returns {Mat3}
/** */
* Creates trasposed matrix from the current. transposeTo() {
* @public var res = new Mat3();
* @returns {Mat3} var m = this._m;
*/ res._m[0] = m[0];
transposeTo() { res._m[1] = m[3];
var res = new Mat3(); res._m[2] = m[6];
var m = this._m; res._m[3] = m[1];
res._m[0] = m[0]; res._m[4] = m[4];
res._m[1] = m[3]; res._m[5] = m[7];
res._m[2] = m[6]; res._m[6] = m[2];
res._m[3] = m[1]; res._m[7] = m[5];
res._m[4] = m[4]; res._m[8] = m[8];
res._m[5] = m[7]; return res;
res._m[6] = m[2]; }
res._m[7] = m[5];
res._m[8] = m[8]; /**
return res; * Sets matrix to identity.
} * @public
* @returns {Mat3}
/** */
* Sets matrix to identity. setIdentity() {
* @public this._m[0] = 1;
* @returns {Mat3} this._m[1] = 0;
*/ this._m[2] = 0;
setIdentity() { this._m[3] = 0;
this._m[0] = 1; this._m[4] = 1;
this._m[1] = 0; this._m[5] = 0;
this._m[2] = 0; this._m[6] = 0;
this._m[3] = 0; this._m[7] = 0;
this._m[4] = 1; this._m[8] = 1;
this._m[5] = 0; return this;
this._m[6] = 0; }
this._m[7] = 0;
this._m[8] = 1; /**
return this; * Multiply to 3d vector.
} * @public
* @params {Vec3} p - 3d vector.
/** * @returns {Vec3}
* Multiply to 3d vector. */
* @public mulVec(p) {
* @params {Vec3} p - 3d vector. var d = p.x,
* @returns {Vec3} e = p.y,
*/ g = p.z;
mulVec(p) { var m = this._m;
var d = p.x, return new Vec3(
e = p.y, m[0] * d + m[3] * e + m[6] * g,
g = p.z; m[1] * d + m[4] * e + m[7] * g,
var m = this._m; m[2] * d + m[5] * e + m[8] * g
return new Vec3( );
m[0] * d + m[3] * e + m[6] * g, }
m[1] * d + m[4] * e + m[7] * g,
m[2] * d + m[5] * e + m[8] * g /**
); * Converts to 4x4 matrix.
} * @public
* @returns {Mat4}
/** */
* Converts to 4x4 matrix. toMatrix4() {
* @public var res = new Mat4();
* @returns {Mat4} var b = res._m;
*/ var a = this._m;
toMatrix4() { b[0] = a[0];
var res = new Mat4(); b[1] = a[1];
var b = res._m; b[2] = a[2];
var a = this._m; b[3] = 0;
b[0] = a[0]; b[4] = a[3];
b[1] = a[1]; b[5] = a[4];
b[2] = a[2]; b[6] = a[5];
b[3] = 0; b[7] = 0;
b[4] = a[3]; b[8] = a[6];
b[5] = a[4]; b[9] = a[7];
b[6] = a[5]; b[10] = a[8];
b[7] = 0; b[11] = 0;
b[8] = a[6]; b[12] = 0;
b[9] = a[7]; b[13] = 0;
b[10] = a[8]; b[14] = 0;
b[11] = 0; b[15] = 1;
b[12] = 0; return res;
b[13] = 0; }
b[14] = 0; }
b[15] = 1;
return res; /**
} * Mat3 factory.
} * @static
* @return {Mat3}
/** */
* Mat3 factory. export function mat3() {
* @static return new Mat3();
* @return {Mat3} }
*/
export function mat3() {
return new Mat3();
}

View File

@ -1,7 +1,3 @@
/**
* @module og/math/Ray
*/
"use strict"; "use strict";
import { EPS10 } from "../math.js"; import { EPS10 } from "../math.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/math/Vec2
*/
"use strict"; "use strict";
import { Vec3 } from "./Vec3.js"; import { Vec3 } from "./Vec3.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/math/Vec3
*/
"use strict"; "use strict";
import { Quat } from "./Quat.js"; import { Quat } from "./Quat.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/math/Vec4
*/
"use strict"; "use strict";
import { frac } from "../math.js"; import { frac } from "../math.js";

View File

@ -1,104 +1,104 @@
/** /**
* @module og/math/coder * @module og/math/coder
*/ */
"use strict"; "use strict";
import * as math from "../math.js"; import * as math from "../math.js";
import { Vec4 } from "./Vec4.js"; 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 {number} v - 32 bit float value. * @param {number} v - 32 bit float value.
* @returns {math.Vec4} - RGBA vector value. * @returns {math.Vec4} - RGBA vector value.
*/ */
export function encodeFloatToRGBA(v) { 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 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); var yzww = new Vec4(enc.y / 255, enc.z / 255, enc.w / 255, 0);
return enc.subA(yzww); return enc.subA(yzww);
} }
/** /**
* Decode RGBA vector to 32 bit float value. * Decode RGBA vector to 32 bit float value.
* @function * @function
* @param {Vec4} rgba - RGBA encoded 32 bit float value. * @param {Vec4} rgba - RGBA encoded 32 bit float value.
* @returns {number} - Float value. * @returns {number} - Float value.
*/ */
export function decodeFloatFromRGBA(rgba) { export function decodeFloatFromRGBA(rgba) {
var s = 1.0 - math.step(128.0, rgba.x) * 2.0; var s = 1.0 - math.step(128.0, rgba.x) * 2.0;
var e = 2.0 * math.mod(rgba.x, 128.0) + math.step(128.0, rgba.y) - 127.0; 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.0; var m = math.mod(rgba.y, 128.0) * 65536.0 + rgba.z * 256.0 + rgba.w + 8388608.0;
return s * math.exp2(e) * (m * 1.1920928955078125e-7); return s * math.exp2(e) * (m * 1.1920928955078125e-7);
} }
/** /**
* Decode RGBA vector to 32 bit float value. * Decode RGBA vector to 32 bit float value.
* @function * @function
* @param {Vec4} rgba - RGBA encoded 32 bit float value. * @param {Vec4} rgba - RGBA encoded 32 bit float value.
* @returns {number} - Float value. * @returns {number} - Float value.
*/ */
export function decodeFloatFromRGBAArr(arr, use32) { export function decodeFloatFromRGBAArr(arr, use32) {
var s = 1.0 - math.step(128.0, arr[0]) * 2.0; var s = 1.0 - math.step(128.0, arr[0]) * 2.0;
var e = 2.0 * math.mod(arr[0], 128.0) + math.step(128.0, arr[1]) - 127.0; 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.0; var m = math.mod(arr[1], 128.0) * 65536.0 + arr[2] * 256.0 + (use32 ? arr[3] : 0.0) + 8388608.0;
return s * math.exp2(e) * (m * 1.1920928955078125e-7); return s * math.exp2(e) * (m * 1.1920928955078125e-7);
} }
/** /**
* Separate 64 bit value to two 32 bit float values. * Separate 64 bit value to two 32 bit float values.
* @function * @function
* @param {number} value - Double type value. * @param {number} value - Double type value.
* @returns {Array.<number>} Encoded array. (exactly 2 entries) * @returns {Array.<number>} Encoded array. (exactly 2 entries)
*/ */
export function doubleToTwoFloats(value) { export function doubleToTwoFloats(value) {
var high, low; var high, low;
if (value >= 0.0) { if (value >= 0.0) {
let doubleHigh = Math.floor(value / 65536.0) * 65536.0; let doubleHigh = Math.floor(value / 65536.0) * 65536.0;
high = Math.fround(doubleHigh); high = Math.fround(doubleHigh);
low = Math.fround(value - doubleHigh); low = Math.fround(value - doubleHigh);
} else { } else {
let doubleHigh = Math.floor(-value / 65536.0) * 65536.0; let doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
high = Math.fround(-doubleHigh); high = Math.fround(-doubleHigh);
low = Math.fround(value + doubleHigh); low = Math.fround(value + doubleHigh);
} }
return new Float32Array([high, low]); return new Float32Array([high, low]);
} }
/** /**
* Separate 64 bit value to two 32 bit float values. * Separate 64 bit value to two 32 bit float values.
* @function * @function
* @param {number} value - Double type value. * @param {number} value - Double type value.
* @returns {Array.<number>} Encoded array. (exactly 2 entries) * @returns {Array.<number>} Encoded array. (exactly 2 entries)
*/ */
export function doubleToTwoFloats2(value, highLowArr) { export function doubleToTwoFloats2(value, highLowArr) {
if (value >= 0.0) { if (value >= 0.0) {
let doubleHigh = Math.floor(value / 65536.0) * 65536.0; let doubleHigh = Math.floor(value / 65536.0) * 65536.0;
highLowArr[0] = Math.fround(doubleHigh); highLowArr[0] = Math.fround(doubleHigh);
highLowArr[1] = Math.fround(value - doubleHigh); highLowArr[1] = Math.fround(value - doubleHigh);
} else { } else {
let doubleHigh = Math.floor(-value / 65536.0) * 65536.0; let doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
highLowArr[0] = Math.fround(-doubleHigh); highLowArr[0] = Math.fround(-doubleHigh);
highLowArr[1] = Math.fround(value + doubleHigh); highLowArr[1] = Math.fround(value + doubleHigh);
} }
return highLowArr; return highLowArr;
} }
/** /**
* Separate 64 bit value to two 32 bit float values. * Separate 64 bit value to two 32 bit float values.
* @function * @function
* @param {number} value - Double type value. * @param {number} value - Double type value.
* @returns {Array.<number>} Encoded array. (exactly 2 entries) * @returns {Array.<number>} Encoded array. (exactly 2 entries)
*/ */
export function doubleToTwoFloatsV2(value, highLowVec) { export function doubleToTwoFloatsV2(value, highLowVec) {
if (value >= 0.0) { if (value >= 0.0) {
let doubleHigh = Math.floor(value / 65536.0) * 65536.0; let doubleHigh = Math.floor(value / 65536.0) * 65536.0;
highLowVec.x = Math.fround(doubleHigh); highLowVec.x = Math.fround(doubleHigh);
highLowVec.y = Math.fround(value - doubleHigh); highLowVec.y = Math.fround(value - doubleHigh);
} else { } else {
let doubleHigh = Math.floor(-value / 65536.0) * 65536.0; let doubleHigh = Math.floor(-value / 65536.0) * 65536.0;
highLowVec.x = Math.fround(-doubleHigh); highLowVec.x = Math.fround(-doubleHigh);
highLowVec.y = Math.fround(value + doubleHigh); highLowVec.y = Math.fround(value + doubleHigh);
} }
return highLowVec; return highLowVec;
} }

View File

@ -1,13 +1,13 @@
/** /**
* @module og/proj/EPSG3857 * @module og/proj/EPSG3857
*/ */
"use strict"; "use strict";
import { Proj, Units } from "./Proj.js"; import { Proj, Units } from "./Proj.js";
/** /**
* EPSG:3857 projection object. * EPSG:3857 projection object.
* @type {Proj} * @type {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

@ -1,63 +1,59 @@
/** "use strict";
* @module og/proj/Proj
*/ /**
* Projection units: 'degrees', 'ft', 'm' or 'km'.
"use strict"; * @enum {string}
* @api
/** */
* Projection units: 'degrees', 'ft', 'm' or 'km'. export const Units = {
* @enum {string} DEGREES: "degrees",
* @api FEET: "ft",
*/ METERS: "m",
export const Units = { KILOMETERS: "km"
DEGREES: "degrees", };
FEET: "ft",
METERS: "m", /**
KILOMETERS: "km" * Meters per unit lookup table.
}; * @const
* @type {Object.<og.proj.Units, number>}
/** */
* Meters per unit lookup table. export const METERS_PER_UNIT = {};
* @const METERS_PER_UNIT[Units.FEET] = 0.3048;
* @type {Object.<og.proj.Units, number>} METERS_PER_UNIT[Units.METERS] = 1;
*/ METERS_PER_UNIT[Units.KILOMETERS] = 1000;
export const METERS_PER_UNIT = {};
METERS_PER_UNIT[Units.FEET] = 0.3048; let _counter = 0;
METERS_PER_UNIT[Units.METERS] = 1; class Proj {
METERS_PER_UNIT[Units.KILOMETERS] = 1000; constructor(options) {
/**
let _counter = 0; * @public
class Proj { * @type {string}
constructor(options) { */
/** this.code = options.code;
* @public
* @type {string} /**
*/ * @public
this.code = options.code; * @type {proj.Units}
*/
/** this.units = /** @type {Units} */ (options.units);
* @public
* @type {proj.Units} /**
*/ * Projection identifier, especially usefull for comparison.
this.units = /** @type {Units} */ (options.units); * @const
* @type {integer}
/** */
* Projection identifier, especially usefull for comparison. this.id = _counter++;
* @const }
* @type {integer}
*/ /**
this.id = _counter++; * Compare projections.
} * @public
* @param {Proj} proj - Projetion object.
/** * @returns {boolean}
* Compare projections. */
* @public equal(proj) {
* @param {Proj} proj - Projetion object. return proj.id === this.id;
* @returns {boolean} }
*/ }
equal(proj) {
return proj.id === this.id; export { Proj };
}
}
export { Proj };

View File

@ -1,4 +1,5 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent.js";
import { EPSG4326 } from "../proj/EPSG4326.js"; import { EPSG4326 } from "../proj/EPSG4326.js";
import { Node } from "../quadTree/Node.js"; import { Node } from "../quadTree/Node.js";

View File

@ -1,4 +1,5 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent.js";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator.js";
import { Node } from "../quadTree/Node.js"; import { Node } from "../quadTree/Node.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/quadTree/EntityCollectionNode
*/
'use strict'; 'use strict';
import { Sphere } from '../bv/Sphere.js'; import { Sphere } from '../bv/Sphere.js';

View File

@ -1,4 +1,5 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent.js";
import { EPSG4326 } from "../proj/EPSG4326.js"; import { EPSG4326 } from "../proj/EPSG4326.js";
import { Node } from "../quadTree/Node.js"; import { Node } from "../quadTree/Node.js";

View File

@ -1,4 +1,5 @@
"use strict"; "use strict";
import { EPSG3857 } from "../proj/EPSG3857.js"; import { EPSG3857 } from "../proj/EPSG3857.js";
export class QuadTreeStrategy { export class QuadTreeStrategy {

View File

@ -1,4 +1,5 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent.js";
import { EPSG4326 } from "../proj/EPSG4326.js"; import { EPSG4326 } from "../proj/EPSG4326.js";
import { Node } from "../quadTree/Node.js"; import { Node } from "../quadTree/Node.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/renderer/RendererEvents
*/
"use strict"; "use strict";
import { Events } from "../Events.js"; import { Events } from "../Events.js";

View File

@ -1,78 +1,74 @@
/** 'use strict';
* @module og/scene/Axes
*/ import { Program } from '../webgl/Program.js';
import { RenderNode } from './RenderNode.js';
'use strict';
class Axes extends RenderNode {
import { Program } from '../webgl/Program.js'; constructor(size) {
import { RenderNode } from './RenderNode.js'; super("Axes");
class Axes extends RenderNode { this.size = size || 100;
constructor(size) { this.axesBuffer = null;
super("Axes"); this.axesColorBuffer = null;
}
this.size = size || 100;
this.axesBuffer = null; init() {
this.axesColorBuffer = null; this.createAxisBuffer(this.size);
} this.drawMode = this.renderer.handler.gl.LINES;
this.renderer.handler.addProgram(new Program("axesShader", {
init() { uniforms: {
this.createAxisBuffer(this.size); projectionViewMatrix: 'mat4'
this.drawMode = this.renderer.handler.gl.LINES; },
this.renderer.handler.addProgram(new Program("axesShader", { attributes: {
uniforms: { aVertexPosition: 'vec3',
projectionViewMatrix: 'mat4' aVertexColor: 'vec4'
}, },
attributes: { vertexShader:
aVertexPosition: 'vec3', `attribute vec3 aVertexPosition;
aVertexColor: 'vec4' attribute vec4 aVertexColor;
}, uniform mat4 projectionViewMatrix;
vertexShader: varying vec4 vColor;
`attribute vec3 aVertexPosition; void main(void) {
attribute vec4 aVertexColor; gl_Position = projectionViewMatrix * vec4(aVertexPosition, 1.0);
uniform mat4 projectionViewMatrix; vColor = aVertexColor;
varying vec4 vColor; }`,
void main(void) { fragmentShader:
gl_Position = projectionViewMatrix * vec4(aVertexPosition, 1.0); `precision highp float;
vColor = aVertexColor; varying vec4 vColor;
}`, void main(void) {
fragmentShader: gl_FragColor = vColor;
`precision highp float; }`
varying vec4 vColor; }));
void main(void) { }
gl_FragColor = vColor;
}` frame() {
}));
} this.renderer.handler.programs.axesShader.activate().set({
projectionViewMatrix: this.renderer.activeCamera.getProjectionViewMatrix(),
frame() { aVertexPosition: this.axisBuffer,
aVertexColor: this.axisColorBuffer
this.renderer.handler.programs.axesShader.activate().set({ });
projectionViewMatrix: this.renderer.activeCamera.getProjectionViewMatrix(),
aVertexPosition: this.axisBuffer, this.renderer.handler.programs.axesShader.drawArrays(this.drawMode, this.axisBuffer.numItems);
aVertexColor: this.axisColorBuffer }
});
createAxisBuffer(gridSize) {
this.renderer.handler.programs.axesShader.drawArrays(this.drawMode, this.axisBuffer.numItems);
} var vertices = [
0.0, 0.0, 0.0, gridSize - 1, 0.0, 0.0, // x - R
createAxisBuffer(gridSize) { 0.0, 0.0, 0.0, 0.0, gridSize - 1, 0.0, // y - B
0.0, 0.0, 0.0, 0.0, 0.0, gridSize - 1 // z - G
var vertices = [ ];
0.0, 0.0, 0.0, gridSize - 1, 0.0, 0.0, // x - R
0.0, 0.0, 0.0, 0.0, gridSize - 1, 0.0, // y - B var colors = [
0.0, 0.0, 0.0, 0.0, 0.0, gridSize - 1 // z - G 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, // x - R
]; 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, // y - B
0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 // z - G
var colors = [ ];
1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, // x - R
0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, // y - B this.axisBuffer = this.renderer.handler.createArrayBuffer(new Float32Array(vertices), 3, 6);
0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 // z - G this.axisColorBuffer = this.renderer.handler.createArrayBuffer(new Float32Array(colors), 4, 6);
]; }
}
this.axisBuffer = this.renderer.handler.createArrayBuffer(new Float32Array(vertices), 3, 6);
this.axisColorBuffer = this.renderer.handler.createArrayBuffer(new Float32Array(colors), 4, 6); export { Axes };
}
}
export { Axes };

View File

@ -1,7 +1,3 @@
/**
* @module og/scene/BaseNode
*/
"use strict"; "use strict";
/** /**

View File

@ -1,7 +1,3 @@
/**
* @module og/scene/Planet
*/
"use strict"; "use strict";
import { PlanetCamera } from "../camera/PlanetCamera.js"; import { PlanetCamera } from "../camera/PlanetCamera.js";

View File

@ -1,108 +1,104 @@
/** 'use strict';
* @module og/scene/SkyBox
*/ import * as shaders from '../shaders/skybox.js';
import { RenderNode } from './RenderNode.js';
'use strict';
class SkyBox extends RenderNode {
import * as shaders from '../shaders/skybox.js'; constructor(params) {
import { RenderNode } from './RenderNode.js'; super("skybox");
this.params = params;
class SkyBox extends RenderNode { this.vertexPositionBuffer = null;
constructor(params) { this.texture = null;
super("skybox"); }
this.params = params;
this.vertexPositionBuffer = null; static createDefault(RESOURCES_URL) {
this.texture = null; return new SkyBox({
} nx: RESOURCES_URL + "skybox/gal/_nx.jpg",
px: RESOURCES_URL + "skybox/gal/_px.jpg",
static createDefault(RESOURCES_URL) { py: RESOURCES_URL + "skybox/gal/_py.jpg",
return new SkyBox({ ny: RESOURCES_URL + "skybox/gal/_ny.jpg",
nx: RESOURCES_URL + "skybox/gal/_nx.jpg", pz: RESOURCES_URL + "skybox/gal/_pz.jpg",
px: RESOURCES_URL + "skybox/gal/_px.jpg", nz: RESOURCES_URL + "skybox/gal/_nz.jpg"
py: RESOURCES_URL + "skybox/gal/_py.jpg", });
ny: RESOURCES_URL + "skybox/gal/_ny.jpg", }
pz: RESOURCES_URL + "skybox/gal/_pz.jpg",
nz: RESOURCES_URL + "skybox/gal/_nz.jpg" init() {
}); this.renderer.handler.addProgram(shaders.skybox(), true);
} this.texture = this.renderer.handler.loadCubeMapTexture(this.params);
this._createBuffers();
init() { this.drawMode = this.renderer.handler.gl.TRIANGLES;
this.renderer.handler.addProgram(shaders.skybox(), true); }
this.texture = this.renderer.handler.loadCubeMapTexture(this.params);
this._createBuffers(); frame() {
this.drawMode = this.renderer.handler.gl.TRIANGLES; var h = this.renderer.handler;
} var gl = h.gl;
var cam = this.renderer.activeCamera;
frame() { gl.disable(h.gl.DEPTH_TEST);
var h = this.renderer.handler;
var gl = h.gl; h.programs.skybox.activate();
var cam = this.renderer.activeCamera; var sh = h.programs.skybox._program;
gl.disable(h.gl.DEPTH_TEST); var shu = sh.uniforms;
gl.uniformMatrix4fv(shu.projectionViewMatrix, false, cam.getProjectionViewMatrix());
h.programs.skybox.activate(); gl.uniform3fv(shu.pos, cam.eye.toVec());
var sh = h.programs.skybox._program; gl.activeTexture(gl.TEXTURE0);
var shu = sh.uniforms; gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.texture);
gl.uniformMatrix4fv(shu.projectionViewMatrix, false, cam.getProjectionViewMatrix()); gl.uniform1i(shu.uSampler, 0);
gl.uniform3fv(shu.pos, cam.eye.toVec()); var buf = this.vertexPositionBuffer;
gl.activeTexture(gl.TEXTURE0); gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.texture); gl.vertexAttribPointer(sh.attributes.aVertexPosition, buf.itemSize, gl.FLOAT, false, 0, 0);
gl.uniform1i(shu.uSampler, 0);
var buf = this.vertexPositionBuffer; gl.drawArrays(this.drawMode, 0, buf.numItems);
gl.bindBuffer(gl.ARRAY_BUFFER, buf); h.gl.enable(h.gl.DEPTH_TEST);
gl.vertexAttribPointer(sh.attributes.aVertexPosition, buf.itemSize, gl.FLOAT, false, 0, 0); }
gl.drawArrays(this.drawMode, 0, buf.numItems); _createBuffers() {
h.gl.enable(h.gl.DEPTH_TEST);
} var vertices = new Float32Array([
-100000000.0, 100000000.0, -100000000.0,
_createBuffers() { -100000000.0, -100000000.0, -100000000.0,
100000000.0, -100000000.0, -100000000.0,
var vertices = new Float32Array([ 100000000.0, -100000000.0, -100000000.0,
-100000000.0, 100000000.0, -100000000.0, 100000000.0, 100000000.0, -100000000.0,
-100000000.0, -100000000.0, -100000000.0, -100000000.0, 100000000.0, -100000000.0,
100000000.0, -100000000.0, -100000000.0,
100000000.0, -100000000.0, -100000000.0, -100000000.0, -100000000.0, 100000000.0,
100000000.0, 100000000.0, -100000000.0, -100000000.0, -100000000.0, -100000000.0,
-100000000.0, 100000000.0, -100000000.0, -100000000.0, 100000000.0, -100000000.0,
-100000000.0, 100000000.0, -100000000.0,
-100000000.0, -100000000.0, 100000000.0, -100000000.0, 100000000.0, 100000000.0,
-100000000.0, -100000000.0, -100000000.0, -100000000.0, -100000000.0, 100000000.0,
-100000000.0, 100000000.0, -100000000.0,
-100000000.0, 100000000.0, -100000000.0, 100000000.0, -100000000.0, -100000000.0,
-100000000.0, 100000000.0, 100000000.0, 100000000.0, -100000000.0, 100000000.0,
-100000000.0, -100000000.0, 100000000.0, 100000000.0, 100000000.0, 100000000.0,
100000000.0, 100000000.0, 100000000.0,
100000000.0, -100000000.0, -100000000.0, 100000000.0, 100000000.0, -100000000.0,
100000000.0, -100000000.0, 100000000.0, 100000000.0, -100000000.0, -100000000.0,
100000000.0, 100000000.0, 100000000.0,
100000000.0, 100000000.0, 100000000.0, -100000000.0, -100000000.0, 100000000.0,
100000000.0, 100000000.0, -100000000.0, -100000000.0, 100000000.0, 100000000.0,
100000000.0, -100000000.0, -100000000.0, 100000000.0, 100000000.0, 100000000.0,
100000000.0, 100000000.0, 100000000.0,
-100000000.0, -100000000.0, 100000000.0, 100000000.0, -100000000.0, 100000000.0,
-100000000.0, 100000000.0, 100000000.0, -100000000.0, -100000000.0, 100000000.0,
100000000.0, 100000000.0, 100000000.0,
100000000.0, 100000000.0, 100000000.0, -100000000.0, 100000000.0, -100000000.0,
100000000.0, -100000000.0, 100000000.0, 100000000.0, 100000000.0, -100000000.0,
-100000000.0, -100000000.0, 100000000.0, 100000000.0, 100000000.0, 100000000.0,
100000000.0, 100000000.0, 100000000.0,
-100000000.0, 100000000.0, -100000000.0, -100000000.0, 100000000.0, 100000000.0,
100000000.0, 100000000.0, -100000000.0, -100000000.0, 100000000.0, -100000000.0,
100000000.0, 100000000.0, 100000000.0,
100000000.0, 100000000.0, 100000000.0, -100000000.0, -100000000.0, -100000000.0,
-100000000.0, 100000000.0, 100000000.0, -100000000.0, -100000000.0, 100000000.0,
-100000000.0, 100000000.0, -100000000.0, 100000000.0, -100000000.0, -100000000.0,
100000000.0, -100000000.0, -100000000.0,
-100000000.0, -100000000.0, -100000000.0, -100000000.0, -100000000.0, 100000000.0,
-100000000.0, -100000000.0, 100000000.0, 100000000.0, -100000000.0, 100000000.0
100000000.0, -100000000.0, -100000000.0, ]);
100000000.0, -100000000.0, -100000000.0,
-100000000.0, -100000000.0, 100000000.0, this.vertexPositionBuffer = this.renderer.handler.createArrayBuffer(vertices, 3, vertices.length / 3);
100000000.0, -100000000.0, 100000000.0 }
]); }
this.vertexPositionBuffer = this.renderer.handler.createArrayBuffer(vertices, 3, vertices.length / 3); export { SkyBox };
}
}
export { SkyBox };

View File

@ -1,226 +1,230 @@
'use strict'; /**
* @module og/segment/SegmentHelper
import { N, W, S, E } from '../quadTree/quadTree.js'; */
function NewIndexesTypedArray(arr) { 'use strict';
return new Uint32Array(arr);
} import { N, W, S, E } from '../quadTree/quadTree.js';
function createCenterBodyIndexes(size) { function NewIndexesTypedArray(arr) {
return new Uint32Array(arr);
let indexes = []; }
var i0 = 1, function createCenterBodyIndexes(size) {
j0 = 1;
let indexes = [];
var i1 = 1,
j1 = 1; var i0 = 1,
j0 = 1;
var ind1, ind2, nr;
for (var i = i0; i < size - 1 - i1; i++) { var i1 = 1,
for (var j = j0; j < size - j1; j++) { j1 = 1;
ind1 = i * size + j;
nr = (i + 1) * size; var ind1, ind2, nr;
ind2 = nr + j; for (var i = i0; i < size - 1 - i1; i++) {
indexes.push(ind1, ind2); for (var j = j0; j < size - j1; j++) {
} ind1 = i * size + j;
indexes.push(ind2, nr + j0); nr = (i + 1) * size;
} ind2 = nr + j;
indexes.push(indexes[indexes.length - 1], size * size - size); indexes.push(ind1, ind2);
}
return NewIndexesTypedArray(indexes); indexes.push(ind2, nr + j0);
} }
indexes.push(indexes[indexes.length - 1], size * size - size);
function createWestNeighborSkirt(size, deltaGr) {
let indexes = []; return NewIndexesTypedArray(indexes);
var grCount = (size - 1) / deltaGr; }
var b = size * size - size;
var k = 0; function createWestNeighborSkirt(size, deltaGr) {
for (var i = 0; i < size - 2; i++) { let indexes = [];
if (i % grCount === 0) { var grCount = (size - 1) / deltaGr;
k = i; var b = size * size - size;
} var k = 0;
var rind = b - size * i - size + 1, for (var i = 0; i < size - 2; i++) {
lind = b - size * k; if (i % grCount === 0) {
indexes.push(lind, rind); k = i;
} }
var rind = b - size * i - size + 1,
if (deltaGr === (size - 1)) { lind = b - size * k;
indexes.push(size); indexes.push(lind, rind);
indexes.push(0); }
}
if (deltaGr === (size - 1)) {
return NewIndexesTypedArray(indexes); indexes.push(size);
} indexes.push(0);
}
function createNorthNeighborSkirt(size, deltaGr) {
let indexes = []; return NewIndexesTypedArray(indexes);
var grCount = (size - 1) / deltaGr; }
var k = 0;
for (var i = 0; i < size - 2; i++) { function createNorthNeighborSkirt(size, deltaGr) {
if (i % grCount === 0) { let indexes = [];
k = i; var grCount = (size - 1) / deltaGr;
} var k = 0;
var rind = size + i + 1, for (var i = 0; i < size - 2; i++) {
lind = k; if (i % grCount === 0) {
indexes.push(lind, rind); k = i;
} }
var rind = size + i + 1,
if (deltaGr === (size - 1)) { lind = k;
indexes.push(size - 2); indexes.push(lind, rind);
indexes.push(size - 1); }
}
if (deltaGr === (size - 1)) {
return NewIndexesTypedArray(indexes); indexes.push(size - 2);
} indexes.push(size - 1);
}
function createEastNeighborSkirt(size, deltaGr) {
let indexes = []; return NewIndexesTypedArray(indexes);
var grCount = (size - 1) / deltaGr; }
var k = 0;
for (var i = 0; i < size - 2; i++) { function createEastNeighborSkirt(size, deltaGr) {
if (i % grCount === 0) { let indexes = [];
k = i; var grCount = (size - 1) / deltaGr;
} var k = 0;
var rind = size * (i + 1) + size - 2, for (var i = 0; i < size - 2; i++) {
lind = size + size * k - 1; if (i % grCount === 0) {
indexes.push(lind, rind); k = i;
} }
var rind = size * (i + 1) + size - 2,
if (deltaGr === (size - 1)) { lind = size + size * k - 1;
indexes.push(size * (size - 1) - 1); indexes.push(lind, rind);
indexes.push(size * size - 1); }
}
if (deltaGr === (size - 1)) {
return NewIndexesTypedArray(indexes); indexes.push(size * (size - 1) - 1);
} indexes.push(size * size - 1);
}
function createSouthNeighborSkirt(size, deltaGr) {
let indexes = []; return NewIndexesTypedArray(indexes);
var grCount = (size - 1) / deltaGr; }
var k = 0;
var rb = size * (size - 1) - 2; function createSouthNeighborSkirt(size, deltaGr) {
var lb = size * size - 1; let indexes = [];
for (var i = 0; i < size - 2; i++) { var grCount = (size - 1) / deltaGr;
if (i % grCount === 0) { var k = 0;
k = i; var rb = size * (size - 1) - 2;
} var lb = size * size - 1;
var rind = rb - i, for (var i = 0; i < size - 2; i++) {
lind = lb - k; if (i % grCount === 0) {
indexes.push(lind, rind); k = i;
} }
var rind = rb - i,
if (deltaGr === (size - 1)) { lind = lb - k;
indexes.push(size * size - size + 1); indexes.push(lind, rind);
} }
indexes.push(size * size - size);
if (deltaGr === (size - 1)) {
return NewIndexesTypedArray(indexes); indexes.push(size * size - size + 1);
} }
indexes.push(size * size - size);
function initIndexesBodySkirts(pow) {
var table = []; return NewIndexesTypedArray(indexes);
}
table[N] = [];
table[W] = []; function initIndexesBodySkirts(pow) {
table[S] = []; var table = [];
table[E] = [];
table[N] = [];
for (var i = 0; i <= pow; i++) { table[W] = [];
var d = Math.pow(2, i), table[S] = [];
d1 = d + 1; table[E] = [];
table[N][i] = []; for (var i = 0; i <= pow; i++) {
table[W][i] = []; var d = Math.pow(2, i),
table[S][i] = []; d1 = d + 1;
table[E][i] = [];
table[N][i] = [];
for (var j = 0; j <= pow; j++) { table[W][i] = [];
var dd = Math.pow(2, j); table[S][i] = [];
table[W][i][j] = createWestNeighborSkirt(d1, dd); table[E][i] = [];
table[N][i][j] = createNorthNeighborSkirt(d1, dd);
table[E][i][j] = createEastNeighborSkirt(d1, dd); for (var j = 0; j <= pow; j++) {
table[S][i][j] = createSouthNeighborSkirt(d1, dd); var dd = Math.pow(2, j);
table[W][i][j] = createWestNeighborSkirt(d1, dd);
} table[N][i][j] = createNorthNeighborSkirt(d1, dd);
} table[E][i][j] = createEastNeighborSkirt(d1, dd);
return table; table[S][i][j] = createSouthNeighborSkirt(d1, dd);
}
}
function initIndexBodiesTable(pow) { }
var table = []; return table;
for (var i = 0; i <= pow; i++) { }
var d = Math.pow(2, i);
table[i] = createCenterBodyIndexes(d + 1); function initIndexBodiesTable(pow) {
} var table = [];
return table; for (var i = 0; i <= pow; i++) {
} var d = Math.pow(2, i);
table[i] = createCenterBodyIndexes(d + 1);
function createTextureCoords(size) { }
var texCoords = new Uint16Array((size + 1) * (size + 1) * 2); return table;
let k = 0; }
for (var i = 0; i <= size; i++) {
for (var j = 0; j <= size; j++) { function createTextureCoords(size) {
texCoords[k++] = j / size * 0xFFFF; var texCoords = new Uint16Array((size + 1) * (size + 1) * 2);
texCoords[k++] = i / size * 0xFFFF; let k = 0;
} for (var i = 0; i <= size; i++) {
} for (var j = 0; j <= size; j++) {
return texCoords; texCoords[k++] = j / size * 0xFFFF;
} texCoords[k++] = i / size * 0xFFFF;
}
class SegmentHelper { }
constructor(maxGridSize = 0) { return texCoords;
this._maxGridSize = maxGridSize; }
}
class SegmentHelper {
get maxGridSize() { constructor(maxGridSize = 0) {
return this._maxGridSize; this._maxGridSize = maxGridSize;
} }
init() { get maxGridSize() {
this.centerIndexesTable = initIndexBodiesTable(this._maxGridSize); return this._maxGridSize;
this.skirtsIndexesTable = initIndexesBodySkirts(this._maxGridSize); }
}
init() {
setMaxGridSize(gridSize) { this.centerIndexesTable = initIndexBodiesTable(this._maxGridSize);
this._maxGridSize = gridSize; this.skirtsIndexesTable = initIndexesBodySkirts(this._maxGridSize);
this.init(); }
}
setMaxGridSize(gridSize) {
createSegmentIndexes(size, sidesSizes) { this._maxGridSize = gridSize;
if (size) { this.init();
let c = this.centerIndexesTable[size], }
w = this.skirtsIndexesTable[W][size][sidesSizes[W]],
n = this.skirtsIndexesTable[N][size][sidesSizes[N]], createSegmentIndexes(size, sidesSizes) {
e = this.skirtsIndexesTable[E][size][sidesSizes[E]], if (size) {
s = this.skirtsIndexesTable[S][size][sidesSizes[S]]; let c = this.centerIndexesTable[size],
w = this.skirtsIndexesTable[W][size][sidesSizes[W]],
let indexes = NewIndexesTypedArray(c.length + w.length + n.length + e.length + s.length); n = this.skirtsIndexesTable[N][size][sidesSizes[N]],
e = this.skirtsIndexesTable[E][size][sidesSizes[E]],
indexes.set(c, 0); s = this.skirtsIndexesTable[S][size][sidesSizes[S]];
indexes.set(w, c.length);
indexes.set(n, c.length + w.length); let indexes = NewIndexesTypedArray(c.length + w.length + n.length + e.length + s.length);
indexes.set(e, c.length + w.length + n.length);
indexes.set(s, c.length + w.length + n.length + e.length); indexes.set(c, 0);
indexes.set(w, c.length);
return indexes; indexes.set(n, c.length + w.length);
} else { indexes.set(e, c.length + w.length + n.length);
return NewIndexesTypedArray([0, 2, 1, 3]); indexes.set(s, c.length + w.length + n.length + e.length);
}
} return indexes;
} else {
initTextureCoordsTable(pow) { return NewIndexesTypedArray([0, 2, 1, 3]);
var table = []; }
for (var i = 0; i <= pow; i++) { }
var d = Math.pow(2, i);
table[i] = createTextureCoords(d); initTextureCoordsTable(pow) {
} var table = [];
return table; for (var i = 0; i <= pow; i++) {
} var d = Math.pow(2, i);
} table[i] = createTextureCoords(d);
}
let instance = new SegmentHelper(); return table;
}
export function getInstance() { }
return instance;
let instance = new SegmentHelper();
export function getInstance() {
return instance;
} }

View File

@ -1,5 +1,5 @@
/** /**
* @module og/shaders/drawnode * @module og/shaders/geoObject
*/ */
"use strict"; "use strict";

View File

@ -1,7 +1,3 @@
/**
* @module og/terrainProvider/EmptyTerrain
*/
"use strict"; "use strict";
import { binarySearchFast } from "../utils/shared.js"; import { binarySearchFast } from "../utils/shared.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/utils/FontAtlas
*/
'use strict'; 'use strict';
import { Deferred } from '../Deferred.js'; import { Deferred } from '../Deferred.js';

View File

@ -1,7 +1,3 @@
/**
* @module og/utils/NormalMapCreator
*/
"use strict"; "use strict";
import { Lock } from "../Lock.js"; import { Lock } from "../Lock.js";

View File

@ -1,7 +1,3 @@
/**
* @module og/utils/VectorTileCreator
*/
'use strict'; 'use strict';
import { doubleToTwoFloats2 } from '../math/coder.js'; import { doubleToTwoFloats2 } from '../math/coder.js';

View File

@ -1,7 +1,3 @@
/**
* @module og/webgl/Framebuffer
*/
"use strict"; "use strict";
import { ImageCanvas } from "../ImageCanvas.js"; import { ImageCanvas } from "../ImageCanvas.js";

Some files were not shown because too many files have changed in this diff Show More