@gjsify/example-dom-three-postprocessing-pixel 0.1.13 → 0.2.0

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.
Files changed (3) hide show
  1. package/dist/browser.js +404 -157
  2. package/dist/gjs.js +1072 -1561
  3. package/package.json +12 -12
package/dist/gjs.js CHANGED
@@ -10,10 +10,6 @@ var __esm = (fn, res) => function __init() {
10
10
  var __commonJS = (cb, mod) => function __require() {
11
11
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
12
  };
13
- var __export = (target, all) => {
14
- for (var name2 in all)
15
- __defProp(target, name2, { get: all[name2], enumerable: true });
16
- };
17
13
  var __copyProps = (to, from, except, desc) => {
18
14
  if (from && typeof from === "object" || typeof from === "function") {
19
15
  for (let key of __getOwnPropNames(from))
@@ -30,14 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
26
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
27
  mod
32
28
  ));
33
- var __toCommonJS = (mod) => {
34
- var ns = __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
- if (typeof ns.default !== "undefined") {
36
- var keys = Object.keys(ns);
37
- if (keys.length === 1 || (keys.length === 2 && keys.includes("__esModule"))) return ns.default;
38
- }
39
- return ns;
40
- };
41
29
 
42
30
  // ../../../packages/infra/esbuild-plugin-gjsify/dist/shims/console-gjs.js
43
31
  function _formatArgs(...args) {
@@ -83,10 +71,10 @@ var init_console_gjs = __esm({
83
71
  _groupIndentation;
84
72
  _timers = /* @__PURE__ */ new Map();
85
73
  _counters = /* @__PURE__ */ new Map();
86
- constructor(stdoutOrOptions, stderr2) {
74
+ constructor(stdoutOrOptions, stderr) {
87
75
  if (stdoutOrOptions && typeof stdoutOrOptions.write === "function") {
88
76
  this._stdout = stdoutOrOptions;
89
- this._stderr = stderr2 || this._stdout;
77
+ this._stderr = stderr || this._stdout;
90
78
  } else if (stdoutOrOptions && typeof stdoutOrOptions === "object") {
91
79
  const opts = stdoutOrOptions;
92
80
  this._stdout = opts.stdout;
@@ -265,22 +253,10 @@ var init_console_gjs = __esm({
265
253
  });
266
254
 
267
255
  // ../../../packages/gjs/utils/lib/esm/callable.js
268
- function makeCallable(Cls) {
269
- return new Proxy(Cls, {
270
- apply(target, thisArg, args) {
271
- const tmp = Reflect.construct(target, args, target);
272
- for (const key of Reflect.ownKeys(tmp)) {
273
- const desc = Object.getOwnPropertyDescriptor(tmp, key);
274
- if (desc) Object.defineProperty(thisArg, key, desc);
275
- }
276
- return thisArg;
277
- }
278
- });
279
- }
280
256
  var init_callable = __esm({
281
257
  "../../../packages/gjs/utils/lib/esm/callable.js"() {
282
258
  init_console_gjs();
283
- init_auto_globals_495e9d950c();
259
+ init_auto_globals_97a682e619();
284
260
  }
285
261
  });
286
262
 
@@ -322,7 +298,7 @@ var B64_CHARS, B64_LOOKUP;
322
298
  var init_base64 = __esm({
323
299
  "../../../packages/gjs/utils/lib/esm/base64.js"() {
324
300
  init_console_gjs();
325
- init_auto_globals_495e9d950c();
301
+ init_auto_globals_97a682e619();
326
302
  B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
327
303
  B64_LOOKUP = new Uint8Array(256);
328
304
  for (let i = 0; i < B64_CHARS.length; i++) B64_LOOKUP[B64_CHARS.charCodeAt(i)] = i;
@@ -333,7 +309,7 @@ var init_base64 = __esm({
333
309
  var init_byte_array = __esm({
334
310
  "../../../packages/gjs/utils/lib/esm/byte-array.js"() {
335
311
  init_console_gjs();
336
- init_auto_globals_495e9d950c();
312
+ init_auto_globals_97a682e619();
337
313
  }
338
314
  });
339
315
 
@@ -343,7 +319,7 @@ var glib_2_0_default;
343
319
  var init_glib_2_0 = __esm({
344
320
  "../../../node_modules/@girs/glib-2.0/glib-2.0.js"() {
345
321
  init_console_gjs();
346
- init_auto_globals_495e9d950c();
322
+ init_auto_globals_97a682e619();
347
323
  glib_2_0_default = GLib;
348
324
  }
349
325
  });
@@ -353,7 +329,7 @@ var glib_2_default;
353
329
  var init_glib_2 = __esm({
354
330
  "../../../node_modules/@girs/glib-2.0/index.js"() {
355
331
  init_console_gjs();
356
- init_auto_globals_495e9d950c();
332
+ init_auto_globals_97a682e619();
357
333
  init_glib_2_0();
358
334
  glib_2_default = glib_2_0_default;
359
335
  }
@@ -364,7 +340,7 @@ var byteArray;
364
340
  var init_cli = __esm({
365
341
  "../../../packages/gjs/utils/lib/esm/cli.js"() {
366
342
  init_console_gjs();
367
- init_auto_globals_495e9d950c();
343
+ init_auto_globals_97a682e619();
368
344
  init_glib_2();
369
345
  byteArray = imports.byteArray;
370
346
  }
@@ -374,7 +350,7 @@ var init_cli = __esm({
374
350
  var init_defer = __esm({
375
351
  "../../../packages/gjs/utils/lib/esm/defer.js"() {
376
352
  init_console_gjs();
377
- init_auto_globals_495e9d950c();
353
+ init_auto_globals_97a682e619();
378
354
  }
379
355
  });
380
356
 
@@ -413,7 +389,7 @@ var VALID_ENCODINGS;
413
389
  var init_encoding = __esm({
414
390
  "../../../packages/gjs/utils/lib/esm/encoding.js"() {
415
391
  init_console_gjs();
416
- init_auto_globals_495e9d950c();
392
+ init_auto_globals_97a682e619();
417
393
  VALID_ENCODINGS = ["utf8", "ascii", "latin1", "binary", "base64", "base64url", "hex", "ucs2", "utf16le"];
418
394
  }
419
395
  });
@@ -427,34 +403,15 @@ function registerGlobal(name2, value2) {
427
403
  var init_globals = __esm({
428
404
  "../../../packages/gjs/utils/lib/esm/globals.js"() {
429
405
  init_console_gjs();
430
- init_auto_globals_495e9d950c();
406
+ init_auto_globals_97a682e619();
431
407
  }
432
408
  });
433
409
 
434
410
  // ../../../packages/gjs/utils/lib/esm/error.js
435
- var initErrorV8Methods;
436
411
  var init_error = __esm({
437
412
  "../../../packages/gjs/utils/lib/esm/error.js"() {
438
413
  init_console_gjs();
439
- init_auto_globals_495e9d950c();
440
- initErrorV8Methods = (ErrorConstructor) => {
441
- if (!Error.captureStackTrace) {
442
- Error.captureStackTrace = function(targetObject, constructorOpt) {
443
- const container = new Error();
444
- const target = constructorOpt || targetObject;
445
- Object.defineProperty(target, "stack", {
446
- configurable: true,
447
- get: function getStack() {
448
- var stack = container.stack;
449
- Object.defineProperty(this, "stack", {
450
- value: stack
451
- });
452
- return stack;
453
- }
454
- });
455
- };
456
- }
457
- };
414
+ init_auto_globals_97a682e619();
458
415
  }
459
416
  });
460
417
 
@@ -463,7 +420,7 @@ var byteArray2;
463
420
  var init_file = __esm({
464
421
  "../../../packages/gjs/utils/lib/esm/file.js"() {
465
422
  init_console_gjs();
466
- init_auto_globals_495e9d950c();
423
+ init_auto_globals_97a682e619();
467
424
  init_glib_2();
468
425
  byteArray2 = imports.byteArray;
469
426
  }
@@ -475,7 +432,7 @@ var gio_2_0_default;
475
432
  var init_gio_2_0 = __esm({
476
433
  "../../../node_modules/@girs/gio-2.0/gio-2.0.js"() {
477
434
  init_console_gjs();
478
- init_auto_globals_495e9d950c();
435
+ init_auto_globals_97a682e619();
479
436
  gio_2_0_default = Gio;
480
437
  }
481
438
  });
@@ -485,7 +442,7 @@ var gio_2_default;
485
442
  var init_gio_2 = __esm({
486
443
  "../../../node_modules/@girs/gio-2.0/index.js"() {
487
444
  init_console_gjs();
488
- init_auto_globals_495e9d950c();
445
+ init_auto_globals_97a682e619();
489
446
  init_gio_2_0();
490
447
  gio_2_default = gio_2_0_default;
491
448
  }
@@ -496,7 +453,7 @@ import GioUnix from "gi://GioUnix?version=2.0";
496
453
  var init_giounix_2_0 = __esm({
497
454
  "../../../node_modules/@girs/giounix-2.0/giounix-2.0.js"() {
498
455
  init_console_gjs();
499
- init_auto_globals_495e9d950c();
456
+ init_auto_globals_97a682e619();
500
457
  }
501
458
  });
502
459
 
@@ -504,7 +461,7 @@ var init_giounix_2_0 = __esm({
504
461
  var init_giounix_2 = __esm({
505
462
  "../../../node_modules/@girs/giounix-2.0/index.js"() {
506
463
  init_console_gjs();
507
- init_auto_globals_495e9d950c();
464
+ init_auto_globals_97a682e619();
508
465
  init_giounix_2_0();
509
466
  }
510
467
  });
@@ -513,7 +470,7 @@ var init_giounix_2 = __esm({
513
470
  var init_fs = __esm({
514
471
  "../../../packages/gjs/utils/lib/esm/fs.js"() {
515
472
  init_console_gjs();
516
- init_auto_globals_495e9d950c();
473
+ init_auto_globals_97a682e619();
517
474
  init_gio_2();
518
475
  init_giounix_2();
519
476
  }
@@ -524,7 +481,7 @@ var byteArray3;
524
481
  var init_gio = __esm({
525
482
  "../../../packages/gjs/utils/lib/esm/gio.js"() {
526
483
  init_console_gjs();
527
- init_auto_globals_495e9d950c();
484
+ init_auto_globals_97a682e619();
528
485
  init_glib_2();
529
486
  byteArray3 = imports.byteArray;
530
487
  }
@@ -534,7 +491,7 @@ var init_gio = __esm({
534
491
  var init_gio_errors = __esm({
535
492
  "../../../packages/gjs/utils/lib/esm/gio-errors.js"() {
536
493
  init_console_gjs();
537
- init_auto_globals_495e9d950c();
494
+ init_auto_globals_97a682e619();
538
495
  }
539
496
  });
540
497
 
@@ -543,7 +500,7 @@ var warnNotImplemented;
543
500
  var init_message = __esm({
544
501
  "../../../packages/gjs/utils/lib/esm/message.js"() {
545
502
  init_console_gjs();
546
- init_auto_globals_495e9d950c();
503
+ init_auto_globals_97a682e619();
547
504
  warnNotImplemented = (msg) => {
548
505
  const message = msg ? `Not implemented: ${msg}` : "Not implemented";
549
506
  console.warn(message);
@@ -552,15 +509,19 @@ var init_message = __esm({
552
509
  }
553
510
  });
554
511
 
512
+ // ../../../packages/gjs/utils/lib/esm/microtask.js
513
+ var init_microtask = __esm({
514
+ "../../../packages/gjs/utils/lib/esm/microtask.js"() {
515
+ init_console_gjs();
516
+ init_auto_globals_97a682e619();
517
+ }
518
+ });
519
+
555
520
  // ../../../packages/gjs/utils/lib/esm/next-tick.js
556
- var nextTick;
557
521
  var init_next_tick = __esm({
558
522
  "../../../packages/gjs/utils/lib/esm/next-tick.js"() {
559
523
  init_console_gjs();
560
- init_auto_globals_495e9d950c();
561
- nextTick = typeof globalThis.process?.nextTick === "function" ? globalThis.process.nextTick : typeof globalThis.queueMicrotask === "function" ? (fn, ...args) => queueMicrotask(() => fn(...args)) : (fn, ...args) => {
562
- Promise.resolve().then(() => fn(...args));
563
- };
524
+ init_auto_globals_97a682e619();
564
525
  }
565
526
  });
566
527
 
@@ -569,7 +530,7 @@ var File;
569
530
  var init_path = __esm({
570
531
  "../../../packages/gjs/utils/lib/esm/path.js"() {
571
532
  init_console_gjs();
572
- init_auto_globals_495e9d950c();
533
+ init_auto_globals_97a682e619();
573
534
  init_gio_2();
574
535
  init_glib_2();
575
536
  ({ File } = gio_2_default);
@@ -581,7 +542,7 @@ var toString;
581
542
  var init_structured_clone = __esm({
582
543
  "../../../packages/gjs/utils/lib/esm/structured-clone.js"() {
583
544
  init_console_gjs();
584
- init_auto_globals_495e9d950c();
545
+ init_auto_globals_97a682e619();
585
546
  ({ toString } = Object.prototype);
586
547
  }
587
548
  });
@@ -590,7 +551,7 @@ var init_structured_clone = __esm({
590
551
  var init_main_loop = __esm({
591
552
  "../../../packages/gjs/utils/lib/esm/main-loop.js"() {
592
553
  init_console_gjs();
593
- init_auto_globals_495e9d950c();
554
+ init_auto_globals_97a682e619();
594
555
  }
595
556
  });
596
557
 
@@ -598,7 +559,7 @@ var init_main_loop = __esm({
598
559
  var init_esm = __esm({
599
560
  "../../../packages/gjs/utils/lib/esm/index.js"() {
600
561
  init_console_gjs();
601
- init_auto_globals_495e9d950c();
562
+ init_auto_globals_97a682e619();
602
563
  init_callable();
603
564
  init_base64();
604
565
  init_byte_array();
@@ -612,6 +573,7 @@ var init_esm = __esm({
612
573
  init_gio();
613
574
  init_gio_errors();
614
575
  init_message();
576
+ init_microtask();
615
577
  init_next_tick();
616
578
  init_path();
617
579
  init_structured_clone();
@@ -624,7 +586,7 @@ var _encoder, BlobPolyfill, FilePolyfill, Blob2, File2;
624
586
  var init_blob = __esm({
625
587
  "../../../packages/node/buffer/lib/esm/blob.js"() {
626
588
  init_console_gjs();
627
- init_auto_globals_495e9d950c();
589
+ init_auto_globals_97a682e619();
628
590
  _encoder = new TextEncoder();
629
591
  BlobPolyfill = class _BlobPolyfill {
630
592
  _parts;
@@ -694,7 +656,7 @@ var init_blob = __esm({
694
656
  var init_register = __esm({
695
657
  "../../../packages/node/buffer/lib/esm/register.js"() {
696
658
  init_console_gjs();
697
- init_auto_globals_495e9d950c();
659
+ init_auto_globals_97a682e619();
698
660
  init_esm();
699
661
  init_blob();
700
662
  registerGlobal("Blob", Blob2);
@@ -796,7 +758,7 @@ var NAMED_COLORS, BLACK;
796
758
  var init_color = __esm({
797
759
  "../../../packages/dom/canvas2d-core/lib/esm/color.js"() {
798
760
  init_console_gjs();
799
- init_auto_globals_495e9d950c();
761
+ init_auto_globals_97a682e619();
800
762
  NAMED_COLORS = {
801
763
  aliceblue: "#f0f8ff",
802
764
  antiquewhite: "#faebd7",
@@ -1055,7 +1017,7 @@ var COMPOSITE_OP_MAP, LINE_CAP_MAP, LINE_JOIN_MAP;
1055
1017
  var init_cairo_utils = __esm({
1056
1018
  "../../../packages/dom/canvas2d-core/lib/esm/cairo-utils.js"() {
1057
1019
  init_console_gjs();
1058
- init_auto_globals_495e9d950c();
1020
+ init_auto_globals_97a682e619();
1059
1021
  COMPOSITE_OP_MAP = {
1060
1022
  "source-over": 2,
1061
1023
  // OVER
@@ -1161,7 +1123,7 @@ function cloneState(state) {
1161
1123
  var init_canvas_state = __esm({
1162
1124
  "../../../packages/dom/canvas2d-core/lib/esm/canvas-state.js"() {
1163
1125
  init_console_gjs();
1164
- init_auto_globals_495e9d950c();
1126
+ init_auto_globals_97a682e619();
1165
1127
  init_color();
1166
1128
  }
1167
1129
  });
@@ -1171,7 +1133,7 @@ var OurImageData;
1171
1133
  var init_image_data = __esm({
1172
1134
  "../../../packages/dom/canvas2d-core/lib/esm/image-data.js"() {
1173
1135
  init_console_gjs();
1174
- init_auto_globals_495e9d950c();
1136
+ init_auto_globals_97a682e619();
1175
1137
  OurImageData = class {
1176
1138
  constructor(swOrData, sh, maybeHeight) {
1177
1139
  this.colorSpace = "srgb";
@@ -1200,7 +1162,7 @@ var CanvasGradient;
1200
1162
  var init_canvas_gradient = __esm({
1201
1163
  "../../../packages/dom/canvas2d-core/lib/esm/canvas-gradient.js"() {
1202
1164
  init_console_gjs();
1203
- init_auto_globals_495e9d950c();
1165
+ init_auto_globals_97a682e619();
1204
1166
  init_color();
1205
1167
  CanvasGradient = class {
1206
1168
  constructor(type, x0, y0, x1, y1, r0, r1) {
@@ -1230,7 +1192,7 @@ var CanvasPattern;
1230
1192
  var init_canvas_pattern = __esm({
1231
1193
  "../../../packages/dom/canvas2d-core/lib/esm/canvas-pattern.js"() {
1232
1194
  init_console_gjs();
1233
- init_auto_globals_495e9d950c();
1195
+ init_auto_globals_97a682e619();
1234
1196
  CanvasPattern = class _CanvasPattern {
1235
1197
  constructor(surface, repetition) {
1236
1198
  this._pattern = new Cairo2.SurfacePattern(surface);
@@ -1292,7 +1254,7 @@ var Path2D;
1292
1254
  var init_canvas_path = __esm({
1293
1255
  "../../../packages/dom/canvas2d-core/lib/esm/canvas-path.js"() {
1294
1256
  init_console_gjs();
1295
- init_auto_globals_495e9d950c();
1257
+ init_auto_globals_97a682e619();
1296
1258
  init_cairo_utils();
1297
1259
  Path2D = class _Path2D {
1298
1260
  constructor(pathOrSvg) {
@@ -1406,7 +1368,7 @@ var CanvasRenderingContext2D;
1406
1368
  var init_canvas_rendering_context_2d = __esm({
1407
1369
  "../../../packages/dom/canvas2d-core/lib/esm/canvas-rendering-context-2d.js"() {
1408
1370
  init_console_gjs();
1409
- init_auto_globals_495e9d950c();
1371
+ init_auto_globals_97a682e619();
1410
1372
  init_color();
1411
1373
  init_cairo_utils();
1412
1374
  init_canvas_state();
@@ -2393,7 +2355,7 @@ var init_canvas_rendering_context_2d = __esm({
2393
2355
  var init_esm2 = __esm({
2394
2356
  "../../../packages/dom/canvas2d-core/lib/esm/index.js"() {
2395
2357
  init_console_gjs();
2396
- init_auto_globals_495e9d950c();
2358
+ init_auto_globals_97a682e619();
2397
2359
  init_canvas_rendering_context_2d();
2398
2360
  init_canvas_gradient();
2399
2361
  init_canvas_pattern();
@@ -2408,7 +2370,7 @@ var DOMExceptionCodes, _DOMExceptionPolyfill, DOMException2;
2408
2370
  var init_esm3 = __esm({
2409
2371
  "../../../packages/web/dom-exception/lib/esm/index.js"() {
2410
2372
  init_console_gjs();
2411
- init_auto_globals_495e9d950c();
2373
+ init_auto_globals_97a682e619();
2412
2374
  DOMExceptionCodes = {
2413
2375
  IndexSizeError: 1,
2414
2376
  HierarchyRequestError: 3,
@@ -2450,7 +2412,7 @@ var kType, kBubbles, kCancelable, kComposed, kTarget, kCurrentTarget, kEventPhas
2450
2412
  var init_esm4 = __esm({
2451
2413
  "../../../packages/web/dom-events/lib/esm/index.js"() {
2452
2414
  init_console_gjs();
2453
- init_auto_globals_495e9d950c();
2415
+ init_auto_globals_97a682e619();
2454
2416
  init_esm3();
2455
2417
  kType = /* @__PURE__ */ Symbol("type");
2456
2418
  kBubbles = /* @__PURE__ */ Symbol("bubbles");
@@ -2642,7 +2604,7 @@ var init_esm4 = __esm({
2642
2604
  addEventListener(type, callback, options) {
2643
2605
  if (callback === null) return;
2644
2606
  const capture = typeof options === "boolean" ? options : options?.capture ?? false;
2645
- const once2 = typeof options === "object" ? options?.once ?? false : false;
2607
+ const once = typeof options === "object" ? options?.once ?? false : false;
2646
2608
  const passive = typeof options === "object" ? options?.passive ?? false : false;
2647
2609
  let list = this._listeners.get(type);
2648
2610
  if (!list) {
@@ -2652,7 +2614,7 @@ var init_esm4 = __esm({
2652
2614
  for (const entry2 of list) {
2653
2615
  if (entry2.listener === callback && entry2.capture === capture) return;
2654
2616
  }
2655
- const entry = { listener: callback, capture, once: once2, passive, removed: false };
2617
+ const entry = { listener: callback, capture, once, passive, removed: false };
2656
2618
  list.push(entry);
2657
2619
  if (typeof options === "object" && options?.signal) {
2658
2620
  options.signal.addEventListener("abort", () => {
@@ -2914,7 +2876,7 @@ var NodeType;
2914
2876
  var init_node_type = __esm({
2915
2877
  "../../../packages/dom/dom-elements/lib/esm/node-type.js"() {
2916
2878
  init_console_gjs();
2917
- init_auto_globals_495e9d950c();
2879
+ init_auto_globals_97a682e619();
2918
2880
  NodeType = {
2919
2881
  ELEMENT_NODE: 1,
2920
2882
  ATTRIBUTE_NODE: 2,
@@ -2934,7 +2896,7 @@ var NodeList;
2934
2896
  var init_node_list = __esm({
2935
2897
  "../../../packages/dom/dom-elements/lib/esm/node-list.js"() {
2936
2898
  init_console_gjs();
2937
- init_auto_globals_495e9d950c();
2899
+ init_auto_globals_97a682e619();
2938
2900
  NodeList = class {
2939
2901
  constructor(items) {
2940
2902
  this._items = items;
@@ -2974,7 +2936,7 @@ var nodeType, parentNode, childNodesList, elementChildren, isConnected, tagName,
2974
2936
  var init_property_symbol = __esm({
2975
2937
  "../../../packages/dom/dom-elements/lib/esm/property-symbol.js"() {
2976
2938
  init_console_gjs();
2977
- init_auto_globals_495e9d950c();
2939
+ init_auto_globals_97a682e619();
2978
2940
  nodeType = /* @__PURE__ */ Symbol("nodeType");
2979
2941
  parentNode = /* @__PURE__ */ Symbol("parentNode");
2980
2942
  childNodesList = /* @__PURE__ */ Symbol("childNodesList");
@@ -2997,7 +2959,7 @@ var _a, _b, _c, _d, _e, Node;
2997
2959
  var init_node = __esm({
2998
2960
  "../../../packages/dom/dom-elements/lib/esm/node.js"() {
2999
2961
  init_console_gjs();
3000
- init_auto_globals_495e9d950c();
2962
+ init_auto_globals_97a682e619();
3001
2963
  init_esm4();
3002
2964
  init_node_type();
3003
2965
  init_node_list();
@@ -3247,7 +3209,7 @@ var Attr;
3247
3209
  var init_attr = __esm({
3248
3210
  "../../../packages/dom/dom-elements/lib/esm/attr.js"() {
3249
3211
  init_console_gjs();
3250
- init_auto_globals_495e9d950c();
3212
+ init_auto_globals_97a682e619();
3251
3213
  init_property_symbol();
3252
3214
  Attr = class {
3253
3215
  constructor(name2, value2, namespaceURI2 = null, prefix2 = null, ownerElement2 = null) {
@@ -3284,7 +3246,7 @@ var NamespaceURI;
3284
3246
  var init_namespace_uri = __esm({
3285
3247
  "../../../packages/dom/dom-elements/lib/esm/namespace-uri.js"() {
3286
3248
  init_console_gjs();
3287
- init_auto_globals_495e9d950c();
3249
+ init_auto_globals_97a682e619();
3288
3250
  NamespaceURI = {
3289
3251
  html: "http://www.w3.org/1999/xhtml",
3290
3252
  svg: "http://www.w3.org/2000/svg",
@@ -3300,7 +3262,7 @@ var NamedNodeMap;
3300
3262
  var init_named_node_map = __esm({
3301
3263
  "../../../packages/dom/dom-elements/lib/esm/named-node-map.js"() {
3302
3264
  init_console_gjs();
3303
- init_auto_globals_495e9d950c();
3265
+ init_auto_globals_97a682e619();
3304
3266
  init_attr();
3305
3267
  init_namespace_uri();
3306
3268
  NamedNodeMap = class {
@@ -3430,7 +3392,7 @@ var _a2, _b2, _c2, _d2, _e2, _f, Element;
3430
3392
  var init_element = __esm({
3431
3393
  "../../../packages/dom/dom-elements/lib/esm/element.js"() {
3432
3394
  init_console_gjs();
3433
- init_auto_globals_495e9d950c();
3395
+ init_auto_globals_97a682e619();
3434
3396
  init_node();
3435
3397
  init_node_type();
3436
3398
  init_named_node_map();
@@ -3682,7 +3644,7 @@ var CSSStyleDeclaration, HTMLElement;
3682
3644
  var init_html_element = __esm({
3683
3645
  "../../../packages/dom/dom-elements/lib/esm/html-element.js"() {
3684
3646
  init_console_gjs();
3685
- init_auto_globals_495e9d950c();
3647
+ init_auto_globals_97a682e619();
3686
3648
  init_esm4();
3687
3649
  init_element();
3688
3650
  init_property_symbol();
@@ -4112,7 +4074,7 @@ var HTMLCanvasElement2;
4112
4074
  var init_html_canvas_element = __esm({
4113
4075
  "../../../packages/dom/dom-elements/lib/esm/html-canvas-element.js"() {
4114
4076
  init_console_gjs();
4115
- init_auto_globals_495e9d950c();
4077
+ init_auto_globals_97a682e619();
4116
4078
  init_html_element();
4117
4079
  HTMLCanvasElement2 = class _HTMLCanvasElement extends HTMLElement {
4118
4080
  constructor() {
@@ -4192,7 +4154,7 @@ var DOMMatrix, DOMMatrixReadOnly;
4192
4154
  var init_dom_matrix = __esm({
4193
4155
  "../../../packages/dom/dom-elements/lib/esm/dom-matrix.js"() {
4194
4156
  init_console_gjs();
4195
- init_auto_globals_495e9d950c();
4157
+ init_auto_globals_97a682e619();
4196
4158
  DOMMatrix = class _DOMMatrix {
4197
4159
  constructor(init) {
4198
4160
  this.a = 1;
@@ -4330,7 +4292,7 @@ function defineGlobalIfMissing(name2, value2) {
4330
4292
  var init_helpers = __esm({
4331
4293
  "../../../packages/dom/dom-elements/lib/esm/register/helpers.js"() {
4332
4294
  init_console_gjs();
4333
- init_auto_globals_495e9d950c();
4295
+ init_auto_globals_97a682e619();
4334
4296
  }
4335
4297
  });
4336
4298
 
@@ -4339,7 +4301,7 @@ var CANVAS2D_KEY;
4339
4301
  var init_canvas = __esm({
4340
4302
  "../../../packages/dom/dom-elements/lib/esm/register/canvas.js"() {
4341
4303
  init_console_gjs();
4342
- init_auto_globals_495e9d950c();
4304
+ init_auto_globals_97a682e619();
4343
4305
  init_esm2();
4344
4306
  init_html_canvas_element();
4345
4307
  init_dom_matrix();
@@ -4364,7 +4326,7 @@ var CharacterData;
4364
4326
  var init_character_data = __esm({
4365
4327
  "../../../packages/dom/dom-elements/lib/esm/character-data.js"() {
4366
4328
  init_console_gjs();
4367
- init_auto_globals_495e9d950c();
4329
+ init_auto_globals_97a682e619();
4368
4330
  init_node();
4369
4331
  init_node_type();
4370
4332
  init_property_symbol();
@@ -4426,7 +4388,7 @@ var Comment;
4426
4388
  var init_comment = __esm({
4427
4389
  "../../../packages/dom/dom-elements/lib/esm/comment.js"() {
4428
4390
  init_console_gjs();
4429
- init_auto_globals_495e9d950c();
4391
+ init_auto_globals_97a682e619();
4430
4392
  init_character_data();
4431
4393
  init_node_type();
4432
4394
  init_property_symbol();
@@ -4454,7 +4416,7 @@ var gdkpixbuf_2_0_default;
4454
4416
  var init_gdkpixbuf_2_0 = __esm({
4455
4417
  "../../../node_modules/@girs/gdkpixbuf-2.0/gdkpixbuf-2.0.js"() {
4456
4418
  init_console_gjs();
4457
- init_auto_globals_495e9d950c();
4419
+ init_auto_globals_97a682e619();
4458
4420
  gdkpixbuf_2_0_default = GdkPixbuf2;
4459
4421
  }
4460
4422
  });
@@ -4464,7 +4426,7 @@ var gdkpixbuf_2_default;
4464
4426
  var init_gdkpixbuf_2 = __esm({
4465
4427
  "../../../node_modules/@girs/gdkpixbuf-2.0/index.js"() {
4466
4428
  init_console_gjs();
4467
- init_auto_globals_495e9d950c();
4429
+ init_auto_globals_97a682e619();
4468
4430
  init_gdkpixbuf_2_0();
4469
4431
  gdkpixbuf_2_default = gdkpixbuf_2_0_default;
4470
4432
  }
@@ -4476,7 +4438,7 @@ var HTMLImageElement2;
4476
4438
  var init_html_image_element = __esm({
4477
4439
  "../../../packages/dom/dom-elements/lib/esm/html-image-element.js"() {
4478
4440
  init_console_gjs();
4479
- init_auto_globals_495e9d950c();
4441
+ init_auto_globals_97a682e619();
4480
4442
  init_glib_2();
4481
4443
  init_gio_2();
4482
4444
  init_gdkpixbuf_2();
@@ -4706,12 +4668,269 @@ var init_html_image_element = __esm({
4706
4668
  }
4707
4669
  });
4708
4670
 
4671
+ // ../../../packages/dom/dom-elements/lib/esm/html-media-element.js
4672
+ var HAVE_NOTHING, HAVE_METADATA, HAVE_CURRENT_DATA, HAVE_FUTURE_DATA, HAVE_ENOUGH_DATA, NETWORK_EMPTY, NETWORK_IDLE, NETWORK_LOADING, NETWORK_NO_SOURCE, HTMLMediaElement;
4673
+ var init_html_media_element = __esm({
4674
+ "../../../packages/dom/dom-elements/lib/esm/html-media-element.js"() {
4675
+ init_console_gjs();
4676
+ init_auto_globals_97a682e619();
4677
+ init_esm4();
4678
+ init_html_element();
4679
+ HAVE_NOTHING = 0;
4680
+ HAVE_METADATA = 1;
4681
+ HAVE_CURRENT_DATA = 2;
4682
+ HAVE_FUTURE_DATA = 3;
4683
+ HAVE_ENOUGH_DATA = 4;
4684
+ NETWORK_EMPTY = 0;
4685
+ NETWORK_IDLE = 1;
4686
+ NETWORK_LOADING = 2;
4687
+ NETWORK_NO_SOURCE = 3;
4688
+ HTMLMediaElement = class extends HTMLElement {
4689
+ constructor() {
4690
+ super(...arguments);
4691
+ this._src = "";
4692
+ this._srcObject = null;
4693
+ this.currentTime = 0;
4694
+ this.duration = NaN;
4695
+ this.paused = true;
4696
+ this.ended = false;
4697
+ this.volume = 1;
4698
+ this.muted = false;
4699
+ this.defaultMuted = false;
4700
+ this.loop = false;
4701
+ this.autoplay = false;
4702
+ this.preload = "";
4703
+ this.playbackRate = 1;
4704
+ this.defaultPlaybackRate = 1;
4705
+ this.readyState = HAVE_NOTHING;
4706
+ this.networkState = NETWORK_EMPTY;
4707
+ }
4708
+ // -- Buffered/seekable stubs --
4709
+ get buffered() {
4710
+ return { length: 0, start: () => 0, end: () => 0 };
4711
+ }
4712
+ get seekable() {
4713
+ return { length: 0, start: () => 0, end: () => 0 };
4714
+ }
4715
+ get played() {
4716
+ return { length: 0, start: () => 0, end: () => 0 };
4717
+ }
4718
+ // -- src property --
4719
+ get src() {
4720
+ return this._src;
4721
+ }
4722
+ set src(value2) {
4723
+ this._src = value2;
4724
+ this._srcObject = null;
4725
+ this.dispatchEvent(new Event("srcchange"));
4726
+ }
4727
+ // -- srcObject property (MediaStream) --
4728
+ get srcObject() {
4729
+ return this._srcObject;
4730
+ }
4731
+ set srcObject(stream) {
4732
+ this._srcObject = stream;
4733
+ this._src = "";
4734
+ this.dispatchEvent(new Event("srcobjectchange"));
4735
+ }
4736
+ // -- Playback control --
4737
+ play() {
4738
+ this.paused = false;
4739
+ this.ended = false;
4740
+ this.dispatchEvent(new Event("play"));
4741
+ return Promise.resolve();
4742
+ }
4743
+ pause() {
4744
+ this.paused = true;
4745
+ this.dispatchEvent(new Event("pause"));
4746
+ }
4747
+ load() {
4748
+ this.readyState = HAVE_NOTHING;
4749
+ this.networkState = NETWORK_LOADING;
4750
+ this.dispatchEvent(new Event("loadstart"));
4751
+ }
4752
+ canPlayType(_type) {
4753
+ return "";
4754
+ }
4755
+ static {
4756
+ this.HAVE_NOTHING = HAVE_NOTHING;
4757
+ }
4758
+ static {
4759
+ this.HAVE_METADATA = HAVE_METADATA;
4760
+ }
4761
+ static {
4762
+ this.HAVE_CURRENT_DATA = HAVE_CURRENT_DATA;
4763
+ }
4764
+ static {
4765
+ this.HAVE_FUTURE_DATA = HAVE_FUTURE_DATA;
4766
+ }
4767
+ static {
4768
+ this.HAVE_ENOUGH_DATA = HAVE_ENOUGH_DATA;
4769
+ }
4770
+ static {
4771
+ this.NETWORK_EMPTY = NETWORK_EMPTY;
4772
+ }
4773
+ static {
4774
+ this.NETWORK_IDLE = NETWORK_IDLE;
4775
+ }
4776
+ static {
4777
+ this.NETWORK_LOADING = NETWORK_LOADING;
4778
+ }
4779
+ static {
4780
+ this.NETWORK_NO_SOURCE = NETWORK_NO_SOURCE;
4781
+ }
4782
+ get [Symbol.toStringTag]() {
4783
+ return "HTMLMediaElement";
4784
+ }
4785
+ };
4786
+ }
4787
+ });
4788
+
4789
+ // ../../../packages/dom/dom-elements/lib/esm/gst-time.js
4790
+ function secondsToGstTime(seconds) {
4791
+ return BigInt(Math.round(seconds * NS_PER_SECOND));
4792
+ }
4793
+ function gstTimeToSeconds(nanoseconds) {
4794
+ return Number(nanoseconds) / NS_PER_SECOND;
4795
+ }
4796
+ var NS_PER_SECOND;
4797
+ var init_gst_time = __esm({
4798
+ "../../../packages/dom/dom-elements/lib/esm/gst-time.js"() {
4799
+ init_console_gjs();
4800
+ init_auto_globals_97a682e619();
4801
+ NS_PER_SECOND = 1e9;
4802
+ }
4803
+ });
4804
+
4805
+ // ../../../packages/dom/dom-elements/lib/esm/html-video-element.js
4806
+ var GST_STATE_PLAYING, GST_STATE_PAUSED, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_FLAG_KEY_UNIT, GST_SEEK_TYPE_SET, GST_SEEK_TYPE_NONE, HTMLVideoElement2;
4807
+ var init_html_video_element = __esm({
4808
+ "../../../packages/dom/dom-elements/lib/esm/html-video-element.js"() {
4809
+ init_console_gjs();
4810
+ init_auto_globals_97a682e619();
4811
+ init_html_media_element();
4812
+ init_esm4();
4813
+ init_property_symbol();
4814
+ init_namespace_uri();
4815
+ init_gst_time();
4816
+ GST_STATE_PLAYING = 4;
4817
+ GST_STATE_PAUSED = 3;
4818
+ GST_FORMAT_TIME = 3;
4819
+ GST_SEEK_FLAG_FLUSH = 1;
4820
+ GST_SEEK_FLAG_KEY_UNIT = 4;
4821
+ GST_SEEK_TYPE_SET = 1;
4822
+ GST_SEEK_TYPE_NONE = 0;
4823
+ HTMLVideoElement2 = class extends HTMLMediaElement {
4824
+ constructor() {
4825
+ super();
4826
+ this._pipeline = null;
4827
+ this._videoWidth = 0;
4828
+ this._videoHeight = 0;
4829
+ this.poster = "";
4830
+ this[tagName] = "VIDEO";
4831
+ this[localName] = "video";
4832
+ this[namespaceURI] = NamespaceURI.html;
4833
+ const self2 = this;
4834
+ Object.defineProperty(this, "paused", {
4835
+ get() {
4836
+ if (!self2._pipeline) return true;
4837
+ const [, state] = self2._pipeline.get_state(0n);
4838
+ return state !== GST_STATE_PLAYING;
4839
+ },
4840
+ configurable: true,
4841
+ enumerable: true
4842
+ });
4843
+ Object.defineProperty(this, "currentTime", {
4844
+ get() {
4845
+ if (!self2._pipeline) return 0;
4846
+ const [ok, pos] = self2._pipeline.query_position(GST_FORMAT_TIME);
4847
+ return ok ? gstTimeToSeconds(pos) : 0;
4848
+ },
4849
+ set(seconds) {
4850
+ self2._pipeline?.seek(
4851
+ 1,
4852
+ GST_FORMAT_TIME,
4853
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
4854
+ GST_SEEK_TYPE_SET,
4855
+ secondsToGstTime(seconds),
4856
+ GST_SEEK_TYPE_NONE,
4857
+ -1n
4858
+ );
4859
+ },
4860
+ configurable: true,
4861
+ enumerable: true
4862
+ });
4863
+ Object.defineProperty(this, "duration", {
4864
+ get() {
4865
+ if (!self2._pipeline) return NaN;
4866
+ const [ok, dur] = self2._pipeline.query_duration(GST_FORMAT_TIME);
4867
+ return ok && Number(dur) > 0 ? gstTimeToSeconds(dur) : NaN;
4868
+ },
4869
+ configurable: true,
4870
+ enumerable: true
4871
+ });
4872
+ Object.defineProperty(this, "volume", {
4873
+ get() {
4874
+ return self2._playbin()?.volume ?? 1;
4875
+ },
4876
+ set(v) {
4877
+ const pb = self2._playbin();
4878
+ if (pb) pb.volume = Math.max(0, Math.min(1, v));
4879
+ },
4880
+ configurable: true,
4881
+ enumerable: true
4882
+ });
4883
+ Object.defineProperty(this, "muted", {
4884
+ get() {
4885
+ return self2._playbin()?.mute ?? false;
4886
+ },
4887
+ set(v) {
4888
+ const pb = self2._playbin();
4889
+ if (pb) pb.mute = v;
4890
+ },
4891
+ configurable: true,
4892
+ enumerable: true
4893
+ });
4894
+ }
4895
+ async play() {
4896
+ this._pipeline?.set_state(GST_STATE_PLAYING);
4897
+ this.dispatchEvent(new Event("play"));
4898
+ this.dispatchEvent(new Event("playing"));
4899
+ }
4900
+ pause() {
4901
+ this._pipeline?.set_state(GST_STATE_PAUSED);
4902
+ this.dispatchEvent(new Event("pause"));
4903
+ }
4904
+ /** Intrinsic width of the video (set by bridge when media metadata loads). */
4905
+ get videoWidth() {
4906
+ return this._videoWidth;
4907
+ }
4908
+ set videoWidth(value2) {
4909
+ this._videoWidth = value2;
4910
+ }
4911
+ /** Intrinsic height of the video (set by bridge when media metadata loads). */
4912
+ get videoHeight() {
4913
+ return this._videoHeight;
4914
+ }
4915
+ set videoHeight(value2) {
4916
+ this._videoHeight = value2;
4917
+ }
4918
+ get [Symbol.toStringTag]() {
4919
+ return "HTMLVideoElement";
4920
+ }
4921
+ _playbin() {
4922
+ return this._pipeline?.get_by_name("playbin") ?? null;
4923
+ }
4924
+ };
4925
+ }
4926
+ });
4927
+
4709
4928
  // ../../../packages/dom/dom-elements/lib/esm/text.js
4710
4929
  var Text;
4711
4930
  var init_text = __esm({
4712
4931
  "../../../packages/dom/dom-elements/lib/esm/text.js"() {
4713
4932
  init_console_gjs();
4714
- init_auto_globals_495e9d950c();
4933
+ init_auto_globals_97a682e619();
4715
4934
  init_character_data();
4716
4935
  init_node_type();
4717
4936
  init_property_symbol();
@@ -4768,7 +4987,7 @@ var DocumentFragment;
4768
4987
  var init_document_fragment = __esm({
4769
4988
  "../../../packages/dom/dom-elements/lib/esm/document-fragment.js"() {
4770
4989
  init_console_gjs();
4771
- init_auto_globals_495e9d950c();
4990
+ init_auto_globals_97a682e619();
4772
4991
  init_node();
4773
4992
  init_text();
4774
4993
  init_node_type();
@@ -4886,10 +5105,11 @@ var Document, document2;
4886
5105
  var init_document = __esm({
4887
5106
  "../../../packages/dom/dom-elements/lib/esm/document.js"() {
4888
5107
  init_console_gjs();
4889
- init_auto_globals_495e9d950c();
5108
+ init_auto_globals_97a682e619();
4890
5109
  init_node();
4891
5110
  init_html_element();
4892
5111
  init_html_image_element();
5112
+ init_html_video_element();
4893
5113
  init_html_canvas_element();
4894
5114
  init_text();
4895
5115
  init_comment();
@@ -4921,6 +5141,8 @@ var init_document = __esm({
4921
5141
  switch (tag) {
4922
5142
  case "img":
4923
5143
  return new HTMLImageElement2();
5144
+ case "video":
5145
+ return new HTMLVideoElement2();
4924
5146
  case "canvas":
4925
5147
  return new HTMLCanvasElement2();
4926
5148
  default: {
@@ -4972,7 +5194,7 @@ var DOMTokenList;
4972
5194
  var init_dom_token_list = __esm({
4973
5195
  "../../../packages/dom/dom-elements/lib/esm/dom-token-list.js"() {
4974
5196
  init_console_gjs();
4975
- init_auto_globals_495e9d950c();
5197
+ init_auto_globals_97a682e619();
4976
5198
  DOMTokenList = class {
4977
5199
  constructor(ownerElement2, attributeName) {
4978
5200
  this._ownerElement = ownerElement2;
@@ -5087,7 +5309,7 @@ var Window;
5087
5309
  var init_document2 = __esm({
5088
5310
  "../../../packages/dom/dom-elements/lib/esm/register/document.js"() {
5089
5311
  init_console_gjs();
5090
- init_auto_globals_495e9d950c();
5312
+ init_auto_globals_97a682e619();
5091
5313
  init_esm4();
5092
5314
  init_comment();
5093
5315
  init_document();
@@ -5136,7 +5358,7 @@ var Image;
5136
5358
  var init_image = __esm({
5137
5359
  "../../../packages/dom/dom-elements/lib/esm/image.js"() {
5138
5360
  init_console_gjs();
5139
- init_auto_globals_495e9d950c();
5361
+ init_auto_globals_97a682e619();
5140
5362
  init_html_image_element();
5141
5363
  Image = class extends HTMLImageElement2 {
5142
5364
  /**
@@ -5162,7 +5384,7 @@ var init_image = __esm({
5162
5384
  var init_image2 = __esm({
5163
5385
  "../../../packages/dom/dom-elements/lib/esm/register/image.js"() {
5164
5386
  init_console_gjs();
5165
- init_auto_globals_495e9d950c();
5387
+ init_auto_globals_97a682e619();
5166
5388
  init_html_image_element();
5167
5389
  init_image();
5168
5390
  init_helpers();
@@ -5175,7 +5397,7 @@ var init_image2 = __esm({
5175
5397
  var init_navigator = __esm({
5176
5398
  "../../../packages/dom/dom-elements/lib/esm/register/navigator.js"() {
5177
5399
  init_console_gjs();
5178
- init_auto_globals_495e9d950c();
5400
+ init_auto_globals_97a682e619();
5179
5401
  if (typeof globalThis.navigator === "undefined") {
5180
5402
  globalThis.navigator = {};
5181
5403
  }
@@ -5290,7 +5512,7 @@ var textEncoder, textDecoder, hasSharedArrayBuffer, Buffer2, kMaxLength, kString
5290
5512
  var init_buffer = __esm({
5291
5513
  "../../../packages/node/buffer/lib/esm/buffer.js"() {
5292
5514
  init_console_gjs();
5293
- init_auto_globals_495e9d950c();
5515
+ init_auto_globals_97a682e619();
5294
5516
  init_esm();
5295
5517
  textEncoder = new TextEncoder();
5296
5518
  textDecoder = new TextDecoder();
@@ -5843,7 +6065,7 @@ var atob2, btoa;
5843
6065
  var init_esm5 = __esm({
5844
6066
  "../../../packages/node/buffer/lib/esm/index.js"() {
5845
6067
  init_console_gjs();
5846
- init_auto_globals_495e9d950c();
6068
+ init_auto_globals_97a682e619();
5847
6069
  init_buffer();
5848
6070
  atob2 = globalThis.atob;
5849
6071
  btoa = globalThis.btoa;
@@ -5854,7 +6076,7 @@ var init_esm5 = __esm({
5854
6076
  var init_buffer2 = __esm({
5855
6077
  "../../../packages/node/globals/lib/esm/register/buffer.js"() {
5856
6078
  init_console_gjs();
5857
- init_auto_globals_495e9d950c();
6079
+ init_auto_globals_97a682e619();
5858
6080
  init_esm5();
5859
6081
  init_register();
5860
6082
  if (!("Buffer" in globalThis)) {
@@ -5872,7 +6094,7 @@ var init_buffer2 = __esm({
5872
6094
  var init_encoding2 = __esm({
5873
6095
  "../../../packages/node/globals/lib/esm/register/encoding.js"() {
5874
6096
  init_console_gjs();
5875
- init_auto_globals_495e9d950c();
6097
+ init_auto_globals_97a682e619();
5876
6098
  init_glib_2();
5877
6099
  if (typeof globalThis.btoa !== "function") {
5878
6100
  Object.defineProperty(globalThis, "btoa", {
@@ -5906,1121 +6128,115 @@ var init_encoding2 = __esm({
5906
6128
  }
5907
6129
  });
5908
6130
 
5909
- // ../../../packages/node/globals/lib/esm/register/microtask.js
5910
- var init_microtask = __esm({
5911
- "../../../packages/node/globals/lib/esm/register/microtask.js"() {
5912
- init_console_gjs();
5913
- init_auto_globals_495e9d950c();
5914
- if (typeof queueMicrotask !== "function") {
5915
- Object.defineProperty(globalThis, "queueMicrotask", {
5916
- value: function queueMicrotask2(callback) {
5917
- Promise.resolve().then(callback).catch((err) => {
5918
- setTimeout(() => {
5919
- throw err;
5920
- }, 0);
5921
- });
5922
- },
5923
- enumerable: true,
5924
- writable: true,
5925
- configurable: true
5926
- });
5927
- }
5928
- }
5929
- });
5930
-
5931
- // ../../../packages/node/events/lib/esm/event-emitter.js
5932
- function onceWrapper() {
5933
- const { target, type, listener } = this;
5934
- if (this.wrapperFn) target.removeListener(type, this.wrapperFn);
5935
- const result = listener.apply(target, arguments);
5936
- return result;
5937
- }
5938
- function _onceWrap(target, type, listener) {
5939
- const state = { target, type, listener, wrapperFn: void 0 };
5940
- const wrapped = onceWrapper.bind(state);
5941
- state.wrapperFn = wrapped;
5942
- wrapped.listener = listener;
5943
- return wrapped;
6131
+ // ../../../packages/node/globals/lib/esm/register/timers.js
6132
+ function getGLib() {
6133
+ return globalThis.imports?.gi?.GLib;
5944
6134
  }
5945
- function arrayClone(arr) {
5946
- switch (arr.length) {
5947
- case 0:
5948
- return [];
5949
- case 1:
5950
- return [arr[0]];
5951
- case 2:
5952
- return [arr[0], arr[1]];
5953
- case 3:
5954
- return [arr[0], arr[1], arr[2]];
5955
- default:
5956
- return arr.slice();
5957
- }
5958
- }
5959
- function checkListener(listener) {
5960
- if (typeof listener !== "function") {
5961
- throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
5962
- }
5963
- }
5964
- function validateNumber(value2, name2) {
5965
- if (typeof value2 !== "number" || value2 !== value2) {
5966
- throw new TypeError(`The "${name2}" argument must be of type number. Received type ${typeof value2}`);
5967
- }
5968
- }
5969
- function spliceOne(list, index) {
5970
- for (; index + 1 < list.length; index++) {
5971
- list[index] = list[index + 1];
6135
+ function removeById(timeout) {
6136
+ if (timeout instanceof GjsifyTimeout) {
6137
+ timeout._cancel();
6138
+ } else if (typeof timeout === "number") {
6139
+ try {
6140
+ getGLib()?.Source.remove(timeout);
6141
+ } catch {
6142
+ }
5972
6143
  }
5973
- list.pop();
5974
6144
  }
5975
- function unwrapListeners(arr) {
5976
- const ret = new Array(arr.length);
5977
- for (let i = 0; i < ret.length; ++i) {
5978
- ret[i] = arr[i].listener ?? arr[i];
5979
- }
5980
- return ret;
6145
+ function setImmediate(callback, ...args) {
6146
+ return setTimeout(callback, 0, ...args);
5981
6147
  }
5982
- function createAbortError(signal) {
5983
- const err = new Error("The operation was aborted");
5984
- err.name = "AbortError";
5985
- err.code = "ABORT_ERR";
5986
- if (signal?.reason) {
5987
- err.cause = signal.reason;
5988
- }
5989
- return err;
6148
+ function clearImmediate(id) {
6149
+ clearTimeout(id);
5990
6150
  }
5991
- var kCapture, kRejection, EventEmitter;
5992
- var init_event_emitter = __esm({
5993
- "../../../packages/node/events/lib/esm/event-emitter.js"() {
6151
+ var _isGjsTimer, GjsifyTimeout;
6152
+ var init_timers = __esm({
6153
+ "../../../packages/node/globals/lib/esm/register/timers.js"() {
5994
6154
  init_console_gjs();
5995
- init_auto_globals_495e9d950c();
5996
- kCapture = /* @__PURE__ */ Symbol("kCapture");
5997
- kRejection = /* @__PURE__ */ Symbol.for("nodejs.rejection");
5998
- EventEmitter = class _EventEmitter {
5999
- static defaultMaxListeners = 10;
6000
- static errorMonitor = /* @__PURE__ */ Symbol("events.errorMonitor");
6001
- static captureRejectionSymbol = kRejection;
6002
- static _captureRejections = false;
6003
- static get captureRejections() {
6004
- return _EventEmitter._captureRejections;
6005
- }
6006
- static set captureRejections(value2) {
6007
- if (typeof value2 !== "boolean") {
6008
- throw new TypeError('The "captureRejections" argument must be of type boolean.');
6009
- }
6010
- _EventEmitter._captureRejections = value2;
6011
- }
6012
- _events;
6013
- _eventsCount;
6014
- _maxListeners;
6015
- [kCapture];
6016
- constructor(opts) {
6017
- this._events = /* @__PURE__ */ Object.create(null);
6018
- this._eventsCount = 0;
6019
- this._maxListeners = void 0;
6020
- this[kCapture] = opts?.captureRejections ?? _EventEmitter._captureRejections;
6021
- }
6022
- setMaxListeners(n) {
6023
- validateNumber(n, "n");
6024
- if (n < 0) {
6025
- throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n);
6026
- }
6027
- this._maxListeners = n;
6028
- return this;
6029
- }
6030
- getMaxListeners() {
6031
- return this._maxListeners ?? _EventEmitter.defaultMaxListeners;
6032
- }
6033
- emit(type, ...args) {
6034
- const events = this._events;
6035
- let doError = type === "error";
6036
- if (events !== void 0) {
6037
- if (doError && events[_EventEmitter.errorMonitor] !== void 0) {
6038
- this.emit(_EventEmitter.errorMonitor, ...args);
6039
- }
6040
- doError = doError && events.error === void 0;
6041
- } else if (!doError) {
6042
- return false;
6043
- }
6044
- if (doError) {
6045
- let er;
6046
- if (args.length > 0) {
6047
- er = args[0];
6048
- } else {
6049
- er = new Error("Unhandled error.");
6050
- }
6051
- if (er instanceof Error) {
6052
- throw er;
6053
- }
6054
- const err = new Error("Unhandled error. (" + er + ")");
6055
- err.context = er;
6056
- throw err;
6057
- }
6058
- const handler = events[type];
6059
- if (handler === void 0) {
6060
- return false;
6061
- }
6062
- if (typeof handler === "function") {
6063
- const result = handler.apply(this, args);
6064
- if (result !== void 0 && result !== null && this[kCapture]) {
6065
- this._addCatch(result, type, args);
6066
- }
6067
- } else {
6068
- const listeners = arrayClone(handler);
6069
- const len = listeners.length;
6070
- for (let i = 0; i < len; ++i) {
6071
- const result = listeners[i].apply(this, args);
6072
- if (result !== void 0 && result !== null && this[kCapture]) {
6073
- this._addCatch(result, type, args);
6074
- }
6075
- }
6076
- }
6077
- return true;
6078
- }
6079
- _addCatch(result, type, args) {
6080
- if (typeof result?.then === "function") {
6081
- result.then(void 0, (err) => {
6082
- const handler = this[kRejection];
6083
- if (typeof handler === "function") {
6084
- handler.call(this, err, type, ...args);
6085
- } else {
6086
- const prev = this[kCapture];
6087
- try {
6088
- this[kCapture] = false;
6089
- this.emit("error", err);
6090
- } finally {
6091
- this[kCapture] = prev;
6092
- }
6093
- }
6094
- });
6095
- }
6096
- }
6097
- addListener(type, listener) {
6098
- return this._addListener(type, listener, false);
6099
- }
6100
- on(type, listener) {
6101
- return this._addListener(type, listener, false);
6102
- }
6103
- prependListener(type, listener) {
6104
- return this._addListener(type, listener, true);
6105
- }
6106
- _addListener(type, listener, prepend) {
6107
- checkListener(listener);
6108
- let events = this._events;
6109
- if (events === void 0) {
6110
- events = this._events = /* @__PURE__ */ Object.create(null);
6111
- this._eventsCount = 0;
6112
- } else if (events.newListener !== void 0) {
6113
- this.emit("newListener", type, listener.listener ?? listener);
6114
- events = this._events;
6115
- }
6116
- let existing = events[type];
6117
- if (existing === void 0) {
6118
- events[type] = listener;
6119
- ++this._eventsCount;
6120
- } else if (typeof existing === "function") {
6121
- events[type] = prepend ? [listener, existing] : [existing, listener];
6122
- } else {
6123
- if (prepend) {
6124
- existing.unshift(listener);
6125
- } else {
6126
- existing.push(listener);
6127
- }
6128
- }
6129
- const m = this.getMaxListeners();
6130
- if (m > 0) {
6131
- const count2 = typeof events[type] === "function" ? 1 : events[type].length;
6132
- if (count2 > m && !events[type].warned) {
6133
- if (typeof events[type] !== "function") {
6134
- events[type].warned = true;
6135
- }
6136
- const w = new Error(
6137
- `Possible EventEmitter memory leak detected. ${count2} ${String(type)} listeners added to [${this.constructor.name}]. Use emitter.setMaxListeners() to increase limit`
6138
- );
6139
- w.name = "MaxListenersExceededWarning";
6140
- console.warn(w.message);
6155
+ init_auto_globals_97a682e619();
6156
+ _isGjsTimer = getGLib() !== void 0;
6157
+ GjsifyTimeout = class {
6158
+ _id = null;
6159
+ _refed = true;
6160
+ _callback;
6161
+ _delay;
6162
+ _args;
6163
+ _repeat;
6164
+ constructor(callback, delay, args, repeat) {
6165
+ this._callback = callback;
6166
+ this._delay = delay;
6167
+ this._args = args;
6168
+ this._repeat = repeat;
6169
+ this._schedule();
6170
+ }
6171
+ _schedule() {
6172
+ const GLib4 = getGLib();
6173
+ if (!GLib4) return;
6174
+ const timeoutAdd = GLib4.timeout_add.bind(GLib4);
6175
+ this._id = timeoutAdd(GLib4.PRIORITY_DEFAULT, this._delay, () => {
6176
+ try {
6177
+ this._callback.apply(globalThis, this._args);
6178
+ } catch (err) {
6179
+ setTimeout(() => {
6180
+ throw err;
6181
+ }, 0);
6141
6182
  }
6142
- }
6143
- return this;
6144
- }
6145
- once(type, listener) {
6146
- checkListener(listener);
6147
- this.on(type, _onceWrap(this, type, listener));
6148
- return this;
6183
+ if (this._repeat) return GLib4.SOURCE_CONTINUE;
6184
+ this._id = null;
6185
+ return GLib4.SOURCE_REMOVE;
6186
+ });
6149
6187
  }
6150
- prependOnceListener(type, listener) {
6151
- checkListener(listener);
6152
- this.prependListener(type, _onceWrap(this, type, listener));
6188
+ ref() {
6189
+ this._refed = true;
6153
6190
  return this;
6154
6191
  }
6155
- removeListener(type, listener) {
6156
- checkListener(listener);
6157
- const events = this._events;
6158
- if (events === void 0) {
6159
- return this;
6160
- }
6161
- const list = events[type];
6162
- if (list === void 0) {
6163
- return this;
6164
- }
6165
- if (list === listener || list.listener === listener) {
6166
- if (--this._eventsCount === 0) {
6167
- this._events = /* @__PURE__ */ Object.create(null);
6168
- } else {
6169
- delete events[type];
6170
- if (events.removeListener) {
6171
- this.emit("removeListener", type, list.listener ?? listener);
6172
- }
6173
- }
6174
- } else if (typeof list !== "function") {
6175
- let position = -1;
6176
- for (let i = list.length - 1; i >= 0; i--) {
6177
- if (list[i] === listener || list[i].listener === listener) {
6178
- position = i;
6179
- break;
6180
- }
6181
- }
6182
- if (position < 0) {
6183
- return this;
6184
- }
6185
- if (position === 0) {
6186
- list.shift();
6187
- } else {
6188
- spliceOne(list, position);
6189
- }
6190
- if (list.length === 1) {
6191
- events[type] = list[0];
6192
- }
6193
- if (events.removeListener !== void 0) {
6194
- this.emit("removeListener", type, listener.listener ?? listener);
6195
- }
6196
- }
6192
+ unref() {
6193
+ this._refed = false;
6197
6194
  return this;
6198
6195
  }
6199
- off(type, listener) {
6200
- return this.removeListener(type, listener);
6196
+ hasRef() {
6197
+ return this._refed;
6201
6198
  }
6202
- removeAllListeners(type) {
6203
- const events = this._events;
6204
- if (events === void 0) {
6205
- return this;
6206
- }
6207
- if (events.removeListener === void 0) {
6208
- if (arguments.length === 0) {
6209
- this._events = /* @__PURE__ */ Object.create(null);
6210
- this._eventsCount = 0;
6211
- } else if (events[type] !== void 0) {
6212
- if (--this._eventsCount === 0) {
6213
- this._events = /* @__PURE__ */ Object.create(null);
6214
- } else {
6215
- delete events[type];
6216
- }
6217
- }
6218
- return this;
6219
- }
6220
- if (arguments.length === 0) {
6221
- const keys = Object.keys(events);
6222
- for (let i = 0; i < keys.length; ++i) {
6223
- const key = keys[i];
6224
- if (key === "removeListener") continue;
6225
- this.removeAllListeners(key);
6226
- }
6227
- this.removeAllListeners("removeListener");
6228
- this._events = /* @__PURE__ */ Object.create(null);
6229
- this._eventsCount = 0;
6230
- return this;
6231
- }
6232
- const listeners = events[type];
6233
- if (typeof listeners === "function") {
6234
- this.removeListener(type, listeners);
6235
- } else if (listeners !== void 0) {
6236
- for (let i = listeners.length - 1; i >= 0; i--) {
6237
- this.removeListener(type, listeners[i]);
6238
- }
6239
- }
6199
+ refresh() {
6200
+ this._cancel();
6201
+ this._schedule();
6240
6202
  return this;
6241
6203
  }
6242
- listeners(type) {
6243
- const events = this._events;
6244
- if (events === void 0) {
6245
- return [];
6246
- }
6247
- const evlistener = events[type];
6248
- if (evlistener === void 0) {
6249
- return [];
6250
- }
6251
- if (typeof evlistener === "function") {
6252
- return [evlistener.listener ?? evlistener];
6253
- }
6254
- return unwrapListeners(evlistener);
6255
- }
6256
- rawListeners(type) {
6257
- const events = this._events;
6258
- if (events === void 0) {
6259
- return [];
6260
- }
6261
- const evlistener = events[type];
6262
- if (evlistener === void 0) {
6263
- return [];
6264
- }
6265
- if (typeof evlistener === "function") {
6266
- return [evlistener];
6267
- }
6268
- return arrayClone(evlistener);
6269
- }
6270
- listenerCount(type) {
6271
- const events = this._events;
6272
- if (events === void 0) {
6273
- return 0;
6274
- }
6275
- const evlistener = events[type];
6276
- if (evlistener === void 0) {
6277
- return 0;
6278
- }
6279
- if (typeof evlistener === "function") {
6280
- return 1;
6281
- }
6282
- return evlistener.length;
6283
- }
6284
- eventNames() {
6285
- return (this._eventsCount ?? 0) > 0 ? Reflect.ownKeys(this._events) : [];
6286
- }
6287
- // -- Static methods --
6288
- /**
6289
- * Returns a promise that resolves when the emitter emits the given event,
6290
- * or rejects if the emitter emits 'error' while waiting.
6291
- */
6292
- static once(emitter, name2, options) {
6293
- return new Promise((resolve, reject) => {
6294
- const signal = options?.signal;
6295
- if (signal?.aborted) {
6296
- reject(createAbortError(signal));
6297
- return;
6298
- }
6299
- if (typeof emitter.addEventListener === "function") {
6300
- const eventTarget = emitter;
6301
- const handler = (...args) => {
6302
- if (signal) {
6303
- signal.removeEventListener("abort", abortHandler2);
6304
- }
6305
- resolve(args);
6306
- };
6307
- const errorHandler2 = (err) => {
6308
- if (signal) {
6309
- signal.removeEventListener("abort", abortHandler2);
6310
- }
6311
- eventTarget.removeEventListener("error", errorHandler2);
6312
- reject(err);
6313
- };
6314
- const abortHandler2 = () => {
6315
- eventTarget.removeEventListener(name2, handler);
6316
- eventTarget.removeEventListener("error", errorHandler2);
6317
- reject(createAbortError(signal));
6318
- };
6319
- eventTarget.addEventListener(name2, handler, { once: true });
6320
- if (name2 !== "error") {
6321
- eventTarget.addEventListener("error", errorHandler2, { once: true });
6322
- }
6323
- if (signal) {
6324
- signal.addEventListener("abort", abortHandler2, { once: true });
6325
- }
6326
- return;
6327
- }
6328
- const ee = emitter;
6329
- const eventHandler = (...args) => {
6330
- if (signal) {
6331
- signal.removeEventListener("abort", abortHandler);
6332
- }
6333
- if (errorHandler !== void 0) {
6334
- ee.removeListener("error", errorHandler);
6335
- }
6336
- resolve(args);
6337
- };
6338
- let errorHandler;
6339
- if (name2 !== "error") {
6340
- errorHandler = (err) => {
6341
- ee.removeListener(name2, eventHandler);
6342
- if (signal) {
6343
- signal.removeEventListener("abort", abortHandler);
6344
- }
6345
- reject(err);
6346
- };
6347
- ee.once("error", errorHandler);
6348
- }
6349
- ee.once(name2, eventHandler);
6350
- const abortHandler = () => {
6351
- ee.removeListener(name2, eventHandler);
6352
- if (errorHandler) {
6353
- ee.removeListener("error", errorHandler);
6354
- }
6355
- reject(createAbortError(signal));
6356
- };
6357
- if (signal) {
6358
- signal.addEventListener("abort", abortHandler, { once: true });
6359
- }
6360
- });
6361
- }
6362
- /**
6363
- * Returns an async iterator that yields event arguments each time the emitter emits.
6364
- */
6365
- static on(emitter, event, options) {
6366
- const signal = options?.signal;
6367
- if (signal?.aborted) {
6368
- throw createAbortError(signal);
6369
- }
6370
- const highWaterMark = options?.highWaterMark ?? Number.MAX_SAFE_INTEGER;
6371
- const lowWaterMark = options?.lowWaterMark ?? 1;
6372
- validateNumber(highWaterMark, "highWaterMark");
6373
- validateNumber(lowWaterMark, "lowWaterMark");
6374
- const unconsumedEvents = [];
6375
- const unconsumedPromises = [];
6376
- let error3 = null;
6377
- let finished = false;
6378
- let paused = false;
6379
- const eventHandler = (...args) => {
6380
- if (unconsumedPromises.length > 0) {
6381
- const { resolve } = unconsumedPromises.shift();
6382
- resolve({ value: args, done: false });
6383
- } else {
6384
- unconsumedEvents.push(args);
6385
- if (unconsumedEvents.length >= highWaterMark && !paused) {
6386
- paused = true;
6387
- if (typeof emitter.pause === "function") {
6388
- emitter.pause();
6389
- }
6390
- }
6391
- }
6392
- };
6393
- const errorHandler = (err) => {
6394
- error3 = err;
6395
- if (unconsumedPromises.length > 0) {
6396
- const { reject } = unconsumedPromises.shift();
6397
- reject(err);
6398
- }
6399
- iterator.return();
6400
- };
6401
- const abortHandler = () => {
6402
- errorHandler(createAbortError(signal));
6403
- };
6404
- emitter.on(event, eventHandler);
6405
- if (event !== "error") {
6406
- emitter.on("error", errorHandler);
6407
- }
6408
- if (signal) {
6409
- signal.addEventListener("abort", abortHandler, { once: true });
6410
- }
6411
- const cleanup = () => {
6412
- emitter.removeListener(event, eventHandler);
6413
- emitter.removeListener("error", errorHandler);
6414
- if (signal) {
6415
- signal.removeEventListener("abort", abortHandler);
6416
- }
6417
- finished = true;
6418
- for (const { resolve } of unconsumedPromises) {
6419
- resolve({ value: void 0, done: true });
6420
- }
6421
- unconsumedPromises.length = 0;
6422
- unconsumedEvents.length = 0;
6423
- };
6424
- const iterator = {
6425
- next() {
6426
- if (unconsumedEvents.length > 0) {
6427
- const value2 = unconsumedEvents.shift();
6428
- if (paused && unconsumedEvents.length < lowWaterMark) {
6429
- paused = false;
6430
- if (typeof emitter.resume === "function") {
6431
- emitter.resume();
6432
- }
6433
- }
6434
- return Promise.resolve({ value: value2, done: false });
6435
- }
6436
- if (error3) {
6437
- const p = Promise.reject(error3);
6438
- error3 = null;
6439
- return p;
6440
- }
6441
- if (finished) {
6442
- return Promise.resolve({ value: void 0, done: true });
6443
- }
6444
- return new Promise((resolve, reject) => {
6445
- unconsumedPromises.push({ resolve, reject });
6446
- });
6447
- },
6448
- return() {
6449
- cleanup();
6450
- return Promise.resolve({ value: void 0, done: true });
6451
- },
6452
- throw(err) {
6453
- if (!finished) {
6454
- error3 = err;
6455
- cleanup();
6456
- }
6457
- return Promise.reject(err);
6458
- },
6459
- [Symbol.asyncIterator]() {
6460
- return this;
6461
- }
6462
- };
6463
- return iterator;
6464
- }
6465
- /**
6466
- * Returns the number of listeners listening to the event name.
6467
- * @deprecated Use emitter.listenerCount() instead.
6468
- */
6469
- static listenerCount(emitter, type) {
6470
- return emitter.listenerCount(type);
6471
- }
6472
- /**
6473
- * Returns a copy of the array of listeners for the event named eventName.
6474
- */
6475
- static getEventListeners(emitter, name2) {
6476
- if (typeof emitter.listeners === "function") {
6477
- return emitter.listeners(name2);
6478
- }
6479
- return [];
6480
- }
6481
- /**
6482
- * Set max listeners on one or more emitters.
6483
- */
6484
- static setMaxListeners(n, ...emitters) {
6485
- validateNumber(n, "n");
6486
- if (n < 0) {
6487
- throw new RangeError('The value of "n" is out of range.');
6488
- }
6489
- if (emitters.length === 0) {
6490
- _EventEmitter.defaultMaxListeners = n;
6491
- } else {
6492
- for (const emitter of emitters) {
6493
- if (typeof emitter.setMaxListeners === "function") {
6494
- emitter.setMaxListeners(n);
6495
- }
6496
- }
6497
- }
6498
- }
6499
- /**
6500
- * Returns the currently set max listeners on the emitter.
6501
- */
6502
- static getMaxListeners(emitter) {
6503
- if (typeof emitter.getMaxListeners === "function") {
6504
- return emitter.getMaxListeners();
6505
- }
6506
- return _EventEmitter.defaultMaxListeners;
6507
- }
6508
- /**
6509
- * Listens once to an abort event on the provided signal and returns a disposable.
6510
- */
6511
- static addAbortListener(signal, listener) {
6512
- if (signal.aborted) {
6513
- Promise.resolve().then(() => listener());
6514
- }
6515
- const handler = () => listener();
6516
- signal.addEventListener("abort", handler, { once: true });
6517
- return {
6518
- [Symbol.dispose]() {
6519
- signal.removeEventListener("abort", handler);
6520
- }
6521
- };
6522
- }
6523
- };
6524
- EventEmitter.EventEmitter = EventEmitter;
6525
- }
6526
- });
6527
-
6528
- // ../../../packages/node/events/lib/esm/index.js
6529
- var esm_exports = {};
6530
- __export(esm_exports, {
6531
- EventEmitter: () => EventEmitter2,
6532
- addAbortListener: () => addAbortListener,
6533
- captureRejectionSymbol: () => captureRejectionSymbol,
6534
- default: () => index_default,
6535
- defaultMaxListeners: () => defaultMaxListeners,
6536
- errorMonitor: () => errorMonitor,
6537
- getEventListeners: () => getEventListeners,
6538
- getMaxListeners: () => getMaxListeners,
6539
- listenerCount: () => listenerCount,
6540
- on: () => on,
6541
- once: () => once,
6542
- setMaxListeners: () => setMaxListeners
6543
- });
6544
- var EventEmitter2, captureRejectionSymbol, errorMonitor, defaultMaxListeners, setMaxListeners, getMaxListeners, once, on, getEventListeners, listenerCount, addAbortListener, index_default;
6545
- var init_esm6 = __esm({
6546
- "../../../packages/node/events/lib/esm/index.js"() {
6547
- init_console_gjs();
6548
- init_auto_globals_495e9d950c();
6549
- init_esm();
6550
- init_event_emitter();
6551
- EventEmitter2 = makeCallable(EventEmitter);
6552
- EventEmitter2.EventEmitter = EventEmitter2;
6553
- captureRejectionSymbol = EventEmitter2.captureRejectionSymbol;
6554
- errorMonitor = EventEmitter2.errorMonitor;
6555
- defaultMaxListeners = EventEmitter2.defaultMaxListeners;
6556
- setMaxListeners = EventEmitter2.setMaxListeners;
6557
- getMaxListeners = EventEmitter2.getMaxListeners;
6558
- once = EventEmitter2.once;
6559
- on = EventEmitter2.on;
6560
- getEventListeners = EventEmitter2.getEventListeners;
6561
- listenerCount = EventEmitter2.listenerCount;
6562
- addAbortListener = EventEmitter2.addAbortListener;
6563
- index_default = EventEmitter2;
6564
- }
6565
- });
6566
-
6567
- // ../../../packages/node/events/cjs-compat.cjs
6568
- var require_cjs_compat = __commonJS({
6569
- "../../../packages/node/events/cjs-compat.cjs"(exports, module) {
6570
- init_console_gjs();
6571
- init_auto_globals_495e9d950c();
6572
- var mod = (init_esm6(), __toCommonJS(esm_exports));
6573
- module.exports = mod.default || mod;
6574
- }
6575
- });
6576
-
6577
- // ../../../packages/node/process/lib/esm/index.js
6578
- function getGjsGlobal() {
6579
- return globalThis;
6580
- }
6581
- function detectGjsVersion() {
6582
- try {
6583
- const system = getGjsGlobal().imports?.system;
6584
- if (system?.version !== void 0) {
6585
- const v = Number(system.version);
6586
- const major = Math.floor(v / 1e4);
6587
- const minor = Math.floor(v % 1e4 / 100);
6588
- const patch = v % 100;
6589
- return `${major}.${minor}.${patch}`;
6590
- }
6591
- } catch {
6592
- }
6593
- return void 0;
6594
- }
6595
- function detectNodeVersion() {
6596
- if (typeof globalThis.process?.versions?.node === "string") {
6597
- return globalThis.process.versions.node;
6598
- }
6599
- return void 0;
6600
- }
6601
- function detectVersionInfo() {
6602
- const nodeVersion = detectNodeVersion();
6603
- if (nodeVersion) {
6604
- return {
6605
- version: globalThis.process.version,
6606
- versions: { ...globalThis.process.versions },
6607
- title: globalThis.process?.title || "node"
6608
- };
6609
- }
6610
- const gjsVersion = detectGjsVersion();
6611
- const versions2 = {
6612
- node: "20.0.0"
6613
- // Compatibility version — many npm packages check process.versions.node
6614
- };
6615
- if (gjsVersion) versions2.gjs = gjsVersion;
6616
- return {
6617
- version: "v20.0.0",
6618
- // Compatibility version for Node.js API level checks
6619
- versions: versions2,
6620
- title: "gjs"
6621
- };
6622
- }
6623
- function detectPpid() {
6624
- if (typeof globalThis.process?.ppid === "number") {
6625
- return globalThis.process.ppid;
6626
- }
6627
- try {
6628
- const GLib4 = getGjsGlobal().imports?.gi?.GLib;
6629
- if (GLib4) {
6630
- const [, contents] = GLib4.file_get_contents("/proc/self/status");
6631
- if (contents) {
6632
- const str = new TextDecoder().decode(contents);
6633
- const match = str.match(/PPid:\s+(\d+)/);
6634
- if (match) return parseInt(match[1], 10);
6635
- }
6636
- }
6637
- } catch {
6638
- }
6639
- return 0;
6640
- }
6641
- function detectPlatform() {
6642
- try {
6643
- const GLib4 = getGjsGlobal().imports?.gi?.GLib;
6644
- if (GLib4) {
6645
- const osInfo = GLib4.get_os_info("ID");
6646
- if (osInfo) return "linux";
6647
- }
6648
- } catch {
6649
- }
6650
- if (typeof getGjsGlobal().imports?.system !== "undefined") {
6651
- return "linux";
6652
- }
6653
- if (typeof globalThis.process?.platform === "string") {
6654
- return globalThis.process.platform;
6655
- }
6656
- return "linux";
6657
- }
6658
- function detectArch() {
6659
- if (typeof globalThis.process?.arch === "string") {
6660
- return globalThis.process.arch;
6661
- }
6662
- try {
6663
- const system = getGjsGlobal().imports?.system;
6664
- if (system?.programInvocationName) {
6665
- }
6666
- } catch {
6667
- }
6668
- return "x64";
6669
- }
6670
- function getCwd() {
6671
- try {
6672
- const GLib4 = getGjsGlobal().imports?.gi?.GLib;
6673
- if (GLib4?.get_current_dir) return GLib4.get_current_dir();
6674
- } catch {
6675
- }
6676
- return "/";
6677
- }
6678
- function getEnvProxy() {
6679
- if (typeof globalThis.process?.env === "object") {
6680
- return globalThis.process.env;
6681
- }
6682
- try {
6683
- const GLib4 = getGjsGlobal().imports?.gi?.GLib;
6684
- if (GLib4) {
6685
- return new Proxy({}, {
6686
- get(_target2, prop) {
6687
- if (typeof prop !== "string") return void 0;
6688
- return GLib4.getenv(prop) ?? void 0;
6689
- },
6690
- set(_target2, prop, value2) {
6691
- if (typeof prop !== "string") return false;
6692
- GLib4.setenv(prop, String(value2), true);
6693
- return true;
6694
- },
6695
- deleteProperty(_target2, prop) {
6696
- if (typeof prop !== "string") return false;
6697
- GLib4.unsetenv(prop);
6698
- return true;
6699
- },
6700
- has(_target2, prop) {
6701
- if (typeof prop !== "string") return false;
6702
- return GLib4.getenv(prop) !== null;
6703
- },
6704
- ownKeys(_target2) {
6705
- const envp = GLib4.listenv();
6706
- return envp;
6707
- },
6708
- getOwnPropertyDescriptor(_target2, prop) {
6709
- if (typeof prop !== "string") return void 0;
6710
- const val = GLib4.getenv(prop);
6711
- if (val === null) return void 0;
6712
- return { configurable: true, enumerable: true, writable: true, value: val };
6713
- }
6714
- });
6715
- }
6716
- } catch {
6717
- }
6718
- return {};
6719
- }
6720
- function getArgv() {
6721
- if (typeof globalThis.process?.argv !== "undefined") {
6722
- return globalThis.process.argv;
6723
- }
6724
- try {
6725
- const system = getGjsGlobal().imports?.system;
6726
- if (system?.programArgs) {
6727
- return ["gjs", system.programInvocationName || "", ...system.programArgs];
6728
- }
6729
- } catch {
6730
- }
6731
- return ["gjs"];
6732
- }
6733
- function getExecPath() {
6734
- if (typeof globalThis.process?.execPath === "string") {
6735
- return globalThis.process.execPath;
6736
- }
6737
- try {
6738
- const system = getGjsGlobal().imports?.system;
6739
- if (system?.programInvocationName) return system.programInvocationName;
6740
- } catch {
6741
- }
6742
- return "/usr/bin/gjs";
6743
- }
6744
- function getPid() {
6745
- if (typeof globalThis.process?.pid === "number") {
6746
- return globalThis.process.pid;
6747
- }
6748
- try {
6749
- const GLib4 = getGjsGlobal().imports?.gi?.GLib;
6750
- if (GLib4) {
6751
- const [, contents] = GLib4.file_get_contents("/proc/self/stat");
6752
- if (contents) {
6753
- const str = new TextDecoder().decode(contents);
6754
- const pid2 = parseInt(str, 10);
6755
- if (!isNaN(pid2)) return pid2;
6756
- }
6757
- }
6758
- } catch {
6759
- }
6760
- return 0;
6761
- }
6762
- function getMonotonicTime() {
6763
- try {
6764
- const GLib4 = getGjsGlobal().imports?.gi?.GLib;
6765
- if (GLib4?.get_monotonic_time) {
6766
- return BigInt(GLib4.get_monotonic_time()) * 1000n;
6767
- }
6768
- } catch {
6769
- }
6770
- if (typeof performance?.now === "function") {
6771
- return BigInt(Math.round(performance.now() * 1e6));
6772
- }
6773
- return BigInt(Date.now()) * 1000000n;
6774
- }
6775
- var import_events, startTime, hrtimeBase, Process, process, platform, arch, env, argv, argv0, execPath, pid, ppid, version, versions, cwd, chdir, exit, nextTick2, hrtime, uptime, memoryUsage, cpuUsage, kill, abort, umask, emitWarning, execArgv, config, stdout, stderr, stdin, index_default2;
6776
- var init_esm7 = __esm({
6777
- "../../../packages/node/process/lib/esm/index.js"() {
6778
- init_console_gjs();
6779
- init_auto_globals_495e9d950c();
6780
- import_events = __toESM(require_cjs_compat(), 1);
6781
- startTime = Date.now();
6782
- hrtimeBase = getMonotonicTime();
6783
- Process = class extends import_events.EventEmitter {
6784
- platform;
6785
- arch;
6786
- env;
6787
- argv;
6788
- argv0;
6789
- execPath;
6790
- pid;
6791
- ppid;
6792
- version;
6793
- versions;
6794
- title;
6795
- execArgv;
6796
- config;
6797
- exitCode;
6798
- constructor() {
6799
- super();
6800
- this.platform = detectPlatform();
6801
- this.arch = detectArch();
6802
- this.env = getEnvProxy();
6803
- this.argv = getArgv();
6804
- this.argv0 = this.argv[0] || "gjs";
6805
- this.execPath = getExecPath();
6806
- this.execArgv = globalThis.process?.execArgv ?? [];
6807
- this.config = globalThis.process?.config ?? { target_defaults: {}, variables: {} };
6808
- this.pid = getPid();
6809
- this.ppid = detectPpid();
6810
- const versionInfo = detectVersionInfo();
6811
- this.version = versionInfo.version;
6812
- this.versions = versionInfo.versions;
6813
- this.title = versionInfo.title;
6814
- }
6815
- cwd() {
6816
- return getCwd();
6817
- }
6818
- chdir(directory) {
6204
+ _cancel() {
6205
+ if (this._id === null) return;
6819
6206
  try {
6820
- const GLib4 = getGjsGlobal().imports?.gi?.GLib;
6821
- if (GLib4?.chdir) {
6822
- if (!GLib4.file_test(
6823
- directory,
6824
- 16
6825
- /* G_FILE_TEST_EXISTS */
6826
- )) {
6827
- const err = new Error(`ENOENT: no such file or directory, chdir '${directory}'`);
6828
- err.code = "ENOENT";
6829
- err.syscall = "chdir";
6830
- err.path = directory;
6831
- throw err;
6832
- }
6833
- GLib4.chdir(directory);
6834
- return;
6835
- }
6836
- } catch (e) {
6837
- if (e && typeof e === "object" && e.code === "ENOENT") throw e;
6838
- }
6839
- const nativeProcess = globalThis.process;
6840
- if (nativeProcess && nativeProcess !== this && typeof nativeProcess.chdir === "function") {
6841
- nativeProcess.chdir(directory);
6842
- return;
6843
- }
6844
- throw new Error("process.chdir() is not supported in this environment");
6845
- }
6846
- kill(pid2, signal) {
6847
- const nativeProcess = globalThis.process;
6848
- if (nativeProcess && nativeProcess !== this && typeof nativeProcess.kill === "function") {
6849
- return nativeProcess.kill(pid2, signal);
6850
- }
6851
- try {
6852
- const GLib4 = getGjsGlobal().imports?.gi?.GLib;
6853
- if (GLib4) {
6854
- const sig = typeof signal === "number" ? String(signal) : signal || "SIGTERM";
6855
- const sigArg = sig.startsWith("SIG") ? `-${sig.slice(3)}` : `-${sig}`;
6856
- GLib4.spawn_command_line_sync(`kill ${sigArg} ${pid2}`);
6857
- return true;
6858
- }
6859
- } catch {
6860
- }
6861
- throw new Error("process.kill() is not supported in this environment");
6862
- }
6863
- exit(code) {
6864
- this.exitCode = code ?? this.exitCode ?? 0;
6865
- this.emit("exit", this.exitCode);
6866
- try {
6867
- const system = getGjsGlobal().imports?.system;
6868
- if (system?.exit) {
6869
- system.exit(this.exitCode);
6870
- }
6207
+ getGLib()?.Source.remove(this._id);
6871
6208
  } catch {
6872
6209
  }
6873
- const nativeProcess = globalThis.process;
6874
- if (nativeProcess && nativeProcess !== this && typeof nativeProcess.exit === "function") {
6875
- nativeProcess.exit(this.exitCode);
6876
- }
6877
- throw new Error(`process.exit(${this.exitCode})`);
6210
+ this._id = null;
6878
6211
  }
6879
- nextTick(callback, ...args) {
6880
- if (typeof queueMicrotask === "function") {
6881
- queueMicrotask(() => callback(...args));
6882
- } else {
6883
- Promise.resolve().then(() => callback(...args));
6884
- }
6885
- }
6886
- hrtime(time2) {
6887
- const now = getMonotonicTime() - hrtimeBase;
6888
- const seconds = Number(now / 1000000000n);
6889
- const nanoseconds = Number(now % 1000000000n);
6890
- if (time2) {
6891
- let diffSec = seconds - time2[0];
6892
- let diffNano = nanoseconds - time2[1];
6893
- if (diffNano < 0) {
6894
- diffSec--;
6895
- diffNano += 1e9;
6896
- }
6897
- return [diffSec, diffNano];
6898
- }
6899
- return [seconds, nanoseconds];
6212
+ [Symbol.toPrimitive]() {
6213
+ return this._id;
6900
6214
  }
6901
- uptime() {
6902
- return (Date.now() - startTime) / 1e3;
6215
+ [Symbol.dispose]() {
6216
+ this._cancel();
6903
6217
  }
6904
- memoryUsage() {
6905
- try {
6906
- const GLib4 = getGjsGlobal().imports?.gi?.GLib;
6907
- if (GLib4) {
6908
- const [, contents] = GLib4.file_get_contents("/proc/self/status");
6909
- if (contents) {
6910
- const str = new TextDecoder().decode(contents);
6911
- const vmRSS = str.match(/VmRSS:\s+(\d+)/);
6912
- const rss = vmRSS ? parseInt(vmRSS[1], 10) * 1024 : 0;
6913
- return { rss, heapTotal: rss, heapUsed: rss, external: 0, arrayBuffers: 0 };
6914
- }
6915
- }
6916
- } catch {
6917
- }
6918
- const nativeProcess = globalThis.process;
6919
- if (nativeProcess && nativeProcess !== this && typeof nativeProcess.memoryUsage === "function") {
6920
- return nativeProcess.memoryUsage();
6921
- }
6922
- return { rss: 0, heapTotal: 0, heapUsed: 0, external: 0, arrayBuffers: 0 };
6923
- }
6924
- cpuUsage(previousValue) {
6925
- const nativeProcess = globalThis.process;
6926
- if (nativeProcess && nativeProcess !== this && typeof nativeProcess.cpuUsage === "function") {
6927
- return nativeProcess.cpuUsage(previousValue);
6928
- }
6929
- return { user: 0, system: 0 };
6930
- }
6931
- // Stub: stdout/stderr/stdin — these need stream to be implemented fully
6932
- // Note: Cannot check globalThis.process.stdout here — on GJS globalThis.process
6933
- // IS this instance, so that would cause infinite recursion.
6934
- stdout = { write: (data) => {
6935
- console.log(data);
6936
- return true;
6937
- }, fd: 1 };
6938
- stderr = { write: (data) => {
6939
- console.error(data);
6940
- return true;
6941
- }, fd: 2 };
6942
- stdin = { fd: 0 };
6943
- abort() {
6944
- this.exit(1);
6945
- }
6946
- // no-op stubs for compatibility
6947
- umask(mask) {
6948
- return 18;
6949
- }
6950
- emitWarning(warning, name2) {
6951
- if (typeof warning === "string") {
6952
- console.warn(`(${name2 || "Warning"}): ${warning}`);
6953
- } else {
6954
- console.warn(warning.message);
6955
- }
6956
- }
6957
- };
6958
- Process.prototype.hrtime.bigint = function() {
6959
- return getMonotonicTime() - hrtimeBase;
6960
6218
  };
6961
- process = new Process();
6962
- platform = process.platform;
6963
- arch = process.arch;
6964
- env = process.env;
6965
- argv = process.argv;
6966
- argv0 = process.argv0;
6967
- execPath = process.execPath;
6968
- pid = process.pid;
6969
- ppid = process.ppid;
6970
- version = process.version;
6971
- versions = process.versions;
6972
- cwd = process.cwd.bind(process);
6973
- chdir = process.chdir.bind(process);
6974
- exit = process.exit.bind(process);
6975
- nextTick2 = process.nextTick.bind(process);
6976
- hrtime = process.hrtime.bind(process);
6977
- uptime = process.uptime.bind(process);
6978
- memoryUsage = process.memoryUsage.bind(process);
6979
- cpuUsage = process.cpuUsage.bind(process);
6980
- kill = process.kill.bind(process);
6981
- abort = process.abort.bind(process);
6982
- umask = process.umask.bind(process);
6983
- emitWarning = process.emitWarning.bind(process);
6984
- execArgv = process.execArgv;
6985
- config = process.config;
6986
- stdout = process.stdout;
6987
- stderr = process.stderr;
6988
- stdin = process.stdin;
6989
- index_default2 = process;
6990
- }
6991
- });
6992
-
6993
- // ../../../packages/node/globals/lib/esm/register/process.js
6994
- var init_process = __esm({
6995
- "../../../packages/node/globals/lib/esm/register/process.js"() {
6996
- init_console_gjs();
6997
- init_auto_globals_495e9d950c();
6998
- init_esm();
6999
- init_esm7();
7000
- if (typeof Promise.withResolvers !== "function") {
7001
- Promise.withResolvers = function() {
7002
- let resolve;
7003
- let reject;
7004
- const promise = new Promise((res, rej) => {
7005
- resolve = res;
7006
- reject = rej;
7007
- });
7008
- return { promise, resolve, reject };
7009
- };
7010
- }
7011
- initErrorV8Methods(Error);
7012
- if (!("global" in globalThis)) {
7013
- Object.defineProperty(globalThis, "global", {
7014
- value: globalThis,
7015
- writable: false,
7016
- enumerable: false,
6219
+ if (_isGjsTimer) {
6220
+ const setT = (cb, delay = 0, ...args) => new GjsifyTimeout(cb, Math.max(0, delay | 0), args, false);
6221
+ const setI = (cb, delay = 0, ...args) => new GjsifyTimeout(cb, Math.max(0, delay | 0), args, true);
6222
+ const g = globalThis;
6223
+ g.setTimeout = setT;
6224
+ g.clearTimeout = removeById;
6225
+ g.setInterval = setI;
6226
+ g.clearInterval = removeById;
6227
+ }
6228
+ if (!("setImmediate" in globalThis)) {
6229
+ Object.defineProperty(globalThis, "setImmediate", {
6230
+ value: setImmediate,
6231
+ enumerable: true,
6232
+ writable: true,
7017
6233
  configurable: true
7018
6234
  });
7019
6235
  }
7020
- if (!("process" in globalThis)) {
7021
- Object.defineProperty(globalThis, "process", {
7022
- value: index_default2,
7023
- enumerable: false,
6236
+ if (!("clearImmediate" in globalThis)) {
6237
+ Object.defineProperty(globalThis, "clearImmediate", {
6238
+ value: clearImmediate,
6239
+ enumerable: true,
7024
6240
  writable: true,
7025
6241
  configurable: true
7026
6242
  });
@@ -7040,10 +6256,10 @@ function encodeComponent(s) {
7040
6256
  return encodeURIComponent(s).replace(/%20/g, "+");
7041
6257
  }
7042
6258
  var PARSE_FLAGS, URLSearchParams, URL2;
7043
- var init_esm8 = __esm({
6259
+ var init_esm6 = __esm({
7044
6260
  "../../../packages/node/url/lib/esm/index.js"() {
7045
6261
  init_console_gjs();
7046
- init_auto_globals_495e9d950c();
6262
+ init_auto_globals_97a682e619();
7047
6263
  init_glib_2();
7048
6264
  PARSE_FLAGS = glib_2_default.UriFlags.HAS_PASSWORD | glib_2_default.UriFlags.ENCODED | glib_2_default.UriFlags.SCHEME_NORMALIZE;
7049
6265
  URLSearchParams = class _URLSearchParams {
@@ -7243,6 +6459,44 @@ var init_esm8 = __esm({
7243
6459
  toJSON() {
7244
6460
  return this.href;
7245
6461
  }
6462
+ // ---- URL.createObjectURL / URL.revokeObjectURL ----
6463
+ //
6464
+ // Consumers like Excalibur.js do `const src = URL.createObjectURL(blob);
6465
+ // image.src = src;`. For that to work on GJS we need `src` to be a path
6466
+ // `HTMLImageElement` / `HTMLAudioElement` / `FontFace` can actually read —
6467
+ // i.e. a `file://` URL. We implement this as a static method on our own
6468
+ // URL class (no globalThis monkey-patching):
6469
+ //
6470
+ // - Fast path: if the Blob already carries a `_tmpPath` (e.g. written
6471
+ // by `@gjsify/fetch` XHR when `responseType='blob'`), wrap it as
6472
+ // `file://<_tmpPath>`.
6473
+ // - Slow path: if the Blob has `arrayBuffer()`/bytes but no `_tmpPath`,
6474
+ // materialise the bytes into a GLib temp file and wrap that. This
6475
+ // path is async in the spec — but W3C `createObjectURL` is sync. We
6476
+ // read the bytes via `GLib.Bytes`-style synchronous access when
6477
+ // possible and fall back to a sentinel if not.
6478
+ //
6479
+ // Reference: https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
6480
+ static _objectURLPaths = /* @__PURE__ */ new Map();
6481
+ static _objectURLCounter = 0;
6482
+ static createObjectURL(blob) {
6483
+ const tmp = blob?._tmpPath;
6484
+ if (typeof tmp === "string" && tmp.length > 0) {
6485
+ const url = `file://${tmp}`;
6486
+ _URL._objectURLPaths.set(url, tmp);
6487
+ return url;
6488
+ }
6489
+ return "file:///dev/null";
6490
+ }
6491
+ static revokeObjectURL(url) {
6492
+ const path = _URL._objectURLPaths.get(url);
6493
+ if (!path) return;
6494
+ try {
6495
+ glib_2_default.unlink(path);
6496
+ } catch {
6497
+ }
6498
+ _URL._objectURLPaths.delete(url);
6499
+ }
7246
6500
  };
7247
6501
  }
7248
6502
  });
@@ -7251,8 +6505,8 @@ var init_esm8 = __esm({
7251
6505
  var init_url = __esm({
7252
6506
  "../../../packages/node/globals/lib/esm/register/url.js"() {
7253
6507
  init_console_gjs();
7254
- init_auto_globals_495e9d950c();
7255
- init_esm8();
6508
+ init_auto_globals_97a682e619();
6509
+ init_esm6();
7256
6510
  if (typeof globalThis.URL !== "function") {
7257
6511
  Object.defineProperty(globalThis, "URL", {
7258
6512
  value: URL2,
@@ -7274,10 +6528,10 @@ var init_url = __esm({
7274
6528
 
7275
6529
  // ../../../packages/node/perf_hooks/lib/esm/index.js
7276
6530
  var performance2, PerformanceObserverStub, PerformanceEntryStub, PerformanceObserverEntryListStub, PerformanceObserver, PerformanceEntry, PerformanceObserverEntryList, PerformanceMark, PerformanceMeasure;
7277
- var init_esm9 = __esm({
6531
+ var init_esm7 = __esm({
7278
6532
  "../../../packages/node/perf_hooks/lib/esm/index.js"() {
7279
6533
  init_console_gjs();
7280
- init_auto_globals_495e9d950c();
6534
+ init_auto_globals_97a682e619();
7281
6535
  if (globalThis.performance) {
7282
6536
  performance2 = globalThis.performance;
7283
6537
  } else {
@@ -7303,17 +6557,17 @@ var init_esm9 = __esm({
7303
6557
  return entry;
7304
6558
  },
7305
6559
  measure(name2, startMark, endMark) {
7306
- let startTime2 = 0;
6560
+ let startTime = 0;
7307
6561
  let endTime = _now();
7308
6562
  if (startMark) {
7309
6563
  const s = _entries.find((e) => e.entryType === "mark" && e.name === startMark);
7310
- if (s) startTime2 = s.startTime;
6564
+ if (s) startTime = s.startTime;
7311
6565
  }
7312
6566
  if (endMark) {
7313
6567
  const e = _entries.find((e2) => e2.entryType === "mark" && e2.name === endMark);
7314
6568
  if (e) endTime = e.startTime;
7315
6569
  }
7316
- const entry = { name: name2, entryType: "measure", startTime: startTime2, duration: endTime - startTime2 };
6570
+ const entry = { name: name2, entryType: "measure", startTime, duration: endTime - startTime };
7317
6571
  _entries.push(entry);
7318
6572
  return entry;
7319
6573
  },
@@ -7396,8 +6650,8 @@ var init_esm9 = __esm({
7396
6650
  var init_performance = __esm({
7397
6651
  "../../../packages/web/web-globals/lib/esm/register/performance.js"() {
7398
6652
  init_console_gjs();
7399
- init_auto_globals_495e9d950c();
7400
- init_esm9();
6653
+ init_auto_globals_97a682e619();
6654
+ init_esm7();
7401
6655
  if (typeof globalThis.performance === "undefined") {
7402
6656
  globalThis.performance = performance2;
7403
6657
  }
@@ -7409,10 +6663,10 @@ var init_performance = __esm({
7409
6663
 
7410
6664
  // ../../../packages/web/abort-controller/lib/esm/index.js
7411
6665
  var kAbort, kInternal, AbortSignal2, AbortController2;
7412
- var init_esm10 = __esm({
6666
+ var init_esm8 = __esm({
7413
6667
  "../../../packages/web/abort-controller/lib/esm/index.js"() {
7414
6668
  init_console_gjs();
7415
- init_auto_globals_495e9d950c();
6669
+ init_auto_globals_97a682e619();
7416
6670
  init_esm4();
7417
6671
  kAbort = /* @__PURE__ */ Symbol("abort");
7418
6672
  kInternal = /* @__PURE__ */ Symbol("internal");
@@ -7501,8 +6755,8 @@ var init_esm10 = __esm({
7501
6755
  var init_register2 = __esm({
7502
6756
  "../../../packages/web/abort-controller/lib/esm/register.js"() {
7503
6757
  init_console_gjs();
7504
- init_auto_globals_495e9d950c();
7505
- init_esm10();
6758
+ init_auto_globals_97a682e619();
6759
+ init_esm8();
7506
6760
  if (typeof globalThis.AbortController === "undefined") {
7507
6761
  globalThis.AbortController = AbortController2;
7508
6762
  }
@@ -7517,7 +6771,7 @@ var toRegister;
7517
6771
  var init_custom_events = __esm({
7518
6772
  "../../../packages/web/dom-events/lib/esm/register/custom-events.js"() {
7519
6773
  init_console_gjs();
7520
- init_auto_globals_495e9d950c();
6774
+ init_auto_globals_97a682e619();
7521
6775
  init_esm4();
7522
6776
  toRegister = {
7523
6777
  CustomEvent: CustomEvent2,
@@ -7538,7 +6792,7 @@ var init_custom_events = __esm({
7538
6792
  var init_register3 = __esm({
7539
6793
  "../../../packages/web/dom-exception/lib/esm/register.js"() {
7540
6794
  init_console_gjs();
7541
- init_auto_globals_495e9d950c();
6795
+ init_auto_globals_97a682e619();
7542
6796
  init_esm3();
7543
6797
  if (typeof globalThis.DOMException === "undefined") {
7544
6798
  globalThis.DOMException = DOMException2;
@@ -7546,9 +6800,9 @@ var init_register3 = __esm({
7546
6800
  }
7547
6801
  });
7548
6802
 
7549
- // node_modules/.cache/gjsify/auto-globals-495e9d950c.mjs
7550
- var init_auto_globals_495e9d950c = __esm({
7551
- "node_modules/.cache/gjsify/auto-globals-495e9d950c.mjs"() {
6803
+ // node_modules/.cache/gjsify/auto-globals-97a682e619.mjs
6804
+ var init_auto_globals_97a682e619 = __esm({
6805
+ "node_modules/.cache/gjsify/auto-globals-97a682e619.mjs"() {
7552
6806
  init_register();
7553
6807
  init_canvas();
7554
6808
  init_document2();
@@ -7556,8 +6810,7 @@ var init_auto_globals_495e9d950c = __esm({
7556
6810
  init_navigator();
7557
6811
  init_buffer2();
7558
6812
  init_encoding2();
7559
- init_microtask();
7560
- init_process();
6813
+ init_timers();
7561
6814
  init_url();
7562
6815
  init_performance();
7563
6816
  init_register2();
@@ -7572,7 +6825,7 @@ var require_twiddle = __commonJS({
7572
6825
  "use strict";
7573
6826
  "use restrict";
7574
6827
  init_console_gjs();
7575
- init_auto_globals_495e9d950c();
6828
+ init_auto_globals_97a682e619();
7576
6829
  var INT_BITS = 32;
7577
6830
  exports.INT_BITS = INT_BITS;
7578
6831
  exports.INT_MAX = 2147483647;
@@ -7727,7 +6980,7 @@ var require_twiddle = __commonJS({
7727
6980
  var require_literals = __commonJS({
7728
6981
  "../../../node_modules/glsl-tokenizer/lib/literals.js"(exports, module) {
7729
6982
  init_console_gjs();
7730
- init_auto_globals_495e9d950c();
6983
+ init_auto_globals_97a682e619();
7731
6984
  module.exports = [
7732
6985
  // current
7733
6986
  "precision",
@@ -7827,7 +7080,7 @@ var require_literals = __commonJS({
7827
7080
  var require_operators = __commonJS({
7828
7081
  "../../../node_modules/glsl-tokenizer/lib/operators.js"(exports, module) {
7829
7082
  init_console_gjs();
7830
- init_auto_globals_495e9d950c();
7083
+ init_auto_globals_97a682e619();
7831
7084
  module.exports = [
7832
7085
  "<<=",
7833
7086
  ">>=",
@@ -7882,7 +7135,7 @@ var require_operators = __commonJS({
7882
7135
  var require_builtins = __commonJS({
7883
7136
  "../../../node_modules/glsl-tokenizer/lib/builtins.js"(exports, module) {
7884
7137
  init_console_gjs();
7885
- init_auto_globals_495e9d950c();
7138
+ init_auto_globals_97a682e619();
7886
7139
  module.exports = [
7887
7140
  // Keep this list sorted
7888
7141
  "abs",
@@ -8040,7 +7293,7 @@ var require_builtins = __commonJS({
8040
7293
  var require_literals_300es = __commonJS({
8041
7294
  "../../../node_modules/glsl-tokenizer/lib/literals-300es.js"(exports, module) {
8042
7295
  init_console_gjs();
8043
- init_auto_globals_495e9d950c();
7296
+ init_auto_globals_97a682e619();
8044
7297
  var v100 = require_literals();
8045
7298
  module.exports = v100.slice().concat([
8046
7299
  "layout",
@@ -8134,7 +7387,7 @@ var require_literals_300es = __commonJS({
8134
7387
  var require_builtins_300es = __commonJS({
8135
7388
  "../../../node_modules/glsl-tokenizer/lib/builtins-300es.js"(exports, module) {
8136
7389
  init_console_gjs();
8137
- init_auto_globals_495e9d950c();
7390
+ init_auto_globals_97a682e619();
8138
7391
  var v100 = require_builtins();
8139
7392
  v100 = v100.slice().filter(function(b) {
8140
7393
  return !/^(gl\_|texture)/.test(b);
@@ -8204,7 +7457,7 @@ var require_builtins_300es = __commonJS({
8204
7457
  var require_glsl_tokenizer = __commonJS({
8205
7458
  "../../../node_modules/glsl-tokenizer/index.js"(exports, module) {
8206
7459
  init_console_gjs();
8207
- init_auto_globals_495e9d950c();
7460
+ init_auto_globals_97a682e619();
8208
7461
  module.exports = tokenize2;
8209
7462
  var literals100 = require_literals();
8210
7463
  var operators = require_operators();
@@ -8537,7 +7790,7 @@ var require_glsl_tokenizer = __commonJS({
8537
7790
  var require_string = __commonJS({
8538
7791
  "../../../node_modules/glsl-tokenizer/string.js"(exports, module) {
8539
7792
  init_console_gjs();
8540
- init_auto_globals_495e9d950c();
7793
+ init_auto_globals_97a682e619();
8541
7794
  var tokenize2 = require_glsl_tokenizer();
8542
7795
  module.exports = tokenizeString;
8543
7796
  function tokenizeString(str, opt) {
@@ -8552,71 +7805,71 @@ var require_string = __commonJS({
8552
7805
 
8553
7806
  // src/gjs/gjs.ts
8554
7807
  init_console_gjs();
8555
- init_auto_globals_495e9d950c();
7808
+ init_auto_globals_97a682e619();
8556
7809
  import Adw2 from "gi://Adw?version=1";
8557
7810
  import Gio2 from "gi://Gio?version=2.0";
8558
7811
 
8559
7812
  // src/gjs/pixel-window.ts
8560
7813
  init_console_gjs();
8561
- init_auto_globals_495e9d950c();
7814
+ init_auto_globals_97a682e619();
8562
7815
  import GObject2 from "gi://GObject?version=2.0";
8563
7816
  import GLib3 from "gi://GLib?version=2.0";
8564
7817
  import Gtk4 from "gi://Gtk?version=4.0";
8565
7818
  import Adw from "gi://Adw?version=1";
8566
7819
 
8567
- // ../../../packages/dom/webgl/lib/esm/index.js
7820
+ // ../../../packages/framework/webgl/lib/esm/index.js
8568
7821
  init_console_gjs();
8569
- init_auto_globals_495e9d950c();
7822
+ init_auto_globals_97a682e619();
8570
7823
 
8571
7824
  // ../../../node_modules/@girs/gjs/index.js
8572
7825
  init_console_gjs();
8573
- init_auto_globals_495e9d950c();
7826
+ init_auto_globals_97a682e619();
8574
7827
 
8575
7828
  // ../../../node_modules/@girs/gjs/gjs.js
8576
7829
  init_console_gjs();
8577
- init_auto_globals_495e9d950c();
7830
+ init_auto_globals_97a682e619();
8578
7831
  var imports2 = globalThis.imports || {};
8579
7832
 
8580
- // ../../../packages/dom/webgl/lib/esm/index.js
7833
+ // ../../../packages/framework/webgl/lib/esm/index.js
8581
7834
  init_gio_2();
8582
7835
 
8583
7836
  // ../../../node_modules/@girs/gtk-4.0/index.js
8584
7837
  init_console_gjs();
8585
- init_auto_globals_495e9d950c();
7838
+ init_auto_globals_97a682e619();
8586
7839
 
8587
7840
  // ../../../node_modules/@girs/gtk-4.0/gtk-4.0.js
8588
7841
  init_console_gjs();
8589
- init_auto_globals_495e9d950c();
7842
+ init_auto_globals_97a682e619();
8590
7843
  import Gtk from "gi://Gtk?version=4.0";
8591
7844
 
8592
- // ../../../packages/dom/webgl/lib/esm/webgl-rendering-context.js
7845
+ // ../../../packages/framework/webgl/lib/esm/webgl-rendering-context.js
8593
7846
  init_console_gjs();
8594
- init_auto_globals_495e9d950c();
7847
+ init_auto_globals_97a682e619();
8595
7848
 
8596
7849
  // ../../../node_modules/@girs/gwebgl-0.1/index.js
8597
7850
  init_console_gjs();
8598
- init_auto_globals_495e9d950c();
7851
+ init_auto_globals_97a682e619();
8599
7852
 
8600
7853
  // ../../../node_modules/@girs/gwebgl-0.1/gwebgl-0.1.js
8601
7854
  init_console_gjs();
8602
- init_auto_globals_495e9d950c();
7855
+ init_auto_globals_97a682e619();
8603
7856
  import Gwebgl from "gi://Gwebgl?version=0.1";
8604
7857
  var gwebgl_0_1_default = Gwebgl;
8605
7858
 
8606
7859
  // ../../../node_modules/@girs/gwebgl-0.1/index.js
8607
7860
  var gwebgl_0_default = gwebgl_0_1_default;
8608
7861
 
8609
- // ../../../packages/dom/webgl/lib/esm/webgl-context-base.js
7862
+ // ../../../packages/framework/webgl/lib/esm/webgl-context-base.js
8610
7863
  init_console_gjs();
8611
- init_auto_globals_495e9d950c();
7864
+ init_auto_globals_97a682e619();
8612
7865
  init_gdkpixbuf_2();
8613
7866
  var bits = __toESM(require_twiddle(), 1);
8614
7867
  var import_string = __toESM(require_string(), 1);
8615
7868
  import GdkPixbuf3 from "gi://GdkPixbuf?version=2.0";
8616
7869
 
8617
- // ../../../packages/dom/webgl/lib/esm/webgl-context-attributes.js
7870
+ // ../../../packages/framework/webgl/lib/esm/webgl-context-attributes.js
8618
7871
  init_console_gjs();
8619
- init_auto_globals_495e9d950c();
7872
+ init_auto_globals_97a682e619();
8620
7873
  var WebGLContextAttributes = class {
8621
7874
  constructor(alpha, depth, stencil, antialias, premultipliedAlpha, preserveDrawingBuffer, preferLowPowerToHighPerformance, failIfMajorPerformanceCaveat) {
8622
7875
  this.alpha = alpha;
@@ -8638,13 +7891,13 @@ var WebGLContextAttributes = class {
8638
7891
  }
8639
7892
  };
8640
7893
 
8641
- // ../../../packages/dom/webgl/lib/esm/utils.js
7894
+ // ../../../packages/framework/webgl/lib/esm/utils.js
8642
7895
  init_console_gjs();
8643
- init_auto_globals_495e9d950c();
7896
+ init_auto_globals_97a682e619();
8644
7897
 
8645
- // ../../../packages/dom/webgl/lib/esm/webgl-uniform-location.js
7898
+ // ../../../packages/framework/webgl/lib/esm/webgl-uniform-location.js
8646
7899
  init_console_gjs();
8647
- init_auto_globals_495e9d950c();
7900
+ init_auto_globals_97a682e619();
8648
7901
  var WebGLUniformLocation = class {
8649
7902
  constructor(_, program, info2) {
8650
7903
  this._linkCount = 0;
@@ -8657,7 +7910,7 @@ var WebGLUniformLocation = class {
8657
7910
  }
8658
7911
  };
8659
7912
 
8660
- // ../../../packages/dom/webgl/lib/esm/utils.js
7913
+ // ../../../packages/framework/webgl/lib/esm/utils.js
8661
7914
  init_glib_2();
8662
7915
  function checkObject(object) {
8663
7916
  return typeof object === "object" || object === void 0;
@@ -8840,9 +8093,9 @@ function premultiplyAlpha(data) {
8840
8093
  return out;
8841
8094
  }
8842
8095
 
8843
- // ../../../packages/dom/webgl/lib/esm/extensions/oes-element-index-unit.js
8096
+ // ../../../packages/framework/webgl/lib/esm/extensions/oes-element-index-unit.js
8844
8097
  init_console_gjs();
8845
- init_auto_globals_495e9d950c();
8098
+ init_auto_globals_97a682e619();
8846
8099
  var OESElementIndexUint = class {
8847
8100
  };
8848
8101
  function getOESElementIndexUint(context) {
@@ -8854,9 +8107,9 @@ function getOESElementIndexUint(context) {
8854
8107
  return result;
8855
8108
  }
8856
8109
 
8857
- // ../../../packages/dom/webgl/lib/esm/extensions/oes-standard-derivatives.js
8110
+ // ../../../packages/framework/webgl/lib/esm/extensions/oes-standard-derivatives.js
8858
8111
  init_console_gjs();
8859
- init_auto_globals_495e9d950c();
8112
+ init_auto_globals_97a682e619();
8860
8113
  var OESStandardDerivatives = class {
8861
8114
  constructor() {
8862
8115
  this.FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 35723;
@@ -8871,9 +8124,9 @@ function getOESStandardDerivatives(context) {
8871
8124
  return result;
8872
8125
  }
8873
8126
 
8874
- // ../../../packages/dom/webgl/lib/esm/extensions/oes-texture-float.js
8127
+ // ../../../packages/framework/webgl/lib/esm/extensions/oes-texture-float.js
8875
8128
  init_console_gjs();
8876
- init_auto_globals_495e9d950c();
8129
+ init_auto_globals_97a682e619();
8877
8130
  var OESTextureFloat = class {
8878
8131
  };
8879
8132
  function getOESTextureFloat(context) {
@@ -8885,9 +8138,9 @@ function getOESTextureFloat(context) {
8885
8138
  return result;
8886
8139
  }
8887
8140
 
8888
- // ../../../packages/dom/webgl/lib/esm/extensions/oes-texture-float-linear.js
8141
+ // ../../../packages/framework/webgl/lib/esm/extensions/oes-texture-float-linear.js
8889
8142
  init_console_gjs();
8890
- init_auto_globals_495e9d950c();
8143
+ init_auto_globals_97a682e619();
8891
8144
  var OESTextureFloatLinear = class {
8892
8145
  };
8893
8146
  function getOESTextureFloatLinear(context) {
@@ -8899,9 +8152,9 @@ function getOESTextureFloatLinear(context) {
8899
8152
  return result;
8900
8153
  }
8901
8154
 
8902
- // ../../../packages/dom/webgl/lib/esm/extensions/stackgl-destroy-context.js
8155
+ // ../../../packages/framework/webgl/lib/esm/extensions/stackgl-destroy-context.js
8903
8156
  init_console_gjs();
8904
- init_auto_globals_495e9d950c();
8157
+ init_auto_globals_97a682e619();
8905
8158
  var STACKGLDestroyContext = class {
8906
8159
  constructor(ctx) {
8907
8160
  this.destroy = ctx.destroy.bind(ctx);
@@ -8911,9 +8164,9 @@ function getSTACKGLDestroyContext(ctx) {
8911
8164
  return new STACKGLDestroyContext(ctx);
8912
8165
  }
8913
8166
 
8914
- // ../../../packages/dom/webgl/lib/esm/extensions/stackgl-resize-drawing-buffer.js
8167
+ // ../../../packages/framework/webgl/lib/esm/extensions/stackgl-resize-drawing-buffer.js
8915
8168
  init_console_gjs();
8916
- init_auto_globals_495e9d950c();
8169
+ init_auto_globals_97a682e619();
8917
8170
  var STACKGLResizeDrawingBuffer = class {
8918
8171
  constructor(ctx) {
8919
8172
  this.resize = ctx.resize.bind(ctx);
@@ -8923,9 +8176,9 @@ function getSTACKGLResizeDrawingBuffer(ctx) {
8923
8176
  return new STACKGLResizeDrawingBuffer(ctx);
8924
8177
  }
8925
8178
 
8926
- // ../../../packages/dom/webgl/lib/esm/extensions/ext-blend-minmax.js
8179
+ // ../../../packages/framework/webgl/lib/esm/extensions/ext-blend-minmax.js
8927
8180
  init_console_gjs();
8928
- init_auto_globals_495e9d950c();
8181
+ init_auto_globals_97a682e619();
8929
8182
  var EXTBlendMinMax = class {
8930
8183
  constructor() {
8931
8184
  this.MIN_EXT = 32775;
@@ -8941,9 +8194,9 @@ function getEXTBlendMinMax(context) {
8941
8194
  return result;
8942
8195
  }
8943
8196
 
8944
- // ../../../packages/dom/webgl/lib/esm/extensions/ext-color-buffer-float.js
8197
+ // ../../../packages/framework/webgl/lib/esm/extensions/ext-color-buffer-float.js
8945
8198
  init_console_gjs();
8946
- init_auto_globals_495e9d950c();
8199
+ init_auto_globals_97a682e619();
8947
8200
  var EXTColorBufferFloat = class {
8948
8201
  };
8949
8202
  function getEXTColorBufferFloat(context) {
@@ -8954,9 +8207,9 @@ function getEXTColorBufferFloat(context) {
8954
8207
  return null;
8955
8208
  }
8956
8209
 
8957
- // ../../../packages/dom/webgl/lib/esm/extensions/ext-color-buffer-half-float.js
8210
+ // ../../../packages/framework/webgl/lib/esm/extensions/ext-color-buffer-half-float.js
8958
8211
  init_console_gjs();
8959
- init_auto_globals_495e9d950c();
8212
+ init_auto_globals_97a682e619();
8960
8213
  var EXTColorBufferHalfFloat = class {
8961
8214
  };
8962
8215
  function getEXTColorBufferHalfFloat(context) {
@@ -8967,9 +8220,9 @@ function getEXTColorBufferHalfFloat(context) {
8967
8220
  return null;
8968
8221
  }
8969
8222
 
8970
- // ../../../packages/dom/webgl/lib/esm/extensions/ext-texture-filter-anisotropic.js
8223
+ // ../../../packages/framework/webgl/lib/esm/extensions/ext-texture-filter-anisotropic.js
8971
8224
  init_console_gjs();
8972
- init_auto_globals_495e9d950c();
8225
+ init_auto_globals_97a682e619();
8973
8226
  var EXTTextureFilterAnisotropic = class {
8974
8227
  constructor() {
8975
8228
  this.TEXTURE_MAX_ANISOTROPY_EXT = 34046;
@@ -8985,9 +8238,9 @@ function getEXTTextureFilterAnisotropic(context) {
8985
8238
  return result;
8986
8239
  }
8987
8240
 
8988
- // ../../../packages/dom/webgl/lib/esm/extensions/oes-texture-half-float.js
8241
+ // ../../../packages/framework/webgl/lib/esm/extensions/oes-texture-half-float.js
8989
8242
  init_console_gjs();
8990
- init_auto_globals_495e9d950c();
8243
+ init_auto_globals_97a682e619();
8991
8244
  var OESTextureHalfFloat = class {
8992
8245
  constructor() {
8993
8246
  this.HALF_FLOAT_OES = 36193;
@@ -9004,9 +8257,9 @@ function getOESTextureHalfFloat(context) {
9004
8257
  return null;
9005
8258
  }
9006
8259
 
9007
- // ../../../packages/dom/webgl/lib/esm/webgl-active-info.js
8260
+ // ../../../packages/framework/webgl/lib/esm/webgl-active-info.js
9008
8261
  init_console_gjs();
9009
- init_auto_globals_495e9d950c();
8262
+ init_auto_globals_97a682e619();
9010
8263
  var WebGLActiveInfo = class {
9011
8264
  constructor(_) {
9012
8265
  this.size = _.size;
@@ -9015,13 +8268,13 @@ var WebGLActiveInfo = class {
9015
8268
  }
9016
8269
  };
9017
8270
 
9018
- // ../../../packages/dom/webgl/lib/esm/webgl-framebuffer.js
8271
+ // ../../../packages/framework/webgl/lib/esm/webgl-framebuffer.js
9019
8272
  init_console_gjs();
9020
- init_auto_globals_495e9d950c();
8273
+ init_auto_globals_97a682e619();
9021
8274
 
9022
- // ../../../packages/dom/webgl/lib/esm/linkable.js
8275
+ // ../../../packages/framework/webgl/lib/esm/linkable.js
9023
8276
  init_console_gjs();
9024
- init_auto_globals_495e9d950c();
8277
+ init_auto_globals_97a682e619();
9025
8278
  var Linkable = class {
9026
8279
  constructor(_) {
9027
8280
  this._ = 0;
@@ -9070,7 +8323,7 @@ var Linkable = class {
9070
8323
  }
9071
8324
  };
9072
8325
 
9073
- // ../../../packages/dom/webgl/lib/esm/webgl-framebuffer.js
8326
+ // ../../../packages/framework/webgl/lib/esm/webgl-framebuffer.js
9074
8327
  var WebGLFramebuffer = class extends Linkable {
9075
8328
  constructor(_, ctx) {
9076
8329
  super(_);
@@ -9176,9 +8429,9 @@ var WebGLFramebuffer = class extends Linkable {
9176
8429
  }
9177
8430
  };
9178
8431
 
9179
- // ../../../packages/dom/webgl/lib/esm/webgl-buffer.js
8432
+ // ../../../packages/framework/webgl/lib/esm/webgl-buffer.js
9180
8433
  init_console_gjs();
9181
- init_auto_globals_495e9d950c();
8434
+ init_auto_globals_97a682e619();
9182
8435
  var WebGLBuffer = class extends Linkable {
9183
8436
  constructor(_, ctx) {
9184
8437
  super(_);
@@ -9193,9 +8446,9 @@ var WebGLBuffer = class extends Linkable {
9193
8446
  }
9194
8447
  };
9195
8448
 
9196
- // ../../../packages/dom/webgl/lib/esm/webgl-drawing-buffer-wrapper.js
8449
+ // ../../../packages/framework/webgl/lib/esm/webgl-drawing-buffer-wrapper.js
9197
8450
  init_console_gjs();
9198
- init_auto_globals_495e9d950c();
8451
+ init_auto_globals_97a682e619();
9199
8452
  var WebGLDrawingBufferWrapper = class {
9200
8453
  constructor(framebuffer, color, depthStencil) {
9201
8454
  this._framebuffer = framebuffer;
@@ -9204,9 +8457,9 @@ var WebGLDrawingBufferWrapper = class {
9204
8457
  }
9205
8458
  };
9206
8459
 
9207
- // ../../../packages/dom/webgl/lib/esm/webgl-program.js
8460
+ // ../../../packages/framework/webgl/lib/esm/webgl-program.js
9208
8461
  init_console_gjs();
9209
- init_auto_globals_495e9d950c();
8462
+ init_auto_globals_97a682e619();
9210
8463
  var WebGLProgram = class extends Linkable {
9211
8464
  constructor(_, ctx) {
9212
8465
  super(_);
@@ -9229,9 +8482,9 @@ var WebGLProgram = class extends Linkable {
9229
8482
  }
9230
8483
  };
9231
8484
 
9232
- // ../../../packages/dom/webgl/lib/esm/webgl-renderbuffer.js
8485
+ // ../../../packages/framework/webgl/lib/esm/webgl-renderbuffer.js
9233
8486
  init_console_gjs();
9234
- init_auto_globals_495e9d950c();
8487
+ init_auto_globals_97a682e619();
9235
8488
  var WebGLRenderbuffer = class extends Linkable {
9236
8489
  constructor(_, ctx) {
9237
8490
  super(_);
@@ -9252,9 +8505,9 @@ var WebGLRenderbuffer = class extends Linkable {
9252
8505
  }
9253
8506
  };
9254
8507
 
9255
- // ../../../packages/dom/webgl/lib/esm/webgl-shader.js
8508
+ // ../../../packages/framework/webgl/lib/esm/webgl-shader.js
9256
8509
  init_console_gjs();
9257
- init_auto_globals_495e9d950c();
8510
+ init_auto_globals_97a682e619();
9258
8511
  var WebGLShader = class extends Linkable {
9259
8512
  constructor(_, ctx, type) {
9260
8513
  super(_);
@@ -9275,9 +8528,9 @@ var WebGLShader = class extends Linkable {
9275
8528
  }
9276
8529
  };
9277
8530
 
9278
- // ../../../packages/dom/webgl/lib/esm/webgl-shader-precision-format.js
8531
+ // ../../../packages/framework/webgl/lib/esm/webgl-shader-precision-format.js
9279
8532
  init_console_gjs();
9280
- init_auto_globals_495e9d950c();
8533
+ init_auto_globals_97a682e619();
9281
8534
  var WebGLShaderPrecisionFormat = class {
9282
8535
  constructor(_) {
9283
8536
  this.rangeMin = _.rangeMin;
@@ -9286,9 +8539,9 @@ var WebGLShaderPrecisionFormat = class {
9286
8539
  }
9287
8540
  };
9288
8541
 
9289
- // ../../../packages/dom/webgl/lib/esm/webgl-texture-unit.js
8542
+ // ../../../packages/framework/webgl/lib/esm/webgl-texture-unit.js
9290
8543
  init_console_gjs();
9291
- init_auto_globals_495e9d950c();
8544
+ init_auto_globals_97a682e619();
9292
8545
  var WebGLTextureUnit = class {
9293
8546
  constructor(ctx, idx) {
9294
8547
  this._mode = 0;
@@ -9299,9 +8552,9 @@ var WebGLTextureUnit = class {
9299
8552
  }
9300
8553
  };
9301
8554
 
9302
- // ../../../packages/dom/webgl/lib/esm/webgl-texture.js
8555
+ // ../../../packages/framework/webgl/lib/esm/webgl-texture.js
9303
8556
  init_console_gjs();
9304
- init_auto_globals_495e9d950c();
8557
+ init_auto_globals_97a682e619();
9305
8558
  var WebGLTexture = class extends Linkable {
9306
8559
  constructor(_, ctx) {
9307
8560
  super(_);
@@ -9320,9 +8573,9 @@ var WebGLTexture = class extends Linkable {
9320
8573
  }
9321
8574
  };
9322
8575
 
9323
- // ../../../packages/dom/webgl/lib/esm/webgl-vertex-attribute.js
8576
+ // ../../../packages/framework/webgl/lib/esm/webgl-vertex-attribute.js
9324
8577
  init_console_gjs();
9325
- init_auto_globals_495e9d950c();
8578
+ init_auto_globals_97a682e619();
9326
8579
  var WebGLVertexArrayObjectAttribute = class {
9327
8580
  constructor(ctx, idx) {
9328
8581
  this._isPointer = false;
@@ -9464,7 +8717,7 @@ var WebGLVertexArrayGlobalState = class {
9464
8717
  }
9465
8718
  };
9466
8719
 
9467
- // ../../../packages/dom/webgl/lib/esm/webgl-context-base.js
8720
+ // ../../../packages/framework/webgl/lib/esm/webgl-context-base.js
9468
8721
  init_esm();
9469
8722
  var VERSION = "0.0.1";
9470
8723
  var CONTEXT_COUNTER = 0;
@@ -10256,9 +9509,9 @@ var WebGLContextBase = class {
10256
9509
  const glArea = this.canvas.getGlArea();
10257
9510
  const es = glArea.get_use_es();
10258
9511
  const usesGlsl1Syntax = /\b(attribute|varying)\b/.test(source);
10259
- const version2 = usesGlsl1Syntax ? es ? "100" : "120" : this._getGlslVersion(es);
10260
- if (version2) {
10261
- source = "#version " + version2 + "\n" + preamble + source;
9512
+ const version = usesGlsl1Syntax ? es ? "100" : "120" : this._getGlslVersion(es);
9513
+ if (version) {
9514
+ source = "#version " + version + "\n" + preamble + source;
10262
9515
  } else if (preamble) {
10263
9516
  source = preamble + source;
10264
9517
  }
@@ -12789,7 +12042,7 @@ var WebGLContextBase = class {
12789
12042
  }
12790
12043
  };
12791
12044
 
12792
- // ../../../packages/dom/webgl/lib/esm/webgl-rendering-context.js
12045
+ // ../../../packages/framework/webgl/lib/esm/webgl-rendering-context.js
12793
12046
  var WebGLRenderingContext2 = class extends WebGLContextBase {
12794
12047
  constructor(canvas, options = {}) {
12795
12048
  super(canvas, options);
@@ -12972,14 +12225,14 @@ var WebGLRenderingContext2 = class extends WebGLContextBase {
12972
12225
  }
12973
12226
  };
12974
12227
 
12975
- // ../../../packages/dom/webgl/lib/esm/webgl2-rendering-context.js
12228
+ // ../../../packages/framework/webgl/lib/esm/webgl2-rendering-context.js
12976
12229
  init_console_gjs();
12977
- init_auto_globals_495e9d950c();
12230
+ init_auto_globals_97a682e619();
12978
12231
  import GdkPixbuf4 from "gi://GdkPixbuf?version=2.0";
12979
12232
 
12980
- // ../../../packages/dom/webgl/lib/esm/webgl-query.js
12233
+ // ../../../packages/framework/webgl/lib/esm/webgl-query.js
12981
12234
  init_console_gjs();
12982
- init_auto_globals_495e9d950c();
12235
+ init_auto_globals_97a682e619();
12983
12236
  var WebGLQuery = class extends Linkable {
12984
12237
  constructor(_, ctx) {
12985
12238
  super(_);
@@ -12992,9 +12245,9 @@ var WebGLQuery = class extends Linkable {
12992
12245
  }
12993
12246
  };
12994
12247
 
12995
- // ../../../packages/dom/webgl/lib/esm/webgl-sampler.js
12248
+ // ../../../packages/framework/webgl/lib/esm/webgl-sampler.js
12996
12249
  init_console_gjs();
12997
- init_auto_globals_495e9d950c();
12250
+ init_auto_globals_97a682e619();
12998
12251
  var WebGLSampler = class extends Linkable {
12999
12252
  constructor(_, ctx) {
13000
12253
  super(_);
@@ -13007,9 +12260,9 @@ var WebGLSampler = class extends Linkable {
13007
12260
  }
13008
12261
  };
13009
12262
 
13010
- // ../../../packages/dom/webgl/lib/esm/webgl-sync.js
12263
+ // ../../../packages/framework/webgl/lib/esm/webgl-sync.js
13011
12264
  init_console_gjs();
13012
- init_auto_globals_495e9d950c();
12265
+ init_auto_globals_97a682e619();
13013
12266
  var WebGLSync = class extends Linkable {
13014
12267
  constructor(_, ctx) {
13015
12268
  super(_);
@@ -13022,9 +12275,9 @@ var WebGLSync = class extends Linkable {
13022
12275
  }
13023
12276
  };
13024
12277
 
13025
- // ../../../packages/dom/webgl/lib/esm/webgl-transform-feedback.js
12278
+ // ../../../packages/framework/webgl/lib/esm/webgl-transform-feedback.js
13026
12279
  init_console_gjs();
13027
- init_auto_globals_495e9d950c();
12280
+ init_auto_globals_97a682e619();
13028
12281
  var WebGLTransformFeedback = class extends Linkable {
13029
12282
  constructor(_, ctx) {
13030
12283
  super(_);
@@ -13037,9 +12290,9 @@ var WebGLTransformFeedback = class extends Linkable {
13037
12290
  }
13038
12291
  };
13039
12292
 
13040
- // ../../../packages/dom/webgl/lib/esm/webgl-vertex-array-object.js
12293
+ // ../../../packages/framework/webgl/lib/esm/webgl-vertex-array-object.js
13041
12294
  init_console_gjs();
13042
- init_auto_globals_495e9d950c();
12295
+ init_auto_globals_97a682e619();
13043
12296
  var WebGLVertexArrayObject = class extends Linkable {
13044
12297
  constructor(_, ctx) {
13045
12298
  super(_);
@@ -13057,7 +12310,7 @@ var WebGLVertexArrayObject = class extends Linkable {
13057
12310
  }
13058
12311
  };
13059
12312
 
13060
- // ../../../packages/dom/webgl/lib/esm/webgl2-rendering-context.js
12313
+ // ../../../packages/framework/webgl/lib/esm/webgl2-rendering-context.js
13061
12314
  init_esm();
13062
12315
  var WebGL2RenderingContext = class _WebGL2RenderingContext extends WebGLContextBase {
13063
12316
  constructor(canvas, options = {}) {
@@ -13867,8 +13120,18 @@ var WebGL2RenderingContext = class _WebGL2RenderingContext extends WebGLContextB
13867
13120
  this._native2.vertexAttribIPointer(index, size, type, stride, offset);
13868
13121
  }
13869
13122
  drawBuffers(buffers) {
13870
- const mapped = buffers.map((b) => b === 1029 ? this.COLOR_ATTACHMENT0 : b);
13871
- this._native2.drawBuffers(Array.from(mapped));
13123
+ let hasBack = false;
13124
+ for (let i = 0; i < buffers.length; i++) {
13125
+ if (buffers[i] === 1029) {
13126
+ hasBack = true;
13127
+ break;
13128
+ }
13129
+ }
13130
+ if (!hasBack) {
13131
+ this._native2.drawBuffers(buffers);
13132
+ return;
13133
+ }
13134
+ this._native2.drawBuffers(buffers.map((b) => b === 1029 ? this.COLOR_ATTACHMENT0 : b));
13872
13135
  }
13873
13136
  drawRangeElements(mode, start2, end, count2, type, offset) {
13874
13137
  if (count2 < 0 || offset < 0) {
@@ -13965,10 +13228,10 @@ var WebGL2RenderingContext = class _WebGL2RenderingContext extends WebGLContextB
13965
13228
  void drawbuffer;
13966
13229
  }
13967
13230
  invalidateFramebuffer(target, attachments) {
13968
- this._native2.invalidateFramebuffer(target, Array.from(attachments));
13231
+ this._native2.invalidateFramebuffer(target, attachments);
13969
13232
  }
13970
13233
  invalidateSubFramebuffer(target, attachments, x, y, width, height) {
13971
- this._native2.invalidateSubFramebuffer(target, Array.from(attachments), x, y, width, height);
13234
+ this._native2.invalidateSubFramebuffer(target, attachments, x, y, width, height);
13972
13235
  }
13973
13236
  readBuffer(src) {
13974
13237
  this._native2.readBuffer(src);
@@ -14012,53 +13275,53 @@ var WebGL2RenderingContext = class _WebGL2RenderingContext extends WebGLContextB
14012
13275
  uniform1uiv(location, data, _srcOffset, _srcLength) {
14013
13276
  if (!location) return;
14014
13277
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
14015
- this._native2.uniform1uiv(location._, arr.length, Array.from(arr));
13278
+ this._native2.uniform1uiv(location._, arr.length, arr);
14016
13279
  }
14017
13280
  uniform2uiv(location, data, _srcOffset, _srcLength) {
14018
13281
  if (!location) return;
14019
13282
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
14020
- this._native2.uniform2uiv(location._, arr.length / 2, Array.from(arr));
13283
+ this._native2.uniform2uiv(location._, arr.length / 2, arr);
14021
13284
  }
14022
13285
  uniform3uiv(location, data, _srcOffset, _srcLength) {
14023
13286
  if (!location) return;
14024
13287
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
14025
- this._native2.uniform3uiv(location._, arr.length / 3, Array.from(arr));
13288
+ this._native2.uniform3uiv(location._, arr.length / 3, arr);
14026
13289
  }
14027
13290
  uniform4uiv(location, data, _srcOffset, _srcLength) {
14028
13291
  if (!location) return;
14029
13292
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
14030
- this._native2.uniform4uiv(location._, arr.length / 4, Array.from(arr));
13293
+ this._native2.uniform4uiv(location._, arr.length / 4, arr);
14031
13294
  }
14032
13295
  // ─── Non-square Matrix Uniforms ───────────────────────────────────────
14033
13296
  uniformMatrix2x3fv(location, transpose, data, _srcOffset, _srcLength) {
14034
13297
  if (!location) return;
14035
13298
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14036
- this._native2.uniformMatrix2x3fv(location._, transpose, Array.from(arr));
13299
+ this._native2.uniformMatrix2x3fv(location._, transpose, arr);
14037
13300
  }
14038
13301
  uniformMatrix3x2fv(location, transpose, data, _srcOffset, _srcLength) {
14039
13302
  if (!location) return;
14040
13303
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14041
- this._native2.uniformMatrix3x2fv(location._, transpose, Array.from(arr));
13304
+ this._native2.uniformMatrix3x2fv(location._, transpose, arr);
14042
13305
  }
14043
13306
  uniformMatrix2x4fv(location, transpose, data, _srcOffset, _srcLength) {
14044
13307
  if (!location) return;
14045
13308
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14046
- this._native2.uniformMatrix2x4fv(location._, transpose, Array.from(arr));
13309
+ this._native2.uniformMatrix2x4fv(location._, transpose, arr);
14047
13310
  }
14048
13311
  uniformMatrix4x2fv(location, transpose, data, _srcOffset, _srcLength) {
14049
13312
  if (!location) return;
14050
13313
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14051
- this._native2.uniformMatrix4x2fv(location._, transpose, Array.from(arr));
13314
+ this._native2.uniformMatrix4x2fv(location._, transpose, arr);
14052
13315
  }
14053
13316
  uniformMatrix3x4fv(location, transpose, data, _srcOffset, _srcLength) {
14054
13317
  if (!location) return;
14055
13318
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14056
- this._native2.uniformMatrix3x4fv(location._, transpose, Array.from(arr));
13319
+ this._native2.uniformMatrix3x4fv(location._, transpose, arr);
14057
13320
  }
14058
13321
  uniformMatrix4x3fv(location, transpose, data, _srcOffset, _srcLength) {
14059
13322
  if (!location) return;
14060
13323
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14061
- this._native2.uniformMatrix4x3fv(location._, transpose, Array.from(arr));
13324
+ this._native2.uniformMatrix4x3fv(location._, transpose, arr);
14062
13325
  }
14063
13326
  // ─── getUniform — WebGL2 uint type support ────────────────────────────
14064
13327
  /** WebGL1 getUniform falls to default:null for UNSIGNED_INT types. Handle them here. */
@@ -14313,16 +13576,16 @@ var WebGL2RenderingContext = class _WebGL2RenderingContext extends WebGLContextB
14313
13576
  }
14314
13577
  };
14315
13578
 
14316
- // ../../../packages/dom/webgl/lib/esm/html-canvas-element.js
13579
+ // ../../../packages/framework/webgl/lib/esm/html-canvas-element.js
14317
13580
  init_console_gjs();
14318
- init_auto_globals_495e9d950c();
13581
+ init_auto_globals_97a682e619();
14319
13582
 
14320
13583
  // ../../../packages/dom/dom-elements/lib/esm/index.js
14321
13584
  init_console_gjs();
14322
- init_auto_globals_495e9d950c();
13585
+ init_auto_globals_97a682e619();
14323
13586
  init_html_canvas_element();
14324
13587
 
14325
- // ../../../packages/dom/webgl/lib/esm/html-canvas-element.js
13588
+ // ../../../packages/framework/webgl/lib/esm/html-canvas-element.js
14326
13589
  var HTMLCanvasElement3 = class extends HTMLCanvasElement2 {
14327
13590
  constructor(gtkGlArea) {
14328
13591
  super();
@@ -14383,27 +13646,27 @@ var HTMLCanvasElement3 = class extends HTMLCanvasElement2 {
14383
13646
  }
14384
13647
  };
14385
13648
 
14386
- // ../../../packages/dom/webgl/lib/esm/canvas-webgl-widget.js
13649
+ // ../../../packages/framework/webgl/lib/esm/webgl-bridge.js
14387
13650
  init_console_gjs();
14388
- init_auto_globals_495e9d950c();
13651
+ init_auto_globals_97a682e619();
14389
13652
  import GObject from "gi://GObject";
14390
13653
  import GLib2 from "gi://GLib?version=2.0";
14391
13654
  import Gtk3 from "gi://Gtk?version=4.0";
14392
13655
 
14393
- // ../../../packages/dom/event-bridge/lib/esm/index.js
13656
+ // ../../../packages/framework/event-bridge/lib/esm/index.js
14394
13657
  init_console_gjs();
14395
- init_auto_globals_495e9d950c();
13658
+ init_auto_globals_97a682e619();
14396
13659
 
14397
- // ../../../packages/dom/event-bridge/lib/esm/event-bridge.js
13660
+ // ../../../packages/framework/event-bridge/lib/esm/event-bridge.js
14398
13661
  init_console_gjs();
14399
- init_auto_globals_495e9d950c();
13662
+ init_auto_globals_97a682e619();
14400
13663
  init_esm4();
14401
13664
  import Gtk2 from "gi://Gtk?version=4.0";
14402
13665
  import Gdk4 from "gi://Gdk?version=4.0";
14403
13666
 
14404
- // ../../../packages/dom/event-bridge/lib/esm/key-map.js
13667
+ // ../../../packages/framework/event-bridge/lib/esm/key-map.js
14405
13668
  init_console_gjs();
14406
- init_auto_globals_495e9d950c();
13669
+ init_auto_globals_97a682e619();
14407
13670
  import Gdk3 from "gi://Gdk?version=4.0";
14408
13671
  var SPECIAL_KEYS = {
14409
13672
  Return: "Enter",
@@ -14592,7 +13855,7 @@ function gdkKeyvalToLocation(keyval) {
14592
13855
  return 0;
14593
13856
  }
14594
13857
 
14595
- // ../../../packages/dom/event-bridge/lib/esm/event-bridge.js
13858
+ // ../../../packages/framework/event-bridge/lib/esm/event-bridge.js
14596
13859
  function extractModifiers(controller) {
14597
13860
  const mods = controller.get_current_event_state();
14598
13861
  return {
@@ -14778,11 +14041,11 @@ function attachEventControllers(widget, getElement, options) {
14778
14041
  widget.add_controller(focusCtrl);
14779
14042
  }
14780
14043
 
14781
- // ../../../packages/dom/webgl/lib/esm/canvas-webgl-widget.js
14044
+ // ../../../packages/framework/webgl/lib/esm/webgl-bridge.js
14782
14045
  init_esm4();
14783
- var CanvasWebGLWidget = GObject.registerClass(
14784
- { GTypeName: "GjsifyCanvasWebGLWidget" },
14785
- class CanvasWebGLWidget2 extends Gtk3.GLArea {
14046
+ var WebGLBridge = GObject.registerClass(
14047
+ { GTypeName: "GjsifyWebGLBridge" },
14048
+ class WebGLBridge2 extends Gtk3.GLArea {
14786
14049
  constructor(params) {
14787
14050
  super(params);
14788
14051
  this._canvas = null;
@@ -14797,6 +14060,12 @@ var CanvasWebGLWidget = GObject.registerClass(
14797
14060
  this.set_has_depth_buffer(true);
14798
14061
  this.set_has_stencil_buffer(true);
14799
14062
  attachEventControllers(this, () => this._canvas, { captureKeys: true });
14063
+ this._tickCallbackId = this.add_tick_callback((_widget, _frameClock) => {
14064
+ if (this._frameCallback !== null) {
14065
+ this.queue_render();
14066
+ }
14067
+ return GLib2.SOURCE_CONTINUE;
14068
+ });
14800
14069
  const initId = this.connect("render", () => {
14801
14070
  this.disconnect(initId);
14802
14071
  this.make_current();
@@ -14812,6 +14081,18 @@ var CanvasWebGLWidget = GObject.registerClass(
14812
14081
  }
14813
14082
  this._readyCallbacks = [];
14814
14083
  }
14084
+ this._renderTag = this.connect("render", (_widget) => {
14085
+ if (this._frameCallback !== null) {
14086
+ const time2 = (GLib2.get_monotonic_time() - this._timeOrigin) / 1e3;
14087
+ if (globalThis.__GJSIFY_DEBUG_RAF === true) {
14088
+ console.log(`[rAF] frame callback fires t=${time2.toFixed(1)}`);
14089
+ }
14090
+ const cb = this._frameCallback;
14091
+ this._frameCallback = null;
14092
+ cb(time2);
14093
+ }
14094
+ return true;
14095
+ });
14815
14096
  return true;
14816
14097
  });
14817
14098
  this.connect("resize", () => {
@@ -14875,30 +14156,13 @@ var CanvasWebGLWidget = GObject.registerClass(
14875
14156
  }
14876
14157
  /**
14877
14158
  * Schedules a single animation frame callback, matching the browser `requestAnimationFrame` API.
14878
- * Backed by GTK frame clock (vsync-synced) + the GLArea render signal.
14879
- * Returns 0 (handle cancel not yet implemented).
14159
+ * Backed by a persistent GTK frame clock tick callback (vsync-synced) + a persistent GLArea
14160
+ * render signal handler. Both are installed once at construction / first render respectively,
14161
+ * eliminating per-frame GLib.Source allocation and GObject signal connect/disconnect overhead.
14162
+ * Returns 0 (handle — cancel via cancelAnimationFrame clears the pending callback).
14880
14163
  */
14881
14164
  requestAnimationFrame(cb) {
14882
14165
  this._frameCallback = cb;
14883
- if (this._tickCallbackId === null) {
14884
- this._tickCallbackId = this.add_tick_callback((_widget, _frameClock) => {
14885
- this._tickCallbackId = null;
14886
- if (this._renderTag === null) {
14887
- this._renderTag = this.connect("render", (_widget2) => {
14888
- this.disconnect(this._renderTag);
14889
- this._renderTag = null;
14890
- const time2 = (GLib2.get_monotonic_time() - this._timeOrigin) / 1e3;
14891
- if (globalThis.__GJSIFY_DEBUG_RAF === true) {
14892
- console.log(`[rAF] frame callback fires t=${time2.toFixed(1)}`);
14893
- }
14894
- this._frameCallback?.(time2);
14895
- return true;
14896
- });
14897
- }
14898
- this.queue_render();
14899
- return GLib2.SOURCE_REMOVE;
14900
- });
14901
- }
14902
14166
  this.queue_render();
14903
14167
  return 0;
14904
14168
  }
@@ -14920,22 +14184,22 @@ var CanvasWebGLWidget = GObject.registerClass(
14920
14184
  }
14921
14185
  );
14922
14186
 
14923
- // ../../../packages/dom/webgl/lib/esm/index.js
14187
+ // ../../../packages/framework/webgl/lib/esm/index.js
14924
14188
  globalThis.WebGLRenderingContext = WebGLRenderingContext2;
14925
14189
  globalThis.WebGL2RenderingContext = WebGL2RenderingContext;
14926
14190
 
14927
14191
  // src/three-demo.ts
14928
14192
  init_console_gjs();
14929
- init_auto_globals_495e9d950c();
14193
+ init_auto_globals_97a682e619();
14930
14194
 
14931
14195
  // ../../../node_modules/three/build/three.module.js
14932
14196
  init_console_gjs();
14933
- init_auto_globals_495e9d950c();
14197
+ init_auto_globals_97a682e619();
14934
14198
 
14935
14199
  // ../../../node_modules/three/build/three.core.js
14936
14200
  init_console_gjs();
14937
- init_auto_globals_495e9d950c();
14938
- var REVISION = "183";
14201
+ init_auto_globals_97a682e619();
14202
+ var REVISION = "184";
14939
14203
  var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
14940
14204
  var TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
14941
14205
  var CullFaceNone = 0;
@@ -15659,6 +14923,9 @@ var MathUtils = {
15659
14923
  denormalize
15660
14924
  };
15661
14925
  var Vector2 = class _Vector2 {
14926
+ static {
14927
+ _Vector2.prototype.isVector2 = true;
14928
+ }
15662
14929
  /**
15663
14930
  * Constructs a new 2D vector.
15664
14931
  *
@@ -15666,7 +14933,6 @@ var Vector2 = class _Vector2 {
15666
14933
  * @param {number} [y=0] - The y value of this vector.
15667
14934
  */
15668
14935
  constructor(x = 0, y = 0) {
15669
- _Vector2.prototype.isVector2 = true;
15670
14936
  this.x = x;
15671
14937
  this.y = y;
15672
14938
  }
@@ -16884,6 +16150,9 @@ var Quaternion = class {
16884
16150
  }
16885
16151
  };
16886
16152
  var Vector3 = class _Vector3 {
16153
+ static {
16154
+ _Vector3.prototype.isVector3 = true;
16155
+ }
16887
16156
  /**
16888
16157
  * Constructs a new 3D vector.
16889
16158
  *
@@ -16892,7 +16161,6 @@ var Vector3 = class _Vector3 {
16892
16161
  * @param {number} [z=0] - The z value of this vector.
16893
16162
  */
16894
16163
  constructor(x = 0, y = 0, z = 0) {
16895
- _Vector3.prototype.isVector3 = true;
16896
16164
  this.x = x;
16897
16165
  this.y = y;
16898
16166
  this.z = z;
@@ -17790,6 +17058,9 @@ var Vector3 = class _Vector3 {
17790
17058
  var _vector$c = /* @__PURE__ */ new Vector3();
17791
17059
  var _quaternion$5 = /* @__PURE__ */ new Quaternion();
17792
17060
  var Matrix3 = class _Matrix3 {
17061
+ static {
17062
+ _Matrix3.prototype.isMatrix3 = true;
17063
+ }
17793
17064
  /**
17794
17065
  * Constructs a new 3x3 matrix. The arguments are supposed to be
17795
17066
  * in row-major order. If no arguments are provided, the constructor
@@ -17806,7 +17077,6 @@ var Matrix3 = class _Matrix3 {
17806
17077
  * @param {number} [n33] - 3-3 matrix element.
17807
17078
  */
17808
17079
  constructor(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
17809
- _Matrix3.prototype.isMatrix3 = true;
17810
17080
  this.elements = [
17811
17081
  1,
17812
17082
  0,
@@ -18506,7 +17776,7 @@ var Source = class {
18506
17776
  if (typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement) {
18507
17777
  target.set(data.videoWidth, data.videoHeight, 0);
18508
17778
  } else if (typeof VideoFrame !== "undefined" && data instanceof VideoFrame) {
18509
- target.set(data.displayHeight, data.displayWidth, 0);
17779
+ target.set(data.displayWidth, data.displayHeight, 0);
18510
17780
  } else if (data !== null) {
18511
17781
  target.set(data.width, data.height, data.depth || 0);
18512
17782
  } else {
@@ -18636,6 +17906,7 @@ var Texture = class _Texture extends EventDispatcher {
18636
17906
  this.isRenderTargetTexture = false;
18637
17907
  this.isArrayTexture = image && image.depth && image.depth > 1 ? true : false;
18638
17908
  this.pmremVersion = 0;
17909
+ this.normalized = false;
18639
17910
  }
18640
17911
  /**
18641
17912
  * The width of the texture in pixels.
@@ -18663,11 +17934,11 @@ var Texture = class _Texture extends EventDispatcher {
18663
17934
  get image() {
18664
17935
  return this.source.data;
18665
17936
  }
18666
- set image(value2 = null) {
17937
+ set image(value2) {
18667
17938
  this.source.data = value2;
18668
17939
  }
18669
17940
  /**
18670
- * Updates the texture transformation matrix from the from the properties {@link Texture#offset},
17941
+ * Updates the texture transformation matrix from the properties {@link Texture#offset},
18671
17942
  * {@link Texture#repeat}, {@link Texture#rotation}, and {@link Texture#center}.
18672
17943
  */
18673
17944
  updateMatrix() {
@@ -18716,6 +17987,7 @@ var Texture = class _Texture extends EventDispatcher {
18716
17987
  this.format = source.format;
18717
17988
  this.internalFormat = source.internalFormat;
18718
17989
  this.type = source.type;
17990
+ this.normalized = source.normalized;
18719
17991
  this.offset.copy(source.offset);
18720
17992
  this.repeat.copy(source.repeat);
18721
17993
  this.center.copy(source.center);
@@ -18792,6 +18064,7 @@ var Texture = class _Texture extends EventDispatcher {
18792
18064
  format: this.format,
18793
18065
  internalFormat: this.internalFormat,
18794
18066
  type: this.type,
18067
+ normalized: this.normalized,
18795
18068
  colorSpace: this.colorSpace,
18796
18069
  minFilter: this.minFilter,
18797
18070
  magFilter: this.magFilter,
@@ -18897,6 +18170,9 @@ Texture.DEFAULT_IMAGE = null;
18897
18170
  Texture.DEFAULT_MAPPING = UVMapping;
18898
18171
  Texture.DEFAULT_ANISOTROPY = 1;
18899
18172
  var Vector4 = class _Vector4 {
18173
+ static {
18174
+ _Vector4.prototype.isVector4 = true;
18175
+ }
18900
18176
  /**
18901
18177
  * Constructs a new 4D vector.
18902
18178
  *
@@ -18906,7 +18182,6 @@ var Vector4 = class _Vector4 {
18906
18182
  * @param {number} [w=1] - The w value of this vector.
18907
18183
  */
18908
18184
  constructor(x = 0, y = 0, z = 0, w = 1) {
18909
- _Vector4.prototype.isVector4 = true;
18910
18185
  this.x = x;
18911
18186
  this.y = y;
18912
18187
  this.z = z;
@@ -19814,6 +19089,7 @@ var RenderTarget = class extends EventDispatcher {
19814
19089
  this.resolveStencilBuffer = source.resolveStencilBuffer;
19815
19090
  if (source.depthTexture !== null) this.depthTexture = source.depthTexture.clone();
19816
19091
  this.samples = source.samples;
19092
+ this.multiview = source.multiview;
19817
19093
  return this;
19818
19094
  }
19819
19095
  /**
@@ -19901,6 +19177,9 @@ var Data3DTexture = class extends Texture {
19901
19177
  }
19902
19178
  };
19903
19179
  var Matrix4 = class _Matrix4 {
19180
+ static {
19181
+ _Matrix4.prototype.isMatrix4 = true;
19182
+ }
19904
19183
  /**
19905
19184
  * Constructs a new 4x4 matrix. The arguments are supposed to be
19906
19185
  * in row-major order. If no arguments are provided, the constructor
@@ -19924,7 +19203,6 @@ var Matrix4 = class _Matrix4 {
19924
19203
  * @param {number} [n44] - 4-4 matrix element.
19925
19204
  */
19926
19205
  constructor(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
19927
- _Matrix4.prototype.isMatrix4 = true;
19928
19206
  this.elements = [
19929
19207
  1,
19930
19208
  0,
@@ -22287,9 +21565,7 @@ var Object3D = class _Object3D extends EventDispatcher {
22287
21565
  this.rotation.order = source.rotation.order;
22288
21566
  this.quaternion.copy(source.quaternion);
22289
21567
  this.scale.copy(source.scale);
22290
- if (source.pivot !== null) {
22291
- this.pivot = source.pivot.clone();
22292
- }
21568
+ this.pivot = source.pivot !== null ? source.pivot.clone() : null;
22293
21569
  this.matrix.copy(source.matrix);
22294
21570
  this.matrixWorld.copy(source.matrixWorld);
22295
21571
  this.matrixAutoUpdate = source.matrixAutoUpdate;
@@ -22379,6 +21655,7 @@ var WebXRController = class {
22379
21655
  this._grip.linearVelocity = new Vector3();
22380
21656
  this._grip.hasAngularVelocity = false;
22381
21657
  this._grip.angularVelocity = new Vector3();
21658
+ this._grip.eventsEnabled = false;
22382
21659
  }
22383
21660
  return this._grip;
22384
21661
  }
@@ -22508,6 +21785,13 @@ var WebXRController = class {
22508
21785
  } else {
22509
21786
  grip.hasAngularVelocity = false;
22510
21787
  }
21788
+ if (grip.eventsEnabled) {
21789
+ grip.dispatchEvent({
21790
+ type: "gripUpdated",
21791
+ data: inputSource,
21792
+ target: this
21793
+ });
21794
+ }
22511
21795
  }
22512
21796
  }
22513
21797
  }
@@ -23520,7 +22804,7 @@ var Triangle = class _Triangle {
23520
22804
  static isFrontFacing(a, b, c, direction) {
23521
22805
  _v0$2.subVectors(c, b);
23522
22806
  _v1$5.subVectors(a, b);
23523
- return _v0$2.cross(_v1$5).dot(direction) < 0 ? true : false;
22807
+ return _v0$2.cross(_v1$5).dot(direction) < 0;
23524
22808
  }
23525
22809
  /**
23526
22810
  * Sets the triangle's vertices by copying the given values.
@@ -24281,7 +23565,7 @@ function satForAxes(axes, v0, v1, v2, extents) {
24281
23565
  var _vector$a = /* @__PURE__ */ new Vector3();
24282
23566
  var _vector2$1 = /* @__PURE__ */ new Vector2();
24283
23567
  var _id$2 = 0;
24284
- var BufferAttribute = class {
23568
+ var BufferAttribute = class extends EventDispatcher {
24285
23569
  /**
24286
23570
  * Constructs a new buffer attribute.
24287
23571
  *
@@ -24290,6 +23574,7 @@ var BufferAttribute = class {
24290
23574
  * @param {boolean} [normalized=false] - Whether the data are normalized or not.
24291
23575
  */
24292
23576
  constructor(array, itemSize, normalized = false) {
23577
+ super();
24293
23578
  if (Array.isArray(array)) {
24294
23579
  throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
24295
23580
  }
@@ -24686,6 +23971,12 @@ var BufferAttribute = class {
24686
23971
  if (this.usage !== StaticDrawUsage) data.usage = this.usage;
24687
23972
  return data;
24688
23973
  }
23974
+ /**
23975
+ * Disposes of the buffer attribute. Available only in {@link WebGPURenderer}.
23976
+ */
23977
+ dispose() {
23978
+ this.dispatchEvent({ type: "dispose" });
23979
+ }
24689
23980
  };
24690
23981
  var Uint16BufferAttribute = class extends BufferAttribute {
24691
23982
  /**
@@ -27040,9 +26331,10 @@ var Plane = class {
27040
26331
  *
27041
26332
  * @param {Line3} line - The line to compute the intersection for.
27042
26333
  * @param {Vector3} target - The target vector that is used to store the method's result.
27043
- * @return {?Vector3} The intersection point.
26334
+ * @param {boolean} [clampToLine=true] - Whether to clamp the intersection to the line segment.
26335
+ * @return {?Vector3} The intersection point. Returns `null` if no intersection is detected.
27044
26336
  */
27045
- intersectLine(line, target) {
26337
+ intersectLine(line, target, clampToLine = true) {
27046
26338
  const direction = line.delta(_vector1);
27047
26339
  const denominator = this.normal.dot(direction);
27048
26340
  if (denominator === 0) {
@@ -27052,7 +26344,7 @@ var Plane = class {
27052
26344
  return null;
27053
26345
  }
27054
26346
  const t = -(line.start.dot(this.normal) + this.constant) / denominator;
27055
- if (t < 0 || t > 1) {
26347
+ if (clampToLine === true && (t < 0 || t > 1)) {
27056
26348
  return null;
27057
26349
  }
27058
26350
  return target.copy(line.start).addScaledVector(direction, t);
@@ -27944,7 +27236,7 @@ function cloneUniforms(src) {
27944
27236
  dst[u] = {};
27945
27237
  for (const p in src[u]) {
27946
27238
  const property = src[u][p];
27947
- if (property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture || property.isQuaternion)) {
27239
+ if (isThreeObject(property)) {
27948
27240
  if (property.isRenderTargetTexture) {
27949
27241
  warn2("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().");
27950
27242
  dst[u][p] = null;
@@ -27952,7 +27244,15 @@ function cloneUniforms(src) {
27952
27244
  dst[u][p] = property.clone();
27953
27245
  }
27954
27246
  } else if (Array.isArray(property)) {
27955
- dst[u][p] = property.slice();
27247
+ if (isThreeObject(property[0])) {
27248
+ const clonedProperty = [];
27249
+ for (let i = 0, l = property.length; i < l; i++) {
27250
+ clonedProperty[i] = property[i].clone();
27251
+ }
27252
+ dst[u][p] = clonedProperty;
27253
+ } else {
27254
+ dst[u][p] = property.slice();
27255
+ }
27956
27256
  } else {
27957
27257
  dst[u][p] = property;
27958
27258
  }
@@ -27970,6 +27270,9 @@ function mergeUniforms(uniforms) {
27970
27270
  }
27971
27271
  return merged;
27972
27272
  }
27273
+ function isThreeObject(property) {
27274
+ return property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture || property.isQuaternion);
27275
+ }
27973
27276
  function cloneUniformsGroups(src) {
27974
27277
  const dst = [];
27975
27278
  for (let u = 0; u < src.length; u++) {
@@ -28828,10 +28131,10 @@ var KeyframeTrack = class {
28828
28131
  * @param {number} endTime - The end time.
28829
28132
  * @return {KeyframeTrack} A reference to this keyframe track.
28830
28133
  */
28831
- trim(startTime2, endTime) {
28134
+ trim(startTime, endTime) {
28832
28135
  const times = this.times, nKeys = times.length;
28833
28136
  let from = 0, to = nKeys - 1;
28834
- while (from !== nKeys && times[from] < startTime2) {
28137
+ while (from !== nKeys && times[from] < startTime) {
28835
28138
  ++from;
28836
28139
  }
28837
28140
  while (to !== -1 && times[to] > endTime) {
@@ -31042,6 +30345,77 @@ var Spherical = class {
31042
30345
  return new this.constructor().copy(this);
31043
30346
  }
31044
30347
  };
30348
+ var Matrix2 = class _Matrix2 {
30349
+ static {
30350
+ _Matrix2.prototype.isMatrix2 = true;
30351
+ }
30352
+ /**
30353
+ * Constructs a new 2x2 matrix. The arguments are supposed to be
30354
+ * in row-major order. If no arguments are provided, the constructor
30355
+ * initializes the matrix as an identity matrix.
30356
+ *
30357
+ * @param {number} [n11] - 1-1 matrix element.
30358
+ * @param {number} [n12] - 1-2 matrix element.
30359
+ * @param {number} [n21] - 2-1 matrix element.
30360
+ * @param {number} [n22] - 2-2 matrix element.
30361
+ */
30362
+ constructor(n11, n12, n21, n22) {
30363
+ this.elements = [
30364
+ 1,
30365
+ 0,
30366
+ 0,
30367
+ 1
30368
+ ];
30369
+ if (n11 !== void 0) {
30370
+ this.set(n11, n12, n21, n22);
30371
+ }
30372
+ }
30373
+ /**
30374
+ * Sets this matrix to the 2x2 identity matrix.
30375
+ *
30376
+ * @return {Matrix2} A reference to this matrix.
30377
+ */
30378
+ identity() {
30379
+ this.set(
30380
+ 1,
30381
+ 0,
30382
+ 0,
30383
+ 1
30384
+ );
30385
+ return this;
30386
+ }
30387
+ /**
30388
+ * Sets the elements of the matrix from the given array.
30389
+ *
30390
+ * @param {Array<number>} array - The matrix elements in column-major order.
30391
+ * @param {number} [offset=0] - Index of the first element in the array.
30392
+ * @return {Matrix2} A reference to this matrix.
30393
+ */
30394
+ fromArray(array, offset = 0) {
30395
+ for (let i = 0; i < 4; i++) {
30396
+ this.elements[i] = array[i + offset];
30397
+ }
30398
+ return this;
30399
+ }
30400
+ /**
30401
+ * Sets the elements of the matrix.The arguments are supposed to be
30402
+ * in row-major order.
30403
+ *
30404
+ * @param {number} n11 - 1-1 matrix element.
30405
+ * @param {number} n12 - 1-2 matrix element.
30406
+ * @param {number} n21 - 2-1 matrix element.
30407
+ * @param {number} n22 - 2-2 matrix element.
30408
+ * @return {Matrix2} A reference to this matrix.
30409
+ */
30410
+ set(n11, n12, n21, n22) {
30411
+ const te = this.elements;
30412
+ te[0] = n11;
30413
+ te[2] = n12;
30414
+ te[1] = n21;
30415
+ te[3] = n22;
30416
+ return this;
30417
+ }
30418
+ };
31045
30419
  var Controls = class extends EventDispatcher {
31046
30420
  /**
31047
30421
  * Constructs a new controls instance.
@@ -31232,11 +30606,12 @@ function WebGLAnimation() {
31232
30606
  start: function() {
31233
30607
  if (isAnimating === true) return;
31234
30608
  if (animationLoop === null) return;
30609
+ if (context === null) return;
31235
30610
  requestId = context.requestAnimationFrame(onAnimationFrame);
31236
30611
  isAnimating = true;
31237
30612
  },
31238
30613
  stop: function() {
31239
- context.cancelAnimationFrame(requestId);
30614
+ if (context !== null) context.cancelAnimationFrame(requestId);
31240
30615
  isAnimating = false;
31241
30616
  },
31242
30617
  setAnimationLoop: function(callback) {
@@ -31403,8 +30778,8 @@ var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = textur
31403
30778
  var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif";
31404
30779
  var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
31405
30780
  var colorspace_pars_fragment = "vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}";
31406
- var envmap_fragment = "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n #endif\n#endif";
31407
- var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif";
30781
+ var envmap_fragment = "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n #endif\n#endif";
30782
+ var envmap_common_pars_fragment = "#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif";
31408
30783
  var envmap_pars_fragment = "#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif";
31409
30784
  var envmap_pars_vertex = "#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif";
31410
30785
  var envmap_vertex = "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif";
@@ -31416,17 +30791,18 @@ var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n uniform sampler2D grad
31416
30791
  var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif";
31417
30792
  var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
31418
30793
  var lights_lambert_pars_fragment = "varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert";
31419
- var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif";
30794
+ var lights_pars_begin = "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif\n#include <lightprobes_pars_fragment>";
31420
30795
  var envmap_physical_pars_fragment = "#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif";
31421
30796
  var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
31422
30797
  var lights_toon_pars_fragment = "varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon";
31423
30798
  var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
31424
30799
  var lights_phong_pars_fragment = "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong";
31425
30800
  var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif";
31426
- var lights_physical_pars_fragment = "uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n float v = 0.5 / ( gv + gl );\n return v;\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid 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 ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n 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 ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid 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 ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid 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 ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid 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) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
31427
- var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
30801
+ var lights_physical_pars_fragment = "uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid 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 ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n 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 ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid 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 ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid 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 ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid 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) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}";
30802
+ var lights_fragment_begin = "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n #ifdef USE_LIGHT_PROBES_GRID\n vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix );\n irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif";
31428
30803
  var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif";
31429
30804
  var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n #if defined( LAMBERT ) || defined( PHONG )\n irradiance += iblIrradiance;\n #endif\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif";
30805
+ var lightprobes_pars_fragment = "#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n vec3 res = probesResolution;\n vec3 gridRange = probesMax - probesMin;\n vec3 resMinusOne = res - 1.0;\n vec3 probeSpacing = gridRange / resMinusOne;\n vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n uvw = uvw * resMinusOne / res + 0.5 / res;\n float nz = res.z;\n float paddedSlices = nz + 2.0;\n float atlasDepth = 7.0 * paddedSlices;\n float uvZBase = uvw.z * nz + 1.0;\n vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n vec3 c0 = s0.xyz;\n vec3 c1 = vec3( s0.w, s1.xy );\n vec3 c2 = vec3( s1.zw, s2.x );\n vec3 c3 = s2.yzw;\n vec3 c4 = s3.xyz;\n vec3 c5 = vec3( s3.w, s4.xy );\n vec3 c6 = vec3( s4.zw, s5.x );\n vec3 c7 = s5.yzw;\n vec3 c8 = s6.xyz;\n float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n vec3 result = c0 * 0.886227;\n result += c1 * 2.0 * 0.511664 * y;\n result += c2 * 2.0 * 0.511664 * z;\n result += c3 * 2.0 * 0.511664 * x;\n result += c4 * 2.0 * 0.429043 * x * y;\n result += c5 * 2.0 * 0.429043 * y * z;\n result += c6 * ( 0.743125 * z * z - 0.247708 );\n result += c7 * 2.0 * 0.429043 * x * z;\n result += c8 * 0.429043 * ( x * x - y * y );\n return max( result, vec3( 0.0 ) );\n}\n#endif";
31430
30806
  var logdepthbuf_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
31431
30807
  var logdepthbuf_pars_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
31432
30808
  var logdepthbuf_pars_vertex = "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
@@ -31443,7 +30819,7 @@ var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetB
31443
30819
  var morphtarget_pars_vertex = "#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif";
31444
30820
  var morphtarget_vertex = "#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif";
31445
30821
  var normal_fragment_begin = "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;";
31446
- var normal_fragment_maps = "#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif";
30822
+ var normal_fragment_maps = "#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #if defined( USE_PACKED_NORMALMAP )\n mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n #endif\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif";
31447
30823
  var normal_pars_fragment = "#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif";
31448
30824
  var normal_pars_vertex = "#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif";
31449
30825
  var normal_vertex = "#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif";
@@ -31462,7 +30838,7 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
31462
30838
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif";
31463
30839
  var shadowmap_pars_fragment = "#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n \n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp -= shadowBias;\n #else\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n #endif\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n vec2 sample0 = vogelDiskSample( 0, 5, phi );\n vec2 sample1 = vogelDiskSample( 1, 5, phi );\n vec2 sample2 = vogelDiskSample( 2, 5, phi );\n vec2 sample3 = vogelDiskSample( 3, 5, phi );\n vec2 sample4 = vogelDiskSample( 4, 5, phi );\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n depth = 1.0 - depth;\n #endif\n shadow = step( dp, depth );\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif";
31464
30840
  var shadowmap_pars_vertex = "#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif";
31465
- var shadowmap_vertex = "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif";
30841
+ var shadowmap_vertex = "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n #ifdef HAS_NORMAL\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #else\n vec3 shadowWorldNormal = vec3( 0.0 );\n #endif\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif";
31466
30842
  var shadowmask_pars_fragment = "float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}";
31467
30843
  var skinbase_vertex = "#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
31468
30844
  var skinning_pars_vertex = "#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif";
@@ -31481,7 +30857,7 @@ var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defin
31481
30857
  var vertex$h = "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}";
31482
30858
  var fragment$h = "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}";
31483
30859
  var vertex$g = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}";
31484
- var fragment$g = "#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}";
30860
+ var fragment$g = "#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}";
31485
30861
  var vertex$f = "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}";
31486
30862
  var fragment$f = "uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}";
31487
30863
  var vertex$e = "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vHighPrecisionZW = gl_Position.zw;\n}";
@@ -31569,6 +30945,7 @@ var ShaderChunk = {
31569
30945
  lights_fragment_begin,
31570
30946
  lights_fragment_maps,
31571
30947
  lights_fragment_end,
30948
+ lightprobes_pars_fragment,
31572
30949
  logdepthbuf_fragment,
31573
30950
  logdepthbuf_pars_fragment,
31574
30951
  logdepthbuf_pars_vertex,
@@ -31672,7 +31049,6 @@ var UniformsLib = {
31672
31049
  envmap: {
31673
31050
  envMap: { value: null },
31674
31051
  envMapRotation: { value: /* @__PURE__ */ new Matrix3() },
31675
- flipEnvMap: { value: -1 },
31676
31052
  reflectivity: { value: 1 },
31677
31053
  // basic, lambert, phong
31678
31054
  ior: { value: 1.5 },
@@ -31791,7 +31167,11 @@ var UniformsLib = {
31791
31167
  height: {}
31792
31168
  } },
31793
31169
  ltc_1: { value: null },
31794
- ltc_2: { value: null }
31170
+ ltc_2: { value: null },
31171
+ probesSH: { value: null },
31172
+ probesMin: { value: /* @__PURE__ */ new Vector3() },
31173
+ probesMax: { value: /* @__PURE__ */ new Vector3() },
31174
+ probesResolution: { value: /* @__PURE__ */ new Vector3() }
31795
31175
  },
31796
31176
  points: {
31797
31177
  diffuse: { value: /* @__PURE__ */ new Color(16777215) },
@@ -31992,7 +31372,6 @@ var ShaderLib = {
31992
31372
  backgroundCube: {
31993
31373
  uniforms: {
31994
31374
  envMap: { value: null },
31995
- flipEnvMap: { value: -1 },
31996
31375
  backgroundBlurriness: { value: 0 },
31997
31376
  backgroundIntensity: { value: 1 },
31998
31377
  backgroundRotation: { value: /* @__PURE__ */ new Matrix3() }
@@ -32096,8 +31475,9 @@ ShaderLib.physical = {
32096
31475
  fragmentShader: ShaderChunk.meshphysical_frag
32097
31476
  };
32098
31477
  var _rgb = { r: 0, b: 0, g: 0 };
32099
- var _e1$1 = /* @__PURE__ */ new Euler();
32100
31478
  var _m1$12 = /* @__PURE__ */ new Matrix4();
31479
+ var _m$1 = /* @__PURE__ */ new Matrix3();
31480
+ _m$1.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
32101
31481
  function WebGLBackground(renderer, environments, state, objects, alpha, premultipliedAlpha) {
32102
31482
  const clearColor = new Color(0);
32103
31483
  let clearAlpha = alpha === true ? 0 : 1;
@@ -32166,19 +31546,13 @@ function WebGLBackground(renderer, environments, state, objects, alpha, premulti
32166
31546
  });
32167
31547
  objects.update(boxMesh);
32168
31548
  }
32169
- _e1$1.copy(scene.backgroundRotation);
32170
- _e1$1.x *= -1;
32171
- _e1$1.y *= -1;
32172
- _e1$1.z *= -1;
32173
- if (background.isCubeTexture && background.isRenderTargetTexture === false) {
32174
- _e1$1.y *= -1;
32175
- _e1$1.z *= -1;
32176
- }
32177
31549
  boxMesh.material.uniforms.envMap.value = background;
32178
- boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture && background.isRenderTargetTexture === false ? -1 : 1;
32179
31550
  boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
32180
31551
  boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
32181
- boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4(_m1$12.makeRotationFromEuler(_e1$1));
31552
+ boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4(_m1$12.makeRotationFromEuler(scene.backgroundRotation)).transpose();
31553
+ if (background.isCubeTexture && background.isRenderTargetTexture === false) {
31554
+ boxMesh.material.uniforms.backgroundRotation.value.premultiply(_m$1);
31555
+ }
32182
31556
  boxMesh.material.toneMapped = ColorManagement.getTransfer(background.colorSpace) !== SRGBTransfer;
32183
31557
  if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {
32184
31558
  boxMesh.material.needsUpdate = true;
@@ -32654,27 +32028,10 @@ function WebGLBufferRenderer(gl, extensions, info2) {
32654
32028
  }
32655
32029
  info2.update(elementCount, mode, 1);
32656
32030
  }
32657
- function renderMultiDrawInstances(starts, counts, drawCount, primcount) {
32658
- if (drawCount === 0) return;
32659
- const extension = extensions.get("WEBGL_multi_draw");
32660
- if (extension === null) {
32661
- for (let i = 0; i < starts.length; i++) {
32662
- renderInstances(starts[i], counts[i], primcount[i]);
32663
- }
32664
- } else {
32665
- extension.multiDrawArraysInstancedWEBGL(mode, starts, 0, counts, 0, primcount, 0, drawCount);
32666
- let elementCount = 0;
32667
- for (let i = 0; i < drawCount; i++) {
32668
- elementCount += counts[i] * primcount[i];
32669
- }
32670
- info2.update(elementCount, mode, 1);
32671
- }
32672
- }
32673
32031
  this.setMode = setMode;
32674
32032
  this.render = render;
32675
32033
  this.renderInstances = renderInstances;
32676
32034
  this.renderMultiDraw = renderMultiDraw;
32677
- this.renderMultiDrawInstances = renderMultiDrawInstances;
32678
32035
  }
32679
32036
  function WebGLCapabilities(gl, extensions, parameters, utils) {
32680
32037
  let maxAnisotropy;
@@ -32724,6 +32081,9 @@ function WebGLCapabilities(gl, extensions, parameters, utils) {
32724
32081
  }
32725
32082
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
32726
32083
  const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions.has("EXT_clip_control");
32084
+ if (parameters.reversedDepthBuffer === true && reversedDepthBuffer === false) {
32085
+ warn2("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");
32086
+ }
32727
32087
  const maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
32728
32088
  const maxVertexTextures = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
32729
32089
  const maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
@@ -33987,13 +33347,13 @@ function WebGLGeometries(gl, attributes2, info2, bindingStates) {
33987
33347
  const indices = [];
33988
33348
  const geometryIndex = geometry.index;
33989
33349
  const geometryPosition = geometry.attributes.position;
33990
- let version2 = 0;
33350
+ let version = 0;
33991
33351
  if (geometryPosition === void 0) {
33992
33352
  return;
33993
33353
  }
33994
33354
  if (geometryIndex !== null) {
33995
33355
  const array = geometryIndex.array;
33996
- version2 = geometryIndex.version;
33356
+ version = geometryIndex.version;
33997
33357
  for (let i = 0, l = array.length; i < l; i += 3) {
33998
33358
  const a = array[i + 0];
33999
33359
  const b = array[i + 1];
@@ -34002,7 +33362,7 @@ function WebGLGeometries(gl, attributes2, info2, bindingStates) {
34002
33362
  }
34003
33363
  } else {
34004
33364
  const array = geometryPosition.array;
34005
- version2 = geometryPosition.version;
33365
+ version = geometryPosition.version;
34006
33366
  for (let i = 0, l = array.length / 3 - 1; i < l; i += 3) {
34007
33367
  const a = i + 0;
34008
33368
  const b = i + 1;
@@ -34011,7 +33371,7 @@ function WebGLGeometries(gl, attributes2, info2, bindingStates) {
34011
33371
  }
34012
33372
  }
34013
33373
  const attribute = new (geometryPosition.count >= 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(indices, 1);
34014
- attribute.version = version2;
33374
+ attribute.version = version;
34015
33375
  const previousAttribute = wireframeAttributes.get(geometry);
34016
33376
  if (previousAttribute) attributes2.remove(previousAttribute);
34017
33377
  wireframeAttributes.set(geometry, attribute);
@@ -34065,28 +33425,11 @@ function WebGLIndexedBufferRenderer(gl, extensions, info2) {
34065
33425
  }
34066
33426
  info2.update(elementCount, mode, 1);
34067
33427
  }
34068
- function renderMultiDrawInstances(starts, counts, drawCount, primcount) {
34069
- if (drawCount === 0) return;
34070
- const extension = extensions.get("WEBGL_multi_draw");
34071
- if (extension === null) {
34072
- for (let i = 0; i < starts.length; i++) {
34073
- renderInstances(starts[i] / bytesPerElement, counts[i], primcount[i]);
34074
- }
34075
- } else {
34076
- extension.multiDrawElementsInstancedWEBGL(mode, counts, 0, type, starts, 0, primcount, 0, drawCount);
34077
- let elementCount = 0;
34078
- for (let i = 0; i < drawCount; i++) {
34079
- elementCount += counts[i] * primcount[i];
34080
- }
34081
- info2.update(elementCount, mode, 1);
34082
- }
34083
- }
34084
33428
  this.setMode = setMode;
34085
33429
  this.setIndex = setIndex;
34086
33430
  this.render = render;
34087
33431
  this.renderInstances = renderInstances;
34088
33432
  this.renderMultiDraw = renderMultiDraw;
34089
- this.renderMultiDrawInstances = renderMultiDrawInstances;
34090
33433
  }
34091
33434
  function WebGLInfo(gl) {
34092
33435
  const memory = {
@@ -34289,7 +33632,8 @@ function WebGLOutput(type, width, height, depth, stencil) {
34289
33632
  const targetA = new WebGLRenderTarget(width, height, {
34290
33633
  type,
34291
33634
  depthBuffer: depth,
34292
- stencilBuffer: stencil
33635
+ stencilBuffer: stencil,
33636
+ depthTexture: depth ? new DepthTexture(width, height) : void 0
34293
33637
  });
34294
33638
  const targetB = new WebGLRenderTarget(width, height, {
34295
33639
  type: HalfFloatType,
@@ -34442,6 +33786,7 @@ function WebGLOutput(type, width, height, depth, stencil) {
34442
33786
  return _isCompositing;
34443
33787
  };
34444
33788
  this.dispose = function() {
33789
+ if (targetA.depthTexture) targetA.depthTexture.dispose();
34445
33790
  targetA.dispose();
34446
33791
  targetB.dispose();
34447
33792
  geometry.dispose();
@@ -35453,6 +34798,7 @@ function WebGLProgram2(renderer, cacheKey, parameters, bindingStates) {
35453
34798
  parameters.thicknessMapUv ? "#define THICKNESSMAP_UV " + parameters.thicknessMapUv : "",
35454
34799
  //
35455
34800
  parameters.vertexTangents && parameters.flatShading === false ? "#define USE_TANGENT" : "",
34801
+ parameters.vertexNormals ? "#define HAS_NORMAL" : "",
35456
34802
  parameters.vertexColors ? "#define USE_COLOR" : "",
35457
34803
  parameters.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
35458
34804
  parameters.vertexUv1s ? "#define USE_UV1" : "",
@@ -35539,6 +34885,7 @@ function WebGLProgram2(renderer, cacheKey, parameters, bindingStates) {
35539
34885
  parameters.normalMap ? "#define USE_NORMALMAP" : "",
35540
34886
  parameters.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
35541
34887
  parameters.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
34888
+ parameters.packedNormalMap ? "#define USE_PACKED_NORMALMAP" : "",
35542
34889
  parameters.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
35543
34890
  parameters.anisotropy ? "#define USE_ANISOTROPY" : "",
35544
34891
  parameters.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
@@ -35579,6 +34926,7 @@ function WebGLProgram2(renderer, cacheKey, parameters, bindingStates) {
35579
34926
  parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
35580
34927
  parameters.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
35581
34928
  parameters.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
34929
+ parameters.numLightProbeGrids > 0 ? "#define USE_LIGHT_PROBES_GRID" : "",
35582
34930
  parameters.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",
35583
34931
  parameters.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "",
35584
34932
  parameters.logarithmicDepthBuffer ? "#define USE_LOGARITHMIC_DEPTH_BUFFER" : "",
@@ -35793,6 +35141,9 @@ var WebGLShaderStage = class {
35793
35141
  this.usedTimes = 0;
35794
35142
  }
35795
35143
  };
35144
+ function isPackedRGFormat(format) {
35145
+ return format === RGFormat || format === RG11_EAC_Format || format === RED_GREEN_RGTC2_Format;
35146
+ }
35796
35147
  function WebGLPrograms(renderer, environments, extensions, capabilities, bindingStates, clipping) {
35797
35148
  const _programLayers = new Layers();
35798
35149
  const _customShaders = new WebGLShaderCache();
@@ -35823,7 +35174,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
35823
35174
  if (value2 === 0) return "uv";
35824
35175
  return `uv${value2}`;
35825
35176
  }
35826
- function getParameters(material, lights, shadows, scene, object) {
35177
+ function getParameters(material, lights, shadows, scene, object, lightProbeGrids) {
35827
35178
  const fog = scene.fog;
35828
35179
  const geometry = object.geometry;
35829
35180
  const environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
@@ -35918,7 +35269,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
35918
35269
  instancing: IS_INSTANCEDMESH,
35919
35270
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
35920
35271
  instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
35921
- outputColorSpace: currentRenderTarget === null ? renderer.outputColorSpace : currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace,
35272
+ outputColorSpace: currentRenderTarget === null ? renderer.outputColorSpace : currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace,
35922
35273
  alphaToCoverage: !!material.alphaToCoverage,
35923
35274
  map: HAS_MAP,
35924
35275
  matcap: HAS_MATCAP,
@@ -35933,6 +35284,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
35933
35284
  emissiveMap: HAS_EMISSIVEMAP,
35934
35285
  normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
35935
35286
  normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
35287
+ packedNormalMap: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap && isPackedRGFormat(material.normalMap.format),
35936
35288
  metalnessMap: HAS_METALNESSMAP,
35937
35289
  roughnessMap: HAS_ROUGHNESSMAP,
35938
35290
  anisotropy: HAS_ANISOTROPY,
@@ -35986,6 +35338,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
35986
35338
  alphaMapUv: HAS_ALPHAMAP && getChannel(material.alphaMap.channel),
35987
35339
  //
35988
35340
  vertexTangents: !!geometry.attributes.tangent && (HAS_NORMALMAP || HAS_ANISOTROPY),
35341
+ vertexNormals: !!geometry.attributes.normal,
35989
35342
  vertexColors: material.vertexColors,
35990
35343
  vertexAlphas: material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4,
35991
35344
  pointsUvs: object.isPoints === true && !!geometry.attributes.uv && (HAS_MAP || HAS_ALPHAMAP),
@@ -36013,6 +35366,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
36013
35366
  numSpotLightShadows: lights.spotShadowMap.length,
36014
35367
  numSpotLightShadowsWithMaps: lights.numSpotLightShadowsWithMaps,
36015
35368
  numLightProbes: lights.numLightProbes,
35369
+ numLightProbeGrids: lightProbeGrids.length,
36016
35370
  numClippingPlanes: clipping.numPlanes,
36017
35371
  numClipIntersection: clipping.numIntersection,
36018
35372
  dithering: material.dithering,
@@ -36156,6 +35510,10 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
36156
35510
  _programLayers.enable(20);
36157
35511
  if (parameters.gradientMap)
36158
35512
  _programLayers.enable(21);
35513
+ if (parameters.packedNormalMap)
35514
+ _programLayers.enable(22);
35515
+ if (parameters.vertexNormals)
35516
+ _programLayers.enable(23);
36159
35517
  array.push(_programLayers.mask);
36160
35518
  _programLayers.disableAll();
36161
35519
  if (parameters.fog)
@@ -36202,6 +35560,8 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
36202
35560
  _programLayers.enable(20);
36203
35561
  if (parameters.alphaToCoverage)
36204
35562
  _programLayers.enable(21);
35563
+ if (parameters.numLightProbeGrids > 0)
35564
+ _programLayers.enable(22);
36205
35565
  array.push(_programLayers.mask);
36206
35566
  }
36207
35567
  function getUniforms(material) {
@@ -36801,10 +36161,12 @@ function WebGLRenderState(extensions) {
36801
36161
  const lights = new WebGLLights(extensions);
36802
36162
  const lightsArray = [];
36803
36163
  const shadowsArray = [];
36164
+ const lightProbeGridArray = [];
36804
36165
  function init(camera) {
36805
36166
  state.camera = camera;
36806
36167
  lightsArray.length = 0;
36807
36168
  shadowsArray.length = 0;
36169
+ lightProbeGridArray.length = 0;
36808
36170
  }
36809
36171
  function pushLight(light) {
36810
36172
  lightsArray.push(light);
@@ -36812,6 +36174,9 @@ function WebGLRenderState(extensions) {
36812
36174
  function pushShadow(shadowLight) {
36813
36175
  shadowsArray.push(shadowLight);
36814
36176
  }
36177
+ function pushLightProbeGrid(volume) {
36178
+ lightProbeGridArray.push(volume);
36179
+ }
36815
36180
  function setupLights() {
36816
36181
  lights.setup(lightsArray);
36817
36182
  }
@@ -36821,9 +36186,11 @@ function WebGLRenderState(extensions) {
36821
36186
  const state = {
36822
36187
  lightsArray,
36823
36188
  shadowsArray,
36189
+ lightProbeGridArray,
36824
36190
  camera: null,
36825
36191
  lights,
36826
- transmissionRenderTarget: {}
36192
+ transmissionRenderTarget: {},
36193
+ textureUnits: 0
36827
36194
  };
36828
36195
  return {
36829
36196
  init,
@@ -36831,7 +36198,8 @@ function WebGLRenderState(extensions) {
36831
36198
  setupLights,
36832
36199
  setupLightsView,
36833
36200
  pushLight,
36834
- pushShadow
36201
+ pushShadow,
36202
+ pushLightProbeGrid
36835
36203
  };
36836
36204
  }
36837
36205
  function WebGLRenderStates(extensions) {
@@ -37391,6 +36759,7 @@ function WebGLState(gl, extensions) {
37391
36759
  const uboBindings = /* @__PURE__ */ new WeakMap();
37392
36760
  const uboProgramMap = /* @__PURE__ */ new WeakMap();
37393
36761
  let enabledCapabilities = {};
36762
+ let parameters = {};
37394
36763
  let currentBoundFramebuffers = {};
37395
36764
  let currentDrawbuffers = /* @__PURE__ */ new WeakMap();
37396
36765
  let defaultDrawbuffers = [];
@@ -37413,14 +36782,14 @@ function WebGLState(gl, extensions) {
37413
36782
  let currentPolygonOffsetUnits = null;
37414
36783
  const maxTextures = gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
37415
36784
  let lineWidthAvailable = false;
37416
- let version2 = 0;
36785
+ let version = 0;
37417
36786
  const glVersion = gl.getParameter(gl.VERSION);
37418
36787
  if (glVersion.indexOf("WebGL") !== -1) {
37419
- version2 = parseFloat(/^WebGL (\d)/.exec(glVersion)[1]);
37420
- lineWidthAvailable = version2 >= 1;
36788
+ version = parseFloat(/^WebGL (\d)/.exec(glVersion)[1]);
36789
+ lineWidthAvailable = version >= 1;
37421
36790
  } else if (glVersion.indexOf("OpenGL ES") !== -1) {
37422
- version2 = parseFloat(/^OpenGL ES (\d)/.exec(glVersion)[1]);
37423
- lineWidthAvailable = version2 >= 2;
36791
+ version = parseFloat(/^OpenGL ES (\d)/.exec(glVersion)[1]);
36792
+ lineWidthAvailable = version >= 2;
37424
36793
  }
37425
36794
  let currentTextureSlot = null;
37426
36795
  let currentBoundTextures = {};
@@ -37815,6 +37184,19 @@ function WebGLState(gl, extensions) {
37815
37184
  error2("WebGLState:", e);
37816
37185
  }
37817
37186
  }
37187
+ function getParameter(name2) {
37188
+ if (parameters[name2] !== void 0) {
37189
+ return parameters[name2];
37190
+ } else {
37191
+ return gl.getParameter(name2);
37192
+ }
37193
+ }
37194
+ function pixelStorei(name2, value2) {
37195
+ if (parameters[name2] !== value2) {
37196
+ gl.pixelStorei(name2, value2);
37197
+ parameters[name2] = value2;
37198
+ }
37199
+ }
37818
37200
  function scissor(scissor2) {
37819
37201
  if (currentScissor.equals(scissor2) === false) {
37820
37202
  gl.scissor(scissor2.x, scissor2.y, scissor2.z, scissor2.w);
@@ -37880,7 +37262,21 @@ function WebGLState(gl, extensions) {
37880
37262
  gl.lineWidth(1);
37881
37263
  gl.scissor(0, 0, gl.canvas.width, gl.canvas.height);
37882
37264
  gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
37265
+ gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
37266
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
37267
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
37268
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
37269
+ gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.BROWSER_DEFAULT_WEBGL);
37270
+ gl.pixelStorei(gl.PACK_ROW_LENGTH, 0);
37271
+ gl.pixelStorei(gl.PACK_SKIP_PIXELS, 0);
37272
+ gl.pixelStorei(gl.PACK_SKIP_ROWS, 0);
37273
+ gl.pixelStorei(gl.UNPACK_ROW_LENGTH, 0);
37274
+ gl.pixelStorei(gl.UNPACK_IMAGE_HEIGHT, 0);
37275
+ gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, 0);
37276
+ gl.pixelStorei(gl.UNPACK_SKIP_ROWS, 0);
37277
+ gl.pixelStorei(gl.UNPACK_SKIP_IMAGES, 0);
37883
37278
  enabledCapabilities = {};
37279
+ parameters = {};
37884
37280
  currentTextureSlot = null;
37885
37281
  currentBoundTextures = {};
37886
37282
  currentBoundFramebuffers = {};
@@ -37934,6 +37330,8 @@ function WebGLState(gl, extensions) {
37934
37330
  compressedTexImage3D,
37935
37331
  texImage2D,
37936
37332
  texImage3D,
37333
+ pixelStorei,
37334
+ getParameter,
37937
37335
  updateUBOMapping,
37938
37336
  uniformBlockBinding,
37939
37337
  texStorage2D,
@@ -37952,6 +37350,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
37952
37350
  const supportsInvalidateFramebuffer = typeof navigator === "undefined" ? false : /OculusBrowser/g.test(navigator.userAgent);
37953
37351
  const _imageDimensions = new Vector2();
37954
37352
  const _videoTextures = /* @__PURE__ */ new WeakMap();
37353
+ const _htmlTextures = /* @__PURE__ */ new Set();
37955
37354
  let _canvas2;
37956
37355
  const _sources = /* @__PURE__ */ new WeakMap();
37957
37356
  let useOffscreenCanvas = false;
@@ -38001,16 +37400,25 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38001
37400
  if (texture.isWebGLArrayRenderTarget || texture.isCompressedArrayTexture) return _gl.TEXTURE_2D_ARRAY;
38002
37401
  return _gl.TEXTURE_2D;
38003
37402
  }
38004
- function getInternalFormat(internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false) {
37403
+ function getInternalFormat(internalFormatName, glFormat, glType, normalized, colorSpace, forceLinearTransfer = false) {
38005
37404
  if (internalFormatName !== null) {
38006
37405
  if (_gl[internalFormatName] !== void 0) return _gl[internalFormatName];
38007
37406
  warn2("WebGLRenderer: Attempt to use non-existing WebGL internal format '" + internalFormatName + "'");
38008
37407
  }
37408
+ let ext_texture_norm16;
37409
+ if (normalized) {
37410
+ ext_texture_norm16 = extensions.get("EXT_texture_norm16");
37411
+ if (!ext_texture_norm16) {
37412
+ warn2("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension");
37413
+ }
37414
+ }
38009
37415
  let internalFormat = glFormat;
38010
37416
  if (glFormat === _gl.RED) {
38011
37417
  if (glType === _gl.FLOAT) internalFormat = _gl.R32F;
38012
37418
  if (glType === _gl.HALF_FLOAT) internalFormat = _gl.R16F;
38013
37419
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8;
37420
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.R16_EXT;
37421
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.R16_SNORM_EXT;
38014
37422
  }
38015
37423
  if (glFormat === _gl.RED_INTEGER) {
38016
37424
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8UI;
@@ -38024,6 +37432,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38024
37432
  if (glType === _gl.FLOAT) internalFormat = _gl.RG32F;
38025
37433
  if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RG16F;
38026
37434
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8;
37435
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RG16_EXT;
37436
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RG16_SNORM_EXT;
38027
37437
  }
38028
37438
  if (glFormat === _gl.RG_INTEGER) {
38029
37439
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8UI;
@@ -38050,6 +37460,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38050
37460
  if (glType === _gl.INT) internalFormat = _gl.RGBA32I;
38051
37461
  }
38052
37462
  if (glFormat === _gl.RGB) {
37463
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGB16_EXT;
37464
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGB16_SNORM_EXT;
38053
37465
  if (glType === _gl.UNSIGNED_INT_5_9_9_9_REV) internalFormat = _gl.RGB9_E5;
38054
37466
  if (glType === _gl.UNSIGNED_INT_10F_11F_11F_REV) internalFormat = _gl.R11F_G11F_B10F;
38055
37467
  }
@@ -38058,6 +37470,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38058
37470
  if (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F;
38059
37471
  if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F;
38060
37472
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = transfer === SRGBTransfer ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
37473
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGBA16_EXT;
37474
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGBA16_SNORM_EXT;
38061
37475
  if (glType === _gl.UNSIGNED_SHORT_4_4_4_4) internalFormat = _gl.RGBA4;
38062
37476
  if (glType === _gl.UNSIGNED_SHORT_5_5_5_1) internalFormat = _gl.RGB5_A1;
38063
37477
  }
@@ -38106,6 +37520,9 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38106
37520
  if (texture.isVideoTexture) {
38107
37521
  _videoTextures.delete(texture);
38108
37522
  }
37523
+ if (texture.isHTMLTexture) {
37524
+ _htmlTextures.delete(texture);
37525
+ }
38109
37526
  }
38110
37527
  function onRenderTargetDispose(event) {
38111
37528
  const renderTarget = event.target;
@@ -38182,6 +37599,12 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38182
37599
  function resetTextureUnits() {
38183
37600
  textureUnits = 0;
38184
37601
  }
37602
+ function getTextureUnits() {
37603
+ return textureUnits;
37604
+ }
37605
+ function setTextureUnits(value2) {
37606
+ textureUnits = value2;
37607
+ }
38185
37608
  function allocateTextureUnit() {
38186
37609
  const textureUnit = textureUnits;
38187
37610
  if (textureUnit >= capabilities.maxTextures) {
@@ -38364,10 +37787,10 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38364
37787
  }
38365
37788
  }
38366
37789
  updateRanges.length = mergeIndex + 1;
38367
- const currentUnpackRowLen = _gl.getParameter(_gl.UNPACK_ROW_LENGTH);
38368
- const currentUnpackSkipPixels = _gl.getParameter(_gl.UNPACK_SKIP_PIXELS);
38369
- const currentUnpackSkipRows = _gl.getParameter(_gl.UNPACK_SKIP_ROWS);
38370
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
37790
+ const currentUnpackRowLen = state.getParameter(_gl.UNPACK_ROW_LENGTH);
37791
+ const currentUnpackSkipPixels = state.getParameter(_gl.UNPACK_SKIP_PIXELS);
37792
+ const currentUnpackSkipRows = state.getParameter(_gl.UNPACK_SKIP_ROWS);
37793
+ state.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
38371
37794
  for (let i = 0, l = updateRanges.length; i < l; i++) {
38372
37795
  const range = updateRanges[i];
38373
37796
  const pixelStart = Math.floor(range.start / componentStride);
@@ -38376,14 +37799,14 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38376
37799
  const y = Math.floor(pixelStart / image.width);
38377
37800
  const width = pixelCount;
38378
37801
  const height = 1;
38379
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, x);
38380
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, y);
37802
+ state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, x);
37803
+ state.pixelStorei(_gl.UNPACK_SKIP_ROWS, y);
38381
37804
  state.texSubImage2D(_gl.TEXTURE_2D, 0, x, y, width, height, glFormat, glType, image.data);
38382
37805
  }
38383
37806
  texture.clearUpdateRanges();
38384
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
38385
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
38386
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
37807
+ state.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
37808
+ state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
37809
+ state.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
38387
37810
  }
38388
37811
  }
38389
37812
  function uploadTexture(textureProperties, texture, slot) {
@@ -38396,18 +37819,21 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38396
37819
  const sourceProperties = properties.get(source);
38397
37820
  if (source.version !== sourceProperties.__version || forceUpload === true) {
38398
37821
  state.activeTexture(_gl.TEXTURE0 + slot);
38399
- const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
38400
- const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
38401
- const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
38402
- _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
38403
- _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
38404
- _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
38405
- _gl.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
37822
+ const isImageBitmap = typeof ImageBitmap !== "undefined" && texture.image instanceof ImageBitmap;
37823
+ if (isImageBitmap === false) {
37824
+ const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
37825
+ const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
37826
+ const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
37827
+ state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
37828
+ state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
37829
+ state.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
37830
+ }
37831
+ state.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
38406
37832
  let image = resizeImage(texture.image, false, capabilities.maxTextureSize);
38407
37833
  image = verifyColorSpace(texture, image);
38408
37834
  const glFormat = utils.convert(texture.format, texture.colorSpace);
38409
37835
  const glType = utils.convert(texture.type);
38410
- let glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture);
37836
+ let glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace, texture.isVideoTexture);
38411
37837
  setTextureParameters(textureType, texture);
38412
37838
  let mipmap;
38413
37839
  const mipmaps = texture.mipmaps;
@@ -38569,6 +37995,35 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38569
37995
  }
38570
37996
  }
38571
37997
  }
37998
+ } else if (texture.isHTMLTexture) {
37999
+ if ("texElementImage2D" in _gl) {
38000
+ const canvas = _gl.canvas;
38001
+ if (!canvas.hasAttribute("layoutsubtree")) {
38002
+ canvas.setAttribute("layoutsubtree", "true");
38003
+ }
38004
+ if (image.parentNode !== canvas) {
38005
+ canvas.appendChild(image);
38006
+ _htmlTextures.add(texture);
38007
+ canvas.onpaint = (event) => {
38008
+ const changed = event.changedElements;
38009
+ for (const t of _htmlTextures) {
38010
+ if (changed.includes(t.image)) {
38011
+ t.needsUpdate = true;
38012
+ }
38013
+ }
38014
+ };
38015
+ canvas.requestPaint();
38016
+ return;
38017
+ }
38018
+ const level = 0;
38019
+ const internalFormat = _gl.RGBA;
38020
+ const srcFormat = _gl.RGBA;
38021
+ const srcType = _gl.UNSIGNED_BYTE;
38022
+ _gl.texElementImage2D(_gl.TEXTURE_2D, level, internalFormat, srcFormat, srcType, image);
38023
+ _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR);
38024
+ _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE);
38025
+ _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE);
38026
+ }
38572
38027
  } else {
38573
38028
  if (mipmaps.length > 0) {
38574
38029
  if (useTexStorage && allocateMemory) {
@@ -38619,10 +38074,10 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38619
38074
  const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
38620
38075
  const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
38621
38076
  const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
38622
- _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
38623
- _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
38624
- _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
38625
- _gl.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
38077
+ state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
38078
+ state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
38079
+ state.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
38080
+ state.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
38626
38081
  const isCompressed = texture.isCompressedTexture || texture.image[0].isCompressedTexture;
38627
38082
  const isDataTexture = texture.image[0] && texture.image[0].isDataTexture;
38628
38083
  const cubeImage = [];
@@ -38634,7 +38089,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38634
38089
  }
38635
38090
  cubeImage[i] = verifyColorSpace(texture, cubeImage[i]);
38636
38091
  }
38637
- const image = cubeImage[0], glFormat = utils.convert(texture.format, texture.colorSpace), glType = utils.convert(texture.type), glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
38092
+ const image = cubeImage[0], glFormat = utils.convert(texture.format, texture.colorSpace), glType = utils.convert(texture.type), glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
38638
38093
  const useTexStorage = texture.isVideoTexture !== true;
38639
38094
  const allocateMemory = sourceProperties.__version === void 0 || forceUpload === true;
38640
38095
  const dataReady = source.dataReady;
@@ -38731,7 +38186,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38731
38186
  function setupFrameBufferTexture(framebuffer, renderTarget, texture, attachment, textureTarget, level) {
38732
38187
  const glFormat = utils.convert(texture.format, texture.colorSpace);
38733
38188
  const glType = utils.convert(texture.type);
38734
- const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
38189
+ const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
38735
38190
  const renderTargetProperties = properties.get(renderTarget);
38736
38191
  const textureProperties = properties.get(texture);
38737
38192
  textureProperties.__renderTarget = renderTarget;
@@ -38773,7 +38228,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38773
38228
  const texture = textures[i];
38774
38229
  const glFormat = utils.convert(texture.format, texture.colorSpace);
38775
38230
  const glType = utils.convert(texture.type);
38776
- const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
38231
+ const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
38777
38232
  if (useMultisampledRTT(renderTarget)) {
38778
38233
  multisampledRTTExt.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, getRenderTargetSamples(renderTarget), glInternalFormat, renderTarget.width, renderTarget.height);
38779
38234
  } else if (useMultisample) {
@@ -38973,7 +38428,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38973
38428
  _gl.bindRenderbuffer(_gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);
38974
38429
  const glFormat = utils.convert(texture2.format, texture2.colorSpace);
38975
38430
  const glType = utils.convert(texture2.type);
38976
- const glInternalFormat = getInternalFormat(texture2.internalFormat, glFormat, glType, texture2.colorSpace, renderTarget.isXRRenderTarget === true);
38431
+ const glInternalFormat = getInternalFormat(texture2.internalFormat, glFormat, glType, texture2.normalized, texture2.colorSpace, renderTarget.isXRRenderTarget === true);
38977
38432
  const samples = getRenderTargetSamples(renderTarget);
38978
38433
  _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
38979
38434
  _gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);
@@ -39169,6 +38624,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
39169
38624
  }
39170
38625
  this.allocateTextureUnit = allocateTextureUnit;
39171
38626
  this.resetTextureUnits = resetTextureUnits;
38627
+ this.getTextureUnits = getTextureUnits;
38628
+ this.setTextureUnits = setTextureUnits;
39172
38629
  this.setTexture2D = setTexture2D;
39173
38630
  this.setTexture2DArray = setTexture2DArray;
39174
38631
  this.setTexture3D = setTexture3D;
@@ -39889,8 +39346,9 @@ var WebXRManager = class extends EventDispatcher {
39889
39346
  };
39890
39347
  }
39891
39348
  };
39892
- var _e1 = /* @__PURE__ */ new Euler();
39893
39349
  var _m12 = /* @__PURE__ */ new Matrix4();
39350
+ var _m = /* @__PURE__ */ new Matrix3();
39351
+ _m.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
39894
39352
  function WebGLMaterials(renderer, properties) {
39895
39353
  function refreshTransformUniform(map, uniform) {
39896
39354
  if (map.matrixAutoUpdate === true) {
@@ -39908,7 +39366,9 @@ function WebGLMaterials(renderer, properties) {
39908
39366
  }
39909
39367
  }
39910
39368
  function refreshMaterialUniforms(uniforms, material, pixelRatio, height, transmissionRenderTarget) {
39911
- if (material.isMeshBasicMaterial) {
39369
+ if (material.isNodeMaterial) {
39370
+ material.uniformsNeedUpdate = false;
39371
+ } else if (material.isMeshBasicMaterial) {
39912
39372
  refreshUniformsCommon(uniforms, material);
39913
39373
  } else if (material.isMeshLambertMaterial) {
39914
39374
  refreshUniformsCommon(uniforms, material);
@@ -40010,16 +39470,10 @@ function WebGLMaterials(renderer, properties) {
40010
39470
  const envMapRotation = materialProperties.envMapRotation;
40011
39471
  if (envMap) {
40012
39472
  uniforms.envMap.value = envMap;
40013
- _e1.copy(envMapRotation);
40014
- _e1.x *= -1;
40015
- _e1.y *= -1;
40016
- _e1.z *= -1;
39473
+ uniforms.envMapRotation.value.setFromMatrix4(_m12.makeRotationFromEuler(envMapRotation)).transpose();
40017
39474
  if (envMap.isCubeTexture && envMap.isRenderTargetTexture === false) {
40018
- _e1.y *= -1;
40019
- _e1.z *= -1;
39475
+ uniforms.envMapRotation.value.premultiply(_m);
40020
39476
  }
40021
- uniforms.envMapRotation.value.setFromMatrix4(_m12.makeRotationFromEuler(_e1));
40022
- uniforms.flipEnvMap.value = envMap.isCubeTexture && envMap.isRenderTargetTexture === false ? -1 : 1;
40023
39477
  uniforms.reflectivity.value = material.reflectivity;
40024
39478
  uniforms.ior.value = material.ior;
40025
39479
  uniforms.refractionRatio.value = material.refractionRatio;
@@ -40285,6 +39739,8 @@ function WebGLUniformsGroups(gl, info2, capabilities, state) {
40285
39739
  uniform.__data[9] = value2.elements[7];
40286
39740
  uniform.__data[10] = value2.elements[8];
40287
39741
  uniform.__data[11] = 0;
39742
+ } else if (ArrayBuffer.isView(value2)) {
39743
+ uniform.__data.set(new value2.constructor(value2.buffer, value2.byteOffset, uniform.__data.length));
40288
39744
  } else {
40289
39745
  value2.toArray(uniform.__data, arrayOffset);
40290
39746
  arrayOffset += info3.storage / Float32Array.BYTES_PER_ELEMENT;
@@ -40302,6 +39758,8 @@ function WebGLUniformsGroups(gl, info2, capabilities, state) {
40302
39758
  if (cache[indexString] === void 0) {
40303
39759
  if (typeof value2 === "number" || typeof value2 === "boolean") {
40304
39760
  cache[indexString] = value2;
39761
+ } else if (ArrayBuffer.isView(value2)) {
39762
+ cache[indexString] = value2.slice();
40305
39763
  } else {
40306
39764
  cache[indexString] = value2.clone();
40307
39765
  }
@@ -40313,6 +39771,8 @@ function WebGLUniformsGroups(gl, info2, capabilities, state) {
40313
39771
  cache[indexString] = value2;
40314
39772
  return true;
40315
39773
  }
39774
+ } else if (ArrayBuffer.isView(value2)) {
39775
+ return true;
40316
39776
  } else {
40317
39777
  if (cachedObject.equals(value2) === false) {
40318
39778
  cachedObject.copy(value2);
@@ -40380,6 +39840,9 @@ function WebGLUniformsGroups(gl, info2, capabilities, state) {
40380
39840
  info3.storage = 64;
40381
39841
  } else if (value2.isTexture) {
40382
39842
  warn2("WebGLRenderer: Texture samplers can not be part of an uniforms group.");
39843
+ } else if (ArrayBuffer.isView(value2)) {
39844
+ info3.boundary = 16;
39845
+ info3.storage = value2.byteLength;
40383
39846
  } else {
40384
39847
  warn2("WebGLRenderer: Unsupported uniform value type.", value2);
40385
39848
  }
@@ -40983,6 +40446,7 @@ var WebGLRenderer = class {
40983
40446
  ]);
40984
40447
  const uintClearColor = new Uint32Array(4);
40985
40448
  const intClearColor = new Int32Array(4);
40449
+ const objectPosition = new Vector3();
40986
40450
  let currentRenderList = null;
40987
40451
  let currentRenderState = null;
40988
40452
  const renderListStack = [];
@@ -41013,6 +40477,7 @@ var WebGLRenderer = class {
41013
40477
  this.transmissionResolutionScale = 1;
41014
40478
  const _this = this;
41015
40479
  let _isContextLost = false;
40480
+ let _nodesHandler = null;
41016
40481
  this._outputColorSpace = SRGBColorSpace;
41017
40482
  let _currentActiveCubeFace = 0;
41018
40483
  let _currentActiveMipmapLevel = 0;
@@ -41181,13 +40646,13 @@ var WebGLRenderer = class {
41181
40646
  };
41182
40647
  this.setEffects = function(effects) {
41183
40648
  if (_outputBufferType === UnsignedByteType) {
41184
- console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");
40649
+ error2("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");
41185
40650
  return;
41186
40651
  }
41187
40652
  if (effects) {
41188
40653
  for (let i = 0; i < effects.length; i++) {
41189
40654
  if (effects[i].isOutputPass === true) {
41190
- console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");
40655
+ warn2("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");
41191
40656
  break;
41192
40657
  }
41193
40658
  }
@@ -41278,6 +40743,7 @@ var WebGLRenderer = class {
41278
40743
  }
41279
40744
  if (depth2) {
41280
40745
  bits2 |= _gl.DEPTH_BUFFER_BIT;
40746
+ this.state.buffers.depth.setMask(true);
41281
40747
  }
41282
40748
  if (stencil2) {
41283
40749
  bits2 |= _gl.STENCIL_BUFFER_BIT;
@@ -41296,6 +40762,10 @@ var WebGLRenderer = class {
41296
40762
  this.clearStencil = function() {
41297
40763
  this.clear(false, false, true);
41298
40764
  };
40765
+ this.setNodesHandler = function(nodesHandler) {
40766
+ nodesHandler.setRenderer(this);
40767
+ _nodesHandler = nodesHandler;
40768
+ };
41299
40769
  this.dispose = function() {
41300
40770
  canvas.removeEventListener("webglcontextlost", onContextLost, false);
41301
40771
  canvas.removeEventListener("webglcontextrestored", onContextRestore, false);
@@ -41418,23 +40888,18 @@ var WebGLRenderer = class {
41418
40888
  renderer.setMode(_gl.TRIANGLES);
41419
40889
  }
41420
40890
  if (object.isBatchedMesh) {
41421
- if (object._multiDrawInstances !== null) {
41422
- warnOnce("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");
41423
- renderer.renderMultiDrawInstances(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances);
41424
- } else {
41425
- if (!extensions.get("WEBGL_multi_draw")) {
41426
- const starts = object._multiDrawStarts;
41427
- const counts = object._multiDrawCounts;
41428
- const drawCount2 = object._multiDrawCount;
41429
- const bytesPerElement = index ? attributes2.get(index).bytesPerElement : 1;
41430
- const uniforms = properties.get(material).currentProgram.getUniforms();
41431
- for (let i = 0; i < drawCount2; i++) {
41432
- uniforms.setValue(_gl, "_gl_DrawID", i);
41433
- renderer.render(starts[i] / bytesPerElement, counts[i]);
41434
- }
41435
- } else {
41436
- renderer.renderMultiDraw(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount);
40891
+ if (!extensions.get("WEBGL_multi_draw")) {
40892
+ const starts = object._multiDrawStarts;
40893
+ const counts = object._multiDrawCounts;
40894
+ const drawCount2 = object._multiDrawCount;
40895
+ const bytesPerElement = index ? attributes2.get(index).bytesPerElement : 1;
40896
+ const uniforms = properties.get(material).currentProgram.getUniforms();
40897
+ for (let i = 0; i < drawCount2; i++) {
40898
+ uniforms.setValue(_gl, "_gl_DrawID", i);
40899
+ renderer.render(starts[i] / bytesPerElement, counts[i]);
41437
40900
  }
40901
+ } else {
40902
+ renderer.renderMultiDraw(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount);
41438
40903
  }
41439
40904
  } else if (object.isInstancedMesh) {
41440
40905
  renderer.renderInstances(drawStart, drawCount, object.count);
@@ -41555,6 +41020,9 @@ var WebGLRenderer = class {
41555
41020
  return;
41556
41021
  }
41557
41022
  if (_isContextLost === true) return;
41023
+ if (_nodesHandler !== null) {
41024
+ _nodesHandler.renderStart(scene, camera);
41025
+ }
41558
41026
  const isXRPresenting = xr.enabled === true && xr.isPresenting === true;
41559
41027
  const useOutput = output !== null && (_currentRenderTarget === null || isXRPresenting) && output.begin(_this, _currentRenderTarget);
41560
41028
  if (scene.matrixWorldAutoUpdate === true) scene.updateMatrixWorld();
@@ -41566,6 +41034,7 @@ var WebGLRenderer = class {
41566
41034
  if (scene.isScene === true) scene.onBeforeRender(_this, scene, camera, _currentRenderTarget);
41567
41035
  currentRenderState = renderStates.get(scene, renderStateStack.length);
41568
41036
  currentRenderState.init(camera);
41037
+ currentRenderState.state.textureUnits = textures.getTextureUnits();
41569
41038
  renderStateStack.push(currentRenderState);
41570
41039
  _projScreenMatrix3.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
41571
41040
  _frustum.setFromProjectionMatrix(_projScreenMatrix3, WebGLCoordinateSystem, camera.reversedDepth);
@@ -41633,6 +41102,7 @@ var WebGLRenderer = class {
41633
41102
  renderStateStack.pop();
41634
41103
  if (renderStateStack.length > 0) {
41635
41104
  currentRenderState = renderStateStack[renderStateStack.length - 1];
41105
+ textures.setTextureUnits(currentRenderState.state.textureUnits);
41636
41106
  if (_clippingEnabled === true) clipping.setGlobalState(_this.clippingPlanes, currentRenderState.state.camera);
41637
41107
  } else {
41638
41108
  currentRenderState = null;
@@ -41643,6 +41113,9 @@ var WebGLRenderer = class {
41643
41113
  } else {
41644
41114
  currentRenderList = null;
41645
41115
  }
41116
+ if (_nodesHandler !== null) {
41117
+ _nodesHandler.renderEnd();
41118
+ }
41646
41119
  };
41647
41120
  function projectObject(object, camera, groupOrder, sortObjects) {
41648
41121
  if (object.visible === false) return;
@@ -41652,6 +41125,8 @@ var WebGLRenderer = class {
41652
41125
  groupOrder = object.renderOrder;
41653
41126
  } else if (object.isLOD) {
41654
41127
  if (object.autoUpdate === true) object.update(camera);
41128
+ } else if (object.isLightProbeGrid) {
41129
+ currentRenderState.pushLightProbeGrid(object);
41655
41130
  } else if (object.isLight) {
41656
41131
  currentRenderState.pushLight(object);
41657
41132
  if (object.castShadow) {
@@ -41818,7 +41293,7 @@ var WebGLRenderer = class {
41818
41293
  const lights = currentRenderState.state.lights;
41819
41294
  const shadowsArray = currentRenderState.state.shadowsArray;
41820
41295
  const lightsStateVersion = lights.state.version;
41821
- const parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, object);
41296
+ const parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, object, currentRenderState.state.lightProbeGridArray);
41822
41297
  const programCacheKey = programCache.getProgramCacheKey(parameters2);
41823
41298
  let programs = materialProperties.programs;
41824
41299
  materialProperties.environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
@@ -41839,6 +41314,9 @@ var WebGLRenderer = class {
41839
41314
  }
41840
41315
  } else {
41841
41316
  parameters2.uniforms = programCache.getUniforms(material);
41317
+ if (_nodesHandler !== null && material.isNodeMaterial) {
41318
+ _nodesHandler.build(material, object, parameters2);
41319
+ }
41842
41320
  material.onBeforeCompile(parameters2, _this);
41843
41321
  program = programCache.acquireProgram(parameters2, programCacheKey);
41844
41322
  programs.set(programCacheKey, program);
@@ -41869,6 +41347,7 @@ var WebGLRenderer = class {
41869
41347
  uniforms.spotLightMap.value = lights.state.spotLightMap;
41870
41348
  uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
41871
41349
  }
41350
+ materialProperties.lightProbeGrid = currentRenderState.state.lightProbeGridArray.length > 0;
41872
41351
  materialProperties.currentProgram = program;
41873
41352
  materialProperties.uniformsList = null;
41874
41353
  return program;
@@ -41899,12 +41378,24 @@ var WebGLRenderer = class {
41899
41378
  materialProperties.vertexTangents = parameters2.vertexTangents;
41900
41379
  materialProperties.toneMapping = parameters2.toneMapping;
41901
41380
  }
41381
+ function findLightProbeGrid(volumes, object) {
41382
+ if (volumes.length === 0) return null;
41383
+ if (volumes.length === 1) {
41384
+ return volumes[0].texture !== null ? volumes[0] : null;
41385
+ }
41386
+ objectPosition.setFromMatrixPosition(object.matrixWorld);
41387
+ for (let i = 0, l = volumes.length; i < l; i++) {
41388
+ const v = volumes[i];
41389
+ if (v.texture !== null && v.boundingBox.containsPoint(objectPosition)) return v;
41390
+ }
41391
+ return null;
41392
+ }
41902
41393
  function setProgram(camera, scene, geometry, material, object) {
41903
41394
  if (scene.isScene !== true) scene = _emptyScene;
41904
41395
  textures.resetTextureUnits();
41905
41396
  const fog = scene.fog;
41906
41397
  const environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
41907
- const colorSpace = _currentRenderTarget === null ? _this.outputColorSpace : _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace;
41398
+ const colorSpace = _currentRenderTarget === null ? _this.outputColorSpace : _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace;
41908
41399
  const usePMREM = material.isMeshStandardMaterial || material.isMeshLambertMaterial && !material.envMap || material.isMeshPhongMaterial && !material.envMap;
41909
41400
  const envMap = environments.get(material.envMap || environment, usePMREM);
41910
41401
  const vertexAlphas = material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4;
@@ -41978,6 +41469,8 @@ var WebGLRenderer = class {
41978
41469
  needsProgramChange = true;
41979
41470
  } else if (materialProperties.morphTargetsCount !== morphTargetsCount) {
41980
41471
  needsProgramChange = true;
41472
+ } else if (!!materialProperties.lightProbeGrid !== currentRenderState.state.lightProbeGridArray.length > 0) {
41473
+ needsProgramChange = true;
41981
41474
  }
41982
41475
  } else {
41983
41476
  needsProgramChange = true;
@@ -41986,6 +41479,9 @@ var WebGLRenderer = class {
41986
41479
  let program = materialProperties.currentProgram;
41987
41480
  if (needsProgramChange === true) {
41988
41481
  program = getProgram(material, scene, object);
41482
+ if (_nodesHandler && material.isNodeMaterial) {
41483
+ _nodesHandler.onUpdateProgram(material, program, materialProperties);
41484
+ }
41989
41485
  }
41990
41486
  let refreshProgram = false;
41991
41487
  let refreshMaterial = false;
@@ -42000,6 +41496,13 @@ var WebGLRenderer = class {
42000
41496
  _currentMaterialId = material.id;
42001
41497
  refreshMaterial = true;
42002
41498
  }
41499
+ if (materialProperties.needsLights) {
41500
+ const objectVolume = findLightProbeGrid(currentRenderState.state.lightProbeGridArray, object);
41501
+ if (materialProperties.lightProbeGrid !== objectVolume) {
41502
+ materialProperties.lightProbeGrid = objectVolume;
41503
+ refreshMaterial = true;
41504
+ }
41505
+ }
42003
41506
  if (refreshProgram || _currentCamera !== camera) {
42004
41507
  const reversedDepthBuffer2 = state.buffers.depth.getReversed();
42005
41508
  if (reversedDepthBuffer2 && camera.reversedDepth !== true) {
@@ -42081,6 +41584,13 @@ var WebGLRenderer = class {
42081
41584
  materials.refreshFogUniforms(m_uniforms, fog);
42082
41585
  }
42083
41586
  materials.refreshMaterialUniforms(m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[camera.id]);
41587
+ if (materialProperties.needsLights && materialProperties.lightProbeGrid) {
41588
+ const volume = materialProperties.lightProbeGrid;
41589
+ m_uniforms.probesSH.value = volume.texture;
41590
+ m_uniforms.probesMin.value.copy(volume.boundingBox.min);
41591
+ m_uniforms.probesMax.value.copy(volume.boundingBox.max);
41592
+ m_uniforms.probesResolution.value.copy(volume.resolution);
41593
+ }
42084
41594
  WebGLUniforms.upload(_gl, getUniformList(materialProperties), m_uniforms, textures);
42085
41595
  }
42086
41596
  if (material.isShaderMaterial && material.uniformsNeedUpdate === true) {
@@ -42093,7 +41603,7 @@ var WebGLRenderer = class {
42093
41603
  p_uniforms.setValue(_gl, "modelViewMatrix", object.modelViewMatrix);
42094
41604
  p_uniforms.setValue(_gl, "normalMatrix", object.normalMatrix);
42095
41605
  p_uniforms.setValue(_gl, "modelMatrix", object.matrixWorld);
42096
- if (material.isShaderMaterial || material.isRawShaderMaterial) {
41606
+ if (material.uniformsGroups !== void 0) {
42097
41607
  const groups = material.uniformsGroups;
42098
41608
  for (let i = 0, l = groups.length; i < l; i++) {
42099
41609
  const group2 = groups[i];
@@ -42362,19 +41872,20 @@ var WebGLRenderer = class {
42362
41872
  textures.setTexture2D(dstTexture, 0);
42363
41873
  glTarget = _gl.TEXTURE_2D;
42364
41874
  }
42365
- _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY);
42366
- _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha);
42367
- _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment);
42368
- const currentUnpackRowLen = _gl.getParameter(_gl.UNPACK_ROW_LENGTH);
42369
- const currentUnpackImageHeight = _gl.getParameter(_gl.UNPACK_IMAGE_HEIGHT);
42370
- const currentUnpackSkipPixels = _gl.getParameter(_gl.UNPACK_SKIP_PIXELS);
42371
- const currentUnpackSkipRows = _gl.getParameter(_gl.UNPACK_SKIP_ROWS);
42372
- const currentUnpackSkipImages = _gl.getParameter(_gl.UNPACK_SKIP_IMAGES);
42373
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
42374
- _gl.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, image.height);
42375
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, minX);
42376
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, minY);
42377
- _gl.pixelStorei(_gl.UNPACK_SKIP_IMAGES, minZ);
41875
+ state.activeTexture(_gl.TEXTURE0);
41876
+ state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY);
41877
+ state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha);
41878
+ state.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment);
41879
+ const currentUnpackRowLen = state.getParameter(_gl.UNPACK_ROW_LENGTH);
41880
+ const currentUnpackImageHeight = state.getParameter(_gl.UNPACK_IMAGE_HEIGHT);
41881
+ const currentUnpackSkipPixels = state.getParameter(_gl.UNPACK_SKIP_PIXELS);
41882
+ const currentUnpackSkipRows = state.getParameter(_gl.UNPACK_SKIP_ROWS);
41883
+ const currentUnpackSkipImages = state.getParameter(_gl.UNPACK_SKIP_IMAGES);
41884
+ state.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
41885
+ state.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, image.height);
41886
+ state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, minX);
41887
+ state.pixelStorei(_gl.UNPACK_SKIP_ROWS, minY);
41888
+ state.pixelStorei(_gl.UNPACK_SKIP_IMAGES, minZ);
42378
41889
  const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture;
42379
41890
  const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture;
42380
41891
  if (srcTexture.isDepthTexture) {
@@ -42438,11 +41949,11 @@ var WebGLRenderer = class {
42438
41949
  }
42439
41950
  }
42440
41951
  }
42441
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
42442
- _gl.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight);
42443
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
42444
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
42445
- _gl.pixelStorei(_gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages);
41952
+ state.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
41953
+ state.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight);
41954
+ state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
41955
+ state.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
41956
+ state.pixelStorei(_gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages);
42446
41957
  if (dstLevel === 0 && dstTexture.generateMipmaps) {
42447
41958
  _gl.generateMipmap(glTarget);
42448
41959
  }
@@ -42507,7 +42018,7 @@ var WebGLRenderer = class {
42507
42018
 
42508
42019
  // ../../../node_modules/three/examples/jsm/controls/OrbitControls.js
42509
42020
  init_console_gjs();
42510
- init_auto_globals_495e9d950c();
42021
+ init_auto_globals_97a682e619();
42511
42022
  var _changeEvent = { type: "change" };
42512
42023
  var _startEvent = { type: "start" };
42513
42024
  var _endEvent = { type: "end" };
@@ -42649,7 +42160,7 @@ var OrbitControls = class extends Controls {
42649
42160
  this.stopListenToKeyEvents();
42650
42161
  const document3 = this.domElement.getRootNode();
42651
42162
  document3.removeEventListener("keydown", this._interceptControlDown, { capture: true });
42652
- this.domElement.style.touchAction = "auto";
42163
+ this.domElement.style.touchAction = "";
42653
42164
  }
42654
42165
  dispose() {
42655
42166
  this.disconnect();
@@ -43419,11 +42930,11 @@ function interceptControlUp(event) {
43419
42930
 
43420
42931
  // ../../../node_modules/three/examples/jsm/postprocessing/EffectComposer.js
43421
42932
  init_console_gjs();
43422
- init_auto_globals_495e9d950c();
42933
+ init_auto_globals_97a682e619();
43423
42934
 
43424
42935
  // ../../../node_modules/three/examples/jsm/shaders/CopyShader.js
43425
42936
  init_console_gjs();
43426
- init_auto_globals_495e9d950c();
42937
+ init_auto_globals_97a682e619();
43427
42938
  var CopyShader = {
43428
42939
  name: "CopyShader",
43429
42940
  uniforms: {
@@ -43465,11 +42976,11 @@ var CopyShader = {
43465
42976
 
43466
42977
  // ../../../node_modules/three/examples/jsm/postprocessing/ShaderPass.js
43467
42978
  init_console_gjs();
43468
- init_auto_globals_495e9d950c();
42979
+ init_auto_globals_97a682e619();
43469
42980
 
43470
42981
  // ../../../node_modules/three/examples/jsm/postprocessing/Pass.js
43471
42982
  init_console_gjs();
43472
- init_auto_globals_495e9d950c();
42983
+ init_auto_globals_97a682e619();
43473
42984
  var Pass = class {
43474
42985
  /**
43475
42986
  * Constructs a new pass.
@@ -43627,7 +43138,7 @@ var ShaderPass = class extends Pass {
43627
43138
 
43628
43139
  // ../../../node_modules/three/examples/jsm/postprocessing/MaskPass.js
43629
43140
  init_console_gjs();
43630
- init_auto_globals_495e9d950c();
43141
+ init_auto_globals_97a682e619();
43631
43142
  var MaskPass = class extends Pass {
43632
43143
  /**
43633
43144
  * Constructs a new mask pass.
@@ -43902,7 +43413,7 @@ var EffectComposer = class {
43902
43413
 
43903
43414
  // ../../../node_modules/three/examples/jsm/postprocessing/RenderPixelatedPass.js
43904
43415
  init_console_gjs();
43905
- init_auto_globals_495e9d950c();
43416
+ init_auto_globals_97a682e619();
43906
43417
  var RenderPixelatedPass = class extends Pass {
43907
43418
  /**
43908
43419
  * Constructs a new render pixelated pass.
@@ -44124,11 +43635,11 @@ var RenderPixelatedPass = class extends Pass {
44124
43635
 
44125
43636
  // ../../../node_modules/three/examples/jsm/postprocessing/OutputPass.js
44126
43637
  init_console_gjs();
44127
- init_auto_globals_495e9d950c();
43638
+ init_auto_globals_97a682e619();
44128
43639
 
44129
43640
  // ../../../node_modules/three/examples/jsm/shaders/OutputShader.js
44130
43641
  init_console_gjs();
44131
- init_auto_globals_495e9d950c();
43642
+ init_auto_globals_97a682e619();
44132
43643
  var OutputShader = {
44133
43644
  name: "OutputShader",
44134
43645
  uniforms: {
@@ -45737,7 +45248,7 @@ start.__type = [() => __\u03A9HTMLCanvasElement, "canvas", () => __\u03A9StartOp
45737
45248
 
45738
45249
  // blueprint:./pixel-window.blp
45739
45250
  init_console_gjs();
45740
- init_auto_globals_495e9d950c();
45251
+ init_auto_globals_97a682e619();
45741
45252
  var pixel_window_default = '<?xml version="1.0" encoding="UTF-8"?>\n<!--\nDO NOT EDIT!\nThis file was @generated by blueprint-compiler. Instead, edit the\ncorresponding .blp file and regenerate this file with blueprint-compiler.\n-->\n<interface>\n <requires lib="gtk" version="4.0"/>\n <template class="PixelWindow" parent="AdwApplicationWindow">\n <property name="default-width">1100</property>\n <property name="default-height">700</property>\n <property name="title">Pixel Post-Processing</property>\n <child type="breakpoint">\n <object class="AdwBreakpoint">\n <condition>max-width: 799sp</condition>\n <setter object="splitView" property="collapsed">true</setter>\n <setter object="splitView" property="show-sidebar">false</setter>\n </object>\n </child>\n <child type="breakpoint">\n <object class="AdwBreakpoint">\n <condition>min-width: 800sp</condition>\n <setter object="splitView" property="collapsed">false</setter>\n <setter object="splitView" property="show-sidebar">true</setter>\n </object>\n </child>\n <property name="content">\n <object class="GtkBox">\n <property name="orientation">1</property>\n <child>\n <object class="AdwHeaderBar">\n <child type="start">\n <object class="GtkToggleButton" id="sidebarToggleButton">\n <property name="icon-name">sidebar-show-symbolic</property>\n <property name="tooltip-text">Toggle Sidebar</property>\n <property name="active" bind-source="splitView" bind-property="show-sidebar" bind-flags="sync-create"/>\n </object>\n </child>\n <child type="end">\n <object class="GtkButton" id="pauseButton">\n <property name="icon-name">media-playback-pause-symbolic</property>\n <property name="tooltip-text">Pause Rendering</property>\n </object>\n </child>\n </object>\n </child>\n <child>\n <object class="AdwOverlaySplitView" id="splitView">\n <property name="sidebar-width-fraction">0.3</property>\n <property name="min-sidebar-width">280</property>\n <property name="max-sidebar-width">400</property>\n <property name="show-sidebar" bind-source="sidebarToggleButton" bind-property="active" bind-flags="sync-create"/>\n <property name="sidebar">\n <object class="GtkScrolledWindow">\n <property name="hscrollbar-policy">2</property>\n <child>\n <object class="GtkBox">\n <property name="orientation">1</property>\n <property name="spacing">12</property>\n <property name="margin-top">12</property>\n <property name="margin-bottom">12</property>\n <property name="margin-start">12</property>\n <property name="margin-end">12</property>\n <child>\n <object class="AdwPreferencesGroup">\n <property name="title">Post-Processing</property>\n <child>\n <object class="AdwSpinRow" id="pixelSizeRow">\n <property name="title">Pixel Size</property>\n </object>\n </child>\n <child>\n <object class="AdwSpinRow" id="normalEdgeRow">\n <property name="title">Normal Edge</property>\n </object>\n </child>\n <child>\n <object class="AdwSpinRow" id="depthEdgeRow">\n <property name="title">Depth Edge</property>\n </object>\n </child>\n <child>\n <object class="AdwSwitchRow" id="pixelAlignRow">\n <property name="title">Pixel-Aligned Panning</property>\n <property name="active">true</property>\n </object>\n </child>\n </object>\n </child>\n </object>\n </child>\n </object>\n </property>\n <property name="content">\n <object class="GtkBox" id="glAreaContainer">\n <property name="hexpand">true</property>\n <property name="vexpand">true</property>\n </object>\n </property>\n </object>\n </child>\n </object>\n </property>\n </template>\n</interface>';
45742
45253
 
45743
45254
  // src/gjs/pixel-window.ts
@@ -45746,7 +45257,7 @@ function __assignType2(fn, args) {
45746
45257
  return fn;
45747
45258
  }
45748
45259
  var PixelWindow = class extends Adw.ApplicationWindow {
45749
- /** Live demo reference; set once the CanvasWebGLWidget is ready. */
45260
+ /** Live demo reference; set once the WebGLBridge is ready. */
45750
45261
  _demo = null;
45751
45262
  static {
45752
45263
  GObject2.registerClass({
@@ -45786,7 +45297,7 @@ var PixelWindow = class extends Adw.ApplicationWindow {
45786
45297
  value: 0.4
45787
45298
  }));
45788
45299
  this._depthEdgeRow.set_digits(2);
45789
- const glArea = new CanvasWebGLWidget();
45300
+ const glArea = new WebGLBridge();
45790
45301
  glArea.set_hexpand(true);
45791
45302
  glArea.set_vexpand(true);
45792
45303
  glArea.installGlobals();