Skip to content

Commit

Permalink
Deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ib Green committed Jun 10, 2019
1 parent ab1f563 commit 1b4916a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
10 changes: 6 additions & 4 deletions docs/upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## Upgrading to v3.0

#### `Matrix` transforms now return `Array` by default
#### Matrix API changes

* Matrix setter functions no longer support ommitted parameters. (Motivation: Increased API rigor, improved debugging and library compactness).

#### `Matrix` transforms now return `Array`s by default

The `Matrix4` and `Matrix3` classes no longer by default create new `Vector2`, `Vector3` and `Vector4` instances. Instead they create standard JavaScript arrays.

Expand All @@ -29,14 +33,12 @@ assert(vector instanceof Vector4);

Motivation: This change reduces dependencies between math.gl core classes which improves tree-shaking and bundle sizes.

### Matrix setter functions no longer support ommitted parameters

Motivation: This change increases rigor, facilitates debugging, and improves library compactness, and the use case for default parameters was questionable.

#### Deprecations

| Method | Replacement | Reason |
| --- | --- | --- |
| `Matrix*.setColumnMajor` | `Matrix*.set` | API simplification |
| `Matrix4.transformPoint` | `Matrix4.transform` | Name alignment |
| `Matrix4.transformVector` | `Matrix4.transform` | Name alignment |
| `Matrix4.transformDirection` | `Matrix4.transformAsVector` | Name alignment |
Expand Down
18 changes: 6 additions & 12 deletions modules/core/src/classes/base/matrix.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import MathArray from './math-array';
import {checkNumber} from '../../lib/validators';
import {checkNumber, deprecated} from '../../lib/validators';
import {config} from '../../lib/common';

export default class Matrix extends MathArray {
Expand Down Expand Up @@ -37,17 +37,6 @@ export default class Matrix extends MathArray {
return this.copy(arguments);
}

// accepts row major order, stores as column major
setTransposed() {
const {RANK} = this;
for (let row = 0; row < RANK; row++) {
for (let col = 0; col < RANK; col++) {
this[row * RANK + col] = arguments[col * RANK + row];
}
}
return this.check();
}

toColumnMajor(result) {
return this.toArray(result);
}
Expand Down Expand Up @@ -88,4 +77,9 @@ export default class Matrix extends MathArray {
multiplyMatrices(a, b) {
return this.copy(a).multiplyRight(b);
}

setColumnMajor() {
deprecated('Matrix.setColumnMajor', '3.0');
return this.set(arguments);
}
}

0 comments on commit 1b4916a

Please sign in to comment.