@luma.gl/shadertools 9.0.14 → 9.0.15
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
CHANGED
|
@@ -7847,17 +7847,11 @@ vec3 geometry_getNormal() {
|
|
|
7847
7847
|
printRowMajor: true,
|
|
7848
7848
|
_cartographicRadians: false
|
|
7849
7849
|
};
|
|
7850
|
-
globalThis.mathgl = globalThis.mathgl || {
|
|
7851
|
-
config: {
|
|
7852
|
-
...DEFAULT_CONFIG
|
|
7853
|
-
}
|
|
7854
|
-
};
|
|
7850
|
+
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
|
|
7855
7851
|
var config = globalThis.mathgl.config;
|
|
7856
|
-
function formatValue(value, {
|
|
7857
|
-
precision = config.precision
|
|
7858
|
-
} = {}) {
|
|
7852
|
+
function formatValue(value, { precision = config.precision } = {}) {
|
|
7859
7853
|
value = round(value);
|
|
7860
|
-
return
|
|
7854
|
+
return `${parseFloat(value.toPrecision(precision))}`;
|
|
7861
7855
|
}
|
|
7862
7856
|
function isArray(value) {
|
|
7863
7857
|
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
@@ -7901,28 +7895,12 @@ vec3 geometry_getNormal() {
|
|
|
7901
7895
|
}
|
|
7902
7896
|
|
|
7903
7897
|
// ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
ExtendableBuiltin.prototype = Object.create(cls.prototype, {
|
|
7911
|
-
constructor: {
|
|
7912
|
-
value: cls,
|
|
7913
|
-
enumerable: false,
|
|
7914
|
-
writable: true,
|
|
7915
|
-
configurable: true
|
|
7916
|
-
}
|
|
7917
|
-
});
|
|
7918
|
-
if (Object.setPrototypeOf) {
|
|
7919
|
-
Object.setPrototypeOf(ExtendableBuiltin, cls);
|
|
7920
|
-
} else {
|
|
7921
|
-
ExtendableBuiltin.__proto__ = cls;
|
|
7922
|
-
}
|
|
7923
|
-
return ExtendableBuiltin;
|
|
7924
|
-
}
|
|
7925
|
-
var MathArray = class extends _extendableBuiltin(Array) {
|
|
7898
|
+
var MathArray = class extends Array {
|
|
7899
|
+
// Common methods
|
|
7900
|
+
/**
|
|
7901
|
+
* Clone the current object
|
|
7902
|
+
* @returns a new copy of this object
|
|
7903
|
+
*/
|
|
7926
7904
|
clone() {
|
|
7927
7905
|
return new this.constructor().copy(this);
|
|
7928
7906
|
}
|
|
@@ -7942,7 +7920,10 @@ vec3 geometry_getNormal() {
|
|
|
7942
7920
|
return targetObject;
|
|
7943
7921
|
}
|
|
7944
7922
|
from(arrayOrObject) {
|
|
7945
|
-
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) :
|
|
7923
|
+
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
|
|
7924
|
+
// @ts-ignore
|
|
7925
|
+
this.fromObject(arrayOrObject)
|
|
7926
|
+
);
|
|
7946
7927
|
}
|
|
7947
7928
|
to(arrayOrObject) {
|
|
7948
7929
|
if (arrayOrObject === this) {
|
|
@@ -7953,18 +7934,20 @@ vec3 geometry_getNormal() {
|
|
|
7953
7934
|
toTarget(target) {
|
|
7954
7935
|
return target ? this.to(target) : this;
|
|
7955
7936
|
}
|
|
7937
|
+
/** @deprecated */
|
|
7956
7938
|
toFloat32Array() {
|
|
7957
7939
|
return new Float32Array(this);
|
|
7958
7940
|
}
|
|
7959
7941
|
toString() {
|
|
7960
7942
|
return this.formatString(config);
|
|
7961
7943
|
}
|
|
7944
|
+
/** Formats string according to options */
|
|
7962
7945
|
formatString(opts) {
|
|
7963
7946
|
let string = "";
|
|
7964
7947
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
7965
7948
|
string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
|
|
7966
7949
|
}
|
|
7967
|
-
return
|
|
7950
|
+
return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
|
|
7968
7951
|
}
|
|
7969
7952
|
equals(array) {
|
|
7970
7953
|
if (!array || this.length !== array.length) {
|
|
@@ -7988,6 +7971,8 @@ vec3 geometry_getNormal() {
|
|
|
7988
7971
|
}
|
|
7989
7972
|
return true;
|
|
7990
7973
|
}
|
|
7974
|
+
// Modifiers
|
|
7975
|
+
/** Negates all values in this object */
|
|
7991
7976
|
negate() {
|
|
7992
7977
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
7993
7978
|
this[i] = -this[i];
|
|
@@ -8005,12 +7990,14 @@ vec3 geometry_getNormal() {
|
|
|
8005
7990
|
}
|
|
8006
7991
|
return this.check();
|
|
8007
7992
|
}
|
|
7993
|
+
/** Minimal */
|
|
8008
7994
|
min(vector) {
|
|
8009
7995
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8010
7996
|
this[i] = Math.min(vector[i], this[i]);
|
|
8011
7997
|
}
|
|
8012
7998
|
return this.check();
|
|
8013
7999
|
}
|
|
8000
|
+
/** Maximal */
|
|
8014
8001
|
max(vector) {
|
|
8015
8002
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8016
8003
|
this[i] = Math.max(vector[i], this[i]);
|
|
@@ -8051,18 +8038,25 @@ vec3 geometry_getNormal() {
|
|
|
8051
8038
|
}
|
|
8052
8039
|
return this.check();
|
|
8053
8040
|
}
|
|
8041
|
+
/**
|
|
8042
|
+
* Multiplies all elements by `scale`
|
|
8043
|
+
* Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
|
|
8044
|
+
*/
|
|
8054
8045
|
multiplyByScalar(scalar) {
|
|
8055
8046
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8056
8047
|
this[i] *= scalar;
|
|
8057
8048
|
}
|
|
8058
8049
|
return this.check();
|
|
8059
8050
|
}
|
|
8051
|
+
// Debug checks
|
|
8052
|
+
/** Throws an error if array length is incorrect or contains illegal values */
|
|
8060
8053
|
check() {
|
|
8061
8054
|
if (config.debug && !this.validate()) {
|
|
8062
|
-
throw new Error(
|
|
8055
|
+
throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
|
|
8063
8056
|
}
|
|
8064
8057
|
return this;
|
|
8065
8058
|
}
|
|
8059
|
+
/** Returns false if the array length is incorrect or contains illegal values */
|
|
8066
8060
|
validate() {
|
|
8067
8061
|
let valid = this.length === this.ELEMENTS;
|
|
8068
8062
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
@@ -8070,39 +8064,48 @@ vec3 geometry_getNormal() {
|
|
|
8070
8064
|
}
|
|
8071
8065
|
return valid;
|
|
8072
8066
|
}
|
|
8067
|
+
// three.js compatibility
|
|
8068
|
+
/** @deprecated */
|
|
8073
8069
|
sub(a) {
|
|
8074
8070
|
return this.subtract(a);
|
|
8075
8071
|
}
|
|
8072
|
+
/** @deprecated */
|
|
8076
8073
|
setScalar(a) {
|
|
8077
8074
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8078
8075
|
this[i] = a;
|
|
8079
8076
|
}
|
|
8080
8077
|
return this.check();
|
|
8081
8078
|
}
|
|
8079
|
+
/** @deprecated */
|
|
8082
8080
|
addScalar(a) {
|
|
8083
8081
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8084
8082
|
this[i] += a;
|
|
8085
8083
|
}
|
|
8086
8084
|
return this.check();
|
|
8087
8085
|
}
|
|
8086
|
+
/** @deprecated */
|
|
8088
8087
|
subScalar(a) {
|
|
8089
8088
|
return this.addScalar(-a);
|
|
8090
8089
|
}
|
|
8090
|
+
/** @deprecated */
|
|
8091
8091
|
multiplyScalar(scalar) {
|
|
8092
8092
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8093
8093
|
this[i] *= scalar;
|
|
8094
8094
|
}
|
|
8095
8095
|
return this.check();
|
|
8096
8096
|
}
|
|
8097
|
+
/** @deprecated */
|
|
8097
8098
|
divideScalar(a) {
|
|
8098
8099
|
return this.multiplyByScalar(1 / a);
|
|
8099
8100
|
}
|
|
8101
|
+
/** @deprecated */
|
|
8100
8102
|
clampScalar(min, max) {
|
|
8101
8103
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8102
8104
|
this[i] = Math.min(Math.max(this[i], min), max);
|
|
8103
8105
|
}
|
|
8104
8106
|
return this.check();
|
|
8105
8107
|
}
|
|
8108
|
+
/** @deprecated */
|
|
8106
8109
|
get elements() {
|
|
8107
8110
|
return this;
|
|
8108
8111
|
}
|
|
@@ -8122,13 +8125,13 @@ vec3 geometry_getNormal() {
|
|
|
8122
8125
|
}
|
|
8123
8126
|
function checkNumber(value) {
|
|
8124
8127
|
if (!Number.isFinite(value)) {
|
|
8125
|
-
throw new Error(
|
|
8128
|
+
throw new Error(`Invalid number ${JSON.stringify(value)}`);
|
|
8126
8129
|
}
|
|
8127
8130
|
return value;
|
|
8128
8131
|
}
|
|
8129
8132
|
function checkVector(v, length, callerName = "") {
|
|
8130
8133
|
if (config.debug && !validateVector(v, length)) {
|
|
8131
|
-
throw new Error(
|
|
8134
|
+
throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
|
|
8132
8135
|
}
|
|
8133
8136
|
return v;
|
|
8134
8137
|
}
|
|
@@ -8253,19 +8256,29 @@ vec3 geometry_getNormal() {
|
|
|
8253
8256
|
|
|
8254
8257
|
// ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
|
|
8255
8258
|
var Matrix = class extends MathArray {
|
|
8259
|
+
// fromObject(object) {
|
|
8260
|
+
// const array = object.elements;
|
|
8261
|
+
// return this.fromRowMajor(array);
|
|
8262
|
+
// }
|
|
8263
|
+
// toObject(object) {
|
|
8264
|
+
// const array = object.elements;
|
|
8265
|
+
// this.toRowMajor(array);
|
|
8266
|
+
// return object;
|
|
8267
|
+
// }
|
|
8268
|
+
// TODO better override formatString?
|
|
8256
8269
|
toString() {
|
|
8257
8270
|
let string = "[";
|
|
8258
8271
|
if (config.printRowMajor) {
|
|
8259
8272
|
string += "row-major:";
|
|
8260
8273
|
for (let row = 0; row < this.RANK; ++row) {
|
|
8261
8274
|
for (let col = 0; col < this.RANK; ++col) {
|
|
8262
|
-
string +=
|
|
8275
|
+
string += ` ${this[col * this.RANK + row]}`;
|
|
8263
8276
|
}
|
|
8264
8277
|
}
|
|
8265
8278
|
} else {
|
|
8266
8279
|
string += "column-major:";
|
|
8267
8280
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
8268
|
-
string +=
|
|
8281
|
+
string += ` ${this[i]}`;
|
|
8269
8282
|
}
|
|
8270
8283
|
}
|
|
8271
8284
|
string += "]";
|
|
@@ -8274,9 +8287,11 @@ vec3 geometry_getNormal() {
|
|
|
8274
8287
|
getElementIndex(row, col) {
|
|
8275
8288
|
return col * this.RANK + row;
|
|
8276
8289
|
}
|
|
8290
|
+
// By default assumes row major indices
|
|
8277
8291
|
getElement(row, col) {
|
|
8278
8292
|
return this[col * this.RANK + row];
|
|
8279
8293
|
}
|
|
8294
|
+
// By default assumes row major indices
|
|
8280
8295
|
setElement(row, col, value) {
|
|
8281
8296
|
this[col * this.RANK + row] = checkNumber(value);
|
|
8282
8297
|
return this;
|
|
@@ -9042,6 +9057,7 @@ vec3 geometry_getNormal() {
|
|
|
9042
9057
|
this[15] = array[15];
|
|
9043
9058
|
return this.check();
|
|
9044
9059
|
}
|
|
9060
|
+
// eslint-disable-next-line max-params
|
|
9045
9061
|
set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
|
|
9046
9062
|
this[0] = m00;
|
|
9047
9063
|
this[1] = m10;
|
|
@@ -9061,6 +9077,8 @@ vec3 geometry_getNormal() {
|
|
|
9061
9077
|
this[15] = m33;
|
|
9062
9078
|
return this.check();
|
|
9063
9079
|
}
|
|
9080
|
+
// accepts row major order, stores as column major
|
|
9081
|
+
// eslint-disable-next-line max-params
|
|
9064
9082
|
setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
9065
9083
|
this[0] = m00;
|
|
9066
9084
|
this[1] = m10;
|
|
@@ -9099,25 +9117,41 @@ vec3 geometry_getNormal() {
|
|
|
9099
9117
|
result[15] = this[15];
|
|
9100
9118
|
return result;
|
|
9101
9119
|
}
|
|
9120
|
+
// Constructors
|
|
9121
|
+
/** Set to identity matrix */
|
|
9102
9122
|
identity() {
|
|
9103
9123
|
return this.copy(IDENTITY_MATRIX);
|
|
9104
9124
|
}
|
|
9125
|
+
/**
|
|
9126
|
+
*
|
|
9127
|
+
* @param object
|
|
9128
|
+
* @returns self
|
|
9129
|
+
*/
|
|
9130
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9105
9131
|
fromObject(object) {
|
|
9106
9132
|
return this.check();
|
|
9107
9133
|
}
|
|
9134
|
+
/**
|
|
9135
|
+
* Calculates a 4x4 matrix from the given quaternion
|
|
9136
|
+
* @param quaternion Quaternion to create matrix from
|
|
9137
|
+
* @returns self
|
|
9138
|
+
*/
|
|
9108
9139
|
fromQuaternion(quaternion) {
|
|
9109
9140
|
fromQuat(this, quaternion);
|
|
9110
9141
|
return this.check();
|
|
9111
9142
|
}
|
|
9143
|
+
/**
|
|
9144
|
+
* Generates a frustum matrix with the given bounds
|
|
9145
|
+
* @param view.left - Left bound of the frustum
|
|
9146
|
+
* @param view.right - Right bound of the frustum
|
|
9147
|
+
* @param view.bottom - Bottom bound of the frustum
|
|
9148
|
+
* @param view.top - Top bound of the frustum
|
|
9149
|
+
* @param view.near - Near bound of the frustum
|
|
9150
|
+
* @param view.far - Far bound of the frustum. Can be set to Infinity.
|
|
9151
|
+
* @returns self
|
|
9152
|
+
*/
|
|
9112
9153
|
frustum(view) {
|
|
9113
|
-
const {
|
|
9114
|
-
left,
|
|
9115
|
-
right,
|
|
9116
|
-
bottom,
|
|
9117
|
-
top,
|
|
9118
|
-
near = DEFAULT_NEAR,
|
|
9119
|
-
far = DEFAULT_FAR
|
|
9120
|
-
} = view;
|
|
9154
|
+
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
9121
9155
|
if (far === Infinity) {
|
|
9122
9156
|
computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
|
|
9123
9157
|
} else {
|
|
@@ -9125,35 +9159,47 @@ vec3 geometry_getNormal() {
|
|
|
9125
9159
|
}
|
|
9126
9160
|
return this.check();
|
|
9127
9161
|
}
|
|
9162
|
+
/**
|
|
9163
|
+
* Generates a look-at matrix with the given eye position, focal point,
|
|
9164
|
+
* and up axis
|
|
9165
|
+
* @param view.eye - (vector) Position of the viewer
|
|
9166
|
+
* @param view.center - (vector) Point the viewer is looking at
|
|
9167
|
+
* @param view.up - (vector) Up axis
|
|
9168
|
+
* @returns self
|
|
9169
|
+
*/
|
|
9128
9170
|
lookAt(view) {
|
|
9129
|
-
const {
|
|
9130
|
-
eye,
|
|
9131
|
-
center = [0, 0, 0],
|
|
9132
|
-
up = [0, 1, 0]
|
|
9133
|
-
} = view;
|
|
9171
|
+
const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
|
|
9134
9172
|
lookAt(this, eye, center, up);
|
|
9135
9173
|
return this.check();
|
|
9136
9174
|
}
|
|
9175
|
+
/**
|
|
9176
|
+
* Generates a orthogonal projection matrix with the given bounds
|
|
9177
|
+
* from "traditional" view space parameters
|
|
9178
|
+
* @param view.left - Left bound of the frustum
|
|
9179
|
+
* @param view.right number Right bound of the frustum
|
|
9180
|
+
* @param view.bottom - Bottom bound of the frustum
|
|
9181
|
+
* @param view.top number Top bound of the frustum
|
|
9182
|
+
* @param view.near - Near bound of the frustum
|
|
9183
|
+
* @param view.far number Far bound of the frustum
|
|
9184
|
+
* @returns self
|
|
9185
|
+
*/
|
|
9137
9186
|
ortho(view) {
|
|
9138
|
-
const {
|
|
9139
|
-
left,
|
|
9140
|
-
right,
|
|
9141
|
-
bottom,
|
|
9142
|
-
top,
|
|
9143
|
-
near = DEFAULT_NEAR,
|
|
9144
|
-
far = DEFAULT_FAR
|
|
9145
|
-
} = view;
|
|
9187
|
+
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
9146
9188
|
ortho(this, left, right, bottom, top, near, far);
|
|
9147
9189
|
return this.check();
|
|
9148
9190
|
}
|
|
9191
|
+
/**
|
|
9192
|
+
* Generates an orthogonal projection matrix with the same parameters
|
|
9193
|
+
* as a perspective matrix (plus focalDistance)
|
|
9194
|
+
* @param view.fovy Vertical field of view in radians
|
|
9195
|
+
* @param view.aspect Aspect ratio. Typically viewport width / viewport height
|
|
9196
|
+
* @param view.focalDistance Distance in the view frustum used for extent calculations
|
|
9197
|
+
* @param view.near Near bound of the frustum
|
|
9198
|
+
* @param view.far Far bound of the frustum
|
|
9199
|
+
* @returns self
|
|
9200
|
+
*/
|
|
9149
9201
|
orthographic(view) {
|
|
9150
|
-
const {
|
|
9151
|
-
fovy = DEFAULT_FOVY,
|
|
9152
|
-
aspect = DEFAULT_ASPECT,
|
|
9153
|
-
focalDistance = 1,
|
|
9154
|
-
near = DEFAULT_NEAR,
|
|
9155
|
-
far = DEFAULT_FAR
|
|
9156
|
-
} = view;
|
|
9202
|
+
const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
|
|
9157
9203
|
checkRadians(fovy);
|
|
9158
9204
|
const halfY = fovy / 2;
|
|
9159
9205
|
const top = focalDistance * Math.tan(halfY);
|
|
@@ -9167,32 +9213,53 @@ vec3 geometry_getNormal() {
|
|
|
9167
9213
|
far
|
|
9168
9214
|
});
|
|
9169
9215
|
}
|
|
9216
|
+
/**
|
|
9217
|
+
* Generates a perspective projection matrix with the given bounds
|
|
9218
|
+
* @param view.fovy Vertical field of view in radians
|
|
9219
|
+
* @param view.aspect Aspect ratio. typically viewport width/height
|
|
9220
|
+
* @param view.near Near bound of the frustum
|
|
9221
|
+
* @param view.far Far bound of the frustum
|
|
9222
|
+
* @returns self
|
|
9223
|
+
*/
|
|
9170
9224
|
perspective(view) {
|
|
9171
|
-
const {
|
|
9172
|
-
fovy = 45 * Math.PI / 180,
|
|
9173
|
-
aspect = 1,
|
|
9174
|
-
near = 0.1,
|
|
9175
|
-
far = 500
|
|
9176
|
-
} = view;
|
|
9225
|
+
const { fovy = 45 * Math.PI / 180, aspect = 1, near = 0.1, far = 500 } = view;
|
|
9177
9226
|
checkRadians(fovy);
|
|
9178
9227
|
perspective(this, fovy, aspect, near, far);
|
|
9179
9228
|
return this.check();
|
|
9180
9229
|
}
|
|
9230
|
+
// Accessors
|
|
9181
9231
|
determinant() {
|
|
9182
9232
|
return determinant(this);
|
|
9183
9233
|
}
|
|
9234
|
+
/**
|
|
9235
|
+
* Extracts the non-uniform scale assuming the matrix is an affine transformation.
|
|
9236
|
+
* The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
|
|
9237
|
+
* @param result
|
|
9238
|
+
* @returns self
|
|
9239
|
+
*/
|
|
9184
9240
|
getScale(result = [-0, -0, -0]) {
|
|
9185
9241
|
result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
|
|
9186
9242
|
result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
|
|
9187
9243
|
result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
|
|
9188
9244
|
return result;
|
|
9189
9245
|
}
|
|
9246
|
+
/**
|
|
9247
|
+
* Gets the translation portion, assuming the matrix is a affine transformation matrix.
|
|
9248
|
+
* @param result
|
|
9249
|
+
* @returns self
|
|
9250
|
+
*/
|
|
9190
9251
|
getTranslation(result = [-0, -0, -0]) {
|
|
9191
9252
|
result[0] = this[12];
|
|
9192
9253
|
result[1] = this[13];
|
|
9193
9254
|
result[2] = this[14];
|
|
9194
9255
|
return result;
|
|
9195
9256
|
}
|
|
9257
|
+
/**
|
|
9258
|
+
* Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
|
|
9259
|
+
* @param result
|
|
9260
|
+
* @param scaleResult
|
|
9261
|
+
* @returns self
|
|
9262
|
+
*/
|
|
9196
9263
|
getRotation(result, scaleResult) {
|
|
9197
9264
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
9198
9265
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
@@ -9218,6 +9285,12 @@ vec3 geometry_getNormal() {
|
|
|
9218
9285
|
result[15] = 1;
|
|
9219
9286
|
return result;
|
|
9220
9287
|
}
|
|
9288
|
+
/**
|
|
9289
|
+
*
|
|
9290
|
+
* @param result
|
|
9291
|
+
* @param scaleResult
|
|
9292
|
+
* @returns self
|
|
9293
|
+
*/
|
|
9221
9294
|
getRotationMatrix3(result, scaleResult) {
|
|
9222
9295
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
9223
9296
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
@@ -9236,6 +9309,7 @@ vec3 geometry_getNormal() {
|
|
|
9236
9309
|
result[8] = this[10] * inverseScale2;
|
|
9237
9310
|
return result;
|
|
9238
9311
|
}
|
|
9312
|
+
// Modifiers
|
|
9239
9313
|
transpose() {
|
|
9240
9314
|
transpose(this, this);
|
|
9241
9315
|
return this.check();
|
|
@@ -9244,6 +9318,7 @@ vec3 geometry_getNormal() {
|
|
|
9244
9318
|
invert(this, this);
|
|
9245
9319
|
return this.check();
|
|
9246
9320
|
}
|
|
9321
|
+
// Operations
|
|
9247
9322
|
multiplyLeft(a) {
|
|
9248
9323
|
multiply(this, a, this);
|
|
9249
9324
|
return this.check();
|
|
@@ -9252,33 +9327,68 @@ vec3 geometry_getNormal() {
|
|
|
9252
9327
|
multiply(this, this, a);
|
|
9253
9328
|
return this.check();
|
|
9254
9329
|
}
|
|
9330
|
+
// Rotates a matrix by the given angle around the X axis
|
|
9255
9331
|
rotateX(radians) {
|
|
9256
9332
|
rotateX(this, this, radians);
|
|
9257
9333
|
return this.check();
|
|
9258
9334
|
}
|
|
9335
|
+
// Rotates a matrix by the given angle around the Y axis.
|
|
9259
9336
|
rotateY(radians) {
|
|
9260
9337
|
rotateY(this, this, radians);
|
|
9261
9338
|
return this.check();
|
|
9262
9339
|
}
|
|
9340
|
+
/**
|
|
9341
|
+
* Rotates a matrix by the given angle around the Z axis.
|
|
9342
|
+
* @param radians
|
|
9343
|
+
* @returns self
|
|
9344
|
+
*/
|
|
9263
9345
|
rotateZ(radians) {
|
|
9264
9346
|
rotateZ(this, this, radians);
|
|
9265
9347
|
return this.check();
|
|
9266
9348
|
}
|
|
9349
|
+
/**
|
|
9350
|
+
*
|
|
9351
|
+
* @param param0
|
|
9352
|
+
* @returns self
|
|
9353
|
+
*/
|
|
9267
9354
|
rotateXYZ(angleXYZ) {
|
|
9268
9355
|
return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
|
|
9269
9356
|
}
|
|
9357
|
+
/**
|
|
9358
|
+
*
|
|
9359
|
+
* @param radians
|
|
9360
|
+
* @param axis
|
|
9361
|
+
* @returns self
|
|
9362
|
+
*/
|
|
9270
9363
|
rotateAxis(radians, axis) {
|
|
9271
9364
|
rotate(this, this, radians, axis);
|
|
9272
9365
|
return this.check();
|
|
9273
9366
|
}
|
|
9367
|
+
/**
|
|
9368
|
+
*
|
|
9369
|
+
* @param factor
|
|
9370
|
+
* @returns self
|
|
9371
|
+
*/
|
|
9274
9372
|
scale(factor) {
|
|
9275
9373
|
scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
|
|
9276
9374
|
return this.check();
|
|
9277
9375
|
}
|
|
9376
|
+
/**
|
|
9377
|
+
*
|
|
9378
|
+
* @param vec
|
|
9379
|
+
* @returns self
|
|
9380
|
+
*/
|
|
9278
9381
|
translate(vector) {
|
|
9279
9382
|
translate(this, this, vector);
|
|
9280
9383
|
return this.check();
|
|
9281
9384
|
}
|
|
9385
|
+
// Transforms
|
|
9386
|
+
/**
|
|
9387
|
+
* Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
|
|
9388
|
+
* @param vector
|
|
9389
|
+
* @param result
|
|
9390
|
+
* @returns self
|
|
9391
|
+
*/
|
|
9282
9392
|
transform(vector, result) {
|
|
9283
9393
|
if (vector.length === 4) {
|
|
9284
9394
|
result = transformMat43(result || [-0, -0, -0, -0], vector, this);
|
|
@@ -9287,10 +9397,14 @@ vec3 geometry_getNormal() {
|
|
|
9287
9397
|
}
|
|
9288
9398
|
return this.transformAsPoint(vector, result);
|
|
9289
9399
|
}
|
|
9400
|
+
/**
|
|
9401
|
+
* Transforms any 2 or 3 element array as point (w implicitly 1)
|
|
9402
|
+
* @param vector
|
|
9403
|
+
* @param result
|
|
9404
|
+
* @returns self
|
|
9405
|
+
*/
|
|
9290
9406
|
transformAsPoint(vector, result) {
|
|
9291
|
-
const {
|
|
9292
|
-
length
|
|
9293
|
-
} = vector;
|
|
9407
|
+
const { length } = vector;
|
|
9294
9408
|
let out;
|
|
9295
9409
|
switch (length) {
|
|
9296
9410
|
case 2:
|
|
@@ -9305,6 +9419,12 @@ vec3 geometry_getNormal() {
|
|
|
9305
9419
|
checkVector(out, vector.length);
|
|
9306
9420
|
return out;
|
|
9307
9421
|
}
|
|
9422
|
+
/**
|
|
9423
|
+
* Transforms any 2 or 3 element array as vector (w implicitly 0)
|
|
9424
|
+
* @param vector
|
|
9425
|
+
* @param result
|
|
9426
|
+
* @returns self
|
|
9427
|
+
*/
|
|
9308
9428
|
transformAsVector(vector, result) {
|
|
9309
9429
|
let out;
|
|
9310
9430
|
switch (vector.length) {
|
|
@@ -9320,15 +9440,19 @@ vec3 geometry_getNormal() {
|
|
|
9320
9440
|
checkVector(out, vector.length);
|
|
9321
9441
|
return out;
|
|
9322
9442
|
}
|
|
9443
|
+
/** @deprecated */
|
|
9323
9444
|
transformPoint(vector, result) {
|
|
9324
9445
|
return this.transformAsPoint(vector, result);
|
|
9325
9446
|
}
|
|
9447
|
+
/** @deprecated */
|
|
9326
9448
|
transformVector(vector, result) {
|
|
9327
9449
|
return this.transformAsPoint(vector, result);
|
|
9328
9450
|
}
|
|
9451
|
+
/** @deprecated */
|
|
9329
9452
|
transformDirection(vector, result) {
|
|
9330
9453
|
return this.transformAsVector(vector, result);
|
|
9331
9454
|
}
|
|
9455
|
+
// three.js math API compatibility
|
|
9332
9456
|
makeRotationX(radians) {
|
|
9333
9457
|
return this.identity().rotateX(radians);
|
|
9334
9458
|
}
|
package/dist/dist.min.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['luma'] = factory();
|
|
6
6
|
else root['luma'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var jn=Object.create;var ue=Object.defineProperty;var $n=Object.getOwnPropertyDescriptor;var Kn=Object.getOwnPropertyNames;var Zn=Object.getPrototypeOf,Jn=Object.prototype.hasOwnProperty;var eo=(t,e,r)=>e in t?ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var to=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ro=(t,e)=>{for(var r in e)ue(t,r,{get:e[r],enumerable:!0})},ve=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Kn(e))!Jn.call(t,o)&&o!==r&&ue(t,o,{get:()=>e[o],enumerable:!(n=$n(e,o))||n.enumerable});return t},Ae=(t,e,r)=>(ve(t,e,"default"),r&&ve(r,e,"default")),or=(t,e,r)=>(r=t!=null?jn(Zn(t)):{},ve(e||!t||!t.__esModule?ue(r,"default",{value:t,enumerable:!0}):r,t)),no=t=>ve(ue({},"__esModule",{value:!0}),t);var ir=(t,e,r)=>(eo(t,typeof e!="symbol"?e+"":e,r),r);var $e=to((
|
|
7
|
+
"use strict";var __exports__=(()=>{var jn=Object.create;var ue=Object.defineProperty;var $n=Object.getOwnPropertyDescriptor;var Kn=Object.getOwnPropertyNames;var Zn=Object.getPrototypeOf,Jn=Object.prototype.hasOwnProperty;var eo=(t,e,r)=>e in t?ue(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var to=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ro=(t,e)=>{for(var r in e)ue(t,r,{get:e[r],enumerable:!0})},ve=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Kn(e))!Jn.call(t,o)&&o!==r&&ue(t,o,{get:()=>e[o],enumerable:!(n=$n(e,o))||n.enumerable});return t},Ae=(t,e,r)=>(ve(t,e,"default"),r&&ve(r,e,"default")),or=(t,e,r)=>(r=t!=null?jn(Zn(t)):{},ve(e||!t||!t.__esModule?ue(r,"default",{value:t,enumerable:!0}):r,t)),no=t=>ve(ue({},"__esModule",{value:!0}),t);var ir=(t,e,r)=>(eo(t,typeof e!="symbol"?e+"":e,r),r);var $e=to((Ri,sr)=>{sr.exports=globalThis.luma});var xe={};ro(xe,{ShaderAssembler:()=>pe,ShaderModuleInstance:()=>C,_ShaderModuleInstance:()=>C,_getDependencyGraph:()=>be,_resolveModules:()=>re,_warp:()=>ce,assembleShaderPairGLSL:()=>Pe,brightnessContrast:()=>Gr,bulgePinch:()=>ln,capitalize:()=>K,colorHalftone:()=>rn,combineInjects:()=>mr,convertToVec4:()=>it,denoise:()=>Hr,dirlight:()=>Qt,dirlight1:()=>Qn,dotScreen:()=>nn,edgeWork:()=>on,fp32:()=>Ur,fp64:()=>pn,fp64arithmetic:()=>Ht,fxaa:()=>un,generateShaderForModule:()=>Ir,geometry1:()=>dn,getPassthroughFS:()=>Nr,getQualifierDetails:()=>kr,getShaderInfo:()=>ye,getShaderLayoutFromWGSL:()=>Or,glsl:()=>ar,gouraudLighting:()=>Vn,gouraudMaterial:()=>Bt,hexagonalPixelate:()=>sn,hueSaturation:()=>Wr,ink:()=>an,lighting:()=>Q,lights1:()=>te,magnify:()=>cn,noise:()=>jr,normalizeShaderModule:()=>Sr,pbr:()=>Wn,pbrMaterial:()=>qr,phongLighting:()=>qn,phongMaterial:()=>Vt,picking:()=>zr,project1:()=>je,random:()=>B,sepia:()=>$r,swirl:()=>fn,tiltShift:()=>Jr,triangleBlur:()=>en,typeToChannelCount:()=>Tr,typeToChannelSuffix:()=>Er,vibrance:()=>Kr,vignette:()=>Zr,zoomBlur:()=>tn});Ae(xe,or($e(),1));var ar=t=>`${t}`;function z(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var Ke={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function lr(t){let e={};for(let[r,n]of Object.entries(t))e[r]=oo(n);return e}function fr(t,e,r){let n={};for(let[o,i]of Object.entries(e))t&&o in t&&!i.private?(i.validate&&z(i.validate(t[o],i),`${r}: invalid ${o}`),n[o]=t[o]):n[o]=i.value;return n}function oo(t){let e=cr(t);if(e!=="object")return{value:t,...Ke[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...Ke[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=cr(t.value),{...t,...Ke[e],type:e}):{type:"object",value:null};throw new Error("props")}function cr(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var ur=`#ifdef MODULE_LOGDEPTH
|
|
8
8
|
logdepth_adjustPosition(gl_Position);
|
|
9
9
|
#endif
|
|
10
10
|
`,_r=`#ifdef MODULE_MATERIAL
|
|
@@ -2461,7 +2461,7 @@ return geometry_vPosition;
|
|
|
2461
2461
|
vec3 geometry_getNormal() {
|
|
2462
2462
|
return geometry_vNormal;
|
|
2463
2463
|
}
|
|
2464
|
-
`,dn={name:"geometry",vs:si,fs:ai};var Ta=1/Math.PI*180,Ma=1/180*Math.PI,ci={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...ci}};var O=globalThis.mathgl.config;function mn(t,{precision:e=O.precision}={}){return t=li(t),"".concat(parseFloat(t.toPrecision(e)))}function Be(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Wt(t,e,r){let n=O.EPSILON;r&&(O.EPSILON=r);try{if(t===e)return!0;if(Be(t)&&Be(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!Wt(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=O.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{O.EPSILON=n}}function li(t){return Math.round(t/O.EPSILON)*O.EPSILON}function fi(t){function e(){var r=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}var Ve=class extends fi(Array){clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Be(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(O)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+mn(this[n],e);return"".concat(e.printTypes?this.constructor.name:"","[").concat(r,"]")}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Wt(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let o=0;o<this.ELEMENTS;++o){let i=e[o],a=typeof r=="number"?r:r[o];this[o]=i+n*(a-i)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(O.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),r);return this.check()}get elements(){return this}};function ui(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function gn(t){if(!Number.isFinite(t))throw new Error("Invalid number ".concat(JSON.stringify(t)));return t}function qe(t,e,r=""){if(O.debug&&!ui(t,e))throw new Error("math.gl: ".concat(r," some fields set to invalid numbers'"));return t}var H=typeof Float32Array<"u"?Float32Array:Array;var Ua=Math.PI/180;function _i(){let t=new H(2);return H!=Float32Array&&(t[0]=0,t[1]=0),t}function An(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}var za=function(){let t=_i();return function(e,r,n,o,i,a){let f,u;for(r||(r=2),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],i(t,t,a),e[f]=t[0],e[f+1]=t[1];return e}}();function bn(t,e,r){let n=e[0],o=e[1],i=r[3]*n+r[7]*o||1;return t[0]=(r[0]*n+r[4]*o)/i,t[1]=(r[1]*n+r[5]*o)/i,t}function yn(t,e,r){let n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i||1;return t[0]=(r[0]*n+r[4]*o+r[8]*i)/a,t[1]=(r[1]*n+r[5]*o+r[9]*i)/a,t[2]=(r[2]*n+r[6]*o+r[10]*i)/a,t}function hi(){let t=new H(3);return H!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Pn(t,e,r){let n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i+r[15];return a=a||1,t[0]=(r[0]*n+r[4]*o+r[8]*i+r[12])/a,t[1]=(r[1]*n+r[5]*o+r[9]*i+r[13])/a,t[2]=(r[2]*n+r[6]*o+r[10]*i+r[14])/a,t}var Xa=function(){let t=hi();return function(e,r,n,o,i,a){let f,u;for(r||(r=3),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],t[2]=e[f+2],i(t,t,a),e[f]=t[0],e[f+1]=t[1],e[f+2]=t[2];return e}}();var Ge=class extends Ve{toString(){let e="[";if(O.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=" ".concat(this[n*this.RANK+r])}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=" ".concat(this[r])}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=gn(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)r[o]=this[n+o];return r}setColumn(e,r){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=r[o];return this}};function pi(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function wn(t,e){if(t===e){let r=e[1],n=e[2],o=e[3],i=e[6],a=e[7],f=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=i,t[11]=e[14],t[12]=o,t[13]=a,t[14]=f}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ln(t,e){let r=e[0],n=e[1],o=e[2],i=e[3],a=e[4],f=e[5],u=e[6],h=e[7],p=e[8],d=e[9],m=e[10],x=e[11],w=e[12],g=e[13],A=e[14],L=e[15],v=r*f-n*a,y=r*u-o*a,P=r*h-i*a,b=n*u-o*f,S=n*h-i*f,k=o*h-i*u,F=p*g-d*w,M=p*A-m*w,N=p*L-x*w,I=d*A-m*g,U=d*L-x*g,R=m*L-x*A,E=v*R-y*U+P*I+b*N-S*M+k*F;return E?(E=1/E,t[0]=(f*R-u*U+h*I)*E,t[1]=(o*U-n*R-i*I)*E,t[2]=(g*k-A*S+L*b)*E,t[3]=(m*S-d*k-x*b)*E,t[4]=(u*N-a*R-h*M)*E,t[5]=(r*R-o*N+i*M)*E,t[6]=(A*P-w*k-L*y)*E,t[7]=(p*k-m*P+x*y)*E,t[8]=(a*U-f*N+h*F)*E,t[9]=(n*N-r*U-i*F)*E,t[10]=(w*S-g*P+L*v)*E,t[11]=(d*P-p*S-x*v)*E,t[12]=(f*M-a*I-u*F)*E,t[13]=(r*I-n*M+o*F)*E,t[14]=(g*y-w*b-A*v)*E,t[15]=(p*b-d*y+m*v)*E,t):null}function Sn(t){let e=t[0],r=t[1],n=t[2],o=t[3],i=t[4],a=t[5],f=t[6],u=t[7],h=t[8],p=t[9],d=t[10],m=t[11],x=t[12],w=t[13],g=t[14],A=t[15],L=e*a-r*i,v=e*f-n*i,y=r*f-n*a,P=h*w-p*x,b=h*g-d*x,S=p*g-d*w,k=e*S-r*b+n*P,F=i*S-a*b+f*P,M=h*y-p*v+d*L,N=x*y-w*v+g*L;return u*k-o*F+A*M-m*N}function $t(t,e,r){let n=e[0],o=e[1],i=e[2],a=e[3],f=e[4],u=e[5],h=e[6],p=e[7],d=e[8],m=e[9],x=e[10],w=e[11],g=e[12],A=e[13],L=e[14],v=e[15],y=r[0],P=r[1],b=r[2],S=r[3];return t[0]=y*n+P*f+b*d+S*g,t[1]=y*o+P*u+b*m+S*A,t[2]=y*i+P*h+b*x+S*L,t[3]=y*a+P*p+b*w+S*v,y=r[4],P=r[5],b=r[6],S=r[7],t[4]=y*n+P*f+b*d+S*g,t[5]=y*o+P*u+b*m+S*A,t[6]=y*i+P*h+b*x+S*L,t[7]=y*a+P*p+b*w+S*v,y=r[8],P=r[9],b=r[10],S=r[11],t[8]=y*n+P*f+b*d+S*g,t[9]=y*o+P*u+b*m+S*A,t[10]=y*i+P*h+b*x+S*L,t[11]=y*a+P*p+b*w+S*v,y=r[12],P=r[13],b=r[14],S=r[15],t[12]=y*n+P*f+b*d+S*g,t[13]=y*o+P*u+b*m+S*A,t[14]=y*i+P*h+b*x+S*L,t[15]=y*a+P*p+b*w+S*v,t}function kn(t,e,r){let n=r[0],o=r[1],i=r[2],a,f,u,h,p,d,m,x,w,g,A,L;return e===t?(t[12]=e[0]*n+e[4]*o+e[8]*i+e[12],t[13]=e[1]*n+e[5]*o+e[9]*i+e[13],t[14]=e[2]*n+e[6]*o+e[10]*i+e[14],t[15]=e[3]*n+e[7]*o+e[11]*i+e[15]):(a=e[0],f=e[1],u=e[2],h=e[3],p=e[4],d=e[5],m=e[6],x=e[7],w=e[8],g=e[9],A=e[10],L=e[11],t[0]=a,t[1]=f,t[2]=u,t[3]=h,t[4]=p,t[5]=d,t[6]=m,t[7]=x,t[8]=w,t[9]=g,t[10]=A,t[11]=L,t[12]=a*n+p*o+w*i+e[12],t[13]=f*n+d*o+g*i+e[13],t[14]=u*n+m*o+A*i+e[14],t[15]=h*n+x*o+L*i+e[15]),t}function Nn(t,e,r){let n=r[0],o=r[1],i=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function En(t,e,r,n){let o=n[0],i=n[1],a=n[2],f=Math.sqrt(o*o+i*i+a*a),u,h,p,d,m,x,w,g,A,L,v,y,P,b,S,k,F,M,N,I,U,R,E,fe;return f<1e-6?null:(f=1/f,o*=f,i*=f,a*=f,h=Math.sin(r),u=Math.cos(r),p=1-u,d=e[0],m=e[1],x=e[2],w=e[3],g=e[4],A=e[5],L=e[6],v=e[7],y=e[8],P=e[9],b=e[10],S=e[11],k=o*o*p+u,F=i*o*p+a*h,M=a*o*p-i*h,N=o*i*p-a*h,I=i*i*p+u,U=a*i*p+o*h,R=o*a*p+i*h,E=i*a*p-o*h,fe=a*a*p+u,t[0]=d*k+g*F+y*M,t[1]=m*k+A*F+P*M,t[2]=x*k+L*F+b*M,t[3]=w*k+v*F+S*M,t[4]=d*N+g*I+y*U,t[5]=m*N+A*I+P*U,t[6]=x*N+L*I+b*U,t[7]=w*N+v*I+S*U,t[8]=d*R+g*E+y*fe,t[9]=m*R+A*E+P*fe,t[10]=x*R+L*E+b*fe,t[11]=w*R+v*E+S*fe,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Tn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[4],a=e[5],f=e[6],u=e[7],h=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*o+h*n,t[5]=a*o+p*n,t[6]=f*o+d*n,t[7]=u*o+m*n,t[8]=h*o-i*n,t[9]=p*o-a*n,t[10]=d*o-f*n,t[11]=m*o-u*n,t}function Mn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[0],a=e[1],f=e[2],u=e[3],h=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o-h*n,t[1]=a*o-p*n,t[2]=f*o-d*n,t[3]=u*o-m*n,t[8]=i*n+h*o,t[9]=a*n+p*o,t[10]=f*n+d*o,t[11]=u*n+m*o,t}function Fn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[0],a=e[1],f=e[2],u=e[3],h=e[4],p=e[5],d=e[6],m=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o+h*n,t[1]=a*o+p*n,t[2]=f*o+d*n,t[3]=u*o+m*n,t[4]=h*o-i*n,t[5]=p*o-a*n,t[6]=d*o-f*n,t[7]=m*o-u*n,t}function In(t,e){let r=e[0],n=e[1],o=e[2],i=e[3],a=r+r,f=n+n,u=o+o,h=r*a,p=n*a,d=n*f,m=o*a,x=o*f,w=o*u,g=i*a,A=i*f,L=i*u;return t[0]=1-d-w,t[1]=p+L,t[2]=m-A,t[3]=0,t[4]=p-L,t[5]=1-h-w,t[6]=x+g,t[7]=0,t[8]=m+A,t[9]=x-g,t[10]=1-h-d,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Cn(t,e,r,n,o,i,a){let f=1/(r-e),u=1/(o-n),h=1/(i-a);return t[0]=i*2*f,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i*2*u,t[6]=0,t[7]=0,t[8]=(r+e)*f,t[9]=(o+n)*u,t[10]=(a+i)*h,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*i*2*h,t[15]=0,t}function di(t,e,r,n,o){let i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let a=1/(n-o);t[10]=(o+n)*a,t[14]=2*o*n*a}else t[10]=-1,t[14]=-2*n;return t}var Rn=di;function mi(t,e,r,n,o,i,a){let f=1/(e-r),u=1/(n-o),h=1/(i-a);return t[0]=-2*f,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*h,t[11]=0,t[12]=(e+r)*f,t[13]=(o+n)*u,t[14]=(a+i)*h,t[15]=1,t}var On=mi;function Un(t,e,r,n){let o,i,a,f,u,h,p,d,m,x,w=e[0],g=e[1],A=e[2],L=n[0],v=n[1],y=n[2],P=r[0],b=r[1],S=r[2];return Math.abs(w-P)<1e-6&&Math.abs(g-b)<1e-6&&Math.abs(A-S)<1e-6?pi(t):(d=w-P,m=g-b,x=A-S,o=1/Math.sqrt(d*d+m*m+x*x),d*=o,m*=o,x*=o,i=v*x-y*m,a=y*d-L*x,f=L*m-v*d,o=Math.sqrt(i*i+a*a+f*f),o?(o=1/o,i*=o,a*=o,f*=o):(i=0,a=0,f=0),u=m*f-x*a,h=x*i-d*f,p=d*a-m*i,o=Math.sqrt(u*u+h*h+p*p),o?(o=1/o,u*=o,h*=o,p*=o):(u=0,h=0,p=0),t[0]=i,t[1]=u,t[2]=d,t[3]=0,t[4]=a,t[5]=h,t[6]=m,t[7]=0,t[8]=f,t[9]=p,t[10]=x,t[11]=0,t[12]=-(i*w+a*g+f*A),t[13]=-(u*w+h*g+p*A),t[14]=-(d*w+m*g+x*A),t[15]=1,t)}function gi(){let t=new H(4);return H!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function zn(t,e,r){let n=e[0],o=e[1],i=e[2],a=e[3];return t[0]=r[0]*n+r[4]*o+r[8]*i+r[12]*a,t[1]=r[1]*n+r[5]*o+r[9]*i+r[13]*a,t[2]=r[2]*n+r[6]*o+r[10]*i+r[14]*a,t[3]=r[3]*n+r[7]*o+r[11]*i+r[15]*a,t}var Wa=function(){let t=gi();return function(e,r,n,o,i,a){let f,u;for(r||(r=4),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],t[2]=e[f+2],t[3]=e[f+3],i(t,t,a),e[f]=t[0],e[f+1]=t[1],e[f+2]=t[2],e[f+3]=t[3];return e}}();var Jt;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Jt||(Jt={}));var xi=45*Math.PI/180,vi=1,Kt=.1,Zt=500,Ai=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ee=class extends Ge{static get IDENTITY(){return yi()}static get ZERO(){return bi()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Jt}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,n,o,i,a,f,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=i,this[5]=a,this[6]=f,this[7]=u,this[8]=h,this[9]=p,this[10]=d,this[11]=m,this[12]=x,this[13]=w,this[14]=g,this[15]=A,this.check()}setRowMajor(e,r,n,o,i,a,f,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=i,this[2]=h,this[3]=x,this[4]=r,this[5]=a,this[6]=p,this[7]=w,this[8]=n,this[9]=f,this[10]=d,this[11]=g,this[12]=o,this[13]=u,this[14]=m,this[15]=A,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Ai)}fromObject(e){return this.check()}fromQuaternion(e){return In(this,e),this.check()}frustum(e){let{left:r,right:n,bottom:o,top:i,near:a=Kt,far:f=Zt}=e;return f===1/0?Pi(this,r,n,o,i,a):Cn(this,r,n,o,i,a,f),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:o=[0,1,0]}=e;return Un(this,r,n,o),this.check()}ortho(e){let{left:r,right:n,bottom:o,top:i,near:a=Kt,far:f=Zt}=e;return On(this,r,n,o,i,a,f),this.check()}orthographic(e){let{fovy:r=xi,aspect:n=vi,focalDistance:o=1,near:i=Kt,far:a=Zt}=e;Dn(r);let f=r/2,u=o*Math.tan(f),h=u*n;return this.ortho({left:-h,right:h,bottom:-u,top:u,near:i,far:a})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:o=.1,far:i=500}=e;return Dn(r),Rn(this,r,n,o,i),this.check()}determinant(){return Sn(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*o,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*o,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return wn(this,this),this.check()}invert(){return Ln(this,this),this.check()}multiplyLeft(e){return $t(this,e,this),this.check()}multiplyRight(e){return $t(this,this,e),this.check()}rotateX(e){return Tn(this,this,e),this.check()}rotateY(e){return Mn(this,this,e),this.check()}rotateZ(e){return Fn(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return En(this,this,e,r),this.check()}scale(e){return Nn(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return kn(this,this,e),this.check()}transform(e,r){return e.length===4?(r=zn(r||[-0,-0,-0,-0],e,this),qe(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,o;switch(n){case 2:o=An(r||[-0,-0],e,this);break;case 3:o=Pn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return qe(o,e.length),o}transformAsVector(e,r){let n;switch(e.length){case 2:n=bn(r||[-0,-0],e,this);break;case 3:n=yn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return qe(n,e.length),n}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},He,We;function bi(){return He||(He=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(He)),He}function yi(){return We||(We=new ee,Object.freeze(We)),We}function Dn(t){if(t>Math.PI*2)throw Error("expected radians")}function Pi(t,e,r,n,o,i){let a=2*i/(r-e),f=2*i/(o-n),u=(r+e)/(r-e),h=(o+n)/(o-n),p=-1,d=-1,m=-2*i;return t[0]=a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=f,t[6]=0,t[7]=0,t[8]=u,t[9]=h,t[10]=p,t[11]=d,t[12]=0,t[13]=0,t[14]=m,t[15]=0,t}var er=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],wi={modelMatrix:er,viewMatrix:er,projectionMatrix:er,cameraPositionWorld:[0,0,0]};function Li(t=wi,e={}){let r={};return t.modelMatrix!==void 0&&(r.modelMatrix=t.modelMatrix),t.viewMatrix!==void 0&&(r.viewMatrix=t.viewMatrix),t.projectionMatrix!==void 0&&(r.projectionMatrix=t.projectionMatrix),t.cameraPositionWorld!==void 0&&(r.cameraPositionWorld=t.cameraPositionWorld),(t.projectionMatrix!==void 0||t.viewMatrix!==void 0)&&(r.viewProjectionMatrix=new ee(t.projectionMatrix).multiplyRight(t.viewMatrix)),r}var Yn=`varying vec4 project_vPositionWorld;
|
|
2464
|
+
`,dn={name:"geometry",vs:si,fs:ai};var Ea=1/Math.PI*180,Ta=1/180*Math.PI,ci={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...ci}};var O=globalThis.mathgl.config;function mn(t,{precision:e=O.precision}={}){return t=li(t),`${parseFloat(t.toPrecision(e))}`}function Be(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Wt(t,e,r){let n=O.EPSILON;r&&(O.EPSILON=r);try{if(t===e)return!0;if(Be(t)&&Be(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!Wt(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=O.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{O.EPSILON=n}}function li(t){return Math.round(t/O.EPSILON)*O.EPSILON}var Ve=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Be(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(O)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+mn(this[n],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Wt(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let o=0;o<this.ELEMENTS;++o){let i=e[o],a=typeof r=="number"?r:r[o];this[o]=i+n*(a-i)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(O.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),r);return this.check()}get elements(){return this}};function fi(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function gn(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function qe(t,e,r=""){if(O.debug&&!fi(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}var H=typeof Float32Array<"u"?Float32Array:Array;var Oa=Math.PI/180;function ui(){let t=new H(2);return H!=Float32Array&&(t[0]=0,t[1]=0),t}function An(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}var Ua=function(){let t=ui();return function(e,r,n,o,i,a){let f,u;for(r||(r=2),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],i(t,t,a),e[f]=t[0],e[f+1]=t[1];return e}}();function bn(t,e,r){let n=e[0],o=e[1],i=r[3]*n+r[7]*o||1;return t[0]=(r[0]*n+r[4]*o)/i,t[1]=(r[1]*n+r[5]*o)/i,t}function yn(t,e,r){let n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i||1;return t[0]=(r[0]*n+r[4]*o+r[8]*i)/a,t[1]=(r[1]*n+r[5]*o+r[9]*i)/a,t[2]=(r[2]*n+r[6]*o+r[10]*i)/a,t}function _i(){let t=new H(3);return H!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Pn(t,e,r){let n=e[0],o=e[1],i=e[2],a=r[3]*n+r[7]*o+r[11]*i+r[15];return a=a||1,t[0]=(r[0]*n+r[4]*o+r[8]*i+r[12])/a,t[1]=(r[1]*n+r[5]*o+r[9]*i+r[13])/a,t[2]=(r[2]*n+r[6]*o+r[10]*i+r[14])/a,t}var Ya=function(){let t=_i();return function(e,r,n,o,i,a){let f,u;for(r||(r=3),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],t[2]=e[f+2],i(t,t,a),e[f]=t[0],e[f+1]=t[1],e[f+2]=t[2];return e}}();var Ge=class extends Ve{toString(){let e="[";if(O.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=gn(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)r[o]=this[n+o];return r}setColumn(e,r){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=r[o];return this}};function hi(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function wn(t,e){if(t===e){let r=e[1],n=e[2],o=e[3],i=e[6],a=e[7],f=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=i,t[11]=e[14],t[12]=o,t[13]=a,t[14]=f}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ln(t,e){let r=e[0],n=e[1],o=e[2],i=e[3],a=e[4],f=e[5],u=e[6],h=e[7],p=e[8],d=e[9],m=e[10],x=e[11],w=e[12],g=e[13],A=e[14],L=e[15],v=r*f-n*a,y=r*u-o*a,P=r*h-i*a,b=n*u-o*f,S=n*h-i*f,k=o*h-i*u,F=p*g-d*w,M=p*A-m*w,N=p*L-x*w,I=d*A-m*g,U=d*L-x*g,R=m*L-x*A,E=v*R-y*U+P*I+b*N-S*M+k*F;return E?(E=1/E,t[0]=(f*R-u*U+h*I)*E,t[1]=(o*U-n*R-i*I)*E,t[2]=(g*k-A*S+L*b)*E,t[3]=(m*S-d*k-x*b)*E,t[4]=(u*N-a*R-h*M)*E,t[5]=(r*R-o*N+i*M)*E,t[6]=(A*P-w*k-L*y)*E,t[7]=(p*k-m*P+x*y)*E,t[8]=(a*U-f*N+h*F)*E,t[9]=(n*N-r*U-i*F)*E,t[10]=(w*S-g*P+L*v)*E,t[11]=(d*P-p*S-x*v)*E,t[12]=(f*M-a*I-u*F)*E,t[13]=(r*I-n*M+o*F)*E,t[14]=(g*y-w*b-A*v)*E,t[15]=(p*b-d*y+m*v)*E,t):null}function Sn(t){let e=t[0],r=t[1],n=t[2],o=t[3],i=t[4],a=t[5],f=t[6],u=t[7],h=t[8],p=t[9],d=t[10],m=t[11],x=t[12],w=t[13],g=t[14],A=t[15],L=e*a-r*i,v=e*f-n*i,y=r*f-n*a,P=h*w-p*x,b=h*g-d*x,S=p*g-d*w,k=e*S-r*b+n*P,F=i*S-a*b+f*P,M=h*y-p*v+d*L,N=x*y-w*v+g*L;return u*k-o*F+A*M-m*N}function $t(t,e,r){let n=e[0],o=e[1],i=e[2],a=e[3],f=e[4],u=e[5],h=e[6],p=e[7],d=e[8],m=e[9],x=e[10],w=e[11],g=e[12],A=e[13],L=e[14],v=e[15],y=r[0],P=r[1],b=r[2],S=r[3];return t[0]=y*n+P*f+b*d+S*g,t[1]=y*o+P*u+b*m+S*A,t[2]=y*i+P*h+b*x+S*L,t[3]=y*a+P*p+b*w+S*v,y=r[4],P=r[5],b=r[6],S=r[7],t[4]=y*n+P*f+b*d+S*g,t[5]=y*o+P*u+b*m+S*A,t[6]=y*i+P*h+b*x+S*L,t[7]=y*a+P*p+b*w+S*v,y=r[8],P=r[9],b=r[10],S=r[11],t[8]=y*n+P*f+b*d+S*g,t[9]=y*o+P*u+b*m+S*A,t[10]=y*i+P*h+b*x+S*L,t[11]=y*a+P*p+b*w+S*v,y=r[12],P=r[13],b=r[14],S=r[15],t[12]=y*n+P*f+b*d+S*g,t[13]=y*o+P*u+b*m+S*A,t[14]=y*i+P*h+b*x+S*L,t[15]=y*a+P*p+b*w+S*v,t}function kn(t,e,r){let n=r[0],o=r[1],i=r[2],a,f,u,h,p,d,m,x,w,g,A,L;return e===t?(t[12]=e[0]*n+e[4]*o+e[8]*i+e[12],t[13]=e[1]*n+e[5]*o+e[9]*i+e[13],t[14]=e[2]*n+e[6]*o+e[10]*i+e[14],t[15]=e[3]*n+e[7]*o+e[11]*i+e[15]):(a=e[0],f=e[1],u=e[2],h=e[3],p=e[4],d=e[5],m=e[6],x=e[7],w=e[8],g=e[9],A=e[10],L=e[11],t[0]=a,t[1]=f,t[2]=u,t[3]=h,t[4]=p,t[5]=d,t[6]=m,t[7]=x,t[8]=w,t[9]=g,t[10]=A,t[11]=L,t[12]=a*n+p*o+w*i+e[12],t[13]=f*n+d*o+g*i+e[13],t[14]=u*n+m*o+A*i+e[14],t[15]=h*n+x*o+L*i+e[15]),t}function Nn(t,e,r){let n=r[0],o=r[1],i=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function En(t,e,r,n){let o=n[0],i=n[1],a=n[2],f=Math.sqrt(o*o+i*i+a*a),u,h,p,d,m,x,w,g,A,L,v,y,P,b,S,k,F,M,N,I,U,R,E,fe;return f<1e-6?null:(f=1/f,o*=f,i*=f,a*=f,h=Math.sin(r),u=Math.cos(r),p=1-u,d=e[0],m=e[1],x=e[2],w=e[3],g=e[4],A=e[5],L=e[6],v=e[7],y=e[8],P=e[9],b=e[10],S=e[11],k=o*o*p+u,F=i*o*p+a*h,M=a*o*p-i*h,N=o*i*p-a*h,I=i*i*p+u,U=a*i*p+o*h,R=o*a*p+i*h,E=i*a*p-o*h,fe=a*a*p+u,t[0]=d*k+g*F+y*M,t[1]=m*k+A*F+P*M,t[2]=x*k+L*F+b*M,t[3]=w*k+v*F+S*M,t[4]=d*N+g*I+y*U,t[5]=m*N+A*I+P*U,t[6]=x*N+L*I+b*U,t[7]=w*N+v*I+S*U,t[8]=d*R+g*E+y*fe,t[9]=m*R+A*E+P*fe,t[10]=x*R+L*E+b*fe,t[11]=w*R+v*E+S*fe,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Tn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[4],a=e[5],f=e[6],u=e[7],h=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=i*o+h*n,t[5]=a*o+p*n,t[6]=f*o+d*n,t[7]=u*o+m*n,t[8]=h*o-i*n,t[9]=p*o-a*n,t[10]=d*o-f*n,t[11]=m*o-u*n,t}function Mn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[0],a=e[1],f=e[2],u=e[3],h=e[8],p=e[9],d=e[10],m=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o-h*n,t[1]=a*o-p*n,t[2]=f*o-d*n,t[3]=u*o-m*n,t[8]=i*n+h*o,t[9]=a*n+p*o,t[10]=f*n+d*o,t[11]=u*n+m*o,t}function Fn(t,e,r){let n=Math.sin(r),o=Math.cos(r),i=e[0],a=e[1],f=e[2],u=e[3],h=e[4],p=e[5],d=e[6],m=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=i*o+h*n,t[1]=a*o+p*n,t[2]=f*o+d*n,t[3]=u*o+m*n,t[4]=h*o-i*n,t[5]=p*o-a*n,t[6]=d*o-f*n,t[7]=m*o-u*n,t}function In(t,e){let r=e[0],n=e[1],o=e[2],i=e[3],a=r+r,f=n+n,u=o+o,h=r*a,p=n*a,d=n*f,m=o*a,x=o*f,w=o*u,g=i*a,A=i*f,L=i*u;return t[0]=1-d-w,t[1]=p+L,t[2]=m-A,t[3]=0,t[4]=p-L,t[5]=1-h-w,t[6]=x+g,t[7]=0,t[8]=m+A,t[9]=x-g,t[10]=1-h-d,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Cn(t,e,r,n,o,i,a){let f=1/(r-e),u=1/(o-n),h=1/(i-a);return t[0]=i*2*f,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i*2*u,t[6]=0,t[7]=0,t[8]=(r+e)*f,t[9]=(o+n)*u,t[10]=(a+i)*h,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*i*2*h,t[15]=0,t}function pi(t,e,r,n,o){let i=1/Math.tan(e/2);if(t[0]=i/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let a=1/(n-o);t[10]=(o+n)*a,t[14]=2*o*n*a}else t[10]=-1,t[14]=-2*n;return t}var Rn=pi;function di(t,e,r,n,o,i,a){let f=1/(e-r),u=1/(n-o),h=1/(i-a);return t[0]=-2*f,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*h,t[11]=0,t[12]=(e+r)*f,t[13]=(o+n)*u,t[14]=(a+i)*h,t[15]=1,t}var On=di;function Un(t,e,r,n){let o,i,a,f,u,h,p,d,m,x,w=e[0],g=e[1],A=e[2],L=n[0],v=n[1],y=n[2],P=r[0],b=r[1],S=r[2];return Math.abs(w-P)<1e-6&&Math.abs(g-b)<1e-6&&Math.abs(A-S)<1e-6?hi(t):(d=w-P,m=g-b,x=A-S,o=1/Math.sqrt(d*d+m*m+x*x),d*=o,m*=o,x*=o,i=v*x-y*m,a=y*d-L*x,f=L*m-v*d,o=Math.sqrt(i*i+a*a+f*f),o?(o=1/o,i*=o,a*=o,f*=o):(i=0,a=0,f=0),u=m*f-x*a,h=x*i-d*f,p=d*a-m*i,o=Math.sqrt(u*u+h*h+p*p),o?(o=1/o,u*=o,h*=o,p*=o):(u=0,h=0,p=0),t[0]=i,t[1]=u,t[2]=d,t[3]=0,t[4]=a,t[5]=h,t[6]=m,t[7]=0,t[8]=f,t[9]=p,t[10]=x,t[11]=0,t[12]=-(i*w+a*g+f*A),t[13]=-(u*w+h*g+p*A),t[14]=-(d*w+m*g+x*A),t[15]=1,t)}function mi(){let t=new H(4);return H!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function zn(t,e,r){let n=e[0],o=e[1],i=e[2],a=e[3];return t[0]=r[0]*n+r[4]*o+r[8]*i+r[12]*a,t[1]=r[1]*n+r[5]*o+r[9]*i+r[13]*a,t[2]=r[2]*n+r[6]*o+r[10]*i+r[14]*a,t[3]=r[3]*n+r[7]*o+r[11]*i+r[15]*a,t}var Ha=function(){let t=mi();return function(e,r,n,o,i,a){let f,u;for(r||(r=4),n||(n=0),o?u=Math.min(o*r+n,e.length):u=e.length,f=n;f<u;f+=r)t[0]=e[f],t[1]=e[f+1],t[2]=e[f+2],t[3]=e[f+3],i(t,t,a),e[f]=t[0],e[f+1]=t[1],e[f+2]=t[2],e[f+3]=t[3];return e}}();var Jt;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Jt||(Jt={}));var gi=45*Math.PI/180,xi=1,Kt=.1,Zt=500,vi=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),ee=class extends Ge{static get IDENTITY(){return bi()}static get ZERO(){return Ai()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Jt}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,n,o,i,a,f,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=i,this[5]=a,this[6]=f,this[7]=u,this[8]=h,this[9]=p,this[10]=d,this[11]=m,this[12]=x,this[13]=w,this[14]=g,this[15]=A,this.check()}setRowMajor(e,r,n,o,i,a,f,u,h,p,d,m,x,w,g,A){return this[0]=e,this[1]=i,this[2]=h,this[3]=x,this[4]=r,this[5]=a,this[6]=p,this[7]=w,this[8]=n,this[9]=f,this[10]=d,this[11]=g,this[12]=o,this[13]=u,this[14]=m,this[15]=A,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(vi)}fromObject(e){return this.check()}fromQuaternion(e){return In(this,e),this.check()}frustum(e){let{left:r,right:n,bottom:o,top:i,near:a=Kt,far:f=Zt}=e;return f===1/0?yi(this,r,n,o,i,a):Cn(this,r,n,o,i,a,f),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:o=[0,1,0]}=e;return Un(this,r,n,o),this.check()}ortho(e){let{left:r,right:n,bottom:o,top:i,near:a=Kt,far:f=Zt}=e;return On(this,r,n,o,i,a,f),this.check()}orthographic(e){let{fovy:r=gi,aspect:n=xi,focalDistance:o=1,near:i=Kt,far:a=Zt}=e;Dn(r);let f=r/2,u=o*Math.tan(f),h=u*n;return this.ortho({left:-h,right:h,bottom:-u,top:u,near:i,far:a})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:o=.1,far:i=500}=e;return Dn(r),Rn(this,r,n,o,i),this.check()}determinant(){return Sn(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],i=1/n[1],a=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*o,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*o,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return wn(this,this),this.check()}invert(){return Ln(this,this),this.check()}multiplyLeft(e){return $t(this,e,this),this.check()}multiplyRight(e){return $t(this,this,e),this.check()}rotateX(e){return Tn(this,this,e),this.check()}rotateY(e){return Mn(this,this,e),this.check()}rotateZ(e){return Fn(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return En(this,this,e,r),this.check()}scale(e){return Nn(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return kn(this,this,e),this.check()}transform(e,r){return e.length===4?(r=zn(r||[-0,-0,-0,-0],e,this),qe(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,o;switch(n){case 2:o=An(r||[-0,-0],e,this);break;case 3:o=Pn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return qe(o,e.length),o}transformAsVector(e,r){let n;switch(e.length){case 2:n=bn(r||[-0,-0],e,this);break;case 3:n=yn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return qe(n,e.length),n}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},He,We;function Ai(){return He||(He=new ee([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(He)),He}function bi(){return We||(We=new ee,Object.freeze(We)),We}function Dn(t){if(t>Math.PI*2)throw Error("expected radians")}function yi(t,e,r,n,o,i){let a=2*i/(r-e),f=2*i/(o-n),u=(r+e)/(r-e),h=(o+n)/(o-n),p=-1,d=-1,m=-2*i;return t[0]=a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=f,t[6]=0,t[7]=0,t[8]=u,t[9]=h,t[10]=p,t[11]=d,t[12]=0,t[13]=0,t[14]=m,t[15]=0,t}var er=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Pi={modelMatrix:er,viewMatrix:er,projectionMatrix:er,cameraPositionWorld:[0,0,0]};function wi(t=Pi,e={}){let r={};return t.modelMatrix!==void 0&&(r.modelMatrix=t.modelMatrix),t.viewMatrix!==void 0&&(r.viewMatrix=t.viewMatrix),t.projectionMatrix!==void 0&&(r.projectionMatrix=t.projectionMatrix),t.cameraPositionWorld!==void 0&&(r.cameraPositionWorld=t.cameraPositionWorld),(t.projectionMatrix!==void 0||t.viewMatrix!==void 0)&&(r.viewProjectionMatrix=new ee(t.projectionMatrix).multiplyRight(t.viewMatrix)),r}var Yn=`varying vec4 project_vPositionWorld;
|
|
2465
2465
|
varying vec3 project_vNormalWorld;
|
|
2466
2466
|
vec4 project_getPosition_World() {
|
|
2467
2467
|
return project_vPositionWorld;
|
|
@@ -2469,7 +2469,7 @@ return project_vPositionWorld;
|
|
|
2469
2469
|
vec3 project_getNormal_World() {
|
|
2470
2470
|
return project_vNormalWorld;
|
|
2471
2471
|
}
|
|
2472
|
-
`,
|
|
2472
|
+
`,Li=`${Yn}
|
|
2473
2473
|
|
|
2474
2474
|
// Unprefixed uniforms
|
|
2475
2475
|
uniform mat4 modelMatrix;
|
|
@@ -2522,8 +2522,8 @@ vec4 project_view_to_clipspace(vec3 position) {
|
|
|
2522
2522
|
vec4 project_to_clipspace(vec3 position) {
|
|
2523
2523
|
return viewProjectionMatrix * vec4(position, 1.);
|
|
2524
2524
|
}
|
|
2525
|
-
`,
|
|
2526
|
-
${Yn}`,je={name:"project",getUniforms:
|
|
2525
|
+
`,Si=`
|
|
2526
|
+
${Yn}`,je={name:"project",getUniforms:wi,vs:Li,fs:Si};var tr=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
2527
2527
|
struct AmbientLight {
|
|
2528
2528
|
vec3 color;
|
|
2529
2529
|
};
|
|
@@ -2548,13 +2548,13 @@ return pointLight.attenuation.x
|
|
|
2548
2548
|
+ pointLight.attenuation.z * distance * distance;
|
|
2549
2549
|
}
|
|
2550
2550
|
#endif
|
|
2551
|
-
`;var
|
|
2551
|
+
`;var ki={lightSources:{}};function rr(t={}){let{color:e=[0,0,0],intensity:r=1}=t;return e.map(n=>n*r/255)}function Ni({ambientLight:t,pointLights:e=[],directionalLights:r=[]}){let n={};return t?n["lighting_uAmbientLight.color"]=rr(t):n["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((o,i)=>{n[`lighting_uPointLight[${i}].color`]=rr(o),n[`lighting_uPointLight[${i}].position`]=o.position,n[`lighting_uPointLight[${i}].attenuation`]=o.attenuation||[1,0,0]}),n.lighting_uPointLightCount=e.length,r.forEach((o,i)=>{n[`lighting_uDirectionalLight[${i}].color`]=rr(o),n[`lighting_uDirectionalLight[${i}].direction`]=o.direction}),n.lighting_uDirectionalLightCount=r.length,n}function Xn(t=ki){if("lightSources"in t){let{ambientLight:e,pointLights:r,directionalLights:n}=t.lightSources||{};return e||r&&r.length>0||n&&n.length>0?Object.assign({},Ni({ambientLight:e,pointLights:r,directionalLights:n}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){let e={pointLights:[],directionalLights:[]};for(let r of t.lights||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;default:}return Xn({lightSources:e})}return{}}var te={name:"lights",vs:tr,fs:tr,getUniforms:Xn,defines:{MAX_LIGHTS:3}};var Ei={lightDirection:new Float32Array([1,1,2])};function Ti(t=Ei){let e={};return t.lightDirection&&(e.dirlight_uLightDirection=t.lightDirection),e}var Mi=`uniform vec3 dirlight_uLightDirection;
|
|
2552
2552
|
vec4 dirlight_filterColor(vec4 color) {
|
|
2553
2553
|
vec3 normal = project_getNormal_World();
|
|
2554
2554
|
float d = abs(dot(normalize(normal), normalize(dirlight_uLightDirection)));
|
|
2555
2555
|
return vec4(color.rgb * d, color.a);
|
|
2556
2556
|
}
|
|
2557
|
-
`,Qn={name:"dirlight",fs:
|
|
2557
|
+
`,Qn={name:"dirlight",fs:Mi,getUniforms:Ti,dependencies:[je]};var nr=`uniform float lighting_uAmbient;
|
|
2558
2558
|
uniform float lighting_uDiffuse;
|
|
2559
2559
|
uniform float lighting_uShininess;
|
|
2560
2560
|
uniform vec3 lighting_uSpecularColor;
|
|
@@ -2617,7 +2617,7 @@ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction,
|
|
|
2617
2617
|
}
|
|
2618
2618
|
return lightColor;
|
|
2619
2619
|
}
|
|
2620
|
-
`;var
|
|
2620
|
+
`;var Fi={};function Ii(t){let{ambient:e=.35,diffuse:r=.6,shininess:n=32,specularColor:o=[30,30,30]}=t;return{lighting_uAmbient:e,lighting_uDiffuse:r,lighting_uShininess:n,lighting_uSpecularColor:o.map(i=>i/255)}}function Bn(t=Fi){if(!("material"in t))return{};let{material:e}=t;return e?Ii(e):{lighting_uEnabled:!1}}var Vn={name:"gouraud-lighting",dependencies:[te],vs:nr,defines:{LIGHTING_VERTEX:1},getUniforms:Bn},qn={name:"phong-lighting",dependencies:[te],fs:nr,defines:{LIGHTING_FRAGMENT:1},getUniforms:Bn};var Gn=`uniform mat4 u_MVPMatrix;
|
|
2621
2621
|
uniform mat4 u_ModelMatrix;
|
|
2622
2622
|
uniform mat4 u_NormalMatrix;
|
|
2623
2623
|
out vec3 pbr_vPosition;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { NumberArray } from '@math.gl/types';
|
|
2
3
|
import { UniformFormat } from "../../types.js";
|
|
3
4
|
import { PropType } from "../filters/prop-types.js";
|
|
5
|
+
import { Sampler, Texture } from '@luma.gl/core';
|
|
4
6
|
export type UniformValue = number | boolean | Readonly<NumberArray>;
|
|
5
7
|
export type UniformInfo = {
|
|
6
8
|
format?: UniformFormat;
|
|
@@ -9,7 +11,7 @@ export type UniformInfo = {
|
|
|
9
11
|
* A shader module definition object
|
|
10
12
|
* @note Can be viewed as the ShaderModuleProps for a ShaderModuleInstance
|
|
11
13
|
*/
|
|
12
|
-
export type ShaderModule<PropsT extends Record<string, unknown> = Record<string, unknown>, UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>, BindingsT extends Record<string,
|
|
14
|
+
export type ShaderModule<PropsT extends Record<string, unknown> = Record<string, unknown>, UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>, BindingsT extends Record<string, Buffer | Texture | Sampler> = {}> = {
|
|
13
15
|
/** Used for type inference not for values */
|
|
14
16
|
props?: Required<PropsT>;
|
|
15
17
|
/** Used for type inference, not currently used for values */
|
|
@@ -23,8 +25,8 @@ export type ShaderModule<PropsT extends Record<string, unknown> = Record<string,
|
|
|
23
25
|
uniformPropTypes?: Record<keyof UniformsT, UniformInfo>;
|
|
24
26
|
/** Default uniform values */
|
|
25
27
|
defaultUniforms?: Required<UniformsT>;
|
|
26
|
-
/** Function that maps
|
|
27
|
-
getUniforms?: (
|
|
28
|
+
/** Function that maps props to uniforms & bindings */
|
|
29
|
+
getUniforms?: (props?: any, oldProps?: any) => Record<string, UniformValue>;
|
|
28
30
|
/** uniform buffers, textures, samplers, storage, ... */
|
|
29
31
|
bindings?: Record<keyof BindingsT, {
|
|
30
32
|
location: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-module.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,aAAa,EAAC,uBAAoB;AAC1C,OAAO,EAAC,QAAQ,EAAC,iCAA8B;AAE/C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;AAEpE,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,GAAG,QAAQ,CAAC;AAEb;;;GAGG;AACH,MAAM,MAAM,YAAY,CACtB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAC7E,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../../src/lib/shader-module/shader-module.ts"],"names":[],"mappings":";AAIA,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,aAAa,EAAC,uBAAoB;AAC1C,OAAO,EAAC,QAAQ,EAAC,iCAA8B;AAC/C,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;AAEpE,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,GAAG,QAAQ,CAAC;AAEb;;;GAGG;AACH,MAAM,MAAM,YAAY,CACtB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAC7E,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,IAC/D;IACF,6CAA6C;IAC7C,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IAEZ,uGAAuG;IACvG,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,SAAS,EAAE,aAAa,CAAC,CAAC;IACtD,6BAA6B;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,SAAS,EAAE,WAAW,CAAC,CAAC;IACxD,6BAA6B;IAC7B,eAAe,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEtC,sDAAsD;IACtD,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,GAAG,KAAK,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAE5E,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,SAAS,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;KAAC,CAAC,CAAC;IAEjG,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAC1C,iBAAiB;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IACrE,YAAY,CAAC,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACxC,2CAA2C;IAC3C,YAAY,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAEzC,eAAe;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,8DAA8D;AAC9D,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/shadertools",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.15",
|
|
4
4
|
"description": "Shader module system for luma.gl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"@math.gl/core": "^4.0.0",
|
|
53
53
|
"@math.gl/types": "^4.0.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "48b6e702cf6ad35748cfa88ffd249c17861ff2af"
|
|
56
56
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import {NumberArray} from '@math.gl/types';
|
|
6
6
|
import {UniformFormat} from '../../types';
|
|
7
7
|
import {PropType} from '../filters/prop-types';
|
|
8
|
+
import {Sampler, Texture} from '@luma.gl/core';
|
|
8
9
|
|
|
9
10
|
export type UniformValue = number | boolean | Readonly<NumberArray>; // Float32Array> | Readonly<Int32Array> | Readonly<Uint32Array> | Readonly<number[]>;
|
|
10
11
|
|
|
@@ -19,7 +20,7 @@ export type UniformInfo = {
|
|
|
19
20
|
export type ShaderModule<
|
|
20
21
|
PropsT extends Record<string, unknown> = Record<string, unknown>,
|
|
21
22
|
UniformsT extends Record<string, UniformValue> = Record<string, UniformValue>,
|
|
22
|
-
BindingsT extends Record<string,
|
|
23
|
+
BindingsT extends Record<string, Buffer | Texture | Sampler> = {}
|
|
23
24
|
> = {
|
|
24
25
|
/** Used for type inference not for values */
|
|
25
26
|
props?: Required<PropsT>;
|
|
@@ -37,9 +38,8 @@ export type ShaderModule<
|
|
|
37
38
|
/** Default uniform values */
|
|
38
39
|
defaultUniforms?: Required<UniformsT>; // Record<keyof UniformsT, UniformValue>;
|
|
39
40
|
|
|
40
|
-
/** Function that maps
|
|
41
|
-
|
|
42
|
-
getUniforms?: (settings?: any, prevUniforms?: any) => Record<string, UniformValue>;
|
|
41
|
+
/** Function that maps props to uniforms & bindings */
|
|
42
|
+
getUniforms?: (props?: any, oldProps?: any) => Record<string, UniformValue>;
|
|
43
43
|
|
|
44
44
|
/** uniform buffers, textures, samplers, storage, ... */
|
|
45
45
|
bindings?: Record<keyof BindingsT, {location: number; type: 'texture' | 'sampler' | 'uniforms'}>;
|