Pārlūkot izejas kodu

Temporarily add Matrix2

master
Palash Bansal pirms 1 gada
vecāks
revīzija
dda99a29c0
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
3 mainītis faili ar 113 papildinājumiem un 1 dzēšanām
  1. 2
    1
      src/three/Threejs.ts
  2. 54
    0
      src/three/math/Matrix2.d.ts
  3. 57
    0
      src/three/math/Matrix2.js

+ 2
- 1
src/three/Threejs.ts Parādīt failu

@@ -168,6 +168,7 @@ export {Sphere} from 'three'
export {Ray} from 'three'
export {Matrix4} from 'three'
export {Matrix3} from 'three'
export {Matrix2} from './math/Matrix2'
export {Box3} from 'three'
export {Box2} from 'three'
export {Line3} from 'three'
@@ -235,4 +236,4 @@ export {GLTFExporter} from 'three/examples/jsm/exporters/GLTFExporter'
export {OrbitControls} from 'three/examples/jsm/controls/OrbitControls.js'
export * from 'three/examples/jsm/utils/BufferGeometryUtils.js'
export type {Event, EventListener, EventListener2} from 'three'
export type {MeshPhysicalMaterialParameters, MeshBasicMaterialParameters, MaterialParameters} from 'three'
export type {MeshPhysicalMaterialParameters, MeshBasicMaterialParameters, MaterialParameters} from 'three'

+ 54
- 0
src/three/math/Matrix2.d.ts Parādīt failu

@@ -0,0 +1,54 @@
/* eslint-disable */
export type Matrix2Tuple = [
n11: number,
n12: number,
n21: number,
n22: number,
];

/**
* A class representing a 2x2 {@link https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix}.
*
* @example
* const m = new Matrix2();
*/
export class Matrix2 {
readonly isMatrix2: true;

/**
* A {@link https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major} list of matrix values.
*/
elements: Matrix2Tuple;

/**
* Creates a 2x2 {@link https://en.wikipedia.org/wiki/Identity_matrix identity matrix}.
*/
constructor();

/**
* Creates a 2x2 matrix with the given arguments in row-major order.
*/
constructor(n11: number, n12: number, n21: number, n22: number);

/**
* Resets this matrix to the 2x2 identity matrix:
*/
identity(): this;

/**
* Sets the elements of this matrix based on an array in
* {@link https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major} format.
*
* @param array the array to read the elements from
* @param offset (optional) index of first element in the array. Default is `0`.
*/
fromArray(array: ArrayLike<number>, offset?: number): this;

/**
* Sets the 2x2 matrix values to the given
* {@link https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major} sequence of values:
* [n11, n12,
* n21, n22]
*/
set(n11: number, n12: number, n21: number, n22: number): this;
}

+ 57
- 0
src/three/math/Matrix2.js Parādīt failu

@@ -0,0 +1,57 @@
/* eslint-disable */
export class Matrix2 {

constructor(n11, n12, n21, n22) {

Matrix2.prototype.isMatrix2 = true

this.elements = [
1, 0,
0, 1,
]

if (n11 !== undefined) {

this.set(n11, n12, n21, n22)

}

}

identity() {

this.set(
1, 0,
0, 1,
)

return this

}

fromArray(array, offset = 0) {

for (let i = 0; i < 4; i++) {

this.elements[i] = array[i + offset]

}

return this

}

set(n11, n12, n21, n22) {

const te = this.elements

te[0] = n11
te[2] = n12
te[1] = n21
te[3] = n22

return this

}

}

Notiek ielāde…
Atcelt
Saglabāt