@luma.gl/shadertools 9.0.0 → 9.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +199 -75
- package/dist/dist.min.js +8 -8
- package/dist.min.js +3758 -0
- package/package.json +3 -3
package/dist/dist.dev.js
CHANGED
|
@@ -7845,17 +7845,11 @@ vec3 geometry_getNormal() {
|
|
|
7845
7845
|
printRowMajor: true,
|
|
7846
7846
|
_cartographicRadians: false
|
|
7847
7847
|
};
|
|
7848
|
-
globalThis.mathgl = globalThis.mathgl || {
|
|
7849
|
-
config: {
|
|
7850
|
-
...DEFAULT_CONFIG
|
|
7851
|
-
}
|
|
7852
|
-
};
|
|
7848
|
+
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
7853
7849
|
var config = globalThis.mathgl.config;
|
|
7854
|
-
function formatValue(value, {
|
|
7855
|
-
precision = config.precision
|
|
7856
|
-
} = {}) {
|
|
7850
|
+
function formatValue(value, { precision = config.precision } = {}) {
|
|
7857
7851
|
value = round(value);
|
|
7858
|
-
return
|
|
7852
|
+
return `${parseFloat(value.toPrecision(precision))}`;
|
|
7859
7853
|
}
|
|
7860
7854
|
function isArray(value) {
|
|
7861
7855
|
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
@@ -7899,28 +7893,12 @@ vec3 geometry_getNormal() {
|
|
|
7899
7893
|
}
|
|
7900
7894
|
|
|
7901
7895
|
// ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
ExtendableBuiltin.prototype = Object.create(cls.prototype, {
|
|
7909
|
-
constructor: {
|
|
7910
|
-
value: cls,
|
|
7911
|
-
enumerable: false,
|
|
7912
|
-
writable: true,
|
|
7913
|
-
configurable: true
|
|
7914
|
-
}
|
|
7915
|
-
});
|
|
7916
|
-
if (Object.setPrototypeOf) {
|
|
7917
|
-
Object.setPrototypeOf(ExtendableBuiltin, cls);
|
|
7918
|
-
} else {
|
|
7919
|
-
ExtendableBuiltin.__proto__ = cls;
|
|
7920
|
-
}
|
|
7921
|
-
return ExtendableBuiltin;
|
|
7922
|
-
}
|
|
7923
|
-
var MathArray = class extends _extendableBuiltin(Array) {
|
|
7896
|
+
var MathArray = class extends Array {
|
|
7897
|
+
// Common methods
|
|
7898
|
+
/**
|
|
7899
|
+
* Clone the current object
|
|
7900
|
+
* @returns a new copy of this object
|
|
7901
|
+
*/
|
|
7924
7902
|
clone() {
|
|
7925
7903
|
return new this.constructor().copy(this);
|
|
7926
7904
|
}
|
|
@@ -7940,7 +7918,10 @@ vec3 geometry_getNormal() {
|
|
|
7940
7918
|
return targetObject;
|
|
7941
7919
|
}
|
|
7942
7920
|
from(arrayOrObject) {
|
|
7943
|
-
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) :
|
|
7921
|
+
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
|
|
7922
|
+
// @ts-ignore
|
|
7923
|
+
this.fromObject(arrayOrObject)
|
|
7924
|
+
);
|
|
7944
7925
|
}
|
|
7945
7926
|
to(arrayOrObject) {
|
|
7946
7927
|
if (arrayOrObject === this) {
|
|
@@ -7951,18 +7932,20 @@ vec3 geometry_getNormal() {
|
|
|
7951
7932
|
toTarget(target) {
|
|
7952
7933
|
return target ? this.to(target) : this;
|
|
7953
7934
|
}
|
|
7935
|
+
/** @deprecated */
|
|
7954
7936
|
toFloat32Array() {
|
|
7955
7937
|
return new Float32Array(this);
|
|
7956
7938
|
}
|
|
7957
7939
|
toString() {
|
|
7958
7940
|
return this.formatString(config);
|
|
7959
7941
|
}
|
|
7942
|
+
/** Formats string according to options */
|
|
7960
7943
|
formatString(opts) {
|
|
7961
7944
|
let string = "";
|
|
7962
7945
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
7963
7946
|
string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
|
|
7964
7947
|
}
|
|
7965
|
-
return
|
|
7948
|
+
return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
|
|
7966
7949
|
}
|
|
7967
7950
|
equals(array) {
|
|
7968
7951
|
if (!array || this.length !== array.length) {
|
|
@@ -7986,6 +7969,8 @@ vec3 geometry_getNormal() {
|
|
|
7986
7969
|
}
|
|
7987
7970
|
return true;
|
|
7988
7971
|
}
|
|
7972
|
+
// Modifiers
|
|
7973
|
+
/** Negates all values in this object */
|
|
7989
7974
|
negate() {
|
|
7990
7975
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
7991
7976
|
this[i] = -this[i];
|
|
@@ -8003,12 +7988,14 @@ vec3 geometry_getNormal() {
|
|
|
8003
7988
|
}
|
|
8004
7989
|
return this.check();
|
|
8005
7990
|
}
|
|
7991
|
+
/** Minimal */
|
|
8006
7992
|
min(vector) {
|
|
8007
7993
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8008
7994
|
this[i] = Math.min(vector[i], this[i]);
|
|
8009
7995
|
}
|
|
8010
7996
|
return this.check();
|
|
8011
7997
|
}
|
|
7998
|
+
/** Maximal */
|
|
8012
7999
|
max(vector) {
|
|
8013
8000
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8014
8001
|
this[i] = Math.max(vector[i], this[i]);
|
|
@@ -8049,18 +8036,25 @@ vec3 geometry_getNormal() {
|
|
|
8049
8036
|
}
|
|
8050
8037
|
return this.check();
|
|
8051
8038
|
}
|
|
8039
|
+
/**
|
|
8040
|
+
* Multiplies all elements by `scale`
|
|
8041
|
+
* Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
|
|
8042
|
+
*/
|
|
8052
8043
|
multiplyByScalar(scalar) {
|
|
8053
8044
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8054
8045
|
this[i] *= scalar;
|
|
8055
8046
|
}
|
|
8056
8047
|
return this.check();
|
|
8057
8048
|
}
|
|
8049
|
+
// Debug checks
|
|
8050
|
+
/** Throws an error if array length is incorrect or contains illegal values */
|
|
8058
8051
|
check() {
|
|
8059
8052
|
if (config.debug && !this.validate()) {
|
|
8060
|
-
throw new Error(
|
|
8053
|
+
throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
|
|
8061
8054
|
}
|
|
8062
8055
|
return this;
|
|
8063
8056
|
}
|
|
8057
|
+
/** Returns false if the array length is incorrect or contains illegal values */
|
|
8064
8058
|
validate() {
|
|
8065
8059
|
let valid = this.length === this.ELEMENTS;
|
|
8066
8060
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
@@ -8068,39 +8062,48 @@ vec3 geometry_getNormal() {
|
|
|
8068
8062
|
}
|
|
8069
8063
|
return valid;
|
|
8070
8064
|
}
|
|
8065
|
+
// three.js compatibility
|
|
8066
|
+
/** @deprecated */
|
|
8071
8067
|
sub(a) {
|
|
8072
8068
|
return this.subtract(a);
|
|
8073
8069
|
}
|
|
8070
|
+
/** @deprecated */
|
|
8074
8071
|
setScalar(a) {
|
|
8075
8072
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8076
8073
|
this[i] = a;
|
|
8077
8074
|
}
|
|
8078
8075
|
return this.check();
|
|
8079
8076
|
}
|
|
8077
|
+
/** @deprecated */
|
|
8080
8078
|
addScalar(a) {
|
|
8081
8079
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8082
8080
|
this[i] += a;
|
|
8083
8081
|
}
|
|
8084
8082
|
return this.check();
|
|
8085
8083
|
}
|
|
8084
|
+
/** @deprecated */
|
|
8086
8085
|
subScalar(a) {
|
|
8087
8086
|
return this.addScalar(-a);
|
|
8088
8087
|
}
|
|
8088
|
+
/** @deprecated */
|
|
8089
8089
|
multiplyScalar(scalar) {
|
|
8090
8090
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8091
8091
|
this[i] *= scalar;
|
|
8092
8092
|
}
|
|
8093
8093
|
return this.check();
|
|
8094
8094
|
}
|
|
8095
|
+
/** @deprecated */
|
|
8095
8096
|
divideScalar(a) {
|
|
8096
8097
|
return this.multiplyByScalar(1 / a);
|
|
8097
8098
|
}
|
|
8099
|
+
/** @deprecated */
|
|
8098
8100
|
clampScalar(min, max) {
|
|
8099
8101
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8100
8102
|
this[i] = Math.min(Math.max(this[i], min), max);
|
|
8101
8103
|
}
|
|
8102
8104
|
return this.check();
|
|
8103
8105
|
}
|
|
8106
|
+
/** @deprecated */
|
|
8104
8107
|
get elements() {
|
|
8105
8108
|
return this;
|
|
8106
8109
|
}
|
|
@@ -8120,13 +8123,13 @@ vec3 geometry_getNormal() {
|
|
|
8120
8123
|
}
|
|
8121
8124
|
function checkNumber(value) {
|
|
8122
8125
|
if (!Number.isFinite(value)) {
|
|
8123
|
-
throw new Error(
|
|
8126
|
+
throw new Error(`Invalid number ${JSON.stringify(value)}`);
|
|
8124
8127
|
}
|
|
8125
8128
|
return value;
|
|
8126
8129
|
}
|
|
8127
8130
|
function checkVector(v, length, callerName = "") {
|
|
8128
8131
|
if (config.debug && !validateVector(v, length)) {
|
|
8129
|
-
throw new Error(
|
|
8132
|
+
throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
|
|
8130
8133
|
}
|
|
8131
8134
|
return v;
|
|
8132
8135
|
}
|
|
@@ -8251,19 +8254,29 @@ vec3 geometry_getNormal() {
|
|
|
8251
8254
|
|
|
8252
8255
|
// ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
|
|
8253
8256
|
var Matrix = class extends MathArray {
|
|
8257
|
+
// fromObject(object) {
|
|
8258
|
+
// const array = object.elements;
|
|
8259
|
+
// return this.fromRowMajor(array);
|
|
8260
|
+
// }
|
|
8261
|
+
// toObject(object) {
|
|
8262
|
+
// const array = object.elements;
|
|
8263
|
+
// this.toRowMajor(array);
|
|
8264
|
+
// return object;
|
|
8265
|
+
// }
|
|
8266
|
+
// TODO better override formatString?
|
|
8254
8267
|
toString() {
|
|
8255
8268
|
let string = "[";
|
|
8256
8269
|
if (config.printRowMajor) {
|
|
8257
8270
|
string += "row-major:";
|
|
8258
8271
|
for (let row = 0; row < this.RANK; ++row) {
|
|
8259
8272
|
for (let col = 0; col < this.RANK; ++col) {
|
|
8260
|
-
string +=
|
|
8273
|
+
string += ` ${this[col * this.RANK + row]}`;
|
|
8261
8274
|
}
|
|
8262
8275
|
}
|
|
8263
8276
|
} else {
|
|
8264
8277
|
string += "column-major:";
|
|
8265
8278
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8266
|
-
string +=
|
|
8279
|
+
string += ` ${this[i]}`;
|
|
8267
8280
|
}
|
|
8268
8281
|
}
|
|
8269
8282
|
string += "]";
|
|
@@ -8272,9 +8285,11 @@ vec3 geometry_getNormal() {
|
|
|
8272
8285
|
getElementIndex(row, col) {
|
|
8273
8286
|
return col * this.RANK + row;
|
|
8274
8287
|
}
|
|
8288
|
+
// By default assumes row major indices
|
|
8275
8289
|
getElement(row, col) {
|
|
8276
8290
|
return this[col * this.RANK + row];
|
|
8277
8291
|
}
|
|
8292
|
+
// By default assumes row major indices
|
|
8278
8293
|
setElement(row, col, value) {
|
|
8279
8294
|
this[col * this.RANK + row] = checkNumber(value);
|
|
8280
8295
|
return this;
|
|
@@ -9040,6 +9055,7 @@ vec3 geometry_getNormal() {
|
|
|
9040
9055
|
this[15] = array[15];
|
|
9041
9056
|
return this.check();
|
|
9042
9057
|
}
|
|
9058
|
+
// eslint-disable-next-line max-params
|
|
9043
9059
|
set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
|
|
9044
9060
|
this[0] = m00;
|
|
9045
9061
|
this[1] = m10;
|
|
@@ -9059,6 +9075,8 @@ vec3 geometry_getNormal() {
|
|
|
9059
9075
|
this[15] = m33;
|
|
9060
9076
|
return this.check();
|
|
9061
9077
|
}
|
|
9078
|
+
// accepts row major order, stores as column major
|
|
9079
|
+
// eslint-disable-next-line max-params
|
|
9062
9080
|
setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
9063
9081
|
this[0] = m00;
|
|
9064
9082
|
this[1] = m10;
|
|
@@ -9097,25 +9115,41 @@ vec3 geometry_getNormal() {
|
|
|
9097
9115
|
result[15] = this[15];
|
|
9098
9116
|
return result;
|
|
9099
9117
|
}
|
|
9118
|
+
// Constructors
|
|
9119
|
+
/** Set to identity matrix */
|
|
9100
9120
|
identity() {
|
|
9101
9121
|
return this.copy(IDENTITY_MATRIX);
|
|
9102
9122
|
}
|
|
9123
|
+
/**
|
|
9124
|
+
*
|
|
9125
|
+
* @param object
|
|
9126
|
+
* @returns self
|
|
9127
|
+
*/
|
|
9128
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9103
9129
|
fromObject(object) {
|
|
9104
9130
|
return this.check();
|
|
9105
9131
|
}
|
|
9132
|
+
/**
|
|
9133
|
+
* Calculates a 4x4 matrix from the given quaternion
|
|
9134
|
+
* @param quaternion Quaternion to create matrix from
|
|
9135
|
+
* @returns self
|
|
9136
|
+
*/
|
|
9106
9137
|
fromQuaternion(quaternion) {
|
|
9107
9138
|
fromQuat(this, quaternion);
|
|
9108
9139
|
return this.check();
|
|
9109
9140
|
}
|
|
9141
|
+
/**
|
|
9142
|
+
* Generates a frustum matrix with the given bounds
|
|
9143
|
+
* @param view.left - Left bound of the frustum
|
|
9144
|
+
* @param view.right - Right bound of the frustum
|
|
9145
|
+
* @param view.bottom - Bottom bound of the frustum
|
|
9146
|
+
* @param view.top - Top bound of the frustum
|
|
9147
|
+
* @param view.near - Near bound of the frustum
|
|
9148
|
+
* @param view.far - Far bound of the frustum. Can be set to Infinity.
|
|
9149
|
+
* @returns self
|
|
9150
|
+
*/
|
|
9110
9151
|
frustum(view) {
|
|
9111
|
-
const {
|
|
9112
|
-
left,
|
|
9113
|
-
right,
|
|
9114
|
-
bottom,
|
|
9115
|
-
top,
|
|
9116
|
-
near = DEFAULT_NEAR,
|
|
9117
|
-
far = DEFAULT_FAR
|
|
9118
|
-
} = view;
|
|
9152
|
+
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
9119
9153
|
if (far === Infinity) {
|
|
9120
9154
|
computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
|
|
9121
9155
|
} else {
|
|
@@ -9123,35 +9157,47 @@ vec3 geometry_getNormal() {
|
|
|
9123
9157
|
}
|
|
9124
9158
|
return this.check();
|
|
9125
9159
|
}
|
|
9160
|
+
/**
|
|
9161
|
+
* Generates a look-at matrix with the given eye position, focal point,
|
|
9162
|
+
* and up axis
|
|
9163
|
+
* @param view.eye - (vector) Position of the viewer
|
|
9164
|
+
* @param view.center - (vector) Point the viewer is looking at
|
|
9165
|
+
* @param view.up - (vector) Up axis
|
|
9166
|
+
* @returns self
|
|
9167
|
+
*/
|
|
9126
9168
|
lookAt(view) {
|
|
9127
|
-
const {
|
|
9128
|
-
eye,
|
|
9129
|
-
center = [0, 0, 0],
|
|
9130
|
-
up = [0, 1, 0]
|
|
9131
|
-
} = view;
|
|
9169
|
+
const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
|
|
9132
9170
|
lookAt(this, eye, center, up);
|
|
9133
9171
|
return this.check();
|
|
9134
9172
|
}
|
|
9173
|
+
/**
|
|
9174
|
+
* Generates a orthogonal projection matrix with the given bounds
|
|
9175
|
+
* from "traditional" view space parameters
|
|
9176
|
+
* @param view.left - Left bound of the frustum
|
|
9177
|
+
* @param view.right number Right bound of the frustum
|
|
9178
|
+
* @param view.bottom - Bottom bound of the frustum
|
|
9179
|
+
* @param view.top number Top bound of the frustum
|
|
9180
|
+
* @param view.near - Near bound of the frustum
|
|
9181
|
+
* @param view.far number Far bound of the frustum
|
|
9182
|
+
* @returns self
|
|
9183
|
+
*/
|
|
9135
9184
|
ortho(view) {
|
|
9136
|
-
const {
|
|
9137
|
-
left,
|
|
9138
|
-
right,
|
|
9139
|
-
bottom,
|
|
9140
|
-
top,
|
|
9141
|
-
near = DEFAULT_NEAR,
|
|
9142
|
-
far = DEFAULT_FAR
|
|
9143
|
-
} = view;
|
|
9185
|
+
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
9144
9186
|
ortho(this, left, right, bottom, top, near, far);
|
|
9145
9187
|
return this.check();
|
|
9146
9188
|
}
|
|
9189
|
+
/**
|
|
9190
|
+
* Generates an orthogonal projection matrix with the same parameters
|
|
9191
|
+
* as a perspective matrix (plus focalDistance)
|
|
9192
|
+
* @param view.fovy Vertical field of view in radians
|
|
9193
|
+
* @param view.aspect Aspect ratio. Typically viewport width / viewport height
|
|
9194
|
+
* @param view.focalDistance Distance in the view frustum used for extent calculations
|
|
9195
|
+
* @param view.near Near bound of the frustum
|
|
9196
|
+
* @param view.far Far bound of the frustum
|
|
9197
|
+
* @returns self
|
|
9198
|
+
*/
|
|
9147
9199
|
orthographic(view) {
|
|
9148
|
-
const {
|
|
9149
|
-
fovy = DEFAULT_FOVY,
|
|
9150
|
-
aspect = DEFAULT_ASPECT,
|
|
9151
|
-
focalDistance = 1,
|
|
9152
|
-
near = DEFAULT_NEAR,
|
|
9153
|
-
far = DEFAULT_FAR
|
|
9154
|
-
} = view;
|
|
9200
|
+
const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
9155
9201
|
checkRadians(fovy);
|
|
9156
9202
|
const halfY = fovy / 2;
|
|
9157
9203
|
const top = focalDistance * Math.tan(halfY);
|
|
@@ -9165,32 +9211,53 @@ vec3 geometry_getNormal() {
|
|
|
9165
9211
|
far
|
|
9166
9212
|
});
|
|
9167
9213
|
}
|
|
9214
|
+
/**
|
|
9215
|
+
* Generates a perspective projection matrix with the given bounds
|
|
9216
|
+
* @param view.fovy Vertical field of view in radians
|
|
9217
|
+
* @param view.aspect Aspect ratio. typically viewport width/height
|
|
9218
|
+
* @param view.near Near bound of the frustum
|
|
9219
|
+
* @param view.far Far bound of the frustum
|
|
9220
|
+
* @returns self
|
|
9221
|
+
*/
|
|
9168
9222
|
perspective(view) {
|
|
9169
|
-
const {
|
|
9170
|
-
fovy = 45 * Math.PI / 180,
|
|
9171
|
-
aspect = 1,
|
|
9172
|
-
near = 0.1,
|
|
9173
|
-
far = 500
|
|
9174
|
-
} = view;
|
|
9223
|
+
const { fovy = 45 * Math.PI / 180, aspect = 1, near = 0.1, far = 500 } = view;
|
|
9175
9224
|
checkRadians(fovy);
|
|
9176
9225
|
perspective(this, fovy, aspect, near, far);
|
|
9177
9226
|
return this.check();
|
|
9178
9227
|
}
|
|
9228
|
+
// Accessors
|
|
9179
9229
|
determinant() {
|
|
9180
9230
|
return determinant(this);
|
|
9181
9231
|
}
|
|
9232
|
+
/**
|
|
9233
|
+
* Extracts the non-uniform scale assuming the matrix is an affine transformation.
|
|
9234
|
+
* The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
|
|
9235
|
+
* @param result
|
|
9236
|
+
* @returns self
|
|
9237
|
+
*/
|
|
9182
9238
|
getScale(result = [-0, -0, -0]) {
|
|
9183
9239
|
result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
|
|
9184
9240
|
result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
|
|
9185
9241
|
result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
|
|
9186
9242
|
return result;
|
|
9187
9243
|
}
|
|
9244
|
+
/**
|
|
9245
|
+
* Gets the translation portion, assuming the matrix is a affine transformation matrix.
|
|
9246
|
+
* @param result
|
|
9247
|
+
* @returns self
|
|
9248
|
+
*/
|
|
9188
9249
|
getTranslation(result = [-0, -0, -0]) {
|
|
9189
9250
|
result[0] = this[12];
|
|
9190
9251
|
result[1] = this[13];
|
|
9191
9252
|
result[2] = this[14];
|
|
9192
9253
|
return result;
|
|
9193
9254
|
}
|
|
9255
|
+
/**
|
|
9256
|
+
* Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
|
|
9257
|
+
* @param result
|
|
9258
|
+
* @param scaleResult
|
|
9259
|
+
* @returns self
|
|
9260
|
+
*/
|
|
9194
9261
|
getRotation(result, scaleResult) {
|
|
9195
9262
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
9196
9263
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
@@ -9216,6 +9283,12 @@ vec3 geometry_getNormal() {
|
|
|
9216
9283
|
result[15] = 1;
|
|
9217
9284
|
return result;
|
|
9218
9285
|
}
|
|
9286
|
+
/**
|
|
9287
|
+
*
|
|
9288
|
+
* @param result
|
|
9289
|
+
* @param scaleResult
|
|
9290
|
+
* @returns self
|
|
9291
|
+
*/
|
|
9219
9292
|
getRotationMatrix3(result, scaleResult) {
|
|
9220
9293
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
9221
9294
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
@@ -9234,6 +9307,7 @@ vec3 geometry_getNormal() {
|
|
|
9234
9307
|
result[8] = this[10] * inverseScale2;
|
|
9235
9308
|
return result;
|
|
9236
9309
|
}
|
|
9310
|
+
// Modifiers
|
|
9237
9311
|
transpose() {
|
|
9238
9312
|
transpose(this, this);
|
|
9239
9313
|
return this.check();
|
|
@@ -9242,6 +9316,7 @@ vec3 geometry_getNormal() {
|
|
|
9242
9316
|
invert(this, this);
|
|
9243
9317
|
return this.check();
|
|
9244
9318
|
}
|
|
9319
|
+
// Operations
|
|
9245
9320
|
multiplyLeft(a) {
|
|
9246
9321
|
multiply(this, a, this);
|
|
9247
9322
|
return this.check();
|
|
@@ -9250,33 +9325,68 @@ vec3 geometry_getNormal() {
|
|
|
9250
9325
|
multiply(this, this, a);
|
|
9251
9326
|
return this.check();
|
|
9252
9327
|
}
|
|
9328
|
+
// Rotates a matrix by the given angle around the X axis
|
|
9253
9329
|
rotateX(radians) {
|
|
9254
9330
|
rotateX(this, this, radians);
|
|
9255
9331
|
return this.check();
|
|
9256
9332
|
}
|
|
9333
|
+
// Rotates a matrix by the given angle around the Y axis.
|
|
9257
9334
|
rotateY(radians) {
|
|
9258
9335
|
rotateY(this, this, radians);
|
|
9259
9336
|
return this.check();
|
|
9260
9337
|
}
|
|
9338
|
+
/**
|
|
9339
|
+
* Rotates a matrix by the given angle around the Z axis.
|
|
9340
|
+
* @param radians
|
|
9341
|
+
* @returns self
|
|
9342
|
+
*/
|
|
9261
9343
|
rotateZ(radians) {
|
|
9262
9344
|
rotateZ(this, this, radians);
|
|
9263
9345
|
return this.check();
|
|
9264
9346
|
}
|
|
9347
|
+
/**
|
|
9348
|
+
*
|
|
9349
|
+
* @param param0
|
|
9350
|
+
* @returns self
|
|
9351
|
+
*/
|
|
9265
9352
|
rotateXYZ(angleXYZ) {
|
|
9266
9353
|
return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
|
|
9267
9354
|
}
|
|
9355
|
+
/**
|
|
9356
|
+
*
|
|
9357
|
+
* @param radians
|
|
9358
|
+
* @param axis
|
|
9359
|
+
* @returns self
|
|
9360
|
+
*/
|
|
9268
9361
|
rotateAxis(radians, axis) {
|
|
9269
9362
|
rotate(this, this, radians, axis);
|
|
9270
9363
|
return this.check();
|
|
9271
9364
|
}
|
|
9365
|
+
/**
|
|
9366
|
+
*
|
|
9367
|
+
* @param factor
|
|
9368
|
+
* @returns self
|
|
9369
|
+
*/
|
|
9272
9370
|
scale(factor) {
|
|
9273
9371
|
scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
|
|
9274
9372
|
return this.check();
|
|
9275
9373
|
}
|
|
9374
|
+
/**
|
|
9375
|
+
*
|
|
9376
|
+
* @param vec
|
|
9377
|
+
* @returns self
|
|
9378
|
+
*/
|
|
9276
9379
|
translate(vector) {
|
|
9277
9380
|
translate(this, this, vector);
|
|
9278
9381
|
return this.check();
|
|
9279
9382
|
}
|
|
9383
|
+
// Transforms
|
|
9384
|
+
/**
|
|
9385
|
+
* Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
|
|
9386
|
+
* @param vector
|
|
9387
|
+
* @param result
|
|
9388
|
+
* @returns self
|
|
9389
|
+
*/
|
|
9280
9390
|
transform(vector, result) {
|
|
9281
9391
|
if (vector.length === 4) {
|
|
9282
9392
|
result = transformMat43(result || [-0, -0, -0, -0], vector, this);
|
|
@@ -9285,10 +9395,14 @@ vec3 geometry_getNormal() {
|
|
|
9285
9395
|
}
|
|
9286
9396
|
return this.transformAsPoint(vector, result);
|
|
9287
9397
|
}
|
|
9398
|
+
/**
|
|
9399
|
+
* Transforms any 2 or 3 element array as point (w implicitly 1)
|
|
9400
|
+
* @param vector
|
|
9401
|
+
* @param result
|
|
9402
|
+
* @returns self
|
|
9403
|
+
*/
|
|
9288
9404
|
transformAsPoint(vector, result) {
|
|
9289
|
-
const {
|
|
9290
|
-
length
|
|
9291
|
-
} = vector;
|
|
9405
|
+
const { length } = vector;
|
|
9292
9406
|
let out;
|
|
9293
9407
|
switch (length) {
|
|
9294
9408
|
case 2:
|
|
@@ -9303,6 +9417,12 @@ vec3 geometry_getNormal() {
|
|
|
9303
9417
|
checkVector(out, vector.length);
|
|
9304
9418
|
return out;
|
|
9305
9419
|
}
|
|
9420
|
+
/**
|
|
9421
|
+
* Transforms any 2 or 3 element array as vector (w implicitly 0)
|
|
9422
|
+
* @param vector
|
|
9423
|
+
* @param result
|
|
9424
|
+
* @returns self
|
|
9425
|
+
*/
|
|
9306
9426
|
transformAsVector(vector, result) {
|
|
9307
9427
|
let out;
|
|
9308
9428
|
switch (vector.length) {
|
|
@@ -9318,15 +9438,19 @@ vec3 geometry_getNormal() {
|
|
|
9318
9438
|
checkVector(out, vector.length);
|
|
9319
9439
|
return out;
|
|
9320
9440
|
}
|
|
9441
|
+
/** @deprecated */
|
|
9321
9442
|
transformPoint(vector, result) {
|
|
9322
9443
|
return this.transformAsPoint(vector, result);
|
|
9323
9444
|
}
|
|
9445
|
+
/** @deprecated */
|
|
9324
9446
|
transformVector(vector, result) {
|
|
9325
9447
|
return this.transformAsPoint(vector, result);
|
|
9326
9448
|
}
|
|
9449
|
+
/** @deprecated */
|
|
9327
9450
|
transformDirection(vector, result) {
|
|
9328
9451
|
return this.transformAsVector(vector, result);
|
|
9329
9452
|
}
|
|
9453
|
+
// three.js math API compatibility
|
|
9330
9454
|
makeRotationX(radians) {
|
|
9331
9455
|
return this.identity().rotateX(radians);
|
|
9332
9456
|
}
|