tempest.games 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12166,13 +12166,17 @@ var init_internal = __esm(() => {
12166
12166
  });
12167
12167
 
12168
12168
  // ../../packages/atom.io/dist/realtime/index.js
12169
+ function employSocket2(socket, event, handleEvent) {
12170
+ socket.on(event, handleEvent);
12171
+ return socket.off.bind(socket, event, handleEvent);
12172
+ }
12169
12173
  function onLoad2(loadable, fn2) {
12170
12174
  if (loadable instanceof Promise)
12171
12175
  loadable.then(fn2);
12172
12176
  else
12173
12177
  fn2(loadable);
12174
12178
  }
12175
- function castSocket2(socket, guard, logError) {
12179
+ function guardSocket2(socket, guard, logError) {
12176
12180
  if (guard === `TRUST`)
12177
12181
  return socket;
12178
12182
  return {
@@ -12204,13 +12208,6 @@ function castSocket2(socket, guard, logError) {
12204
12208
  emit: socket.emit.bind(socket)
12205
12209
  };
12206
12210
  }
12207
- function employSocket2(socket, event, handleEvent) {
12208
- socket.on(event, handleEvent);
12209
- const retireSocket = () => {
12210
- socket.off(event, handleEvent);
12211
- };
12212
- return retireSocket;
12213
- }
12214
12211
  var mutexAtoms, InvariantMap, SyncGroup, isSocketKey = (key) => key.startsWith(`socket::`), isUserKey2 = (key) => key.startsWith(`user::`), isRoomKey2 = (key) => key.startsWith(`room::`), roomKeysAtom2, usersInRooms2, visibleUsersInRoomsSelector2, visibilityFromRoomSelector2, mutualUsersSelector2, ownersOfRooms2;
12215
12212
  var init_realtime = __esm(() => {
12216
12213
  init_main();
@@ -13051,7 +13048,7 @@ function provideRooms({
13051
13048
  roomNames,
13052
13049
  userKey
13053
13050
  }) {
13054
- const roomSocket = castSocket2(socket, createRoomSocketGuard(roomNames));
13051
+ const roomSocket = guardSocket2(socket, createRoomSocketGuard(roomNames));
13055
13052
  const exposeMutable = realtimeMutableProvider({
13056
13053
  socket,
13057
13054
  store,
@@ -15175,7 +15172,7 @@ var require_src2 = __commonJS((exports, module2) => {
15175
15172
  }
15176
15173
  });
15177
15174
 
15178
- // ../../node_modules/.pnpm/@t3-oss+env-core@0.13.10_arktype@2.1.29_typescript@5.9.3_zod@4.2.1/node_modules/@t3-oss/env-core/dist/standard.js
15175
+ // ../../node_modules/.pnpm/@t3-oss+env-core@0.13.10_arktype@2.1.29_typescript@5.9.3_zod@4.3.4/node_modules/@t3-oss/env-core/dist/standard.js
15179
15176
  function ensureSynchronous(value3, message) {
15180
15177
  if (value3 instanceof Promise)
15181
15178
  throw new Error(message);
@@ -15202,7 +15199,7 @@ function parseWithDictionary(dictionary, value3) {
15202
15199
  }
15203
15200
  var init_standard = () => {};
15204
15201
 
15205
- // ../../node_modules/.pnpm/@t3-oss+env-core@0.13.10_arktype@2.1.29_typescript@5.9.3_zod@4.2.1/node_modules/@t3-oss/env-core/dist/index.js
15202
+ // ../../node_modules/.pnpm/@t3-oss+env-core@0.13.10_arktype@2.1.29_typescript@5.9.3_zod@4.3.4/node_modules/@t3-oss/env-core/dist/index.js
15206
15203
  function createEnv(opts) {
15207
15204
  const runtimeEnv = opts.runtimeEnvStrict ?? opts.runtimeEnv ?? process.env;
15208
15205
  if (opts.emptyStringAsUndefined ?? false) {
@@ -15269,7 +15266,7 @@ var init_dist = __esm(() => {
15269
15266
  });
15270
15267
 
15271
15268
  // src/library/env.ts
15272
- var BUILDING_WITH_VITE, HAS_WINDOW, IS_SERVER, IS_TEST, str, maybeBool, env2;
15269
+ var BUILDING_WITH_VITE, HAS_WINDOW, IS_SERVER, IS_TEST, str, requiredBool, optionalBool, env2;
15273
15270
  var init_env = __esm(() => {
15274
15271
  init_dist();
15275
15272
  init_out4();
@@ -15278,7 +15275,8 @@ var init_env = __esm(() => {
15278
15275
  IS_SERVER = !BUILDING_WITH_VITE && !HAS_WINDOW;
15279
15276
  IS_TEST = `vitest` in globalThis;
15280
15277
  str = type(`string`);
15281
- maybeBool = type(`"true" | "false" | undefined`);
15278
+ requiredBool = type(`"true" | "false"`).pipe((s) => s === `true`);
15279
+ optionalBool = type(`"true" | "false" | undefined`).pipe((s) => s === `true`);
15282
15280
  env2 = createEnv({
15283
15281
  isServer: IS_SERVER,
15284
15282
  server: {
@@ -15289,7 +15287,7 @@ var init_env = __esm(() => {
15289
15287
  POSTGRES_HOST: str,
15290
15288
  POSTGRES_PORT: str.pipe((s) => Number.parseInt(s, 10)),
15291
15289
  BACKEND_PORT: str.pipe((s) => Number.parseInt(s, 10)),
15292
- RUN_WORKERS_FROM_SOURCE: maybeBool.pipe((s) => s === `true`),
15290
+ RUN_WORKERS_FROM_SOURCE: optionalBool,
15293
15291
  FRONTEND_PORT: str.pipe((s) => Number.parseInt(s, 10)),
15294
15292
  FRONTEND_ORIGINS: str.pipe.try((s) => JSON.parse(s), type(`string[]`)),
15295
15293
  API_KEY_OPENAI: type(`string | undefined`),
@@ -15297,10 +15295,10 @@ var init_env = __esm(() => {
15297
15295
  },
15298
15296
  clientPrefix: `VITE_`,
15299
15297
  client: {
15300
- VITE_HIDE_DEVTOOLS: type(`string | undefined`).pipe((s) => s === `true`),
15298
+ VITE_HIDE_DEVTOOLS: requiredBool,
15301
15299
  VITE_BACKEND_ORIGIN: str,
15302
15300
  VITE_DEV_FRONTEND_HOST: type(`string | undefined`),
15303
- VITE_DEV_HTTPS: maybeBool.pipe((s) => s === `true`)
15301
+ VITE_DEV_HTTPS: optionalBool
15304
15302
  },
15305
15303
  runtimeEnv: import.meta.env,
15306
15304
  emptyStringAsUndefined: true
@@ -15453,7 +15451,13 @@ function setState(...params) {
15453
15451
  // src/backend.worker.bug-rangers.bun.ts
15454
15452
  init_internal();
15455
15453
 
15456
- // ../../packages/atom.io/src/realtime/cast-socket.ts
15454
+ // ../../packages/atom.io/src/realtime/employ-socket.ts
15455
+ function employSocket(socket, event, handleEvent) {
15456
+ socket.on(event, handleEvent);
15457
+ return socket.off.bind(socket, event, handleEvent);
15458
+ }
15459
+
15460
+ // ../../packages/atom.io/src/realtime/guard-socket.ts
15457
15461
  function onLoad(loadable, fn2) {
15458
15462
  if (loadable instanceof Promise) {
15459
15463
  loadable.then(fn2);
@@ -15461,7 +15465,7 @@ function onLoad(loadable, fn2) {
15461
15465
  fn2(loadable);
15462
15466
  }
15463
15467
  }
15464
- function castSocket(socket, guard, logError) {
15468
+ function guardSocket(socket, guard, logError) {
15465
15469
  if (guard === `TRUST`) {
15466
15470
  return socket;
15467
15471
  }
@@ -15501,15 +15505,6 @@ function castSocket(socket, guard, logError) {
15501
15505
  return guardedSocket;
15502
15506
  }
15503
15507
 
15504
- // ../../packages/atom.io/src/realtime/employ-socket.ts
15505
- function employSocket(socket, event, handleEvent) {
15506
- socket.on(event, handleEvent);
15507
- const retireSocket = () => {
15508
- socket.off(event, handleEvent);
15509
- };
15510
- return retireSocket;
15511
- }
15512
-
15513
15508
  // ../../packages/atom.io/src/realtime/realtime-key-types.ts
15514
15509
  var isUserKey = (key) => key.startsWith(`user::`);
15515
15510
  var isRoomKey = (key) => key.startsWith(`room::`);
@@ -18920,8 +18915,10 @@ class UList3 extends Set {
18920
18915
  }
18921
18916
  }
18922
18917
 
18923
- // ../../node_modules/.pnpm/three@0.180.0/node_modules/three/build/three.core.js
18924
- var REVISION = "180";
18918
+ // ../../node_modules/.pnpm/three@0.182.0/node_modules/three/build/three.core.js
18919
+ var REVISION = "182";
18920
+ var PCFShadowMap = 1;
18921
+ var VSMShadowMap = 3;
18925
18922
  var NeverDepth = 0;
18926
18923
  var AlwaysDepth = 1;
18927
18924
  var LessDepth = 2;
@@ -18930,7 +18927,20 @@ var EqualDepth = 4;
18930
18927
  var GreaterEqualDepth = 5;
18931
18928
  var GreaterDepth = 6;
18932
18929
  var NotEqualDepth = 7;
18930
+ var MultiplyOperation = 0;
18931
+ var MixOperation = 1;
18932
+ var AddOperation = 2;
18933
+ var LinearToneMapping = 1;
18934
+ var ReinhardToneMapping = 2;
18935
+ var CineonToneMapping = 3;
18936
+ var ACESFilmicToneMapping = 4;
18937
+ var CustomToneMapping = 5;
18938
+ var AgXToneMapping = 6;
18939
+ var NeutralToneMapping = 7;
18933
18940
  var UVMapping = 300;
18941
+ var CubeReflectionMapping = 301;
18942
+ var CubeRefractionMapping = 302;
18943
+ var CubeUVReflectionMapping = 306;
18934
18944
  var RepeatWrapping = 1000;
18935
18945
  var ClampToEdgeWrapping = 1001;
18936
18946
  var MirroredRepeatWrapping = 1002;
@@ -18951,6 +18961,37 @@ var LinearTransfer = "linear";
18951
18961
  var SRGBTransfer = "srgb";
18952
18962
  var WebGLCoordinateSystem = 2000;
18953
18963
  var WebGPUCoordinateSystem = 2001;
18964
+ function isTypedArray(array) {
18965
+ return ArrayBuffer.isView(array) && !(array instanceof DataView);
18966
+ }
18967
+ function createElementNS(name) {
18968
+ return document.createElementNS("http://www.w3.org/1999/xhtml", name);
18969
+ }
18970
+ var _cache = {};
18971
+ var _setConsoleFunction = null;
18972
+ function warn(...params) {
18973
+ const message = "THREE." + params.shift();
18974
+ if (_setConsoleFunction) {
18975
+ _setConsoleFunction("warn", message, ...params);
18976
+ } else {
18977
+ console.warn(message, ...params);
18978
+ }
18979
+ }
18980
+ function error(...params) {
18981
+ const message = "THREE." + params.shift();
18982
+ if (_setConsoleFunction) {
18983
+ _setConsoleFunction("error", message, ...params);
18984
+ } else {
18985
+ console.error(message, ...params);
18986
+ }
18987
+ }
18988
+ function warnOnce(...params) {
18989
+ const message = params.join(" ");
18990
+ if (message in _cache)
18991
+ return;
18992
+ _cache[message] = true;
18993
+ warn(...params);
18994
+ }
18954
18995
  class EventDispatcher {
18955
18996
  addEventListener(type2, listener) {
18956
18997
  if (this._listeners === undefined)
@@ -19291,15 +19332,15 @@ class Quaternion {
19291
19332
  }
19292
19333
  static slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {
19293
19334
  let x0 = src0[srcOffset0 + 0], y0 = src0[srcOffset0 + 1], z0 = src0[srcOffset0 + 2], w0 = src0[srcOffset0 + 3];
19294
- const x1 = src1[srcOffset1 + 0], y1 = src1[srcOffset1 + 1], z1 = src1[srcOffset1 + 2], w1 = src1[srcOffset1 + 3];
19295
- if (t === 0) {
19335
+ let x1 = src1[srcOffset1 + 0], y1 = src1[srcOffset1 + 1], z1 = src1[srcOffset1 + 2], w1 = src1[srcOffset1 + 3];
19336
+ if (t <= 0) {
19296
19337
  dst[dstOffset + 0] = x0;
19297
19338
  dst[dstOffset + 1] = y0;
19298
19339
  dst[dstOffset + 2] = z0;
19299
19340
  dst[dstOffset + 3] = w0;
19300
19341
  return;
19301
19342
  }
19302
- if (t === 1) {
19343
+ if (t >= 1) {
19303
19344
  dst[dstOffset + 0] = x1;
19304
19345
  dst[dstOffset + 1] = y1;
19305
19346
  dst[dstOffset + 2] = z1;
@@ -19307,19 +19348,29 @@ class Quaternion {
19307
19348
  return;
19308
19349
  }
19309
19350
  if (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {
19351
+ let dot = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1;
19352
+ if (dot < 0) {
19353
+ x1 = -x1;
19354
+ y1 = -y1;
19355
+ z1 = -z1;
19356
+ w1 = -w1;
19357
+ dot = -dot;
19358
+ }
19310
19359
  let s = 1 - t;
19311
- const cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1, dir = cos >= 0 ? 1 : -1, sqrSin = 1 - cos * cos;
19312
- if (sqrSin > Number.EPSILON) {
19313
- const sin = Math.sqrt(sqrSin), len = Math.atan2(sin, cos * dir);
19314
- s = Math.sin(s * len) / sin;
19315
- t = Math.sin(t * len) / sin;
19316
- }
19317
- const tDir = t * dir;
19318
- x0 = x0 * s + x1 * tDir;
19319
- y0 = y0 * s + y1 * tDir;
19320
- z0 = z0 * s + z1 * tDir;
19321
- w0 = w0 * s + w1 * tDir;
19322
- if (s === 1 - t) {
19360
+ if (dot < 0.9995) {
19361
+ const theta = Math.acos(dot);
19362
+ const sin = Math.sin(theta);
19363
+ s = Math.sin(s * theta) / sin;
19364
+ t = Math.sin(t * theta) / sin;
19365
+ x0 = x0 * s + x1 * t;
19366
+ y0 = y0 * s + y1 * t;
19367
+ z0 = z0 * s + z1 * t;
19368
+ w0 = w0 * s + w1 * t;
19369
+ } else {
19370
+ x0 = x0 * s + x1 * t;
19371
+ y0 = y0 * s + y1 * t;
19372
+ z0 = z0 * s + z1 * t;
19373
+ w0 = w0 * s + w1 * t;
19323
19374
  const f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);
19324
19375
  x0 *= f;
19325
19376
  y0 *= f;
@@ -19442,7 +19493,7 @@ class Quaternion {
19442
19493
  this._w = c1 * c2 * c3 + s1 * s2 * s3;
19443
19494
  break;
19444
19495
  default:
19445
- console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + order);
19496
+ warn("Quaternion: .setFromEuler() encountered an unknown order: " + order);
19446
19497
  }
19447
19498
  if (update === true)
19448
19499
  this._onChangeCallback();
@@ -19577,46 +19628,37 @@ class Quaternion {
19577
19628
  return this;
19578
19629
  }
19579
19630
  slerp(qb, t) {
19580
- if (t === 0)
19631
+ if (t <= 0)
19581
19632
  return this;
19582
- if (t === 1)
19633
+ if (t >= 1)
19583
19634
  return this.copy(qb);
19584
- const x = this._x, y = this._y, z = this._z, w = this._w;
19585
- let cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
19586
- if (cosHalfTheta < 0) {
19587
- this._w = -qb._w;
19588
- this._x = -qb._x;
19589
- this._y = -qb._y;
19590
- this._z = -qb._z;
19591
- cosHalfTheta = -cosHalfTheta;
19635
+ let { _x: x, _y: y, _z: z, _w: w } = qb;
19636
+ let dot = this.dot(qb);
19637
+ if (dot < 0) {
19638
+ x = -x;
19639
+ y = -y;
19640
+ z = -z;
19641
+ w = -w;
19642
+ dot = -dot;
19643
+ }
19644
+ let s = 1 - t;
19645
+ if (dot < 0.9995) {
19646
+ const theta = Math.acos(dot);
19647
+ const sin = Math.sin(theta);
19648
+ s = Math.sin(s * theta) / sin;
19649
+ t = Math.sin(t * theta) / sin;
19650
+ this._x = this._x * s + x * t;
19651
+ this._y = this._y * s + y * t;
19652
+ this._z = this._z * s + z * t;
19653
+ this._w = this._w * s + w * t;
19654
+ this._onChangeCallback();
19592
19655
  } else {
19593
- this.copy(qb);
19594
- }
19595
- if (cosHalfTheta >= 1) {
19596
- this._w = w;
19597
- this._x = x;
19598
- this._y = y;
19599
- this._z = z;
19600
- return this;
19601
- }
19602
- const sqrSinHalfTheta = 1 - cosHalfTheta * cosHalfTheta;
19603
- if (sqrSinHalfTheta <= Number.EPSILON) {
19604
- const s = 1 - t;
19605
- this._w = s * w + t * this._w;
19606
- this._x = s * x + t * this._x;
19607
- this._y = s * y + t * this._y;
19608
- this._z = s * z + t * this._z;
19656
+ this._x = this._x * s + x * t;
19657
+ this._y = this._y * s + y * t;
19658
+ this._z = this._z * s + z * t;
19659
+ this._w = this._w * s + w * t;
19609
19660
  this.normalize();
19610
- return this;
19611
19661
  }
19612
- const sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
19613
- const halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
19614
- const ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta, ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
19615
- this._w = w * ratioA + this._w * ratioB;
19616
- this._x = x * ratioA + this._x * ratioB;
19617
- this._y = y * ratioA + this._y * ratioB;
19618
- this._z = z * ratioA + this._z * ratioB;
19619
- this._onChangeCallback();
19620
19662
  return this;
19621
19663
  }
19622
19664
  slerpQuaternions(qa, qb, t) {
@@ -20310,16 +20352,6 @@ class Matrix3 {
20310
20352
  }
20311
20353
  }
20312
20354
  var _m3 = /* @__PURE__ */ new Matrix3;
20313
- function createElementNS(name) {
20314
- return document.createElementNS("http://www.w3.org/1999/xhtml", name);
20315
- }
20316
- var _cache = {};
20317
- function warnOnce(message) {
20318
- if (message in _cache)
20319
- return;
20320
- _cache[message] = true;
20321
- console.warn(message);
20322
- }
20323
20355
  var LINEAR_REC709_TO_XYZ = /* @__PURE__ */ new Matrix3().set(0.4123908, 0.3575843, 0.1804808, 0.212639, 0.7151687, 0.0721923, 0.0193308, 0.1191948, 0.9505322);
20324
20356
  var XYZ_TO_LINEAR_REC709 = /* @__PURE__ */ new Matrix3().set(3.2409699, -1.5373832, -0.4986108, -0.9692436, 1.8759675, 0.0415551, 0.0556301, -0.203977, 1.0569715);
20325
20357
  function createColorManagement() {
@@ -20380,11 +20412,11 @@ function createColorManagement() {
20380
20412
  return this.spaces[colorSpace].workingColorSpaceConfig.unpackColorSpace;
20381
20413
  },
20382
20414
  fromWorkingColorSpace: function(color, targetColorSpace) {
20383
- warnOnce("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().");
20415
+ warnOnce("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().");
20384
20416
  return ColorManagement.workingToColorSpace(color, targetColorSpace);
20385
20417
  },
20386
20418
  toWorkingColorSpace: function(color, sourceColorSpace) {
20387
- warnOnce("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().");
20419
+ warnOnce("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().");
20388
20420
  return ColorManagement.colorSpaceToWorking(color, sourceColorSpace);
20389
20421
  }
20390
20422
  };
@@ -20478,7 +20510,7 @@ class ImageUtils {
20478
20510
  height: image.height
20479
20511
  };
20480
20512
  } else {
20481
- console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.");
20513
+ warn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.");
20482
20514
  return image;
20483
20515
  }
20484
20516
  }
@@ -20498,7 +20530,7 @@ class Source {
20498
20530
  const data = this.data;
20499
20531
  if (typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement) {
20500
20532
  target.set(data.videoWidth, data.videoHeight, 0);
20501
- } else if (data instanceof VideoFrame) {
20533
+ } else if (typeof VideoFrame !== "undefined" && data instanceof VideoFrame) {
20502
20534
  target.set(data.displayHeight, data.displayWidth, 0);
20503
20535
  } else if (data !== null) {
20504
20536
  target.set(data.width, data.height, data.depth || 0);
@@ -20555,7 +20587,7 @@ function serializeImage(image) {
20555
20587
  type: image.data.constructor.name
20556
20588
  };
20557
20589
  } else {
20558
- console.warn("THREE.Texture: Unable to serialize Texture.");
20590
+ warn("Texture: Unable to serialize Texture.");
20559
20591
  return {};
20560
20592
  }
20561
20593
  }
@@ -20665,12 +20697,12 @@ class Texture extends EventDispatcher {
20665
20697
  for (const key in values) {
20666
20698
  const newValue = values[key];
20667
20699
  if (newValue === undefined) {
20668
- console.warn(`THREE.Texture.setValues(): parameter '${key}' has value of undefined.`);
20700
+ warn(`Texture.setValues(): parameter '${key}' has value of undefined.`);
20669
20701
  continue;
20670
20702
  }
20671
20703
  const currentValue = this[key];
20672
20704
  if (currentValue === undefined) {
20673
- console.warn(`THREE.Texture.setValues(): property '${key}' does not exist.`);
20705
+ warn(`Texture.setValues(): property '${key}' does not exist.`);
20674
20706
  continue;
20675
20707
  }
20676
20708
  if (currentValue && newValue && (currentValue.isVector2 && newValue.isVector2)) {
@@ -20871,6 +20903,12 @@ class Matrix4 {
20871
20903
  return this;
20872
20904
  }
20873
20905
  extractBasis(xAxis, yAxis, zAxis) {
20906
+ if (this.determinant() === 0) {
20907
+ xAxis.set(1, 0, 0);
20908
+ yAxis.set(0, 1, 0);
20909
+ zAxis.set(0, 0, 1);
20910
+ return this;
20911
+ }
20874
20912
  xAxis.setFromMatrixColumn(this, 0);
20875
20913
  yAxis.setFromMatrixColumn(this, 1);
20876
20914
  zAxis.setFromMatrixColumn(this, 2);
@@ -20881,6 +20919,9 @@ class Matrix4 {
20881
20919
  return this;
20882
20920
  }
20883
20921
  extractRotation(m) {
20922
+ if (m.determinant() === 0) {
20923
+ return this.identity();
20924
+ }
20884
20925
  const te = this.elements;
20885
20926
  const me = m.elements;
20886
20927
  const scaleX = 1 / _v1$5.setFromMatrixColumn(m, 0).length();
@@ -21081,7 +21122,13 @@ class Matrix4 {
21081
21122
  const n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
21082
21123
  const n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
21083
21124
  const n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
21084
- return n41 * (+n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34) + n42 * (+n11 * n23 * n34 - n11 * n24 * n33 + n14 * n21 * n33 - n13 * n21 * n34 + n13 * n24 * n31 - n14 * n23 * n31) + n43 * (+n11 * n24 * n32 - n11 * n22 * n34 - n14 * n21 * n32 + n12 * n21 * n34 + n14 * n22 * n31 - n12 * n24 * n31) + n44 * (-n13 * n22 * n31 - n11 * n23 * n32 + n11 * n22 * n33 + n13 * n21 * n32 - n12 * n21 * n33 + n12 * n23 * n31);
21125
+ const t11 = n23 * n34 - n24 * n33;
21126
+ const t12 = n22 * n34 - n24 * n32;
21127
+ const t13 = n22 * n33 - n23 * n32;
21128
+ const t21 = n21 * n34 - n24 * n31;
21129
+ const t22 = n21 * n33 - n23 * n31;
21130
+ const t23 = n21 * n32 - n22 * n31;
21131
+ return n11 * (n42 * t11 - n43 * t12 + n44 * t13) - n12 * (n41 * t11 - n43 * t21 + n44 * t22) + n13 * (n41 * t12 - n42 * t21 + n44 * t23) - n14 * (n41 * t13 - n42 * t22 + n43 * t23);
21085
21132
  }
21086
21133
  transpose() {
21087
21134
  const te = this.elements;
@@ -21235,15 +21282,20 @@ class Matrix4 {
21235
21282
  }
21236
21283
  decompose(position, quaternion, scale) {
21237
21284
  const te = this.elements;
21285
+ position.x = te[12];
21286
+ position.y = te[13];
21287
+ position.z = te[14];
21288
+ if (this.determinant() === 0) {
21289
+ scale.set(1, 1, 1);
21290
+ quaternion.identity();
21291
+ return this;
21292
+ }
21238
21293
  let sx = _v1$5.set(te[0], te[1], te[2]).length();
21239
21294
  const sy = _v1$5.set(te[4], te[5], te[6]).length();
21240
21295
  const sz = _v1$5.set(te[8], te[9], te[10]).length();
21241
21296
  const det = this.determinant();
21242
21297
  if (det < 0)
21243
21298
  sx = -sx;
21244
- position.x = te[12];
21245
- position.y = te[13];
21246
- position.z = te[14];
21247
21299
  _m1$2.copy(this);
21248
21300
  const invSX = 1 / sx;
21249
21301
  const invSY = 1 / sy;
@@ -21509,7 +21561,7 @@ class Euler {
21509
21561
  }
21510
21562
  break;
21511
21563
  default:
21512
- console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + order);
21564
+ warn("Euler: .setFromRotationMatrix() encountered an unknown order: " + order);
21513
21565
  }
21514
21566
  this._order = order;
21515
21567
  if (update === true)
@@ -21768,7 +21820,7 @@ class Object3D extends EventDispatcher {
21768
21820
  return this;
21769
21821
  }
21770
21822
  if (object2 === this) {
21771
- console.error("THREE.Object3D.add: object can't be added as a child of itself.", object2);
21823
+ error("Object3D.add: object can't be added as a child of itself.", object2);
21772
21824
  return this;
21773
21825
  }
21774
21826
  if (object2 && object2.isObject3D) {
@@ -21780,7 +21832,7 @@ class Object3D extends EventDispatcher {
21780
21832
  this.dispatchEvent(_childaddedEvent);
21781
21833
  _childaddedEvent.child = null;
21782
21834
  } else {
21783
- console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", object2);
21835
+ error("Object3D.add: object not an instance of THREE.Object3D.", object2);
21784
21836
  }
21785
21837
  return this;
21786
21838
  }
@@ -22396,7 +22448,7 @@ class Color {
22396
22448
  if (string2 === undefined)
22397
22449
  return;
22398
22450
  if (parseFloat(string2) < 1) {
22399
- console.warn("THREE.Color: Alpha component of " + style + " will be ignored.");
22451
+ warn("Color: Alpha component of " + style + " will be ignored.");
22400
22452
  }
22401
22453
  }
22402
22454
  let m;
@@ -22424,7 +22476,7 @@ class Color {
22424
22476
  }
22425
22477
  break;
22426
22478
  default:
22427
- console.warn("THREE.Color: Unknown color model " + style);
22479
+ warn("Color: Unknown color model " + style);
22428
22480
  }
22429
22481
  } else if (m = /^\#([A-Fa-f\d]+)$/.exec(style)) {
22430
22482
  const hex2 = m[1];
@@ -22434,7 +22486,7 @@ class Color {
22434
22486
  } else if (size === 6) {
22435
22487
  return this.setHex(parseInt(hex2, 16), colorSpace);
22436
22488
  } else {
22437
- console.warn("THREE.Color: Invalid hex color " + style);
22489
+ warn("Color: Invalid hex color " + style);
22438
22490
  }
22439
22491
  } else if (style && style.length > 0) {
22440
22492
  return this.setColorName(style, colorSpace);
@@ -22446,7 +22498,7 @@ class Color {
22446
22498
  if (hex2 !== undefined) {
22447
22499
  this.setHex(hex2, colorSpace);
22448
22500
  } else {
22449
- console.warn("THREE.Color: Unknown color " + style);
22501
+ warn("Color: Unknown color " + style);
22450
22502
  }
22451
22503
  return this;
22452
22504
  }
@@ -22647,7 +22699,7 @@ function cloneUniforms(src) {
22647
22699
  const property = src[u][p];
22648
22700
  if (property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture || property.isQuaternion)) {
22649
22701
  if (property.isRenderTargetTexture) {
22650
- console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().");
22702
+ warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().");
22651
22703
  dst[u][p] = null;
22652
22704
  } else {
22653
22705
  dst[u][p] = property.clone();
@@ -22679,9 +22731,6 @@ function convertArray(array, type2) {
22679
22731
  }
22680
22732
  return Array.prototype.slice.call(array);
22681
22733
  }
22682
- function isTypedArray(object2) {
22683
- return ArrayBuffer.isView(object2) && !(object2 instanceof DataView);
22684
- }
22685
22734
  class Interpolant {
22686
22735
  constructor(parameterPositions, sampleValues, sampleSize, resultBuffer) {
22687
22736
  this.parameterPositions = parameterPositions;
@@ -22933,7 +22982,7 @@ class KeyframeTrack {
22933
22982
  throw new Error(message);
22934
22983
  }
22935
22984
  }
22936
- console.warn("THREE.KeyframeTrack:", message);
22985
+ warn("KeyframeTrack:", message);
22937
22986
  return this;
22938
22987
  }
22939
22988
  this.createInterpolant = factoryMethod;
@@ -22995,24 +23044,24 @@ class KeyframeTrack {
22995
23044
  let valid = true;
22996
23045
  const valueSize = this.getValueSize();
22997
23046
  if (valueSize - Math.floor(valueSize) !== 0) {
22998
- console.error("THREE.KeyframeTrack: Invalid value size in track.", this);
23047
+ error("KeyframeTrack: Invalid value size in track.", this);
22999
23048
  valid = false;
23000
23049
  }
23001
23050
  const times = this.times, values = this.values, nKeys = times.length;
23002
23051
  if (nKeys === 0) {
23003
- console.error("THREE.KeyframeTrack: Track is empty.", this);
23052
+ error("KeyframeTrack: Track is empty.", this);
23004
23053
  valid = false;
23005
23054
  }
23006
23055
  let prevTime = null;
23007
23056
  for (let i = 0;i !== nKeys; i++) {
23008
23057
  const currTime = times[i];
23009
23058
  if (typeof currTime === "number" && isNaN(currTime)) {
23010
- console.error("THREE.KeyframeTrack: Time is not a valid number.", this, i, currTime);
23059
+ error("KeyframeTrack: Time is not a valid number.", this, i, currTime);
23011
23060
  valid = false;
23012
23061
  break;
23013
23062
  }
23014
23063
  if (prevTime !== null && prevTime > currTime) {
23015
- console.error("THREE.KeyframeTrack: Out of order keys.", this, i, currTime, prevTime);
23064
+ error("KeyframeTrack: Out of order keys.", this, i, currTime, prevTime);
23016
23065
  valid = false;
23017
23066
  break;
23018
23067
  }
@@ -23023,7 +23072,7 @@ class KeyframeTrack {
23023
23072
  for (let i = 0, n = values.length;i !== n; ++i) {
23024
23073
  const value3 = values[i];
23025
23074
  if (isNaN(value3)) {
23026
- console.error("THREE.KeyframeTrack: Value is not a valid number.", this, i, value3);
23075
+ error("KeyframeTrack: Value is not a valid number.", this, i, value3);
23027
23076
  valid = false;
23028
23077
  break;
23029
23078
  }
@@ -23173,7 +23222,7 @@ class LoadingManager {
23173
23222
  this.onLoad = onLoad3;
23174
23223
  this.onProgress = onProgress;
23175
23224
  this.onError = onError;
23176
- this.abortController = new AbortController;
23225
+ this._abortController = null;
23177
23226
  this.itemStart = function(url3) {
23178
23227
  itemsTotal++;
23179
23228
  if (isLoading === false) {
@@ -23235,10 +23284,16 @@ class LoadingManager {
23235
23284
  };
23236
23285
  this.abort = function() {
23237
23286
  this.abortController.abort();
23238
- this.abortController = new AbortController;
23287
+ this._abortController = null;
23239
23288
  return this;
23240
23289
  };
23241
23290
  }
23291
+ get abortController() {
23292
+ if (!this._abortController) {
23293
+ this._abortController = new AbortController;
23294
+ }
23295
+ return this._abortController;
23296
+ }
23242
23297
  }
23243
23298
  var DefaultLoadingManager = /* @__PURE__ */ new LoadingManager;
23244
23299
 
@@ -23494,7 +23549,7 @@ class PropertyBinding {
23494
23549
  this.getValue = this._getValue_unavailable;
23495
23550
  this.setValue = this._setValue_unavailable;
23496
23551
  if (!targetObject) {
23497
- console.warn("THREE.PropertyBinding: No target node found for track: " + this.path + ".");
23552
+ warn("PropertyBinding: No target node found for track: " + this.path + ".");
23498
23553
  return;
23499
23554
  }
23500
23555
  if (objectName) {
@@ -23502,18 +23557,18 @@ class PropertyBinding {
23502
23557
  switch (objectName) {
23503
23558
  case "materials":
23504
23559
  if (!targetObject.material) {
23505
- console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this);
23560
+ error("PropertyBinding: Can not bind to material as node does not have a material.", this);
23506
23561
  return;
23507
23562
  }
23508
23563
  if (!targetObject.material.materials) {
23509
- console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this);
23564
+ error("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this);
23510
23565
  return;
23511
23566
  }
23512
23567
  targetObject = targetObject.material.materials;
23513
23568
  break;
23514
23569
  case "bones":
23515
23570
  if (!targetObject.skeleton) {
23516
- console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.", this);
23571
+ error("PropertyBinding: Can not bind to bones as node does not have a skeleton.", this);
23517
23572
  return;
23518
23573
  }
23519
23574
  targetObject = targetObject.skeleton.bones;
@@ -23530,25 +23585,25 @@ class PropertyBinding {
23530
23585
  break;
23531
23586
  }
23532
23587
  if (!targetObject.material) {
23533
- console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.", this);
23588
+ error("PropertyBinding: Can not bind to material as node does not have a material.", this);
23534
23589
  return;
23535
23590
  }
23536
23591
  if (!targetObject.material.map) {
23537
- console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.", this);
23592
+ error("PropertyBinding: Can not bind to material.map as node.material does not have a map.", this);
23538
23593
  return;
23539
23594
  }
23540
23595
  targetObject = targetObject.material.map;
23541
23596
  break;
23542
23597
  default:
23543
23598
  if (targetObject[objectName] === undefined) {
23544
- console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.", this);
23599
+ error("PropertyBinding: Can not bind to objectName of node undefined.", this);
23545
23600
  return;
23546
23601
  }
23547
23602
  targetObject = targetObject[objectName];
23548
23603
  }
23549
23604
  if (objectIndex !== undefined) {
23550
23605
  if (targetObject[objectIndex] === undefined) {
23551
- console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, targetObject);
23606
+ error("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, targetObject);
23552
23607
  return;
23553
23608
  }
23554
23609
  targetObject = targetObject[objectIndex];
@@ -23557,7 +23612,7 @@ class PropertyBinding {
23557
23612
  const nodeProperty = targetObject[propertyName];
23558
23613
  if (nodeProperty === undefined) {
23559
23614
  const nodeName = parsedPath.nodeName;
23560
- console.error("THREE.PropertyBinding: Trying to update property for track: " + nodeName + "." + propertyName + " but it wasn't found.", targetObject);
23615
+ error("PropertyBinding: Trying to update property for track: " + nodeName + "." + propertyName + " but it wasn't found.", targetObject);
23561
23616
  return;
23562
23617
  }
23563
23618
  let versioning = this.Versioning.None;
@@ -23571,11 +23626,11 @@ class PropertyBinding {
23571
23626
  if (propertyIndex !== undefined) {
23572
23627
  if (propertyName === "morphTargetInfluences") {
23573
23628
  if (!targetObject.geometry) {
23574
- console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this);
23629
+ error("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this);
23575
23630
  return;
23576
23631
  }
23577
23632
  if (!targetObject.geometry.morphAttributes) {
23578
- console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this);
23633
+ error("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this);
23579
23634
  return;
23580
23635
  }
23581
23636
  if (targetObject.morphTargetDictionary[propertyIndex] !== undefined) {
@@ -23651,13 +23706,13 @@ if (typeof __THREE_DEVTOOLS__ !== "undefined") {
23651
23706
  }
23652
23707
  if (typeof window !== "undefined") {
23653
23708
  if (window.__THREE__) {
23654
- console.warn("WARNING: Multiple instances of Three.js being imported.");
23709
+ warn("WARNING: Multiple instances of Three.js being imported.");
23655
23710
  } else {
23656
23711
  window.__THREE__ = REVISION;
23657
23712
  }
23658
23713
  }
23659
23714
 
23660
- // ../../node_modules/.pnpm/three@0.180.0/node_modules/three/build/three.module.js
23715
+ // ../../node_modules/.pnpm/three@0.182.0/node_modules/three/build/three.module.js
23661
23716
  var alphahash_fragment = `#ifdef USE_ALPHAHASH
23662
23717
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
23663
23718
  #endif`;
@@ -24015,13 +24070,6 @@ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
24015
24070
  vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
24016
24071
  return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
24017
24072
  }
24018
- mat3 transposeMat3( const in mat3 m ) {
24019
- mat3 tmp;
24020
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
24021
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
24022
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
24023
- return tmp;
24024
- }
24025
24073
  bool isPerspectiveMatrix( mat4 m ) {
24026
24074
  return m[ 2 ][ 3 ] == - 1.0;
24027
24075
  }
@@ -24232,7 +24280,6 @@ var envmap_common_pars_fragment = `#ifdef USE_ENVMAP
24232
24280
  #else
24233
24281
  uniform sampler2D envMap;
24234
24282
  #endif
24235
-
24236
24283
  #endif`;
24237
24284
  var envmap_pars_fragment = `#ifdef USE_ENVMAP
24238
24285
  uniform float reflectivity;
@@ -24465,7 +24512,7 @@ var envmap_physical_pars_fragment = `#ifdef USE_ENVMAP
24465
24512
  vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
24466
24513
  #ifdef ENVMAP_TYPE_CUBE_UV
24467
24514
  vec3 reflectVec = reflect( - viewDir, normal );
24468
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
24515
+ reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
24469
24516
  reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
24470
24517
  vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
24471
24518
  return envMapColor.rgb * envMapIntensity;
@@ -24525,7 +24572,9 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
24525
24572
  #define RE_Direct RE_Direct_BlinnPhong
24526
24573
  #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`;
24527
24574
  var lights_physical_fragment = `PhysicalMaterial material;
24528
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
24575
+ material.diffuseColor = diffuseColor.rgb;
24576
+ material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
24577
+ material.metalness = metalnessFactor;
24529
24578
  vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
24530
24579
  float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
24531
24580
  material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
@@ -24547,9 +24596,11 @@ material.roughness = min( material.roughness, 1.0 );
24547
24596
  vec3 specularColorFactor = vec3( 1.0 );
24548
24597
  material.specularF90 = 1.0;
24549
24598
  #endif
24550
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
24599
+ material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
24600
+ material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
24551
24601
  #else
24552
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
24602
+ material.specularColor = vec3( 0.04 );
24603
+ material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
24553
24604
  material.specularF90 = 1.0;
24554
24605
  #endif
24555
24606
  #ifdef USE_CLEARCOAT
@@ -24587,7 +24638,7 @@ material.roughness = min( material.roughness, 1.0 );
24587
24638
  #ifdef USE_SHEEN_COLORMAP
24588
24639
  material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
24589
24640
  #endif
24590
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
24641
+ material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );
24591
24642
  #ifdef USE_SHEEN_ROUGHNESSMAP
24592
24643
  material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
24593
24644
  #endif
@@ -24611,10 +24662,14 @@ material.roughness = min( material.roughness, 1.0 );
24611
24662
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
24612
24663
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
24613
24664
  #endif`;
24614
- var lights_physical_pars_fragment = `struct PhysicalMaterial {
24665
+ var lights_physical_pars_fragment = `uniform sampler2D dfgLUT;
24666
+ struct PhysicalMaterial {
24615
24667
  vec3 diffuseColor;
24616
- float roughness;
24668
+ vec3 diffuseContribution;
24617
24669
  vec3 specularColor;
24670
+ vec3 specularColorBlended;
24671
+ float roughness;
24672
+ float metalness;
24618
24673
  float specularF90;
24619
24674
  float dispersion;
24620
24675
  #ifdef USE_CLEARCOAT
@@ -24629,6 +24684,8 @@ var lights_physical_pars_fragment = `struct PhysicalMaterial {
24629
24684
  float iridescenceThickness;
24630
24685
  vec3 iridescenceFresnel;
24631
24686
  vec3 iridescenceF0;
24687
+ vec3 iridescenceFresnelDielectric;
24688
+ vec3 iridescenceFresnelMetallic;
24632
24689
  #endif
24633
24690
  #ifdef USE_SHEEN
24634
24691
  vec3 sheenColor;
@@ -24677,7 +24734,7 @@ float D_GGX( const in float alpha, const in float dotNH ) {
24677
24734
  float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
24678
24735
  float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
24679
24736
  float v = 0.5 / ( gv + gl );
24680
- return saturate(v);
24737
+ return v;
24681
24738
  }
24682
24739
  float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
24683
24740
  float a2 = alphaT * alphaB;
@@ -24705,7 +24762,7 @@ float D_GGX( const in float alpha, const in float dotNH ) {
24705
24762
  }
24706
24763
  #endif
24707
24764
  vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
24708
- vec3 f0 = material.specularColor;
24765
+ vec3 f0 = material.specularColorBlended;
24709
24766
  float f90 = material.specularF90;
24710
24767
  float roughness = material.roughness;
24711
24768
  float alpha = pow2( roughness );
@@ -24763,7 +24820,7 @@ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in m
24763
24820
  vec3 T1, T2;
24764
24821
  T1 = normalize( V - N * dot( V, N ) );
24765
24822
  T2 = - cross( N, T1 );
24766
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
24823
+ mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
24767
24824
  vec3 coords[ 4 ];
24768
24825
  coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
24769
24826
  coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
@@ -24805,22 +24862,15 @@ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 no
24805
24862
  float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
24806
24863
  float dotNV = saturate( dot( normal, viewDir ) );
24807
24864
  float r2 = roughness * roughness;
24808
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
24809
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
24810
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
24811
- return saturate( DG * RECIPROCAL_PI );
24812
- }
24813
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
24814
- float dotNV = saturate( dot( normal, viewDir ) );
24815
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
24816
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
24817
- vec4 r = roughness * c0 + c1;
24818
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
24819
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
24820
- return fab;
24865
+ float rInv = 1.0 / ( roughness + 0.1 );
24866
+ float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
24867
+ float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
24868
+ float DG = exp( a * dotNV + b );
24869
+ return saturate( DG );
24821
24870
  }
24822
24871
  vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
24823
- vec2 fab = DFGApprox( normal, viewDir, roughness );
24872
+ float dotNV = saturate( dot( normal, viewDir ) );
24873
+ vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
24824
24874
  return specularColor * fab.x + specularF90 * fab.y;
24825
24875
  }
24826
24876
  #ifdef USE_IRIDESCENCE
@@ -24828,7 +24878,8 @@ void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 view
24828
24878
  #else
24829
24879
  void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
24830
24880
  #endif
24831
- vec2 fab = DFGApprox( normal, viewDir, roughness );
24881
+ float dotNV = saturate( dot( normal, viewDir ) );
24882
+ vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
24832
24883
  #ifdef USE_IRIDESCENCE
24833
24884
  vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
24834
24885
  #else
@@ -24841,6 +24892,24 @@ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const
24841
24892
  singleScatter += FssEss;
24842
24893
  multiScatter += Fms * Ems;
24843
24894
  }
24895
+ vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
24896
+ vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
24897
+ float dotNL = saturate( dot( normal, lightDir ) );
24898
+ float dotNV = saturate( dot( normal, viewDir ) );
24899
+ vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
24900
+ vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
24901
+ vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
24902
+ vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;
24903
+ float Ess_V = dfgV.x + dfgV.y;
24904
+ float Ess_L = dfgL.x + dfgL.y;
24905
+ float Ems_V = 1.0 - Ess_V;
24906
+ float Ems_L = 1.0 - Ess_L;
24907
+ vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
24908
+ vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );
24909
+ float compensationFactor = Ems_V * Ems_L;
24910
+ vec3 multiScatter = Fms * compensationFactor;
24911
+ return singleScatter + multiScatter;
24912
+ }
24844
24913
  #if NUM_RECT_AREA_LIGHTS > 0
24845
24914
  void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
24846
24915
  vec3 normal = geometryNormal;
@@ -24863,9 +24932,9 @@ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const
24863
24932
  vec3( 0, 1, 0 ),
24864
24933
  vec3( t1.z, 0, t1.w )
24865
24934
  );
24866
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
24935
+ vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );
24867
24936
  reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
24868
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
24937
+ reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
24869
24938
  }
24870
24939
  #endif
24871
24940
  void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
@@ -24877,34 +24946,63 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geome
24877
24946
  clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
24878
24947
  #endif
24879
24948
  #ifdef USE_SHEEN
24880
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
24881
- #endif
24882
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
24883
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
24949
+
24950
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
24951
+
24952
+ float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
24953
+ float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
24954
+
24955
+ float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
24956
+
24957
+ irradiance *= sheenEnergyComp;
24958
+
24959
+ #endif
24960
+ reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
24961
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
24884
24962
  }
24885
24963
  void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
24886
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
24964
+ vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
24965
+ #ifdef USE_SHEEN
24966
+ float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
24967
+ float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
24968
+ diffuse *= sheenEnergyComp;
24969
+ #endif
24970
+ reflectedLight.indirectDiffuse += diffuse;
24887
24971
  }
24888
24972
  void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
24889
24973
  #ifdef USE_CLEARCOAT
24890
24974
  clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
24891
24975
  #endif
24892
24976
  #ifdef USE_SHEEN
24893
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
24894
- #endif
24895
- vec3 singleScattering = vec3( 0.0 );
24896
- vec3 multiScattering = vec3( 0.0 );
24897
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
24977
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;
24978
+ #endif
24979
+ vec3 singleScatteringDielectric = vec3( 0.0 );
24980
+ vec3 multiScatteringDielectric = vec3( 0.0 );
24981
+ vec3 singleScatteringMetallic = vec3( 0.0 );
24982
+ vec3 multiScatteringMetallic = vec3( 0.0 );
24898
24983
  #ifdef USE_IRIDESCENCE
24899
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
24984
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
24985
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
24900
24986
  #else
24901
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
24987
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
24988
+ computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
24989
+ #endif
24990
+ vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
24991
+ vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
24992
+ vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
24993
+ vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
24994
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
24995
+ vec3 indirectSpecular = radiance * singleScattering;
24996
+ indirectSpecular += multiScattering * cosineWeightedIrradiance;
24997
+ vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
24998
+ #ifdef USE_SHEEN
24999
+ float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
25000
+ float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
25001
+ indirectSpecular *= sheenEnergyComp;
25002
+ indirectDiffuse *= sheenEnergyComp;
24902
25003
  #endif
24903
- vec3 totalScattering = singleScattering + multiScattering;
24904
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
24905
- reflectedLight.indirectSpecular += radiance * singleScattering;
24906
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
24907
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
25004
+ reflectedLight.indirectSpecular += indirectSpecular;
25005
+ reflectedLight.indirectDiffuse += indirectDiffuse;
24908
25006
  }
24909
25007
  #define RE_Direct RE_Direct_Physical
24910
25008
  #define RE_Direct_RectArea RE_Direct_RectArea_Physical
@@ -24929,7 +25027,9 @@ vec3 geometryClearcoatNormal = vec3( 0.0 );
24929
25027
  material.iridescence = saturate( material.iridescence );
24930
25028
  }
24931
25029
  if ( material.iridescence > 0.0 ) {
24932
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
25030
+ material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
25031
+ material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
25032
+ material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
24933
25033
  material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
24934
25034
  }
24935
25035
  #endif
@@ -24943,7 +25043,7 @@ IncidentLight directLight;
24943
25043
  for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
24944
25044
  pointLight = pointLights[ i ];
24945
25045
  getPointLightInfo( pointLight, geometryPosition, directLight );
24946
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
25046
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
24947
25047
  pointLightShadow = pointLightShadows[ i ];
24948
25048
  directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
24949
25049
  #endif
@@ -25401,7 +25501,11 @@ var shadowmap_pars_fragment = `#if NUM_SPOT_LIGHT_COORDS > 0
25401
25501
  #endif
25402
25502
  #ifdef USE_SHADOWMAP
25403
25503
  #if NUM_DIR_LIGHT_SHADOWS > 0
25404
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
25504
+ #if defined( SHADOWMAP_TYPE_PCF )
25505
+ uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
25506
+ #else
25507
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
25508
+ #endif
25405
25509
  varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
25406
25510
  struct DirectionalLightShadow {
25407
25511
  float shadowIntensity;
@@ -25413,7 +25517,11 @@ var shadowmap_pars_fragment = `#if NUM_SPOT_LIGHT_COORDS > 0
25413
25517
  uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
25414
25518
  #endif
25415
25519
  #if NUM_SPOT_LIGHT_SHADOWS > 0
25416
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
25520
+ #if defined( SHADOWMAP_TYPE_PCF )
25521
+ uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
25522
+ #else
25523
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
25524
+ #endif
25417
25525
  struct SpotLightShadow {
25418
25526
  float shadowIntensity;
25419
25527
  float shadowBias;
@@ -25424,7 +25532,11 @@ var shadowmap_pars_fragment = `#if NUM_SPOT_LIGHT_COORDS > 0
25424
25532
  uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
25425
25533
  #endif
25426
25534
  #if NUM_POINT_LIGHT_SHADOWS > 0
25427
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
25535
+ #if defined( SHADOWMAP_TYPE_PCF )
25536
+ uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
25537
+ #elif defined( SHADOWMAP_TYPE_BASIC )
25538
+ uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
25539
+ #endif
25428
25540
  varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
25429
25541
  struct PointLightShadow {
25430
25542
  float shadowIntensity;
@@ -25437,157 +25549,132 @@ var shadowmap_pars_fragment = `#if NUM_SPOT_LIGHT_COORDS > 0
25437
25549
  };
25438
25550
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
25439
25551
  #endif
25440
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
25441
- float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
25442
- #ifdef USE_REVERSED_DEPTH_BUFFER
25443
- return step( depth, compare );
25444
- #else
25445
- return step( compare, depth );
25446
- #endif
25447
- }
25448
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
25449
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
25450
- }
25451
- float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
25452
- float occlusion = 1.0;
25453
- vec2 distribution = texture2DDistribution( shadow, uv );
25454
- #ifdef USE_REVERSED_DEPTH_BUFFER
25455
- float hard_shadow = step( distribution.x, compare );
25456
- #else
25457
- float hard_shadow = step( compare, distribution.x );
25458
- #endif
25459
- if ( hard_shadow != 1.0 ) {
25460
- float distance = compare - distribution.x;
25461
- float variance = max( 0.00000, distribution.y * distribution.y );
25462
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
25552
+ #if defined( SHADOWMAP_TYPE_PCF )
25553
+ float interleavedGradientNoise( vec2 position ) {
25554
+ return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
25463
25555
  }
25464
- return occlusion;
25465
- }
25466
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
25556
+ vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
25557
+ const float goldenAngle = 2.399963229728653;
25558
+ float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
25559
+ float theta = float( sampleIndex ) * goldenAngle + phi;
25560
+ return vec2( cos( theta ), sin( theta ) ) * r;
25561
+ }
25562
+ #endif
25563
+ #if defined( SHADOWMAP_TYPE_PCF )
25564
+ float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
25565
+ float shadow = 1.0;
25566
+ shadowCoord.xyz /= shadowCoord.w;
25567
+ shadowCoord.z += shadowBias;
25568
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
25569
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
25570
+ if ( frustumTest ) {
25571
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
25572
+ float radius = shadowRadius * texelSize.x;
25573
+ float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
25574
+ shadow = (
25575
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
25576
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
25577
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
25578
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
25579
+ texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
25580
+ ) * 0.2;
25581
+ }
25582
+ return mix( 1.0, shadow, shadowIntensity );
25583
+ }
25584
+ #elif defined( SHADOWMAP_TYPE_VSM )
25585
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
25586
+ float shadow = 1.0;
25587
+ shadowCoord.xyz /= shadowCoord.w;
25588
+ shadowCoord.z += shadowBias;
25589
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
25590
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
25591
+ if ( frustumTest ) {
25592
+ vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
25593
+ float mean = distribution.x;
25594
+ float variance = distribution.y * distribution.y;
25595
+ #ifdef USE_REVERSED_DEPTH_BUFFER
25596
+ float hard_shadow = step( mean, shadowCoord.z );
25597
+ #else
25598
+ float hard_shadow = step( shadowCoord.z, mean );
25599
+ #endif
25600
+ if ( hard_shadow == 1.0 ) {
25601
+ shadow = 1.0;
25602
+ } else {
25603
+ variance = max( variance, 0.0000001 );
25604
+ float d = shadowCoord.z - mean;
25605
+ float p_max = variance / ( variance + d * d );
25606
+ p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
25607
+ shadow = max( hard_shadow, p_max );
25608
+ }
25609
+ }
25610
+ return mix( 1.0, shadow, shadowIntensity );
25611
+ }
25612
+ #else
25613
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
25614
+ float shadow = 1.0;
25615
+ shadowCoord.xyz /= shadowCoord.w;
25616
+ shadowCoord.z += shadowBias;
25617
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
25618
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
25619
+ if ( frustumTest ) {
25620
+ float depth = texture2D( shadowMap, shadowCoord.xy ).r;
25621
+ #ifdef USE_REVERSED_DEPTH_BUFFER
25622
+ shadow = step( depth, shadowCoord.z );
25623
+ #else
25624
+ shadow = step( shadowCoord.z, depth );
25625
+ #endif
25626
+ }
25627
+ return mix( 1.0, shadow, shadowIntensity );
25628
+ }
25629
+ #endif
25630
+ #if NUM_POINT_LIGHT_SHADOWS > 0
25631
+ #if defined( SHADOWMAP_TYPE_PCF )
25632
+ float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
25467
25633
  float shadow = 1.0;
25468
- shadowCoord.xyz /= shadowCoord.w;
25469
- shadowCoord.z += shadowBias;
25470
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
25471
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
25472
- if ( frustumTest ) {
25473
- #if defined( SHADOWMAP_TYPE_PCF )
25474
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
25475
- float dx0 = - texelSize.x * shadowRadius;
25476
- float dy0 = - texelSize.y * shadowRadius;
25477
- float dx1 = + texelSize.x * shadowRadius;
25478
- float dy1 = + texelSize.y * shadowRadius;
25479
- float dx2 = dx0 / 2.0;
25480
- float dy2 = dy0 / 2.0;
25481
- float dx3 = dx1 / 2.0;
25482
- float dy3 = dy1 / 2.0;
25483
- shadow = (
25484
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
25485
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
25486
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
25487
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
25488
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
25489
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
25490
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
25491
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
25492
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
25493
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
25494
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
25495
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
25496
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
25497
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
25498
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
25499
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
25500
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
25501
- ) * ( 1.0 / 17.0 );
25502
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
25503
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
25504
- float dx = texelSize.x;
25505
- float dy = texelSize.y;
25506
- vec2 uv = shadowCoord.xy;
25507
- vec2 f = fract( uv * shadowMapSize + 0.5 );
25508
- uv -= f * texelSize;
25634
+ vec3 lightToPosition = shadowCoord.xyz;
25635
+ vec3 bd3D = normalize( lightToPosition );
25636
+ vec3 absVec = abs( lightToPosition );
25637
+ float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
25638
+ if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
25639
+ float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
25640
+ dp += shadowBias;
25641
+ float texelSize = shadowRadius / shadowMapSize.x;
25642
+ vec3 absDir = abs( bd3D );
25643
+ vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
25644
+ tangent = normalize( cross( bd3D, tangent ) );
25645
+ vec3 bitangent = cross( bd3D, tangent );
25646
+ float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
25509
25647
  shadow = (
25510
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
25511
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
25512
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
25513
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
25514
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
25515
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
25516
- f.x ) +
25517
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
25518
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
25519
- f.x ) +
25520
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
25521
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
25522
- f.y ) +
25523
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
25524
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
25525
- f.y ) +
25526
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
25527
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
25528
- f.x ),
25529
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
25530
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
25531
- f.x ),
25532
- f.y )
25533
- ) * ( 1.0 / 9.0 );
25534
- #elif defined( SHADOWMAP_TYPE_VSM )
25535
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
25536
- #else
25537
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
25538
- #endif
25648
+ texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +
25649
+ texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +
25650
+ texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +
25651
+ texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +
25652
+ texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )
25653
+ ) * 0.2;
25539
25654
  }
25540
25655
  return mix( 1.0, shadow, shadowIntensity );
25541
25656
  }
25542
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
25543
- vec3 absV = abs( v );
25544
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
25545
- absV *= scaleToCube;
25546
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
25547
- vec2 planar = v.xy;
25548
- float almostATexel = 1.5 * texelSizeY;
25549
- float almostOne = 1.0 - almostATexel;
25550
- if ( absV.z >= almostOne ) {
25551
- if ( v.z > 0.0 )
25552
- planar.x = 4.0 - v.x;
25553
- } else if ( absV.x >= almostOne ) {
25554
- float signX = sign( v.x );
25555
- planar.x = v.z * signX + 2.0 * signX;
25556
- } else if ( absV.y >= almostOne ) {
25557
- float signY = sign( v.y );
25558
- planar.x = v.x + 2.0 * signY + 2.0;
25559
- planar.y = v.z * signY - 2.0;
25560
- }
25561
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
25562
- }
25563
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
25657
+ #elif defined( SHADOWMAP_TYPE_BASIC )
25658
+ float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
25564
25659
  float shadow = 1.0;
25565
25660
  vec3 lightToPosition = shadowCoord.xyz;
25566
-
25567
- float lightToPositionLength = length( lightToPosition );
25568
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
25569
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
25570
- vec3 bd3D = normalize( lightToPosition );
25571
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
25572
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
25573
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
25574
- shadow = (
25575
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
25576
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
25577
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
25578
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
25579
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
25580
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
25581
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
25582
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
25583
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
25584
- ) * ( 1.0 / 9.0 );
25661
+ vec3 bd3D = normalize( lightToPosition );
25662
+ vec3 absVec = abs( lightToPosition );
25663
+ float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
25664
+ if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
25665
+ float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
25666
+ dp += shadowBias;
25667
+ float depth = textureCube( shadowMap, bd3D ).r;
25668
+ #ifdef USE_REVERSED_DEPTH_BUFFER
25669
+ shadow = step( depth, dp );
25585
25670
  #else
25586
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
25671
+ shadow = step( dp, depth );
25587
25672
  #endif
25588
25673
  }
25589
25674
  return mix( 1.0, shadow, shadowIntensity );
25590
25675
  }
25676
+ #endif
25677
+ #endif
25591
25678
  #endif`;
25592
25679
  var shadowmap_pars_vertex = `#if NUM_SPOT_LIGHT_COORDS > 0
25593
25680
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
@@ -25685,7 +25772,7 @@ var shadowmask_pars_fragment = `float getShadowMask() {
25685
25772
  }
25686
25773
  #pragma unroll_loop_end
25687
25774
  #endif
25688
- #if NUM_POINT_LIGHT_SHADOWS > 0
25775
+ #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
25689
25776
  PointLightShadow pointLight;
25690
25777
  #pragma unroll_loop_start
25691
25778
  for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
@@ -25867,7 +25954,7 @@ var transmission_fragment = `#ifdef USE_TRANSMISSION
25867
25954
  vec3 v = normalize( cameraPosition - pos );
25868
25955
  vec3 n = inverseTransformDirection( normal, viewMatrix );
25869
25956
  vec4 transmitted = getIBLVolumeRefraction(
25870
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
25957
+ n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
25871
25958
  pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
25872
25959
  material.attenuationColor, material.attenuationDistance );
25873
25960
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
@@ -26419,7 +26506,6 @@ uniform float nearDistance;
26419
26506
  uniform float farDistance;
26420
26507
  varying vec3 vWorldPosition;
26421
26508
  #include <common>
26422
- #include <packing>
26423
26509
  #include <uv_pars_fragment>
26424
26510
  #include <map_pars_fragment>
26425
26511
  #include <alphamap_pars_fragment>
@@ -26436,7 +26522,7 @@ void main () {
26436
26522
  float dist = length( vWorldPosition - referencePosition );
26437
26523
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
26438
26524
  dist = saturate( dist );
26439
- gl_FragColor = packDepthToRGBA( dist );
26525
+ gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
26440
26526
  }`;
26441
26527
  var vertex$c = `varying vec3 vWorldDirection;
26442
26528
  #include <common>
@@ -26634,7 +26720,6 @@ uniform vec3 diffuse;
26634
26720
  uniform vec3 emissive;
26635
26721
  uniform float opacity;
26636
26722
  #include <common>
26637
- #include <packing>
26638
26723
  #include <dithering_pars_fragment>
26639
26724
  #include <color_pars_fragment>
26640
26725
  #include <uv_pars_fragment>
@@ -26808,7 +26893,6 @@ uniform float opacity;
26808
26893
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
26809
26894
  varying vec3 vViewPosition;
26810
26895
  #endif
26811
- #include <packing>
26812
26896
  #include <uv_pars_fragment>
26813
26897
  #include <normal_pars_fragment>
26814
26898
  #include <bumpmap_pars_fragment>
@@ -26821,7 +26905,7 @@ void main() {
26821
26905
  #include <logdepthbuf_fragment>
26822
26906
  #include <normal_fragment_begin>
26823
26907
  #include <normal_fragment_maps>
26824
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
26908
+ gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
26825
26909
  #ifdef OPAQUE
26826
26910
  gl_FragColor.a = 1.0;
26827
26911
  #endif
@@ -26873,7 +26957,6 @@ uniform vec3 specular;
26873
26957
  uniform float shininess;
26874
26958
  uniform float opacity;
26875
26959
  #include <common>
26876
- #include <packing>
26877
26960
  #include <dithering_pars_fragment>
26878
26961
  #include <color_pars_fragment>
26879
26962
  #include <uv_pars_fragment>
@@ -27024,7 +27107,6 @@ uniform float opacity;
27024
27107
  #endif
27025
27108
  varying vec3 vViewPosition;
27026
27109
  #include <common>
27027
- #include <packing>
27028
27110
  #include <dithering_pars_fragment>
27029
27111
  #include <color_pars_fragment>
27030
27112
  #include <uv_pars_fragment>
@@ -27081,9 +27163,10 @@ void main() {
27081
27163
  #include <transmission_fragment>
27082
27164
  vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
27083
27165
  #ifdef USE_SHEEN
27084
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
27085
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
27086
- #endif
27166
+
27167
+ outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
27168
+
27169
+ #endif
27087
27170
  #ifdef USE_CLEARCOAT
27088
27171
  float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
27089
27172
  vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
@@ -27139,7 +27222,6 @@ uniform vec3 diffuse;
27139
27222
  uniform vec3 emissive;
27140
27223
  uniform float opacity;
27141
27224
  #include <common>
27142
- #include <packing>
27143
27225
  #include <dithering_pars_fragment>
27144
27226
  #include <color_pars_fragment>
27145
27227
  #include <uv_pars_fragment>
@@ -27273,7 +27355,6 @@ void main() {
27273
27355
  var fragment$2 = `uniform vec3 color;
27274
27356
  uniform float opacity;
27275
27357
  #include <common>
27276
- #include <packing>
27277
27358
  #include <fog_pars_fragment>
27278
27359
  #include <bsdfs>
27279
27360
  #include <lights_pars_begin>
@@ -27454,8 +27535,8 @@ var ShaderChunk = {
27454
27535
  cube_frag: fragment$f,
27455
27536
  depth_vert: vertex$e,
27456
27537
  depth_frag: fragment$e,
27457
- distanceRGBA_vert: vertex$d,
27458
- distanceRGBA_frag: fragment$d,
27538
+ distance_vert: vertex$d,
27539
+ distance_frag: fragment$d,
27459
27540
  equirect_vert: vertex$c,
27460
27541
  equirect_frag: fragment$c,
27461
27542
  linedashed_vert: vertex$b,
@@ -27501,7 +27582,8 @@ var UniformsLib = {
27501
27582
  flipEnvMap: { value: -1 },
27502
27583
  reflectivity: { value: 1 },
27503
27584
  ior: { value: 1.5 },
27504
- refractionRatio: { value: 0.98 }
27585
+ refractionRatio: { value: 0.98 },
27586
+ dfgLUT: { value: null }
27505
27587
  },
27506
27588
  aomap: {
27507
27589
  aoMap: { value: null },
@@ -27837,7 +27919,7 @@ var ShaderLib = {
27837
27919
  vertexShader: ShaderChunk.equirect_vert,
27838
27920
  fragmentShader: ShaderChunk.equirect_frag
27839
27921
  },
27840
- distanceRGBA: {
27922
+ distance: {
27841
27923
  uniforms: /* @__PURE__ */ mergeUniforms([
27842
27924
  UniformsLib.common,
27843
27925
  UniformsLib.displacementmap,
@@ -27847,8 +27929,8 @@ var ShaderLib = {
27847
27929
  farDistance: { value: 1000 }
27848
27930
  }
27849
27931
  ]),
27850
- vertexShader: ShaderChunk.distanceRGBA_vert,
27851
- fragmentShader: ShaderChunk.distanceRGBA_frag
27932
+ vertexShader: ShaderChunk.distance_vert,
27933
+ fragmentShader: ShaderChunk.distance_frag
27852
27934
  },
27853
27935
  shadow: {
27854
27936
  uniforms: /* @__PURE__ */ mergeUniforms([
@@ -27916,24 +27998,45 @@ ShaderLib.physical = {
27916
27998
  vertexShader: ShaderChunk.meshphysical_vert,
27917
27999
  fragmentShader: ShaderChunk.meshphysical_frag
27918
28000
  };
27919
- var PHI = (1 + Math.sqrt(5)) / 2;
27920
- var INV_PHI = 1 / PHI;
27921
- var _axisDirections = [
27922
- /* @__PURE__ */ new Vector3(-PHI, INV_PHI, 0),
27923
- /* @__PURE__ */ new Vector3(PHI, INV_PHI, 0),
27924
- /* @__PURE__ */ new Vector3(-INV_PHI, 0, PHI),
27925
- /* @__PURE__ */ new Vector3(INV_PHI, 0, PHI),
27926
- /* @__PURE__ */ new Vector3(0, PHI, -INV_PHI),
27927
- /* @__PURE__ */ new Vector3(0, PHI, INV_PHI),
27928
- /* @__PURE__ */ new Vector3(-1, 1, -1),
27929
- /* @__PURE__ */ new Vector3(1, 1, -1),
27930
- /* @__PURE__ */ new Vector3(-1, 1, 1),
27931
- /* @__PURE__ */ new Vector3(1, 1, 1)
27932
- ];
28001
+ var toneMappingMap = {
28002
+ [LinearToneMapping]: "LINEAR_TONE_MAPPING",
28003
+ [ReinhardToneMapping]: "REINHARD_TONE_MAPPING",
28004
+ [CineonToneMapping]: "CINEON_TONE_MAPPING",
28005
+ [ACESFilmicToneMapping]: "ACES_FILMIC_TONE_MAPPING",
28006
+ [AgXToneMapping]: "AGX_TONE_MAPPING",
28007
+ [NeutralToneMapping]: "NEUTRAL_TONE_MAPPING",
28008
+ [CustomToneMapping]: "CUSTOM_TONE_MAPPING"
28009
+ };
27933
28010
  var mat4array = new Float32Array(16);
27934
28011
  var mat3array = new Float32Array(9);
27935
28012
  var mat2array = new Float32Array(4);
28013
+ var toneMappingFunctions = {
28014
+ [LinearToneMapping]: "Linear",
28015
+ [ReinhardToneMapping]: "Reinhard",
28016
+ [CineonToneMapping]: "Cineon",
28017
+ [ACESFilmicToneMapping]: "ACESFilmic",
28018
+ [AgXToneMapping]: "AgX",
28019
+ [NeutralToneMapping]: "Neutral",
28020
+ [CustomToneMapping]: "Custom"
28021
+ };
27936
28022
  var shaderChunkMap = new Map;
28023
+ var shadowMapTypeDefines = {
28024
+ [PCFShadowMap]: "SHADOWMAP_TYPE_PCF",
28025
+ [VSMShadowMap]: "SHADOWMAP_TYPE_VSM"
28026
+ };
28027
+ var envMapTypeDefines = {
28028
+ [CubeReflectionMapping]: "ENVMAP_TYPE_CUBE",
28029
+ [CubeRefractionMapping]: "ENVMAP_TYPE_CUBE",
28030
+ [CubeUVReflectionMapping]: "ENVMAP_TYPE_CUBE_UV"
28031
+ };
28032
+ var envMapModeDefines = {
28033
+ [CubeRefractionMapping]: "ENVMAP_MODE_REFRACTION"
28034
+ };
28035
+ var envMapBlendingDefines = {
28036
+ [MultiplyOperation]: "ENVMAP_BLENDING_MULTIPLY",
28037
+ [MixOperation]: "ENVMAP_BLENDING_MIX",
28038
+ [AddOperation]: "ENVMAP_BLENDING_ADD"
28039
+ };
27937
28040
  var reversedFuncs = {
27938
28041
  [NeverDepth]: AlwaysDepth,
27939
28042
  [LessDepth]: GreaterDepth,
@@ -27944,6 +28047,520 @@ var reversedFuncs = {
27944
28047
  [NotEqualDepth]: EqualDepth,
27945
28048
  [GreaterEqualDepth]: LessEqualDepth
27946
28049
  };
28050
+ var DATA = new Uint16Array([
28051
+ 12469,
28052
+ 15057,
28053
+ 12620,
28054
+ 14925,
28055
+ 13266,
28056
+ 14620,
28057
+ 13807,
28058
+ 14376,
28059
+ 14323,
28060
+ 13990,
28061
+ 14545,
28062
+ 13625,
28063
+ 14713,
28064
+ 13328,
28065
+ 14840,
28066
+ 12882,
28067
+ 14931,
28068
+ 12528,
28069
+ 14996,
28070
+ 12233,
28071
+ 15039,
28072
+ 11829,
28073
+ 15066,
28074
+ 11525,
28075
+ 15080,
28076
+ 11295,
28077
+ 15085,
28078
+ 10976,
28079
+ 15082,
28080
+ 10705,
28081
+ 15073,
28082
+ 10495,
28083
+ 13880,
28084
+ 14564,
28085
+ 13898,
28086
+ 14542,
28087
+ 13977,
28088
+ 14430,
28089
+ 14158,
28090
+ 14124,
28091
+ 14393,
28092
+ 13732,
28093
+ 14556,
28094
+ 13410,
28095
+ 14702,
28096
+ 12996,
28097
+ 14814,
28098
+ 12596,
28099
+ 14891,
28100
+ 12291,
28101
+ 14937,
28102
+ 11834,
28103
+ 14957,
28104
+ 11489,
28105
+ 14958,
28106
+ 11194,
28107
+ 14943,
28108
+ 10803,
28109
+ 14921,
28110
+ 10506,
28111
+ 14893,
28112
+ 10278,
28113
+ 14858,
28114
+ 9960,
28115
+ 14484,
28116
+ 14039,
28117
+ 14487,
28118
+ 14025,
28119
+ 14499,
28120
+ 13941,
28121
+ 14524,
28122
+ 13740,
28123
+ 14574,
28124
+ 13468,
28125
+ 14654,
28126
+ 13106,
28127
+ 14743,
28128
+ 12678,
28129
+ 14818,
28130
+ 12344,
28131
+ 14867,
28132
+ 11893,
28133
+ 14889,
28134
+ 11509,
28135
+ 14893,
28136
+ 11180,
28137
+ 14881,
28138
+ 10751,
28139
+ 14852,
28140
+ 10428,
28141
+ 14812,
28142
+ 10128,
28143
+ 14765,
28144
+ 9754,
28145
+ 14712,
28146
+ 9466,
28147
+ 14764,
28148
+ 13480,
28149
+ 14764,
28150
+ 13475,
28151
+ 14766,
28152
+ 13440,
28153
+ 14766,
28154
+ 13347,
28155
+ 14769,
28156
+ 13070,
28157
+ 14786,
28158
+ 12713,
28159
+ 14816,
28160
+ 12387,
28161
+ 14844,
28162
+ 11957,
28163
+ 14860,
28164
+ 11549,
28165
+ 14868,
28166
+ 11215,
28167
+ 14855,
28168
+ 10751,
28169
+ 14825,
28170
+ 10403,
28171
+ 14782,
28172
+ 10044,
28173
+ 14729,
28174
+ 9651,
28175
+ 14666,
28176
+ 9352,
28177
+ 14599,
28178
+ 9029,
28179
+ 14967,
28180
+ 12835,
28181
+ 14966,
28182
+ 12831,
28183
+ 14963,
28184
+ 12804,
28185
+ 14954,
28186
+ 12723,
28187
+ 14936,
28188
+ 12564,
28189
+ 14917,
28190
+ 12347,
28191
+ 14900,
28192
+ 11958,
28193
+ 14886,
28194
+ 11569,
28195
+ 14878,
28196
+ 11247,
28197
+ 14859,
28198
+ 10765,
28199
+ 14828,
28200
+ 10401,
28201
+ 14784,
28202
+ 10011,
28203
+ 14727,
28204
+ 9600,
28205
+ 14660,
28206
+ 9289,
28207
+ 14586,
28208
+ 8893,
28209
+ 14508,
28210
+ 8533,
28211
+ 15111,
28212
+ 12234,
28213
+ 15110,
28214
+ 12234,
28215
+ 15104,
28216
+ 12216,
28217
+ 15092,
28218
+ 12156,
28219
+ 15067,
28220
+ 12010,
28221
+ 15028,
28222
+ 11776,
28223
+ 14981,
28224
+ 11500,
28225
+ 14942,
28226
+ 11205,
28227
+ 14902,
28228
+ 10752,
28229
+ 14861,
28230
+ 10393,
28231
+ 14812,
28232
+ 9991,
28233
+ 14752,
28234
+ 9570,
28235
+ 14682,
28236
+ 9252,
28237
+ 14603,
28238
+ 8808,
28239
+ 14519,
28240
+ 8445,
28241
+ 14431,
28242
+ 8145,
28243
+ 15209,
28244
+ 11449,
28245
+ 15208,
28246
+ 11451,
28247
+ 15202,
28248
+ 11451,
28249
+ 15190,
28250
+ 11438,
28251
+ 15163,
28252
+ 11384,
28253
+ 15117,
28254
+ 11274,
28255
+ 15055,
28256
+ 10979,
28257
+ 14994,
28258
+ 10648,
28259
+ 14932,
28260
+ 10343,
28261
+ 14871,
28262
+ 9936,
28263
+ 14803,
28264
+ 9532,
28265
+ 14729,
28266
+ 9218,
28267
+ 14645,
28268
+ 8742,
28269
+ 14556,
28270
+ 8381,
28271
+ 14461,
28272
+ 8020,
28273
+ 14365,
28274
+ 7603,
28275
+ 15273,
28276
+ 10603,
28277
+ 15272,
28278
+ 10607,
28279
+ 15267,
28280
+ 10619,
28281
+ 15256,
28282
+ 10631,
28283
+ 15231,
28284
+ 10614,
28285
+ 15182,
28286
+ 10535,
28287
+ 15118,
28288
+ 10389,
28289
+ 15042,
28290
+ 10167,
28291
+ 14963,
28292
+ 9787,
28293
+ 14883,
28294
+ 9447,
28295
+ 14800,
28296
+ 9115,
28297
+ 14710,
28298
+ 8665,
28299
+ 14615,
28300
+ 8318,
28301
+ 14514,
28302
+ 7911,
28303
+ 14411,
28304
+ 7507,
28305
+ 14279,
28306
+ 7198,
28307
+ 15314,
28308
+ 9675,
28309
+ 15313,
28310
+ 9683,
28311
+ 15309,
28312
+ 9712,
28313
+ 15298,
28314
+ 9759,
28315
+ 15277,
28316
+ 9797,
28317
+ 15229,
28318
+ 9773,
28319
+ 15166,
28320
+ 9668,
28321
+ 15084,
28322
+ 9487,
28323
+ 14995,
28324
+ 9274,
28325
+ 14898,
28326
+ 8910,
28327
+ 14800,
28328
+ 8539,
28329
+ 14697,
28330
+ 8234,
28331
+ 14590,
28332
+ 7790,
28333
+ 14479,
28334
+ 7409,
28335
+ 14367,
28336
+ 7067,
28337
+ 14178,
28338
+ 6621,
28339
+ 15337,
28340
+ 8619,
28341
+ 15337,
28342
+ 8631,
28343
+ 15333,
28344
+ 8677,
28345
+ 15325,
28346
+ 8769,
28347
+ 15305,
28348
+ 8871,
28349
+ 15264,
28350
+ 8940,
28351
+ 15202,
28352
+ 8909,
28353
+ 15119,
28354
+ 8775,
28355
+ 15022,
28356
+ 8565,
28357
+ 14916,
28358
+ 8328,
28359
+ 14804,
28360
+ 8009,
28361
+ 14688,
28362
+ 7614,
28363
+ 14569,
28364
+ 7287,
28365
+ 14448,
28366
+ 6888,
28367
+ 14321,
28368
+ 6483,
28369
+ 14088,
28370
+ 6171,
28371
+ 15350,
28372
+ 7402,
28373
+ 15350,
28374
+ 7419,
28375
+ 15347,
28376
+ 7480,
28377
+ 15340,
28378
+ 7613,
28379
+ 15322,
28380
+ 7804,
28381
+ 15287,
28382
+ 7973,
28383
+ 15229,
28384
+ 8057,
28385
+ 15148,
28386
+ 8012,
28387
+ 15046,
28388
+ 7846,
28389
+ 14933,
28390
+ 7611,
28391
+ 14810,
28392
+ 7357,
28393
+ 14682,
28394
+ 7069,
28395
+ 14552,
28396
+ 6656,
28397
+ 14421,
28398
+ 6316,
28399
+ 14251,
28400
+ 5948,
28401
+ 14007,
28402
+ 5528,
28403
+ 15356,
28404
+ 5942,
28405
+ 15356,
28406
+ 5977,
28407
+ 15353,
28408
+ 6119,
28409
+ 15348,
28410
+ 6294,
28411
+ 15332,
28412
+ 6551,
28413
+ 15302,
28414
+ 6824,
28415
+ 15249,
28416
+ 7044,
28417
+ 15171,
28418
+ 7122,
28419
+ 15070,
28420
+ 7050,
28421
+ 14949,
28422
+ 6861,
28423
+ 14818,
28424
+ 6611,
28425
+ 14679,
28426
+ 6349,
28427
+ 14538,
28428
+ 6067,
28429
+ 14398,
28430
+ 5651,
28431
+ 14189,
28432
+ 5311,
28433
+ 13935,
28434
+ 4958,
28435
+ 15359,
28436
+ 4123,
28437
+ 15359,
28438
+ 4153,
28439
+ 15356,
28440
+ 4296,
28441
+ 15353,
28442
+ 4646,
28443
+ 15338,
28444
+ 5160,
28445
+ 15311,
28446
+ 5508,
28447
+ 15263,
28448
+ 5829,
28449
+ 15188,
28450
+ 6042,
28451
+ 15088,
28452
+ 6094,
28453
+ 14966,
28454
+ 6001,
28455
+ 14826,
28456
+ 5796,
28457
+ 14678,
28458
+ 5543,
28459
+ 14527,
28460
+ 5287,
28461
+ 14377,
28462
+ 4985,
28463
+ 14133,
28464
+ 4586,
28465
+ 13869,
28466
+ 4257,
28467
+ 15360,
28468
+ 1563,
28469
+ 15360,
28470
+ 1642,
28471
+ 15358,
28472
+ 2076,
28473
+ 15354,
28474
+ 2636,
28475
+ 15341,
28476
+ 3350,
28477
+ 15317,
28478
+ 4019,
28479
+ 15273,
28480
+ 4429,
28481
+ 15203,
28482
+ 4732,
28483
+ 15105,
28484
+ 4911,
28485
+ 14981,
28486
+ 4932,
28487
+ 14836,
28488
+ 4818,
28489
+ 14679,
28490
+ 4621,
28491
+ 14517,
28492
+ 4386,
28493
+ 14359,
28494
+ 4156,
28495
+ 14083,
28496
+ 3795,
28497
+ 13808,
28498
+ 3437,
28499
+ 15360,
28500
+ 122,
28501
+ 15360,
28502
+ 137,
28503
+ 15358,
28504
+ 285,
28505
+ 15355,
28506
+ 636,
28507
+ 15344,
28508
+ 1274,
28509
+ 15322,
28510
+ 2177,
28511
+ 15281,
28512
+ 2765,
28513
+ 15215,
28514
+ 3223,
28515
+ 15120,
28516
+ 3451,
28517
+ 14995,
28518
+ 3569,
28519
+ 14846,
28520
+ 3567,
28521
+ 14681,
28522
+ 3466,
28523
+ 14511,
28524
+ 3305,
28525
+ 14344,
28526
+ 3121,
28527
+ 14037,
28528
+ 2800,
28529
+ 13753,
28530
+ 2467,
28531
+ 15360,
28532
+ 0,
28533
+ 15360,
28534
+ 1,
28535
+ 15359,
28536
+ 21,
28537
+ 15355,
28538
+ 89,
28539
+ 15346,
28540
+ 253,
28541
+ 15325,
28542
+ 479,
28543
+ 15287,
28544
+ 796,
28545
+ 15225,
28546
+ 1148,
28547
+ 15133,
28548
+ 1492,
28549
+ 15008,
28550
+ 1749,
28551
+ 14856,
28552
+ 1882,
28553
+ 14685,
28554
+ 1886,
28555
+ 14506,
28556
+ 1783,
28557
+ 14324,
28558
+ 1608,
28559
+ 13996,
28560
+ 1398,
28561
+ 13702,
28562
+ 1183
28563
+ ]);
27947
28564
 
27948
28565
  // src/library/bug-rangers-game-state.ts
27949
28566
  var dragStateAtom = atom2({
@@ -28498,7 +29115,7 @@ parent.receiveRelay((socket, userKey) => {
28498
29115
  const exposeState = realtimeStateProvider(config3);
28499
29116
  const exposeMutable = realtimeMutableProvider(config3);
28500
29117
  const exposeFamily = realtimeAtomFamilyProvider(config3);
28501
- const gameSocket = castSocket(socket, bugRangersGuard, parent.logger.error);
29118
+ const gameSocket = guardSocket(socket, bugRangersGuard, parent.logger.error);
28502
29119
  const usersHereAtom = findState(usersInRoomsAtoms, ROOM_KEY);
28503
29120
  const coreStack = [];
28504
29121
  coreStack.push(exposeState(turnNumberAtom), exposeState(gameStateAtom), exposeState(turnInProgressAtom), exposeMutable(playerTurnOrderAtom), exposeMutable(gameTilesAtom), exposeFamily(playerReadyStatusAtoms, usersHereAtom), exposeFamily(playerColorAtoms, usersHereAtom), exposeFamily(playerRemainingCubesAtoms, usersHereAtom), exposeFamily(playerRemainingTilesAtoms, usersHereAtom), exposeFamily(tileOwnerAtoms, gameTilesAtom), exposeFamily(tileCubeCountAtoms, gameTilesAtom), exposeFamily(gameTilesStackHeightAtoms, gameTilesAtom), employSocket(gameSocket, `wantFirst`, () => {