Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ocular-dev-tools #309

Merged
merged 3 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
dist/
coverage/
test/
*.md
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const config = deepMerge(defaultConfig, {
overrides: [
{
// scripts use devDependencies
files: ['**/test/**/*.js', '**/scripts/**/*.js', '*.config.js', '*.config.local.js'],
files: ['**/test/**/*.ts', '**/scripts/**/*.js', '*.config.js', '*.config.local.js'],
rules: {
'import/no-unresolved': 0,
'import/no-extraneous-dependencies': 0
Expand Down
20 changes: 15 additions & 5 deletions .ocularrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@ module.exports = {
},

entry: {
test: 'test/node.js',
'test-browser': 'test/browser.js',
bench: 'test/bench/node.js',
'bench-browser': 'test/bench/browser.js',
size: 'test/size/import-nothing.js'
test: 'test/node.ts',
'test-browser': 'test/browser.ts',
bench: 'test/bench/node.ts',
'bench-browser': 'test/bench/browser.ts',
size: [
'test/size/core.js',
'test/size/vector3.js',
'test/size/matrix4.js',
'test/size/quaternion.js',
'test/size/culling.js',
'test/size/geospatial.js',
'test/size/polygon.js',
'test/size/sun.js',
'test/size/web-mercator.js'
]
}
};
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
<title>math.gl tests</title>
</head>
<body>
<script src='test-browser-bundle.js'></script>
</body>
</html>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
import {Vector3} from '@math.gl/core';

class ObjectVector {
x: number;
y: number;
z: number;

constructor(x = -0, y = -0, z = -0) {
this.x = x;
this.y = y;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@ const IDENTITY = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1];

class ClassNoConstructor {}
class ClassWithConstructor {
data: any;

constructor() {
this.data = null;
}
}
class ClassWithConstructorXYZ {
x: number;
y: number;
z: number;
w: number;

constructor() {
this.x = -0;
this.y = -0;
Expand Down Expand Up @@ -46,6 +53,10 @@ class ArrayExtender extends Array {
// DEFAULT PARAMETERS

class XYZVector {
x: number;
y: number;
z: number;

constructor(x = 0, y = 0, z = 0) {
this.x = x;
this.y = y;
Expand All @@ -54,18 +65,26 @@ class XYZVector {
}

class XYZVectorLogicalOr {
constructor(x, y, z) {
x: number;
y: number;
z: number;

constructor(x?: number, y?: number, z?: number) {
this.x = x || 0;
this.y = y || 0;
this.z = z || 0;
}
}

class XYZVectorBitwiseOr {
constructor(x, y, z) {
this.x = x || 0;
this.y = y || 0;
this.z = z || 0;
x: number;
y: number;
z: number;

constructor(x?: number, y?: number, z?: number) {
this.x = x | 0;
this.y = y | 0;
this.z = z | 0;
}
}

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ function makeRotationY(angle) {
return new Matrix3([cosAngle, 0.0, sinAngle, 0.0, 1.0, 0.0, -sinAngle, 0.0, cosAngle]);
}

function makeRotationZ(angle, result) {
function makeRotationZ(angle) {
const cosAngle = Math.cos(angle);
const sinAngle = Math.sin(angle);
return new Matrix3([cosAngle, -sinAngle, 0.0, sinAngle, cosAngle, 0.0, 0.0, 0.0, 1.0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ test('Plane#transforms a plane according to a transform', (t) => {
const transformedPlane = plane.clone().transform(transform);

tapeEquals(t, transformedPlane.distance, plane.distance * 2.0);
tapeEquals(t, transformedPlane.normal, [-normal.x, normal.y, -normal.z], _MathUtils.EPSILON10);
tapeEquals(
t,
transformedPlane.normal,
[-normal.x, normal.y, -normal.z],
'epsilon:' + _MathUtils.EPSILON10
);

t.end();
});
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {promises as fs} from 'fs';
import fs from 'fs';

export async function openFile(filePath) {
let data = null;
if (typeof fetch !== 'undefined') {
const request = await fetch(filePath);
data = new Uint8Array(await request.arrayBuffer());
} else if (fs) {
data = await fs.readFile(filePath);
data = await fs.promises.readFile(filePath);
}
return data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import {
toCartographicFromRadians
} from '../src/type-utils';

import ellipsoidBench from '@math.gl/geospatial/test/ellipsoid/ellipsoid.bench';
import ellipsoidBench from './ellipsoid/ellipsoid.bench';

class ObjectVector {
x: number;
y: number;
z: number;

constructor(x = 0, y = 0, z = 0) {
this.x = x;
this.y = y;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
// @ts-nocheck
import {earcut, Polygon, modifyPolygonWindingDirection, WINDING} from '@math.gl/polygon';
import {toNested} from './utils.js';
import {toNested} from './utils';

const polygonSmall = [0, 0, 1, 1, 0, 2, -1, 1, -1.25, 0.5, 0, 0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

*/

import {promises as fs} from 'fs';
import fs from 'fs';
import {resolve} from 'path';
import test from 'tape-promise/tape';
import {earcut} from '@math.gl/polygon';
Expand Down Expand Up @@ -49,7 +49,7 @@ async function openFile(filePath) {
const request = await fetch(filePath);
data = await request.json();
} else if (fs) {
data = await fs.readFile(filePath);
data = await fs.promises.readFile(filePath);
data = JSON.parse(data.toString());
}
return data;
Expand All @@ -59,7 +59,7 @@ const FIXTURES_PATH = 'modules/polygon/test/data/earcut/fixtures/';

Object.keys(expected.triangles).forEach((id) => {
test(id, async (t) => {
const filepath = resolve(FIXTURES_PATH, `${id}.json`);
const filepath = FIXTURES_PATH + `${id}.json`;
const raw = await openFile(filepath);
const data = flatten(raw);
const indices = earcut(data.vertices, data.holes, data.dimensions);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable max-statements */
import test from 'tape-promise/tape';
import {tapeEquals} from 'test/utils/tape-assertions';
import {toNested} from './utils.js';
import {toNested} from './utils';

import {configure} from '@math.gl/core';
import {_Polygon as Polygon, WINDING} from '@math.gl/polygon';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions modules/web-mercator/test/browser.js

This file was deleted.

19 changes: 0 additions & 19 deletions modules/web-mercator/test/index.js

This file was deleted.

20 changes: 20 additions & 0 deletions modules/web-mercator/test/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Mercator Utils
import './spec/web-mercator-utils.spec';
// Perspective Viewport test cases
import './spec/web-mercator-viewport.spec';
// Specific mercator test cases
import './spec/mercator-project-unproject.spec';
// Get bounds
import './spec/get-bounds.spec';
// Fit bounds
import './spec/fit-bounds.spec';
// Normalization
import './spec/normalize-viewport-props.spec';
// Fly to
import './spec/fly-to-viewport.spec';
// Compare FP32 and Offset
import './fp32-limits';

// Test vs. mapbox Transform
import './spec/versus-mapbox/mapbox-node-polyfill';
import './spec/versus-mapbox/versus-mapbox.spec';
12 changes: 0 additions & 12 deletions modules/web-mercator/test/node.js

This file was deleted.

3 changes: 0 additions & 3 deletions modules/web-mercator/test/size/import-nothing.js

This file was deleted.

Loading