@luma.gl/shadertools 9.0.0-beta.8 → 9.0.0-beta.9

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
@@ -554,62 +554,6 @@ ${moduleSource}
554
554
  `;
555
555
  }
556
556
  }
557
- function getVersionDefines(platformInfo) {
558
- let versionDefines = "";
559
- if (platformInfo.features.has("webgl2")) {
560
- versionDefines += glsl`\
561
- # define FEATURE_GLSL_DERIVATIVES
562
- # define FEATURE_GLSL_DRAW_BUFFERS
563
- # define FEATURE_GLSL_FRAG_DEPTH
564
- # define FEATURE_GLSL_TEXTURE_LOD
565
- `;
566
- }
567
- if (!platformInfo.features.has("webgl2")) {
568
- if (platformInfo.features.has("glsl-frag-depth")) {
569
- versionDefines += glsl`\
570
-
571
- // FEATURE_GLSL_FRAG_DEPTH => gl_FragDepth is available
572
- #ifdef GL_EXT_frag_depth
573
- # extension GL_EXT_frag_depth : enable
574
- # define FEATURE_GLSL_FRAG_DEPTH
575
- # define FRAG_DEPTH
576
- # define gl_FragDepth gl_FragDepthEXT
577
- #endif
578
- `;
579
- }
580
- if (platformInfo?.features.has("glsl-derivatives")) {
581
- versionDefines += glsl`\
582
-
583
- // FEATURE_GLSL_DERIVATIVES => dxdF, dxdY and fwidth are available
584
- #if defined(GL_OES_standard_derivatives) || defined(FEATURE_GLSL_DERIVATIVES)
585
- # extension GL_OES_standard_derivatives : enable
586
- # define FEATURE_GLSL_DERIVATIVES
587
- #endif
588
- `;
589
- }
590
- if (platformInfo?.features.has("glsl-frag-data")) {
591
- versionDefines += glsl`\
592
-
593
- // FEATURE_GLSL_DRAW_BUFFERS => gl_FragData[] is available
594
- #ifdef GL_EXT_draw_buffers
595
- # extension GL_EXT_draw_buffers : require
596
- # define FEATURE_GLSL_DRAW_BUFFERS
597
- #endif
598
- `;
599
- }
600
- if (platformInfo?.features.has("glsl-texture-lod")) {
601
- versionDefines += glsl`\
602
- // TEXTURE_LOD => texture2DLod etc are available
603
- #ifdef GL_EXT_shader_texture_lod
604
- # extension GL_EXT_shader_texture_lod : enable
605
- # define FEATURE_GLSL_TEXTURE_LOD
606
- # define TEXTURE_LOD
607
- #endif
608
- `;
609
- }
610
- }
611
- return versionDefines;
612
- }
613
557
 
614
558
  // src/lib/shader-transpiler/transpile-glsl-shader.ts
615
559
  function transpileGLSLShader(source, stage) {
@@ -897,7 +841,6 @@ precision highp float;
897
841
  ${getShaderNameDefine({ id, source, stage })}
898
842
  ${`#define SHADER_TYPE_${stage.toUpperCase()}`}
899
843
  ${getPlatformShaderDefines(platformInfo)}
900
- ${getVersionDefines(platformInfo)}
901
844
  ${stage === "fragment" ? FRAGMENT_SHADER_PROLOGUE : ""}
902
845
 
903
846
  // ----- APPLICATION DEFINES -------------------------
@@ -5046,14 +4989,6 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
5046
4989
 
5047
4990
  // src/modules/lighting/pbr-material/pbr-fragment-glsl.ts
5048
4991
  var fs3 = glsl`\
5049
- #if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
5050
- # error PBR fragment shader: Texture LOD is not available
5051
- #endif
5052
-
5053
- #if !defined(HAS_TANGENTS) && !defined(FEATURE_GLSL_DERIVATIVES)
5054
- # error PBR fragment shader: Derivatives are not available
5055
- #endif
5056
-
5057
4992
  precision highp float;
5058
4993
 
5059
4994
  uniform Projection {
@@ -5400,7 +5335,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
5400
5335
  color += calculateFinalColor(pbrInfo, lighting_uAmbientLight.color);
5401
5336
 
5402
5337
  // Apply directional light
5403
- for(int i = 0, i < lighting_uDirectionalLightCount, i++) {
5338
+ for(int i = 0; i < lighting_uDirectionalLightCount; i++) {
5404
5339
  if (i < lighting_uDirectionalLightCount) {
5405
5340
  PBRInfo_setDirectionalLight(pbrInfo, lighting_uDirectionalLight[i].direction);
5406
5341
  color += calculateFinalColor(pbrInfo, lighting_uDirectionalLight[i].color);
@@ -5408,7 +5343,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
5408
5343
  }
5409
5344
 
5410
5345
  // Apply point light
5411
- for(int i = 0, i < lighting_uPointLightCount, i++) {
5346
+ for(int i = 0; i < lighting_uPointLightCount; i++) {
5412
5347
  if (i < lighting_uPointLightCount) {
5413
5348
  PBRInfo_setPointLight(pbrInfo, lighting_uPointLight[i]);
5414
5349
  float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));
@@ -7910,17 +7845,11 @@ vec3 geometry_getNormal() {
7910
7845
  printRowMajor: true,
7911
7846
  _cartographicRadians: false
7912
7847
  };
7913
- globalThis.mathgl = globalThis.mathgl || {
7914
- config: {
7915
- ...DEFAULT_CONFIG
7916
- }
7917
- };
7848
+ globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
7918
7849
  var config = globalThis.mathgl.config;
7919
- function formatValue(value, {
7920
- precision = config.precision
7921
- } = {}) {
7850
+ function formatValue(value, { precision = config.precision } = {}) {
7922
7851
  value = round(value);
7923
- return "".concat(parseFloat(value.toPrecision(precision)));
7852
+ return `${parseFloat(value.toPrecision(precision))}`;
7924
7853
  }
7925
7854
  function isArray(value) {
7926
7855
  return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
@@ -7964,28 +7893,12 @@ vec3 geometry_getNormal() {
7964
7893
  }
7965
7894
 
7966
7895
  // ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
7967
- function _extendableBuiltin(cls) {
7968
- function ExtendableBuiltin() {
7969
- var instance = Reflect.construct(cls, Array.from(arguments));
7970
- Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
7971
- return instance;
7972
- }
7973
- ExtendableBuiltin.prototype = Object.create(cls.prototype, {
7974
- constructor: {
7975
- value: cls,
7976
- enumerable: false,
7977
- writable: true,
7978
- configurable: true
7979
- }
7980
- });
7981
- if (Object.setPrototypeOf) {
7982
- Object.setPrototypeOf(ExtendableBuiltin, cls);
7983
- } else {
7984
- ExtendableBuiltin.__proto__ = cls;
7985
- }
7986
- return ExtendableBuiltin;
7987
- }
7988
- 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
+ */
7989
7902
  clone() {
7990
7903
  return new this.constructor().copy(this);
7991
7904
  }
@@ -8005,7 +7918,10 @@ vec3 geometry_getNormal() {
8005
7918
  return targetObject;
8006
7919
  }
8007
7920
  from(arrayOrObject) {
8008
- return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
7921
+ return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
7922
+ // @ts-ignore
7923
+ this.fromObject(arrayOrObject)
7924
+ );
8009
7925
  }
8010
7926
  to(arrayOrObject) {
8011
7927
  if (arrayOrObject === this) {
@@ -8016,18 +7932,20 @@ vec3 geometry_getNormal() {
8016
7932
  toTarget(target) {
8017
7933
  return target ? this.to(target) : this;
8018
7934
  }
7935
+ /** @deprecated */
8019
7936
  toFloat32Array() {
8020
7937
  return new Float32Array(this);
8021
7938
  }
8022
7939
  toString() {
8023
7940
  return this.formatString(config);
8024
7941
  }
7942
+ /** Formats string according to options */
8025
7943
  formatString(opts) {
8026
7944
  let string = "";
8027
7945
  for (let i = 0; i < this.ELEMENTS; ++i) {
8028
7946
  string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
8029
7947
  }
8030
- return "".concat(opts.printTypes ? this.constructor.name : "", "[").concat(string, "]");
7948
+ return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
8031
7949
  }
8032
7950
  equals(array) {
8033
7951
  if (!array || this.length !== array.length) {
@@ -8051,6 +7969,8 @@ vec3 geometry_getNormal() {
8051
7969
  }
8052
7970
  return true;
8053
7971
  }
7972
+ // Modifiers
7973
+ /** Negates all values in this object */
8054
7974
  negate() {
8055
7975
  for (let i = 0; i < this.ELEMENTS; ++i) {
8056
7976
  this[i] = -this[i];
@@ -8068,12 +7988,14 @@ vec3 geometry_getNormal() {
8068
7988
  }
8069
7989
  return this.check();
8070
7990
  }
7991
+ /** Minimal */
8071
7992
  min(vector) {
8072
7993
  for (let i = 0; i < this.ELEMENTS; ++i) {
8073
7994
  this[i] = Math.min(vector[i], this[i]);
8074
7995
  }
8075
7996
  return this.check();
8076
7997
  }
7998
+ /** Maximal */
8077
7999
  max(vector) {
8078
8000
  for (let i = 0; i < this.ELEMENTS; ++i) {
8079
8001
  this[i] = Math.max(vector[i], this[i]);
@@ -8114,18 +8036,25 @@ vec3 geometry_getNormal() {
8114
8036
  }
8115
8037
  return this.check();
8116
8038
  }
8039
+ /**
8040
+ * Multiplies all elements by `scale`
8041
+ * Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
8042
+ */
8117
8043
  multiplyByScalar(scalar) {
8118
8044
  for (let i = 0; i < this.ELEMENTS; ++i) {
8119
8045
  this[i] *= scalar;
8120
8046
  }
8121
8047
  return this.check();
8122
8048
  }
8049
+ // Debug checks
8050
+ /** Throws an error if array length is incorrect or contains illegal values */
8123
8051
  check() {
8124
8052
  if (config.debug && !this.validate()) {
8125
- throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
8053
+ throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
8126
8054
  }
8127
8055
  return this;
8128
8056
  }
8057
+ /** Returns false if the array length is incorrect or contains illegal values */
8129
8058
  validate() {
8130
8059
  let valid = this.length === this.ELEMENTS;
8131
8060
  for (let i = 0; i < this.ELEMENTS; ++i) {
@@ -8133,39 +8062,48 @@ vec3 geometry_getNormal() {
8133
8062
  }
8134
8063
  return valid;
8135
8064
  }
8065
+ // three.js compatibility
8066
+ /** @deprecated */
8136
8067
  sub(a) {
8137
8068
  return this.subtract(a);
8138
8069
  }
8070
+ /** @deprecated */
8139
8071
  setScalar(a) {
8140
8072
  for (let i = 0; i < this.ELEMENTS; ++i) {
8141
8073
  this[i] = a;
8142
8074
  }
8143
8075
  return this.check();
8144
8076
  }
8077
+ /** @deprecated */
8145
8078
  addScalar(a) {
8146
8079
  for (let i = 0; i < this.ELEMENTS; ++i) {
8147
8080
  this[i] += a;
8148
8081
  }
8149
8082
  return this.check();
8150
8083
  }
8084
+ /** @deprecated */
8151
8085
  subScalar(a) {
8152
8086
  return this.addScalar(-a);
8153
8087
  }
8088
+ /** @deprecated */
8154
8089
  multiplyScalar(scalar) {
8155
8090
  for (let i = 0; i < this.ELEMENTS; ++i) {
8156
8091
  this[i] *= scalar;
8157
8092
  }
8158
8093
  return this.check();
8159
8094
  }
8095
+ /** @deprecated */
8160
8096
  divideScalar(a) {
8161
8097
  return this.multiplyByScalar(1 / a);
8162
8098
  }
8099
+ /** @deprecated */
8163
8100
  clampScalar(min, max) {
8164
8101
  for (let i = 0; i < this.ELEMENTS; ++i) {
8165
8102
  this[i] = Math.min(Math.max(this[i], min), max);
8166
8103
  }
8167
8104
  return this.check();
8168
8105
  }
8106
+ /** @deprecated */
8169
8107
  get elements() {
8170
8108
  return this;
8171
8109
  }
@@ -8185,13 +8123,13 @@ vec3 geometry_getNormal() {
8185
8123
  }
8186
8124
  function checkNumber(value) {
8187
8125
  if (!Number.isFinite(value)) {
8188
- throw new Error("Invalid number ".concat(JSON.stringify(value)));
8126
+ throw new Error(`Invalid number ${JSON.stringify(value)}`);
8189
8127
  }
8190
8128
  return value;
8191
8129
  }
8192
8130
  function checkVector(v, length, callerName = "") {
8193
8131
  if (config.debug && !validateVector(v, length)) {
8194
- throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
8132
+ throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
8195
8133
  }
8196
8134
  return v;
8197
8135
  }
@@ -8316,19 +8254,29 @@ vec3 geometry_getNormal() {
8316
8254
 
8317
8255
  // ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
8318
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?
8319
8267
  toString() {
8320
8268
  let string = "[";
8321
8269
  if (config.printRowMajor) {
8322
8270
  string += "row-major:";
8323
8271
  for (let row = 0; row < this.RANK; ++row) {
8324
8272
  for (let col = 0; col < this.RANK; ++col) {
8325
- string += " ".concat(this[col * this.RANK + row]);
8273
+ string += ` ${this[col * this.RANK + row]}`;
8326
8274
  }
8327
8275
  }
8328
8276
  } else {
8329
8277
  string += "column-major:";
8330
8278
  for (let i = 0; i < this.ELEMENTS; ++i) {
8331
- string += " ".concat(this[i]);
8279
+ string += ` ${this[i]}`;
8332
8280
  }
8333
8281
  }
8334
8282
  string += "]";
@@ -8337,9 +8285,11 @@ vec3 geometry_getNormal() {
8337
8285
  getElementIndex(row, col) {
8338
8286
  return col * this.RANK + row;
8339
8287
  }
8288
+ // By default assumes row major indices
8340
8289
  getElement(row, col) {
8341
8290
  return this[col * this.RANK + row];
8342
8291
  }
8292
+ // By default assumes row major indices
8343
8293
  setElement(row, col, value) {
8344
8294
  this[col * this.RANK + row] = checkNumber(value);
8345
8295
  return this;
@@ -9105,6 +9055,7 @@ vec3 geometry_getNormal() {
9105
9055
  this[15] = array[15];
9106
9056
  return this.check();
9107
9057
  }
9058
+ // eslint-disable-next-line max-params
9108
9059
  set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
9109
9060
  this[0] = m00;
9110
9061
  this[1] = m10;
@@ -9124,6 +9075,8 @@ vec3 geometry_getNormal() {
9124
9075
  this[15] = m33;
9125
9076
  return this.check();
9126
9077
  }
9078
+ // accepts row major order, stores as column major
9079
+ // eslint-disable-next-line max-params
9127
9080
  setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
9128
9081
  this[0] = m00;
9129
9082
  this[1] = m10;
@@ -9162,25 +9115,41 @@ vec3 geometry_getNormal() {
9162
9115
  result[15] = this[15];
9163
9116
  return result;
9164
9117
  }
9118
+ // Constructors
9119
+ /** Set to identity matrix */
9165
9120
  identity() {
9166
9121
  return this.copy(IDENTITY_MATRIX);
9167
9122
  }
9123
+ /**
9124
+ *
9125
+ * @param object
9126
+ * @returns self
9127
+ */
9128
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9168
9129
  fromObject(object) {
9169
9130
  return this.check();
9170
9131
  }
9132
+ /**
9133
+ * Calculates a 4x4 matrix from the given quaternion
9134
+ * @param quaternion Quaternion to create matrix from
9135
+ * @returns self
9136
+ */
9171
9137
  fromQuaternion(quaternion) {
9172
9138
  fromQuat(this, quaternion);
9173
9139
  return this.check();
9174
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
+ */
9175
9151
  frustum(view) {
9176
- const {
9177
- left,
9178
- right,
9179
- bottom,
9180
- top,
9181
- near = DEFAULT_NEAR,
9182
- far = DEFAULT_FAR
9183
- } = view;
9152
+ const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
9184
9153
  if (far === Infinity) {
9185
9154
  computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
9186
9155
  } else {
@@ -9188,35 +9157,47 @@ vec3 geometry_getNormal() {
9188
9157
  }
9189
9158
  return this.check();
9190
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
+ */
9191
9168
  lookAt(view) {
9192
- const {
9193
- eye,
9194
- center = [0, 0, 0],
9195
- up = [0, 1, 0]
9196
- } = view;
9169
+ const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
9197
9170
  lookAt(this, eye, center, up);
9198
9171
  return this.check();
9199
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
+ */
9200
9184
  ortho(view) {
9201
- const {
9202
- left,
9203
- right,
9204
- bottom,
9205
- top,
9206
- near = DEFAULT_NEAR,
9207
- far = DEFAULT_FAR
9208
- } = view;
9185
+ const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
9209
9186
  ortho(this, left, right, bottom, top, near, far);
9210
9187
  return this.check();
9211
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
+ */
9212
9199
  orthographic(view) {
9213
- const {
9214
- fovy = DEFAULT_FOVY,
9215
- aspect = DEFAULT_ASPECT,
9216
- focalDistance = 1,
9217
- near = DEFAULT_NEAR,
9218
- far = DEFAULT_FAR
9219
- } = view;
9200
+ const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
9220
9201
  checkRadians(fovy);
9221
9202
  const halfY = fovy / 2;
9222
9203
  const top = focalDistance * Math.tan(halfY);
@@ -9230,32 +9211,53 @@ vec3 geometry_getNormal() {
9230
9211
  far
9231
9212
  });
9232
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
+ */
9233
9222
  perspective(view) {
9234
- const {
9235
- fovy = 45 * Math.PI / 180,
9236
- aspect = 1,
9237
- near = 0.1,
9238
- far = 500
9239
- } = view;
9223
+ const { fovy = 45 * Math.PI / 180, aspect = 1, near = 0.1, far = 500 } = view;
9240
9224
  checkRadians(fovy);
9241
9225
  perspective(this, fovy, aspect, near, far);
9242
9226
  return this.check();
9243
9227
  }
9228
+ // Accessors
9244
9229
  determinant() {
9245
9230
  return determinant(this);
9246
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
+ */
9247
9238
  getScale(result = [-0, -0, -0]) {
9248
9239
  result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
9249
9240
  result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
9250
9241
  result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
9251
9242
  return result;
9252
9243
  }
9244
+ /**
9245
+ * Gets the translation portion, assuming the matrix is a affine transformation matrix.
9246
+ * @param result
9247
+ * @returns self
9248
+ */
9253
9249
  getTranslation(result = [-0, -0, -0]) {
9254
9250
  result[0] = this[12];
9255
9251
  result[1] = this[13];
9256
9252
  result[2] = this[14];
9257
9253
  return result;
9258
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
+ */
9259
9261
  getRotation(result, scaleResult) {
9260
9262
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
9261
9263
  scaleResult = scaleResult || [-0, -0, -0];
@@ -9281,6 +9283,12 @@ vec3 geometry_getNormal() {
9281
9283
  result[15] = 1;
9282
9284
  return result;
9283
9285
  }
9286
+ /**
9287
+ *
9288
+ * @param result
9289
+ * @param scaleResult
9290
+ * @returns self
9291
+ */
9284
9292
  getRotationMatrix3(result, scaleResult) {
9285
9293
  result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
9286
9294
  scaleResult = scaleResult || [-0, -0, -0];
@@ -9299,6 +9307,7 @@ vec3 geometry_getNormal() {
9299
9307
  result[8] = this[10] * inverseScale2;
9300
9308
  return result;
9301
9309
  }
9310
+ // Modifiers
9302
9311
  transpose() {
9303
9312
  transpose(this, this);
9304
9313
  return this.check();
@@ -9307,6 +9316,7 @@ vec3 geometry_getNormal() {
9307
9316
  invert(this, this);
9308
9317
  return this.check();
9309
9318
  }
9319
+ // Operations
9310
9320
  multiplyLeft(a) {
9311
9321
  multiply(this, a, this);
9312
9322
  return this.check();
@@ -9315,33 +9325,68 @@ vec3 geometry_getNormal() {
9315
9325
  multiply(this, this, a);
9316
9326
  return this.check();
9317
9327
  }
9328
+ // Rotates a matrix by the given angle around the X axis
9318
9329
  rotateX(radians) {
9319
9330
  rotateX(this, this, radians);
9320
9331
  return this.check();
9321
9332
  }
9333
+ // Rotates a matrix by the given angle around the Y axis.
9322
9334
  rotateY(radians) {
9323
9335
  rotateY(this, this, radians);
9324
9336
  return this.check();
9325
9337
  }
9338
+ /**
9339
+ * Rotates a matrix by the given angle around the Z axis.
9340
+ * @param radians
9341
+ * @returns self
9342
+ */
9326
9343
  rotateZ(radians) {
9327
9344
  rotateZ(this, this, radians);
9328
9345
  return this.check();
9329
9346
  }
9347
+ /**
9348
+ *
9349
+ * @param param0
9350
+ * @returns self
9351
+ */
9330
9352
  rotateXYZ(angleXYZ) {
9331
9353
  return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
9332
9354
  }
9355
+ /**
9356
+ *
9357
+ * @param radians
9358
+ * @param axis
9359
+ * @returns self
9360
+ */
9333
9361
  rotateAxis(radians, axis) {
9334
9362
  rotate(this, this, radians, axis);
9335
9363
  return this.check();
9336
9364
  }
9365
+ /**
9366
+ *
9367
+ * @param factor
9368
+ * @returns self
9369
+ */
9337
9370
  scale(factor) {
9338
9371
  scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
9339
9372
  return this.check();
9340
9373
  }
9374
+ /**
9375
+ *
9376
+ * @param vec
9377
+ * @returns self
9378
+ */
9341
9379
  translate(vector) {
9342
9380
  translate(this, this, vector);
9343
9381
  return this.check();
9344
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
+ */
9345
9390
  transform(vector, result) {
9346
9391
  if (vector.length === 4) {
9347
9392
  result = transformMat43(result || [-0, -0, -0, -0], vector, this);
@@ -9350,10 +9395,14 @@ vec3 geometry_getNormal() {
9350
9395
  }
9351
9396
  return this.transformAsPoint(vector, result);
9352
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
+ */
9353
9404
  transformAsPoint(vector, result) {
9354
- const {
9355
- length
9356
- } = vector;
9405
+ const { length } = vector;
9357
9406
  let out;
9358
9407
  switch (length) {
9359
9408
  case 2:
@@ -9368,6 +9417,12 @@ vec3 geometry_getNormal() {
9368
9417
  checkVector(out, vector.length);
9369
9418
  return out;
9370
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
+ */
9371
9426
  transformAsVector(vector, result) {
9372
9427
  let out;
9373
9428
  switch (vector.length) {
@@ -9383,15 +9438,19 @@ vec3 geometry_getNormal() {
9383
9438
  checkVector(out, vector.length);
9384
9439
  return out;
9385
9440
  }
9441
+ /** @deprecated */
9386
9442
  transformPoint(vector, result) {
9387
9443
  return this.transformAsPoint(vector, result);
9388
9444
  }
9445
+ /** @deprecated */
9389
9446
  transformVector(vector, result) {
9390
9447
  return this.transformAsPoint(vector, result);
9391
9448
  }
9449
+ /** @deprecated */
9392
9450
  transformDirection(vector, result) {
9393
9451
  return this.transformAsVector(vector, result);
9394
9452
  }
9453
+ // three.js math API compatibility
9395
9454
  makeRotationX(radians) {
9396
9455
  return this.identity().rotateX(radians);
9397
9456
  }
@@ -9861,14 +9920,6 @@ void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, ve
9861
9920
 
9862
9921
  // src/modules-webgl1/lighting/pbr/pbr-fragment-glsl.ts
9863
9922
  var fs27 = glsl`\
9864
- #if defined(USE_TEX_LOD) && !defined(FEATURE_GLSL_TEXTURE_LOD)
9865
- # error PBR fragment shader: Texture LOD is not available
9866
- #endif
9867
-
9868
- #if !defined(HAS_TANGENTS) && !defined(FEATURE_GLSL_DERIVATIVES)
9869
- # error PBR fragment shader: Derivatives are not available
9870
- #endif
9871
-
9872
9923
  precision highp float;
9873
9924
 
9874
9925
  uniform bool pbr_uUnlit;
@@ -10197,7 +10248,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
10197
10248
  color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);
10198
10249
 
10199
10250
  // Apply directional light
10200
- for(int i = 0, i < lighting_uDirectionalLightCount, i++) {
10251
+ for(int i = 0; i < lighting_uDirectionalLightCount; i++) {
10201
10252
  if (i < lighting_uDirectionalLightCount) {
10202
10253
  PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);
10203
10254
  color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);
@@ -10205,7 +10256,7 @@ vec4 pbr_filterColor(vec4 colorUnused)
10205
10256
  }
10206
10257
 
10207
10258
  // Apply point light
10208
- for(int i = 0, i < lighting_uPointLightCount, i++) {
10259
+ for(int i = 0; i < lighting_uPointLightCount; i++) {
10209
10260
  if (i < lighting_uPointLightCount) {
10210
10261
  PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);
10211
10262
  float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));