#698 fixed tests

This commit is contained in:
Zemledelec 2023-08-02 18:10:55 +04:00
parent ac9eff110d
commit c6b978b8cf
84 changed files with 348 additions and 260 deletions

View File

@ -5,5 +5,11 @@ module.exports = {
coverageProvider: "v8", coverageProvider: "v8",
setupFiles: ["jest-canvas-mock"], setupFiles: ["jest-canvas-mock"],
testEnvironment: "jsdom", testEnvironment: "jsdom",
setupFilesAfterEnv: ["./tests/setupTests.js"] setupFilesAfterEnv: ["./tests/setupTests.js"],
moduleFileExtensions: ["ts", "js"],
preset: 'ts-jest/presets/js-with-ts',
testRegex: [
"\\.test\\.js$",
"\\.test\\.ts$",
]
}; };

103
package-lock.json generated
View File

@ -15,7 +15,7 @@
"@babel/preset-env": "^7.21.5", "@babel/preset-env": "^7.21.5",
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-terser": "^0.4.1", "@rollup/plugin-terser": "^0.4.1",
"@types/jest": "^29.5.1", "@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.2.1", "@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1", "@typescript-eslint/parser": "^6.2.1",
"clean-jsdoc-theme": "^4.2.7", "clean-jsdoc-theme": "^4.2.7",
@ -30,6 +30,7 @@
"prettier": "^2.8.8", "prettier": "^2.8.8",
"rollup": "^3.21.3", "rollup": "^3.21.3",
"rollup-plugin-postcss": "^4.0.2", "rollup-plugin-postcss": "^4.0.2",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6" "typescript": "^5.1.6"
} }
}, },
@ -2880,9 +2881,9 @@
} }
}, },
"node_modules/@types/jest": { "node_modules/@types/jest": {
"version": "29.5.1", "version": "29.5.3",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.1.tgz", "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.3.tgz",
"integrity": "sha512-tEuVcHrpaixS36w7hpsfLBLpjtMRJUE09/MHXn923LOVojDwyC14cWcfc0rDs0VEfUyYmt/+iX1kxxp+gZMcaQ==", "integrity": "sha512-1Nq7YrO/vJE/FYnqYyw0FS8LdrjExSgIiHyKg7xPpn+yi8Q4huZryKnkJatN1ZRH89Kw2v33/8ZMB7DuZeSLlA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"expect": "^29.0.0", "expect": "^29.0.0",
@ -3760,6 +3761,18 @@
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
} }
}, },
"node_modules/bs-logger": {
"version": "0.2.6",
"resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz",
"integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==",
"dev": true,
"dependencies": {
"fast-json-stable-stringify": "2.x"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/bser": { "node_modules/bser": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz",
@ -9055,6 +9068,12 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/make-error": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
"dev": true
},
"node_modules/makeerror": { "node_modules/makeerror": {
"version": "1.0.12", "version": "1.0.12",
"resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz",
@ -11849,6 +11868,82 @@
"typescript": ">=4.2.0" "typescript": ">=4.2.0"
} }
}, },
"node_modules/ts-jest": {
"version": "29.1.1",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz",
"integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==",
"dev": true,
"dependencies": {
"bs-logger": "0.x",
"fast-json-stable-stringify": "2.x",
"jest-util": "^29.0.0",
"json5": "^2.2.3",
"lodash.memoize": "4.x",
"make-error": "1.x",
"semver": "^7.5.3",
"yargs-parser": "^21.0.1"
},
"bin": {
"ts-jest": "cli.js"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
},
"peerDependencies": {
"@babel/core": ">=7.0.0-beta.0 <8",
"@jest/types": "^29.0.0",
"babel-jest": "^29.0.0",
"jest": "^29.0.0",
"typescript": ">=4.3 <6"
},
"peerDependenciesMeta": {
"@babel/core": {
"optional": true
},
"@jest/types": {
"optional": true
},
"babel-jest": {
"optional": true
},
"esbuild": {
"optional": true
}
}
},
"node_modules/ts-jest/node_modules/lru-cache": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"dependencies": {
"yallist": "^4.0.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/ts-jest/node_modules/semver": {
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
},
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/ts-jest/node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
},
"node_modules/tslib": { "node_modules/tslib": {
"version": "2.5.0", "version": "2.5.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",

View File

@ -42,7 +42,7 @@
"@babel/preset-env": "^7.21.5", "@babel/preset-env": "^7.21.5",
"@rollup/plugin-json": "^6.0.0", "@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-terser": "^0.4.1", "@rollup/plugin-terser": "^0.4.1",
"@types/jest": "^29.5.1", "@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.2.1", "@typescript-eslint/eslint-plugin": "^6.2.1",
"@typescript-eslint/parser": "^6.2.1", "@typescript-eslint/parser": "^6.2.1",
"clean-jsdoc-theme": "^4.2.7", "clean-jsdoc-theme": "^4.2.7",
@ -57,6 +57,7 @@
"prettier": "^2.8.8", "prettier": "^2.8.8",
"rollup": "^3.21.3", "rollup": "^3.21.3",
"rollup-plugin-postcss": "^4.0.2", "rollup-plugin-postcss": "^4.0.2",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6" "typescript": "^5.1.6"
}, },
"lint-staged": { "lint-staged": {

View File

@ -1,13 +1,10 @@
"use strict"; "use strict";
import * as math from "./math";
import * as mercator from "./mercator"; import * as mercator from "./mercator";
import {Ellipsoid} from "./ellipsoid/Ellipsoid"; import {Ellipsoid} from "./ellipsoid/Ellipsoid";
import {LonLat} from "./LonLat"; import {LonLat} from "./LonLat";
//@ts-ignore
import * as math from "./math.js";
/** /**
* Represents geographical coordinates extent. * Represents geographical coordinates extent.
* @class * @class
@ -26,7 +23,7 @@ export class Extent {
/** /**
* Creates extent instance from values in array. * Creates extent instance from values in array.
* @static * @static
* @param {Array.<number>} arr - South west and north east longitude and latidudes packed in array. (exactly 4 entries) * @param {Array.<number>} arr - South west and north-east longitude and latitudes packed in array. (exactly 4 entries)
* @return {Extent} Extent object. * @return {Extent} Extent object.
*/ */
static createFromArray(arr: [number, number, number, number]): Extent { static createFromArray(arr: [number, number, number, number]): Extent {
@ -76,7 +73,7 @@ export class Extent {
} }
/** /**
* Creates extent by meractor grid tile coordinates. * Creates extent by merсator grid tile coordinates.
* @static * @static
* @param {number} x - * @param {number} x -
* @param {number} y - * @param {number} y -

View File

@ -1,9 +1,4 @@
// #StandWithUkraine // #StandWithUkraine
/**
* @module og/Globe
*/
"use strict"; "use strict";
import { CompassButton } from "./control/CompassButton.js"; import { CompassButton } from "./control/CompassButton.js";
@ -14,7 +9,6 @@ import { ScaleControl } from "./control/ScaleControl.js";
import { Sun } from "./control/Sun.js"; import { Sun } from "./control/Sun.js";
import { TouchNavigation } from "./control/TouchNavigation.js"; import { TouchNavigation } from "./control/TouchNavigation.js";
import { ZoomControl } from "./control/ZoomControl.js"; import { ZoomControl } from "./control/ZoomControl.js";
import { Vec3 } from "./math/Vec3.js";
import { Renderer } from "./renderer/Renderer.js"; import { Renderer } from "./renderer/Renderer.js";
import { Planet } from "./scene/Planet.js"; import { Planet } from "./scene/Planet.js";
import { EmptyTerrain } from "./terrain/EmptyTerrain.js"; import { EmptyTerrain } from "./terrain/EmptyTerrain.js";

View File

@ -16,34 +16,37 @@ const INV_PI_BY_180_HALF_PI = INV_PI_BY_180 * HALF_PI;
* @param {number} [height] - Height over the surface. * @param {number} [height] - Height over the surface.
*/ */
export class LonLat { export class LonLat {
/**
* Longitude.
* @public
* @type {number}
*/
public lon: number = 0; public lon: number = 0;
/**
* Latitude.
* @public
* @type {number}
*/
public lat: number = 0; public lat: number = 0;
/**
* Height.
* @public
* @type {number}
*/
public height: number = 0; public height: number = 0;
constructor(lon: number = 0, lat: number = 0, height: number = 0) { constructor(lon: number = 0, lat: number = 0, height: number = 0) {
/**
* Longitude.
* @public
* @type {number}
*/
this.lon = lon; this.lon = lon;
/**
* Latitude.
* @public
* @type {number}
*/
this.lat = lat; this.lat = lat;
/**
* Height.
* @public
* @type {number}
*/
this.height = height; this.height = height;
} }
/**
* Check zero coordinates
* @returns {boolean} -
*/
public isZero(): boolean { public isZero(): boolean {
return this.lon === 0.0 && this.lat === 0.0 && this.height === 0.0; return this.lon === 0.0 && this.lat === 0.0 && this.height === 0.0;
} }
@ -74,7 +77,7 @@ export class LonLat {
} }
/** /**
* Create array from lonlat * Create array from lonlat
* @param lonLat * @param lonLat
* @returns {number[]} * @returns {number[]}
*/ */
@ -83,7 +86,7 @@ export class LonLat {
} }
/** /**
* Create array from lonlat * Create array from lonlat
* @returns {number[]} * @returns {number[]}
*/ */
public toArray(): [number, number, number] { public toArray(): [number, number, number] {

View File

@ -2,8 +2,8 @@
'use strict'; 'use strict';
import { htmlColorToFloat32Array } from './utils/shared.js'; import { htmlColorToFloat32Array } from './utils/shared.js';
import { Vec3 } from './math/Vec3.js'; import { Vec3 } from './math/Vec3';
import { MAX, MIN } from './math.js'; import { MAX, MIN } from './math';
import { transformLeftToRightCoordinateSystem, objParser } from "./utils/objParser.js"; import { transformLeftToRightCoordinateSystem, objParser } from "./utils/objParser.js";
function getColor(color) { function getColor(color) {

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import { Vec3 } from "./math/Vec3.js"; import { Vec3 } from "./math/Vec3";
import { createLonLat, stringTemplate } from "./utils/shared.js"; import { createLonLat, stringTemplate } from "./utils/shared.js";
import { View } from './ui/View.js'; import { View } from './ui/View.js';
import { CLOSE_ICON } from './ui/icons.js'; import { CLOSE_ICON } from './ui/icons.js';

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
import * as math from "../math.js"; import * as math from "../math";
import { Quat } from "../math/Quat.js"; import { Quat } from "../math/Quat";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import * as astro from "./astro.js"; import * as astro from "./astro.js";
import * as jd from "./jd.js"; import * as jd from "./jd.js";

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
import * as math from "../math.js"; import * as math from "../math";
import { Mat3 } from "../math/Mat3.js"; import { Mat3 } from "../math/Mat3";
export function getEccentricAnomaly(M, ecc) { export function getEccentricAnomaly(M, ecc) {
if (ecc == 0.0) { if (ecc == 0.0) {

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
import { PI_TWO } from "../math.js"; import { PI_TWO } from "../math";
import { Mat3 } from "../math/Mat3.js"; import { Mat3 } from "../math/Mat3";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
export function getRotationMatrix(rightAscension, declination, res) { export function getRotationMatrix(rightAscension, declination, res) {
let xAxis = new Vec3(), let xAxis = new Vec3(),

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
/** /**
* Bounding box class. * Bounding box class.

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
/** /**
* Bounding sphere class. * Bounding sphere class.

View File

@ -1,12 +1,12 @@
"use strict"; "use strict";
import { Events } from "../Events.js"; import { Events } from "../Events.js";
import * as math from "../math.js"; import * as math from "../math";
import { Mat3 } from "../math/Mat3.js"; import { Mat3 } from "../math/Mat3";
import { Mat4 } from "../math/Mat4.js"; import { Mat4 } from "../math/Mat4";
import { Vec2 } from "../math/Vec2.js"; import { Vec2 } from "../math/Vec2.js";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { Vec4 } from "../math/Vec4.js"; import { Vec4 } from "../math/Vec4";
import { Frustum } from "./Frustum.js"; import { Frustum } from "./Frustum.js";
/** /**

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import { Mat4 } from "../math/Mat4.js"; import { Mat4 } from "../math/Mat4";
function planeNormalize(plane) { function planeNormalize(plane) {
var t = 1.0 / Math.sqrt(plane[0] * plane[0] + plane[1] * plane[1] + plane[2] * plane[2]); var t = 1.0 / Math.sqrt(plane[0] * plane[0] + plane[1] * plane[1] + plane[2] * plane[2]);

View File

@ -1,13 +1,13 @@
"use strict"; "use strict";
import { Key } from "../Lock.js"; import { Key } from "../Lock.js";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import * as math from "../math.js"; import * as math from "../math";
import { Mat4 } from "../math/Mat4.js"; import { Mat4 } from "../math/Mat4";
import { Quat } from "../math/Quat.js"; import { Quat } from "../math/Quat";
import { Ray } from "../math/Ray.js"; import { Ray } from "../math/Ray.js";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator";
import { Camera } from "./Camera.js"; import { Camera } from "./Camera.js";
import { Ellipsoid } from "../ellipsoid/index.js"; import { Ellipsoid } from "../ellipsoid/index.js";

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { LonLat } from '../LonLat.js'; import { LonLat } from '../LonLat';
import { throttle } from '../utils/shared.js'; import { throttle } from '../utils/shared.js';
import * as units from '../utils/units.js'; import * as units from '../utils/units.js';
import { heightMode } from '../utils/units.js'; import { heightMode } from '../utils/units.js';

View File

@ -1,10 +1,10 @@
"use strict"; "use strict";
import { Sphere } from "../bv/Sphere.js"; import { Sphere } from "../bv/Sphere.js";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { Quat } from "../math/Quat.js"; import { Quat } from "../math/Quat";
import { Ray } from "../math/Ray.js"; import { Ray } from "../math/Ray.js";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { Control } from "./Control.js"; import { Control } from "./Control.js";
class Touch { class Touch {

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
import { input } from "../input/input.js"; import { input } from "../input/input.js";
import * as math from "../math.js"; import * as math from "../math";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { Control } from "./Control.js"; import { Control } from "./Control.js";
/** /**

View File

@ -3,12 +3,12 @@
import { Sphere } from "../bv/Sphere.js"; import { Sphere } from "../bv/Sphere.js";
import { input } from "../input/input.js"; import { input } from "../input/input.js";
import { Key } from "../Lock.js"; import { Key } from "../Lock.js";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import * as math from "../math.js"; import * as math from "../math";
import { Mat4 } from "../math/Mat4.js"; import { Mat4 } from "../math/Mat4";
import { Quat } from "../math/Quat.js"; import { Quat } from "../math/Quat";
import { Ray } from "../math/Ray.js"; import { Ray } from "../math/Ray.js";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { Control } from "./Control.js"; import { Control } from "./Control.js";
/** /**

View File

@ -2,8 +2,8 @@
import { Sphere } from "../bv/Sphere.js"; import { Sphere } from "../bv/Sphere.js";
import { Key } from "../Lock.js"; import { Key } from "../Lock.js";
import { Quat } from "../math/Quat.js"; import { Quat } from "../math/Quat";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { Control } from "./Control.js"; import { Control } from "./Control.js";
import { MouseNavigation } from "./MouseNavigation.js"; import { MouseNavigation } from "./MouseNavigation.js";

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
import { RADIANS } from "../math.js"; import { RADIANS } from "../math";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { binarySearch, parseHTML } from "../utils/shared.js"; import { binarySearch, parseHTML } from "../utils/shared.js";
import { Control } from "./Control.js"; import { Control } from "./Control.js";

View File

@ -2,8 +2,8 @@
import { getSunPosition } from "../astro/earth.js"; import { getSunPosition } from "../astro/earth.js";
import { LightSource } from "../light/LightSource.js"; import { LightSource } from "../light/LightSource.js";
import { Quat } from "../math/Quat.js"; import { Quat } from "../math/Quat";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { Control } from "./Control.js"; import { Control } from "./Control.js";
/** /**

View File

@ -2,13 +2,13 @@
import { Sphere } from "../bv/Sphere.js"; import { Sphere } from "../bv/Sphere.js";
import { Key } from "../Lock.js"; import { Key } from "../Lock.js";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { Quat } from "../math/Quat.js"; import { Quat } from "../math/Quat";
import { Ray } from "../math/Ray.js"; import { Ray } from "../math/Ray.js";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { Control } from "./Control.js"; import { Control } from "./Control.js";
import { Vec2 } from "../math/index.js"; import { Vec2 } from "../math/Vec2.js";
import { math } from "../index.js"; import { math } from "../index";
class Touch { class Touch {
constructor() { constructor() {

View File

@ -7,8 +7,8 @@ import {
PolygonDrawingScene PolygonDrawingScene
} from "./PolygonDrawingScene.js"; } from "./PolygonDrawingScene.js";
import { Entity } from "../../entity/Entity.js"; import { Entity } from "../../entity/Entity.js";
import { Line3, Vec2, Vec3 } from "../../math/index.js"; import { Line3, Vec2, Vec3 } from "../../math/index";
import * as math from "../../math.js"; import * as math from "../../math";
import { GeometryType } from "../../entity/Geometry.js"; import { GeometryType } from "../../entity/Geometry.js";
class LineStringDrawingScene extends PolygonDrawingScene { class LineStringDrawingScene extends PolygonDrawingScene {

View File

@ -1,15 +1,15 @@
'use strict'; 'use strict';
import * as math from "../../math.js"; import * as math from "../../math";
import { Entity } from '../../entity/Entity.js'; import { Entity } from '../../entity/Entity.js';
import { Events } from '../../Events.js'; import { Events } from '../../Events.js';
import { Vector } from '../../layer/Vector.js'; import { Vector } from '../../layer/Vector.js';
import { Vec2 } from '../../math/Vec2.js'; import { Vec2 } from '../../math/Vec2.js';
import { Object3d } from '../../Object3d.js'; import { Object3d } from '../../Object3d.js';
import { RenderNode } from '../../scene/RenderNode.js'; import { RenderNode } from '../../scene/RenderNode.js';
import { Vec3 } from '../../math/Vec3.js'; import { Vec3 } from '../../math/Vec3';
import { Line3 } from '../../math/Line3.js'; import { Line3 } from '../../math/Line3.js';
import { LonLat } from '../../LonLat.js'; import { LonLat } from '../../LonLat';
import { Geometry, GeometryType } from "../../entity/Geometry.js"; import { Geometry, GeometryType } from "../../entity/Geometry.js";
const POINTER_OBJ3D = Object3d.createCylinder(1, 1, 2.0, 20, 1, true, false, 0, -0.5, 0); const POINTER_OBJ3D = Object3d.createCylinder(1, 1, 2.0, 20, 1, true, false, 0, -0.5, 0);

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { Vec3 } from "../../math/Vec3.js"; import { Vec3 } from "../../math/Vec3";
import { Deferred } from "../../Deferred.js"; import { Deferred } from "../../Deferred.js";
import { Events } from '../../Events.js'; import { Events } from '../../Events.js';

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { Ellipsoid } from '../../ellipsoid/Ellipsoid.js'; import { Ellipsoid } from '../../ellipsoid/Ellipsoid';
import { Entity } from '../../entity/Entity.js'; import { Entity } from '../../entity/Entity.js';
import { Events } from '../../Events.js'; import { Events } from '../../Events.js';
import { Vector } from '../../layer/Vector.js'; import { Vector } from '../../layer/Vector.js';

View File

@ -1,10 +1,10 @@
'use strict'; 'use strict';
import { Ellipsoid } from '../../ellipsoid/Ellipsoid.js'; import { Ellipsoid } from '../../ellipsoid/Ellipsoid';
import { Entity } from '../../entity/Entity.js'; import { Entity } from '../../entity/Entity.js';
import { Events } from '../../Events.js'; import { Events } from '../../Events.js';
import { Vector } from '../../layer/Vector.js'; import { Vector } from '../../layer/Vector.js';
import { LonLat } from '../../LonLat.js'; import { LonLat } from '../../LonLat';
import { Object3d } from '../../Object3d.js'; import { Object3d } from '../../Object3d.js';
import { RenderNode } from '../../scene/RenderNode.js'; import { RenderNode } from '../../scene/RenderNode.js';

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import * as math from '../../math.js'; import * as math from '../../math';
export function addSeconds(date, seconds) { export function addSeconds(date, seconds) {
return new Date(+date + seconds * 1000); return new Date(+date + seconds * 1000);

View File

@ -2,12 +2,12 @@
import { Box } from "../../bv/Box.js"; import { Box } from "../../bv/Box.js";
import { Sphere } from "../../bv/Sphere.js"; import { Sphere } from "../../bv/Sphere.js";
import { Extent } from "../../Extent.js"; import { Extent } from "../../Extent";
import { Layer } from "../../layer/Layer.js"; import { Layer } from "../../layer/Layer.js";
import { LonLat } from "../../LonLat.js"; import { LonLat } from "../../LonLat";
import { Ray } from "../../math/Ray.js"; import { Ray } from "../../math/Ray.js";
import { Vec3 } from "../../math/Vec3.js"; import { Vec3 } from "../../math/Vec3";
import * as mercator from "../../mercator.js"; import * as mercator from "../../mercator";
import { EPSG3857 } from "../../proj/EPSG3857.js"; import { EPSG3857 } from "../../proj/EPSG3857.js";
import { E, N, NOTRENDERING, OPSIDE, S, W } from "../../quadTree/quadTree.js"; import { E, N, NOTRENDERING, OPSIDE, S, W } from "../../quadTree/quadTree.js";
import * as segmentHelper from "../../segment/segmentHelper.js"; import * as segmentHelper from "../../segment/segmentHelper.js";

View File

@ -3,8 +3,7 @@
import {LonLat} from "../LonLat"; import {LonLat} from "../LonLat";
import {Quat} from "../math/Quat"; import {Quat} from "../math/Quat";
import {Vec3} from "../math/Vec3"; import {Vec3} from "../math/Vec3";
//@ts-ignore import {DEGREES, EPS1, EPS12, EPS15, RADIANS, zeroTwoPI} from "../math";
import {DEGREES, EPS1, EPS12, EPS15, RADIANS, zeroTwoPI} from "../math.js";
export interface IInverseResult { export interface IInverseResult {
distance: number; distance: number;

View File

@ -1,4 +1,4 @@
import { Ellipsoid } from './Ellipsoid.js'; import { Ellipsoid } from './Ellipsoid';
import { wgs84 } from './wgs84.js'; import { wgs84 } from './wgs84';
export { Ellipsoid, wgs84 }; export { Ellipsoid, wgs84 };

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import { Ellipsoid } from "./Ellipsoid.js"; import {Ellipsoid} from "./Ellipsoid";
/** /**
* WGS84 ellipsoid object. * WGS84 ellipsoid object.

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import * as utils from "../utils/shared.js"; import * as utils from "../utils/shared.js";
import { LOCK_FREE, LOCK_UPDATE } from "./LabelWorker.js"; import { LOCK_FREE, LOCK_UPDATE } from "./LabelWorker.js";

View File

@ -1,9 +1,9 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator";
import * as utils from "../utils/shared.js"; import * as utils from "../utils/shared.js";
import { Billboard } from "./Billboard.js"; import { Billboard } from "./Billboard.js";
import { Geometry } from "./Geometry.js"; import { Geometry } from "./Geometry.js";

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
import { Events } from "../Events.js"; import { Events } from "../Events.js";
import * as math from "../math.js"; import * as math from "../math";
import { BillboardHandler } from "./BillboardHandler.js"; import { BillboardHandler } from "./BillboardHandler.js";
import { GeoObjectHandler } from "./GeoObjectHandler.js"; import { GeoObjectHandler } from "./GeoObjectHandler.js";
import { LabelHandler } from "./LabelHandler.js"; import { LabelHandler } from "./LabelHandler.js";

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import { Quat, Vec3 } from "../math/index.js"; import { Quat, Vec3 } from "../math/index";
import { Planet } from "../scene/Planet.js"; import { Planet } from "../scene/Planet.js";
import * as utils from "../utils/shared.js"; import * as utils from "../utils/shared.js";

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { Vec4 } from "../math/Vec4.js"; import { Vec4 } from "../math/Vec4";
import * as utils from "../utils/shared.js"; import * as utils from "../utils/shared.js";
const GeometryType = { const GeometryType = {

View File

@ -2,7 +2,7 @@
import { doubleToTwoFloatsV2 } from "../math/coder.js"; import { doubleToTwoFloatsV2 } from "../math/coder.js";
import { Vec2 } from "../math/Vec2.js"; import { Vec2 } from "../math/Vec2.js";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator";
import * as quadTree from "../quadTree/quadTree.js"; import * as quadTree from "../quadTree/quadTree.js";
import { earcut, flatten } from "../utils/earcut.js"; import { earcut, flatten } from "../utils/earcut.js";
import { GeometryType } from "./Geometry.js"; import { GeometryType } from "./Geometry.js";

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import { Vec4 } from "../math/Vec4.js"; import { Vec4 } from "../math/Vec4";
import * as utils from "../utils/shared.js"; import * as utils from "../utils/shared.js";
import { BaseBillboard } from "./BaseBillboard.js"; import { BaseBillboard } from "./BaseBillboard.js";
import { LOCK_FREE, LOCK_UPDATE } from "./LabelWorker.js"; import { LOCK_FREE, LOCK_UPDATE } from "./LabelWorker.js";

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { Vec4 } from "../math/Vec4.js"; import { Vec4 } from "../math/Vec4";
const COORDINATES_BUFFER = 0; const COORDINATES_BUFFER = 0;
const COLOR_BUFFER = 1; const COLOR_BUFFER = 1;

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { import {
cloneArray, htmlColorToFloat32Array, cloneArray, htmlColorToFloat32Array,
htmlColorToRgba, makeArray, makeArrayTyped htmlColorToRgba, makeArray, makeArrayTyped

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import {Vec3} from "../math/Vec3.js"; import {Vec3} from "../math/Vec3";
import * as utils from "../utils/shared.js"; import * as utils from "../utils/shared.js";
import {Entity} from "./Entity.js"; import {Entity} from "./Entity.js";

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
import { Line3 } from "../math/Line3.js"; import { Line3 } from "../math/Line3.js";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import * as utils from "../utils/shared.js"; import * as utils from "../utils/shared.js";
let _tempHigh = new Vec3(), let _tempHigh = new Vec3(),

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import * as jd from './astro/jd.js'; import * as jd from './astro/jd.js';
import * as math from './math.js'; import * as math from './math';
import * as mercator from './mercator'; import * as mercator from './mercator';
import * as utils from './utils/shared.js'; import * as utils from './utils/shared.js';

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator";
import { Layer } from "./Layer.js"; import { Layer } from "./Layer.js";
import { doubleToTwoFloats2 } from "../math/coder.js"; import { doubleToTwoFloats2 } from "../math/coder.js";

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import { nextHighestPowerOfTwo } from "../math.js"; import { nextHighestPowerOfTwo } from "../math";
import { BaseGeoImage } from "./BaseGeoImage.js"; import { BaseGeoImage } from "./BaseGeoImage.js";
import { isImageLoaded } from "../utils/shared.js"; import { isImageLoaded } from "../utils/shared.js";

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import * as math from '../math.js'; import * as math from '../math';
import { BaseGeoImage } from './BaseGeoImage.js'; import { BaseGeoImage } from './BaseGeoImage.js';
class GeoTexture2d extends BaseGeoImage { class GeoTexture2d extends BaseGeoImage {

View File

@ -2,8 +2,8 @@
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";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { Vector } from "./Vector.js"; import { Vector } from "./Vector.js";
/** /**

View File

@ -1,10 +1,10 @@
"use strict"; "use strict";
import { Events } from "../Events.js"; import { Events } from "../Events.js";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator";
import * as utils from "../utils/shared.js"; import * as utils from "../utils/shared.js";
import { createColorRGB } from "../utils/shared.js"; import { createColorRGB } from "../utils/shared.js";
import { Material } from "./Material.js"; import { Material } from "./Material.js";

View File

@ -1,12 +1,12 @@
"use strict"; "use strict";
import * as mercator from "../mercator";
import { Entity } from "../entity/Entity.js"; import { Entity } from "../entity/Entity.js";
import { EntityCollection } from "../entity/EntityCollection.js"; import { EntityCollection } from "../entity/EntityCollection.js";
import { GeometryHandler } from "../entity/GeometryHandler.js"; import { GeometryHandler } from "../entity/GeometryHandler.js";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import * as math from "../math.js"; import * as math from "../math";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import * as mercator from "../mercator.js";
import { import {
EntityCollectionNode, EntityCollectionNode,
EntityCollectionNodeWGS84 EntityCollectionNodeWGS84

View File

@ -1,8 +1,8 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import * as mercator from "../mercator";
import { LonLat } from "../LonLat.js"; import { Extent } from "../Extent";
import * as mercator from "../mercator.js"; import { LonLat } from "../LonLat";
import { XYZ } from "./XYZ.js"; import { XYZ } from "./XYZ.js";
/** /**

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator";
import { RENDERING } from "../quadTree/quadTree.js"; import { RENDERING } from "../quadTree/quadTree.js";
import { stringTemplate } from "../utils/shared.js"; import { stringTemplate } from "../utils/shared.js";
import { Layer } from "./Layer.js"; import { Layer } from "./Layer.js";

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
/** /**
* Represents basic light source. * Represents basic light source.

View File

@ -1,9 +1,7 @@
/**
* @module og/math
*/
"use strict"; "use strict";
import {Vec3} from "./math/Vec3";
/** @const */ /** @const */
export const TWO_PI = 2.0 * Math.PI; export const TWO_PI = 2.0 * Math.PI;
@ -81,7 +79,7 @@ export const EPS20 = 1e-20;
* log(64, 2) * log(64, 2)
* //returns 6 * //returns 6
*/ */
export function log(n, base) { export function log(n: number, base: number): number {
return Math.log(n) / Math.log(base); return Math.log(n) / Math.log(base);
} }
@ -96,7 +94,7 @@ export function log(n, base) {
* clamp(12, 1, 5) * clamp(12, 1, 5)
* //returns 5 * //returns 5
*/ */
export function clamp(number, min, max) { export function clamp(number: number, min: number, max: number): number {
return Math.max(min, Math.min(number, max)); return Math.max(min, Math.min(number, max));
} }
@ -106,7 +104,7 @@ export function clamp(number, min, max) {
* @param {number} degrees - Degree value. * @param {number} degrees - Degree value.
* @returns {number} - * @returns {number} -
*/ */
export function DEG2RAD(degrees) { export function DEG2RAD(degrees: number): number {
return degrees * RADIANS; return degrees * RADIANS;
} }
@ -116,7 +114,7 @@ export function DEG2RAD(degrees) {
* @param {number} angle - Degree value. * @param {number} angle - Degree value.
* @returns {number} - * @returns {number} -
*/ */
export function RAD2DEG(angle) { export function RAD2DEG(angle: number): number {
return angle * DEGREES; return angle * DEGREES;
} }
@ -126,7 +124,7 @@ export function RAD2DEG(angle) {
* @param {number} x - Input value. * @param {number} x - Input value.
* @returns {boolean} - * @returns {boolean} -
*/ */
export function isPowerOfTwo(x) { export function isPowerOfTwo(x: number): boolean {
return (x & (x - 1)) === 0; return (x & (x - 1)) === 0;
} }
@ -134,9 +132,10 @@ export function isPowerOfTwo(x) {
* Returns next value that is power of two. * Returns next value that is power of two.
* @function * @function
* @param {number} x - Input value. * @param {number} x - Input value.
* @param {number} [maxValue=4096] - Maximal value.
* @returns {number} - * @returns {number} -
*/ */
export function nextHighestPowerOfTwo(x, maxValue = 4096) { export function nextHighestPowerOfTwo(x: number, maxValue: number = 4096): number {
--x; --x;
for (let i = 1; i < 32; i <<= 1) { for (let i = 1; i < 32; i <<= 1) {
x = x | (x >> i); x = x | (x >> i);
@ -151,7 +150,7 @@ export function nextHighestPowerOfTwo(x, maxValue = 4096) {
* @param {number} max - Maximal bound. * @param {number} max - Maximal bound.
* @returns {number} - * @returns {number} -
*/ */
export function randomi(min = 0, max = 1) { export function randomi(min: number = 0, max: number = 1): number {
return Math.floor(Math.random() * (max - min)) + min; return Math.floor(Math.random() * (max - min)) + min;
} }
@ -162,7 +161,7 @@ export function randomi(min = 0, max = 1) {
* @param {number} [max=1] - Maximal bound. * @param {number} [max=1] - Maximal bound.
* @returns {number} - * @returns {number} -
*/ */
export function random(min = 0, max = 1) { export function random(min: number = 0, max: number = 1): number {
return Math.random() * (max - min) + min; return Math.random() * (max - min) + min;
} }
@ -175,7 +174,7 @@ export function random(min = 0, max = 1) {
* @param {boolean} [p] - Positive flag. False - default. * @param {boolean} [p] - Positive flag. False - default.
* @returns {number} - * @returns {number} -
**/ **/
export function degToDec(d, m, s, p) { export function degToDec(d: number, m: number, s: number, p: number): number {
if (p) { if (p) {
return d + m / 60.0 + s / 3600.0; return d + m / 60.0 + s / 3600.0;
} else { } else {
@ -190,7 +189,7 @@ export function degToDec(d, m, s, p) {
* @param {number} n - The divisor. * @param {number} n - The divisor.
* @returns {number} The remainder. * @returns {number} The remainder.
*/ */
export function mod(m, n) { export function mod(m: number, n: number): number {
return ((m % n) + n) % n; return ((m % n) + n) % n;
} }
@ -200,7 +199,7 @@ export function mod(m, n) {
* @param {number} a - Angle in radians * @param {number} a - Angle in radians
* @returns {number} - * @returns {number} -
*/ */
export function zeroTwoPI(a) { export function zeroTwoPI(a: number): number {
const res = mod(a, TWO_PI); const res = mod(a, TWO_PI);
if (Math.abs(res) < EPS14 && Math.abs(a) > EPS14) { if (Math.abs(res) < EPS14 && Math.abs(a) > EPS14) {
return TWO_PI; return TWO_PI;
@ -215,17 +214,17 @@ export function zeroTwoPI(a) {
* @param {number} x - Value to edge. * @param {number} x - Value to edge.
* @returns {number} - * @returns {number} -
*/ */
export function step(edge, x) { export function step(edge: number, x: number): number {
return x < edge ? 0.0 : 1.0; return x < edge ? 0.0 : 1.0;
} }
/** /**
* The fract function returns the fractional part of x, i.e. x minus floor(x). * The frac function returns the fractional part of x, i.e. x minus floor(x).
* @function * @function
* @param {number} x - Input value. * @param {number} x - Input value.
* @returns {number} - * @returns {number} -
*/ */
export function frac(x) { export function frac(x: number): number {
const mx = Math.abs(x) const mx = Math.abs(x)
return mx - Math.floor(mx); return mx - Math.floor(mx);
} }
@ -236,7 +235,7 @@ export function frac(x) {
* @param {number} x - Input value. * @param {number} x - Input value.
* @returns {number} - * @returns {number} -
*/ */
export function log2(x) { export function log2(x: number): number {
return Math.log(x) / LOG2; return Math.log(x) / LOG2;
} }
@ -246,7 +245,7 @@ export function log2(x) {
* @param {number} n - Power value. * @param {number} n - Power value.
* @returns {number} - * @returns {number} -
*/ */
export function exp2(n) { export function exp2(n: number): number {
return Math.pow(2, n); return Math.pow(2, n);
} }
@ -256,7 +255,7 @@ export function exp2(n) {
* @param {number} n - Integer power value. * @param {number} n - Integer power value.
* @returns {number} - * @returns {number} -
*/ */
export function pow2i(n) { export function pow2i(n: number): number {
return 2 << (n - 1); return 2 << (n - 1);
} }
@ -267,7 +266,7 @@ export function pow2i(n) {
* @param {number} h0 - Start value. * @param {number} h0 - Start value.
* @returns {number} - * @returns {number} -
*/ */
export function slice(t, h1, h0) { export function slice(t: number, h1: number, h0: number): number {
return t * (h1 - h0); return t * (h1 - h0);
} }
@ -279,19 +278,19 @@ export function slice(t, h1, h0) {
* @param {number} h0 - Start value. * @param {number} h0 - Start value.
* @returns {number} - * @returns {number} -
*/ */
export function lerp(t, h1, h0) { export function lerp(t: number, h1: number, h0: number): number {
return h0 + t * (h1 - h0); return h0 + t * (h1 - h0);
} }
export function cube(f) { export function cube(f: number): number {
return f * f * f; return f * f * f;
} }
export function square(f) { export function square(f: number): number {
return f * f; return f * f;
} }
export function bezier1v(t, p0, p1, p2, p3) { export function bezier1v(t: number, p0: number, p1: number, p2: number, p3: number): number {
return ( return (
cube(1 - t) * p0 + 3 * square(1 - t) * t * p1 + 3 * (1 - t) * square(t) * p2 + cube(t) * p3 cube(1 - t) * p0 + 3 * square(1 - t) * t * p1 + 3 * (1 - t) * square(t) * p2 + cube(t) * p3
); );
@ -307,15 +306,15 @@ export function bezier1v(t, p0, p1, p2, p3) {
* @param {Vec3} p3 - Fourth control point. * @param {Vec3} p3 - Fourth control point.
* @returns {Vec3} - * @returns {Vec3} -
*/ */
export function bezier3v(t, p0, p1, p2, p3) { export function bezier3v(t: number, p0: Vec3, p1: Vec3, p2: Vec3, p3: Vec3): Vec3 {
var u = 1 - t;
var tt = t * t;
var uu = u * u;
var uuu = uu * u;
var ttt = tt * t;
return p0 let u = 1 - t;
.scaleTo(uuu) let tt = t * t;
let uu = u * u;
let uuu = uu * u;
let ttt = tt * t;
return p0.scaleTo(uuu)
.addA(p1.scaleTo(3 * uu * t)) .addA(p1.scaleTo(3 * uu * t))
.addA(p2.scaleTo(3 * u * tt)) .addA(p2.scaleTo(3 * u * tt))
.addA(p3.scaleTo(ttt)); .addA(p3.scaleTo(ttt));
@ -327,7 +326,7 @@ export function bezier3v(t, p0, p1, p2, p3) {
* @param {number} x - Input angle. * @param {number} x - Input angle.
* @returns {number} - * @returns {number} -
*/ */
export function rev(x) { export function rev(x: number): number {
return x - Math.floor(x / 360.0) * 360.0; return x - Math.floor(x / 360.0) * 360.0;
} }
@ -337,7 +336,7 @@ export function rev(x) {
* @param {number} lon - Longitude. * @param {number} lon - Longitude.
* @returns {number} - * @returns {number} -
*/ */
export function norm_lon(lon) { export function norm_lon(lon: number): number {
return lon > 180 ? ((lon + 180) % 360) - 180 : lon < -180 ? ((lon - 180) % 360) + 180 : lon; return lon > 180 ? ((lon + 180) % 360) - 180 : lon < -180 ? ((lon - 180) % 360) + 180 : lon;
} }
@ -347,21 +346,21 @@ export function norm_lon(lon) {
* @param {number} a - Angle in radians. * @param {number} a - Angle in radians.
* @returns {number} - * @returns {number} -
*/ */
export function negativePItoPI(a) { export function negativePItoPI(a: number): number {
return zeroTwoPI(a + Math.PI) - Math.PI; return zeroTwoPI(a + Math.PI) - Math.PI;
} }
/** /**
* Solve using iteration method and a fixed number of steps. * Solve using iteration method and a fixed number of steps.
* @function * @function
* @param {equationCallback} f - Equation. Used in Euler's equation(see og.orbit) solving. * @param {Function} f - Equation. Used in Euler's equation(see og.orbit) solving.
* @param {number} x0 - First approximation. * @param {number} x0 - First approximation.
* @param {number} maxIter - Maximum iterations. * @param {number} maxIter - Maximum iterations.
* @returns {number} - * @returns {number} -
*/ */
export function solve_iteration_fixed(f, x0, maxIter) { export function solve_iteration_fixed(f: Function, x0: number, maxIter: number): number {
var x = 0; let x = 0;
var x2 = x0; let x2 = x0;
for (let i = 0; i < maxIter; i++) { for (let i = 0; i < maxIter; i++) {
x = x2; x = x2;
x2 = f(x); x2 = f(x);
@ -373,15 +372,15 @@ export function solve_iteration_fixed(f, x0, maxIter) {
* Solve using iteration; terminate when error is below err or the maximum * Solve using iteration; terminate when error is below err or the maximum
* number of iterations is reached. Used in Euler's equation(see og.orbit) solving. * number of iterations is reached. Used in Euler's equation(see og.orbit) solving.
* @function * @function
* @param {equationCallback} f - Equation. * @param {Function} f - Equation.
* @param {number} x0 - First approximation. * @param {number} x0 - First approximation.
* @param {number} err - Maximal accepted error value. * @param {number} err - Maximal accepted error value.
* @param {number} maxIter - Maximum iterations. * @param {number} maxIter - Maximum iterations.
* @returns {number} - * @returns {number} -
*/ */
export function solve_iteration(f, x0, err, maxIter = 50) { export function solve_iteration(f: Function, x0: number, err: number, maxIter: number = 50): number {
var x = 0; let x = 0;
var x2 = x0; let x2 = x0;
for (let i = 0; i < maxIter; i++) { for (let i = 0; i < maxIter; i++) {
x = x2; x = x2;
x2 = f(x); x2 = f(x);
@ -404,7 +403,7 @@ export function solve_iteration(f, x0, err, maxIter = 50) {
* @param b - Second bearing angle * @param b - Second bearing angle
* @returns {number} * @returns {number}
*/ */
function getAngleDirection(a, b) { function getAngleDirection(a: number, b: number): number {
let a_y = Math.cos(a), let a_y = Math.cos(a),
a_x = Math.sin(a), a_x = Math.sin(a),
b_y = Math.cos(b), b_y = Math.cos(b),
@ -423,7 +422,7 @@ function getAngleDirection(a, b) {
* @param {number} b - Second azimuth angle * @param {number} b - Second azimuth angle
* @returns {number} * @returns {number}
*/ */
export function getAngleBetweenAzimuths(a, b) { export function getAngleBetweenAzimuths(a: number, b: number): number {
a = zeroTwoPI(a); a = zeroTwoPI(a);
b = zeroTwoPI(b); b = zeroTwoPI(b);
return ((((a - b) % 360) + 360 + 180) % 360) - 180; return ((((a - b) % 360) + 360 + 180) % 360) - 180;

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import { EPS10 } from '../math.js'; import { EPS10 } from '../math';
import { Vec3 } from './Vec3.js'; import { Vec3 } from './Vec3';
export class Line3 { export class Line3 {
constructor(p0, p1) { constructor(p0, p1) {

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
import { EPS5 } from "../math.js"; import { EPS5 } from "../math";
import { Vec3 } from "./Vec3.js"; import { Vec3 } from "./Vec3";
/** /**
* Plane class. * Plane class.

View File

@ -1,13 +1,10 @@
"use strict"; "use strict";
import * as math from "../math";
import {Vec3} from "./Vec3"; import {Vec3} from "./Vec3";
import {Mat4} from "./Mat4"; import {Mat4} from "./Mat4";
import {Mat3} from "./Mat3"; import {Mat3} from "./Mat3";
//@ts-ignore
import * as math from "../math.js";
/** /**
* A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space. * A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space.
* @constructor * @constructor

View File

@ -1,7 +1,7 @@
"use strict"; "use strict";
import { EPS10 } from "../math.js"; import { EPS10 } from "../math";
import { Vec3 } from "./Vec3.js"; import { Vec3 } from "./Vec3";
/** /**
* Represents a ray that extends infinitely from the provided origin in the provided direction. * Represents a ray that extends infinitely from the provided origin in the provided direction.

View File

@ -1,6 +1,6 @@
"use strict"; "use strict";
import { Vec3 } from "./Vec3.js"; import { Vec3 } from "./Vec3";
/** /**
* Class represents a 3d vector. * Class represents a 3d vector.

View File

@ -1,10 +1,8 @@
"use strict"; "use strict";
import {frac} from "../math";
import {Vec3} from "./Vec3"; import {Vec3} from "./Vec3";
//@ts-ignore
import {frac} from "../math.js";
/** /**
* Class represents a 4d vector. * Class represents a 4d vector.
* @class * @class

View File

@ -4,8 +4,8 @@
"use strict"; "use strict";
import * as math from "../math.js"; import * as math from "../math";
import { Vec4 } from "./Vec4.js"; import { Vec4 } from "./Vec4";
/** /**
* Encode 32 bit float value to the RGBA vector. * Encode 32 bit float value to the RGBA vector.

View File

@ -1,13 +1,13 @@
import { Line2 } from './Line2.js'; import { Line2 } from './Line2.js';
import { Line3 } from './Line3.js'; import { Line3 } from './Line3.js';
import { Mat3 } from './Mat3.js'; import { Mat3 } from './Mat3';
import { Mat4 } from './Mat4.js'; import { Mat4 } from './Mat4';
import { Plane } from './Plane.js'; import { Plane } from './Plane.js';
import { Quat } from './Quat.js'; import { Quat } from './Quat';
import { Ray } from './Ray.js'; import { Ray } from './Ray.js';
import { Vec2 } from './Vec2.js'; import { Vec2 } from './Vec2.js';
import { Vec3 } from './Vec3.js'; import { Vec3 } from './Vec3';
import { Vec4 } from './Vec4.js'; import { Vec4 } from './Vec4';
export { export {
Line2, Line2,

View File

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

View File

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

View File

@ -2,10 +2,10 @@
import { Sphere } from '../bv/Sphere.js'; import { Sphere } from '../bv/Sphere.js';
import { EntityCollection } from '../entity/EntityCollection.js'; import { EntityCollection } from '../entity/EntityCollection.js';
import { Extent } from '../Extent.js'; import { Extent } from '../Extent';
import { LonLat } from '../LonLat.js'; import { LonLat } from '../LonLat';
import { Vec3 } from '../math/Vec3.js'; import { Vec3 } from '../math/Vec3';
import * as mercator from '../mercator.js'; import * as mercator from '../mercator';
import * as quadTree from './quadTree.js'; import * as quadTree from './quadTree.js';
class EntityCollectionNode { class EntityCollectionNode {

View File

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

View File

@ -1,10 +1,10 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { MAX, MIN } from "../math.js"; import { MAX, MIN } from "../math";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { MAX_LAT } from "../mercator.js"; import { MAX_LAT } from "../mercator";
import { EPSG3857 } from "../proj/EPSG3857.js"; import { EPSG3857 } from "../proj/EPSG3857.js";
import { EPSG4326 } from "../proj/EPSG4326.js"; import { EPSG4326 } from "../proj/EPSG4326.js";
import { getMatrixSubArray, getMatrixSubArrayBoundsExt } from "../utils/shared.js"; import { getMatrixSubArray, getMatrixSubArrayBoundsExt } from "../utils/shared.js";

View File

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

View File

@ -6,9 +6,9 @@ import { cons } from "../cons.js";
import { depth } from "../shaders/depth.js"; import { depth } from "../shaders/depth.js";
import { LabelWorker } from "../entity/LabelWorker.js"; import { LabelWorker } from "../entity/LabelWorker.js";
import { input } from "../input/input.js"; import { input } from "../input/input.js";
import { randomi } from "../math.js"; import { randomi } from "../math";
import { Vec2 } from "../math/Vec2.js"; import { Vec2 } from "../math/Vec2.js";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { pickingMask } from "../shaders/pickingMask.js"; import { pickingMask } from "../shaders/pickingMask.js";
import { screenFrame } from "../shaders/screenFrame.js"; import { screenFrame } from "../shaders/screenFrame.js";
import { toneMapping } from "../shaders/toneMapping.js"; import { toneMapping } from "../shaders/toneMapping.js";

View File

@ -6,7 +6,7 @@ import { KeyboardHandler } from "../input/KeyboardHandler.js";
import { MouseHandler } from "../input/MouseHandler.js"; import { MouseHandler } from "../input/MouseHandler.js";
import { TouchHandler } from "../input/TouchHandler.js"; import { TouchHandler } from "../input/TouchHandler.js";
import { Vec2 } from "../math/Vec2.js"; import { Vec2 } from "../math/Vec2.js";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
const LB_M = 0b0001; const LB_M = 0b0001;
const RB_M = 0b0010; const RB_M = 0b0010;

View File

@ -3,14 +3,14 @@
import { PlanetCamera } from "../camera/PlanetCamera.js"; import { PlanetCamera } from "../camera/PlanetCamera.js";
import { Atmosphere } from "../control/Atmosphere.js"; import { Atmosphere } from "../control/Atmosphere.js";
import { SimpleSkyBackground } from "../control/SimpleSkyBackground.js"; import { SimpleSkyBackground } from "../control/SimpleSkyBackground.js";
import { wgs84 } from "../ellipsoid/wgs84.js"; import { wgs84 } from "../ellipsoid/wgs84";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import { Vector } from "../layer/Vector.js"; import { Vector } from "../layer/Vector.js";
import { Key, Lock } from "../Lock.js"; import { Key, Lock } from "../Lock.js";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import * as math from "../math.js"; import * as math from "../math";
import { decodeFloatFromRGBAArr } from "../math/coder.js"; import { decodeFloatFromRGBAArr } from "../math/coder.js";
import { Quat, Vec3, Vec4 } from "../math/index.js"; import { Quat, Vec3, Vec4 } from "../math/index";
import { EarthQuadTreeStrategy } from "../quadTree/EarthQuadTreeStrategy.js"; import { EarthQuadTreeStrategy } from "../quadTree/EarthQuadTreeStrategy.js";
import { NIGHT, SPECULAR } from "../res/images.js"; import { NIGHT, SPECULAR } from "../res/images.js";
import * as segmentHelper from "../segment/segmentHelper.js"; import * as segmentHelper from "../segment/segmentHelper.js";

View File

@ -2,12 +2,12 @@
import { Box } from "../bv/Box.js"; import { Box } from "../bv/Box.js";
import { Sphere } from "../bv/Sphere.js"; import { Sphere } from "../bv/Sphere.js";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import { Layer } from "../layer/Layer.js"; import { Layer } from "../layer/Layer.js";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { Ray } from "../math/Ray.js"; import { Ray } from "../math/Ray.js";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator";
import { EPSG3857 } from "../proj/EPSG3857.js"; import { EPSG3857 } from "../proj/EPSG3857.js";
import { E, N, NOTRENDERING, OPSIDE, S, W } from "../quadTree/quadTree.js"; import { E, N, NOTRENDERING, OPSIDE, S, W } from "../quadTree/quadTree.js";
import * as segmentHelper from "../segment/segmentHelper.js"; import * as segmentHelper from "../segment/segmentHelper.js";

View File

@ -1,10 +1,10 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import { Layer } from "../layer/Layer.js"; import { Layer } from "../layer/Layer.js";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator";
import { EPSG4326 } from "../proj/EPSG4326.js"; import { EPSG4326 } from "../proj/EPSG4326.js";
import * as quadTree from "../quadTree/quadTree.js"; import * as quadTree from "../quadTree/quadTree.js";
import { Segment, TILEGROUP_NORTH, TILEGROUP_SOUTH } from "./Segment.js"; import { Segment, TILEGROUP_NORTH, TILEGROUP_SOUTH } from "./Segment.js";

View File

@ -2,8 +2,8 @@
import { Layer } from "../layer/Layer.js"; import { Layer } from "../layer/Layer.js";
import { WMS } from "../layer/WMS.js"; import { WMS } from "../layer/WMS.js";
import { isPowerOfTwo, nextHighestPowerOfTwo } from "../math.js"; import { isPowerOfTwo, nextHighestPowerOfTwo } from "../math";
import { getTileExtent } from "../mercator.js"; import { getTileExtent } from "../mercator";
import { GlobusTerrain } from "./GlobusTerrain.js"; import { GlobusTerrain } from "./GlobusTerrain.js";
class BilTerrain extends GlobusTerrain { class BilTerrain extends GlobusTerrain {

View File

@ -4,17 +4,17 @@
"use strict"; "use strict";
import { Events } from "../Events.js"; import { Events } from "../Events.js";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator";
import { EPSG3857 } from "../proj/EPSG3857.js"; import { EPSG3857 } from "../proj/EPSG3857.js";
import { NOTRENDERING } from "../quadTree/quadTree.js"; import { NOTRENDERING } from "../quadTree/quadTree.js";
import { Loader } from "../utils/Loader.js"; import { Loader } from "../utils/Loader.js";
import { EmptyTerrain } from "./EmptyTerrain.js"; import { EmptyTerrain } from "./EmptyTerrain.js";
// import { QueueArray } from '../QueueArray.js'; // import { QueueArray } from '../QueueArray.js';
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import { Layer } from "../layer/Layer.js"; import { Layer } from "../layer/Layer.js";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { Ray } from "../math/Ray.js"; import { Ray } from "../math/Ray.js";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { createExtent, stringTemplate } from "../utils/shared.js"; import { createExtent, stringTemplate } from "../utils/shared.js";
const EVENT_NAMES = [ const EVENT_NAMES = [

View File

@ -1,7 +1,7 @@
import { Layer } from "../layer/Layer.js"; import { Layer } from "../layer/Layer.js";
import { isPowerOfTwo } from "../math.js"; import { isPowerOfTwo } from "../math";
import * as mercator from "../mercator.js"; import * as mercator from "../mercator";
import { getTileExtent } from "../mercator.js"; import { getTileExtent } from "../mercator";
import { GlobusTerrain } from "./GlobusTerrain.js"; import { GlobusTerrain } from "./GlobusTerrain.js";
const KEY = const KEY =

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { clamp } from '../math.js'; import { clamp } from '../math';
import { stringTemplate } from '../utils/shared.js'; import { stringTemplate } from '../utils/shared.js';
import { View } from './View.js'; import { View } from './View.js';

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { LonLat } from '../LonLat.js'; import { LonLat } from '../LonLat';
import * as utils from '../utils/shared.js'; import * as utils from '../utils/shared.js';
import { Framebuffer } from '../webgl/Framebuffer.js'; import { Framebuffer } from '../webgl/Framebuffer.js';
import { Program } from '../webgl/Program.js'; import { Program } from '../webgl/Program.js';

View File

@ -4,11 +4,11 @@
"use strict"; "use strict";
import { Extent } from "../Extent.js"; import { Extent } from "../Extent";
import { LonLat } from "../LonLat.js"; import { LonLat } from "../LonLat";
import { Vec2 } from "../math/Vec2.js"; import { Vec2 } from "../math/Vec2.js";
import { Vec3 } from "../math/Vec3.js"; import { Vec3 } from "../math/Vec3";
import { Vec4 } from "../math/Vec4.js"; import { Vec4 } from "../math/Vec4";
import { colorTable } from "./colorTable.js"; import { colorTable } from "./colorTable.js";
export function getDefault(param, def) { export function getDefault(param, def) {

View File

@ -60,7 +60,6 @@ describe('LonLat', () => {
describe('forwardMercator', () => { describe('forwardMercator', () => {
test('converts degrees to mercator', () => { test('converts degrees to mercator', () => {
const lonlat = LonLat.forwardMercator(0, 0, 30); const lonlat = LonLat.forwardMercator(0, 0, 30);
console.log(lonlat)
expect(lonlat).toBeInstanceOf(LonLat); expect(lonlat).toBeInstanceOf(LonLat);
expect(lonlat.lon).toBeCloseTo(0, 5); expect(lonlat.lon).toBeCloseTo(0, 5);
expect(lonlat.lat).toBeCloseTo(0, 5); expect(lonlat.lat).toBeCloseTo(0, 5);

View File

@ -1,6 +1,6 @@
import { LonLat } from "../../src/og/LonLat"; import { LonLat } from "../../src/og/LonLat";
import { Vec3 } from "../../src/og/math/Vec3"; import { Vec3 } from "../../src/og/math/Vec3";
import { Ellipsoid } from "../../src/og/ellipsoid/Ellipsoid.js"; import { Ellipsoid } from "../../src/og/ellipsoid/Ellipsoid";
import { wgs84 } from "../../src/og/ellipsoid/wgs84"; import { wgs84 } from "../../src/og/ellipsoid/wgs84";
test('Testing Ellipsoid Vincenty direct to inverse formulas', () => { test('Testing Ellipsoid Vincenty direct to inverse formulas', () => {

View File

@ -11,7 +11,7 @@ import {
randomi, randomi,
step, step,
getAngleBetweenAzimuths getAngleBetweenAzimuths
} from "../src/og/math.js"; } from "../src/og/math";
describe('math module', () => { describe('math module', () => {
describe('log', () => { describe('log', () => {