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

Calculate oriented bounding box from bounding region for 3D tiles of Cesium's OSM buildings #40

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1e0b40a
ported methods:
sraimund Dec 26, 2024
37ea8d8
partly ported class 'EllipsoidTangentPlane' from Cesium
sraimund Dec 26, 2024
798782e
ported constant from Cesium:
sraimund Dec 26, 2024
ad9d391
ported methods from Cesium:
sraimund Dec 26, 2024
2e836a7
ported methods from Cesium:
sraimund Dec 26, 2024
fc7bbcc
partly ported class 'Rectangle' from Cesium
sraimund Dec 26, 2024
dc5e8dc
partly ported class 'Ray' from Cesium
sraimund Dec 26, 2024
fc2d667
ported method from Cesium:
sraimund Dec 26, 2024
361f7c5
export ported classes
sraimund Dec 26, 2024
a4c6bfb
added geospatial module for Rectangle calculations
sraimund Dec 26, 2024
bd15973
fix: reuse OBBs properties
sraimund Dec 30, 2024
1f6013c
Merge branch 'master' into master
ibgreen Jan 4, 2025
2222cc5
remove types from TSdoc
sraimund Jan 6, 2025
801904f
reuse parent method
sraimund Jan 6, 2025
5c2bd42
global functions makeOrientedBoundingBoxFromRegion() and intersectPla…
sraimund Jan 6, 2025
ae5cef2
rename Rectangle to GeoRectangle
sraimund Jan 6, 2025
0f89190
tests ported
sraimund Jan 6, 2025
d283930
minimal tests added
sraimund Jan 6, 2025
c8f8f7a
Merge remote-tracking branch 'origin/master'
sraimund Jan 6, 2025
2cb1e6b
replace multiplyByVector() by transform()
sraimund Jan 6, 2025
e851a2a
chore: Bump lerna to 4.2.0-alpha.0. Fix CI. Modernize dependencies. (…
ibgreen Jan 4, 2025
f07f502
feat(geospatial): Add makeOBBFromRegion() (#43)
ibgreen Jan 4, 2025
409d06f
v4.2.0-alpha.1
ibgreen Jan 4, 2025
8614fbd
build(deps): bump nanoid from 3.3.7 to 3.3.8 (#39)
dependabot[bot] Jan 4, 2025
c36934c
chore: Fix CI workflows (#46)
ibgreen Jan 4, 2025
e261b33
v4.2.0-alpha.2
ibgreen Jan 4, 2025
8ac014d
chore: Fix CI release action (#47)
ibgreen Jan 4, 2025
b76d955
v4.2.0-alpha.3
ibgreen Jan 4, 2025
26bc24b
moved from culling to geospatial
sraimund Jan 14, 2025
3a838e7
use normalizeAngle() instead of negativePiToPi()
sraimund Jan 14, 2025
cf81329
use normalizeAngle() instead of negativePiToPi() and zeroToTwoPi(), s…
sraimund Jan 14, 2025
2759906
moved from culling to geospatial
sraimund Jan 14, 2025
d709cc9
remove duplicate methods
sraimund Jan 14, 2025
c6a3cfe
adjust exports and imports
sraimund Jan 14, 2025
5e08ff2
removed in favor of geo-rectangle
sraimund Jan 14, 2025
744c5ef
removed in favor of keeping method in culling module
sraimund Jan 14, 2025
28d4faa
tests for EllipsoidTangentPlane
sraimund Jan 14, 2025
ae64150
amend tsdoc
sraimund Jan 14, 2025
717ae2e
adjust version
sraimund Jan 14, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
check_branch:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
outputs:
should_build: ${{ steps.permitted.outputs.result }}

Expand All @@ -30,7 +30,7 @@ jobs:
echo "result=${result}" >> "$GITHUB_OUTPUT"
release:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs: check_branch
permissions:
contents: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
check_branch:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
outputs:
should_deploy: ${{ endsWith(github.ref, steps.get_version.outputs.latest) }}

Expand Down
2 changes: 1 addition & 1 deletion .ocularrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {resolve} from 'path';

export default {
lint: {
paths: ['dev-docs', 'docs', 'modules', 'examples', 'test'], // 'website'
paths: ['dev-docs', 'docs', 'modules', 'test'], // 'examples', 'website'
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx', 'd.ts', 'md']
},

Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# CHANGELOG

## v4.2.0-alpha.3

- chore: Fix CI release action (#47)

## v4.2.0-alpha.2

- chore: Fix CI workflows (#46)
- build(deps): bump nanoid from 3.3.7 to 3.3.8 (#39)

## v4.2.0-alpha.1

- feat(geospatial): Add makeOBBFromRegion() (#43) (Co-authored-by: Raimund Schnürer <[email protected]>)
- chore: Bump lerna to 4.2.0-alpha.0. Fix CI. Modernize dependencies. (#41)
- build(deps): bump vite from 4.5.3 to 4.5.5 (#34)
- chore: Fix website build (#33)

## v4.1.0

- Website home page pass
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/core/api-reference/matrix.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Matrix

`Matrix` is a base class for [`Matrix3`](./docs/modules/core/api-reference/vector3) and [`Matrix4`](./docs/modules/core/api-reference/vector4), providing common methods to those classes.
`Matrix` is a base class for [`Matrix3`](/docs/modules/core/api-reference/vector3) and [`Matrix4`](/docs/modules/core/api-reference/vector4), providing common methods to those classes.

## Methods

Expand Down
10 changes: 8 additions & 2 deletions docs/whats-new.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@
</tbody>
</table>

## v5.0 (In planning stage)
## v5.0 (In planning)

Release Date: TBD, maybe Q4, 2024.
Release Date: TBD, maybe Q2, 2025.

Goal: Stronger type guarantees for math classes via the new sized array types.

## v4.2 (In development)

Release Date: TBD, maybe Q1, 2024.

Goal: Minor functionality additions, as required.

## v4.1

Release Date: Sep 7, 2024.
Expand Down
File renamed without changes.
29 changes: 6 additions & 23 deletions examples/benchmarks/index.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
<!doctype html>
<html>
<head>
<meta charset='UTF-8' />
<title>math.gl benchmarks</title>
<style>
body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 13px;
-webkit-font-smoothing: antialiased;
margin:0;
padding:0;
overflow:auto;
}
</style>
</head>
<body/>
<div id="app"></div>
<script src='./app.js'></script>
</body>
<script type="text/javascript">
App.renderToDOM(document.getElementById('app'));
</script>
</html>
<script type="module">
import {renderToDOM} from './app.tsx';
renderToDOM(document.body);
</script>
<body style="margin: 0;">
</body>
18 changes: 6 additions & 12 deletions examples/benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,19 @@
"license": "MIT",
"private": true,
"scripts": {
"start": "webpack-dev-server --progress --hot --open",
"start-local": "webpack-dev-server --env.local --progress --hot --open",
"generate": "node ./generate-index/index.js"
"start": "vite",
"build": "tsc && vite build",
"serve": "vite preview"
},
"dependencies": {
"@math.gl/core": "4.1.0-alpha.9",
"@probe.gl/bench": "^4.0.0",
"@probe.gl/react-bench": "^4.0.0",
"react": "^16.3.0",
"react-dom": "^16.3.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.4.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.5",
"css-loader": "^2.1.1",
"style-loader": "^0.23.1",
"webpack": "^5.94.0",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.11"
"typescript": "^5.5.0",
"vite": "^5.0.0"
}
}
18 changes: 18 additions & 0 deletions examples/benchmarks/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import fs from 'fs/promises';
import {defineConfig} from 'vite';

/** @see https://vitejs.dev/config/ */
export default defineConfig(async () => ({
resolve: {alias: await getAliases('@math.gl', `${__dirname}/../..`)},
server: {open: true}
}));

/** Run against local source */
const getAliases = async (frameworkName, frameworkRootDir) => {
const modules = await fs.readdir(`${frameworkRootDir}/modules`);
const aliases = {};
for (const module of modules) {
aliases[`${frameworkName}/${module}`] = `${frameworkRootDir}/modules/${module}/src`;
}
return aliases;
};
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "4.1.0-alpha.9",
"version": "4.2.0-alpha.3",
"npmClient": "yarn",
"exact": true,
"packages": [
Expand Down
4 changes: 2 additions & 2 deletions modules/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"publishConfig": {
"access": "public"
},
"version": "4.1.0-alpha.9",
"version": "4.2.0-alpha.3",
"keywords": [
"webgl",
"javascript",
Expand Down Expand Up @@ -45,7 +45,7 @@
"./src/lib/common.js"
],
"dependencies": {
"@math.gl/types": "4.1.0-alpha.9"
"@math.gl/types": "4.2.0-alpha.3"
},
"gitHead": "e1a95300cb225a90da6e90333d4adf290f7ba501"
}
15 changes: 15 additions & 0 deletions modules/core/src/classes/matrix3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import {NumericArray, NumericArray9} from '@math.gl/types';
import {Matrix} from './base/matrix';
import {Vector3} from './vector3';
import {checkVector} from '../lib/validators';

import {vec4_transformMat3} from '../lib/gl-matrix-extras';
Expand Down Expand Up @@ -202,6 +203,20 @@ export class Matrix3 extends Matrix {
return this.check();
}

/**
* Computes the product of this matrix times a (non-uniform) scale, as if the scale were a scale matrix.
*
* @param scale The non-uniform scale on the right-hand side.
* @returns The modified result parameter.
*/
multiplyByScale(scale: Vector3): Matrix3 {
const x = scale.x;
const y = scale.y;
const z = scale.z;

return super.scale([x, x, x, y, y, y, z, z, z]);
}

rotate(radians: number): this {
mat3_rotate(this, this, radians);
return this.check();
Expand Down
2 changes: 2 additions & 0 deletions modules/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export {
// math.gl global utility methods
config,
configure,
safeMod,
normalizeAngle,
formatValue,
isArray,
clone,
Expand Down
68 changes: 68 additions & 0 deletions modules/core/src/lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import type {NumericArray} from '@math.gl/types';

import type {MathArray} from '../classes/base/math-array';
import {EPSILON14, TWO_PI, PI} from './math-utils';

const RADIANS_TO_DEGREES = (1 / Math.PI) * 180;
const DEGREES_TO_RADIANS = (1 / 180) * Math.PI;
Expand Down Expand Up @@ -122,6 +123,73 @@ export function degrees(
return map(radians, (radians) => radians * RADIANS_TO_DEGREES, result);
}


/**
* The modulo operation that also works for negative dividends.
*
* @param m The dividend.
* @param n The divisor.
* @returns The remainder.
*/
export function safeMod(m: number, n: number): number {
if (Math.sign(m) === Math.sign(n) && Math.abs(m) < Math.abs(n)) {
return m;
}

return ((m % n) + n) % n;
}

/**
* Produces an angle restricted to its equivalent in a normalized range
*
* @param angle in radians
* @param range 'zero-to-two-pi' - in the range 0 <= angle <= 2PI, | 'negative-pi-to-pi' - -Pi <= angle <= Pi
* @returns The angle in the range [0, <code>TWO_PI</code>] or [<code>-PI</code>, <code>PI</code>]..
*/
export function normalizeAngle(
angle: number,
range: 'zero-to-two-pi' | 'negative-pi-to-pi'
): number {
switch (range) {
case 'negative-pi-to-pi':
return negativePiToPi(angle);
case 'zero-to-two-pi':
return zeroToTwoPi(angle);
default:
return angle;
}
}

/**
* Produces an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle.
*
* @param angle in radians
* @returns The angle in the range [0, <code>TWO_PI</code>].
*/
function zeroToTwoPi(angle: number): number {
if (angle >= 0 && angle <= TWO_PI) {
return angle;
}
const remainder = safeMod(angle, TWO_PI);
if (Math.abs(remainder) < EPSILON14 && Math.abs(angle) > EPSILON14) {
return TWO_PI;
}
return remainder;
}

/**
* Produces an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle.
*
* @param angle in radians
* @returns The angle in the range [<code>-PI</code>, <code>PI</code>].
*/
function negativePiToPi(angle: number): number {
if (angle >= -PI && angle <= PI) {
return angle;
}
return zeroToTwoPi(angle + PI) - PI;
}

/**
* "GLSL equivalent" of `Math.sin`: Works on single values and vectors
* @deprecated
Expand Down
1 change: 1 addition & 0 deletions modules/core/src/lib/math-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export const PI_OVER_TWO = Math.PI / 2;
export const PI_OVER_FOUR = Math.PI / 4;
export const PI_OVER_SIX = Math.PI / 6;

export const PI = Math.PI;
export const TWO_PI = Math.PI * 2;
Loading