@gjsify/example-dom-three-geometry-teapot 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 +1065 -1554
  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 GLib3 = getGLib();
6173
+ if (!GLib3) return;
6174
+ const timeoutAdd = GLib3.timeout_add.bind(GLib3);
6175
+ this._id = timeoutAdd(GLib3.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 GLib3.SOURCE_CONTINUE;
6184
+ this._id = null;
6185
+ return GLib3.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 GLib3 = getGjsGlobal().imports?.gi?.GLib;
6629
- if (GLib3) {
6630
- const [, contents] = GLib3.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 GLib3 = getGjsGlobal().imports?.gi?.GLib;
6644
- if (GLib3) {
6645
- const osInfo = GLib3.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 GLib3 = getGjsGlobal().imports?.gi?.GLib;
6673
- if (GLib3?.get_current_dir) return GLib3.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 GLib3 = getGjsGlobal().imports?.gi?.GLib;
6684
- if (GLib3) {
6685
- return new Proxy({}, {
6686
- get(_target2, prop) {
6687
- if (typeof prop !== "string") return void 0;
6688
- return GLib3.getenv(prop) ?? void 0;
6689
- },
6690
- set(_target2, prop, value2) {
6691
- if (typeof prop !== "string") return false;
6692
- GLib3.setenv(prop, String(value2), true);
6693
- return true;
6694
- },
6695
- deleteProperty(_target2, prop) {
6696
- if (typeof prop !== "string") return false;
6697
- GLib3.unsetenv(prop);
6698
- return true;
6699
- },
6700
- has(_target2, prop) {
6701
- if (typeof prop !== "string") return false;
6702
- return GLib3.getenv(prop) !== null;
6703
- },
6704
- ownKeys(_target2) {
6705
- const envp = GLib3.listenv();
6706
- return envp;
6707
- },
6708
- getOwnPropertyDescriptor(_target2, prop) {
6709
- if (typeof prop !== "string") return void 0;
6710
- const val = GLib3.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 GLib3 = getGjsGlobal().imports?.gi?.GLib;
6750
- if (GLib3) {
6751
- const [, contents] = GLib3.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 GLib3 = getGjsGlobal().imports?.gi?.GLib;
6765
- if (GLib3?.get_monotonic_time) {
6766
- return BigInt(GLib3.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 GLib3 = getGjsGlobal().imports?.gi?.GLib;
6821
- if (GLib3?.chdir) {
6822
- if (!GLib3.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
- GLib3.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 GLib3 = getGjsGlobal().imports?.gi?.GLib;
6853
- if (GLib3) {
6854
- const sig = typeof signal === "number" ? String(signal) : signal || "SIGTERM";
6855
- const sigArg = sig.startsWith("SIG") ? `-${sig.slice(3)}` : `-${sig}`;
6856
- GLib3.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 GLib3 = getGjsGlobal().imports?.gi?.GLib;
6907
- if (GLib3) {
6908
- const [, contents] = GLib3.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,70 +7805,70 @@ 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/teapot-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 Gtk4 from "gi://Gtk?version=4.0";
8564
7817
  import Adw from "gi://Adw?version=1";
8565
7818
 
8566
- // ../../../packages/dom/webgl/lib/esm/index.js
7819
+ // ../../../packages/framework/webgl/lib/esm/index.js
8567
7820
  init_console_gjs();
8568
- init_auto_globals_495e9d950c();
7821
+ init_auto_globals_97a682e619();
8569
7822
 
8570
7823
  // ../../../node_modules/@girs/gjs/index.js
8571
7824
  init_console_gjs();
8572
- init_auto_globals_495e9d950c();
7825
+ init_auto_globals_97a682e619();
8573
7826
 
8574
7827
  // ../../../node_modules/@girs/gjs/gjs.js
8575
7828
  init_console_gjs();
8576
- init_auto_globals_495e9d950c();
7829
+ init_auto_globals_97a682e619();
8577
7830
  var imports2 = globalThis.imports || {};
8578
7831
 
8579
- // ../../../packages/dom/webgl/lib/esm/index.js
7832
+ // ../../../packages/framework/webgl/lib/esm/index.js
8580
7833
  init_gio_2();
8581
7834
 
8582
7835
  // ../../../node_modules/@girs/gtk-4.0/index.js
8583
7836
  init_console_gjs();
8584
- init_auto_globals_495e9d950c();
7837
+ init_auto_globals_97a682e619();
8585
7838
 
8586
7839
  // ../../../node_modules/@girs/gtk-4.0/gtk-4.0.js
8587
7840
  init_console_gjs();
8588
- init_auto_globals_495e9d950c();
7841
+ init_auto_globals_97a682e619();
8589
7842
  import Gtk from "gi://Gtk?version=4.0";
8590
7843
 
8591
- // ../../../packages/dom/webgl/lib/esm/webgl-rendering-context.js
7844
+ // ../../../packages/framework/webgl/lib/esm/webgl-rendering-context.js
8592
7845
  init_console_gjs();
8593
- init_auto_globals_495e9d950c();
7846
+ init_auto_globals_97a682e619();
8594
7847
 
8595
7848
  // ../../../node_modules/@girs/gwebgl-0.1/index.js
8596
7849
  init_console_gjs();
8597
- init_auto_globals_495e9d950c();
7850
+ init_auto_globals_97a682e619();
8598
7851
 
8599
7852
  // ../../../node_modules/@girs/gwebgl-0.1/gwebgl-0.1.js
8600
7853
  init_console_gjs();
8601
- init_auto_globals_495e9d950c();
7854
+ init_auto_globals_97a682e619();
8602
7855
  import Gwebgl from "gi://Gwebgl?version=0.1";
8603
7856
  var gwebgl_0_1_default = Gwebgl;
8604
7857
 
8605
7858
  // ../../../node_modules/@girs/gwebgl-0.1/index.js
8606
7859
  var gwebgl_0_default = gwebgl_0_1_default;
8607
7860
 
8608
- // ../../../packages/dom/webgl/lib/esm/webgl-context-base.js
7861
+ // ../../../packages/framework/webgl/lib/esm/webgl-context-base.js
8609
7862
  init_console_gjs();
8610
- init_auto_globals_495e9d950c();
7863
+ init_auto_globals_97a682e619();
8611
7864
  init_gdkpixbuf_2();
8612
7865
  var bits = __toESM(require_twiddle(), 1);
8613
7866
  var import_string = __toESM(require_string(), 1);
8614
7867
  import GdkPixbuf3 from "gi://GdkPixbuf?version=2.0";
8615
7868
 
8616
- // ../../../packages/dom/webgl/lib/esm/webgl-context-attributes.js
7869
+ // ../../../packages/framework/webgl/lib/esm/webgl-context-attributes.js
8617
7870
  init_console_gjs();
8618
- init_auto_globals_495e9d950c();
7871
+ init_auto_globals_97a682e619();
8619
7872
  var WebGLContextAttributes = class {
8620
7873
  constructor(alpha, depth, stencil, antialias, premultipliedAlpha, preserveDrawingBuffer, preferLowPowerToHighPerformance, failIfMajorPerformanceCaveat) {
8621
7874
  this.alpha = alpha;
@@ -8637,13 +7890,13 @@ var WebGLContextAttributes = class {
8637
7890
  }
8638
7891
  };
8639
7892
 
8640
- // ../../../packages/dom/webgl/lib/esm/utils.js
7893
+ // ../../../packages/framework/webgl/lib/esm/utils.js
8641
7894
  init_console_gjs();
8642
- init_auto_globals_495e9d950c();
7895
+ init_auto_globals_97a682e619();
8643
7896
 
8644
- // ../../../packages/dom/webgl/lib/esm/webgl-uniform-location.js
7897
+ // ../../../packages/framework/webgl/lib/esm/webgl-uniform-location.js
8645
7898
  init_console_gjs();
8646
- init_auto_globals_495e9d950c();
7899
+ init_auto_globals_97a682e619();
8647
7900
  var WebGLUniformLocation = class {
8648
7901
  constructor(_, program, info2) {
8649
7902
  this._linkCount = 0;
@@ -8656,7 +7909,7 @@ var WebGLUniformLocation = class {
8656
7909
  }
8657
7910
  };
8658
7911
 
8659
- // ../../../packages/dom/webgl/lib/esm/utils.js
7912
+ // ../../../packages/framework/webgl/lib/esm/utils.js
8660
7913
  init_glib_2();
8661
7914
  function checkObject(object) {
8662
7915
  return typeof object === "object" || object === void 0;
@@ -8839,9 +8092,9 @@ function premultiplyAlpha(data) {
8839
8092
  return out;
8840
8093
  }
8841
8094
 
8842
- // ../../../packages/dom/webgl/lib/esm/extensions/oes-element-index-unit.js
8095
+ // ../../../packages/framework/webgl/lib/esm/extensions/oes-element-index-unit.js
8843
8096
  init_console_gjs();
8844
- init_auto_globals_495e9d950c();
8097
+ init_auto_globals_97a682e619();
8845
8098
  var OESElementIndexUint = class {
8846
8099
  };
8847
8100
  function getOESElementIndexUint(context) {
@@ -8853,9 +8106,9 @@ function getOESElementIndexUint(context) {
8853
8106
  return result;
8854
8107
  }
8855
8108
 
8856
- // ../../../packages/dom/webgl/lib/esm/extensions/oes-standard-derivatives.js
8109
+ // ../../../packages/framework/webgl/lib/esm/extensions/oes-standard-derivatives.js
8857
8110
  init_console_gjs();
8858
- init_auto_globals_495e9d950c();
8111
+ init_auto_globals_97a682e619();
8859
8112
  var OESStandardDerivatives = class {
8860
8113
  constructor() {
8861
8114
  this.FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 35723;
@@ -8870,9 +8123,9 @@ function getOESStandardDerivatives(context) {
8870
8123
  return result;
8871
8124
  }
8872
8125
 
8873
- // ../../../packages/dom/webgl/lib/esm/extensions/oes-texture-float.js
8126
+ // ../../../packages/framework/webgl/lib/esm/extensions/oes-texture-float.js
8874
8127
  init_console_gjs();
8875
- init_auto_globals_495e9d950c();
8128
+ init_auto_globals_97a682e619();
8876
8129
  var OESTextureFloat = class {
8877
8130
  };
8878
8131
  function getOESTextureFloat(context) {
@@ -8884,9 +8137,9 @@ function getOESTextureFloat(context) {
8884
8137
  return result;
8885
8138
  }
8886
8139
 
8887
- // ../../../packages/dom/webgl/lib/esm/extensions/oes-texture-float-linear.js
8140
+ // ../../../packages/framework/webgl/lib/esm/extensions/oes-texture-float-linear.js
8888
8141
  init_console_gjs();
8889
- init_auto_globals_495e9d950c();
8142
+ init_auto_globals_97a682e619();
8890
8143
  var OESTextureFloatLinear = class {
8891
8144
  };
8892
8145
  function getOESTextureFloatLinear(context) {
@@ -8898,9 +8151,9 @@ function getOESTextureFloatLinear(context) {
8898
8151
  return result;
8899
8152
  }
8900
8153
 
8901
- // ../../../packages/dom/webgl/lib/esm/extensions/stackgl-destroy-context.js
8154
+ // ../../../packages/framework/webgl/lib/esm/extensions/stackgl-destroy-context.js
8902
8155
  init_console_gjs();
8903
- init_auto_globals_495e9d950c();
8156
+ init_auto_globals_97a682e619();
8904
8157
  var STACKGLDestroyContext = class {
8905
8158
  constructor(ctx) {
8906
8159
  this.destroy = ctx.destroy.bind(ctx);
@@ -8910,9 +8163,9 @@ function getSTACKGLDestroyContext(ctx) {
8910
8163
  return new STACKGLDestroyContext(ctx);
8911
8164
  }
8912
8165
 
8913
- // ../../../packages/dom/webgl/lib/esm/extensions/stackgl-resize-drawing-buffer.js
8166
+ // ../../../packages/framework/webgl/lib/esm/extensions/stackgl-resize-drawing-buffer.js
8914
8167
  init_console_gjs();
8915
- init_auto_globals_495e9d950c();
8168
+ init_auto_globals_97a682e619();
8916
8169
  var STACKGLResizeDrawingBuffer = class {
8917
8170
  constructor(ctx) {
8918
8171
  this.resize = ctx.resize.bind(ctx);
@@ -8922,9 +8175,9 @@ function getSTACKGLResizeDrawingBuffer(ctx) {
8922
8175
  return new STACKGLResizeDrawingBuffer(ctx);
8923
8176
  }
8924
8177
 
8925
- // ../../../packages/dom/webgl/lib/esm/extensions/ext-blend-minmax.js
8178
+ // ../../../packages/framework/webgl/lib/esm/extensions/ext-blend-minmax.js
8926
8179
  init_console_gjs();
8927
- init_auto_globals_495e9d950c();
8180
+ init_auto_globals_97a682e619();
8928
8181
  var EXTBlendMinMax = class {
8929
8182
  constructor() {
8930
8183
  this.MIN_EXT = 32775;
@@ -8940,9 +8193,9 @@ function getEXTBlendMinMax(context) {
8940
8193
  return result;
8941
8194
  }
8942
8195
 
8943
- // ../../../packages/dom/webgl/lib/esm/extensions/ext-color-buffer-float.js
8196
+ // ../../../packages/framework/webgl/lib/esm/extensions/ext-color-buffer-float.js
8944
8197
  init_console_gjs();
8945
- init_auto_globals_495e9d950c();
8198
+ init_auto_globals_97a682e619();
8946
8199
  var EXTColorBufferFloat = class {
8947
8200
  };
8948
8201
  function getEXTColorBufferFloat(context) {
@@ -8953,9 +8206,9 @@ function getEXTColorBufferFloat(context) {
8953
8206
  return null;
8954
8207
  }
8955
8208
 
8956
- // ../../../packages/dom/webgl/lib/esm/extensions/ext-color-buffer-half-float.js
8209
+ // ../../../packages/framework/webgl/lib/esm/extensions/ext-color-buffer-half-float.js
8957
8210
  init_console_gjs();
8958
- init_auto_globals_495e9d950c();
8211
+ init_auto_globals_97a682e619();
8959
8212
  var EXTColorBufferHalfFloat = class {
8960
8213
  };
8961
8214
  function getEXTColorBufferHalfFloat(context) {
@@ -8966,9 +8219,9 @@ function getEXTColorBufferHalfFloat(context) {
8966
8219
  return null;
8967
8220
  }
8968
8221
 
8969
- // ../../../packages/dom/webgl/lib/esm/extensions/ext-texture-filter-anisotropic.js
8222
+ // ../../../packages/framework/webgl/lib/esm/extensions/ext-texture-filter-anisotropic.js
8970
8223
  init_console_gjs();
8971
- init_auto_globals_495e9d950c();
8224
+ init_auto_globals_97a682e619();
8972
8225
  var EXTTextureFilterAnisotropic = class {
8973
8226
  constructor() {
8974
8227
  this.TEXTURE_MAX_ANISOTROPY_EXT = 34046;
@@ -8984,9 +8237,9 @@ function getEXTTextureFilterAnisotropic(context) {
8984
8237
  return result;
8985
8238
  }
8986
8239
 
8987
- // ../../../packages/dom/webgl/lib/esm/extensions/oes-texture-half-float.js
8240
+ // ../../../packages/framework/webgl/lib/esm/extensions/oes-texture-half-float.js
8988
8241
  init_console_gjs();
8989
- init_auto_globals_495e9d950c();
8242
+ init_auto_globals_97a682e619();
8990
8243
  var OESTextureHalfFloat = class {
8991
8244
  constructor() {
8992
8245
  this.HALF_FLOAT_OES = 36193;
@@ -9003,9 +8256,9 @@ function getOESTextureHalfFloat(context) {
9003
8256
  return null;
9004
8257
  }
9005
8258
 
9006
- // ../../../packages/dom/webgl/lib/esm/webgl-active-info.js
8259
+ // ../../../packages/framework/webgl/lib/esm/webgl-active-info.js
9007
8260
  init_console_gjs();
9008
- init_auto_globals_495e9d950c();
8261
+ init_auto_globals_97a682e619();
9009
8262
  var WebGLActiveInfo = class {
9010
8263
  constructor(_) {
9011
8264
  this.size = _.size;
@@ -9014,13 +8267,13 @@ var WebGLActiveInfo = class {
9014
8267
  }
9015
8268
  };
9016
8269
 
9017
- // ../../../packages/dom/webgl/lib/esm/webgl-framebuffer.js
8270
+ // ../../../packages/framework/webgl/lib/esm/webgl-framebuffer.js
9018
8271
  init_console_gjs();
9019
- init_auto_globals_495e9d950c();
8272
+ init_auto_globals_97a682e619();
9020
8273
 
9021
- // ../../../packages/dom/webgl/lib/esm/linkable.js
8274
+ // ../../../packages/framework/webgl/lib/esm/linkable.js
9022
8275
  init_console_gjs();
9023
- init_auto_globals_495e9d950c();
8276
+ init_auto_globals_97a682e619();
9024
8277
  var Linkable = class {
9025
8278
  constructor(_) {
9026
8279
  this._ = 0;
@@ -9069,7 +8322,7 @@ var Linkable = class {
9069
8322
  }
9070
8323
  };
9071
8324
 
9072
- // ../../../packages/dom/webgl/lib/esm/webgl-framebuffer.js
8325
+ // ../../../packages/framework/webgl/lib/esm/webgl-framebuffer.js
9073
8326
  var WebGLFramebuffer = class extends Linkable {
9074
8327
  constructor(_, ctx) {
9075
8328
  super(_);
@@ -9175,9 +8428,9 @@ var WebGLFramebuffer = class extends Linkable {
9175
8428
  }
9176
8429
  };
9177
8430
 
9178
- // ../../../packages/dom/webgl/lib/esm/webgl-buffer.js
8431
+ // ../../../packages/framework/webgl/lib/esm/webgl-buffer.js
9179
8432
  init_console_gjs();
9180
- init_auto_globals_495e9d950c();
8433
+ init_auto_globals_97a682e619();
9181
8434
  var WebGLBuffer = class extends Linkable {
9182
8435
  constructor(_, ctx) {
9183
8436
  super(_);
@@ -9192,9 +8445,9 @@ var WebGLBuffer = class extends Linkable {
9192
8445
  }
9193
8446
  };
9194
8447
 
9195
- // ../../../packages/dom/webgl/lib/esm/webgl-drawing-buffer-wrapper.js
8448
+ // ../../../packages/framework/webgl/lib/esm/webgl-drawing-buffer-wrapper.js
9196
8449
  init_console_gjs();
9197
- init_auto_globals_495e9d950c();
8450
+ init_auto_globals_97a682e619();
9198
8451
  var WebGLDrawingBufferWrapper = class {
9199
8452
  constructor(framebuffer, color, depthStencil) {
9200
8453
  this._framebuffer = framebuffer;
@@ -9203,9 +8456,9 @@ var WebGLDrawingBufferWrapper = class {
9203
8456
  }
9204
8457
  };
9205
8458
 
9206
- // ../../../packages/dom/webgl/lib/esm/webgl-program.js
8459
+ // ../../../packages/framework/webgl/lib/esm/webgl-program.js
9207
8460
  init_console_gjs();
9208
- init_auto_globals_495e9d950c();
8461
+ init_auto_globals_97a682e619();
9209
8462
  var WebGLProgram = class extends Linkable {
9210
8463
  constructor(_, ctx) {
9211
8464
  super(_);
@@ -9228,9 +8481,9 @@ var WebGLProgram = class extends Linkable {
9228
8481
  }
9229
8482
  };
9230
8483
 
9231
- // ../../../packages/dom/webgl/lib/esm/webgl-renderbuffer.js
8484
+ // ../../../packages/framework/webgl/lib/esm/webgl-renderbuffer.js
9232
8485
  init_console_gjs();
9233
- init_auto_globals_495e9d950c();
8486
+ init_auto_globals_97a682e619();
9234
8487
  var WebGLRenderbuffer = class extends Linkable {
9235
8488
  constructor(_, ctx) {
9236
8489
  super(_);
@@ -9251,9 +8504,9 @@ var WebGLRenderbuffer = class extends Linkable {
9251
8504
  }
9252
8505
  };
9253
8506
 
9254
- // ../../../packages/dom/webgl/lib/esm/webgl-shader.js
8507
+ // ../../../packages/framework/webgl/lib/esm/webgl-shader.js
9255
8508
  init_console_gjs();
9256
- init_auto_globals_495e9d950c();
8509
+ init_auto_globals_97a682e619();
9257
8510
  var WebGLShader = class extends Linkable {
9258
8511
  constructor(_, ctx, type) {
9259
8512
  super(_);
@@ -9274,9 +8527,9 @@ var WebGLShader = class extends Linkable {
9274
8527
  }
9275
8528
  };
9276
8529
 
9277
- // ../../../packages/dom/webgl/lib/esm/webgl-shader-precision-format.js
8530
+ // ../../../packages/framework/webgl/lib/esm/webgl-shader-precision-format.js
9278
8531
  init_console_gjs();
9279
- init_auto_globals_495e9d950c();
8532
+ init_auto_globals_97a682e619();
9280
8533
  var WebGLShaderPrecisionFormat = class {
9281
8534
  constructor(_) {
9282
8535
  this.rangeMin = _.rangeMin;
@@ -9285,9 +8538,9 @@ var WebGLShaderPrecisionFormat = class {
9285
8538
  }
9286
8539
  };
9287
8540
 
9288
- // ../../../packages/dom/webgl/lib/esm/webgl-texture-unit.js
8541
+ // ../../../packages/framework/webgl/lib/esm/webgl-texture-unit.js
9289
8542
  init_console_gjs();
9290
- init_auto_globals_495e9d950c();
8543
+ init_auto_globals_97a682e619();
9291
8544
  var WebGLTextureUnit = class {
9292
8545
  constructor(ctx, idx) {
9293
8546
  this._mode = 0;
@@ -9298,9 +8551,9 @@ var WebGLTextureUnit = class {
9298
8551
  }
9299
8552
  };
9300
8553
 
9301
- // ../../../packages/dom/webgl/lib/esm/webgl-texture.js
8554
+ // ../../../packages/framework/webgl/lib/esm/webgl-texture.js
9302
8555
  init_console_gjs();
9303
- init_auto_globals_495e9d950c();
8556
+ init_auto_globals_97a682e619();
9304
8557
  var WebGLTexture = class extends Linkable {
9305
8558
  constructor(_, ctx) {
9306
8559
  super(_);
@@ -9319,9 +8572,9 @@ var WebGLTexture = class extends Linkable {
9319
8572
  }
9320
8573
  };
9321
8574
 
9322
- // ../../../packages/dom/webgl/lib/esm/webgl-vertex-attribute.js
8575
+ // ../../../packages/framework/webgl/lib/esm/webgl-vertex-attribute.js
9323
8576
  init_console_gjs();
9324
- init_auto_globals_495e9d950c();
8577
+ init_auto_globals_97a682e619();
9325
8578
  var WebGLVertexArrayObjectAttribute = class {
9326
8579
  constructor(ctx, idx) {
9327
8580
  this._isPointer = false;
@@ -9463,7 +8716,7 @@ var WebGLVertexArrayGlobalState = class {
9463
8716
  }
9464
8717
  };
9465
8718
 
9466
- // ../../../packages/dom/webgl/lib/esm/webgl-context-base.js
8719
+ // ../../../packages/framework/webgl/lib/esm/webgl-context-base.js
9467
8720
  init_esm();
9468
8721
  var VERSION = "0.0.1";
9469
8722
  var CONTEXT_COUNTER = 0;
@@ -10255,9 +9508,9 @@ var WebGLContextBase = class {
10255
9508
  const glArea = this.canvas.getGlArea();
10256
9509
  const es = glArea.get_use_es();
10257
9510
  const usesGlsl1Syntax = /\b(attribute|varying)\b/.test(source);
10258
- const version2 = usesGlsl1Syntax ? es ? "100" : "120" : this._getGlslVersion(es);
10259
- if (version2) {
10260
- source = "#version " + version2 + "\n" + preamble + source;
9511
+ const version = usesGlsl1Syntax ? es ? "100" : "120" : this._getGlslVersion(es);
9512
+ if (version) {
9513
+ source = "#version " + version + "\n" + preamble + source;
10261
9514
  } else if (preamble) {
10262
9515
  source = preamble + source;
10263
9516
  }
@@ -12788,7 +12041,7 @@ var WebGLContextBase = class {
12788
12041
  }
12789
12042
  };
12790
12043
 
12791
- // ../../../packages/dom/webgl/lib/esm/webgl-rendering-context.js
12044
+ // ../../../packages/framework/webgl/lib/esm/webgl-rendering-context.js
12792
12045
  var WebGLRenderingContext2 = class extends WebGLContextBase {
12793
12046
  constructor(canvas, options = {}) {
12794
12047
  super(canvas, options);
@@ -12971,14 +12224,14 @@ var WebGLRenderingContext2 = class extends WebGLContextBase {
12971
12224
  }
12972
12225
  };
12973
12226
 
12974
- // ../../../packages/dom/webgl/lib/esm/webgl2-rendering-context.js
12227
+ // ../../../packages/framework/webgl/lib/esm/webgl2-rendering-context.js
12975
12228
  init_console_gjs();
12976
- init_auto_globals_495e9d950c();
12229
+ init_auto_globals_97a682e619();
12977
12230
  import GdkPixbuf4 from "gi://GdkPixbuf?version=2.0";
12978
12231
 
12979
- // ../../../packages/dom/webgl/lib/esm/webgl-query.js
12232
+ // ../../../packages/framework/webgl/lib/esm/webgl-query.js
12980
12233
  init_console_gjs();
12981
- init_auto_globals_495e9d950c();
12234
+ init_auto_globals_97a682e619();
12982
12235
  var WebGLQuery = class extends Linkable {
12983
12236
  constructor(_, ctx) {
12984
12237
  super(_);
@@ -12991,9 +12244,9 @@ var WebGLQuery = class extends Linkable {
12991
12244
  }
12992
12245
  };
12993
12246
 
12994
- // ../../../packages/dom/webgl/lib/esm/webgl-sampler.js
12247
+ // ../../../packages/framework/webgl/lib/esm/webgl-sampler.js
12995
12248
  init_console_gjs();
12996
- init_auto_globals_495e9d950c();
12249
+ init_auto_globals_97a682e619();
12997
12250
  var WebGLSampler = class extends Linkable {
12998
12251
  constructor(_, ctx) {
12999
12252
  super(_);
@@ -13006,9 +12259,9 @@ var WebGLSampler = class extends Linkable {
13006
12259
  }
13007
12260
  };
13008
12261
 
13009
- // ../../../packages/dom/webgl/lib/esm/webgl-sync.js
12262
+ // ../../../packages/framework/webgl/lib/esm/webgl-sync.js
13010
12263
  init_console_gjs();
13011
- init_auto_globals_495e9d950c();
12264
+ init_auto_globals_97a682e619();
13012
12265
  var WebGLSync = class extends Linkable {
13013
12266
  constructor(_, ctx) {
13014
12267
  super(_);
@@ -13021,9 +12274,9 @@ var WebGLSync = class extends Linkable {
13021
12274
  }
13022
12275
  };
13023
12276
 
13024
- // ../../../packages/dom/webgl/lib/esm/webgl-transform-feedback.js
12277
+ // ../../../packages/framework/webgl/lib/esm/webgl-transform-feedback.js
13025
12278
  init_console_gjs();
13026
- init_auto_globals_495e9d950c();
12279
+ init_auto_globals_97a682e619();
13027
12280
  var WebGLTransformFeedback = class extends Linkable {
13028
12281
  constructor(_, ctx) {
13029
12282
  super(_);
@@ -13036,9 +12289,9 @@ var WebGLTransformFeedback = class extends Linkable {
13036
12289
  }
13037
12290
  };
13038
12291
 
13039
- // ../../../packages/dom/webgl/lib/esm/webgl-vertex-array-object.js
12292
+ // ../../../packages/framework/webgl/lib/esm/webgl-vertex-array-object.js
13040
12293
  init_console_gjs();
13041
- init_auto_globals_495e9d950c();
12294
+ init_auto_globals_97a682e619();
13042
12295
  var WebGLVertexArrayObject = class extends Linkable {
13043
12296
  constructor(_, ctx) {
13044
12297
  super(_);
@@ -13056,7 +12309,7 @@ var WebGLVertexArrayObject = class extends Linkable {
13056
12309
  }
13057
12310
  };
13058
12311
 
13059
- // ../../../packages/dom/webgl/lib/esm/webgl2-rendering-context.js
12312
+ // ../../../packages/framework/webgl/lib/esm/webgl2-rendering-context.js
13060
12313
  init_esm();
13061
12314
  var WebGL2RenderingContext = class _WebGL2RenderingContext extends WebGLContextBase {
13062
12315
  constructor(canvas, options = {}) {
@@ -13866,8 +13119,18 @@ var WebGL2RenderingContext = class _WebGL2RenderingContext extends WebGLContextB
13866
13119
  this._native2.vertexAttribIPointer(index, size, type, stride, offset);
13867
13120
  }
13868
13121
  drawBuffers(buffers) {
13869
- const mapped = buffers.map((b) => b === 1029 ? this.COLOR_ATTACHMENT0 : b);
13870
- this._native2.drawBuffers(Array.from(mapped));
13122
+ let hasBack = false;
13123
+ for (let i = 0; i < buffers.length; i++) {
13124
+ if (buffers[i] === 1029) {
13125
+ hasBack = true;
13126
+ break;
13127
+ }
13128
+ }
13129
+ if (!hasBack) {
13130
+ this._native2.drawBuffers(buffers);
13131
+ return;
13132
+ }
13133
+ this._native2.drawBuffers(buffers.map((b) => b === 1029 ? this.COLOR_ATTACHMENT0 : b));
13871
13134
  }
13872
13135
  drawRangeElements(mode, start2, end, count2, type, offset) {
13873
13136
  if (count2 < 0 || offset < 0) {
@@ -13964,10 +13227,10 @@ var WebGL2RenderingContext = class _WebGL2RenderingContext extends WebGLContextB
13964
13227
  void drawbuffer;
13965
13228
  }
13966
13229
  invalidateFramebuffer(target, attachments) {
13967
- this._native2.invalidateFramebuffer(target, Array.from(attachments));
13230
+ this._native2.invalidateFramebuffer(target, attachments);
13968
13231
  }
13969
13232
  invalidateSubFramebuffer(target, attachments, x, y, width, height) {
13970
- this._native2.invalidateSubFramebuffer(target, Array.from(attachments), x, y, width, height);
13233
+ this._native2.invalidateSubFramebuffer(target, attachments, x, y, width, height);
13971
13234
  }
13972
13235
  readBuffer(src) {
13973
13236
  this._native2.readBuffer(src);
@@ -14011,53 +13274,53 @@ var WebGL2RenderingContext = class _WebGL2RenderingContext extends WebGLContextB
14011
13274
  uniform1uiv(location, data, _srcOffset, _srcLength) {
14012
13275
  if (!location) return;
14013
13276
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
14014
- this._native2.uniform1uiv(location._, arr.length, Array.from(arr));
13277
+ this._native2.uniform1uiv(location._, arr.length, arr);
14015
13278
  }
14016
13279
  uniform2uiv(location, data, _srcOffset, _srcLength) {
14017
13280
  if (!location) return;
14018
13281
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
14019
- this._native2.uniform2uiv(location._, arr.length / 2, Array.from(arr));
13282
+ this._native2.uniform2uiv(location._, arr.length / 2, arr);
14020
13283
  }
14021
13284
  uniform3uiv(location, data, _srcOffset, _srcLength) {
14022
13285
  if (!location) return;
14023
13286
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
14024
- this._native2.uniform3uiv(location._, arr.length / 3, Array.from(arr));
13287
+ this._native2.uniform3uiv(location._, arr.length / 3, arr);
14025
13288
  }
14026
13289
  uniform4uiv(location, data, _srcOffset, _srcLength) {
14027
13290
  if (!location) return;
14028
13291
  const arr = data instanceof Uint32Array ? data : new Uint32Array(data);
14029
- this._native2.uniform4uiv(location._, arr.length / 4, Array.from(arr));
13292
+ this._native2.uniform4uiv(location._, arr.length / 4, arr);
14030
13293
  }
14031
13294
  // ─── Non-square Matrix Uniforms ───────────────────────────────────────
14032
13295
  uniformMatrix2x3fv(location, transpose, data, _srcOffset, _srcLength) {
14033
13296
  if (!location) return;
14034
13297
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14035
- this._native2.uniformMatrix2x3fv(location._, transpose, Array.from(arr));
13298
+ this._native2.uniformMatrix2x3fv(location._, transpose, arr);
14036
13299
  }
14037
13300
  uniformMatrix3x2fv(location, transpose, data, _srcOffset, _srcLength) {
14038
13301
  if (!location) return;
14039
13302
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14040
- this._native2.uniformMatrix3x2fv(location._, transpose, Array.from(arr));
13303
+ this._native2.uniformMatrix3x2fv(location._, transpose, arr);
14041
13304
  }
14042
13305
  uniformMatrix2x4fv(location, transpose, data, _srcOffset, _srcLength) {
14043
13306
  if (!location) return;
14044
13307
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14045
- this._native2.uniformMatrix2x4fv(location._, transpose, Array.from(arr));
13308
+ this._native2.uniformMatrix2x4fv(location._, transpose, arr);
14046
13309
  }
14047
13310
  uniformMatrix4x2fv(location, transpose, data, _srcOffset, _srcLength) {
14048
13311
  if (!location) return;
14049
13312
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14050
- this._native2.uniformMatrix4x2fv(location._, transpose, Array.from(arr));
13313
+ this._native2.uniformMatrix4x2fv(location._, transpose, arr);
14051
13314
  }
14052
13315
  uniformMatrix3x4fv(location, transpose, data, _srcOffset, _srcLength) {
14053
13316
  if (!location) return;
14054
13317
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14055
- this._native2.uniformMatrix3x4fv(location._, transpose, Array.from(arr));
13318
+ this._native2.uniformMatrix3x4fv(location._, transpose, arr);
14056
13319
  }
14057
13320
  uniformMatrix4x3fv(location, transpose, data, _srcOffset, _srcLength) {
14058
13321
  if (!location) return;
14059
13322
  const arr = data instanceof Float32Array ? data : new Float32Array(data);
14060
- this._native2.uniformMatrix4x3fv(location._, transpose, Array.from(arr));
13323
+ this._native2.uniformMatrix4x3fv(location._, transpose, arr);
14061
13324
  }
14062
13325
  // ─── getUniform — WebGL2 uint type support ────────────────────────────
14063
13326
  /** WebGL1 getUniform falls to default:null for UNSIGNED_INT types. Handle them here. */
@@ -14312,16 +13575,16 @@ var WebGL2RenderingContext = class _WebGL2RenderingContext extends WebGLContextB
14312
13575
  }
14313
13576
  };
14314
13577
 
14315
- // ../../../packages/dom/webgl/lib/esm/html-canvas-element.js
13578
+ // ../../../packages/framework/webgl/lib/esm/html-canvas-element.js
14316
13579
  init_console_gjs();
14317
- init_auto_globals_495e9d950c();
13580
+ init_auto_globals_97a682e619();
14318
13581
 
14319
13582
  // ../../../packages/dom/dom-elements/lib/esm/index.js
14320
13583
  init_console_gjs();
14321
- init_auto_globals_495e9d950c();
13584
+ init_auto_globals_97a682e619();
14322
13585
  init_html_canvas_element();
14323
13586
 
14324
- // ../../../packages/dom/webgl/lib/esm/html-canvas-element.js
13587
+ // ../../../packages/framework/webgl/lib/esm/html-canvas-element.js
14325
13588
  var HTMLCanvasElement3 = class extends HTMLCanvasElement2 {
14326
13589
  constructor(gtkGlArea) {
14327
13590
  super();
@@ -14382,27 +13645,27 @@ var HTMLCanvasElement3 = class extends HTMLCanvasElement2 {
14382
13645
  }
14383
13646
  };
14384
13647
 
14385
- // ../../../packages/dom/webgl/lib/esm/canvas-webgl-widget.js
13648
+ // ../../../packages/framework/webgl/lib/esm/webgl-bridge.js
14386
13649
  init_console_gjs();
14387
- init_auto_globals_495e9d950c();
13650
+ init_auto_globals_97a682e619();
14388
13651
  import GObject from "gi://GObject";
14389
13652
  import GLib2 from "gi://GLib?version=2.0";
14390
13653
  import Gtk3 from "gi://Gtk?version=4.0";
14391
13654
 
14392
- // ../../../packages/dom/event-bridge/lib/esm/index.js
13655
+ // ../../../packages/framework/event-bridge/lib/esm/index.js
14393
13656
  init_console_gjs();
14394
- init_auto_globals_495e9d950c();
13657
+ init_auto_globals_97a682e619();
14395
13658
 
14396
- // ../../../packages/dom/event-bridge/lib/esm/event-bridge.js
13659
+ // ../../../packages/framework/event-bridge/lib/esm/event-bridge.js
14397
13660
  init_console_gjs();
14398
- init_auto_globals_495e9d950c();
13661
+ init_auto_globals_97a682e619();
14399
13662
  init_esm4();
14400
13663
  import Gtk2 from "gi://Gtk?version=4.0";
14401
13664
  import Gdk4 from "gi://Gdk?version=4.0";
14402
13665
 
14403
- // ../../../packages/dom/event-bridge/lib/esm/key-map.js
13666
+ // ../../../packages/framework/event-bridge/lib/esm/key-map.js
14404
13667
  init_console_gjs();
14405
- init_auto_globals_495e9d950c();
13668
+ init_auto_globals_97a682e619();
14406
13669
  import Gdk3 from "gi://Gdk?version=4.0";
14407
13670
  var SPECIAL_KEYS = {
14408
13671
  Return: "Enter",
@@ -14591,7 +13854,7 @@ function gdkKeyvalToLocation(keyval) {
14591
13854
  return 0;
14592
13855
  }
14593
13856
 
14594
- // ../../../packages/dom/event-bridge/lib/esm/event-bridge.js
13857
+ // ../../../packages/framework/event-bridge/lib/esm/event-bridge.js
14595
13858
  function extractModifiers(controller) {
14596
13859
  const mods = controller.get_current_event_state();
14597
13860
  return {
@@ -14777,11 +14040,11 @@ function attachEventControllers(widget, getElement, options) {
14777
14040
  widget.add_controller(focusCtrl);
14778
14041
  }
14779
14042
 
14780
- // ../../../packages/dom/webgl/lib/esm/canvas-webgl-widget.js
14043
+ // ../../../packages/framework/webgl/lib/esm/webgl-bridge.js
14781
14044
  init_esm4();
14782
- var CanvasWebGLWidget = GObject.registerClass(
14783
- { GTypeName: "GjsifyCanvasWebGLWidget" },
14784
- class CanvasWebGLWidget2 extends Gtk3.GLArea {
14045
+ var WebGLBridge = GObject.registerClass(
14046
+ { GTypeName: "GjsifyWebGLBridge" },
14047
+ class WebGLBridge2 extends Gtk3.GLArea {
14785
14048
  constructor(params) {
14786
14049
  super(params);
14787
14050
  this._canvas = null;
@@ -14796,6 +14059,12 @@ var CanvasWebGLWidget = GObject.registerClass(
14796
14059
  this.set_has_depth_buffer(true);
14797
14060
  this.set_has_stencil_buffer(true);
14798
14061
  attachEventControllers(this, () => this._canvas, { captureKeys: true });
14062
+ this._tickCallbackId = this.add_tick_callback((_widget, _frameClock) => {
14063
+ if (this._frameCallback !== null) {
14064
+ this.queue_render();
14065
+ }
14066
+ return GLib2.SOURCE_CONTINUE;
14067
+ });
14799
14068
  const initId = this.connect("render", () => {
14800
14069
  this.disconnect(initId);
14801
14070
  this.make_current();
@@ -14811,6 +14080,18 @@ var CanvasWebGLWidget = GObject.registerClass(
14811
14080
  }
14812
14081
  this._readyCallbacks = [];
14813
14082
  }
14083
+ this._renderTag = this.connect("render", (_widget) => {
14084
+ if (this._frameCallback !== null) {
14085
+ const time2 = (GLib2.get_monotonic_time() - this._timeOrigin) / 1e3;
14086
+ if (globalThis.__GJSIFY_DEBUG_RAF === true) {
14087
+ console.log(`[rAF] frame callback fires t=${time2.toFixed(1)}`);
14088
+ }
14089
+ const cb = this._frameCallback;
14090
+ this._frameCallback = null;
14091
+ cb(time2);
14092
+ }
14093
+ return true;
14094
+ });
14814
14095
  return true;
14815
14096
  });
14816
14097
  this.connect("resize", () => {
@@ -14874,30 +14155,13 @@ var CanvasWebGLWidget = GObject.registerClass(
14874
14155
  }
14875
14156
  /**
14876
14157
  * Schedules a single animation frame callback, matching the browser `requestAnimationFrame` API.
14877
- * Backed by GTK frame clock (vsync-synced) + the GLArea render signal.
14878
- * Returns 0 (handle cancel not yet implemented).
14158
+ * Backed by a persistent GTK frame clock tick callback (vsync-synced) + a persistent GLArea
14159
+ * render signal handler. Both are installed once at construction / first render respectively,
14160
+ * eliminating per-frame GLib.Source allocation and GObject signal connect/disconnect overhead.
14161
+ * Returns 0 (handle — cancel via cancelAnimationFrame clears the pending callback).
14879
14162
  */
14880
14163
  requestAnimationFrame(cb) {
14881
14164
  this._frameCallback = cb;
14882
- if (this._tickCallbackId === null) {
14883
- this._tickCallbackId = this.add_tick_callback((_widget, _frameClock) => {
14884
- this._tickCallbackId = null;
14885
- if (this._renderTag === null) {
14886
- this._renderTag = this.connect("render", (_widget2) => {
14887
- this.disconnect(this._renderTag);
14888
- this._renderTag = null;
14889
- const time2 = (GLib2.get_monotonic_time() - this._timeOrigin) / 1e3;
14890
- if (globalThis.__GJSIFY_DEBUG_RAF === true) {
14891
- console.log(`[rAF] frame callback fires t=${time2.toFixed(1)}`);
14892
- }
14893
- this._frameCallback?.(time2);
14894
- return true;
14895
- });
14896
- }
14897
- this.queue_render();
14898
- return GLib2.SOURCE_REMOVE;
14899
- });
14900
- }
14901
14165
  this.queue_render();
14902
14166
  return 0;
14903
14167
  }
@@ -14919,22 +14183,22 @@ var CanvasWebGLWidget = GObject.registerClass(
14919
14183
  }
14920
14184
  );
14921
14185
 
14922
- // ../../../packages/dom/webgl/lib/esm/index.js
14186
+ // ../../../packages/framework/webgl/lib/esm/index.js
14923
14187
  globalThis.WebGLRenderingContext = WebGLRenderingContext2;
14924
14188
  globalThis.WebGL2RenderingContext = WebGL2RenderingContext;
14925
14189
 
14926
14190
  // src/three-demo.ts
14927
14191
  init_console_gjs();
14928
- init_auto_globals_495e9d950c();
14192
+ init_auto_globals_97a682e619();
14929
14193
 
14930
14194
  // ../../../node_modules/three/build/three.module.js
14931
14195
  init_console_gjs();
14932
- init_auto_globals_495e9d950c();
14196
+ init_auto_globals_97a682e619();
14933
14197
 
14934
14198
  // ../../../node_modules/three/build/three.core.js
14935
14199
  init_console_gjs();
14936
- init_auto_globals_495e9d950c();
14937
- var REVISION = "183";
14200
+ init_auto_globals_97a682e619();
14201
+ var REVISION = "184";
14938
14202
  var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
14939
14203
  var TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
14940
14204
  var CullFaceNone = 0;
@@ -15658,6 +14922,9 @@ var MathUtils = {
15658
14922
  denormalize
15659
14923
  };
15660
14924
  var Vector2 = class _Vector2 {
14925
+ static {
14926
+ _Vector2.prototype.isVector2 = true;
14927
+ }
15661
14928
  /**
15662
14929
  * Constructs a new 2D vector.
15663
14930
  *
@@ -15665,7 +14932,6 @@ var Vector2 = class _Vector2 {
15665
14932
  * @param {number} [y=0] - The y value of this vector.
15666
14933
  */
15667
14934
  constructor(x = 0, y = 0) {
15668
- _Vector2.prototype.isVector2 = true;
15669
14935
  this.x = x;
15670
14936
  this.y = y;
15671
14937
  }
@@ -16883,6 +16149,9 @@ var Quaternion = class {
16883
16149
  }
16884
16150
  };
16885
16151
  var Vector3 = class _Vector3 {
16152
+ static {
16153
+ _Vector3.prototype.isVector3 = true;
16154
+ }
16886
16155
  /**
16887
16156
  * Constructs a new 3D vector.
16888
16157
  *
@@ -16891,7 +16160,6 @@ var Vector3 = class _Vector3 {
16891
16160
  * @param {number} [z=0] - The z value of this vector.
16892
16161
  */
16893
16162
  constructor(x = 0, y = 0, z = 0) {
16894
- _Vector3.prototype.isVector3 = true;
16895
16163
  this.x = x;
16896
16164
  this.y = y;
16897
16165
  this.z = z;
@@ -17789,6 +17057,9 @@ var Vector3 = class _Vector3 {
17789
17057
  var _vector$c = /* @__PURE__ */ new Vector3();
17790
17058
  var _quaternion$5 = /* @__PURE__ */ new Quaternion();
17791
17059
  var Matrix3 = class _Matrix3 {
17060
+ static {
17061
+ _Matrix3.prototype.isMatrix3 = true;
17062
+ }
17792
17063
  /**
17793
17064
  * Constructs a new 3x3 matrix. The arguments are supposed to be
17794
17065
  * in row-major order. If no arguments are provided, the constructor
@@ -17805,7 +17076,6 @@ var Matrix3 = class _Matrix3 {
17805
17076
  * @param {number} [n33] - 3-3 matrix element.
17806
17077
  */
17807
17078
  constructor(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
17808
- _Matrix3.prototype.isMatrix3 = true;
17809
17079
  this.elements = [
17810
17080
  1,
17811
17081
  0,
@@ -18505,7 +17775,7 @@ var Source = class {
18505
17775
  if (typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement) {
18506
17776
  target.set(data.videoWidth, data.videoHeight, 0);
18507
17777
  } else if (typeof VideoFrame !== "undefined" && data instanceof VideoFrame) {
18508
- target.set(data.displayHeight, data.displayWidth, 0);
17778
+ target.set(data.displayWidth, data.displayHeight, 0);
18509
17779
  } else if (data !== null) {
18510
17780
  target.set(data.width, data.height, data.depth || 0);
18511
17781
  } else {
@@ -18635,6 +17905,7 @@ var Texture = class _Texture extends EventDispatcher {
18635
17905
  this.isRenderTargetTexture = false;
18636
17906
  this.isArrayTexture = image && image.depth && image.depth > 1 ? true : false;
18637
17907
  this.pmremVersion = 0;
17908
+ this.normalized = false;
18638
17909
  }
18639
17910
  /**
18640
17911
  * The width of the texture in pixels.
@@ -18662,11 +17933,11 @@ var Texture = class _Texture extends EventDispatcher {
18662
17933
  get image() {
18663
17934
  return this.source.data;
18664
17935
  }
18665
- set image(value2 = null) {
17936
+ set image(value2) {
18666
17937
  this.source.data = value2;
18667
17938
  }
18668
17939
  /**
18669
- * Updates the texture transformation matrix from the from the properties {@link Texture#offset},
17940
+ * Updates the texture transformation matrix from the properties {@link Texture#offset},
18670
17941
  * {@link Texture#repeat}, {@link Texture#rotation}, and {@link Texture#center}.
18671
17942
  */
18672
17943
  updateMatrix() {
@@ -18715,6 +17986,7 @@ var Texture = class _Texture extends EventDispatcher {
18715
17986
  this.format = source.format;
18716
17987
  this.internalFormat = source.internalFormat;
18717
17988
  this.type = source.type;
17989
+ this.normalized = source.normalized;
18718
17990
  this.offset.copy(source.offset);
18719
17991
  this.repeat.copy(source.repeat);
18720
17992
  this.center.copy(source.center);
@@ -18791,6 +18063,7 @@ var Texture = class _Texture extends EventDispatcher {
18791
18063
  format: this.format,
18792
18064
  internalFormat: this.internalFormat,
18793
18065
  type: this.type,
18066
+ normalized: this.normalized,
18794
18067
  colorSpace: this.colorSpace,
18795
18068
  minFilter: this.minFilter,
18796
18069
  magFilter: this.magFilter,
@@ -18896,6 +18169,9 @@ Texture.DEFAULT_IMAGE = null;
18896
18169
  Texture.DEFAULT_MAPPING = UVMapping;
18897
18170
  Texture.DEFAULT_ANISOTROPY = 1;
18898
18171
  var Vector4 = class _Vector4 {
18172
+ static {
18173
+ _Vector4.prototype.isVector4 = true;
18174
+ }
18899
18175
  /**
18900
18176
  * Constructs a new 4D vector.
18901
18177
  *
@@ -18905,7 +18181,6 @@ var Vector4 = class _Vector4 {
18905
18181
  * @param {number} [w=1] - The w value of this vector.
18906
18182
  */
18907
18183
  constructor(x = 0, y = 0, z = 0, w = 1) {
18908
- _Vector4.prototype.isVector4 = true;
18909
18184
  this.x = x;
18910
18185
  this.y = y;
18911
18186
  this.z = z;
@@ -19813,6 +19088,7 @@ var RenderTarget = class extends EventDispatcher {
19813
19088
  this.resolveStencilBuffer = source.resolveStencilBuffer;
19814
19089
  if (source.depthTexture !== null) this.depthTexture = source.depthTexture.clone();
19815
19090
  this.samples = source.samples;
19091
+ this.multiview = source.multiview;
19816
19092
  return this;
19817
19093
  }
19818
19094
  /**
@@ -19900,6 +19176,9 @@ var Data3DTexture = class extends Texture {
19900
19176
  }
19901
19177
  };
19902
19178
  var Matrix4 = class _Matrix4 {
19179
+ static {
19180
+ _Matrix4.prototype.isMatrix4 = true;
19181
+ }
19903
19182
  /**
19904
19183
  * Constructs a new 4x4 matrix. The arguments are supposed to be
19905
19184
  * in row-major order. If no arguments are provided, the constructor
@@ -19923,7 +19202,6 @@ var Matrix4 = class _Matrix4 {
19923
19202
  * @param {number} [n44] - 4-4 matrix element.
19924
19203
  */
19925
19204
  constructor(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
19926
- _Matrix4.prototype.isMatrix4 = true;
19927
19205
  this.elements = [
19928
19206
  1,
19929
19207
  0,
@@ -22286,9 +21564,7 @@ var Object3D = class _Object3D extends EventDispatcher {
22286
21564
  this.rotation.order = source.rotation.order;
22287
21565
  this.quaternion.copy(source.quaternion);
22288
21566
  this.scale.copy(source.scale);
22289
- if (source.pivot !== null) {
22290
- this.pivot = source.pivot.clone();
22291
- }
21567
+ this.pivot = source.pivot !== null ? source.pivot.clone() : null;
22292
21568
  this.matrix.copy(source.matrix);
22293
21569
  this.matrixWorld.copy(source.matrixWorld);
22294
21570
  this.matrixAutoUpdate = source.matrixAutoUpdate;
@@ -22378,6 +21654,7 @@ var WebXRController = class {
22378
21654
  this._grip.linearVelocity = new Vector3();
22379
21655
  this._grip.hasAngularVelocity = false;
22380
21656
  this._grip.angularVelocity = new Vector3();
21657
+ this._grip.eventsEnabled = false;
22381
21658
  }
22382
21659
  return this._grip;
22383
21660
  }
@@ -22507,6 +21784,13 @@ var WebXRController = class {
22507
21784
  } else {
22508
21785
  grip.hasAngularVelocity = false;
22509
21786
  }
21787
+ if (grip.eventsEnabled) {
21788
+ grip.dispatchEvent({
21789
+ type: "gripUpdated",
21790
+ data: inputSource,
21791
+ target: this
21792
+ });
21793
+ }
22510
21794
  }
22511
21795
  }
22512
21796
  }
@@ -23519,7 +22803,7 @@ var Triangle = class _Triangle {
23519
22803
  static isFrontFacing(a, b, c, direction) {
23520
22804
  _v0$2.subVectors(c, b);
23521
22805
  _v1$5.subVectors(a, b);
23522
- return _v0$2.cross(_v1$5).dot(direction) < 0 ? true : false;
22806
+ return _v0$2.cross(_v1$5).dot(direction) < 0;
23523
22807
  }
23524
22808
  /**
23525
22809
  * Sets the triangle's vertices by copying the given values.
@@ -24280,7 +23564,7 @@ function satForAxes(axes, v0, v1, v2, extents) {
24280
23564
  var _vector$a = /* @__PURE__ */ new Vector3();
24281
23565
  var _vector2$1 = /* @__PURE__ */ new Vector2();
24282
23566
  var _id$2 = 0;
24283
- var BufferAttribute = class {
23567
+ var BufferAttribute = class extends EventDispatcher {
24284
23568
  /**
24285
23569
  * Constructs a new buffer attribute.
24286
23570
  *
@@ -24289,6 +23573,7 @@ var BufferAttribute = class {
24289
23573
  * @param {boolean} [normalized=false] - Whether the data are normalized or not.
24290
23574
  */
24291
23575
  constructor(array, itemSize, normalized = false) {
23576
+ super();
24292
23577
  if (Array.isArray(array)) {
24293
23578
  throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
24294
23579
  }
@@ -24685,6 +23970,12 @@ var BufferAttribute = class {
24685
23970
  if (this.usage !== StaticDrawUsage) data.usage = this.usage;
24686
23971
  return data;
24687
23972
  }
23973
+ /**
23974
+ * Disposes of the buffer attribute. Available only in {@link WebGPURenderer}.
23975
+ */
23976
+ dispose() {
23977
+ this.dispatchEvent({ type: "dispose" });
23978
+ }
24688
23979
  };
24689
23980
  var Uint16BufferAttribute = class extends BufferAttribute {
24690
23981
  /**
@@ -27039,9 +26330,10 @@ var Plane = class {
27039
26330
  *
27040
26331
  * @param {Line3} line - The line to compute the intersection for.
27041
26332
  * @param {Vector3} target - The target vector that is used to store the method's result.
27042
- * @return {?Vector3} The intersection point.
26333
+ * @param {boolean} [clampToLine=true] - Whether to clamp the intersection to the line segment.
26334
+ * @return {?Vector3} The intersection point. Returns `null` if no intersection is detected.
27043
26335
  */
27044
- intersectLine(line, target) {
26336
+ intersectLine(line, target, clampToLine = true) {
27045
26337
  const direction = line.delta(_vector1);
27046
26338
  const denominator = this.normal.dot(direction);
27047
26339
  if (denominator === 0) {
@@ -27051,7 +26343,7 @@ var Plane = class {
27051
26343
  return null;
27052
26344
  }
27053
26345
  const t = -(line.start.dot(this.normal) + this.constant) / denominator;
27054
- if (t < 0 || t > 1) {
26346
+ if (clampToLine === true && (t < 0 || t > 1)) {
27055
26347
  return null;
27056
26348
  }
27057
26349
  return target.copy(line.start).addScaledVector(direction, t);
@@ -27622,7 +26914,7 @@ function cloneUniforms(src) {
27622
26914
  dst[u] = {};
27623
26915
  for (const p in src[u]) {
27624
26916
  const property = src[u][p];
27625
- if (property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture || property.isQuaternion)) {
26917
+ if (isThreeObject(property)) {
27626
26918
  if (property.isRenderTargetTexture) {
27627
26919
  warn2("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().");
27628
26920
  dst[u][p] = null;
@@ -27630,7 +26922,15 @@ function cloneUniforms(src) {
27630
26922
  dst[u][p] = property.clone();
27631
26923
  }
27632
26924
  } else if (Array.isArray(property)) {
27633
- dst[u][p] = property.slice();
26925
+ if (isThreeObject(property[0])) {
26926
+ const clonedProperty = [];
26927
+ for (let i = 0, l = property.length; i < l; i++) {
26928
+ clonedProperty[i] = property[i].clone();
26929
+ }
26930
+ dst[u][p] = clonedProperty;
26931
+ } else {
26932
+ dst[u][p] = property.slice();
26933
+ }
27634
26934
  } else {
27635
26935
  dst[u][p] = property;
27636
26936
  }
@@ -27648,6 +26948,9 @@ function mergeUniforms(uniforms) {
27648
26948
  }
27649
26949
  return merged;
27650
26950
  }
26951
+ function isThreeObject(property) {
26952
+ return property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture || property.isQuaternion);
26953
+ }
27651
26954
  function cloneUniformsGroups(src) {
27652
26955
  const dst = [];
27653
26956
  for (let u = 0; u < src.length; u++) {
@@ -28546,10 +27849,10 @@ var KeyframeTrack = class {
28546
27849
  * @param {number} endTime - The end time.
28547
27850
  * @return {KeyframeTrack} A reference to this keyframe track.
28548
27851
  */
28549
- trim(startTime2, endTime) {
27852
+ trim(startTime, endTime) {
28550
27853
  const times = this.times, nKeys = times.length;
28551
27854
  let from = 0, to = nKeys - 1;
28552
- while (from !== nKeys && times[from] < startTime2) {
27855
+ while (from !== nKeys && times[from] < startTime) {
28553
27856
  ++from;
28554
27857
  }
28555
27858
  while (to !== -1 && times[to] > endTime) {
@@ -30599,6 +29902,77 @@ var Spherical = class {
30599
29902
  return new this.constructor().copy(this);
30600
29903
  }
30601
29904
  };
29905
+ var Matrix2 = class _Matrix2 {
29906
+ static {
29907
+ _Matrix2.prototype.isMatrix2 = true;
29908
+ }
29909
+ /**
29910
+ * Constructs a new 2x2 matrix. The arguments are supposed to be
29911
+ * in row-major order. If no arguments are provided, the constructor
29912
+ * initializes the matrix as an identity matrix.
29913
+ *
29914
+ * @param {number} [n11] - 1-1 matrix element.
29915
+ * @param {number} [n12] - 1-2 matrix element.
29916
+ * @param {number} [n21] - 2-1 matrix element.
29917
+ * @param {number} [n22] - 2-2 matrix element.
29918
+ */
29919
+ constructor(n11, n12, n21, n22) {
29920
+ this.elements = [
29921
+ 1,
29922
+ 0,
29923
+ 0,
29924
+ 1
29925
+ ];
29926
+ if (n11 !== void 0) {
29927
+ this.set(n11, n12, n21, n22);
29928
+ }
29929
+ }
29930
+ /**
29931
+ * Sets this matrix to the 2x2 identity matrix.
29932
+ *
29933
+ * @return {Matrix2} A reference to this matrix.
29934
+ */
29935
+ identity() {
29936
+ this.set(
29937
+ 1,
29938
+ 0,
29939
+ 0,
29940
+ 1
29941
+ );
29942
+ return this;
29943
+ }
29944
+ /**
29945
+ * Sets the elements of the matrix from the given array.
29946
+ *
29947
+ * @param {Array<number>} array - The matrix elements in column-major order.
29948
+ * @param {number} [offset=0] - Index of the first element in the array.
29949
+ * @return {Matrix2} A reference to this matrix.
29950
+ */
29951
+ fromArray(array, offset = 0) {
29952
+ for (let i = 0; i < 4; i++) {
29953
+ this.elements[i] = array[i + offset];
29954
+ }
29955
+ return this;
29956
+ }
29957
+ /**
29958
+ * Sets the elements of the matrix.The arguments are supposed to be
29959
+ * in row-major order.
29960
+ *
29961
+ * @param {number} n11 - 1-1 matrix element.
29962
+ * @param {number} n12 - 1-2 matrix element.
29963
+ * @param {number} n21 - 2-1 matrix element.
29964
+ * @param {number} n22 - 2-2 matrix element.
29965
+ * @return {Matrix2} A reference to this matrix.
29966
+ */
29967
+ set(n11, n12, n21, n22) {
29968
+ const te = this.elements;
29969
+ te[0] = n11;
29970
+ te[2] = n12;
29971
+ te[1] = n21;
29972
+ te[3] = n22;
29973
+ return this;
29974
+ }
29975
+ };
30602
29976
  var Controls = class extends EventDispatcher {
30603
29977
  /**
30604
29978
  * Constructs a new controls instance.
@@ -30789,11 +30163,12 @@ function WebGLAnimation() {
30789
30163
  start: function() {
30790
30164
  if (isAnimating === true) return;
30791
30165
  if (animationLoop === null) return;
30166
+ if (context === null) return;
30792
30167
  requestId = context.requestAnimationFrame(onAnimationFrame);
30793
30168
  isAnimating = true;
30794
30169
  },
30795
30170
  stop: function() {
30796
- context.cancelAnimationFrame(requestId);
30171
+ if (context !== null) context.cancelAnimationFrame(requestId);
30797
30172
  isAnimating = false;
30798
30173
  },
30799
30174
  setAnimationLoop: function(callback) {
@@ -30960,8 +30335,8 @@ var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = textur
30960
30335
  var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif";
30961
30336
  var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
30962
30337
  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}";
30963
- 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";
30964
- 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";
30338
+ 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";
30339
+ 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";
30965
30340
  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";
30966
30341
  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";
30967
30342
  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";
@@ -30973,17 +30348,18 @@ var gradientmap_pars_fragment = "#ifdef USE_GRADIENTMAP\n uniform sampler2D grad
30973
30348
  var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif";
30974
30349
  var lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
30975
30350
  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";
30976
- 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";
30351
+ 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>";
30977
30352
  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";
30978
30353
  var lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
30979
30354
  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";
30980
30355
  var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
30981
30356
  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";
30982
30357
  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";
30983
- 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}";
30984
- 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";
30358
+ 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}";
30359
+ 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";
30985
30360
  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";
30986
30361
  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";
30362
+ 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";
30987
30363
  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";
30988
30364
  var logdepthbuf_pars_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
30989
30365
  var logdepthbuf_pars_vertex = "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
@@ -31000,7 +30376,7 @@ var morphnormal_vertex = "#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetB
31000
30376
  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";
31001
30377
  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";
31002
30378
  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;";
31003
- 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";
30379
+ 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";
31004
30380
  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";
31005
30381
  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";
31006
30382
  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";
@@ -31019,7 +30395,7 @@ var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUG
31019
30395
  var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif";
31020
30396
  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";
31021
30397
  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";
31022
- 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";
30398
+ 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";
31023
30399
  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}";
31024
30400
  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";
31025
30401
  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";
@@ -31038,7 +30414,7 @@ var worldpos_vertex = "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defin
31038
30414
  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}";
31039
30415
  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}";
31040
30416
  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}";
31041
- 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}";
30417
+ 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}";
31042
30418
  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}";
31043
30419
  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}";
31044
30420
  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}";
@@ -31126,6 +30502,7 @@ var ShaderChunk = {
31126
30502
  lights_fragment_begin,
31127
30503
  lights_fragment_maps,
31128
30504
  lights_fragment_end,
30505
+ lightprobes_pars_fragment,
31129
30506
  logdepthbuf_fragment,
31130
30507
  logdepthbuf_pars_fragment,
31131
30508
  logdepthbuf_pars_vertex,
@@ -31229,7 +30606,6 @@ var UniformsLib = {
31229
30606
  envmap: {
31230
30607
  envMap: { value: null },
31231
30608
  envMapRotation: { value: /* @__PURE__ */ new Matrix3() },
31232
- flipEnvMap: { value: -1 },
31233
30609
  reflectivity: { value: 1 },
31234
30610
  // basic, lambert, phong
31235
30611
  ior: { value: 1.5 },
@@ -31348,7 +30724,11 @@ var UniformsLib = {
31348
30724
  height: {}
31349
30725
  } },
31350
30726
  ltc_1: { value: null },
31351
- ltc_2: { value: null }
30727
+ ltc_2: { value: null },
30728
+ probesSH: { value: null },
30729
+ probesMin: { value: /* @__PURE__ */ new Vector3() },
30730
+ probesMax: { value: /* @__PURE__ */ new Vector3() },
30731
+ probesResolution: { value: /* @__PURE__ */ new Vector3() }
31352
30732
  },
31353
30733
  points: {
31354
30734
  diffuse: { value: /* @__PURE__ */ new Color(16777215) },
@@ -31549,7 +30929,6 @@ var ShaderLib = {
31549
30929
  backgroundCube: {
31550
30930
  uniforms: {
31551
30931
  envMap: { value: null },
31552
- flipEnvMap: { value: -1 },
31553
30932
  backgroundBlurriness: { value: 0 },
31554
30933
  backgroundIntensity: { value: 1 },
31555
30934
  backgroundRotation: { value: /* @__PURE__ */ new Matrix3() }
@@ -31653,8 +31032,9 @@ ShaderLib.physical = {
31653
31032
  fragmentShader: ShaderChunk.meshphysical_frag
31654
31033
  };
31655
31034
  var _rgb = { r: 0, b: 0, g: 0 };
31656
- var _e1$1 = /* @__PURE__ */ new Euler();
31657
31035
  var _m1$12 = /* @__PURE__ */ new Matrix4();
31036
+ var _m$1 = /* @__PURE__ */ new Matrix3();
31037
+ _m$1.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
31658
31038
  function WebGLBackground(renderer, environments, state, objects, alpha, premultipliedAlpha) {
31659
31039
  const clearColor = new Color(0);
31660
31040
  let clearAlpha = alpha === true ? 0 : 1;
@@ -31723,19 +31103,13 @@ function WebGLBackground(renderer, environments, state, objects, alpha, premulti
31723
31103
  });
31724
31104
  objects.update(boxMesh);
31725
31105
  }
31726
- _e1$1.copy(scene.backgroundRotation);
31727
- _e1$1.x *= -1;
31728
- _e1$1.y *= -1;
31729
- _e1$1.z *= -1;
31730
- if (background.isCubeTexture && background.isRenderTargetTexture === false) {
31731
- _e1$1.y *= -1;
31732
- _e1$1.z *= -1;
31733
- }
31734
31106
  boxMesh.material.uniforms.envMap.value = background;
31735
- boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture && background.isRenderTargetTexture === false ? -1 : 1;
31736
31107
  boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
31737
31108
  boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
31738
- boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4(_m1$12.makeRotationFromEuler(_e1$1));
31109
+ boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4(_m1$12.makeRotationFromEuler(scene.backgroundRotation)).transpose();
31110
+ if (background.isCubeTexture && background.isRenderTargetTexture === false) {
31111
+ boxMesh.material.uniforms.backgroundRotation.value.premultiply(_m$1);
31112
+ }
31739
31113
  boxMesh.material.toneMapped = ColorManagement.getTransfer(background.colorSpace) !== SRGBTransfer;
31740
31114
  if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {
31741
31115
  boxMesh.material.needsUpdate = true;
@@ -32211,27 +31585,10 @@ function WebGLBufferRenderer(gl, extensions, info2) {
32211
31585
  }
32212
31586
  info2.update(elementCount, mode, 1);
32213
31587
  }
32214
- function renderMultiDrawInstances(starts, counts, drawCount, primcount) {
32215
- if (drawCount === 0) return;
32216
- const extension = extensions.get("WEBGL_multi_draw");
32217
- if (extension === null) {
32218
- for (let i = 0; i < starts.length; i++) {
32219
- renderInstances(starts[i], counts[i], primcount[i]);
32220
- }
32221
- } else {
32222
- extension.multiDrawArraysInstancedWEBGL(mode, starts, 0, counts, 0, primcount, 0, drawCount);
32223
- let elementCount = 0;
32224
- for (let i = 0; i < drawCount; i++) {
32225
- elementCount += counts[i] * primcount[i];
32226
- }
32227
- info2.update(elementCount, mode, 1);
32228
- }
32229
- }
32230
31588
  this.setMode = setMode;
32231
31589
  this.render = render;
32232
31590
  this.renderInstances = renderInstances;
32233
31591
  this.renderMultiDraw = renderMultiDraw;
32234
- this.renderMultiDrawInstances = renderMultiDrawInstances;
32235
31592
  }
32236
31593
  function WebGLCapabilities(gl, extensions, parameters, utils) {
32237
31594
  let maxAnisotropy;
@@ -32281,6 +31638,9 @@ function WebGLCapabilities(gl, extensions, parameters, utils) {
32281
31638
  }
32282
31639
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
32283
31640
  const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions.has("EXT_clip_control");
31641
+ if (parameters.reversedDepthBuffer === true && reversedDepthBuffer === false) {
31642
+ warn2("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");
31643
+ }
32284
31644
  const maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
32285
31645
  const maxVertexTextures = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
32286
31646
  const maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
@@ -33544,13 +32904,13 @@ function WebGLGeometries(gl, attributes2, info2, bindingStates) {
33544
32904
  const indices = [];
33545
32905
  const geometryIndex = geometry.index;
33546
32906
  const geometryPosition = geometry.attributes.position;
33547
- let version2 = 0;
32907
+ let version = 0;
33548
32908
  if (geometryPosition === void 0) {
33549
32909
  return;
33550
32910
  }
33551
32911
  if (geometryIndex !== null) {
33552
32912
  const array = geometryIndex.array;
33553
- version2 = geometryIndex.version;
32913
+ version = geometryIndex.version;
33554
32914
  for (let i = 0, l = array.length; i < l; i += 3) {
33555
32915
  const a = array[i + 0];
33556
32916
  const b = array[i + 1];
@@ -33559,7 +32919,7 @@ function WebGLGeometries(gl, attributes2, info2, bindingStates) {
33559
32919
  }
33560
32920
  } else {
33561
32921
  const array = geometryPosition.array;
33562
- version2 = geometryPosition.version;
32922
+ version = geometryPosition.version;
33563
32923
  for (let i = 0, l = array.length / 3 - 1; i < l; i += 3) {
33564
32924
  const a = i + 0;
33565
32925
  const b = i + 1;
@@ -33568,7 +32928,7 @@ function WebGLGeometries(gl, attributes2, info2, bindingStates) {
33568
32928
  }
33569
32929
  }
33570
32930
  const attribute = new (geometryPosition.count >= 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(indices, 1);
33571
- attribute.version = version2;
32931
+ attribute.version = version;
33572
32932
  const previousAttribute = wireframeAttributes.get(geometry);
33573
32933
  if (previousAttribute) attributes2.remove(previousAttribute);
33574
32934
  wireframeAttributes.set(geometry, attribute);
@@ -33622,28 +32982,11 @@ function WebGLIndexedBufferRenderer(gl, extensions, info2) {
33622
32982
  }
33623
32983
  info2.update(elementCount, mode, 1);
33624
32984
  }
33625
- function renderMultiDrawInstances(starts, counts, drawCount, primcount) {
33626
- if (drawCount === 0) return;
33627
- const extension = extensions.get("WEBGL_multi_draw");
33628
- if (extension === null) {
33629
- for (let i = 0; i < starts.length; i++) {
33630
- renderInstances(starts[i] / bytesPerElement, counts[i], primcount[i]);
33631
- }
33632
- } else {
33633
- extension.multiDrawElementsInstancedWEBGL(mode, counts, 0, type, starts, 0, primcount, 0, drawCount);
33634
- let elementCount = 0;
33635
- for (let i = 0; i < drawCount; i++) {
33636
- elementCount += counts[i] * primcount[i];
33637
- }
33638
- info2.update(elementCount, mode, 1);
33639
- }
33640
- }
33641
32985
  this.setMode = setMode;
33642
32986
  this.setIndex = setIndex;
33643
32987
  this.render = render;
33644
32988
  this.renderInstances = renderInstances;
33645
32989
  this.renderMultiDraw = renderMultiDraw;
33646
- this.renderMultiDrawInstances = renderMultiDrawInstances;
33647
32990
  }
33648
32991
  function WebGLInfo(gl) {
33649
32992
  const memory = {
@@ -33846,7 +33189,8 @@ function WebGLOutput(type, width, height, depth, stencil) {
33846
33189
  const targetA = new WebGLRenderTarget(width, height, {
33847
33190
  type,
33848
33191
  depthBuffer: depth,
33849
- stencilBuffer: stencil
33192
+ stencilBuffer: stencil,
33193
+ depthTexture: depth ? new DepthTexture(width, height) : void 0
33850
33194
  });
33851
33195
  const targetB = new WebGLRenderTarget(width, height, {
33852
33196
  type: HalfFloatType,
@@ -33999,6 +33343,7 @@ function WebGLOutput(type, width, height, depth, stencil) {
33999
33343
  return _isCompositing;
34000
33344
  };
34001
33345
  this.dispose = function() {
33346
+ if (targetA.depthTexture) targetA.depthTexture.dispose();
34002
33347
  targetA.dispose();
34003
33348
  targetB.dispose();
34004
33349
  geometry.dispose();
@@ -35010,6 +34355,7 @@ function WebGLProgram2(renderer, cacheKey, parameters, bindingStates) {
35010
34355
  parameters.thicknessMapUv ? "#define THICKNESSMAP_UV " + parameters.thicknessMapUv : "",
35011
34356
  //
35012
34357
  parameters.vertexTangents && parameters.flatShading === false ? "#define USE_TANGENT" : "",
34358
+ parameters.vertexNormals ? "#define HAS_NORMAL" : "",
35013
34359
  parameters.vertexColors ? "#define USE_COLOR" : "",
35014
34360
  parameters.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
35015
34361
  parameters.vertexUv1s ? "#define USE_UV1" : "",
@@ -35096,6 +34442,7 @@ function WebGLProgram2(renderer, cacheKey, parameters, bindingStates) {
35096
34442
  parameters.normalMap ? "#define USE_NORMALMAP" : "",
35097
34443
  parameters.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
35098
34444
  parameters.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
34445
+ parameters.packedNormalMap ? "#define USE_PACKED_NORMALMAP" : "",
35099
34446
  parameters.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
35100
34447
  parameters.anisotropy ? "#define USE_ANISOTROPY" : "",
35101
34448
  parameters.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
@@ -35136,6 +34483,7 @@ function WebGLProgram2(renderer, cacheKey, parameters, bindingStates) {
35136
34483
  parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
35137
34484
  parameters.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
35138
34485
  parameters.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
34486
+ parameters.numLightProbeGrids > 0 ? "#define USE_LIGHT_PROBES_GRID" : "",
35139
34487
  parameters.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",
35140
34488
  parameters.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "",
35141
34489
  parameters.logarithmicDepthBuffer ? "#define USE_LOGARITHMIC_DEPTH_BUFFER" : "",
@@ -35350,6 +34698,9 @@ var WebGLShaderStage = class {
35350
34698
  this.usedTimes = 0;
35351
34699
  }
35352
34700
  };
34701
+ function isPackedRGFormat(format) {
34702
+ return format === RGFormat || format === RG11_EAC_Format || format === RED_GREEN_RGTC2_Format;
34703
+ }
35353
34704
  function WebGLPrograms(renderer, environments, extensions, capabilities, bindingStates, clipping) {
35354
34705
  const _programLayers = new Layers();
35355
34706
  const _customShaders = new WebGLShaderCache();
@@ -35380,7 +34731,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
35380
34731
  if (value2 === 0) return "uv";
35381
34732
  return `uv${value2}`;
35382
34733
  }
35383
- function getParameters(material, lights, shadows, scene, object) {
34734
+ function getParameters(material, lights, shadows, scene, object, lightProbeGrids) {
35384
34735
  const fog = scene.fog;
35385
34736
  const geometry = object.geometry;
35386
34737
  const environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
@@ -35475,7 +34826,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
35475
34826
  instancing: IS_INSTANCEDMESH,
35476
34827
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
35477
34828
  instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
35478
- outputColorSpace: currentRenderTarget === null ? renderer.outputColorSpace : currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace,
34829
+ outputColorSpace: currentRenderTarget === null ? renderer.outputColorSpace : currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace,
35479
34830
  alphaToCoverage: !!material.alphaToCoverage,
35480
34831
  map: HAS_MAP,
35481
34832
  matcap: HAS_MATCAP,
@@ -35490,6 +34841,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
35490
34841
  emissiveMap: HAS_EMISSIVEMAP,
35491
34842
  normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
35492
34843
  normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
34844
+ packedNormalMap: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap && isPackedRGFormat(material.normalMap.format),
35493
34845
  metalnessMap: HAS_METALNESSMAP,
35494
34846
  roughnessMap: HAS_ROUGHNESSMAP,
35495
34847
  anisotropy: HAS_ANISOTROPY,
@@ -35543,6 +34895,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
35543
34895
  alphaMapUv: HAS_ALPHAMAP && getChannel(material.alphaMap.channel),
35544
34896
  //
35545
34897
  vertexTangents: !!geometry.attributes.tangent && (HAS_NORMALMAP || HAS_ANISOTROPY),
34898
+ vertexNormals: !!geometry.attributes.normal,
35546
34899
  vertexColors: material.vertexColors,
35547
34900
  vertexAlphas: material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4,
35548
34901
  pointsUvs: object.isPoints === true && !!geometry.attributes.uv && (HAS_MAP || HAS_ALPHAMAP),
@@ -35570,6 +34923,7 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
35570
34923
  numSpotLightShadows: lights.spotShadowMap.length,
35571
34924
  numSpotLightShadowsWithMaps: lights.numSpotLightShadowsWithMaps,
35572
34925
  numLightProbes: lights.numLightProbes,
34926
+ numLightProbeGrids: lightProbeGrids.length,
35573
34927
  numClippingPlanes: clipping.numPlanes,
35574
34928
  numClipIntersection: clipping.numIntersection,
35575
34929
  dithering: material.dithering,
@@ -35713,6 +35067,10 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
35713
35067
  _programLayers.enable(20);
35714
35068
  if (parameters.gradientMap)
35715
35069
  _programLayers.enable(21);
35070
+ if (parameters.packedNormalMap)
35071
+ _programLayers.enable(22);
35072
+ if (parameters.vertexNormals)
35073
+ _programLayers.enable(23);
35716
35074
  array.push(_programLayers.mask);
35717
35075
  _programLayers.disableAll();
35718
35076
  if (parameters.fog)
@@ -35759,6 +35117,8 @@ function WebGLPrograms(renderer, environments, extensions, capabilities, binding
35759
35117
  _programLayers.enable(20);
35760
35118
  if (parameters.alphaToCoverage)
35761
35119
  _programLayers.enable(21);
35120
+ if (parameters.numLightProbeGrids > 0)
35121
+ _programLayers.enable(22);
35762
35122
  array.push(_programLayers.mask);
35763
35123
  }
35764
35124
  function getUniforms(material) {
@@ -36358,10 +35718,12 @@ function WebGLRenderState(extensions) {
36358
35718
  const lights = new WebGLLights(extensions);
36359
35719
  const lightsArray = [];
36360
35720
  const shadowsArray = [];
35721
+ const lightProbeGridArray = [];
36361
35722
  function init(camera) {
36362
35723
  state.camera = camera;
36363
35724
  lightsArray.length = 0;
36364
35725
  shadowsArray.length = 0;
35726
+ lightProbeGridArray.length = 0;
36365
35727
  }
36366
35728
  function pushLight(light) {
36367
35729
  lightsArray.push(light);
@@ -36369,6 +35731,9 @@ function WebGLRenderState(extensions) {
36369
35731
  function pushShadow(shadowLight) {
36370
35732
  shadowsArray.push(shadowLight);
36371
35733
  }
35734
+ function pushLightProbeGrid(volume) {
35735
+ lightProbeGridArray.push(volume);
35736
+ }
36372
35737
  function setupLights() {
36373
35738
  lights.setup(lightsArray);
36374
35739
  }
@@ -36378,9 +35743,11 @@ function WebGLRenderState(extensions) {
36378
35743
  const state = {
36379
35744
  lightsArray,
36380
35745
  shadowsArray,
35746
+ lightProbeGridArray,
36381
35747
  camera: null,
36382
35748
  lights,
36383
- transmissionRenderTarget: {}
35749
+ transmissionRenderTarget: {},
35750
+ textureUnits: 0
36384
35751
  };
36385
35752
  return {
36386
35753
  init,
@@ -36388,7 +35755,8 @@ function WebGLRenderState(extensions) {
36388
35755
  setupLights,
36389
35756
  setupLightsView,
36390
35757
  pushLight,
36391
- pushShadow
35758
+ pushShadow,
35759
+ pushLightProbeGrid
36392
35760
  };
36393
35761
  }
36394
35762
  function WebGLRenderStates(extensions) {
@@ -36948,6 +36316,7 @@ function WebGLState(gl, extensions) {
36948
36316
  const uboBindings = /* @__PURE__ */ new WeakMap();
36949
36317
  const uboProgramMap = /* @__PURE__ */ new WeakMap();
36950
36318
  let enabledCapabilities = {};
36319
+ let parameters = {};
36951
36320
  let currentBoundFramebuffers = {};
36952
36321
  let currentDrawbuffers = /* @__PURE__ */ new WeakMap();
36953
36322
  let defaultDrawbuffers = [];
@@ -36970,14 +36339,14 @@ function WebGLState(gl, extensions) {
36970
36339
  let currentPolygonOffsetUnits = null;
36971
36340
  const maxTextures = gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
36972
36341
  let lineWidthAvailable = false;
36973
- let version2 = 0;
36342
+ let version = 0;
36974
36343
  const glVersion = gl.getParameter(gl.VERSION);
36975
36344
  if (glVersion.indexOf("WebGL") !== -1) {
36976
- version2 = parseFloat(/^WebGL (\d)/.exec(glVersion)[1]);
36977
- lineWidthAvailable = version2 >= 1;
36345
+ version = parseFloat(/^WebGL (\d)/.exec(glVersion)[1]);
36346
+ lineWidthAvailable = version >= 1;
36978
36347
  } else if (glVersion.indexOf("OpenGL ES") !== -1) {
36979
- version2 = parseFloat(/^OpenGL ES (\d)/.exec(glVersion)[1]);
36980
- lineWidthAvailable = version2 >= 2;
36348
+ version = parseFloat(/^OpenGL ES (\d)/.exec(glVersion)[1]);
36349
+ lineWidthAvailable = version >= 2;
36981
36350
  }
36982
36351
  let currentTextureSlot = null;
36983
36352
  let currentBoundTextures = {};
@@ -37372,6 +36741,19 @@ function WebGLState(gl, extensions) {
37372
36741
  error2("WebGLState:", e);
37373
36742
  }
37374
36743
  }
36744
+ function getParameter(name2) {
36745
+ if (parameters[name2] !== void 0) {
36746
+ return parameters[name2];
36747
+ } else {
36748
+ return gl.getParameter(name2);
36749
+ }
36750
+ }
36751
+ function pixelStorei(name2, value2) {
36752
+ if (parameters[name2] !== value2) {
36753
+ gl.pixelStorei(name2, value2);
36754
+ parameters[name2] = value2;
36755
+ }
36756
+ }
37375
36757
  function scissor(scissor2) {
37376
36758
  if (currentScissor.equals(scissor2) === false) {
37377
36759
  gl.scissor(scissor2.x, scissor2.y, scissor2.z, scissor2.w);
@@ -37437,7 +36819,21 @@ function WebGLState(gl, extensions) {
37437
36819
  gl.lineWidth(1);
37438
36820
  gl.scissor(0, 0, gl.canvas.width, gl.canvas.height);
37439
36821
  gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
36822
+ gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
36823
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
36824
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
36825
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
36826
+ gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.BROWSER_DEFAULT_WEBGL);
36827
+ gl.pixelStorei(gl.PACK_ROW_LENGTH, 0);
36828
+ gl.pixelStorei(gl.PACK_SKIP_PIXELS, 0);
36829
+ gl.pixelStorei(gl.PACK_SKIP_ROWS, 0);
36830
+ gl.pixelStorei(gl.UNPACK_ROW_LENGTH, 0);
36831
+ gl.pixelStorei(gl.UNPACK_IMAGE_HEIGHT, 0);
36832
+ gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, 0);
36833
+ gl.pixelStorei(gl.UNPACK_SKIP_ROWS, 0);
36834
+ gl.pixelStorei(gl.UNPACK_SKIP_IMAGES, 0);
37440
36835
  enabledCapabilities = {};
36836
+ parameters = {};
37441
36837
  currentTextureSlot = null;
37442
36838
  currentBoundTextures = {};
37443
36839
  currentBoundFramebuffers = {};
@@ -37491,6 +36887,8 @@ function WebGLState(gl, extensions) {
37491
36887
  compressedTexImage3D,
37492
36888
  texImage2D,
37493
36889
  texImage3D,
36890
+ pixelStorei,
36891
+ getParameter,
37494
36892
  updateUBOMapping,
37495
36893
  uniformBlockBinding,
37496
36894
  texStorage2D,
@@ -37509,6 +36907,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
37509
36907
  const supportsInvalidateFramebuffer = typeof navigator === "undefined" ? false : /OculusBrowser/g.test(navigator.userAgent);
37510
36908
  const _imageDimensions = new Vector2();
37511
36909
  const _videoTextures = /* @__PURE__ */ new WeakMap();
36910
+ const _htmlTextures = /* @__PURE__ */ new Set();
37512
36911
  let _canvas2;
37513
36912
  const _sources = /* @__PURE__ */ new WeakMap();
37514
36913
  let useOffscreenCanvas = false;
@@ -37558,16 +36957,25 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
37558
36957
  if (texture.isWebGLArrayRenderTarget || texture.isCompressedArrayTexture) return _gl.TEXTURE_2D_ARRAY;
37559
36958
  return _gl.TEXTURE_2D;
37560
36959
  }
37561
- function getInternalFormat(internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false) {
36960
+ function getInternalFormat(internalFormatName, glFormat, glType, normalized, colorSpace, forceLinearTransfer = false) {
37562
36961
  if (internalFormatName !== null) {
37563
36962
  if (_gl[internalFormatName] !== void 0) return _gl[internalFormatName];
37564
36963
  warn2("WebGLRenderer: Attempt to use non-existing WebGL internal format '" + internalFormatName + "'");
37565
36964
  }
36965
+ let ext_texture_norm16;
36966
+ if (normalized) {
36967
+ ext_texture_norm16 = extensions.get("EXT_texture_norm16");
36968
+ if (!ext_texture_norm16) {
36969
+ warn2("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension");
36970
+ }
36971
+ }
37566
36972
  let internalFormat = glFormat;
37567
36973
  if (glFormat === _gl.RED) {
37568
36974
  if (glType === _gl.FLOAT) internalFormat = _gl.R32F;
37569
36975
  if (glType === _gl.HALF_FLOAT) internalFormat = _gl.R16F;
37570
36976
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8;
36977
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.R16_EXT;
36978
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.R16_SNORM_EXT;
37571
36979
  }
37572
36980
  if (glFormat === _gl.RED_INTEGER) {
37573
36981
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8UI;
@@ -37581,6 +36989,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
37581
36989
  if (glType === _gl.FLOAT) internalFormat = _gl.RG32F;
37582
36990
  if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RG16F;
37583
36991
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8;
36992
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RG16_EXT;
36993
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RG16_SNORM_EXT;
37584
36994
  }
37585
36995
  if (glFormat === _gl.RG_INTEGER) {
37586
36996
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8UI;
@@ -37607,6 +37017,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
37607
37017
  if (glType === _gl.INT) internalFormat = _gl.RGBA32I;
37608
37018
  }
37609
37019
  if (glFormat === _gl.RGB) {
37020
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGB16_EXT;
37021
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGB16_SNORM_EXT;
37610
37022
  if (glType === _gl.UNSIGNED_INT_5_9_9_9_REV) internalFormat = _gl.RGB9_E5;
37611
37023
  if (glType === _gl.UNSIGNED_INT_10F_11F_11F_REV) internalFormat = _gl.R11F_G11F_B10F;
37612
37024
  }
@@ -37615,6 +37027,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
37615
37027
  if (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F;
37616
37028
  if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F;
37617
37029
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = transfer === SRGBTransfer ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
37030
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGBA16_EXT;
37031
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGBA16_SNORM_EXT;
37618
37032
  if (glType === _gl.UNSIGNED_SHORT_4_4_4_4) internalFormat = _gl.RGBA4;
37619
37033
  if (glType === _gl.UNSIGNED_SHORT_5_5_5_1) internalFormat = _gl.RGB5_A1;
37620
37034
  }
@@ -37663,6 +37077,9 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
37663
37077
  if (texture.isVideoTexture) {
37664
37078
  _videoTextures.delete(texture);
37665
37079
  }
37080
+ if (texture.isHTMLTexture) {
37081
+ _htmlTextures.delete(texture);
37082
+ }
37666
37083
  }
37667
37084
  function onRenderTargetDispose(event) {
37668
37085
  const renderTarget = event.target;
@@ -37739,6 +37156,12 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
37739
37156
  function resetTextureUnits() {
37740
37157
  textureUnits = 0;
37741
37158
  }
37159
+ function getTextureUnits() {
37160
+ return textureUnits;
37161
+ }
37162
+ function setTextureUnits(value2) {
37163
+ textureUnits = value2;
37164
+ }
37742
37165
  function allocateTextureUnit() {
37743
37166
  const textureUnit = textureUnits;
37744
37167
  if (textureUnit >= capabilities.maxTextures) {
@@ -37921,10 +37344,10 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
37921
37344
  }
37922
37345
  }
37923
37346
  updateRanges.length = mergeIndex + 1;
37924
- const currentUnpackRowLen = _gl.getParameter(_gl.UNPACK_ROW_LENGTH);
37925
- const currentUnpackSkipPixels = _gl.getParameter(_gl.UNPACK_SKIP_PIXELS);
37926
- const currentUnpackSkipRows = _gl.getParameter(_gl.UNPACK_SKIP_ROWS);
37927
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
37347
+ const currentUnpackRowLen = state.getParameter(_gl.UNPACK_ROW_LENGTH);
37348
+ const currentUnpackSkipPixels = state.getParameter(_gl.UNPACK_SKIP_PIXELS);
37349
+ const currentUnpackSkipRows = state.getParameter(_gl.UNPACK_SKIP_ROWS);
37350
+ state.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
37928
37351
  for (let i = 0, l = updateRanges.length; i < l; i++) {
37929
37352
  const range = updateRanges[i];
37930
37353
  const pixelStart = Math.floor(range.start / componentStride);
@@ -37933,14 +37356,14 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
37933
37356
  const y = Math.floor(pixelStart / image.width);
37934
37357
  const width = pixelCount;
37935
37358
  const height = 1;
37936
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, x);
37937
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, y);
37359
+ state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, x);
37360
+ state.pixelStorei(_gl.UNPACK_SKIP_ROWS, y);
37938
37361
  state.texSubImage2D(_gl.TEXTURE_2D, 0, x, y, width, height, glFormat, glType, image.data);
37939
37362
  }
37940
37363
  texture.clearUpdateRanges();
37941
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
37942
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
37943
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
37364
+ state.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
37365
+ state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
37366
+ state.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
37944
37367
  }
37945
37368
  }
37946
37369
  function uploadTexture(textureProperties, texture, slot) {
@@ -37953,18 +37376,21 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
37953
37376
  const sourceProperties = properties.get(source);
37954
37377
  if (source.version !== sourceProperties.__version || forceUpload === true) {
37955
37378
  state.activeTexture(_gl.TEXTURE0 + slot);
37956
- const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
37957
- const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
37958
- const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
37959
- _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
37960
- _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
37961
- _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
37962
- _gl.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
37379
+ const isImageBitmap = typeof ImageBitmap !== "undefined" && texture.image instanceof ImageBitmap;
37380
+ if (isImageBitmap === false) {
37381
+ const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
37382
+ const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
37383
+ const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
37384
+ state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
37385
+ state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
37386
+ state.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
37387
+ }
37388
+ state.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
37963
37389
  let image = resizeImage(texture.image, false, capabilities.maxTextureSize);
37964
37390
  image = verifyColorSpace(texture, image);
37965
37391
  const glFormat = utils.convert(texture.format, texture.colorSpace);
37966
37392
  const glType = utils.convert(texture.type);
37967
- let glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture);
37393
+ let glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace, texture.isVideoTexture);
37968
37394
  setTextureParameters(textureType, texture);
37969
37395
  let mipmap;
37970
37396
  const mipmaps = texture.mipmaps;
@@ -38126,6 +37552,35 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38126
37552
  }
38127
37553
  }
38128
37554
  }
37555
+ } else if (texture.isHTMLTexture) {
37556
+ if ("texElementImage2D" in _gl) {
37557
+ const canvas = _gl.canvas;
37558
+ if (!canvas.hasAttribute("layoutsubtree")) {
37559
+ canvas.setAttribute("layoutsubtree", "true");
37560
+ }
37561
+ if (image.parentNode !== canvas) {
37562
+ canvas.appendChild(image);
37563
+ _htmlTextures.add(texture);
37564
+ canvas.onpaint = (event) => {
37565
+ const changed = event.changedElements;
37566
+ for (const t of _htmlTextures) {
37567
+ if (changed.includes(t.image)) {
37568
+ t.needsUpdate = true;
37569
+ }
37570
+ }
37571
+ };
37572
+ canvas.requestPaint();
37573
+ return;
37574
+ }
37575
+ const level = 0;
37576
+ const internalFormat = _gl.RGBA;
37577
+ const srcFormat = _gl.RGBA;
37578
+ const srcType = _gl.UNSIGNED_BYTE;
37579
+ _gl.texElementImage2D(_gl.TEXTURE_2D, level, internalFormat, srcFormat, srcType, image);
37580
+ _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR);
37581
+ _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE);
37582
+ _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE);
37583
+ }
38129
37584
  } else {
38130
37585
  if (mipmaps.length > 0) {
38131
37586
  if (useTexStorage && allocateMemory) {
@@ -38176,10 +37631,10 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38176
37631
  const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
38177
37632
  const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
38178
37633
  const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
38179
- _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
38180
- _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
38181
- _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
38182
- _gl.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
37634
+ state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
37635
+ state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
37636
+ state.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
37637
+ state.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
38183
37638
  const isCompressed = texture.isCompressedTexture || texture.image[0].isCompressedTexture;
38184
37639
  const isDataTexture = texture.image[0] && texture.image[0].isDataTexture;
38185
37640
  const cubeImage = [];
@@ -38191,7 +37646,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38191
37646
  }
38192
37647
  cubeImage[i] = verifyColorSpace(texture, cubeImage[i]);
38193
37648
  }
38194
- const image = cubeImage[0], glFormat = utils.convert(texture.format, texture.colorSpace), glType = utils.convert(texture.type), glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
37649
+ 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);
38195
37650
  const useTexStorage = texture.isVideoTexture !== true;
38196
37651
  const allocateMemory = sourceProperties.__version === void 0 || forceUpload === true;
38197
37652
  const dataReady = source.dataReady;
@@ -38288,7 +37743,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38288
37743
  function setupFrameBufferTexture(framebuffer, renderTarget, texture, attachment, textureTarget, level) {
38289
37744
  const glFormat = utils.convert(texture.format, texture.colorSpace);
38290
37745
  const glType = utils.convert(texture.type);
38291
- const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
37746
+ const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
38292
37747
  const renderTargetProperties = properties.get(renderTarget);
38293
37748
  const textureProperties = properties.get(texture);
38294
37749
  textureProperties.__renderTarget = renderTarget;
@@ -38330,7 +37785,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38330
37785
  const texture = textures[i];
38331
37786
  const glFormat = utils.convert(texture.format, texture.colorSpace);
38332
37787
  const glType = utils.convert(texture.type);
38333
- const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
37788
+ const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
38334
37789
  if (useMultisampledRTT(renderTarget)) {
38335
37790
  multisampledRTTExt.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, getRenderTargetSamples(renderTarget), glInternalFormat, renderTarget.width, renderTarget.height);
38336
37791
  } else if (useMultisample) {
@@ -38530,7 +37985,7 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38530
37985
  _gl.bindRenderbuffer(_gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);
38531
37986
  const glFormat = utils.convert(texture2.format, texture2.colorSpace);
38532
37987
  const glType = utils.convert(texture2.type);
38533
- const glInternalFormat = getInternalFormat(texture2.internalFormat, glFormat, glType, texture2.colorSpace, renderTarget.isXRRenderTarget === true);
37988
+ const glInternalFormat = getInternalFormat(texture2.internalFormat, glFormat, glType, texture2.normalized, texture2.colorSpace, renderTarget.isXRRenderTarget === true);
38534
37989
  const samples = getRenderTargetSamples(renderTarget);
38535
37990
  _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height);
38536
37991
  _gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i]);
@@ -38726,6 +38181,8 @@ function WebGLTextures(_gl, extensions, state, properties, capabilities, utils,
38726
38181
  }
38727
38182
  this.allocateTextureUnit = allocateTextureUnit;
38728
38183
  this.resetTextureUnits = resetTextureUnits;
38184
+ this.getTextureUnits = getTextureUnits;
38185
+ this.setTextureUnits = setTextureUnits;
38729
38186
  this.setTexture2D = setTexture2D;
38730
38187
  this.setTexture2DArray = setTexture2DArray;
38731
38188
  this.setTexture3D = setTexture3D;
@@ -39446,8 +38903,9 @@ var WebXRManager = class extends EventDispatcher {
39446
38903
  };
39447
38904
  }
39448
38905
  };
39449
- var _e1 = /* @__PURE__ */ new Euler();
39450
38906
  var _m12 = /* @__PURE__ */ new Matrix4();
38907
+ var _m = /* @__PURE__ */ new Matrix3();
38908
+ _m.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
39451
38909
  function WebGLMaterials(renderer, properties) {
39452
38910
  function refreshTransformUniform(map, uniform) {
39453
38911
  if (map.matrixAutoUpdate === true) {
@@ -39465,7 +38923,9 @@ function WebGLMaterials(renderer, properties) {
39465
38923
  }
39466
38924
  }
39467
38925
  function refreshMaterialUniforms(uniforms, material, pixelRatio, height, transmissionRenderTarget) {
39468
- if (material.isMeshBasicMaterial) {
38926
+ if (material.isNodeMaterial) {
38927
+ material.uniformsNeedUpdate = false;
38928
+ } else if (material.isMeshBasicMaterial) {
39469
38929
  refreshUniformsCommon(uniforms, material);
39470
38930
  } else if (material.isMeshLambertMaterial) {
39471
38931
  refreshUniformsCommon(uniforms, material);
@@ -39567,16 +39027,10 @@ function WebGLMaterials(renderer, properties) {
39567
39027
  const envMapRotation = materialProperties.envMapRotation;
39568
39028
  if (envMap) {
39569
39029
  uniforms.envMap.value = envMap;
39570
- _e1.copy(envMapRotation);
39571
- _e1.x *= -1;
39572
- _e1.y *= -1;
39573
- _e1.z *= -1;
39030
+ uniforms.envMapRotation.value.setFromMatrix4(_m12.makeRotationFromEuler(envMapRotation)).transpose();
39574
39031
  if (envMap.isCubeTexture && envMap.isRenderTargetTexture === false) {
39575
- _e1.y *= -1;
39576
- _e1.z *= -1;
39032
+ uniforms.envMapRotation.value.premultiply(_m);
39577
39033
  }
39578
- uniforms.envMapRotation.value.setFromMatrix4(_m12.makeRotationFromEuler(_e1));
39579
- uniforms.flipEnvMap.value = envMap.isCubeTexture && envMap.isRenderTargetTexture === false ? -1 : 1;
39580
39034
  uniforms.reflectivity.value = material.reflectivity;
39581
39035
  uniforms.ior.value = material.ior;
39582
39036
  uniforms.refractionRatio.value = material.refractionRatio;
@@ -39842,6 +39296,8 @@ function WebGLUniformsGroups(gl, info2, capabilities, state) {
39842
39296
  uniform.__data[9] = value2.elements[7];
39843
39297
  uniform.__data[10] = value2.elements[8];
39844
39298
  uniform.__data[11] = 0;
39299
+ } else if (ArrayBuffer.isView(value2)) {
39300
+ uniform.__data.set(new value2.constructor(value2.buffer, value2.byteOffset, uniform.__data.length));
39845
39301
  } else {
39846
39302
  value2.toArray(uniform.__data, arrayOffset);
39847
39303
  arrayOffset += info3.storage / Float32Array.BYTES_PER_ELEMENT;
@@ -39859,6 +39315,8 @@ function WebGLUniformsGroups(gl, info2, capabilities, state) {
39859
39315
  if (cache[indexString] === void 0) {
39860
39316
  if (typeof value2 === "number" || typeof value2 === "boolean") {
39861
39317
  cache[indexString] = value2;
39318
+ } else if (ArrayBuffer.isView(value2)) {
39319
+ cache[indexString] = value2.slice();
39862
39320
  } else {
39863
39321
  cache[indexString] = value2.clone();
39864
39322
  }
@@ -39870,6 +39328,8 @@ function WebGLUniformsGroups(gl, info2, capabilities, state) {
39870
39328
  cache[indexString] = value2;
39871
39329
  return true;
39872
39330
  }
39331
+ } else if (ArrayBuffer.isView(value2)) {
39332
+ return true;
39873
39333
  } else {
39874
39334
  if (cachedObject.equals(value2) === false) {
39875
39335
  cachedObject.copy(value2);
@@ -39937,6 +39397,9 @@ function WebGLUniformsGroups(gl, info2, capabilities, state) {
39937
39397
  info3.storage = 64;
39938
39398
  } else if (value2.isTexture) {
39939
39399
  warn2("WebGLRenderer: Texture samplers can not be part of an uniforms group.");
39400
+ } else if (ArrayBuffer.isView(value2)) {
39401
+ info3.boundary = 16;
39402
+ info3.storage = value2.byteLength;
39940
39403
  } else {
39941
39404
  warn2("WebGLRenderer: Unsupported uniform value type.", value2);
39942
39405
  }
@@ -40540,6 +40003,7 @@ var WebGLRenderer = class {
40540
40003
  ]);
40541
40004
  const uintClearColor = new Uint32Array(4);
40542
40005
  const intClearColor = new Int32Array(4);
40006
+ const objectPosition = new Vector3();
40543
40007
  let currentRenderList = null;
40544
40008
  let currentRenderState = null;
40545
40009
  const renderListStack = [];
@@ -40570,6 +40034,7 @@ var WebGLRenderer = class {
40570
40034
  this.transmissionResolutionScale = 1;
40571
40035
  const _this = this;
40572
40036
  let _isContextLost = false;
40037
+ let _nodesHandler = null;
40573
40038
  this._outputColorSpace = SRGBColorSpace;
40574
40039
  let _currentActiveCubeFace = 0;
40575
40040
  let _currentActiveMipmapLevel = 0;
@@ -40738,13 +40203,13 @@ var WebGLRenderer = class {
40738
40203
  };
40739
40204
  this.setEffects = function(effects) {
40740
40205
  if (_outputBufferType === UnsignedByteType) {
40741
- console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");
40206
+ error2("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");
40742
40207
  return;
40743
40208
  }
40744
40209
  if (effects) {
40745
40210
  for (let i = 0; i < effects.length; i++) {
40746
40211
  if (effects[i].isOutputPass === true) {
40747
- console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");
40212
+ warn2("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");
40748
40213
  break;
40749
40214
  }
40750
40215
  }
@@ -40835,6 +40300,7 @@ var WebGLRenderer = class {
40835
40300
  }
40836
40301
  if (depth2) {
40837
40302
  bits2 |= _gl.DEPTH_BUFFER_BIT;
40303
+ this.state.buffers.depth.setMask(true);
40838
40304
  }
40839
40305
  if (stencil2) {
40840
40306
  bits2 |= _gl.STENCIL_BUFFER_BIT;
@@ -40853,6 +40319,10 @@ var WebGLRenderer = class {
40853
40319
  this.clearStencil = function() {
40854
40320
  this.clear(false, false, true);
40855
40321
  };
40322
+ this.setNodesHandler = function(nodesHandler) {
40323
+ nodesHandler.setRenderer(this);
40324
+ _nodesHandler = nodesHandler;
40325
+ };
40856
40326
  this.dispose = function() {
40857
40327
  canvas.removeEventListener("webglcontextlost", onContextLost, false);
40858
40328
  canvas.removeEventListener("webglcontextrestored", onContextRestore, false);
@@ -40975,23 +40445,18 @@ var WebGLRenderer = class {
40975
40445
  renderer.setMode(_gl.TRIANGLES);
40976
40446
  }
40977
40447
  if (object.isBatchedMesh) {
40978
- if (object._multiDrawInstances !== null) {
40979
- warnOnce("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");
40980
- renderer.renderMultiDrawInstances(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances);
40981
- } else {
40982
- if (!extensions.get("WEBGL_multi_draw")) {
40983
- const starts = object._multiDrawStarts;
40984
- const counts = object._multiDrawCounts;
40985
- const drawCount2 = object._multiDrawCount;
40986
- const bytesPerElement = index ? attributes2.get(index).bytesPerElement : 1;
40987
- const uniforms = properties.get(material).currentProgram.getUniforms();
40988
- for (let i = 0; i < drawCount2; i++) {
40989
- uniforms.setValue(_gl, "_gl_DrawID", i);
40990
- renderer.render(starts[i] / bytesPerElement, counts[i]);
40991
- }
40992
- } else {
40993
- renderer.renderMultiDraw(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount);
40448
+ if (!extensions.get("WEBGL_multi_draw")) {
40449
+ const starts = object._multiDrawStarts;
40450
+ const counts = object._multiDrawCounts;
40451
+ const drawCount2 = object._multiDrawCount;
40452
+ const bytesPerElement = index ? attributes2.get(index).bytesPerElement : 1;
40453
+ const uniforms = properties.get(material).currentProgram.getUniforms();
40454
+ for (let i = 0; i < drawCount2; i++) {
40455
+ uniforms.setValue(_gl, "_gl_DrawID", i);
40456
+ renderer.render(starts[i] / bytesPerElement, counts[i]);
40994
40457
  }
40458
+ } else {
40459
+ renderer.renderMultiDraw(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount);
40995
40460
  }
40996
40461
  } else if (object.isInstancedMesh) {
40997
40462
  renderer.renderInstances(drawStart, drawCount, object.count);
@@ -41112,6 +40577,9 @@ var WebGLRenderer = class {
41112
40577
  return;
41113
40578
  }
41114
40579
  if (_isContextLost === true) return;
40580
+ if (_nodesHandler !== null) {
40581
+ _nodesHandler.renderStart(scene, camera);
40582
+ }
41115
40583
  const isXRPresenting = xr.enabled === true && xr.isPresenting === true;
41116
40584
  const useOutput = output !== null && (_currentRenderTarget === null || isXRPresenting) && output.begin(_this, _currentRenderTarget);
41117
40585
  if (scene.matrixWorldAutoUpdate === true) scene.updateMatrixWorld();
@@ -41123,6 +40591,7 @@ var WebGLRenderer = class {
41123
40591
  if (scene.isScene === true) scene.onBeforeRender(_this, scene, camera, _currentRenderTarget);
41124
40592
  currentRenderState = renderStates.get(scene, renderStateStack.length);
41125
40593
  currentRenderState.init(camera);
40594
+ currentRenderState.state.textureUnits = textures.getTextureUnits();
41126
40595
  renderStateStack.push(currentRenderState);
41127
40596
  _projScreenMatrix3.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
41128
40597
  _frustum.setFromProjectionMatrix(_projScreenMatrix3, WebGLCoordinateSystem, camera.reversedDepth);
@@ -41190,6 +40659,7 @@ var WebGLRenderer = class {
41190
40659
  renderStateStack.pop();
41191
40660
  if (renderStateStack.length > 0) {
41192
40661
  currentRenderState = renderStateStack[renderStateStack.length - 1];
40662
+ textures.setTextureUnits(currentRenderState.state.textureUnits);
41193
40663
  if (_clippingEnabled === true) clipping.setGlobalState(_this.clippingPlanes, currentRenderState.state.camera);
41194
40664
  } else {
41195
40665
  currentRenderState = null;
@@ -41200,6 +40670,9 @@ var WebGLRenderer = class {
41200
40670
  } else {
41201
40671
  currentRenderList = null;
41202
40672
  }
40673
+ if (_nodesHandler !== null) {
40674
+ _nodesHandler.renderEnd();
40675
+ }
41203
40676
  };
41204
40677
  function projectObject(object, camera, groupOrder, sortObjects) {
41205
40678
  if (object.visible === false) return;
@@ -41209,6 +40682,8 @@ var WebGLRenderer = class {
41209
40682
  groupOrder = object.renderOrder;
41210
40683
  } else if (object.isLOD) {
41211
40684
  if (object.autoUpdate === true) object.update(camera);
40685
+ } else if (object.isLightProbeGrid) {
40686
+ currentRenderState.pushLightProbeGrid(object);
41212
40687
  } else if (object.isLight) {
41213
40688
  currentRenderState.pushLight(object);
41214
40689
  if (object.castShadow) {
@@ -41375,7 +40850,7 @@ var WebGLRenderer = class {
41375
40850
  const lights = currentRenderState.state.lights;
41376
40851
  const shadowsArray = currentRenderState.state.shadowsArray;
41377
40852
  const lightsStateVersion = lights.state.version;
41378
- const parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, object);
40853
+ const parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, object, currentRenderState.state.lightProbeGridArray);
41379
40854
  const programCacheKey = programCache.getProgramCacheKey(parameters2);
41380
40855
  let programs = materialProperties.programs;
41381
40856
  materialProperties.environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
@@ -41396,6 +40871,9 @@ var WebGLRenderer = class {
41396
40871
  }
41397
40872
  } else {
41398
40873
  parameters2.uniforms = programCache.getUniforms(material);
40874
+ if (_nodesHandler !== null && material.isNodeMaterial) {
40875
+ _nodesHandler.build(material, object, parameters2);
40876
+ }
41399
40877
  material.onBeforeCompile(parameters2, _this);
41400
40878
  program = programCache.acquireProgram(parameters2, programCacheKey);
41401
40879
  programs.set(programCacheKey, program);
@@ -41426,6 +40904,7 @@ var WebGLRenderer = class {
41426
40904
  uniforms.spotLightMap.value = lights.state.spotLightMap;
41427
40905
  uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
41428
40906
  }
40907
+ materialProperties.lightProbeGrid = currentRenderState.state.lightProbeGridArray.length > 0;
41429
40908
  materialProperties.currentProgram = program;
41430
40909
  materialProperties.uniformsList = null;
41431
40910
  return program;
@@ -41456,12 +40935,24 @@ var WebGLRenderer = class {
41456
40935
  materialProperties.vertexTangents = parameters2.vertexTangents;
41457
40936
  materialProperties.toneMapping = parameters2.toneMapping;
41458
40937
  }
40938
+ function findLightProbeGrid(volumes, object) {
40939
+ if (volumes.length === 0) return null;
40940
+ if (volumes.length === 1) {
40941
+ return volumes[0].texture !== null ? volumes[0] : null;
40942
+ }
40943
+ objectPosition.setFromMatrixPosition(object.matrixWorld);
40944
+ for (let i = 0, l = volumes.length; i < l; i++) {
40945
+ const v = volumes[i];
40946
+ if (v.texture !== null && v.boundingBox.containsPoint(objectPosition)) return v;
40947
+ }
40948
+ return null;
40949
+ }
41459
40950
  function setProgram(camera, scene, geometry, material, object) {
41460
40951
  if (scene.isScene !== true) scene = _emptyScene;
41461
40952
  textures.resetTextureUnits();
41462
40953
  const fog = scene.fog;
41463
40954
  const environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
41464
- const colorSpace = _currentRenderTarget === null ? _this.outputColorSpace : _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace;
40955
+ const colorSpace = _currentRenderTarget === null ? _this.outputColorSpace : _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace;
41465
40956
  const usePMREM = material.isMeshStandardMaterial || material.isMeshLambertMaterial && !material.envMap || material.isMeshPhongMaterial && !material.envMap;
41466
40957
  const envMap = environments.get(material.envMap || environment, usePMREM);
41467
40958
  const vertexAlphas = material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4;
@@ -41535,6 +41026,8 @@ var WebGLRenderer = class {
41535
41026
  needsProgramChange = true;
41536
41027
  } else if (materialProperties.morphTargetsCount !== morphTargetsCount) {
41537
41028
  needsProgramChange = true;
41029
+ } else if (!!materialProperties.lightProbeGrid !== currentRenderState.state.lightProbeGridArray.length > 0) {
41030
+ needsProgramChange = true;
41538
41031
  }
41539
41032
  } else {
41540
41033
  needsProgramChange = true;
@@ -41543,6 +41036,9 @@ var WebGLRenderer = class {
41543
41036
  let program = materialProperties.currentProgram;
41544
41037
  if (needsProgramChange === true) {
41545
41038
  program = getProgram(material, scene, object);
41039
+ if (_nodesHandler && material.isNodeMaterial) {
41040
+ _nodesHandler.onUpdateProgram(material, program, materialProperties);
41041
+ }
41546
41042
  }
41547
41043
  let refreshProgram = false;
41548
41044
  let refreshMaterial = false;
@@ -41557,6 +41053,13 @@ var WebGLRenderer = class {
41557
41053
  _currentMaterialId = material.id;
41558
41054
  refreshMaterial = true;
41559
41055
  }
41056
+ if (materialProperties.needsLights) {
41057
+ const objectVolume = findLightProbeGrid(currentRenderState.state.lightProbeGridArray, object);
41058
+ if (materialProperties.lightProbeGrid !== objectVolume) {
41059
+ materialProperties.lightProbeGrid = objectVolume;
41060
+ refreshMaterial = true;
41061
+ }
41062
+ }
41560
41063
  if (refreshProgram || _currentCamera !== camera) {
41561
41064
  const reversedDepthBuffer2 = state.buffers.depth.getReversed();
41562
41065
  if (reversedDepthBuffer2 && camera.reversedDepth !== true) {
@@ -41638,6 +41141,13 @@ var WebGLRenderer = class {
41638
41141
  materials.refreshFogUniforms(m_uniforms, fog);
41639
41142
  }
41640
41143
  materials.refreshMaterialUniforms(m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[camera.id]);
41144
+ if (materialProperties.needsLights && materialProperties.lightProbeGrid) {
41145
+ const volume = materialProperties.lightProbeGrid;
41146
+ m_uniforms.probesSH.value = volume.texture;
41147
+ m_uniforms.probesMin.value.copy(volume.boundingBox.min);
41148
+ m_uniforms.probesMax.value.copy(volume.boundingBox.max);
41149
+ m_uniforms.probesResolution.value.copy(volume.resolution);
41150
+ }
41641
41151
  WebGLUniforms.upload(_gl, getUniformList(materialProperties), m_uniforms, textures);
41642
41152
  }
41643
41153
  if (material.isShaderMaterial && material.uniformsNeedUpdate === true) {
@@ -41650,7 +41160,7 @@ var WebGLRenderer = class {
41650
41160
  p_uniforms.setValue(_gl, "modelViewMatrix", object.modelViewMatrix);
41651
41161
  p_uniforms.setValue(_gl, "normalMatrix", object.normalMatrix);
41652
41162
  p_uniforms.setValue(_gl, "modelMatrix", object.matrixWorld);
41653
- if (material.isShaderMaterial || material.isRawShaderMaterial) {
41163
+ if (material.uniformsGroups !== void 0) {
41654
41164
  const groups = material.uniformsGroups;
41655
41165
  for (let i = 0, l = groups.length; i < l; i++) {
41656
41166
  const group2 = groups[i];
@@ -41919,19 +41429,20 @@ var WebGLRenderer = class {
41919
41429
  textures.setTexture2D(dstTexture, 0);
41920
41430
  glTarget = _gl.TEXTURE_2D;
41921
41431
  }
41922
- _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY);
41923
- _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha);
41924
- _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment);
41925
- const currentUnpackRowLen = _gl.getParameter(_gl.UNPACK_ROW_LENGTH);
41926
- const currentUnpackImageHeight = _gl.getParameter(_gl.UNPACK_IMAGE_HEIGHT);
41927
- const currentUnpackSkipPixels = _gl.getParameter(_gl.UNPACK_SKIP_PIXELS);
41928
- const currentUnpackSkipRows = _gl.getParameter(_gl.UNPACK_SKIP_ROWS);
41929
- const currentUnpackSkipImages = _gl.getParameter(_gl.UNPACK_SKIP_IMAGES);
41930
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
41931
- _gl.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, image.height);
41932
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, minX);
41933
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, minY);
41934
- _gl.pixelStorei(_gl.UNPACK_SKIP_IMAGES, minZ);
41432
+ state.activeTexture(_gl.TEXTURE0);
41433
+ state.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY);
41434
+ state.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha);
41435
+ state.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment);
41436
+ const currentUnpackRowLen = state.getParameter(_gl.UNPACK_ROW_LENGTH);
41437
+ const currentUnpackImageHeight = state.getParameter(_gl.UNPACK_IMAGE_HEIGHT);
41438
+ const currentUnpackSkipPixels = state.getParameter(_gl.UNPACK_SKIP_PIXELS);
41439
+ const currentUnpackSkipRows = state.getParameter(_gl.UNPACK_SKIP_ROWS);
41440
+ const currentUnpackSkipImages = state.getParameter(_gl.UNPACK_SKIP_IMAGES);
41441
+ state.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
41442
+ state.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, image.height);
41443
+ state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, minX);
41444
+ state.pixelStorei(_gl.UNPACK_SKIP_ROWS, minY);
41445
+ state.pixelStorei(_gl.UNPACK_SKIP_IMAGES, minZ);
41935
41446
  const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture;
41936
41447
  const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture;
41937
41448
  if (srcTexture.isDepthTexture) {
@@ -41995,11 +41506,11 @@ var WebGLRenderer = class {
41995
41506
  }
41996
41507
  }
41997
41508
  }
41998
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
41999
- _gl.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight);
42000
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
42001
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
42002
- _gl.pixelStorei(_gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages);
41509
+ state.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
41510
+ state.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight);
41511
+ state.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
41512
+ state.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
41513
+ state.pixelStorei(_gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages);
42003
41514
  if (dstLevel === 0 && dstTexture.generateMipmaps) {
42004
41515
  _gl.generateMipmap(glTarget);
42005
41516
  }
@@ -42064,7 +41575,7 @@ var WebGLRenderer = class {
42064
41575
 
42065
41576
  // ../../../node_modules/three/examples/jsm/controls/OrbitControls.js
42066
41577
  init_console_gjs();
42067
- init_auto_globals_495e9d950c();
41578
+ init_auto_globals_97a682e619();
42068
41579
  var _changeEvent = { type: "change" };
42069
41580
  var _startEvent = { type: "start" };
42070
41581
  var _endEvent = { type: "end" };
@@ -42206,7 +41717,7 @@ var OrbitControls = class extends Controls {
42206
41717
  this.stopListenToKeyEvents();
42207
41718
  const document3 = this.domElement.getRootNode();
42208
41719
  document3.removeEventListener("keydown", this._interceptControlDown, { capture: true });
42209
- this.domElement.style.touchAction = "auto";
41720
+ this.domElement.style.touchAction = "";
42210
41721
  }
42211
41722
  dispose() {
42212
41723
  this.disconnect();
@@ -42976,7 +42487,7 @@ function interceptControlUp(event) {
42976
42487
 
42977
42488
  // ../../../node_modules/three/examples/jsm/geometries/TeapotGeometry.js
42978
42489
  init_console_gjs();
42979
- init_auto_globals_495e9d950c();
42490
+ init_auto_globals_97a682e619();
42980
42491
  var TeapotGeometry = class extends BufferGeometry {
42981
42492
  /**
42982
42493
  * Constructs a new teapot geometry.
@@ -45936,7 +45447,7 @@ start.__type = [() => __\u03A9HTMLCanvasElement, "canvas", () => __\u03A9StartOp
45936
45447
 
45937
45448
  // blueprint:./teapot-window.blp
45938
45449
  init_console_gjs();
45939
- init_auto_globals_495e9d950c();
45450
+ init_auto_globals_97a682e619();
45940
45451
  var teapot_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="TeapotWindow" parent="AdwApplicationWindow">\n <property name="default-width">1100</property>\n <property name="default-height">700</property>\n <property name="title">Three.js Teapot</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">Geometry</property>\n <child>\n <object class="AdwComboRow" id="tessRow">\n <property name="title">Tessellation Level</property>\n </object>\n </child>\n <child>\n <object class="AdwSwitchRow" id="lidRow">\n <property name="title">Display Lid</property>\n <property name="active">true</property>\n </object>\n </child>\n <child>\n <object class="AdwSwitchRow" id="bodyRow">\n <property name="title">Display Body</property>\n <property name="active">true</property>\n </object>\n </child>\n <child>\n <object class="AdwSwitchRow" id="bottomRow">\n <property name="title">Display Bottom</property>\n <property name="active">true</property>\n </object>\n </child>\n <child>\n <object class="AdwSwitchRow" id="fitLidRow">\n <property name="title">Snug Lid</property>\n <property name="active">false</property>\n </object>\n </child>\n <child>\n <object class="AdwSwitchRow" id="nonblinnRow">\n <property name="title">Original Scale</property>\n <property name="active">false</property>\n </object>\n </child>\n </object>\n </child>\n <child>\n <object class="AdwPreferencesGroup">\n <property name="title">Material</property>\n <child>\n <object class="AdwComboRow" id="shadingRow">\n <property name="title">Shading</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>';
45941
45452
 
45942
45453
  // src/gjs/teapot-window.ts
@@ -45945,7 +45456,7 @@ function __assignType2(fn, args) {
45945
45456
  return fn;
45946
45457
  }
45947
45458
  var TeapotWindow = class extends Adw.ApplicationWindow {
45948
- /** Live demo reference; set once the CanvasWebGLWidget is ready. */
45459
+ /** Live demo reference; set once the WebGLBridge is ready. */
45949
45460
  _demo = null;
45950
45461
  static {
45951
45462
  GObject2.registerClass({
@@ -45972,7 +45483,7 @@ var TeapotWindow = class extends Adw.ApplicationWindow {
45972
45483
  this._tessRow.set_selected(DEFAULT_TESS_INDEX);
45973
45484
  this._shadingRow.set_model(Gtk4.StringList.new([...SHADING_VALUES]));
45974
45485
  this._shadingRow.set_selected(DEFAULT_SHADING_INDEX);
45975
- const glArea = new CanvasWebGLWidget();
45486
+ const glArea = new WebGLBridge();
45976
45487
  glArea.set_hexpand(true);
45977
45488
  glArea.set_vexpand(true);
45978
45489
  glArea.installGlobals();