Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
- `scene.drillPick` now uses a breadth-first search strategy instead of depth-first. This may change which entities are picked when
using large values of `width` and `height` when providing a `limit`, prioritizing entities closer to the camera.

#### Additions :tada:

- Matrices are now backed by `Float64Array`'s, making operations up to 2x faster, resulting in performance improvements across the board. [#12973](https://github.com/CesiumGS/cesium/pull/12973)

#### Fixes :wrench:

- Fix issues with label background when updating properties while `label.show` is `false`. [#12138](https://github.com/CesiumGS/cesium/issues/12138)
Expand Down
86 changes: 45 additions & 41 deletions packages/engine/Source/Core/Matrix3.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Cartesian3 from "./Cartesian3.js";
import Check from "./Check.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
import freezeMatrix from "./freezeMatrix.js";
import CesiumMath from "./Math.js";

/**
Expand Down Expand Up @@ -35,28 +36,30 @@ import CesiumMath from "./Math.js";
* @see Matrix2
* @see Matrix4
*/
function Matrix3(
column0Row0,
column1Row0,
column2Row0,
column0Row1,
column1Row1,
column2Row1,
column0Row2,
column1Row2,
column2Row2,
) {
this[0] = column0Row0 ?? 0.0;
this[1] = column0Row1 ?? 0.0;
this[2] = column0Row2 ?? 0.0;
this[3] = column1Row0 ?? 0.0;
this[4] = column1Row1 ?? 0.0;
this[5] = column1Row2 ?? 0.0;
this[6] = column2Row0 ?? 0.0;
this[7] = column2Row1 ?? 0.0;
this[8] = column2Row2 ?? 0.0;
class Matrix3 extends Float64Array {
constructor(
column0Row0,
column1Row0,
column2Row0,
column0Row1,
column1Row1,
column2Row1,
column0Row2,
column1Row2,
column2Row2,
) {
super(9);
this[0] = column0Row0 ?? 0.0;
this[1] = column0Row1 ?? 0.0;
this[2] = column0Row2 ?? 0.0;
this[3] = column1Row0 ?? 0.0;
this[4] = column1Row1 ?? 0.0;
this[5] = column1Row2 ?? 0.0;
this[6] = column2Row0 ?? 0.0;
this[7] = column2Row1 ?? 0.0;
this[8] = column2Row2 ?? 0.0;
}
}

/**
* The number of elements used to pack the object into an array.
* @type {number}
Expand Down Expand Up @@ -1665,26 +1668,6 @@ Matrix3.equalsEpsilon = function (left, right, epsilon) {
);
};

/**
* An immutable Matrix3 instance initialized to the identity matrix.
*
* @type {Matrix3}
* @constant
*/
Matrix3.IDENTITY = Object.freeze(
new Matrix3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0),
);

/**
* An immutable Matrix3 instance initialized to the zero matrix.
*
* @type {Matrix3}
* @constant
*/
Matrix3.ZERO = Object.freeze(
new Matrix3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
);

/**
* The index into Matrix3 for column 0, row 0.
*
Expand Down Expand Up @@ -1835,4 +1818,25 @@ Matrix3.prototype.toString = function () {
`(${this[2]}, ${this[5]}, ${this[8]})`
);
};

/**
* An immutable Matrix3 instance initialized to the identity matrix.
*
* @type {Readonly<Matrix3>}
* @constant
*/
Matrix3.IDENTITY = freezeMatrix(
new Matrix3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0),
);

/**
* An immutable Matrix3 instance initialized to the zero matrix.
*
* @type {Readonly<Matrix3>}
* @constant
*/
Matrix3.ZERO = freezeMatrix(
new Matrix3(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
);

export default Matrix3;
Loading