pptx-react-viewer 1.1.3 → 1.1.5

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 (39) hide show
  1. package/dist/index.js +1099 -384
  2. package/dist/index.mjs +1099 -385
  3. package/dist/pptx-viewer.css +1 -1
  4. package/dist/viewer/index.js +1117 -390
  5. package/dist/viewer/index.mjs +1117 -391
  6. package/node_modules/emf-converter/dist/index.d.mts +2 -2
  7. package/node_modules/emf-converter/dist/index.d.ts +2 -2
  8. package/node_modules/emf-converter/dist/index.js +91 -33
  9. package/node_modules/emf-converter/dist/index.mjs +91 -33
  10. package/node_modules/emf-converter/package.json +2 -2
  11. package/node_modules/mtx-decompressor/dist/index.js +39 -9
  12. package/node_modules/mtx-decompressor/dist/index.mjs +39 -9
  13. package/node_modules/mtx-decompressor/package.json +2 -2
  14. package/node_modules/pptx-viewer-core/dist/{SvgExporter-BMjoxMDV.d.ts → SvgExporter-0TxiiorD.d.ts} +1 -1
  15. package/node_modules/pptx-viewer-core/dist/{SvgExporter-z6AbXRQg.d.mts → SvgExporter-BQ4KbRO9.d.mts} +1 -1
  16. package/node_modules/pptx-viewer-core/dist/cli/index.d.mts +2 -2
  17. package/node_modules/pptx-viewer-core/dist/cli/index.d.ts +2 -2
  18. package/node_modules/pptx-viewer-core/dist/cli/index.js +0 -0
  19. package/node_modules/pptx-viewer-core/dist/cli/index.mjs +0 -0
  20. package/node_modules/pptx-viewer-core/dist/converter/index.d.mts +3 -3
  21. package/node_modules/pptx-viewer-core/dist/converter/index.d.ts +3 -3
  22. package/node_modules/pptx-viewer-core/dist/converter/index.js +0 -0
  23. package/node_modules/pptx-viewer-core/dist/converter/index.mjs +0 -0
  24. package/node_modules/pptx-viewer-core/dist/index.d.mts +786 -54
  25. package/node_modules/pptx-viewer-core/dist/index.d.ts +786 -54
  26. package/node_modules/pptx-viewer-core/dist/index.js +3589 -630
  27. package/node_modules/pptx-viewer-core/dist/index.mjs +3575 -630
  28. package/node_modules/pptx-viewer-core/dist/{presentation-CchuDGfU.d.mts → presentation-ArhfImJ5.d.mts} +225 -8
  29. package/node_modules/pptx-viewer-core/dist/{presentation-CchuDGfU.d.ts → presentation-ArhfImJ5.d.ts} +225 -8
  30. package/node_modules/pptx-viewer-core/dist/{signature-inspection-status-BcJSdOvb.d.mts → signature-inspection-status-BCUpfCQh.d.mts} +13 -2
  31. package/node_modules/pptx-viewer-core/dist/{signature-inspection-status-BcJSdOvb.d.ts → signature-inspection-status-BCUpfCQh.d.ts} +13 -2
  32. package/node_modules/pptx-viewer-core/dist/signature-node/index.d.mts +2 -2
  33. package/node_modules/pptx-viewer-core/dist/signature-node/index.d.ts +2 -2
  34. package/node_modules/pptx-viewer-core/dist/signature-node/index.js +17 -3
  35. package/node_modules/pptx-viewer-core/dist/signature-node/index.mjs +16 -4
  36. package/node_modules/pptx-viewer-core/dist/{text-operations-CeukUztU.d.mts → text-operations-CLj-sJyk.d.mts} +1 -1
  37. package/node_modules/pptx-viewer-core/dist/{text-operations-e7JxgI5l.d.ts → text-operations-rhJV-A_W.d.ts} +1 -1
  38. package/node_modules/pptx-viewer-core/package.json +5 -5
  39. package/package.json +22 -20
package/dist/index.mjs CHANGED
@@ -1,11 +1,12 @@
1
1
  import * as React10 from 'react';
2
- import React10__default, { createContext, useState, useEffect, useMemo, Suspense, useCallback, forwardRef, useRef, useSyncExternalStore, useImperativeHandle, useContext, useLayoutEffect } from 'react';
2
+ import React10__default, { createContext, useState, useEffect, useMemo, Suspense, useCallback, forwardRef, useRef, useSyncExternalStore, useImperativeHandle, useContext, useLayoutEffect, useDeferredValue } from 'react';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import * as ReactDOM from 'react-dom/client';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import { LuMessageSquare, LuEyeOff, LuSettings, LuX, LuCast, LuShieldCheck, LuPlus, LuPanelLeftClose, LuStickyNote, LuMonitor, LuColumns2, LuPresentation, LuMinus, LuClock, LuDownload, LuTrash2, LuCheck, LuLock, LuEye, LuFileText, LuType, LuLoader, LuShieldAlert, LuSignature, LuInfo, LuTriangleAlert, LuPrinter, LuPenTool, LuWifi, LuWifiOff, LuUsers, LuCopy, LuMonitorOff, LuChevronLeft, LuChevronRight, LuPlay, LuPause, LuPanelLeft, LuUndo, LuRedo, LuSearch, LuShare2, LuPanelRight, LuFolderOpen, LuVideo, LuImage, LuClipboardPaste, LuScissors, LuPaintbrush, LuChevronDown, LuSquare, LuDatabase, LuLayers, LuAArrowUp, LuAArrowDown, LuRemoveFormatting, LuHighlighter, LuList, LuListOrdered, LuIndentDecrease, LuIndentIncrease, LuChevronUp, LuPalette, LuPencil, LuPaintBucket, LuSparkles, LuCaptions, LuSpellCheck, LuGitCompare, LuPipette, LuCaseSensitive, LuReplace, LuTimer, LuMousePointer2, LuEraser, LuGripVertical, LuUpload, LuBold, LuItalic, LuUnderline, LuStrikethrough, LuLink, LuGrid2X2, LuCopyPlus, LuEllipsis, LuCircle, LuMoveRight, LuTriangle, LuDiamond, LuAlignLeft, LuAlignCenter, LuAlignRight, LuAlignJustify, LuSpline, LuSettings2, LuMove, LuRadio, LuArrowDown, LuArrowUp, LuArrowRight, LuArrowLeft, LuReply, LuRotateCw, LuBookmark } from 'react-icons/lu';
8
8
  import { hasShapeProperties, hasTextProperties, SWITCHABLE_LAYOUT_TYPES, isCalloutShape, getCalloutLeaderLineGeometry, buildCalloutLeaderLineSvgPath, getCalloutViewBoxBounds, isInkElement, getLinkedTextBoxSegments, isImageLikeElement, getSubstituteFontFamily, PptxHandler, EncryptedFileError, guidePxToEmu, guideEmuToPx, THEME_COLOR_SCHEME_KEYS, hslToRgb, PRESET_COLOR_MAP, elementActionToPptxAction, mergeShapes, SvgExporter, applyDrawingColorTransforms as applyDrawingColorTransforms$1, getPresetShapeClipPath, svgPathToPolygons, polygonsToSvgPath, EMU_PER_PX as EMU_PER_PX$1, chartDataChangeType, chartDataUpdatePoint, chartDataAddCategory, chartDataRemoveCategory, chartDataAddSeries, chartDataRemoveSeries, getOleObjectTypeLabel, pptxActionToElementAction, hasNonTrivialOverride, COLOR_MAP_ALIAS_KEYS, DEFAULT_COLOR_MAP, addSmartArtNodeAsChild, updateSmartArtNodeText, removeSmartArtNode, switchSmartArtLayout } from 'pptx-viewer-core';
9
+ import DOMPurify from 'dompurify';
9
10
  import { useTranslation } from 'react-i18next';
10
11
  import html2canvasPro from 'html2canvas-pro';
11
12
  import JSZip from 'jszip';
@@ -64,7 +65,7 @@ var init_extends = __esm({
64
65
  }
65
66
  });
66
67
 
67
- // ../../node_modules/.bun/three@0.183.2/node_modules/three/build/three.core.js
68
+ // ../../node_modules/.bun/three@0.184.0/node_modules/three/build/three.core.js
68
69
  function arrayNeedsUint32(array) {
69
70
  for (let i3 = array.length - 1; i3 >= 0; --i3) {
70
71
  if (array[i3] >= 65535) return true;
@@ -1232,7 +1233,7 @@ function cloneUniforms(src) {
1232
1233
  dst[u2] = {};
1233
1234
  for (const p3 in src[u2]) {
1234
1235
  const property = src[u2][p3];
1235
- if (property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture || property.isQuaternion)) {
1236
+ if (isThreeObject(property)) {
1236
1237
  if (property.isRenderTargetTexture) {
1237
1238
  warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().");
1238
1239
  dst[u2][p3] = null;
@@ -1240,7 +1241,15 @@ function cloneUniforms(src) {
1240
1241
  dst[u2][p3] = property.clone();
1241
1242
  }
1242
1243
  } else if (Array.isArray(property)) {
1243
- dst[u2][p3] = property.slice();
1244
+ if (isThreeObject(property[0])) {
1245
+ const clonedProperty = [];
1246
+ for (let i3 = 0, l2 = property.length; i3 < l2; i3++) {
1247
+ clonedProperty[i3] = property[i3].clone();
1248
+ }
1249
+ dst[u2][p3] = clonedProperty;
1250
+ } else {
1251
+ dst[u2][p3] = property.slice();
1252
+ }
1244
1253
  } else {
1245
1254
  dst[u2][p3] = property;
1246
1255
  }
@@ -1251,13 +1260,16 @@ function cloneUniforms(src) {
1251
1260
  function mergeUniforms(uniforms) {
1252
1261
  const merged = {};
1253
1262
  for (let u2 = 0; u2 < uniforms.length; u2++) {
1254
- const tmp2 = cloneUniforms(uniforms[u2]);
1255
- for (const p3 in tmp2) {
1256
- merged[p3] = tmp2[p3];
1263
+ const tmp3 = cloneUniforms(uniforms[u2]);
1264
+ for (const p3 in tmp3) {
1265
+ merged[p3] = tmp3[p3];
1257
1266
  }
1258
1267
  }
1259
1268
  return merged;
1260
1269
  }
1270
+ function isThreeObject(property) {
1271
+ return property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture || property.isQuaternion);
1272
+ }
1261
1273
  function cloneUniformsGroups(src) {
1262
1274
  const dst = [];
1263
1275
  for (let u2 = 0; u2 < src.length; u2++) {
@@ -1680,10 +1692,10 @@ function getTextureTypeByteLength(type) {
1680
1692
  }
1681
1693
  throw new Error(`Unknown texture type ${type}.`);
1682
1694
  }
1683
- var REVISION, MOUSE, TOUCH, CullFaceNone, CullFaceBack, CullFaceFront, CullFaceFrontBack, BasicShadowMap, PCFShadowMap, PCFSoftShadowMap, VSMShadowMap, FrontSide, BackSide, DoubleSide, NoBlending, NormalBlending, AdditiveBlending, SubtractiveBlending, MultiplyBlending, CustomBlending, MaterialBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, OneMinusSrcColorFactor, SrcAlphaFactor, OneMinusSrcAlphaFactor, DstAlphaFactor, OneMinusDstAlphaFactor, DstColorFactor, OneMinusDstColorFactor, SrcAlphaSaturateFactor, ConstantColorFactor, OneMinusConstantColorFactor, ConstantAlphaFactor, OneMinusConstantAlphaFactor, NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth, MultiplyOperation, MixOperation, AddOperation, NoToneMapping, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, CustomToneMapping, AgXToneMapping, NeutralToneMapping, AttachedBindMode, DetachedBindMode, UVMapping, CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping, CubeUVReflectionMapping, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestFilter, NearestMipmapNearestFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipMapLinearFilter, LinearFilter, LinearMipmapNearestFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipMapLinearFilter, UnsignedByteType, ByteType, ShortType, UnsignedShortType, IntType, UnsignedIntType, FloatType, HalfFloatType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedInt248Type, UnsignedInt5999Type, UnsignedInt101111Type, AlphaFormat, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, RedFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBIntegerFormat, RGBAIntegerFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, R11_EAC_Format, SIGNED_R11_EAC_Format, RG11_EAC_Format, SIGNED_RG11_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, LoopOnce, LoopRepeat, LoopPingPong, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InterpolateBezier, ZeroCurvatureEnding, ZeroSlopeEnding, WrapAroundEnding, NormalAnimationBlendMode, AdditiveAnimationBlendMode, TrianglesDrawMode, TriangleStripDrawMode, TriangleFanDrawMode, BasicDepthPacking, RGBADepthPacking, RGBDepthPacking, RGDepthPacking, TangentSpaceNormalMap, ObjectSpaceNormalMap, NoColorSpace, SRGBColorSpace, LinearSRGBColorSpace, LinearTransfer, SRGBTransfer, NoNormalPacking, NormalRGPacking, NormalGAPacking, ZeroStencilOp, KeepStencilOp, ReplaceStencilOp, IncrementStencilOp, DecrementStencilOp, IncrementWrapStencilOp, DecrementWrapStencilOp, InvertStencilOp, NeverStencilFunc, LessStencilFunc, EqualStencilFunc, LessEqualStencilFunc, GreaterStencilFunc, NotEqualStencilFunc, GreaterEqualStencilFunc, AlwaysStencilFunc, NeverCompare, LessCompare, EqualCompare, LessEqualCompare, GreaterCompare, NotEqualCompare, GreaterEqualCompare, AlwaysCompare, StaticDrawUsage, DynamicDrawUsage, StreamDrawUsage, StaticReadUsage, DynamicReadUsage, StreamReadUsage, StaticCopyUsage, DynamicCopyUsage, StreamCopyUsage, GLSL1, GLSL3, WebGLCoordinateSystem, WebGPUCoordinateSystem, TimestampQuery, InterpolationSamplingType, InterpolationSamplingMode, Compatibility, TYPED_ARRAYS, _cache, _setConsoleFunction, ReversedDepthFuncs, EventDispatcher, _lut, _seed, DEG2RAD, RAD2DEG, MathUtils, Vector2, Quaternion, Vector3, _vector$c, _quaternion$5, Matrix3, _m3, LINEAR_REC709_TO_XYZ, XYZ_TO_LINEAR_REC709, ColorManagement, _canvas, ImageUtils, _sourceId, Source, _textureId, _tempVec3, Texture, Vector4, RenderTarget, WebGLRenderTarget, DataArrayTexture, WebGLArrayRenderTarget, Data3DTexture, WebGL3DRenderTarget, Matrix4, _v1$7, _m1$2, _zero, _one, _x, _y, _z, _matrix$2, _quaternion$4, Euler, Layers, _object3DId, _v1$6, _q1, _m1$1, _target, _position$4, _scale$3, _quaternion$3, _xAxis, _yAxis, _zAxis, _addedEvent, _removedEvent, _childaddedEvent, _childremovedEvent, Object3D, Group, _moveEvent, WebXRController, _colorKeywords, _hslA, _hslB, Color, _color, FogExp2, Fog, Scene, _v0$2, _v1$5, _v2$4, _v3$2, _vab, _vac, _vbc, _vap, _vbp, _vcp, _v40, _v41, _v42, Triangle, Box3, _points, _vector$b, _box$4, _v0$1, _v1$4, _v2$3, _f0, _f1, _f2, _center, _extents, _triangleNormal, _testAxis, _tables, DataUtils, _vector$a, _vector2$1, _id$2, BufferAttribute, Int8BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Int16BufferAttribute, Uint16BufferAttribute, Int32BufferAttribute, Uint32BufferAttribute, Float16BufferAttribute, Float32BufferAttribute, _box$3, _v1$3, _v2$2, Sphere, _id$1, _m1, _obj, _offset, _box$2, _boxMorphTargets, _vector$9, BufferGeometry, InterleavedBuffer, _vector$8, InterleavedBufferAttribute, _materialId, Material, SpriteMaterial, _geometry, _intersectPoint, _worldScale, _mvPosition, _alignedPosition, _rotatedPosition, _viewWorldMatrix, _vA$1, _vB$1, _vC$1, _uvA, _uvB, _uvC, Sprite, _v1$2, _v2$1, LOD, _vector$7, _segCenter, _segDir, _diff, _edge1, _edge2, _normal$1, Ray, MeshBasicMaterial, _inverseMatrix$3, _ray$3, _sphere$6, _sphereHitAt, _vA, _vB, _vC, _tempA, _morphA, _intersectionPoint, _intersectionPointWorld, Mesh, _basePosition, _skinIndex, _skinWeight, _vector3, _matrix4, _vertex, _sphere$5, _inverseMatrix$2, _ray$2, SkinnedMesh, Bone, DataTexture, _offsetMatrix, _identityMatrix, Skeleton, InstancedBufferAttribute, _instanceLocalMatrix, _instanceWorldMatrix, _instanceIntersects, _box3, _identity, _mesh$1, _sphere$4, InstancedMesh, _vector1, _vector2, _normalMatrix, Plane, _sphere$3, _defaultSpriteCenter, _vector$6, Frustum, _projScreenMatrix$1, _frustum$1, FrustumArray, MultiDrawRenderList, _matrix$1, _whiteColor, _frustum, _frustumArray, _box$1, _sphere$2, _vector$5, _forward$1, _temp, _renderList, _mesh, _batchIntersects, BatchedMesh, LineBasicMaterial, _vStart, _vEnd, _inverseMatrix$1, _ray$1, _sphere$1, _intersectPointOnRay, _intersectPointOnSegment, Line, _start, _end, LineSegments, LineLoop, PointsMaterial, _inverseMatrix, _ray, _sphere, _position$3, Points, VideoTexture, VideoFrameTexture, FramebufferTexture, CompressedTexture, CompressedArrayTexture, CompressedCubeTexture, CubeTexture, CanvasTexture, DepthTexture, CubeDepthTexture, ExternalTexture, BoxGeometry, CapsuleGeometry, CircleGeometry, CylinderGeometry, ConeGeometry, PolyhedronGeometry, DodecahedronGeometry, _v0, _v1$1, _normal, _triangle, EdgesGeometry, Curve, EllipseCurve, ArcCurve, tmp, px, py, pz, CatmullRomCurve3, CubicBezierCurve, CubicBezierCurve3, LineCurve, LineCurve3, QuadraticBezierCurve, QuadraticBezierCurve3, SplineCurve, Curves, CurvePath, Path, Shape, Earcut, ShapeUtils, ExtrudeGeometry, WorldUVGenerator, IcosahedronGeometry, LatheGeometry, OctahedronGeometry, PlaneGeometry, RingGeometry, ShapeGeometry, SphereGeometry, TetrahedronGeometry, TorusGeometry, TorusKnotGeometry, TubeGeometry, WireframeGeometry, Geometries, ShadowMaterial, UniformsUtils, default_vertex, default_fragment, ShaderMaterial, RawShaderMaterial, MeshStandardMaterial, MeshPhysicalMaterial, MeshPhongMaterial, MeshToonMaterial, MeshNormalMaterial, MeshLambertMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshMatcapMaterial, LineDashedMaterial, AnimationUtils, Interpolant, CubicInterpolant, LinearInterpolant, DiscreteInterpolant, BezierInterpolant, KeyframeTrack, BooleanKeyframeTrack, ColorKeyframeTrack, NumberKeyframeTrack, QuaternionLinearInterpolant, QuaternionKeyframeTrack, StringKeyframeTrack, VectorKeyframeTrack, AnimationClip, Cache, LoadingManager, DefaultLoadingManager, Loader, loading, HttpError, FileLoader, AnimationLoader, CompressedTextureLoader, _loading, ImageLoader, CubeTextureLoader, DataTextureLoader, TextureLoader, Light, HemisphereLight, _projScreenMatrix, _lightPositionWorld, _lookTarget, LightShadow, _position$2, _quaternion$2, _scale$2, Camera, _v3$1, _minTarget, _maxTarget, PerspectiveCamera, SpotLightShadow, SpotLight, PointLightShadow, PointLight, OrthographicCamera, DirectionalLightShadow, DirectionalLight, AmbientLight, RectAreaLight, SphericalHarmonics3, LightProbe, MaterialLoader, LoaderUtils, InstancedBufferGeometry, BufferGeometryLoader, ObjectLoader, TEXTURE_MAPPING, TEXTURE_WRAPPING, TEXTURE_FILTER, _errorMap, ImageBitmapLoader, _context, AudioContext, AudioLoader, _eyeRight, _eyeLeft, _projectionMatrix, StereoCamera, fov, aspect, CubeCamera, ArrayCamera, Timer, _position$1, _quaternion$1, _scale$1, _forward, _up, AudioListener, Audio2, _position, _quaternion, _scale, _orientation, PositionalAudio, AudioAnalyser, PropertyMixer, _RESERVED_CHARS_RE, _reservedRe, _wordChar, _wordCharOrDot, _directoryRe, _nodeRe, _objectRe, _propertyRe, _trackRe, _supportedObjectNames, Composite, PropertyBinding, AnimationObjectGroup, AnimationAction, _controlInterpolantsResultBuffer, AnimationMixer, RenderTarget3D, Uniform, _id, UniformsGroup, InstancedInterleavedBuffer, GLBufferAttribute, _matrix, Raycaster, Clock, Spherical, Cylindrical, Matrix2, _vector$4, Box2, _startP, _startEnd, _d1, _d2, _r, _c1, _c2, Line3, _vector$3, SpotLightHelper, _vector$2, _boneMatrix, _matrixWorldInv, SkeletonHelper, PointLightHelper, _vector$1, _color1, _color2, HemisphereLightHelper, GridHelper, PolarGridHelper, _v1, _v2, _v3, DirectionalLightHelper, _vector, _camera, CameraHelper, _box, BoxHelper, Box3Helper, PlaneHelper, _axis, _lineGeometry, _coneGeometry, ArrowHelper, AxesHelper, ShapePath, Controls, TextureUtils;
1695
+ var REVISION, MOUSE, TOUCH, CullFaceNone, CullFaceBack, CullFaceFront, CullFaceFrontBack, BasicShadowMap, PCFShadowMap, PCFSoftShadowMap, VSMShadowMap, FrontSide, BackSide, DoubleSide, NoBlending, NormalBlending, AdditiveBlending, SubtractiveBlending, MultiplyBlending, CustomBlending, MaterialBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, OneMinusSrcColorFactor, SrcAlphaFactor, OneMinusSrcAlphaFactor, DstAlphaFactor, OneMinusDstAlphaFactor, DstColorFactor, OneMinusDstColorFactor, SrcAlphaSaturateFactor, ConstantColorFactor, OneMinusConstantColorFactor, ConstantAlphaFactor, OneMinusConstantAlphaFactor, NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth, MultiplyOperation, MixOperation, AddOperation, NoToneMapping, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, CustomToneMapping, AgXToneMapping, NeutralToneMapping, AttachedBindMode, DetachedBindMode, UVMapping, CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping, CubeUVReflectionMapping, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, NearestFilter, NearestMipmapNearestFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipMapLinearFilter, LinearFilter, LinearMipmapNearestFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipMapLinearFilter, UnsignedByteType, ByteType, ShortType, UnsignedShortType, IntType, UnsignedIntType, FloatType, HalfFloatType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedInt248Type, UnsignedInt5999Type, UnsignedInt101111Type, AlphaFormat, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, RedFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBIntegerFormat, RGBAIntegerFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, R11_EAC_Format, SIGNED_R11_EAC_Format, RG11_EAC_Format, SIGNED_RG11_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, RED_GREEN_RGTC2_Format, SIGNED_RED_GREEN_RGTC2_Format, LoopOnce, LoopRepeat, LoopPingPong, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InterpolateBezier, ZeroCurvatureEnding, ZeroSlopeEnding, WrapAroundEnding, NormalAnimationBlendMode, AdditiveAnimationBlendMode, TrianglesDrawMode, TriangleStripDrawMode, TriangleFanDrawMode, BasicDepthPacking, RGBADepthPacking, RGBDepthPacking, RGDepthPacking, TangentSpaceNormalMap, ObjectSpaceNormalMap, NoColorSpace, SRGBColorSpace, LinearSRGBColorSpace, LinearTransfer, SRGBTransfer, NoNormalPacking, NormalRGPacking, NormalGAPacking, ZeroStencilOp, KeepStencilOp, ReplaceStencilOp, IncrementStencilOp, DecrementStencilOp, IncrementWrapStencilOp, DecrementWrapStencilOp, InvertStencilOp, NeverStencilFunc, LessStencilFunc, EqualStencilFunc, LessEqualStencilFunc, GreaterStencilFunc, NotEqualStencilFunc, GreaterEqualStencilFunc, AlwaysStencilFunc, NeverCompare, LessCompare, EqualCompare, LessEqualCompare, GreaterCompare, NotEqualCompare, GreaterEqualCompare, AlwaysCompare, StaticDrawUsage, DynamicDrawUsage, StreamDrawUsage, StaticReadUsage, DynamicReadUsage, StreamReadUsage, StaticCopyUsage, DynamicCopyUsage, StreamCopyUsage, GLSL1, GLSL3, WebGLCoordinateSystem, WebGPUCoordinateSystem, TimestampQuery, InterpolationSamplingType, InterpolationSamplingMode, Compatibility, TYPED_ARRAYS, _cache, _setConsoleFunction, ReversedDepthFuncs, EventDispatcher, _lut, _seed, DEG2RAD, RAD2DEG, MathUtils, Vector2, Quaternion, Vector3, _vector$c, _quaternion$5, Matrix3, _m3, LINEAR_REC709_TO_XYZ, XYZ_TO_LINEAR_REC709, ColorManagement, _canvas, ImageUtils, _sourceId, Source, _textureId, _tempVec3, Texture, Vector4, RenderTarget, WebGLRenderTarget, DataArrayTexture, WebGLArrayRenderTarget, Data3DTexture, WebGL3DRenderTarget, Matrix4, _v1$7, _m1$2, _zero, _one, _x, _y, _z, _matrix$2, _quaternion$4, Euler, Layers, _object3DId, _v1$6, _q1, _m1$1, _target, _position$4, _scale$3, _quaternion$3, _xAxis, _yAxis, _zAxis, _addedEvent, _removedEvent, _childaddedEvent, _childremovedEvent, Object3D, Group, _moveEvent, WebXRController, _colorKeywords, _hslA, _hslB, Color, _color, FogExp2, Fog, Scene, _v0$2, _v1$5, _v2$4, _v3$2, _vab, _vac, _vbc, _vap, _vbp, _vcp, _v40, _v41, _v42, Triangle, Box3, _points, _vector$b, _box$4, _v0$1, _v1$4, _v2$3, _f0, _f1, _f2, _center, _extents, _triangleNormal, _testAxis, _tables, DataUtils, _vector$a, _vector2$1, _id$2, BufferAttribute, Int8BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Int16BufferAttribute, Uint16BufferAttribute, Int32BufferAttribute, Uint32BufferAttribute, Float16BufferAttribute, Float32BufferAttribute, _box$3, _v1$3, _v2$2, Sphere, _id$1, _m1, _obj, _offset, _box$2, _boxMorphTargets, _vector$9, BufferGeometry, InterleavedBuffer, _vector$8, InterleavedBufferAttribute, _materialId, Material, SpriteMaterial, _geometry, _intersectPoint, _worldScale, _mvPosition, _alignedPosition, _rotatedPosition, _viewWorldMatrix, _vA$1, _vB$1, _vC$1, _uvA, _uvB, _uvC, Sprite, _v1$2, _v2$1, LOD, _vector$7, _segCenter, _segDir, _diff, _edge1, _edge2, _normal$1, Ray, MeshBasicMaterial, _inverseMatrix$3, _ray$3, _sphere$6, _sphereHitAt, _vA, _vB, _vC, _tempA, _morphA, _intersectionPoint, _intersectionPointWorld, Mesh, _baseVector, _skinIndex, _skinWeight, _vector4, _matrix4, _vertex, _sphere$5, _inverseMatrix$2, _ray$2, SkinnedMesh, Bone, DataTexture, _offsetMatrix, _identityMatrix, Skeleton, InstancedBufferAttribute, _instanceLocalMatrix, _instanceWorldMatrix, _instanceIntersects, _box3, _identity, _mesh$1, _sphere$4, InstancedMesh, _vector1, _vector2, _normalMatrix, Plane, _sphere$3, _defaultSpriteCenter, _vector$6, Frustum, _projScreenMatrix$1, _frustum$1, FrustumArray, MultiDrawRenderList, _matrix$1, _whiteColor, _frustum, _frustumArray, _box$1, _sphere$2, _vector$5, _forward$1, _temp, _renderList, _mesh, _batchIntersects, BatchedMesh, LineBasicMaterial, _vStart, _vEnd, _inverseMatrix$1, _ray$1, _sphere$1, _intersectPointOnRay, _intersectPointOnSegment, Line, _start, _end, LineSegments, LineLoop, PointsMaterial, _inverseMatrix, _ray, _sphere, _position$3, Points, VideoTexture, VideoFrameTexture, FramebufferTexture, CompressedTexture, CompressedArrayTexture, CompressedCubeTexture, CubeTexture, CanvasTexture, HTMLTexture, DepthTexture, CubeDepthTexture, ExternalTexture, BoxGeometry, CapsuleGeometry, CircleGeometry, CylinderGeometry, ConeGeometry, PolyhedronGeometry, DodecahedronGeometry, _v0, _v1$1, _normal, _triangle, EdgesGeometry, Curve, EllipseCurve, ArcCurve, tmp, tmp2, px, py, pz, CatmullRomCurve3, CubicBezierCurve, CubicBezierCurve3, LineCurve, LineCurve3, QuadraticBezierCurve, QuadraticBezierCurve3, SplineCurve, Curves, CurvePath, Path, Shape, Earcut, ShapeUtils, ExtrudeGeometry, WorldUVGenerator, IcosahedronGeometry, LatheGeometry, OctahedronGeometry, PlaneGeometry, RingGeometry, ShapeGeometry, SphereGeometry, TetrahedronGeometry, TorusGeometry, TorusKnotGeometry, TubeGeometry, WireframeGeometry, Geometries, ShadowMaterial, UniformsUtils, default_vertex, default_fragment, ShaderMaterial, RawShaderMaterial, MeshStandardMaterial, MeshPhysicalMaterial, MeshPhongMaterial, MeshToonMaterial, MeshNormalMaterial, MeshLambertMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshMatcapMaterial, LineDashedMaterial, AnimationUtils, Interpolant, CubicInterpolant, LinearInterpolant, DiscreteInterpolant, BezierInterpolant, KeyframeTrack, BooleanKeyframeTrack, ColorKeyframeTrack, NumberKeyframeTrack, QuaternionLinearInterpolant, QuaternionKeyframeTrack, StringKeyframeTrack, VectorKeyframeTrack, AnimationClip, Cache, LoadingManager, DefaultLoadingManager, Loader, loading, HttpError, FileLoader, AnimationLoader, CompressedTextureLoader, _loading, ImageLoader, CubeTextureLoader, DataTextureLoader, TextureLoader, Light, HemisphereLight, _projScreenMatrix, _lightPositionWorld, _lookTarget, LightShadow, _position$2, _quaternion$2, _scale$2, Camera, _v3$1, _minTarget, _maxTarget, PerspectiveCamera, SpotLightShadow, SpotLight, PointLightShadow, PointLight, OrthographicCamera, DirectionalLightShadow, DirectionalLight, AmbientLight, RectAreaLight, SphericalHarmonics3, LightProbe, MaterialLoader, LoaderUtils, InstancedBufferGeometry, BufferGeometryLoader, _customGeometries, ObjectLoader, TEXTURE_MAPPING, TEXTURE_WRAPPING, TEXTURE_FILTER, _errorMap, ImageBitmapLoader, _context, AudioContext, AudioLoader, _eyeRight, _eyeLeft, _projectionMatrix, StereoCamera, fov, aspect, CubeCamera, ArrayCamera, Timer, _position$1, _quaternion$1, _scale$1, _forward, _up, AudioListener, Audio2, _position, _quaternion, _scale, _orientation, PositionalAudio, AudioAnalyser, PropertyMixer, _RESERVED_CHARS_RE, _reservedRe, _wordChar, _wordCharOrDot, _directoryRe, _nodeRe, _objectRe, _propertyRe, _trackRe, _supportedObjectNames, Composite, PropertyBinding, AnimationObjectGroup, AnimationAction, _controlInterpolantsResultBuffer, AnimationMixer, RenderTarget3D, Uniform, _id, UniformsGroup, InstancedInterleavedBuffer, GLBufferAttribute, _matrix, Raycaster, Clock, Spherical, Cylindrical, Matrix2, _vector$4, Box2, _startP, _startEnd, _d1, _d2, _r, _c1, _c2, Line3, _vector$3, SpotLightHelper, _vector$2, _boneMatrix, _matrixWorldInv, SkeletonHelper, PointLightHelper, _vector$1, _color1, _color2, HemisphereLightHelper, GridHelper, PolarGridHelper, _v1, _v2, _v3, DirectionalLightHelper, _vector, _camera, CameraHelper, _box, BoxHelper, Box3Helper, PlaneHelper, _axis, _lineGeometry, _coneGeometry, ArrowHelper, AxesHelper, ShapePath, Controls, TextureUtils;
1684
1696
  var init_three_core = __esm({
1685
- "../../node_modules/.bun/three@0.183.2/node_modules/three/build/three.core.js"() {
1686
- REVISION = "183";
1697
+ "../../node_modules/.bun/three@0.184.0/node_modules/three/build/three.core.js"() {
1698
+ REVISION = "184";
1687
1699
  MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
1688
1700
  TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
1689
1701
  CullFaceNone = 0;
@@ -2246,6 +2258,9 @@ var init_three_core = __esm({
2246
2258
  denormalize
2247
2259
  };
2248
2260
  Vector2 = class _Vector2 {
2261
+ static {
2262
+ _Vector2.prototype.isVector2 = true;
2263
+ }
2249
2264
  /**
2250
2265
  * Constructs a new 2D vector.
2251
2266
  *
@@ -2253,7 +2268,6 @@ var init_three_core = __esm({
2253
2268
  * @param {number} [y=0] - The y value of this vector.
2254
2269
  */
2255
2270
  constructor(x2 = 0, y = 0) {
2256
- _Vector2.prototype.isVector2 = true;
2257
2271
  this.x = x2;
2258
2272
  this.y = y;
2259
2273
  }
@@ -3471,6 +3485,9 @@ var init_three_core = __esm({
3471
3485
  }
3472
3486
  };
3473
3487
  Vector3 = class _Vector3 {
3488
+ static {
3489
+ _Vector3.prototype.isVector3 = true;
3490
+ }
3474
3491
  /**
3475
3492
  * Constructs a new 3D vector.
3476
3493
  *
@@ -3479,7 +3496,6 @@ var init_three_core = __esm({
3479
3496
  * @param {number} [z=0] - The z value of this vector.
3480
3497
  */
3481
3498
  constructor(x2 = 0, y = 0, z = 0) {
3482
- _Vector3.prototype.isVector3 = true;
3483
3499
  this.x = x2;
3484
3500
  this.y = y;
3485
3501
  this.z = z;
@@ -4377,6 +4393,9 @@ var init_three_core = __esm({
4377
4393
  _vector$c = /* @__PURE__ */ new Vector3();
4378
4394
  _quaternion$5 = /* @__PURE__ */ new Quaternion();
4379
4395
  Matrix3 = class _Matrix3 {
4396
+ static {
4397
+ _Matrix3.prototype.isMatrix3 = true;
4398
+ }
4380
4399
  /**
4381
4400
  * Constructs a new 3x3 matrix. The arguments are supposed to be
4382
4401
  * in row-major order. If no arguments are provided, the constructor
@@ -4393,7 +4412,6 @@ var init_three_core = __esm({
4393
4412
  * @param {number} [n33] - 3-3 matrix element.
4394
4413
  */
4395
4414
  constructor(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
4396
- _Matrix3.prototype.isMatrix3 = true;
4397
4415
  this.elements = [
4398
4416
  1,
4399
4417
  0,
@@ -4615,17 +4633,17 @@ var init_three_core = __esm({
4615
4633
  * @return {Matrix3} A reference to this matrix.
4616
4634
  */
4617
4635
  transpose() {
4618
- let tmp2;
4636
+ let tmp3;
4619
4637
  const m2 = this.elements;
4620
- tmp2 = m2[1];
4638
+ tmp3 = m2[1];
4621
4639
  m2[1] = m2[3];
4622
- m2[3] = tmp2;
4623
- tmp2 = m2[2];
4640
+ m2[3] = tmp3;
4641
+ tmp3 = m2[2];
4624
4642
  m2[2] = m2[6];
4625
- m2[6] = tmp2;
4626
- tmp2 = m2[5];
4643
+ m2[6] = tmp3;
4644
+ tmp3 = m2[5];
4627
4645
  m2[5] = m2[7];
4628
- m2[7] = tmp2;
4646
+ m2[7] = tmp3;
4629
4647
  return this;
4630
4648
  }
4631
4649
  /**
@@ -4975,7 +4993,7 @@ var init_three_core = __esm({
4975
4993
  if (typeof HTMLVideoElement !== "undefined" && data instanceof HTMLVideoElement) {
4976
4994
  target.set(data.videoWidth, data.videoHeight, 0);
4977
4995
  } else if (typeof VideoFrame !== "undefined" && data instanceof VideoFrame) {
4978
- target.set(data.displayHeight, data.displayWidth, 0);
4996
+ target.set(data.displayWidth, data.displayHeight, 0);
4979
4997
  } else if (data !== null) {
4980
4998
  target.set(data.width, data.height, data.depth || 0);
4981
4999
  } else {
@@ -5088,6 +5106,7 @@ var init_three_core = __esm({
5088
5106
  this.isRenderTargetTexture = false;
5089
5107
  this.isArrayTexture = image && image.depth && image.depth > 1 ? true : false;
5090
5108
  this.pmremVersion = 0;
5109
+ this.normalized = false;
5091
5110
  }
5092
5111
  /**
5093
5112
  * The width of the texture in pixels.
@@ -5115,11 +5134,11 @@ var init_three_core = __esm({
5115
5134
  get image() {
5116
5135
  return this.source.data;
5117
5136
  }
5118
- set image(value = null) {
5137
+ set image(value) {
5119
5138
  this.source.data = value;
5120
5139
  }
5121
5140
  /**
5122
- * Updates the texture transformation matrix from the from the properties {@link Texture#offset},
5141
+ * Updates the texture transformation matrix from the properties {@link Texture#offset},
5123
5142
  * {@link Texture#repeat}, {@link Texture#rotation}, and {@link Texture#center}.
5124
5143
  */
5125
5144
  updateMatrix() {
@@ -5168,6 +5187,7 @@ var init_three_core = __esm({
5168
5187
  this.format = source.format;
5169
5188
  this.internalFormat = source.internalFormat;
5170
5189
  this.type = source.type;
5190
+ this.normalized = source.normalized;
5171
5191
  this.offset.copy(source.offset);
5172
5192
  this.repeat.copy(source.repeat);
5173
5193
  this.center.copy(source.center);
@@ -5244,6 +5264,7 @@ var init_three_core = __esm({
5244
5264
  format: this.format,
5245
5265
  internalFormat: this.internalFormat,
5246
5266
  type: this.type,
5267
+ normalized: this.normalized,
5247
5268
  colorSpace: this.colorSpace,
5248
5269
  minFilter: this.minFilter,
5249
5270
  magFilter: this.magFilter,
@@ -5349,6 +5370,9 @@ var init_three_core = __esm({
5349
5370
  Texture.DEFAULT_MAPPING = UVMapping;
5350
5371
  Texture.DEFAULT_ANISOTROPY = 1;
5351
5372
  Vector4 = class _Vector4 {
5373
+ static {
5374
+ _Vector4.prototype.isVector4 = true;
5375
+ }
5352
5376
  /**
5353
5377
  * Constructs a new 4D vector.
5354
5378
  *
@@ -5358,7 +5382,6 @@ var init_three_core = __esm({
5358
5382
  * @param {number} [w=1] - The w value of this vector.
5359
5383
  */
5360
5384
  constructor(x2 = 0, y = 0, z = 0, w = 1) {
5361
- _Vector4.prototype.isVector4 = true;
5362
5385
  this.x = x2;
5363
5386
  this.y = y;
5364
5387
  this.z = z;
@@ -6266,6 +6289,7 @@ var init_three_core = __esm({
6266
6289
  this.resolveStencilBuffer = source.resolveStencilBuffer;
6267
6290
  if (source.depthTexture !== null) this.depthTexture = source.depthTexture.clone();
6268
6291
  this.samples = source.samples;
6292
+ this.multiview = source.multiview;
6269
6293
  return this;
6270
6294
  }
6271
6295
  /**
@@ -6389,6 +6413,9 @@ var init_three_core = __esm({
6389
6413
  }
6390
6414
  };
6391
6415
  Matrix4 = class _Matrix4 {
6416
+ static {
6417
+ _Matrix4.prototype.isMatrix4 = true;
6418
+ }
6392
6419
  /**
6393
6420
  * Constructs a new 4x4 matrix. The arguments are supposed to be
6394
6421
  * in row-major order. If no arguments are provided, the constructor
@@ -6412,7 +6439,6 @@ var init_three_core = __esm({
6412
6439
  * @param {number} [n44] - 4-4 matrix element.
6413
6440
  */
6414
6441
  constructor(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
6415
- _Matrix4.prototype.isMatrix4 = true;
6416
6442
  this.elements = [
6417
6443
  1,
6418
6444
  0,
@@ -6917,25 +6943,25 @@ var init_three_core = __esm({
6917
6943
  */
6918
6944
  transpose() {
6919
6945
  const te = this.elements;
6920
- let tmp2;
6921
- tmp2 = te[1];
6946
+ let tmp3;
6947
+ tmp3 = te[1];
6922
6948
  te[1] = te[4];
6923
- te[4] = tmp2;
6924
- tmp2 = te[2];
6949
+ te[4] = tmp3;
6950
+ tmp3 = te[2];
6925
6951
  te[2] = te[8];
6926
- te[8] = tmp2;
6927
- tmp2 = te[6];
6952
+ te[8] = tmp3;
6953
+ tmp3 = te[6];
6928
6954
  te[6] = te[9];
6929
- te[9] = tmp2;
6930
- tmp2 = te[3];
6955
+ te[9] = tmp3;
6956
+ tmp3 = te[3];
6931
6957
  te[3] = te[12];
6932
- te[12] = tmp2;
6933
- tmp2 = te[7];
6958
+ te[12] = tmp3;
6959
+ tmp3 = te[7];
6934
6960
  te[7] = te[13];
6935
- te[13] = tmp2;
6936
- tmp2 = te[11];
6961
+ te[13] = tmp3;
6962
+ tmp3 = te[11];
6937
6963
  te[11] = te[14];
6938
- te[14] = tmp2;
6964
+ te[14] = tmp3;
6939
6965
  return this;
6940
6966
  }
6941
6967
  /**
@@ -8775,9 +8801,7 @@ var init_three_core = __esm({
8775
8801
  this.rotation.order = source.rotation.order;
8776
8802
  this.quaternion.copy(source.quaternion);
8777
8803
  this.scale.copy(source.scale);
8778
- if (source.pivot !== null) {
8779
- this.pivot = source.pivot.clone();
8780
- }
8804
+ this.pivot = source.pivot !== null ? source.pivot.clone() : null;
8781
8805
  this.matrix.copy(source.matrix);
8782
8806
  this.matrixWorld.copy(source.matrixWorld);
8783
8807
  this.matrixAutoUpdate = source.matrixAutoUpdate;
@@ -8867,6 +8891,7 @@ var init_three_core = __esm({
8867
8891
  this._grip.linearVelocity = new Vector3();
8868
8892
  this._grip.hasAngularVelocity = false;
8869
8893
  this._grip.angularVelocity = new Vector3();
8894
+ this._grip.eventsEnabled = false;
8870
8895
  }
8871
8896
  return this._grip;
8872
8897
  }
@@ -8996,6 +9021,13 @@ var init_three_core = __esm({
8996
9021
  } else {
8997
9022
  grip.hasAngularVelocity = false;
8998
9023
  }
9024
+ if (grip.eventsEnabled) {
9025
+ grip.dispatchEvent({
9026
+ type: "gripUpdated",
9027
+ data: inputSource,
9028
+ target: this
9029
+ });
9030
+ }
8999
9031
  }
9000
9032
  }
9001
9033
  }
@@ -10075,7 +10107,7 @@ var init_three_core = __esm({
10075
10107
  static isFrontFacing(a2, b2, c2, direction) {
10076
10108
  _v0$2.subVectors(c2, b2);
10077
10109
  _v1$5.subVectors(a2, b2);
10078
- return _v0$2.cross(_v1$5).dot(direction) < 0 ? true : false;
10110
+ return _v0$2.cross(_v1$5).dot(direction) < 0;
10079
10111
  }
10080
10112
  /**
10081
10113
  * Sets the triangle's vertices by copying the given values.
@@ -10846,7 +10878,7 @@ var init_three_core = __esm({
10846
10878
  _vector$a = /* @__PURE__ */ new Vector3();
10847
10879
  _vector2$1 = /* @__PURE__ */ new Vector2();
10848
10880
  _id$2 = 0;
10849
- BufferAttribute = class {
10881
+ BufferAttribute = class extends EventDispatcher {
10850
10882
  /**
10851
10883
  * Constructs a new buffer attribute.
10852
10884
  *
@@ -10855,6 +10887,7 @@ var init_three_core = __esm({
10855
10887
  * @param {boolean} [normalized=false] - Whether the data are normalized or not.
10856
10888
  */
10857
10889
  constructor(array, itemSize, normalized = false) {
10890
+ super();
10858
10891
  if (Array.isArray(array)) {
10859
10892
  throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
10860
10893
  }
@@ -11251,6 +11284,12 @@ var init_three_core = __esm({
11251
11284
  if (this.usage !== StaticDrawUsage) data.usage = this.usage;
11252
11285
  return data;
11253
11286
  }
11287
+ /**
11288
+ * Disposes of the buffer attribute. Available only in {@link WebGPURenderer}.
11289
+ */
11290
+ dispose() {
11291
+ this.dispatchEvent({ type: "dispose" });
11292
+ }
11254
11293
  };
11255
11294
  Int8BufferAttribute = class extends BufferAttribute {
11256
11295
  /**
@@ -12192,18 +12231,18 @@ var init_three_core = __esm({
12192
12231
  );
12193
12232
  }
12194
12233
  }
12195
- const tmp2 = new Vector3(), tmp22 = new Vector3();
12234
+ const tmp3 = new Vector3(), tmp22 = new Vector3();
12196
12235
  const n = new Vector3(), n2 = new Vector3();
12197
12236
  function handleVertex(v) {
12198
12237
  n.fromBufferAttribute(normalAttribute, v);
12199
12238
  n2.copy(n);
12200
12239
  const t2 = tan1[v];
12201
- tmp2.copy(t2);
12202
- tmp2.sub(n.multiplyScalar(n.dot(t2))).normalize();
12240
+ tmp3.copy(t2);
12241
+ tmp3.sub(n.multiplyScalar(n.dot(t2))).normalize();
12203
12242
  tmp22.crossVectors(n2, t2);
12204
12243
  const test = tmp22.dot(tan2[v]);
12205
12244
  const w = test < 0 ? -1 : 1;
12206
- tangentAttribute.setXYZW(v, tmp2.x, tmp2.y, tmp2.z, w);
12245
+ tangentAttribute.setXYZW(v, tmp3.x, tmp3.y, tmp3.z, w);
12207
12246
  }
12208
12247
  for (let i3 = 0, il = groups.length; i3 < il; ++i3) {
12209
12248
  const group = groups[i3];
@@ -14354,10 +14393,10 @@ var init_three_core = __esm({
14354
14393
  }
14355
14394
  }
14356
14395
  };
14357
- _basePosition = /* @__PURE__ */ new Vector3();
14396
+ _baseVector = /* @__PURE__ */ new Vector4();
14358
14397
  _skinIndex = /* @__PURE__ */ new Vector4();
14359
14398
  _skinWeight = /* @__PURE__ */ new Vector4();
14360
- _vector3 = /* @__PURE__ */ new Vector3();
14399
+ _vector4 = /* @__PURE__ */ new Vector4();
14361
14400
  _matrix4 = /* @__PURE__ */ new Matrix4();
14362
14401
  _vertex = /* @__PURE__ */ new Vector3();
14363
14402
  _sphere$5 = /* @__PURE__ */ new Sphere();
@@ -14499,28 +14538,37 @@ var init_three_core = __esm({
14499
14538
  }
14500
14539
  /**
14501
14540
  * Applies the bone transform associated with the given index to the given
14502
- * vertex position. Returns the updated vector.
14541
+ * vector. Can be used to transform positions or direction vectors by providing
14542
+ * a Vector4 with 1 or 0 in the w component respectively. Returns the updated vector.
14503
14543
  *
14504
14544
  * @param {number} index - The vertex index.
14505
- * @param {Vector3} target - The target object that is used to store the method's result.
14506
- * the skinned mesh's world matrix will be used instead.
14507
- * @return {Vector3} The updated vertex position.
14545
+ * @param {Vector3|Vector4} target - The target object that is used to store the method's result.
14546
+ * @return {Vector3|Vector4} The updated vertex attribute data.
14508
14547
  */
14509
14548
  applyBoneTransform(index, target) {
14510
14549
  const skeleton = this.skeleton;
14511
14550
  const geometry = this.geometry;
14512
14551
  _skinIndex.fromBufferAttribute(geometry.attributes.skinIndex, index);
14513
14552
  _skinWeight.fromBufferAttribute(geometry.attributes.skinWeight, index);
14514
- _basePosition.copy(target).applyMatrix4(this.bindMatrix);
14515
- target.set(0, 0, 0);
14553
+ if (target.isVector4) {
14554
+ _baseVector.copy(target);
14555
+ target.set(0, 0, 0, 0);
14556
+ } else {
14557
+ _baseVector.set(...target, 1);
14558
+ target.set(0, 0, 0);
14559
+ }
14560
+ _baseVector.applyMatrix4(this.bindMatrix);
14516
14561
  for (let i3 = 0; i3 < 4; i3++) {
14517
14562
  const weight = _skinWeight.getComponent(i3);
14518
14563
  if (weight !== 0) {
14519
14564
  const boneIndex = _skinIndex.getComponent(i3);
14520
14565
  _matrix4.multiplyMatrices(skeleton.bones[boneIndex].matrixWorld, skeleton.boneInverses[boneIndex]);
14521
- target.addScaledVector(_vector3.copy(_basePosition).applyMatrix4(_matrix4), weight);
14566
+ target.addScaledVector(_vector4.copy(_baseVector).applyMatrix4(_matrix4), weight);
14522
14567
  }
14523
14568
  }
14569
+ if (target.isVector4) {
14570
+ target.w = _baseVector.w;
14571
+ }
14524
14572
  return target.applyMatrix4(this.bindMatrixInverse);
14525
14573
  }
14526
14574
  };
@@ -14868,18 +14916,24 @@ var init_three_core = __esm({
14868
14916
  *
14869
14917
  * @param {number} index - The instance index.
14870
14918
  * @param {Color} color - The target object that is used to store the method's result.
14919
+ * @return {Color} A reference to the target color.
14871
14920
  */
14872
14921
  getColorAt(index, color) {
14873
- color.fromArray(this.instanceColor.array, index * 3);
14922
+ if (this.instanceColor === null) {
14923
+ return color.setRGB(1, 1, 1);
14924
+ } else {
14925
+ return color.fromArray(this.instanceColor.array, index * 3);
14926
+ }
14874
14927
  }
14875
14928
  /**
14876
14929
  * Gets the local transformation matrix of the defined instance.
14877
14930
  *
14878
14931
  * @param {number} index - The instance index.
14879
14932
  * @param {Matrix4} matrix - The target object that is used to store the method's result.
14933
+ * @return {Matrix4} A reference to the target matrix.
14880
14934
  */
14881
14935
  getMatrixAt(index, matrix) {
14882
- matrix.fromArray(this.instanceMatrix.array, index * 16);
14936
+ return matrix.fromArray(this.instanceMatrix.array, index * 16);
14883
14937
  }
14884
14938
  /**
14885
14939
  * Gets the morph target weights of the defined instance.
@@ -14926,22 +14980,26 @@ var init_three_core = __esm({
14926
14980
  *
14927
14981
  * @param {number} index - The instance index.
14928
14982
  * @param {Color} color - The instance color.
14983
+ * @return {InstancedMesh} A reference to this instanced mesh.
14929
14984
  */
14930
14985
  setColorAt(index, color) {
14931
14986
  if (this.instanceColor === null) {
14932
14987
  this.instanceColor = new InstancedBufferAttribute(new Float32Array(this.instanceMatrix.count * 3).fill(1), 3);
14933
14988
  }
14934
14989
  color.toArray(this.instanceColor.array, index * 3);
14990
+ return this;
14935
14991
  }
14936
14992
  /**
14937
14993
  * Sets the given local transformation matrix to the defined instance. Make sure you set the `needsUpdate` flag of
14938
- * {@link InstancedMesh#instanceMatrix} to `true` after updating all the colors.
14994
+ * {@link InstancedMesh#instanceMatrix} to `true` after updating all the matrices.
14939
14995
  *
14940
14996
  * @param {number} index - The instance index.
14941
14997
  * @param {Matrix4} matrix - The local transformation.
14998
+ * @return {InstancedMesh} A reference to this instanced mesh.
14942
14999
  */
14943
15000
  setMatrixAt(index, matrix) {
14944
15001
  matrix.toArray(this.instanceMatrix.array, index * 16);
15002
+ return this;
14945
15003
  }
14946
15004
  /**
14947
15005
  * Sets the morph target weights to the defined instance. Make sure you set the `needsUpdate` flag of
@@ -14950,6 +15008,7 @@ var init_three_core = __esm({
14950
15008
  * @param {number} index - The instance index.
14951
15009
  * @param {Mesh} object - A mesh which `morphTargetInfluences` property containing the morph target weights
14952
15010
  * of a single instance.
15011
+ * @return {InstancedMesh} A reference to this instanced mesh.
14953
15012
  */
14954
15013
  setMorphAt(index, object) {
14955
15014
  const objectInfluences = object.morphTargetInfluences;
@@ -14966,6 +15025,7 @@ var init_three_core = __esm({
14966
15025
  const dataIndex = len * index;
14967
15026
  array[dataIndex] = morphBaseInfluence;
14968
15027
  array.set(objectInfluences, dataIndex + 1);
15028
+ return this;
14969
15029
  }
14970
15030
  updateMorphTargets() {
14971
15031
  }
@@ -15118,9 +15178,10 @@ var init_three_core = __esm({
15118
15178
  *
15119
15179
  * @param {Line3} line - The line to compute the intersection for.
15120
15180
  * @param {Vector3} target - The target vector that is used to store the method's result.
15121
- * @return {?Vector3} The intersection point.
15181
+ * @param {boolean} [clampToLine=true] - Whether to clamp the intersection to the line segment.
15182
+ * @return {?Vector3} The intersection point. Returns `null` if no intersection is detected.
15122
15183
  */
15123
- intersectLine(line, target) {
15184
+ intersectLine(line, target, clampToLine = true) {
15124
15185
  const direction = line.delta(_vector1);
15125
15186
  const denominator = this.normal.dot(direction);
15126
15187
  if (denominator === 0) {
@@ -15130,7 +15191,7 @@ var init_three_core = __esm({
15130
15191
  return null;
15131
15192
  }
15132
15193
  const t2 = -(line.start.dot(this.normal) + this.constant) / denominator;
15133
- if (t2 < 0 || t2 > 1) {
15194
+ if (clampToLine === true && (t2 < 0 || t2 > 1)) {
15134
15195
  return null;
15135
15196
  }
15136
15197
  return target.copy(line.start).addScaledVector(direction, t2);
@@ -15638,7 +15699,6 @@ var init_three_core = __esm({
15638
15699
  this._multiDrawCounts = new Int32Array(maxInstanceCount);
15639
15700
  this._multiDrawStarts = new Int32Array(maxInstanceCount);
15640
15701
  this._multiDrawCount = 0;
15641
- this._multiDrawInstances = null;
15642
15702
  this._matricesTexture = null;
15643
15703
  this._indirectTexture = null;
15644
15704
  this._colorsTexture = null;
@@ -16183,7 +16243,15 @@ var init_three_core = __esm({
16183
16243
  */
16184
16244
  getColorAt(instanceId, color) {
16185
16245
  this.validateInstanceId(instanceId);
16186
- return color.fromArray(this._colorsTexture.image.data, instanceId * 4);
16246
+ if (this._colorsTexture === null) {
16247
+ if (color.isVector4) {
16248
+ return color.set(1, 1, 1, 1);
16249
+ } else {
16250
+ return color.setRGB(1, 1, 1);
16251
+ }
16252
+ } else {
16253
+ return color.fromArray(this._colorsTexture.image.data, instanceId * 4);
16254
+ }
16187
16255
  }
16188
16256
  /**
16189
16257
  * Sets the visibility of the instance.
@@ -17087,6 +17155,41 @@ var init_three_core = __esm({
17087
17155
  this.needsUpdate = true;
17088
17156
  }
17089
17157
  };
17158
+ HTMLTexture = class extends Texture {
17159
+ /**
17160
+ * Constructs a new texture.
17161
+ *
17162
+ * @param {HTMLElement} [element] - The HTML element.
17163
+ * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.
17164
+ * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.
17165
+ * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.
17166
+ * @param {number} [magFilter=LinearFilter] - The mag filter value.
17167
+ * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.
17168
+ * @param {number} [format=RGBAFormat] - The texture format.
17169
+ * @param {number} [type=UnsignedByteType] - The texture type.
17170
+ * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.
17171
+ */
17172
+ constructor(element2, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) {
17173
+ super(element2, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);
17174
+ this.isHTMLTexture = true;
17175
+ this.generateMipmaps = false;
17176
+ this.needsUpdate = true;
17177
+ const parent = element2 ? element2.parentNode : null;
17178
+ if (parent !== null && "requestPaint" in parent) {
17179
+ parent.onpaint = () => {
17180
+ this.needsUpdate = true;
17181
+ };
17182
+ parent.requestPaint();
17183
+ }
17184
+ }
17185
+ dispose() {
17186
+ const parent = this.image ? this.image.parentNode : null;
17187
+ if (parent !== null && "onpaint" in parent) {
17188
+ parent.onpaint = null;
17189
+ }
17190
+ super.dispose();
17191
+ }
17192
+ };
17090
17193
  DepthTexture = class extends Texture {
17091
17194
  /**
17092
17195
  * Constructs a new depth texture.
@@ -18541,6 +18644,7 @@ var init_three_core = __esm({
18541
18644
  }
18542
18645
  };
18543
18646
  tmp = /* @__PURE__ */ new Vector3();
18647
+ tmp2 = /* @__PURE__ */ new Vector3();
18544
18648
  px = /* @__PURE__ */ new CubicPoly();
18545
18649
  py = /* @__PURE__ */ new CubicPoly();
18546
18650
  pz = /* @__PURE__ */ new CubicPoly();
@@ -18586,8 +18690,8 @@ var init_three_core = __esm({
18586
18690
  if (this.closed || intPoint > 0) {
18587
18691
  p0 = points[(intPoint - 1) % l2];
18588
18692
  } else {
18589
- tmp.subVectors(points[0], points[1]).add(points[0]);
18590
- p0 = tmp;
18693
+ tmp2.subVectors(points[0], points[1]).add(points[0]);
18694
+ p0 = tmp2;
18591
18695
  }
18592
18696
  const p1 = points[intPoint % l2];
18593
18697
  const p22 = points[(intPoint + 1) % l2];
@@ -23436,7 +23540,6 @@ var init_three_core = __esm({
23436
23540
  * @param {function(any)} onLoad - Executed when the loading process has been finished.
23437
23541
  * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.
23438
23542
  * @param {onErrorCallback} [onError] - Executed when errors occur.
23439
- * @return {any|undefined} The cached resource if available.
23440
23543
  */
23441
23544
  load(url, onLoad, onProgress, onError) {
23442
23545
  if (url === void 0) url = "";
@@ -23449,7 +23552,7 @@ var init_three_core = __esm({
23449
23552
  if (onLoad) onLoad(cached);
23450
23553
  this.manager.itemEnd(url);
23451
23554
  }, 0);
23452
- return cached;
23555
+ return;
23453
23556
  }
23454
23557
  if (loading[url] !== void 0) {
23455
23558
  loading[url].push({
@@ -23893,13 +23996,13 @@ var init_three_core = __esm({
23893
23996
  let texData;
23894
23997
  try {
23895
23998
  texData = scope.parse(buffer);
23896
- } catch (error2) {
23999
+ } catch (e2) {
23897
24000
  if (onError !== void 0) {
23898
- onError(error2);
24001
+ onError(e2);
23899
24002
  } else {
23900
- error2(error2);
23901
- return;
24003
+ error(e2);
23902
24004
  }
24005
+ return;
23903
24006
  }
23904
24007
  if (texData.image !== void 0) {
23905
24008
  texture.image = texData.image;
@@ -25235,7 +25338,7 @@ var init_three_core = __esm({
25235
25338
  if (json.userData !== void 0) material.userData = json.userData;
25236
25339
  if (json.vertexColors !== void 0) {
25237
25340
  if (typeof json.vertexColors === "number") {
25238
- material.vertexColors = json.vertexColors > 0 ? true : false;
25341
+ material.vertexColors = json.vertexColors > 0;
25239
25342
  } else {
25240
25343
  material.vertexColors = json.vertexColors;
25241
25344
  }
@@ -25563,6 +25666,7 @@ var init_three_core = __esm({
25563
25666
  return geometry;
25564
25667
  }
25565
25668
  };
25669
+ _customGeometries = {};
25566
25670
  ObjectLoader = class extends Loader {
25567
25671
  /**
25568
25672
  * Constructs a new object loader.
@@ -25592,9 +25696,9 @@ var init_three_core = __esm({
25592
25696
  let json = null;
25593
25697
  try {
25594
25698
  json = JSON.parse(text2);
25595
- } catch (error2) {
25596
- if (onError !== void 0) onError(error2);
25597
- error2("ObjectLoader: Can't parse " + url + ".", error2.message);
25699
+ } catch (e2) {
25700
+ if (onError !== void 0) onError(e2);
25701
+ error("ObjectLoader: Can't parse " + url + ".", e2.message);
25598
25702
  return;
25599
25703
  }
25600
25704
  const metadata = json.metadata;
@@ -25687,6 +25791,17 @@ var init_three_core = __esm({
25687
25791
  this.bindLightTargets(object);
25688
25792
  return object;
25689
25793
  }
25794
+ /**
25795
+ * Registers the given geometry at the internal
25796
+ * geometry library.
25797
+ *
25798
+ * @static
25799
+ * @param {string} type - The geometry type.
25800
+ * @param {BufferGeometry.constructor} geometryClass - The geometry class.
25801
+ */
25802
+ static registerGeometry(type, geometryClass) {
25803
+ _customGeometries[type] = geometryClass;
25804
+ }
25690
25805
  // internals
25691
25806
  parseShapes(json) {
25692
25807
  const shapes = {};
@@ -25727,8 +25842,10 @@ var init_three_core = __esm({
25727
25842
  default:
25728
25843
  if (data.type in Geometries) {
25729
25844
  geometry = Geometries[data.type].fromJSON(data, shapes);
25845
+ } else if (data.type in _customGeometries) {
25846
+ geometry = _customGeometries[data.type].fromJSON(data, shapes);
25730
25847
  } else {
25731
- warn(`ObjectLoader: Unsupported geometry type "${data.type}"`);
25848
+ warn(`ObjectLoader: Unknown geometry type "${data.type}". Use .registerGeometry() before starting the deserialization process.`);
25732
25849
  }
25733
25850
  }
25734
25851
  geometry.uuid = data.uuid;
@@ -25929,6 +26046,7 @@ var init_three_core = __esm({
25929
26046
  if (data.premultiplyAlpha !== void 0) texture.premultiplyAlpha = data.premultiplyAlpha;
25930
26047
  if (data.unpackAlignment !== void 0) texture.unpackAlignment = data.unpackAlignment;
25931
26048
  if (data.compareFunction !== void 0) texture.compareFunction = data.compareFunction;
26049
+ if (data.normalized !== void 0) texture.normalized = data.normalized;
25932
26050
  if (data.userData !== void 0) texture.userData = data.userData;
25933
26051
  textures[data.uuid] = texture;
25934
26052
  }
@@ -26260,6 +26378,9 @@ var init_three_core = __esm({
26260
26378
  * Sets the given loader options. The structure of the object must match the `options` parameter of
26261
26379
  * [createImageBitmap](https://developer.mozilla.org/en-US/docs/Web/API/Window/createImageBitmap).
26262
26380
  *
26381
+ * Note: When caching is enabled, the cache key is based on the URL only. Loading the same URL with
26382
+ * different options will return the cached result of the first request.
26383
+ *
26263
26384
  * @param {Object} options - The loader options to set.
26264
26385
  * @return {ImageBitmapLoader} A reference to this image bitmap loader.
26265
26386
  */
@@ -26274,7 +26395,6 @@ var init_three_core = __esm({
26274
26395
  * @param {function(ImageBitmap)} onLoad - Executed when the loading process has been finished.
26275
26396
  * @param {onProgressCallback} onProgress - Unsupported in this loader.
26276
26397
  * @param {onErrorCallback} onError - Executed when errors occur.
26277
- * @return {ImageBitmap|undefined} The image bitmap.
26278
26398
  */
26279
26399
  load(url, onLoad, onProgress, onError) {
26280
26400
  if (url === void 0) url = "";
@@ -26293,7 +26413,6 @@ var init_three_core = __esm({
26293
26413
  } else {
26294
26414
  if (onLoad) onLoad(imageBitmap);
26295
26415
  scope.manager.itemEnd(url);
26296
- return imageBitmap;
26297
26416
  }
26298
26417
  });
26299
26418
  return;
@@ -26302,7 +26421,7 @@ var init_three_core = __esm({
26302
26421
  if (onLoad) onLoad(cached);
26303
26422
  scope.manager.itemEnd(url);
26304
26423
  }, 0);
26305
- return cached;
26424
+ return;
26306
26425
  }
26307
26426
  const fetchOptions = {};
26308
26427
  fetchOptions.credentials = this.crossOrigin === "anonymous" ? "same-origin" : "include";
@@ -26316,7 +26435,6 @@ var init_three_core = __esm({
26316
26435
  Cache.add(`image-bitmap:${url}`, imageBitmap);
26317
26436
  if (onLoad) onLoad(imageBitmap);
26318
26437
  scope.manager.itemEnd(url);
26319
- return imageBitmap;
26320
26438
  }).catch(function(e2) {
26321
26439
  if (onError) onError(e2);
26322
26440
  _errorMap.set(promise, e2);
@@ -26342,7 +26460,7 @@ var init_three_core = __esm({
26342
26460
  /**
26343
26461
  * Returns the global native audio context.
26344
26462
  *
26345
- * @return {AudioContext} The native audio context.
26463
+ * @return {Window.AudioContext} The native audio context.
26346
26464
  */
26347
26465
  static getContext() {
26348
26466
  if (_context === void 0) {
@@ -26353,7 +26471,7 @@ var init_three_core = __esm({
26353
26471
  /**
26354
26472
  * Allows to set the global native audio context from outside.
26355
26473
  *
26356
- * @param {AudioContext} value - The native context to set.
26474
+ * @param {Window.AudioContext} value - The native context to set.
26357
26475
  */
26358
26476
  static setContext(value) {
26359
26477
  _context = value;
@@ -26388,9 +26506,15 @@ var init_three_core = __esm({
26388
26506
  try {
26389
26507
  const bufferCopy = buffer.slice(0);
26390
26508
  const context2 = AudioContext.getContext();
26509
+ const decodeUrl = url + "#decode";
26510
+ scope.manager.itemStart(decodeUrl);
26391
26511
  context2.decodeAudioData(bufferCopy, function(audioBuffer) {
26392
26512
  onLoad(audioBuffer);
26393
- }).catch(handleError);
26513
+ scope.manager.itemEnd(decodeUrl);
26514
+ }).catch(function(e2) {
26515
+ handleError(e2);
26516
+ scope.manager.itemEnd(decodeUrl);
26517
+ });
26394
26518
  } catch (e2) {
26395
26519
  handleError(e2);
26396
26520
  }
@@ -28226,6 +28350,9 @@ var init_three_core = __esm({
28226
28350
  for (let i3 = 0; i3 !== nTracks; ++i3) {
28227
28351
  const interpolant = tracks[i3].createInterpolant(null);
28228
28352
  interpolants[i3] = interpolant;
28353
+ if (interpolant.settings) {
28354
+ Object.assign(interpolantSettings, interpolant.settings);
28355
+ }
28229
28356
  interpolant.settings = interpolantSettings;
28230
28357
  }
28231
28358
  this._interpolantSettings = interpolantSettings;
@@ -28669,6 +28796,7 @@ var init_three_core = __esm({
28669
28796
  });
28670
28797
  }
28671
28798
  } else {
28799
+ this._loopCount = loopCount;
28672
28800
  this.time = time;
28673
28801
  }
28674
28802
  if (pingPong && (loopCount & 1) === 1) {
@@ -29508,7 +29636,7 @@ var init_three_core = __esm({
29508
29636
  this.oldTime = 0;
29509
29637
  this.elapsedTime = 0;
29510
29638
  this.running = false;
29511
- warn("THREE.Clock: This module has been deprecated. Please use THREE.Timer instead.");
29639
+ warn("Clock: This module has been deprecated. Please use THREE.Timer instead.");
29512
29640
  }
29513
29641
  /**
29514
29642
  * Starts the clock. When `autoStart` is set to `true`, the method is automatically
@@ -29718,6 +29846,9 @@ var init_three_core = __esm({
29718
29846
  }
29719
29847
  };
29720
29848
  Matrix2 = class _Matrix2 {
29849
+ static {
29850
+ _Matrix2.prototype.isMatrix2 = true;
29851
+ }
29721
29852
  /**
29722
29853
  * Constructs a new 2x2 matrix. The arguments are supposed to be
29723
29854
  * in row-major order. If no arguments are provided, the constructor
@@ -29729,7 +29860,6 @@ var init_three_core = __esm({
29729
29860
  * @param {number} [n22] - 2-2 matrix element.
29730
29861
  */
29731
29862
  constructor(n11, n12, n21, n22) {
29732
- _Matrix2.prototype.isMatrix2 = true;
29733
29863
  this.elements = [
29734
29864
  1,
29735
29865
  0,
@@ -30141,6 +30271,7 @@ var init_three_core = __esm({
30141
30271
  _startP.subVectors(point, this.start);
30142
30272
  _startEnd.subVectors(this.end, this.start);
30143
30273
  const startEnd2 = _startEnd.dot(_startEnd);
30274
+ if (startEnd2 === 0) return 0;
30144
30275
  const startEnd_startP = _startEnd.dot(_startP);
30145
30276
  let t2 = startEnd_startP / startEnd2;
30146
30277
  if (clampToLine) {
@@ -31557,7 +31688,7 @@ var init_three_core = __esm({
31557
31688
  }
31558
31689
  });
31559
31690
 
31560
- // ../../node_modules/.bun/three@0.183.2/node_modules/three/build/three.module.js
31691
+ // ../../node_modules/.bun/three@0.184.0/node_modules/three/build/three.module.js
31561
31692
  var three_module_exports = {};
31562
31693
  __export(three_module_exports, {
31563
31694
  ACESFilmicToneMapping: () => ACESFilmicToneMapping,
@@ -31699,6 +31830,7 @@ __export(three_module_exports, {
31699
31830
  GreaterStencilFunc: () => GreaterStencilFunc,
31700
31831
  GridHelper: () => GridHelper,
31701
31832
  Group: () => Group,
31833
+ HTMLTexture: () => HTMLTexture,
31702
31834
  HalfFloatType: () => HalfFloatType,
31703
31835
  HemisphereLight: () => HemisphereLight,
31704
31836
  HemisphereLightHelper: () => HemisphereLightHelper,
@@ -32014,11 +32146,12 @@ function WebGLAnimation() {
32014
32146
  start: function() {
32015
32147
  if (isAnimating === true) return;
32016
32148
  if (animationLoop === null) return;
32149
+ if (context2 === null) return;
32017
32150
  requestId = context2.requestAnimationFrame(onAnimationFrame);
32018
32151
  isAnimating = true;
32019
32152
  },
32020
32153
  stop: function() {
32021
- context2.cancelAnimationFrame(requestId);
32154
+ if (context2 !== null) context2.cancelAnimationFrame(requestId);
32022
32155
  isAnimating = false;
32023
32156
  },
32024
32157
  setAnimationLoop: function(callback) {
@@ -32221,19 +32354,13 @@ function WebGLBackground(renderer, environments, state2, objects, alpha, premult
32221
32354
  });
32222
32355
  objects.update(boxMesh);
32223
32356
  }
32224
- _e1$1.copy(scene.backgroundRotation);
32225
- _e1$1.x *= -1;
32226
- _e1$1.y *= -1;
32227
- _e1$1.z *= -1;
32228
- if (background.isCubeTexture && background.isRenderTargetTexture === false) {
32229
- _e1$1.y *= -1;
32230
- _e1$1.z *= -1;
32231
- }
32232
32357
  boxMesh.material.uniforms.envMap.value = background;
32233
- boxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture && background.isRenderTargetTexture === false ? -1 : 1;
32234
32358
  boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
32235
32359
  boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
32236
- boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4(_m1$12.makeRotationFromEuler(_e1$1));
32360
+ boxMesh.material.uniforms.backgroundRotation.value.setFromMatrix4(_m1$12.makeRotationFromEuler(scene.backgroundRotation)).transpose();
32361
+ if (background.isCubeTexture && background.isRenderTargetTexture === false) {
32362
+ boxMesh.material.uniforms.backgroundRotation.value.premultiply(_m$1);
32363
+ }
32237
32364
  boxMesh.material.toneMapped = ColorManagement.getTransfer(background.colorSpace) !== SRGBTransfer;
32238
32365
  if (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {
32239
32366
  boxMesh.material.needsUpdate = true;
@@ -32709,27 +32836,10 @@ function WebGLBufferRenderer(gl, extensions2, info) {
32709
32836
  }
32710
32837
  info.update(elementCount, mode, 1);
32711
32838
  }
32712
- function renderMultiDrawInstances(starts, counts, drawCount, primcount) {
32713
- if (drawCount === 0) return;
32714
- const extension = extensions2.get("WEBGL_multi_draw");
32715
- if (extension === null) {
32716
- for (let i3 = 0; i3 < starts.length; i3++) {
32717
- renderInstances(starts[i3], counts[i3], primcount[i3]);
32718
- }
32719
- } else {
32720
- extension.multiDrawArraysInstancedWEBGL(mode, starts, 0, counts, 0, primcount, 0, drawCount);
32721
- let elementCount = 0;
32722
- for (let i3 = 0; i3 < drawCount; i3++) {
32723
- elementCount += counts[i3] * primcount[i3];
32724
- }
32725
- info.update(elementCount, mode, 1);
32726
- }
32727
- }
32728
32839
  this.setMode = setMode;
32729
32840
  this.render = render;
32730
32841
  this.renderInstances = renderInstances;
32731
32842
  this.renderMultiDraw = renderMultiDraw;
32732
- this.renderMultiDrawInstances = renderMultiDrawInstances;
32733
32843
  }
32734
32844
  function WebGLCapabilities(gl, extensions2, parameters, utils) {
32735
32845
  let maxAnisotropy;
@@ -32779,6 +32889,9 @@ function WebGLCapabilities(gl, extensions2, parameters, utils) {
32779
32889
  }
32780
32890
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
32781
32891
  const reversedDepthBuffer = parameters.reversedDepthBuffer === true && extensions2.has("EXT_clip_control");
32892
+ if (parameters.reversedDepthBuffer === true && reversedDepthBuffer === false) {
32893
+ warn("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");
32894
+ }
32782
32895
  const maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
32783
32896
  const maxVertexTextures = gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
32784
32897
  const maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
@@ -33584,28 +33697,11 @@ function WebGLIndexedBufferRenderer(gl, extensions2, info) {
33584
33697
  }
33585
33698
  info.update(elementCount, mode, 1);
33586
33699
  }
33587
- function renderMultiDrawInstances(starts, counts, drawCount, primcount) {
33588
- if (drawCount === 0) return;
33589
- const extension = extensions2.get("WEBGL_multi_draw");
33590
- if (extension === null) {
33591
- for (let i3 = 0; i3 < starts.length; i3++) {
33592
- renderInstances(starts[i3] / bytesPerElement, counts[i3], primcount[i3]);
33593
- }
33594
- } else {
33595
- extension.multiDrawElementsInstancedWEBGL(mode, counts, 0, type, starts, 0, primcount, 0, drawCount);
33596
- let elementCount = 0;
33597
- for (let i3 = 0; i3 < drawCount; i3++) {
33598
- elementCount += counts[i3] * primcount[i3];
33599
- }
33600
- info.update(elementCount, mode, 1);
33601
- }
33602
- }
33603
33700
  this.setMode = setMode;
33604
33701
  this.setIndex = setIndex;
33605
33702
  this.render = render;
33606
33703
  this.renderInstances = renderInstances;
33607
33704
  this.renderMultiDraw = renderMultiDraw;
33608
- this.renderMultiDrawInstances = renderMultiDrawInstances;
33609
33705
  }
33610
33706
  function WebGLInfo(gl) {
33611
33707
  const memory = {
@@ -33799,7 +33895,8 @@ function WebGLOutput(type, width, height, depth, stencil) {
33799
33895
  const targetA = new WebGLRenderTarget(width, height, {
33800
33896
  type,
33801
33897
  depthBuffer: depth,
33802
- stencilBuffer: stencil
33898
+ stencilBuffer: stencil,
33899
+ depthTexture: depth ? new DepthTexture(width, height) : void 0
33803
33900
  });
33804
33901
  const targetB = new WebGLRenderTarget(width, height, {
33805
33902
  type: HalfFloatType,
@@ -33952,6 +34049,7 @@ function WebGLOutput(type, width, height, depth, stencil) {
33952
34049
  return _isCompositing;
33953
34050
  };
33954
34051
  this.dispose = function() {
34052
+ if (targetA.depthTexture) targetA.depthTexture.dispose();
33955
34053
  targetA.dispose();
33956
34054
  targetB.dispose();
33957
34055
  geometry.dispose();
@@ -34839,6 +34937,7 @@ function WebGLProgram(renderer, cacheKey, parameters, bindingStates) {
34839
34937
  parameters.thicknessMapUv ? "#define THICKNESSMAP_UV " + parameters.thicknessMapUv : "",
34840
34938
  //
34841
34939
  parameters.vertexTangents && parameters.flatShading === false ? "#define USE_TANGENT" : "",
34940
+ parameters.vertexNormals ? "#define HAS_NORMAL" : "",
34842
34941
  parameters.vertexColors ? "#define USE_COLOR" : "",
34843
34942
  parameters.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
34844
34943
  parameters.vertexUv1s ? "#define USE_UV1" : "",
@@ -34925,6 +35024,7 @@ function WebGLProgram(renderer, cacheKey, parameters, bindingStates) {
34925
35024
  parameters.normalMap ? "#define USE_NORMALMAP" : "",
34926
35025
  parameters.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
34927
35026
  parameters.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
35027
+ parameters.packedNormalMap ? "#define USE_PACKED_NORMALMAP" : "",
34928
35028
  parameters.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
34929
35029
  parameters.anisotropy ? "#define USE_ANISOTROPY" : "",
34930
35030
  parameters.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
@@ -34965,6 +35065,7 @@ function WebGLProgram(renderer, cacheKey, parameters, bindingStates) {
34965
35065
  parameters.shadowMapEnabled ? "#define " + shadowMapTypeDefine : "",
34966
35066
  parameters.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
34967
35067
  parameters.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
35068
+ parameters.numLightProbeGrids > 0 ? "#define USE_LIGHT_PROBES_GRID" : "",
34968
35069
  parameters.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",
34969
35070
  parameters.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "",
34970
35071
  parameters.logarithmicDepthBuffer ? "#define USE_LOGARITHMIC_DEPTH_BUFFER" : "",
@@ -35112,6 +35213,9 @@ function WebGLProgram(renderer, cacheKey, parameters, bindingStates) {
35112
35213
  this.fragmentShader = glFragmentShader;
35113
35214
  return this;
35114
35215
  }
35216
+ function isPackedRGFormat(format) {
35217
+ return format === RGFormat || format === RG11_EAC_Format || format === RED_GREEN_RGTC2_Format;
35218
+ }
35115
35219
  function WebGLPrograms(renderer, environments, extensions2, capabilities, bindingStates, clipping) {
35116
35220
  const _programLayers = new Layers();
35117
35221
  const _customShaders = new WebGLShaderCache();
@@ -35142,7 +35246,7 @@ function WebGLPrograms(renderer, environments, extensions2, capabilities, bindin
35142
35246
  if (value === 0) return "uv";
35143
35247
  return `uv${value}`;
35144
35248
  }
35145
- function getParameters(material, lights, shadows, scene, object) {
35249
+ function getParameters(material, lights, shadows, scene, object, lightProbeGrids) {
35146
35250
  const fog = scene.fog;
35147
35251
  const geometry = object.geometry;
35148
35252
  const environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
@@ -35237,7 +35341,7 @@ function WebGLPrograms(renderer, environments, extensions2, capabilities, bindin
35237
35341
  instancing: IS_INSTANCEDMESH,
35238
35342
  instancingColor: IS_INSTANCEDMESH && object.instanceColor !== null,
35239
35343
  instancingMorph: IS_INSTANCEDMESH && object.morphTexture !== null,
35240
- outputColorSpace: currentRenderTarget === null ? renderer.outputColorSpace : currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace,
35344
+ outputColorSpace: currentRenderTarget === null ? renderer.outputColorSpace : currentRenderTarget.isXRRenderTarget === true ? currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace,
35241
35345
  alphaToCoverage: !!material.alphaToCoverage,
35242
35346
  map: HAS_MAP,
35243
35347
  matcap: HAS_MATCAP,
@@ -35252,6 +35356,7 @@ function WebGLPrograms(renderer, environments, extensions2, capabilities, bindin
35252
35356
  emissiveMap: HAS_EMISSIVEMAP,
35253
35357
  normalMapObjectSpace: HAS_NORMALMAP && material.normalMapType === ObjectSpaceNormalMap,
35254
35358
  normalMapTangentSpace: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap,
35359
+ packedNormalMap: HAS_NORMALMAP && material.normalMapType === TangentSpaceNormalMap && isPackedRGFormat(material.normalMap.format),
35255
35360
  metalnessMap: HAS_METALNESSMAP,
35256
35361
  roughnessMap: HAS_ROUGHNESSMAP,
35257
35362
  anisotropy: HAS_ANISOTROPY,
@@ -35305,6 +35410,7 @@ function WebGLPrograms(renderer, environments, extensions2, capabilities, bindin
35305
35410
  alphaMapUv: HAS_ALPHAMAP && getChannel2(material.alphaMap.channel),
35306
35411
  //
35307
35412
  vertexTangents: !!geometry.attributes.tangent && (HAS_NORMALMAP || HAS_ANISOTROPY),
35413
+ vertexNormals: !!geometry.attributes.normal,
35308
35414
  vertexColors: material.vertexColors,
35309
35415
  vertexAlphas: material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4,
35310
35416
  pointsUvs: object.isPoints === true && !!geometry.attributes.uv && (HAS_MAP || HAS_ALPHAMAP),
@@ -35332,6 +35438,7 @@ function WebGLPrograms(renderer, environments, extensions2, capabilities, bindin
35332
35438
  numSpotLightShadows: lights.spotShadowMap.length,
35333
35439
  numSpotLightShadowsWithMaps: lights.numSpotLightShadowsWithMaps,
35334
35440
  numLightProbes: lights.numLightProbes,
35441
+ numLightProbeGrids: lightProbeGrids.length,
35335
35442
  numClippingPlanes: clipping.numPlanes,
35336
35443
  numClipIntersection: clipping.numIntersection,
35337
35444
  dithering: material.dithering,
@@ -35475,6 +35582,10 @@ function WebGLPrograms(renderer, environments, extensions2, capabilities, bindin
35475
35582
  _programLayers.enable(20);
35476
35583
  if (parameters.gradientMap)
35477
35584
  _programLayers.enable(21);
35585
+ if (parameters.packedNormalMap)
35586
+ _programLayers.enable(22);
35587
+ if (parameters.vertexNormals)
35588
+ _programLayers.enable(23);
35478
35589
  array.push(_programLayers.mask);
35479
35590
  _programLayers.disableAll();
35480
35591
  if (parameters.fog)
@@ -35521,6 +35632,8 @@ function WebGLPrograms(renderer, environments, extensions2, capabilities, bindin
35521
35632
  _programLayers.enable(20);
35522
35633
  if (parameters.alphaToCoverage)
35523
35634
  _programLayers.enable(21);
35635
+ if (parameters.numLightProbeGrids > 0)
35636
+ _programLayers.enable(22);
35524
35637
  array.push(_programLayers.mask);
35525
35638
  }
35526
35639
  function getUniforms(material) {
@@ -36119,10 +36232,12 @@ function WebGLRenderState(extensions2) {
36119
36232
  const lights = new WebGLLights(extensions2);
36120
36233
  const lightsArray = [];
36121
36234
  const shadowsArray = [];
36235
+ const lightProbeGridArray = [];
36122
36236
  function init(camera) {
36123
36237
  state2.camera = camera;
36124
36238
  lightsArray.length = 0;
36125
36239
  shadowsArray.length = 0;
36240
+ lightProbeGridArray.length = 0;
36126
36241
  }
36127
36242
  function pushLight(light) {
36128
36243
  lightsArray.push(light);
@@ -36130,6 +36245,9 @@ function WebGLRenderState(extensions2) {
36130
36245
  function pushShadow(shadowLight) {
36131
36246
  shadowsArray.push(shadowLight);
36132
36247
  }
36248
+ function pushLightProbeGrid(volume) {
36249
+ lightProbeGridArray.push(volume);
36250
+ }
36133
36251
  function setupLights() {
36134
36252
  lights.setup(lightsArray);
36135
36253
  }
@@ -36139,9 +36257,11 @@ function WebGLRenderState(extensions2) {
36139
36257
  const state2 = {
36140
36258
  lightsArray,
36141
36259
  shadowsArray,
36260
+ lightProbeGridArray,
36142
36261
  camera: null,
36143
36262
  lights,
36144
- transmissionRenderTarget: {}
36263
+ transmissionRenderTarget: {},
36264
+ textureUnits: 0
36145
36265
  };
36146
36266
  return {
36147
36267
  init,
@@ -36149,7 +36269,8 @@ function WebGLRenderState(extensions2) {
36149
36269
  setupLights,
36150
36270
  setupLightsView,
36151
36271
  pushLight,
36152
- pushShadow
36272
+ pushShadow,
36273
+ pushLightProbeGrid
36153
36274
  };
36154
36275
  }
36155
36276
  function WebGLRenderStates(extensions2) {
@@ -36688,6 +36809,7 @@ function WebGLState(gl, extensions2) {
36688
36809
  const uboBindings = /* @__PURE__ */ new WeakMap();
36689
36810
  const uboProgramMap = /* @__PURE__ */ new WeakMap();
36690
36811
  let enabledCapabilities = {};
36812
+ let parameters = {};
36691
36813
  let currentBoundFramebuffers = {};
36692
36814
  let currentDrawbuffers = /* @__PURE__ */ new WeakMap();
36693
36815
  let defaultDrawbuffers = [];
@@ -37112,6 +37234,19 @@ function WebGLState(gl, extensions2) {
37112
37234
  error("WebGLState:", e2);
37113
37235
  }
37114
37236
  }
37237
+ function getParameter(name) {
37238
+ if (parameters[name] !== void 0) {
37239
+ return parameters[name];
37240
+ } else {
37241
+ return gl.getParameter(name);
37242
+ }
37243
+ }
37244
+ function pixelStorei(name, value) {
37245
+ if (parameters[name] !== value) {
37246
+ gl.pixelStorei(name, value);
37247
+ parameters[name] = value;
37248
+ }
37249
+ }
37115
37250
  function scissor(scissor2) {
37116
37251
  if (currentScissor.equals(scissor2) === false) {
37117
37252
  gl.scissor(scissor2.x, scissor2.y, scissor2.z, scissor2.w);
@@ -37177,7 +37312,21 @@ function WebGLState(gl, extensions2) {
37177
37312
  gl.lineWidth(1);
37178
37313
  gl.scissor(0, 0, gl.canvas.width, gl.canvas.height);
37179
37314
  gl.viewport(0, 0, gl.canvas.width, gl.canvas.height);
37315
+ gl.pixelStorei(gl.PACK_ALIGNMENT, 4);
37316
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
37317
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
37318
+ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
37319
+ gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.BROWSER_DEFAULT_WEBGL);
37320
+ gl.pixelStorei(gl.PACK_ROW_LENGTH, 0);
37321
+ gl.pixelStorei(gl.PACK_SKIP_PIXELS, 0);
37322
+ gl.pixelStorei(gl.PACK_SKIP_ROWS, 0);
37323
+ gl.pixelStorei(gl.UNPACK_ROW_LENGTH, 0);
37324
+ gl.pixelStorei(gl.UNPACK_IMAGE_HEIGHT, 0);
37325
+ gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, 0);
37326
+ gl.pixelStorei(gl.UNPACK_SKIP_ROWS, 0);
37327
+ gl.pixelStorei(gl.UNPACK_SKIP_IMAGES, 0);
37180
37328
  enabledCapabilities = {};
37329
+ parameters = {};
37181
37330
  currentTextureSlot = null;
37182
37331
  currentBoundTextures = {};
37183
37332
  currentBoundFramebuffers = {};
@@ -37231,6 +37380,8 @@ function WebGLState(gl, extensions2) {
37231
37380
  compressedTexImage3D,
37232
37381
  texImage2D,
37233
37382
  texImage3D,
37383
+ pixelStorei,
37384
+ getParameter,
37234
37385
  updateUBOMapping,
37235
37386
  uniformBlockBinding,
37236
37387
  texStorage2D,
@@ -37249,6 +37400,7 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37249
37400
  const supportsInvalidateFramebuffer = typeof navigator === "undefined" ? false : /OculusBrowser/g.test(navigator.userAgent);
37250
37401
  const _imageDimensions = new Vector2();
37251
37402
  const _videoTextures = /* @__PURE__ */ new WeakMap();
37403
+ const _htmlTextures = /* @__PURE__ */ new Set();
37252
37404
  let _canvas2;
37253
37405
  const _sources = /* @__PURE__ */ new WeakMap();
37254
37406
  let useOffscreenCanvas = false;
@@ -37298,16 +37450,25 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37298
37450
  if (texture.isWebGLArrayRenderTarget || texture.isCompressedArrayTexture) return _gl.TEXTURE_2D_ARRAY;
37299
37451
  return _gl.TEXTURE_2D;
37300
37452
  }
37301
- function getInternalFormat(internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false) {
37453
+ function getInternalFormat(internalFormatName, glFormat, glType, normalized, colorSpace, forceLinearTransfer = false) {
37302
37454
  if (internalFormatName !== null) {
37303
37455
  if (_gl[internalFormatName] !== void 0) return _gl[internalFormatName];
37304
37456
  warn("WebGLRenderer: Attempt to use non-existing WebGL internal format '" + internalFormatName + "'");
37305
37457
  }
37458
+ let ext_texture_norm16;
37459
+ if (normalized) {
37460
+ ext_texture_norm16 = extensions2.get("EXT_texture_norm16");
37461
+ if (!ext_texture_norm16) {
37462
+ warn("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension");
37463
+ }
37464
+ }
37306
37465
  let internalFormat = glFormat;
37307
37466
  if (glFormat === _gl.RED) {
37308
37467
  if (glType === _gl.FLOAT) internalFormat = _gl.R32F;
37309
37468
  if (glType === _gl.HALF_FLOAT) internalFormat = _gl.R16F;
37310
37469
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8;
37470
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.R16_EXT;
37471
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.R16_SNORM_EXT;
37311
37472
  }
37312
37473
  if (glFormat === _gl.RED_INTEGER) {
37313
37474
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.R8UI;
@@ -37321,6 +37482,8 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37321
37482
  if (glType === _gl.FLOAT) internalFormat = _gl.RG32F;
37322
37483
  if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RG16F;
37323
37484
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8;
37485
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RG16_EXT;
37486
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RG16_SNORM_EXT;
37324
37487
  }
37325
37488
  if (glFormat === _gl.RG_INTEGER) {
37326
37489
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = _gl.RG8UI;
@@ -37347,6 +37510,8 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37347
37510
  if (glType === _gl.INT) internalFormat = _gl.RGBA32I;
37348
37511
  }
37349
37512
  if (glFormat === _gl.RGB) {
37513
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGB16_EXT;
37514
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGB16_SNORM_EXT;
37350
37515
  if (glType === _gl.UNSIGNED_INT_5_9_9_9_REV) internalFormat = _gl.RGB9_E5;
37351
37516
  if (glType === _gl.UNSIGNED_INT_10F_11F_11F_REV) internalFormat = _gl.R11F_G11F_B10F;
37352
37517
  }
@@ -37355,6 +37520,8 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37355
37520
  if (glType === _gl.FLOAT) internalFormat = _gl.RGBA32F;
37356
37521
  if (glType === _gl.HALF_FLOAT) internalFormat = _gl.RGBA16F;
37357
37522
  if (glType === _gl.UNSIGNED_BYTE) internalFormat = transfer === SRGBTransfer ? _gl.SRGB8_ALPHA8 : _gl.RGBA8;
37523
+ if (glType === _gl.UNSIGNED_SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGBA16_EXT;
37524
+ if (glType === _gl.SHORT && ext_texture_norm16) internalFormat = ext_texture_norm16.RGBA16_SNORM_EXT;
37358
37525
  if (glType === _gl.UNSIGNED_SHORT_4_4_4_4) internalFormat = _gl.RGBA4;
37359
37526
  if (glType === _gl.UNSIGNED_SHORT_5_5_5_1) internalFormat = _gl.RGB5_A1;
37360
37527
  }
@@ -37403,6 +37570,9 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37403
37570
  if (texture.isVideoTexture) {
37404
37571
  _videoTextures.delete(texture);
37405
37572
  }
37573
+ if (texture.isHTMLTexture) {
37574
+ _htmlTextures.delete(texture);
37575
+ }
37406
37576
  }
37407
37577
  function onRenderTargetDispose(event) {
37408
37578
  const renderTarget2 = event.target;
@@ -37479,6 +37649,12 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37479
37649
  function resetTextureUnits() {
37480
37650
  textureUnits = 0;
37481
37651
  }
37652
+ function getTextureUnits() {
37653
+ return textureUnits;
37654
+ }
37655
+ function setTextureUnits(value) {
37656
+ textureUnits = value;
37657
+ }
37482
37658
  function allocateTextureUnit() {
37483
37659
  const textureUnit = textureUnits;
37484
37660
  if (textureUnit >= capabilities.maxTextures) {
@@ -37661,10 +37837,10 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37661
37837
  }
37662
37838
  }
37663
37839
  updateRanges.length = mergeIndex + 1;
37664
- const currentUnpackRowLen = _gl.getParameter(_gl.UNPACK_ROW_LENGTH);
37665
- const currentUnpackSkipPixels = _gl.getParameter(_gl.UNPACK_SKIP_PIXELS);
37666
- const currentUnpackSkipRows = _gl.getParameter(_gl.UNPACK_SKIP_ROWS);
37667
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
37840
+ const currentUnpackRowLen = state2.getParameter(_gl.UNPACK_ROW_LENGTH);
37841
+ const currentUnpackSkipPixels = state2.getParameter(_gl.UNPACK_SKIP_PIXELS);
37842
+ const currentUnpackSkipRows = state2.getParameter(_gl.UNPACK_SKIP_ROWS);
37843
+ state2.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
37668
37844
  for (let i3 = 0, l2 = updateRanges.length; i3 < l2; i3++) {
37669
37845
  const range = updateRanges[i3];
37670
37846
  const pixelStart = Math.floor(range.start / componentStride);
@@ -37673,14 +37849,14 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37673
37849
  const y = Math.floor(pixelStart / image.width);
37674
37850
  const width = pixelCount;
37675
37851
  const height = 1;
37676
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, x2);
37677
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, y);
37852
+ state2.pixelStorei(_gl.UNPACK_SKIP_PIXELS, x2);
37853
+ state2.pixelStorei(_gl.UNPACK_SKIP_ROWS, y);
37678
37854
  state2.texSubImage2D(_gl.TEXTURE_2D, 0, x2, y, width, height, glFormat, glType, image.data);
37679
37855
  }
37680
37856
  texture.clearUpdateRanges();
37681
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
37682
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
37683
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
37857
+ state2.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
37858
+ state2.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
37859
+ state2.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
37684
37860
  }
37685
37861
  }
37686
37862
  function uploadTexture(textureProperties, texture, slot) {
@@ -37693,18 +37869,21 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37693
37869
  const sourceProperties = properties.get(source);
37694
37870
  if (source.version !== sourceProperties.__version || forceUpload === true) {
37695
37871
  state2.activeTexture(_gl.TEXTURE0 + slot);
37696
- const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
37697
- const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
37698
- const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
37699
- _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
37700
- _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
37701
- _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
37702
- _gl.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
37872
+ const isImageBitmap = typeof ImageBitmap !== "undefined" && texture.image instanceof ImageBitmap;
37873
+ if (isImageBitmap === false) {
37874
+ const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
37875
+ const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
37876
+ const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
37877
+ state2.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
37878
+ state2.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
37879
+ state2.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
37880
+ }
37881
+ state2.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
37703
37882
  let image = resizeImage(texture.image, false, capabilities.maxTextureSize);
37704
37883
  image = verifyColorSpace(texture, image);
37705
37884
  const glFormat = utils.convert(texture.format, texture.colorSpace);
37706
37885
  const glType = utils.convert(texture.type);
37707
- let glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace, texture.isVideoTexture);
37886
+ let glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace, texture.isVideoTexture);
37708
37887
  setTextureParameters(textureType, texture);
37709
37888
  let mipmap;
37710
37889
  const mipmaps = texture.mipmaps;
@@ -37866,6 +38045,35 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37866
38045
  }
37867
38046
  }
37868
38047
  }
38048
+ } else if (texture.isHTMLTexture) {
38049
+ if ("texElementImage2D" in _gl) {
38050
+ const canvas = _gl.canvas;
38051
+ if (!canvas.hasAttribute("layoutsubtree")) {
38052
+ canvas.setAttribute("layoutsubtree", "true");
38053
+ }
38054
+ if (image.parentNode !== canvas) {
38055
+ canvas.appendChild(image);
38056
+ _htmlTextures.add(texture);
38057
+ canvas.onpaint = (event) => {
38058
+ const changed = event.changedElements;
38059
+ for (const t2 of _htmlTextures) {
38060
+ if (changed.includes(t2.image)) {
38061
+ t2.needsUpdate = true;
38062
+ }
38063
+ }
38064
+ };
38065
+ canvas.requestPaint();
38066
+ return;
38067
+ }
38068
+ const level = 0;
38069
+ const internalFormat = _gl.RGBA;
38070
+ const srcFormat = _gl.RGBA;
38071
+ const srcType = _gl.UNSIGNED_BYTE;
38072
+ _gl.texElementImage2D(_gl.TEXTURE_2D, level, internalFormat, srcFormat, srcType, image);
38073
+ _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR);
38074
+ _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE);
38075
+ _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE);
38076
+ }
37869
38077
  } else {
37870
38078
  if (mipmaps.length > 0) {
37871
38079
  if (useTexStorage && allocateMemory) {
@@ -37916,10 +38124,10 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37916
38124
  const workingPrimaries = ColorManagement.getPrimaries(ColorManagement.workingColorSpace);
37917
38125
  const texturePrimaries = texture.colorSpace === NoColorSpace ? null : ColorManagement.getPrimaries(texture.colorSpace);
37918
38126
  const unpackConversion = texture.colorSpace === NoColorSpace || workingPrimaries === texturePrimaries ? _gl.NONE : _gl.BROWSER_DEFAULT_WEBGL;
37919
- _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
37920
- _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
37921
- _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
37922
- _gl.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
38127
+ state2.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, texture.flipY);
38128
+ state2.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha);
38129
+ state2.pixelStorei(_gl.UNPACK_ALIGNMENT, texture.unpackAlignment);
38130
+ state2.pixelStorei(_gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion);
37923
38131
  const isCompressed = texture.isCompressedTexture || texture.image[0].isCompressedTexture;
37924
38132
  const isDataTexture = texture.image[0] && texture.image[0].isDataTexture;
37925
38133
  const cubeImage = [];
@@ -37931,7 +38139,7 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
37931
38139
  }
37932
38140
  cubeImage[i3] = verifyColorSpace(texture, cubeImage[i3]);
37933
38141
  }
37934
- const image = cubeImage[0], glFormat = utils.convert(texture.format, texture.colorSpace), glType = utils.convert(texture.type), glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
38142
+ 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);
37935
38143
  const useTexStorage = texture.isVideoTexture !== true;
37936
38144
  const allocateMemory = sourceProperties.__version === void 0 || forceUpload === true;
37937
38145
  const dataReady = source.dataReady;
@@ -38028,7 +38236,7 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
38028
38236
  function setupFrameBufferTexture(framebuffer, renderTarget2, texture, attachment, textureTarget, level) {
38029
38237
  const glFormat = utils.convert(texture.format, texture.colorSpace);
38030
38238
  const glType = utils.convert(texture.type);
38031
- const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
38239
+ const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
38032
38240
  const renderTargetProperties = properties.get(renderTarget2);
38033
38241
  const textureProperties = properties.get(texture);
38034
38242
  textureProperties.__renderTarget = renderTarget2;
@@ -38070,7 +38278,7 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
38070
38278
  const texture = textures[i3];
38071
38279
  const glFormat = utils.convert(texture.format, texture.colorSpace);
38072
38280
  const glType = utils.convert(texture.type);
38073
- const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.colorSpace);
38281
+ const glInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType, texture.normalized, texture.colorSpace);
38074
38282
  if (useMultisampledRTT(renderTarget2)) {
38075
38283
  multisampledRTTExt.renderbufferStorageMultisampleEXT(_gl.RENDERBUFFER, getRenderTargetSamples(renderTarget2), glInternalFormat, renderTarget2.width, renderTarget2.height);
38076
38284
  } else if (useMultisample) {
@@ -38270,7 +38478,7 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
38270
38478
  _gl.bindRenderbuffer(_gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i3]);
38271
38479
  const glFormat = utils.convert(texture2.format, texture2.colorSpace);
38272
38480
  const glType = utils.convert(texture2.type);
38273
- const glInternalFormat = getInternalFormat(texture2.internalFormat, glFormat, glType, texture2.colorSpace, renderTarget2.isXRRenderTarget === true);
38481
+ const glInternalFormat = getInternalFormat(texture2.internalFormat, glFormat, glType, texture2.normalized, texture2.colorSpace, renderTarget2.isXRRenderTarget === true);
38274
38482
  const samples = getRenderTargetSamples(renderTarget2);
38275
38483
  _gl.renderbufferStorageMultisample(_gl.RENDERBUFFER, samples, glInternalFormat, renderTarget2.width, renderTarget2.height);
38276
38484
  _gl.framebufferRenderbuffer(_gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i3, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer[i3]);
@@ -38466,6 +38674,8 @@ function WebGLTextures(_gl, extensions2, state2, properties, capabilities, utils
38466
38674
  }
38467
38675
  this.allocateTextureUnit = allocateTextureUnit;
38468
38676
  this.resetTextureUnits = resetTextureUnits;
38677
+ this.getTextureUnits = getTextureUnits;
38678
+ this.setTextureUnits = setTextureUnits;
38469
38679
  this.setTexture2D = setTexture2D;
38470
38680
  this.setTexture2DArray = setTexture2DArray;
38471
38681
  this.setTexture3D = setTexture3D;
@@ -38618,7 +38828,9 @@ function WebGLMaterials(renderer, properties) {
38618
38828
  }
38619
38829
  }
38620
38830
  function refreshMaterialUniforms(uniforms, material, pixelRatio, height, transmissionRenderTarget) {
38621
- if (material.isMeshBasicMaterial) {
38831
+ if (material.isNodeMaterial) {
38832
+ material.uniformsNeedUpdate = false;
38833
+ } else if (material.isMeshBasicMaterial) {
38622
38834
  refreshUniformsCommon(uniforms, material);
38623
38835
  } else if (material.isMeshLambertMaterial) {
38624
38836
  refreshUniformsCommon(uniforms, material);
@@ -38720,16 +38932,10 @@ function WebGLMaterials(renderer, properties) {
38720
38932
  const envMapRotation = materialProperties.envMapRotation;
38721
38933
  if (envMap) {
38722
38934
  uniforms.envMap.value = envMap;
38723
- _e1.copy(envMapRotation);
38724
- _e1.x *= -1;
38725
- _e1.y *= -1;
38726
- _e1.z *= -1;
38935
+ uniforms.envMapRotation.value.setFromMatrix4(_m12.makeRotationFromEuler(envMapRotation)).transpose();
38727
38936
  if (envMap.isCubeTexture && envMap.isRenderTargetTexture === false) {
38728
- _e1.y *= -1;
38729
- _e1.z *= -1;
38937
+ uniforms.envMapRotation.value.premultiply(_m);
38730
38938
  }
38731
- uniforms.envMapRotation.value.setFromMatrix4(_m12.makeRotationFromEuler(_e1));
38732
- uniforms.flipEnvMap.value = envMap.isCubeTexture && envMap.isRenderTargetTexture === false ? -1 : 1;
38733
38939
  uniforms.reflectivity.value = material.reflectivity;
38734
38940
  uniforms.ior.value = material.ior;
38735
38941
  uniforms.refractionRatio.value = material.refractionRatio;
@@ -38995,6 +39201,8 @@ function WebGLUniformsGroups(gl, info, capabilities, state2) {
38995
39201
  uniform.__data[9] = value.elements[7];
38996
39202
  uniform.__data[10] = value.elements[8];
38997
39203
  uniform.__data[11] = 0;
39204
+ } else if (ArrayBuffer.isView(value)) {
39205
+ uniform.__data.set(new value.constructor(value.buffer, value.byteOffset, uniform.__data.length));
38998
39206
  } else {
38999
39207
  value.toArray(uniform.__data, arrayOffset);
39000
39208
  arrayOffset += info2.storage / Float32Array.BYTES_PER_ELEMENT;
@@ -39012,6 +39220,8 @@ function WebGLUniformsGroups(gl, info, capabilities, state2) {
39012
39220
  if (cache[indexString] === void 0) {
39013
39221
  if (typeof value === "number" || typeof value === "boolean") {
39014
39222
  cache[indexString] = value;
39223
+ } else if (ArrayBuffer.isView(value)) {
39224
+ cache[indexString] = value.slice();
39015
39225
  } else {
39016
39226
  cache[indexString] = value.clone();
39017
39227
  }
@@ -39023,6 +39233,8 @@ function WebGLUniformsGroups(gl, info, capabilities, state2) {
39023
39233
  cache[indexString] = value;
39024
39234
  return true;
39025
39235
  }
39236
+ } else if (ArrayBuffer.isView(value)) {
39237
+ return true;
39026
39238
  } else {
39027
39239
  if (cachedObject.equals(value) === false) {
39028
39240
  cachedObject.copy(value);
@@ -39090,6 +39302,9 @@ function WebGLUniformsGroups(gl, info, capabilities, state2) {
39090
39302
  info2.storage = 64;
39091
39303
  } else if (value.isTexture) {
39092
39304
  warn("WebGLRenderer: Texture samplers can not be part of an uniforms group.");
39305
+ } else if (ArrayBuffer.isView(value)) {
39306
+ info2.boundary = 16;
39307
+ info2.storage = value.byteLength;
39093
39308
  } else {
39094
39309
  warn("WebGLRenderer: Unsupported uniform value type.", value);
39095
39310
  }
@@ -39131,9 +39346,9 @@ function getDFGLUT() {
39131
39346
  }
39132
39347
  return lut;
39133
39348
  }
39134
- var alphahash_fragment, alphahash_pars_fragment, alphamap_fragment, alphamap_pars_fragment, alphatest_fragment, alphatest_pars_fragment, aomap_fragment, aomap_pars_fragment, batching_pars_vertex, batching_vertex, begin_vertex, beginnormal_vertex, bsdfs, iridescence_fragment, bumpmap_pars_fragment, clipping_planes_fragment, clipping_planes_pars_fragment, clipping_planes_pars_vertex, clipping_planes_vertex, color_fragment, color_pars_fragment, color_pars_vertex, color_vertex, common, cube_uv_reflection_fragment, defaultnormal_vertex, displacementmap_pars_vertex, displacementmap_vertex, emissivemap_fragment, emissivemap_pars_fragment, colorspace_fragment, colorspace_pars_fragment, envmap_fragment, envmap_common_pars_fragment, envmap_pars_fragment, envmap_pars_vertex, envmap_vertex, fog_vertex, fog_pars_vertex, fog_fragment, fog_pars_fragment, gradientmap_pars_fragment, lightmap_pars_fragment, lights_lambert_fragment, lights_lambert_pars_fragment, lights_pars_begin, envmap_physical_pars_fragment, lights_toon_fragment, lights_toon_pars_fragment, lights_phong_fragment, lights_phong_pars_fragment, lights_physical_fragment, lights_physical_pars_fragment, lights_fragment_begin, lights_fragment_maps, lights_fragment_end, logdepthbuf_fragment, logdepthbuf_pars_fragment, logdepthbuf_pars_vertex, logdepthbuf_vertex, map_fragment, map_pars_fragment, map_particle_fragment, map_particle_pars_fragment, metalnessmap_fragment, metalnessmap_pars_fragment, morphinstance_vertex, morphcolor_vertex, morphnormal_vertex, morphtarget_pars_vertex, morphtarget_vertex, normal_fragment_begin, normal_fragment_maps, normal_pars_fragment, normal_pars_vertex, normal_vertex, normalmap_pars_fragment, clearcoat_normal_fragment_begin, clearcoat_normal_fragment_maps, clearcoat_pars_fragment, iridescence_pars_fragment, opaque_fragment, packing, premultiplied_alpha_fragment, project_vertex, dithering_fragment, dithering_pars_fragment, roughnessmap_fragment, roughnessmap_pars_fragment, shadowmap_pars_fragment, shadowmap_pars_vertex, shadowmap_vertex, shadowmask_pars_fragment, skinbase_vertex, skinning_pars_vertex, skinning_vertex, skinnormal_vertex, specularmap_fragment, specularmap_pars_fragment, tonemapping_fragment, tonemapping_pars_fragment, transmission_fragment, transmission_pars_fragment, uv_pars_fragment, uv_pars_vertex, uv_vertex, worldpos_vertex, vertex$h, fragment$h, vertex$g, fragment$g, vertex$f, fragment$f, vertex$e, fragment$e, vertex$d, fragment$d, vertex$c, fragment$c, vertex$b, fragment$b, vertex$a, fragment$a, vertex$9, fragment$9, vertex$8, fragment$8, vertex$7, fragment$7, vertex$6, fragment$6, vertex$5, fragment$5, vertex$4, fragment$4, vertex$3, fragment$3, vertex$2, fragment$2, vertex$1, fragment$1, ShaderChunk, UniformsLib, ShaderLib, _rgb, _e1$1, _m1$12, LOD_MIN, EXTRA_LOD_SIGMA, MAX_SAMPLES, GGX_SAMPLES, _flatCamera, _clearColor, _oldTarget, _oldActiveCubeFace, _oldActiveMipmapLevel, _oldXrEnabled, _origin, PMREMGenerator, WebGLCubeRenderTarget, toneMappingMap, emptyTexture, emptyShadowTexture, emptyArrayTexture, empty3dTexture, emptyCubeTexture, arrayCacheF32, arrayCacheI32, mat4array, mat3array, mat2array, SingleUniform, PureArrayUniform, StructuredUniform, RePathPart, WebGLUniforms, COMPLETION_STATUS_KHR, programIdCount, _m0, toneMappingFunctions, _v02, includePattern, shaderChunkMap, unrollLoopPattern, shadowMapTypeDefines, envMapTypeDefines, envMapModeDefines, envMapBlendingDefines, _id2, WebGLShaderCache, WebGLShaderStage, nextVersion, vertex, fragment, _cubeDirections, _cubeUps, _projScreenMatrix2, _lightPositionWorld2, _lookTarget2, _occlusion_vertex, _occlusion_fragment, WebXRDepthSensing, WebXRManager, _e1, _m12, DATA, lut, WebGLRenderer;
39349
+ var alphahash_fragment, alphahash_pars_fragment, alphamap_fragment, alphamap_pars_fragment, alphatest_fragment, alphatest_pars_fragment, aomap_fragment, aomap_pars_fragment, batching_pars_vertex, batching_vertex, begin_vertex, beginnormal_vertex, bsdfs, iridescence_fragment, bumpmap_pars_fragment, clipping_planes_fragment, clipping_planes_pars_fragment, clipping_planes_pars_vertex, clipping_planes_vertex, color_fragment, color_pars_fragment, color_pars_vertex, color_vertex, common, cube_uv_reflection_fragment, defaultnormal_vertex, displacementmap_pars_vertex, displacementmap_vertex, emissivemap_fragment, emissivemap_pars_fragment, colorspace_fragment, colorspace_pars_fragment, envmap_fragment, envmap_common_pars_fragment, envmap_pars_fragment, envmap_pars_vertex, envmap_vertex, fog_vertex, fog_pars_vertex, fog_fragment, fog_pars_fragment, gradientmap_pars_fragment, lightmap_pars_fragment, lights_lambert_fragment, lights_lambert_pars_fragment, lights_pars_begin, envmap_physical_pars_fragment, lights_toon_fragment, lights_toon_pars_fragment, lights_phong_fragment, lights_phong_pars_fragment, lights_physical_fragment, lights_physical_pars_fragment, lights_fragment_begin, lights_fragment_maps, lights_fragment_end, lightprobes_pars_fragment, logdepthbuf_fragment, logdepthbuf_pars_fragment, logdepthbuf_pars_vertex, logdepthbuf_vertex, map_fragment, map_pars_fragment, map_particle_fragment, map_particle_pars_fragment, metalnessmap_fragment, metalnessmap_pars_fragment, morphinstance_vertex, morphcolor_vertex, morphnormal_vertex, morphtarget_pars_vertex, morphtarget_vertex, normal_fragment_begin, normal_fragment_maps, normal_pars_fragment, normal_pars_vertex, normal_vertex, normalmap_pars_fragment, clearcoat_normal_fragment_begin, clearcoat_normal_fragment_maps, clearcoat_pars_fragment, iridescence_pars_fragment, opaque_fragment, packing, premultiplied_alpha_fragment, project_vertex, dithering_fragment, dithering_pars_fragment, roughnessmap_fragment, roughnessmap_pars_fragment, shadowmap_pars_fragment, shadowmap_pars_vertex, shadowmap_vertex, shadowmask_pars_fragment, skinbase_vertex, skinning_pars_vertex, skinning_vertex, skinnormal_vertex, specularmap_fragment, specularmap_pars_fragment, tonemapping_fragment, tonemapping_pars_fragment, transmission_fragment, transmission_pars_fragment, uv_pars_fragment, uv_pars_vertex, uv_vertex, worldpos_vertex, vertex$h, fragment$h, vertex$g, fragment$g, vertex$f, fragment$f, vertex$e, fragment$e, vertex$d, fragment$d, vertex$c, fragment$c, vertex$b, fragment$b, vertex$a, fragment$a, vertex$9, fragment$9, vertex$8, fragment$8, vertex$7, fragment$7, vertex$6, fragment$6, vertex$5, fragment$5, vertex$4, fragment$4, vertex$3, fragment$3, vertex$2, fragment$2, vertex$1, fragment$1, ShaderChunk, UniformsLib, ShaderLib, _rgb, _m1$12, _m$1, LOD_MIN, EXTRA_LOD_SIGMA, MAX_SAMPLES, GGX_SAMPLES, _flatCamera, _clearColor, _oldTarget, _oldActiveCubeFace, _oldActiveMipmapLevel, _oldXrEnabled, _origin, PMREMGenerator, WebGLCubeRenderTarget, toneMappingMap, emptyTexture, emptyShadowTexture, emptyArrayTexture, empty3dTexture, emptyCubeTexture, arrayCacheF32, arrayCacheI32, mat4array, mat3array, mat2array, SingleUniform, PureArrayUniform, StructuredUniform, RePathPart, WebGLUniforms, COMPLETION_STATUS_KHR, programIdCount, _m0, toneMappingFunctions, _v02, includePattern, shaderChunkMap, unrollLoopPattern, shadowMapTypeDefines, envMapTypeDefines, envMapModeDefines, envMapBlendingDefines, _id2, WebGLShaderCache, WebGLShaderStage, nextVersion, vertex, fragment, _cubeDirections, _cubeUps, _projScreenMatrix2, _lightPositionWorld2, _lookTarget2, _occlusion_vertex, _occlusion_fragment, WebXRDepthSensing, WebXRManager, _m12, _m, DATA, lut, WebGLRenderer;
39135
39350
  var init_three_module = __esm({
39136
- "../../node_modules/.bun/three@0.183.2/node_modules/three/build/three.module.js"() {
39351
+ "../../node_modules/.bun/three@0.184.0/node_modules/three/build/three.module.js"() {
39137
39352
  init_three_core();
39138
39353
  init_three_core();
39139
39354
  alphahash_fragment = "#ifdef USE_ALPHAHASH\n if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif";
@@ -39168,8 +39383,8 @@ var init_three_module = __esm({
39168
39383
  emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif";
39169
39384
  colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
39170
39385
  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}";
39171
- 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";
39172
- 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";
39386
+ 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";
39387
+ 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";
39173
39388
  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";
39174
39389
  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";
39175
39390
  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";
@@ -39181,17 +39396,18 @@ var init_three_module = __esm({
39181
39396
  lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif";
39182
39397
  lights_lambert_fragment = "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;";
39183
39398
  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";
39184
- 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";
39399
+ 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>";
39185
39400
  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";
39186
39401
  lights_toon_fragment = "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;";
39187
39402
  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";
39188
39403
  lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;";
39189
39404
  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";
39190
39405
  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";
39191
- 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}";
39192
- 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";
39406
+ 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}";
39407
+ 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";
39193
39408
  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";
39194
39409
  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";
39410
+ 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";
39195
39411
  logdepthbuf_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif";
39196
39412
  logdepthbuf_pars_fragment = "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
39197
39413
  logdepthbuf_pars_vertex = "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif";
@@ -39208,7 +39424,7 @@ var init_three_module = __esm({
39208
39424
  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";
39209
39425
  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";
39210
39426
  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;";
39211
- 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";
39427
+ 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";
39212
39428
  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";
39213
39429
  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";
39214
39430
  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";
@@ -39227,7 +39443,7 @@ var init_three_module = __esm({
39227
39443
  roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif";
39228
39444
  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";
39229
39445
  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";
39230
- 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";
39446
+ 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";
39231
39447
  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}";
39232
39448
  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";
39233
39449
  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";
@@ -39246,7 +39462,7 @@ var init_three_module = __esm({
39246
39462
  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}";
39247
39463
  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}";
39248
39464
  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}";
39249
- 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}";
39465
+ 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}";
39250
39466
  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}";
39251
39467
  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}";
39252
39468
  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}";
@@ -39334,6 +39550,7 @@ var init_three_module = __esm({
39334
39550
  lights_fragment_begin,
39335
39551
  lights_fragment_maps,
39336
39552
  lights_fragment_end,
39553
+ lightprobes_pars_fragment,
39337
39554
  logdepthbuf_fragment,
39338
39555
  logdepthbuf_pars_fragment,
39339
39556
  logdepthbuf_pars_vertex,
@@ -39437,7 +39654,6 @@ var init_three_module = __esm({
39437
39654
  envmap: {
39438
39655
  envMap: { value: null },
39439
39656
  envMapRotation: { value: /* @__PURE__ */ new Matrix3() },
39440
- flipEnvMap: { value: -1 },
39441
39657
  reflectivity: { value: 1 },
39442
39658
  // basic, lambert, phong
39443
39659
  ior: { value: 1.5 },
@@ -39556,7 +39772,11 @@ var init_three_module = __esm({
39556
39772
  height: {}
39557
39773
  } },
39558
39774
  ltc_1: { value: null },
39559
- ltc_2: { value: null }
39775
+ ltc_2: { value: null },
39776
+ probesSH: { value: null },
39777
+ probesMin: { value: /* @__PURE__ */ new Vector3() },
39778
+ probesMax: { value: /* @__PURE__ */ new Vector3() },
39779
+ probesResolution: { value: /* @__PURE__ */ new Vector3() }
39560
39780
  },
39561
39781
  points: {
39562
39782
  diffuse: { value: /* @__PURE__ */ new Color(16777215) },
@@ -39757,7 +39977,6 @@ var init_three_module = __esm({
39757
39977
  backgroundCube: {
39758
39978
  uniforms: {
39759
39979
  envMap: { value: null },
39760
- flipEnvMap: { value: -1 },
39761
39980
  backgroundBlurriness: { value: 0 },
39762
39981
  backgroundIntensity: { value: 1 },
39763
39982
  backgroundRotation: { value: /* @__PURE__ */ new Matrix3() }
@@ -39861,8 +40080,9 @@ var init_three_module = __esm({
39861
40080
  fragmentShader: ShaderChunk.meshphysical_frag
39862
40081
  };
39863
40082
  _rgb = { r: 0, b: 0, g: 0 };
39864
- _e1$1 = /* @__PURE__ */ new Euler();
39865
40083
  _m1$12 = /* @__PURE__ */ new Matrix4();
40084
+ _m$1 = /* @__PURE__ */ new Matrix3();
40085
+ _m$1.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
39866
40086
  LOD_MIN = 4;
39867
40087
  EXTRA_LOD_SIGMA = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582];
39868
40088
  MAX_SAMPLES = 20;
@@ -41206,8 +41426,9 @@ void main() {
41206
41426
  };
41207
41427
  }
41208
41428
  };
41209
- _e1 = /* @__PURE__ */ new Euler();
41210
41429
  _m12 = /* @__PURE__ */ new Matrix4();
41430
+ _m = /* @__PURE__ */ new Matrix3();
41431
+ _m.set(-1, 0, 0, 0, 1, 0, 0, 0, 1);
41211
41432
  DATA = new Uint16Array([
41212
41433
  12469,
41213
41434
  15057,
@@ -41770,6 +41991,7 @@ void main() {
41770
41991
  ]);
41771
41992
  const uintClearColor = new Uint32Array(4);
41772
41993
  const intClearColor = new Int32Array(4);
41994
+ const objectPosition = new Vector3();
41773
41995
  let currentRenderList = null;
41774
41996
  let currentRenderState = null;
41775
41997
  const renderListStack = [];
@@ -41800,6 +42022,7 @@ void main() {
41800
42022
  this.transmissionResolutionScale = 1;
41801
42023
  const _this = this;
41802
42024
  let _isContextLost = false;
42025
+ let _nodesHandler = null;
41803
42026
  this._outputColorSpace = SRGBColorSpace;
41804
42027
  let _currentActiveCubeFace = 0;
41805
42028
  let _currentActiveMipmapLevel = 0;
@@ -41823,8 +42046,8 @@ void main() {
41823
42046
  let _clippingEnabled = false;
41824
42047
  let _localClippingEnabled = false;
41825
42048
  const _projScreenMatrix3 = new Matrix4();
41826
- const _vector32 = new Vector3();
41827
- const _vector4 = new Vector4();
42049
+ const _vector3 = new Vector3();
42050
+ const _vector42 = new Vector4();
41828
42051
  const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
41829
42052
  let _renderBackground = false;
41830
42053
  function getTargetPixelRatio() {
@@ -41968,13 +42191,13 @@ void main() {
41968
42191
  };
41969
42192
  this.setEffects = function(effects) {
41970
42193
  if (_outputBufferType === UnsignedByteType) {
41971
- console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");
42194
+ error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");
41972
42195
  return;
41973
42196
  }
41974
42197
  if (effects) {
41975
42198
  for (let i3 = 0; i3 < effects.length; i3++) {
41976
42199
  if (effects[i3].isOutputPass === true) {
41977
- console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");
42200
+ warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");
41978
42201
  break;
41979
42202
  }
41980
42203
  }
@@ -42065,6 +42288,7 @@ void main() {
42065
42288
  }
42066
42289
  if (depth2) {
42067
42290
  bits |= _gl.DEPTH_BUFFER_BIT;
42291
+ this.state.buffers.depth.setMask(true);
42068
42292
  }
42069
42293
  if (stencil2) {
42070
42294
  bits |= _gl.STENCIL_BUFFER_BIT;
@@ -42083,6 +42307,10 @@ void main() {
42083
42307
  this.clearStencil = function() {
42084
42308
  this.clear(false, false, true);
42085
42309
  };
42310
+ this.setNodesHandler = function(nodesHandler) {
42311
+ nodesHandler.setRenderer(this);
42312
+ _nodesHandler = nodesHandler;
42313
+ };
42086
42314
  this.dispose = function() {
42087
42315
  canvas.removeEventListener("webglcontextlost", onContextLost, false);
42088
42316
  canvas.removeEventListener("webglcontextrestored", onContextRestore, false);
@@ -42205,23 +42433,18 @@ void main() {
42205
42433
  renderer.setMode(_gl.TRIANGLES);
42206
42434
  }
42207
42435
  if (object.isBatchedMesh) {
42208
- if (object._multiDrawInstances !== null) {
42209
- warnOnce("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");
42210
- renderer.renderMultiDrawInstances(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances);
42211
- } else {
42212
- if (!extensions2.get("WEBGL_multi_draw")) {
42213
- const starts = object._multiDrawStarts;
42214
- const counts = object._multiDrawCounts;
42215
- const drawCount2 = object._multiDrawCount;
42216
- const bytesPerElement = index ? attributes.get(index).bytesPerElement : 1;
42217
- const uniforms = properties.get(material).currentProgram.getUniforms();
42218
- for (let i3 = 0; i3 < drawCount2; i3++) {
42219
- uniforms.setValue(_gl, "_gl_DrawID", i3);
42220
- renderer.render(starts[i3] / bytesPerElement, counts[i3]);
42221
- }
42222
- } else {
42223
- renderer.renderMultiDraw(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount);
42436
+ if (!extensions2.get("WEBGL_multi_draw")) {
42437
+ const starts = object._multiDrawStarts;
42438
+ const counts = object._multiDrawCounts;
42439
+ const drawCount2 = object._multiDrawCount;
42440
+ const bytesPerElement = index ? attributes.get(index).bytesPerElement : 1;
42441
+ const uniforms = properties.get(material).currentProgram.getUniforms();
42442
+ for (let i3 = 0; i3 < drawCount2; i3++) {
42443
+ uniforms.setValue(_gl, "_gl_DrawID", i3);
42444
+ renderer.render(starts[i3] / bytesPerElement, counts[i3]);
42224
42445
  }
42446
+ } else {
42447
+ renderer.renderMultiDraw(object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount);
42225
42448
  }
42226
42449
  } else if (object.isInstancedMesh) {
42227
42450
  renderer.renderInstances(drawStart, drawCount, object.count);
@@ -42342,6 +42565,9 @@ void main() {
42342
42565
  return;
42343
42566
  }
42344
42567
  if (_isContextLost === true) return;
42568
+ if (_nodesHandler !== null) {
42569
+ _nodesHandler.renderStart(scene, camera);
42570
+ }
42345
42571
  const isXRPresenting = xr.enabled === true && xr.isPresenting === true;
42346
42572
  const useOutput = output !== null && (_currentRenderTarget === null || isXRPresenting) && output.begin(_this, _currentRenderTarget);
42347
42573
  if (scene.matrixWorldAutoUpdate === true) scene.updateMatrixWorld();
@@ -42353,6 +42579,7 @@ void main() {
42353
42579
  if (scene.isScene === true) scene.onBeforeRender(_this, scene, camera, _currentRenderTarget);
42354
42580
  currentRenderState = renderStates.get(scene, renderStateStack.length);
42355
42581
  currentRenderState.init(camera);
42582
+ currentRenderState.state.textureUnits = textures.getTextureUnits();
42356
42583
  renderStateStack.push(currentRenderState);
42357
42584
  _projScreenMatrix3.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
42358
42585
  _frustum2.setFromProjectionMatrix(_projScreenMatrix3, WebGLCoordinateSystem, camera.reversedDepth);
@@ -42420,6 +42647,7 @@ void main() {
42420
42647
  renderStateStack.pop();
42421
42648
  if (renderStateStack.length > 0) {
42422
42649
  currentRenderState = renderStateStack[renderStateStack.length - 1];
42650
+ textures.setTextureUnits(currentRenderState.state.textureUnits);
42423
42651
  if (_clippingEnabled === true) clipping.setGlobalState(_this.clippingPlanes, currentRenderState.state.camera);
42424
42652
  } else {
42425
42653
  currentRenderState = null;
@@ -42430,6 +42658,9 @@ void main() {
42430
42658
  } else {
42431
42659
  currentRenderList = null;
42432
42660
  }
42661
+ if (_nodesHandler !== null) {
42662
+ _nodesHandler.renderEnd();
42663
+ }
42433
42664
  };
42434
42665
  function projectObject(object, camera, groupOrder, sortObjects) {
42435
42666
  if (object.visible === false) return;
@@ -42439,6 +42670,8 @@ void main() {
42439
42670
  groupOrder = object.renderOrder;
42440
42671
  } else if (object.isLOD) {
42441
42672
  if (object.autoUpdate === true) object.update(camera);
42673
+ } else if (object.isLightProbeGrid) {
42674
+ currentRenderState.pushLightProbeGrid(object);
42442
42675
  } else if (object.isLight) {
42443
42676
  currentRenderState.pushLight(object);
42444
42677
  if (object.castShadow) {
@@ -42447,12 +42680,12 @@ void main() {
42447
42680
  } else if (object.isSprite) {
42448
42681
  if (!object.frustumCulled || _frustum2.intersectsSprite(object)) {
42449
42682
  if (sortObjects) {
42450
- _vector4.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix3);
42683
+ _vector42.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix3);
42451
42684
  }
42452
42685
  const geometry = objects.update(object);
42453
42686
  const material = object.material;
42454
42687
  if (material.visible) {
42455
- currentRenderList.push(object, geometry, material, groupOrder, _vector4.z, null);
42688
+ currentRenderList.push(object, geometry, material, groupOrder, _vector42.z, null);
42456
42689
  }
42457
42690
  }
42458
42691
  } else if (object.isMesh || object.isLine || object.isPoints) {
@@ -42462,12 +42695,12 @@ void main() {
42462
42695
  if (sortObjects) {
42463
42696
  if (object.boundingSphere !== void 0) {
42464
42697
  if (object.boundingSphere === null) object.computeBoundingSphere();
42465
- _vector4.copy(object.boundingSphere.center);
42698
+ _vector42.copy(object.boundingSphere.center);
42466
42699
  } else {
42467
42700
  if (geometry.boundingSphere === null) geometry.computeBoundingSphere();
42468
- _vector4.copy(geometry.boundingSphere.center);
42701
+ _vector42.copy(geometry.boundingSphere.center);
42469
42702
  }
42470
- _vector4.applyMatrix4(object.matrixWorld).applyMatrix4(_projScreenMatrix3);
42703
+ _vector42.applyMatrix4(object.matrixWorld).applyMatrix4(_projScreenMatrix3);
42471
42704
  }
42472
42705
  if (Array.isArray(material)) {
42473
42706
  const groups = geometry.groups;
@@ -42475,11 +42708,11 @@ void main() {
42475
42708
  const group = groups[i3];
42476
42709
  const groupMaterial = material[group.materialIndex];
42477
42710
  if (groupMaterial && groupMaterial.visible) {
42478
- currentRenderList.push(object, geometry, groupMaterial, groupOrder, _vector4.z, group);
42711
+ currentRenderList.push(object, geometry, groupMaterial, groupOrder, _vector42.z, group);
42479
42712
  }
42480
42713
  }
42481
42714
  } else if (material.visible) {
42482
- currentRenderList.push(object, geometry, material, groupOrder, _vector4.z, null);
42715
+ currentRenderList.push(object, geometry, material, groupOrder, _vector42.z, null);
42483
42716
  }
42484
42717
  }
42485
42718
  }
@@ -42605,7 +42838,7 @@ void main() {
42605
42838
  const lights = currentRenderState.state.lights;
42606
42839
  const shadowsArray = currentRenderState.state.shadowsArray;
42607
42840
  const lightsStateVersion = lights.state.version;
42608
- const parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, object);
42841
+ const parameters2 = programCache.getParameters(material, lights.state, shadowsArray, scene, object, currentRenderState.state.lightProbeGridArray);
42609
42842
  const programCacheKey = programCache.getProgramCacheKey(parameters2);
42610
42843
  let programs = materialProperties.programs;
42611
42844
  materialProperties.environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
@@ -42626,6 +42859,9 @@ void main() {
42626
42859
  }
42627
42860
  } else {
42628
42861
  parameters2.uniforms = programCache.getUniforms(material);
42862
+ if (_nodesHandler !== null && material.isNodeMaterial) {
42863
+ _nodesHandler.build(material, object, parameters2);
42864
+ }
42629
42865
  material.onBeforeCompile(parameters2, _this);
42630
42866
  program = programCache.acquireProgram(parameters2, programCacheKey);
42631
42867
  programs.set(programCacheKey, program);
@@ -42656,6 +42892,7 @@ void main() {
42656
42892
  uniforms.spotLightMap.value = lights.state.spotLightMap;
42657
42893
  uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
42658
42894
  }
42895
+ materialProperties.lightProbeGrid = currentRenderState.state.lightProbeGridArray.length > 0;
42659
42896
  materialProperties.currentProgram = program;
42660
42897
  materialProperties.uniformsList = null;
42661
42898
  return program;
@@ -42686,12 +42923,24 @@ void main() {
42686
42923
  materialProperties.vertexTangents = parameters2.vertexTangents;
42687
42924
  materialProperties.toneMapping = parameters2.toneMapping;
42688
42925
  }
42926
+ function findLightProbeGrid(volumes, object) {
42927
+ if (volumes.length === 0) return null;
42928
+ if (volumes.length === 1) {
42929
+ return volumes[0].texture !== null ? volumes[0] : null;
42930
+ }
42931
+ objectPosition.setFromMatrixPosition(object.matrixWorld);
42932
+ for (let i3 = 0, l2 = volumes.length; i3 < l2; i3++) {
42933
+ const v = volumes[i3];
42934
+ if (v.texture !== null && v.boundingBox.containsPoint(objectPosition)) return v;
42935
+ }
42936
+ return null;
42937
+ }
42689
42938
  function setProgram(camera, scene, geometry, material, object) {
42690
42939
  if (scene.isScene !== true) scene = _emptyScene;
42691
42940
  textures.resetTextureUnits();
42692
42941
  const fog = scene.fog;
42693
42942
  const environment = material.isMeshStandardMaterial || material.isMeshLambertMaterial || material.isMeshPhongMaterial ? scene.environment : null;
42694
- const colorSpace = _currentRenderTarget === null ? _this.outputColorSpace : _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace;
42943
+ const colorSpace = _currentRenderTarget === null ? _this.outputColorSpace : _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : ColorManagement.workingColorSpace;
42695
42944
  const usePMREM = material.isMeshStandardMaterial || material.isMeshLambertMaterial && !material.envMap || material.isMeshPhongMaterial && !material.envMap;
42696
42945
  const envMap = environments.get(material.envMap || environment, usePMREM);
42697
42946
  const vertexAlphas = material.vertexColors === true && !!geometry.attributes.color && geometry.attributes.color.itemSize === 4;
@@ -42765,6 +43014,8 @@ void main() {
42765
43014
  needsProgramChange = true;
42766
43015
  } else if (materialProperties.morphTargetsCount !== morphTargetsCount) {
42767
43016
  needsProgramChange = true;
43017
+ } else if (!!materialProperties.lightProbeGrid !== currentRenderState.state.lightProbeGridArray.length > 0) {
43018
+ needsProgramChange = true;
42768
43019
  }
42769
43020
  } else {
42770
43021
  needsProgramChange = true;
@@ -42773,6 +43024,9 @@ void main() {
42773
43024
  let program = materialProperties.currentProgram;
42774
43025
  if (needsProgramChange === true) {
42775
43026
  program = getProgram(material, scene, object);
43027
+ if (_nodesHandler && material.isNodeMaterial) {
43028
+ _nodesHandler.onUpdateProgram(material, program, materialProperties);
43029
+ }
42776
43030
  }
42777
43031
  let refreshProgram = false;
42778
43032
  let refreshMaterial = false;
@@ -42787,6 +43041,13 @@ void main() {
42787
43041
  _currentMaterialId = material.id;
42788
43042
  refreshMaterial = true;
42789
43043
  }
43044
+ if (materialProperties.needsLights) {
43045
+ const objectVolume = findLightProbeGrid(currentRenderState.state.lightProbeGridArray, object);
43046
+ if (materialProperties.lightProbeGrid !== objectVolume) {
43047
+ materialProperties.lightProbeGrid = objectVolume;
43048
+ refreshMaterial = true;
43049
+ }
43050
+ }
42790
43051
  if (refreshProgram || _currentCamera !== camera) {
42791
43052
  const reversedDepthBuffer2 = state2.buffers.depth.getReversed();
42792
43053
  if (reversedDepthBuffer2 && camera.reversedDepth !== true) {
@@ -42797,7 +43058,7 @@ void main() {
42797
43058
  p_uniforms.setValue(_gl, "viewMatrix", camera.matrixWorldInverse);
42798
43059
  const uCamPos = p_uniforms.map.cameraPosition;
42799
43060
  if (uCamPos !== void 0) {
42800
- uCamPos.setValue(_gl, _vector32.setFromMatrixPosition(camera.matrixWorld));
43061
+ uCamPos.setValue(_gl, _vector3.setFromMatrixPosition(camera.matrixWorld));
42801
43062
  }
42802
43063
  if (capabilities.logarithmicDepthBuffer) {
42803
43064
  p_uniforms.setValue(
@@ -42868,6 +43129,13 @@ void main() {
42868
43129
  materials.refreshFogUniforms(m_uniforms, fog);
42869
43130
  }
42870
43131
  materials.refreshMaterialUniforms(m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[camera.id]);
43132
+ if (materialProperties.needsLights && materialProperties.lightProbeGrid) {
43133
+ const volume = materialProperties.lightProbeGrid;
43134
+ m_uniforms.probesSH.value = volume.texture;
43135
+ m_uniforms.probesMin.value.copy(volume.boundingBox.min);
43136
+ m_uniforms.probesMax.value.copy(volume.boundingBox.max);
43137
+ m_uniforms.probesResolution.value.copy(volume.resolution);
43138
+ }
42871
43139
  WebGLUniforms.upload(_gl, getUniformList(materialProperties), m_uniforms, textures);
42872
43140
  }
42873
43141
  if (material.isShaderMaterial && material.uniformsNeedUpdate === true) {
@@ -42880,7 +43148,7 @@ void main() {
42880
43148
  p_uniforms.setValue(_gl, "modelViewMatrix", object.modelViewMatrix);
42881
43149
  p_uniforms.setValue(_gl, "normalMatrix", object.normalMatrix);
42882
43150
  p_uniforms.setValue(_gl, "modelMatrix", object.matrixWorld);
42883
- if (material.isShaderMaterial || material.isRawShaderMaterial) {
43151
+ if (material.uniformsGroups !== void 0) {
42884
43152
  const groups = material.uniformsGroups;
42885
43153
  for (let i3 = 0, l2 = groups.length; i3 < l2; i3++) {
42886
43154
  const group = groups[i3];
@@ -43149,19 +43417,20 @@ void main() {
43149
43417
  textures.setTexture2D(dstTexture, 0);
43150
43418
  glTarget = _gl.TEXTURE_2D;
43151
43419
  }
43152
- _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY);
43153
- _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha);
43154
- _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment);
43155
- const currentUnpackRowLen = _gl.getParameter(_gl.UNPACK_ROW_LENGTH);
43156
- const currentUnpackImageHeight = _gl.getParameter(_gl.UNPACK_IMAGE_HEIGHT);
43157
- const currentUnpackSkipPixels = _gl.getParameter(_gl.UNPACK_SKIP_PIXELS);
43158
- const currentUnpackSkipRows = _gl.getParameter(_gl.UNPACK_SKIP_ROWS);
43159
- const currentUnpackSkipImages = _gl.getParameter(_gl.UNPACK_SKIP_IMAGES);
43160
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
43161
- _gl.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, image.height);
43162
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, minX);
43163
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, minY);
43164
- _gl.pixelStorei(_gl.UNPACK_SKIP_IMAGES, minZ);
43420
+ state2.activeTexture(_gl.TEXTURE0);
43421
+ state2.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY);
43422
+ state2.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha);
43423
+ state2.pixelStorei(_gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment);
43424
+ const currentUnpackRowLen = state2.getParameter(_gl.UNPACK_ROW_LENGTH);
43425
+ const currentUnpackImageHeight = state2.getParameter(_gl.UNPACK_IMAGE_HEIGHT);
43426
+ const currentUnpackSkipPixels = state2.getParameter(_gl.UNPACK_SKIP_PIXELS);
43427
+ const currentUnpackSkipRows = state2.getParameter(_gl.UNPACK_SKIP_ROWS);
43428
+ const currentUnpackSkipImages = state2.getParameter(_gl.UNPACK_SKIP_IMAGES);
43429
+ state2.pixelStorei(_gl.UNPACK_ROW_LENGTH, image.width);
43430
+ state2.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, image.height);
43431
+ state2.pixelStorei(_gl.UNPACK_SKIP_PIXELS, minX);
43432
+ state2.pixelStorei(_gl.UNPACK_SKIP_ROWS, minY);
43433
+ state2.pixelStorei(_gl.UNPACK_SKIP_IMAGES, minZ);
43165
43434
  const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture;
43166
43435
  const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture;
43167
43436
  if (srcTexture.isDepthTexture) {
@@ -43225,11 +43494,11 @@ void main() {
43225
43494
  }
43226
43495
  }
43227
43496
  }
43228
- _gl.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
43229
- _gl.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight);
43230
- _gl.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
43231
- _gl.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
43232
- _gl.pixelStorei(_gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages);
43497
+ state2.pixelStorei(_gl.UNPACK_ROW_LENGTH, currentUnpackRowLen);
43498
+ state2.pixelStorei(_gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight);
43499
+ state2.pixelStorei(_gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels);
43500
+ state2.pixelStorei(_gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows);
43501
+ state2.pixelStorei(_gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages);
43233
43502
  if (dstLevel === 0 && dstTexture.generateMipmaps) {
43234
43503
  _gl.generateMipmap(glTarget);
43235
43504
  }
@@ -43294,15 +43563,15 @@ void main() {
43294
43563
  }
43295
43564
  });
43296
43565
 
43297
- // ../../node_modules/.bun/use-sync-external-store@1.6.0+b1ab299f0a400331/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
43566
+ // ../../node_modules/.bun/use-sync-external-store@1.6.0+3f10a4be4e334a9b/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
43298
43567
  var require_use_sync_external_store_shim_development = __commonJS({
43299
- "../../node_modules/.bun/use-sync-external-store@1.6.0+b1ab299f0a400331/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports$1) {
43568
+ "../../node_modules/.bun/use-sync-external-store@1.6.0+3f10a4be4e334a9b/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports$1) {
43300
43569
  (function() {
43301
43570
  function is2(x2, y) {
43302
43571
  return x2 === y && (0 !== x2 || 1 / x2 === 1 / y) || x2 !== x2 && y !== y;
43303
43572
  }
43304
43573
  function useSyncExternalStore$2(subscribe3, getSnapshot2) {
43305
- didWarnOld18Alpha || void 0 === React97.startTransition || (didWarnOld18Alpha = true, console.error(
43574
+ didWarnOld18Alpha || void 0 === React100.startTransition || (didWarnOld18Alpha = true, console.error(
43306
43575
  "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
43307
43576
  ));
43308
43577
  var value = getSnapshot2();
@@ -43312,7 +43581,7 @@ var require_use_sync_external_store_shim_development = __commonJS({
43312
43581
  "The result of getSnapshot should be cached to avoid an infinite loop"
43313
43582
  ), didWarnUncachedGetSnapshot = true);
43314
43583
  }
43315
- cachedValue = useState85({
43584
+ cachedValue = useState86({
43316
43585
  inst: { value, getSnapshot: getSnapshot2 }
43317
43586
  });
43318
43587
  var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
@@ -43350,31 +43619,31 @@ var require_use_sync_external_store_shim_development = __commonJS({
43350
43619
  return getSnapshot2();
43351
43620
  }
43352
43621
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
43353
- var React97 = __require("react"), objectIs = "function" === typeof Object.is ? Object.is : is2, useState85 = React97.useState, useEffect72 = React97.useEffect, useLayoutEffect7 = React97.useLayoutEffect, useDebugValue = React97.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
43354
- exports$1.useSyncExternalStore = void 0 !== React97.useSyncExternalStore ? React97.useSyncExternalStore : shim;
43622
+ var React100 = __require("react"), objectIs = "function" === typeof Object.is ? Object.is : is2, useState86 = React100.useState, useEffect72 = React100.useEffect, useLayoutEffect7 = React100.useLayoutEffect, useDebugValue = React100.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
43623
+ exports$1.useSyncExternalStore = void 0 !== React100.useSyncExternalStore ? React100.useSyncExternalStore : shim;
43355
43624
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
43356
43625
  })();
43357
43626
  }
43358
43627
  });
43359
43628
 
43360
- // ../../node_modules/.bun/use-sync-external-store@1.6.0+b1ab299f0a400331/node_modules/use-sync-external-store/shim/index.js
43629
+ // ../../node_modules/.bun/use-sync-external-store@1.6.0+3f10a4be4e334a9b/node_modules/use-sync-external-store/shim/index.js
43361
43630
  var require_shim = __commonJS({
43362
- "../../node_modules/.bun/use-sync-external-store@1.6.0+b1ab299f0a400331/node_modules/use-sync-external-store/shim/index.js"(exports$1, module) {
43631
+ "../../node_modules/.bun/use-sync-external-store@1.6.0+3f10a4be4e334a9b/node_modules/use-sync-external-store/shim/index.js"(exports$1, module) {
43363
43632
  {
43364
43633
  module.exports = require_use_sync_external_store_shim_development();
43365
43634
  }
43366
43635
  }
43367
43636
  });
43368
43637
 
43369
- // ../../node_modules/.bun/use-sync-external-store@1.6.0+b1ab299f0a400331/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
43638
+ // ../../node_modules/.bun/use-sync-external-store@1.6.0+3f10a4be4e334a9b/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
43370
43639
  var require_with_selector_development = __commonJS({
43371
- "../../node_modules/.bun/use-sync-external-store@1.6.0+b1ab299f0a400331/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports$1) {
43640
+ "../../node_modules/.bun/use-sync-external-store@1.6.0+3f10a4be4e334a9b/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports$1) {
43372
43641
  (function() {
43373
43642
  function is2(x2, y) {
43374
43643
  return x2 === y && (0 !== x2 || 1 / x2 === 1 / y) || x2 !== x2 && y !== y;
43375
43644
  }
43376
43645
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
43377
- var React97 = __require("react"), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is2, useSyncExternalStore3 = shim.useSyncExternalStore, useRef73 = React97.useRef, useEffect72 = React97.useEffect, useMemo41 = React97.useMemo, useDebugValue = React97.useDebugValue;
43646
+ var React100 = __require("react"), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is2, useSyncExternalStore3 = shim.useSyncExternalStore, useRef73 = React100.useRef, useEffect72 = React100.useEffect, useMemo41 = React100.useMemo, useDebugValue = React100.useDebugValue;
43378
43647
  exports$1.useSyncExternalStoreWithSelector = function(subscribe3, getSnapshot2, getServerSnapshot2, selector, isEqual) {
43379
43648
  var instRef = useRef73(null);
43380
43649
  if (null === instRef.current) {
@@ -43432,19 +43701,19 @@ var require_with_selector_development = __commonJS({
43432
43701
  }
43433
43702
  });
43434
43703
 
43435
- // ../../node_modules/.bun/use-sync-external-store@1.6.0+b1ab299f0a400331/node_modules/use-sync-external-store/shim/with-selector.js
43704
+ // ../../node_modules/.bun/use-sync-external-store@1.6.0+3f10a4be4e334a9b/node_modules/use-sync-external-store/shim/with-selector.js
43436
43705
  var require_with_selector = __commonJS({
43437
- "../../node_modules/.bun/use-sync-external-store@1.6.0+b1ab299f0a400331/node_modules/use-sync-external-store/shim/with-selector.js"(exports$1, module) {
43706
+ "../../node_modules/.bun/use-sync-external-store@1.6.0+3f10a4be4e334a9b/node_modules/use-sync-external-store/shim/with-selector.js"(exports$1, module) {
43438
43707
  {
43439
43708
  module.exports = require_with_selector_development();
43440
43709
  }
43441
43710
  }
43442
43711
  });
43443
43712
 
43444
- // ../../node_modules/.bun/zustand@5.0.11+10f197a4cef36846/node_modules/zustand/esm/vanilla.mjs
43713
+ // ../../node_modules/.bun/zustand@5.0.11+5e3d5174673d7dcb/node_modules/zustand/esm/vanilla.mjs
43445
43714
  var createStoreImpl, createStore;
43446
43715
  var init_vanilla = __esm({
43447
- "../../node_modules/.bun/zustand@5.0.11+10f197a4cef36846/node_modules/zustand/esm/vanilla.mjs"() {
43716
+ "../../node_modules/.bun/zustand@5.0.11+5e3d5174673d7dcb/node_modules/zustand/esm/vanilla.mjs"() {
43448
43717
  createStoreImpl = (createState) => {
43449
43718
  let state2;
43450
43719
  const listeners = /* @__PURE__ */ new Set();
@@ -43482,7 +43751,7 @@ function useStoreWithEqualityFn(api, selector = identity, equalityFn) {
43482
43751
  }
43483
43752
  var import_with_selector, useSyncExternalStoreWithSelector, identity, createWithEqualityFnImpl, createWithEqualityFn;
43484
43753
  var init_traditional = __esm({
43485
- "../../node_modules/.bun/zustand@5.0.11+10f197a4cef36846/node_modules/zustand/esm/traditional.mjs"() {
43754
+ "../../node_modules/.bun/zustand@5.0.11+5e3d5174673d7dcb/node_modules/zustand/esm/traditional.mjs"() {
43486
43755
  import_with_selector = __toESM(require_with_selector(), 1);
43487
43756
  init_vanilla();
43488
43757
  ({ useSyncExternalStoreWithSelector } = import_with_selector.default);
@@ -43497,7 +43766,7 @@ var init_traditional = __esm({
43497
43766
  }
43498
43767
  });
43499
43768
 
43500
- // ../../node_modules/.bun/suspend-react@0.1.3+b1ab299f0a400331/node_modules/suspend-react/index.js
43769
+ // ../../node_modules/.bun/suspend-react@0.1.3+3f10a4be4e334a9b/node_modules/suspend-react/index.js
43501
43770
  function shallowEqualArrays(arrA, arrB, equal = (a2, b2) => a2 === b2) {
43502
43771
  if (arrA === arrB) return true;
43503
43772
  if (!arrA || !arrB) return false;
@@ -43545,7 +43814,7 @@ function query(fn, keys2 = null, preload2 = false, config = {}) {
43545
43814
  }
43546
43815
  var isPromise, globalCache, suspend, preload, clear;
43547
43816
  var init_suspend_react = __esm({
43548
- "../../node_modules/.bun/suspend-react@0.1.3+b1ab299f0a400331/node_modules/suspend-react/index.js"() {
43817
+ "../../node_modules/.bun/suspend-react@0.1.3+3f10a4be4e334a9b/node_modules/suspend-react/index.js"() {
43549
43818
  isPromise = (promise) => typeof promise === "object" && typeof promise.then === "function";
43550
43819
  globalCache = [];
43551
43820
  suspend = (fn, keys2, config) => query(fn, keys2, false, config);
@@ -43898,7 +44167,7 @@ function x() {
43898
44167
  }
43899
44168
  var a, m, p, b;
43900
44169
  var init_dist = __esm({
43901
- "../../node_modules/.bun/its-fine@2.0.0+26a211c426f3f87c/node_modules/its-fine/dist/index.js"() {
44170
+ "../../node_modules/.bun/its-fine@2.0.0+b2e33729a97476bf/node_modules/its-fine/dist/index.js"() {
43902
44171
  a = /* @__PURE__ */ l(/* @__PURE__ */ React10.createContext(null));
43903
44172
  m = class extends React10.Component {
43904
44173
  render() {
@@ -44214,6 +44483,35 @@ function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
44214
44483
  }
44215
44484
  }
44216
44485
  }
44486
+ function swapInteractivity(store, object, newObject) {
44487
+ const {
44488
+ internal
44489
+ } = store.getState();
44490
+ for (let i3 = 0; i3 < internal.interaction.length; i3++) {
44491
+ if (internal.interaction[i3] === object) internal.interaction[i3] = newObject;
44492
+ }
44493
+ for (let i3 = 0; i3 < internal.initialHits.length; i3++) {
44494
+ if (internal.initialHits[i3] === object) internal.initialHits[i3] = newObject;
44495
+ }
44496
+ internal.hovered.forEach((value, key) => {
44497
+ if (value.eventObject === object || value.object === object) {
44498
+ internal.hovered.delete(key);
44499
+ const next = {
44500
+ ...value,
44501
+ eventObject: value.eventObject === object ? newObject : value.eventObject,
44502
+ object: value.object === object ? newObject : value.object
44503
+ };
44504
+ internal.hovered.set(makeId(next), next);
44505
+ }
44506
+ });
44507
+ internal.capturedMap.forEach((captures) => {
44508
+ const captureData = captures.get(object);
44509
+ if (captureData) {
44510
+ captures.delete(object);
44511
+ captures.set(newObject, captureData);
44512
+ }
44513
+ });
44514
+ }
44217
44515
  function removeInteractivity(store, object) {
44218
44516
  const {
44219
44517
  internal
@@ -50609,10 +50907,10 @@ This ensures that you're testing the behavior the user would see in the browser.
50609
50907
  if ((ye & Zn) === Jn) {
50610
50908
  var n = e2.tag;
50611
50909
  if (n === 3 || n === 1 || n === 0 || n === 11 || n === 14 || n === 15) {
50612
- if (n = G(e2) || "ReactComponent", _m !== null) {
50613
- if (_m.has(n)) return;
50614
- _m.add(n);
50615
- } else _m = /* @__PURE__ */ new Set([n]);
50910
+ if (n = G(e2) || "ReactComponent", _m2 !== null) {
50911
+ if (_m2.has(n)) return;
50912
+ _m2.add(n);
50913
+ } else _m2 = /* @__PURE__ */ new Set([n]);
50616
50914
  B(e2, function() {
50617
50915
  console.error("Can't perform a React state update on a component that hasn't mounted yet. This indicates that you have a side-effect in your render function that asynchronously tries to update the component. Move this work to useEffect instead.");
50618
50916
  });
@@ -51834,7 +52132,7 @@ Check the top-level render call using <` + i3 + ">.");
51834
52132
  var bp = Symbol.for;
51835
52133
  pm = bp("selector.component"), hm = bp("selector.has_pseudo_class"), mm = bp("selector.role"), gm = bp("selector.test_id"), ym = bp("selector.text");
51836
52134
  }
51837
- var bm = [], qb = typeof WeakMap == "function" ? WeakMap : Map, Jn = 0, Zn = 2, uo = 4, ki = 0, vp = 1, iu = 2, vm = 3, Tl = 4, Sm = 6, Ky = 5, ye = Jn, je = null, se = null, ae = 0, tr = 0, km = 1, lu = 2, Sp = 3, eb = 4, Eg = 5, kp = 6, wm = 7, Ig = 8, su = 9, Le = tr, Er = null, _l = false, Pd = false, Lg = false, Ta = 0, nn = ki, Rl = 0, El = 0, Ng = 0, rr = 0, uu = 0, wp = null, Bt = null, Pm = false, xm = 0, nb = 0, tb = 300, Pp = 1 / 0, Fg = 500, xp = null, gn = null, Il = null, zm = 0, Hg = 1, Ag = 2, rb = 3, Ll = 0, ob = 1, ab = 2, ib = 3, lb = 4, Cm = 5, Rn = 0, Nl = null, xd = null, qo = 0, jg = 0, Dg = -0, Wg = null, sb = null, ub = null, Go = zm, cb = null, Gb = 50, zp = 0, Ug = null, Bg = false, Tm = false, Jb = 50, cu = 0, Cp = null, zd = false, _m = null, db = false, fb = /* @__PURE__ */ new Set(), Zb = {}, co = null, Cd = null, pb = false;
52135
+ var bm = [], qb = typeof WeakMap == "function" ? WeakMap : Map, Jn = 0, Zn = 2, uo = 4, ki = 0, vp = 1, iu = 2, vm = 3, Tl = 4, Sm = 6, Ky = 5, ye = Jn, je = null, se = null, ae = 0, tr = 0, km = 1, lu = 2, Sp = 3, eb = 4, Eg = 5, kp = 6, wm = 7, Ig = 8, su = 9, Le = tr, Er = null, _l = false, Pd = false, Lg = false, Ta = 0, nn = ki, Rl = 0, El = 0, Ng = 0, rr = 0, uu = 0, wp = null, Bt = null, Pm = false, xm = 0, nb = 0, tb = 300, Pp = 1 / 0, Fg = 500, xp = null, gn = null, Il = null, zm = 0, Hg = 1, Ag = 2, rb = 3, Ll = 0, ob = 1, ab = 2, ib = 3, lb = 4, Cm = 5, Rn = 0, Nl = null, xd = null, qo = 0, jg = 0, Dg = -0, Wg = null, sb = null, ub = null, Go = zm, cb = null, Gb = 50, zp = 0, Ug = null, Bg = false, Tm = false, Jb = 50, cu = 0, Cp = null, zd = false, _m2 = null, db = false, fb = /* @__PURE__ */ new Set(), Zb = {}, co = null, Cd = null, pb = false;
51838
52136
  try {
51839
52137
  var o0 = Object.preventExtensions({});
51840
52138
  } catch {
@@ -52291,9 +52589,11 @@ function swapInstances() {
52291
52589
  if (parent) {
52292
52590
  var _instance$props$objec, _instance$props$args;
52293
52591
  const target = catalogue[toPascalCase(instance.type)];
52592
+ const prevObject = instance.object;
52294
52593
  instance.object = (_instance$props$objec = instance.props.object) != null ? _instance$props$objec : new target(...(_instance$props$args = instance.props.args) != null ? _instance$props$args : []);
52295
52594
  instance.object.__r3f = instance;
52296
52595
  setFiberRef(fiber, instance.object);
52596
+ swapInteractivity(findInitialRoot(instance), prevObject, instance.object);
52297
52597
  applyProps(instance.object, instance.props);
52298
52598
  if (instance.props.attach) {
52299
52599
  attach(parent, instance);
@@ -52877,8 +53177,8 @@ function createPointerEvents(store) {
52877
53177
  };
52878
53178
  }
52879
53179
  var import_scheduler, threeTypes, act2, isOrthographicCamera, isRef, isColorRepresentation, useIsomorphicLayoutEffect, ErrorBoundary, is, REACT_INTERNAL_PROPS, INDEX_REGEX, RESERVED_PROPS, MEMOIZED_PROTOTYPES, colorMaps, EVENT_REGEX, isObject3D, isRenderer, context, createStore2, memoizedLoaders, isConstructor$1, t, o2, r, e, packageData, Rm, Og, Mg, Rb, Eb, t0, r0, NoEventPriority, catalogue, PREFIX_REGEX, toPascalCase, i2, isConstructor, reconstructed, handleTextInstance, NO_CONTEXT, currentUpdatePriority, NoFlags, Update, reconciler, _roots, shallowLoose, globalEffects, globalAfterEffects, globalTailEffects, addEffect, addAfterEffect, addTail, subscribers, subscription, running, useFrameInProgress, repeat, frame, state, DOM_EVENTS;
52880
- var init_events_760a1017_esm = __esm({
52881
- "../../node_modules/.bun/@react-three+fiber@9.6.0+bae906b8c0d5d7d7/node_modules/@react-three/fiber/dist/events-760a1017.esm.js"() {
53180
+ var init_events_b389eeca_esm = __esm({
53181
+ "../../node_modules/.bun/@react-three+fiber@9.6.1+26134fee8850b5e9/node_modules/@react-three/fiber/dist/events-b389eeca.esm.js"() {
52882
53182
  init_three_module();
52883
53183
  init_traditional();
52884
53184
  init_suspend_react();
@@ -53202,7 +53502,7 @@ var init_events_760a1017_esm = __esm({
53202
53502
  e = 2;
53203
53503
  packageData = {
53204
53504
  name: "@react-three/fiber",
53205
- version: "9.6.0",
53505
+ version: "9.6.1",
53206
53506
  description: "A React renderer for Threejs",
53207
53507
  keywords: [
53208
53508
  "react",
@@ -53596,13 +53896,13 @@ function E(n) {
53596
53896
  }
53597
53897
  var k, D;
53598
53898
  var init_dist2 = __esm({
53599
- "../../node_modules/.bun/react-use-measure@2.1.7+bf16f8eded5e12ee/node_modules/react-use-measure/dist/index.js"() {
53899
+ "../../node_modules/.bun/react-use-measure@2.1.7+21ccd8898788a04d/node_modules/react-use-measure/dist/index.js"() {
53600
53900
  k = ["x", "y", "top", "bottom", "left", "right", "width", "height"];
53601
53901
  D = (n, t2) => k.every((o3) => n[o3] === t2[o3]);
53602
53902
  }
53603
53903
  });
53604
53904
 
53605
- // ../../node_modules/.bun/@react-three+fiber@9.6.0+bae906b8c0d5d7d7/node_modules/@react-three/fiber/dist/react-three-fiber.esm.js
53905
+ // ../../node_modules/.bun/@react-three+fiber@9.6.1+26134fee8850b5e9/node_modules/@react-three/fiber/dist/react-three-fiber.esm.js
53606
53906
  var react_three_fiber_esm_exports = {};
53607
53907
  __export(react_three_fiber_esm_exports, {
53608
53908
  Canvas: () => Canvas,
@@ -53771,9 +54071,9 @@ function Canvas(props) {
53771
54071
  });
53772
54072
  }
53773
54073
  var init_react_three_fiber_esm = __esm({
53774
- "../../node_modules/.bun/@react-three+fiber@9.6.0+bae906b8c0d5d7d7/node_modules/@react-three/fiber/dist/react-three-fiber.esm.js"() {
53775
- init_events_760a1017_esm();
53776
- init_events_760a1017_esm();
54074
+ "../../node_modules/.bun/@react-three+fiber@9.6.1+26134fee8850b5e9/node_modules/@react-three/fiber/dist/react-three-fiber.esm.js"() {
54075
+ init_events_b389eeca_esm();
54076
+ init_events_b389eeca_esm();
53777
54077
  init_three_module();
53778
54078
  init_dist2();
53779
54079
  init_dist();
@@ -53845,7 +54145,7 @@ function isRefObject(ref) {
53845
54145
  }
53846
54146
  var v1, v2, v3, v4, epsilon, getCameraCSSMatrix, getObjectCSSMatrix, Html;
53847
54147
  var init_Html = __esm({
53848
- "../../node_modules/.bun/@react-three+drei@10.7.7+cdb3bc7f51872c1f/node_modules/@react-three/drei/web/Html.js"() {
54148
+ "../../node_modules/.bun/@react-three+drei@10.7.7+20209eb6acc591f5/node_modules/@react-three/drei/web/Html.js"() {
53849
54149
  init_extends();
53850
54150
  init_three_module();
53851
54151
  init_react_three_fiber_esm();
@@ -54162,16 +54462,16 @@ var init_Html = __esm({
54162
54462
  }
54163
54463
  });
54164
54464
 
54165
- // ../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/_polyfill/constants.js
54465
+ // ../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/_polyfill/constants.js
54166
54466
  var version;
54167
54467
  var init_constants = __esm({
54168
- "../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/_polyfill/constants.js"() {
54468
+ "../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/_polyfill/constants.js"() {
54169
54469
  init_three_module();
54170
54470
  version = /* @__PURE__ */ (() => parseInt(REVISION.replace(/\D+/g, "")))();
54171
54471
  }
54172
54472
  });
54173
54473
 
54174
- // ../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/utils/BufferGeometryUtils.js
54474
+ // ../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/utils/BufferGeometryUtils.js
54175
54475
  function toTrianglesDrawMode(geometry, drawMode) {
54176
54476
  if (drawMode === TrianglesDrawMode) {
54177
54477
  console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.");
@@ -54231,15 +54531,15 @@ function toTrianglesDrawMode(geometry, drawMode) {
54231
54531
  }
54232
54532
  }
54233
54533
  var init_BufferGeometryUtils = __esm({
54234
- "../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/utils/BufferGeometryUtils.js"() {
54534
+ "../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/utils/BufferGeometryUtils.js"() {
54235
54535
  init_three_module();
54236
54536
  }
54237
54537
  });
54238
54538
 
54239
- // ../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/controls/EventDispatcher.js
54539
+ // ../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/controls/EventDispatcher.js
54240
54540
  var __defProp2, __defNormalProp, __publicField, EventDispatcher2;
54241
54541
  var init_EventDispatcher = __esm({
54242
- "../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/controls/EventDispatcher.js"() {
54542
+ "../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/controls/EventDispatcher.js"() {
54243
54543
  __defProp2 = Object.defineProperty;
54244
54544
  __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
54245
54545
  __publicField = (obj, key, value) => {
@@ -54316,10 +54616,10 @@ var init_EventDispatcher = __esm({
54316
54616
  }
54317
54617
  });
54318
54618
 
54319
- // ../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/controls/OrbitControls.js
54619
+ // ../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/controls/OrbitControls.js
54320
54620
  var __defProp3, __defNormalProp2, __publicField2, _ray2, _plane, TILT_LIMIT, moduloWrapAround, OrbitControls;
54321
54621
  var init_OrbitControls = __esm({
54322
- "../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/controls/OrbitControls.js"() {
54622
+ "../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/controls/OrbitControls.js"() {
54323
54623
  init_three_module();
54324
54624
  init_EventDispatcher();
54325
54625
  __defProp3 = Object.defineProperty;
@@ -55155,7 +55455,7 @@ var init_OrbitControls = __esm({
55155
55455
  }
55156
55456
  });
55157
55457
 
55158
- // ../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/_polyfill/LoaderUtils.js
55458
+ // ../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/_polyfill/LoaderUtils.js
55159
55459
  function decodeText(array) {
55160
55460
  if (typeof TextDecoder !== "undefined") {
55161
55461
  return new TextDecoder().decode(array);
@@ -55171,11 +55471,11 @@ function decodeText(array) {
55171
55471
  }
55172
55472
  }
55173
55473
  var init_LoaderUtils = __esm({
55174
- "../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/_polyfill/LoaderUtils.js"() {
55474
+ "../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/_polyfill/LoaderUtils.js"() {
55175
55475
  }
55176
55476
  });
55177
55477
 
55178
- // ../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/loaders/GLTFLoader.js
55478
+ // ../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/loaders/GLTFLoader.js
55179
55479
  function GLTFRegistry() {
55180
55480
  let objects = {};
55181
55481
  return {
@@ -55421,7 +55721,7 @@ function addPrimitiveAttributes(geometry, primitiveDef, parser) {
55421
55721
  }
55422
55722
  var SRGBColorSpace2, LinearSRGBColorSpace2, sRGBEncoding, LinearEncoding, GLTFLoader, EXTENSIONS, GLTFLightsExtension, GLTFMaterialsUnlitExtension, GLTFMaterialsEmissiveStrengthExtension, GLTFMaterialsClearcoatExtension, GLTFMaterialsDispersionExtension, GLTFMaterialsIridescenceExtension, GLTFMaterialsSheenExtension, GLTFMaterialsTransmissionExtension, GLTFMaterialsVolumeExtension, GLTFMaterialsIorExtension, GLTFMaterialsSpecularExtension, GLTFMaterialsBumpExtension, GLTFMaterialsAnisotropyExtension, GLTFTextureBasisUExtension, GLTFTextureWebPExtension, GLTFTextureAVIFExtension, GLTFMeshoptCompression, GLTFMeshGpuInstancing, BINARY_EXTENSION_HEADER_MAGIC, BINARY_EXTENSION_HEADER_LENGTH, BINARY_EXTENSION_CHUNK_TYPES, GLTFBinaryExtension, GLTFDracoMeshCompressionExtension, GLTFTextureTransformExtension, GLTFMeshQuantizationExtension, GLTFCubicSplineInterpolant, _q, GLTFCubicSplineQuaternionInterpolant, WEBGL_CONSTANTS, WEBGL_COMPONENT_TYPES, WEBGL_FILTERS, WEBGL_WRAPPINGS, WEBGL_TYPE_SIZES, ATTRIBUTES, PATH_PROPERTIES, INTERPOLATION, ALPHA_MODES, _identityMatrix2, GLTFParser;
55423
55723
  var init_GLTFLoader = __esm({
55424
- "../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/loaders/GLTFLoader.js"() {
55724
+ "../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/loaders/GLTFLoader.js"() {
55425
55725
  init_three_module();
55426
55726
  init_BufferGeometryUtils();
55427
55727
  init_constants();
@@ -57803,7 +58103,7 @@ var init_GLTFLoader = __esm({
57803
58103
  }
57804
58104
  });
57805
58105
 
57806
- // ../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/loaders/DRACOLoader.js
58106
+ // ../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/loaders/DRACOLoader.js
57807
58107
  function DRACOWorker() {
57808
58108
  let decoderConfig;
57809
58109
  let decoderPending;
@@ -57931,7 +58231,7 @@ function DRACOWorker() {
57931
58231
  }
57932
58232
  var _taskCache, DRACOLoader;
57933
58233
  var init_DRACOLoader = __esm({
57934
- "../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/loaders/DRACOLoader.js"() {
58234
+ "../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/loaders/DRACOLoader.js"() {
57935
58235
  init_three_module();
57936
58236
  _taskCache = /* @__PURE__ */ new WeakMap();
57937
58237
  DRACOLoader = class extends Loader {
@@ -58148,10 +58448,10 @@ var init_DRACOLoader = __esm({
58148
58448
  }
58149
58449
  });
58150
58450
 
58151
- // ../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/libs/MeshoptDecoder.js
58451
+ // ../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/libs/MeshoptDecoder.js
58152
58452
  var generated, MeshoptDecoder;
58153
58453
  var init_MeshoptDecoder = __esm({
58154
- "../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/libs/MeshoptDecoder.js"() {
58454
+ "../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/libs/MeshoptDecoder.js"() {
58155
58455
  MeshoptDecoder = () => {
58156
58456
  if (generated)
58157
58457
  return generated;
@@ -58372,9 +58672,9 @@ var init_MeshoptDecoder = __esm({
58372
58672
  }
58373
58673
  });
58374
58674
 
58375
- // ../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/index.js
58675
+ // ../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/index.js
58376
58676
  var init_three_stdlib = __esm({
58377
- "../../node_modules/.bun/three-stdlib@2.36.1+9459c15c9e4c81b0/node_modules/three-stdlib/index.js"() {
58677
+ "../../node_modules/.bun/three-stdlib@2.36.1+7b565cd016fb14f9/node_modules/three-stdlib/index.js"() {
58378
58678
  init_OrbitControls();
58379
58679
  init_GLTFLoader();
58380
58680
  init_DRACOLoader();
@@ -58400,7 +58700,7 @@ function extensions(useDraco = true, useMeshopt = true, extendLoader) {
58400
58700
  }
58401
58701
  var dracoLoader, decoderPath, useGLTF;
58402
58702
  var init_Gltf = __esm({
58403
- "../../node_modules/.bun/@react-three+drei@10.7.7+cdb3bc7f51872c1f/node_modules/@react-three/drei/core/Gltf.js"() {
58703
+ "../../node_modules/.bun/@react-three+drei@10.7.7+20209eb6acc591f5/node_modules/@react-three/drei/core/Gltf.js"() {
58404
58704
  init_extends();
58405
58705
  init_three_stdlib();
58406
58706
  init_react_three_fiber_esm();
@@ -58416,7 +58716,7 @@ var init_Gltf = __esm({
58416
58716
  });
58417
58717
  var OrbitControls2;
58418
58718
  var init_OrbitControls2 = __esm({
58419
- "../../node_modules/.bun/@react-three+drei@10.7.7+cdb3bc7f51872c1f/node_modules/@react-three/drei/core/OrbitControls.js"() {
58719
+ "../../node_modules/.bun/@react-three+drei@10.7.7+20209eb6acc591f5/node_modules/@react-three/drei/core/OrbitControls.js"() {
58420
58720
  init_extends();
58421
58721
  init_react_three_fiber_esm();
58422
58722
  init_three_stdlib();
@@ -58494,12 +58794,12 @@ var init_OrbitControls2 = __esm({
58494
58794
  }
58495
58795
  });
58496
58796
  var init_camera_controls_module = __esm({
58497
- "../../node_modules/.bun/camera-controls@3.1.2+9459c15c9e4c81b0/node_modules/camera-controls/dist/camera-controls.module.js"() {
58797
+ "../../node_modules/.bun/camera-controls@3.1.2+7b565cd016fb14f9/node_modules/camera-controls/dist/camera-controls.module.js"() {
58498
58798
  }
58499
58799
  });
58500
58800
  var Center;
58501
58801
  var init_Center = __esm({
58502
- "../../node_modules/.bun/@react-three+drei@10.7.7+cdb3bc7f51872c1f/node_modules/@react-three/drei/core/Center.js"() {
58802
+ "../../node_modules/.bun/@react-three+drei@10.7.7+20209eb6acc591f5/node_modules/@react-three/drei/core/Center.js"() {
58503
58803
  init_extends();
58504
58804
  init_three_module();
58505
58805
  Center = /* @__PURE__ */ React10.forwardRef(function Center2({
@@ -58564,9 +58864,9 @@ var init_Center = __esm({
58564
58864
  }
58565
58865
  });
58566
58866
 
58567
- // ../../node_modules/.bun/@react-three+drei@10.7.7+cdb3bc7f51872c1f/node_modules/@react-three/drei/index.js
58867
+ // ../../node_modules/.bun/@react-three+drei@10.7.7+20209eb6acc591f5/node_modules/@react-three/drei/index.js
58568
58868
  var init_drei = __esm({
58569
- "../../node_modules/.bun/@react-three+drei@10.7.7+cdb3bc7f51872c1f/node_modules/@react-three/drei/index.js"() {
58869
+ "../../node_modules/.bun/@react-three+drei@10.7.7+20209eb6acc591f5/node_modules/@react-three/drei/index.js"() {
58570
58870
  init_Html();
58571
58871
  init_Gltf();
58572
58872
  init_OrbitControls2();
@@ -73775,6 +74075,13 @@ function hasDistinctScriptFonts(fonts) {
73775
74075
  }
73776
74076
  return Boolean(fonts.eastAsia) && fonts.eastAsia !== base || Boolean(fonts.complexScript) && fonts.complexScript !== base || Boolean(fonts.symbol) && fonts.symbol !== base;
73777
74077
  }
74078
+ function sanitizeMathMl(markup) {
74079
+ const purify = DOMPurify;
74080
+ if (typeof purify.sanitize !== "function") {
74081
+ return markup;
74082
+ }
74083
+ return purify.sanitize(markup, { USE_PROFILES: { mathMl: true, svg: true } });
74084
+ }
73778
74085
  function renderScriptAwareText(text2, needsScriptFonts, scriptFonts, baseFontFamily, keyPrefix) {
73779
74086
  if (!needsScriptFonts || !text2) {
73780
74087
  return text2;
@@ -73865,14 +74172,15 @@ function renderSegmentContent(elementId, segmentIndex, textValue, lines, needsSc
73865
74172
  }
73866
74173
  function renderEquationSegment(elementId, segmentIndex, equationXml, equationNumber) {
73867
74174
  const mathml = convertOmmlToMathMl(equationXml);
73868
- const equationContent = mathml ? /* @__PURE__ */ jsx(
74175
+ const safeMathml = mathml ? sanitizeMathMl(mathml) : "";
74176
+ const equationContent = safeMathml ? /* @__PURE__ */ jsx(
73869
74177
  "span",
73870
74178
  {
73871
74179
  className: "inline-block align-middle",
73872
74180
  style: {
73873
74181
  fontFamily: '"Cambria Math", "STIX Two Math", serif'
73874
74182
  },
73875
- dangerouslySetInnerHTML: { __html: mathml }
74183
+ dangerouslySetInnerHTML: { __html: safeMathml }
73876
74184
  }
73877
74185
  ) : /* @__PURE__ */ jsx("span", { className: "inline-block px-1 py-0.5 rounded text-xs bg-gray-200/20 text-gray-400 italic", children: "Equation" });
73878
74186
  if (equationNumber) {
@@ -86229,7 +86537,7 @@ function ResizeHandle({
86229
86537
  }
86230
86538
  );
86231
86539
  }
86232
- function SlideThumbnail({
86540
+ function SlideThumbnailImpl({
86233
86541
  slide,
86234
86542
  templateElements,
86235
86543
  canvasSize
@@ -86467,6 +86775,37 @@ function ThumbnailTable({
86467
86775
  }
86468
86776
  return /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center text-[10px] text-muted-foreground pointer-events-none", children: "Table" });
86469
86777
  }
86778
+ function arePropsEqual(prev, next) {
86779
+ if (prev.slide.id !== next.slide.id) {
86780
+ return false;
86781
+ }
86782
+ if (prev.slide.isDirty !== next.slide.isDirty) {
86783
+ return false;
86784
+ }
86785
+ if (prev.slide.hidden !== next.slide.hidden) {
86786
+ return false;
86787
+ }
86788
+ if (prev.slide.elements !== next.slide.elements) {
86789
+ return false;
86790
+ }
86791
+ if (prev.slide.backgroundColor !== next.slide.backgroundColor) {
86792
+ return false;
86793
+ }
86794
+ if (prev.slide.backgroundImage !== next.slide.backgroundImage) {
86795
+ return false;
86796
+ }
86797
+ if (prev.slide.backgroundGradient !== next.slide.backgroundGradient) {
86798
+ return false;
86799
+ }
86800
+ if (prev.templateElements !== next.templateElements) {
86801
+ return false;
86802
+ }
86803
+ if (prev.canvasSize.width !== next.canvasSize.width || prev.canvasSize.height !== next.canvasSize.height) {
86804
+ return false;
86805
+ }
86806
+ return true;
86807
+ }
86808
+ var SlideThumbnail = React10__default.memo(SlideThumbnailImpl, arePropsEqual);
86470
86809
  function ContextMenu({
86471
86810
  contextMenuState,
86472
86811
  mode,
@@ -90200,7 +90539,7 @@ function BendingProcessRenderer({
90200
90539
  }
90201
90540
  );
90202
90541
  }
90203
- function SmartArtRenderer({
90542
+ function SmartArtRendererImpl({
90204
90543
  element: element2,
90205
90544
  className = ""
90206
90545
  }) {
@@ -90311,6 +90650,30 @@ function renderLayout(layoutType, element2, nodes, palette, style) {
90311
90650
  }
90312
90651
  return /* @__PURE__ */ jsx(ListRenderer, { element: element2, nodes, palette, style });
90313
90652
  }
90653
+ function arePropsEqual2(prev, next) {
90654
+ if (prev.className !== next.className) {
90655
+ return false;
90656
+ }
90657
+ if (prev.element.id !== next.element.id) {
90658
+ return false;
90659
+ }
90660
+ if (prev.element.type !== next.element.type) {
90661
+ return false;
90662
+ }
90663
+ if (prev.element.width !== next.element.width || prev.element.height !== next.element.height) {
90664
+ return false;
90665
+ }
90666
+ if (prev.element.x !== next.element.x || prev.element.y !== next.element.y) {
90667
+ return false;
90668
+ }
90669
+ const prevData = prev.element.type === "smartArt" ? prev.element.smartArtData : void 0;
90670
+ const nextData = next.element.type === "smartArt" ? next.element.smartArtData : void 0;
90671
+ if (prevData !== nextData) {
90672
+ return false;
90673
+ }
90674
+ return true;
90675
+ }
90676
+ var SmartArtRenderer = React10__default.memo(SmartArtRendererImpl, arePropsEqual2);
90314
90677
  function ZoomElementRenderer({
90315
90678
  element: element2,
90316
90679
  slides,
@@ -93254,7 +93617,7 @@ function SectionBlock({
93254
93617
  )
93255
93618
  ] });
93256
93619
  }
93257
- function SlideCard({
93620
+ function SlideCardImpl({
93258
93621
  slide,
93259
93622
  index,
93260
93623
  isActive,
@@ -93308,6 +93671,49 @@ function SlideCard({
93308
93671
  }
93309
93672
  );
93310
93673
  }
93674
+ function arePropsEqual3(prev, next) {
93675
+ if (prev.slide.id !== next.slide.id) {
93676
+ return false;
93677
+ }
93678
+ if (prev.slide.isDirty !== next.slide.isDirty) {
93679
+ return false;
93680
+ }
93681
+ if (prev.slide.hidden !== next.slide.hidden) {
93682
+ return false;
93683
+ }
93684
+ if (prev.slide.elements !== next.slide.elements) {
93685
+ return false;
93686
+ }
93687
+ if (prev.index !== next.index) {
93688
+ return false;
93689
+ }
93690
+ if (prev.isActive !== next.isActive) {
93691
+ return false;
93692
+ }
93693
+ if (prev.isDragTarget !== next.isDragTarget) {
93694
+ return false;
93695
+ }
93696
+ if (prev.isSelected !== next.isSelected) {
93697
+ return false;
93698
+ }
93699
+ if (prev.selectedCount !== next.selectedCount) {
93700
+ return false;
93701
+ }
93702
+ if (prev.selectionOrder !== next.selectionOrder) {
93703
+ return false;
93704
+ }
93705
+ if (prev.canEdit !== next.canEdit) {
93706
+ return false;
93707
+ }
93708
+ if (prev.canvasSize.width !== next.canvasSize.width || prev.canvasSize.height !== next.canvasSize.height) {
93709
+ return false;
93710
+ }
93711
+ if (prev.onSlideClick !== next.onSlideClick || prev.onDoubleClick !== next.onDoubleClick || prev.onContextMenu !== next.onContextMenu || prev.onDragStart !== next.onDragStart || prev.onDragOver !== next.onDragOver || prev.onDragLeave !== next.onDragLeave || prev.onDrop !== next.onDrop) {
93712
+ return false;
93713
+ }
93714
+ return true;
93715
+ }
93716
+ var SlideCard = React10__default.memo(SlideCardImpl, arePropsEqual3);
93311
93717
  function SorterContextMenu({
93312
93718
  x: x2,
93313
93719
  y,
@@ -94101,6 +94507,14 @@ function getCurrentParagraphIndex(editorEl, segments) {
94101
94507
  }
94102
94508
  return paraIdx;
94103
94509
  }
94510
+ var CSS_VALUE_SAFE = /^[a-zA-Z0-9 _,.\-+#'%/]{1,100}$/;
94511
+ function isCssValueSafe(value) {
94512
+ if (value === void 0 || value === null) {
94513
+ return false;
94514
+ }
94515
+ const str = String(value);
94516
+ return str.length > 0 && CSS_VALUE_SAFE.test(str);
94517
+ }
94104
94518
  function deriveStyleFromElement(element2, inheritedStyle) {
94105
94519
  const style = { ...inheritedStyle };
94106
94520
  const tagName = element2.tagName.toLowerCase();
@@ -94233,17 +94647,17 @@ function segmentsToEditorHtml(segments) {
94233
94647
  if (segment.style.strikethrough) {
94234
94648
  inlineStyles.push("text-decoration:line-through");
94235
94649
  }
94236
- if (segment.style.color) {
94650
+ if (segment.style.color && isCssValueSafe(segment.style.color)) {
94237
94651
  inlineStyles.push(`color:${segment.style.color}`);
94238
94652
  }
94239
- if (segment.style.fontSize) {
94240
- inlineStyles.push(`font-size:${segment.style.fontSize}pt`);
94653
+ if (segment.style.fontSize && Number.isFinite(Number(segment.style.fontSize))) {
94654
+ inlineStyles.push(`font-size:${Number(segment.style.fontSize)}pt`);
94241
94655
  }
94242
- if (segment.style.fontFamily) {
94656
+ if (segment.style.fontFamily && isCssValueSafe(segment.style.fontFamily)) {
94243
94657
  inlineStyles.push(`font-family:${segment.style.fontFamily}`);
94244
94658
  }
94245
94659
  const text2 = escapeHtml(segment.text);
94246
- if (segment.style.hyperlink) {
94660
+ if (segment.style.hyperlink && isUrlSafe(segment.style.hyperlink)) {
94247
94661
  const href = escapeHtml(segment.style.hyperlink);
94248
94662
  return `<a href="${href}" style="color:#4a9eff;text-decoration:underline;cursor:pointer" data-hyperlink="${href}">${text2}</a>`;
94249
94663
  }
@@ -94326,7 +94740,8 @@ function renderRichNotesSegments(segments) {
94326
94740
  if (segment.style.fontFamily) {
94327
94741
  style.fontFamily = segment.style.fontFamily;
94328
94742
  }
94329
- if (segment.style.hyperlink) {
94743
+ if (segment.style.hyperlink && isUrlSafe(segment.style.hyperlink)) {
94744
+ const safeHref = segment.style.hyperlink;
94330
94745
  style.color = "#4a9eff";
94331
94746
  style.textDecoration = "underline";
94332
94747
  style.cursor = "pointer";
@@ -94334,11 +94749,11 @@ function renderRichNotesSegments(segments) {
94334
94749
  /* @__PURE__ */ jsx(
94335
94750
  "a",
94336
94751
  {
94337
- href: segment.style.hyperlink,
94752
+ href: safeHref,
94338
94753
  style,
94339
94754
  onClick: (e2) => {
94340
94755
  e2.preventDefault();
94341
- window.open(segment.style.hyperlink, "_blank");
94756
+ safeOpenUrl(safeHref);
94342
94757
  },
94343
94758
  children: segment.text
94344
94759
  },
@@ -94890,7 +95305,7 @@ function useSlideNotes({
94890
95305
  const href = target.getAttribute("data-hyperlink") || target.getAttribute("href");
94891
95306
  if (href && (e2.ctrlKey || e2.metaKey)) {
94892
95307
  e2.preventDefault();
94893
- window.open(href, "_blank");
95308
+ safeOpenUrl(href);
94894
95309
  }
94895
95310
  }, []);
94896
95311
  return {
@@ -96563,7 +96978,7 @@ function renderNotesSegments(segments) {
96563
96978
  return React10__default.createElement("span", { key: `seg-${index}`, style }, segment.text);
96564
96979
  });
96565
96980
  }
96566
- function ScaledSlidePreview({
96981
+ function ScaledSlidePreviewImpl({
96567
96982
  slide,
96568
96983
  templateElements,
96569
96984
  canvasSize,
@@ -96710,6 +97125,40 @@ function ScaledSlidePreview({
96710
97125
  }
96711
97126
  );
96712
97127
  }
97128
+ function arePropsEqual4(prev, next) {
97129
+ if (prev.slide.id !== next.slide.id) {
97130
+ return false;
97131
+ }
97132
+ if (prev.slide.isDirty !== next.slide.isDirty) {
97133
+ return false;
97134
+ }
97135
+ if (prev.slide.hidden !== next.slide.hidden) {
97136
+ return false;
97137
+ }
97138
+ if (prev.slide.elements !== next.slide.elements) {
97139
+ return false;
97140
+ }
97141
+ if (prev.slide.backgroundColor !== next.slide.backgroundColor) {
97142
+ return false;
97143
+ }
97144
+ if (prev.slide.backgroundImage !== next.slide.backgroundImage) {
97145
+ return false;
97146
+ }
97147
+ if (prev.slide.backgroundGradient !== next.slide.backgroundGradient) {
97148
+ return false;
97149
+ }
97150
+ if (prev.templateElements !== next.templateElements) {
97151
+ return false;
97152
+ }
97153
+ if (prev.canvasSize.width !== next.canvasSize.width || prev.canvasSize.height !== next.canvasSize.height) {
97154
+ return false;
97155
+ }
97156
+ if (prev.className !== next.className) {
97157
+ return false;
97158
+ }
97159
+ return true;
97160
+ }
97161
+ var ScaledSlidePreview = React10__default.memo(ScaledSlidePreviewImpl, arePropsEqual4);
96713
97162
  function PresenterView({
96714
97163
  slides,
96715
97164
  currentSlideIndex,
@@ -111013,6 +111462,13 @@ function convertOmmlToLatex(omml) {
111013
111462
  }
111014
111463
  return ommlChildrenToLatex(oMath);
111015
111464
  }
111465
+ function sanitizeMathMl2(markup) {
111466
+ const purify = DOMPurify;
111467
+ if (typeof purify.sanitize !== "function") {
111468
+ return markup;
111469
+ }
111470
+ return purify.sanitize(markup, { USE_PROFILES: { mathMl: true, svg: true } });
111471
+ }
111016
111472
  var TEMPLATES = [
111017
111473
  {
111018
111474
  label: "Fraction",
@@ -111078,7 +111534,8 @@ var TEMPLATES = [
111078
111534
  var TEMPLATE_MATHML = TEMPLATES.map((tmpl) => {
111079
111535
  try {
111080
111536
  const tmplOmml = convertLatexToOmml(tmpl.latex);
111081
- return convertOmmlToMathMl(tmplOmml);
111537
+ const raw = convertOmmlToMathMl(tmplOmml);
111538
+ return raw ? sanitizeMathMl2(raw) : "";
111082
111539
  } catch {
111083
111540
  return "";
111084
111541
  }
@@ -111090,7 +111547,7 @@ function MathMlPreview({ mathml }) {
111090
111547
  return;
111091
111548
  }
111092
111549
  if (mathml) {
111093
- containerRef.current.innerHTML = mathml;
111550
+ containerRef.current.innerHTML = sanitizeMathMl2(mathml);
111094
111551
  } else {
111095
111552
  containerRef.current.innerHTML = "";
111096
111553
  }
@@ -111118,6 +111575,7 @@ function EquationEditorDialog({
111118
111575
  return convertOmmlToLatex(existingOmml);
111119
111576
  }, [existingOmml]);
111120
111577
  const [latex, setLatex] = useState(initialLatex);
111578
+ const deferredLatex = useDeferredValue(latex);
111121
111579
  const textareaRef = useRef(null);
111122
111580
  useEffect(() => {
111123
111581
  if (isOpen) {
@@ -111126,17 +111584,17 @@ function EquationEditorDialog({
111126
111584
  }
111127
111585
  }, [isOpen, initialLatex]);
111128
111586
  const { mathml, omml } = useMemo(() => {
111129
- if (!latex.trim()) {
111587
+ if (!deferredLatex.trim()) {
111130
111588
  return { mathml: "", omml: {} };
111131
111589
  }
111132
111590
  try {
111133
- const ommlObj = convertLatexToOmml(latex);
111591
+ const ommlObj = convertLatexToOmml(deferredLatex);
111134
111592
  const mathmlStr = convertOmmlToMathMl(ommlObj);
111135
111593
  return { mathml: mathmlStr, omml: ommlObj };
111136
111594
  } catch {
111137
111595
  return { mathml: "", omml: {} };
111138
111596
  }
111139
- }, [latex]);
111597
+ }, [deferredLatex]);
111140
111598
  const handleInsert = useCallback(() => {
111141
111599
  if (!latex.trim()) {
111142
111600
  return;
@@ -113871,6 +114329,7 @@ function useEditorHistory(input) {
113871
114329
  const historyFutureRef = useRef([]);
113872
114330
  const lastHistorySnapshotRef = useRef(null);
113873
114331
  const lastHistorySerializedRef = useRef("");
114332
+ const lastCheapHashRef = useRef("");
113874
114333
  const isApplyingHistoryRef = useRef(false);
113875
114334
  const unlockHistoryTimerRef = useRef(null);
113876
114335
  const [canUndo, setCanUndo] = useState(false);
@@ -114012,15 +114471,21 @@ function useEditorHistory(input) {
114012
114471
  if (hasActivePointerInteraction()) {
114013
114472
  return;
114014
114473
  }
114474
+ const cheapHash = `${slides.length}|${activeSlideIndex}|${canvasSize.width}x${canvasSize.height}|${slides.map((s) => `${s.id}:${s.elements.length}`).join("/")}`;
114475
+ if (cheapHash === lastCheapHashRef.current) {
114476
+ return;
114477
+ }
114015
114478
  const snapshot2 = buildHistorySnapshot();
114016
114479
  const serialized = JSON.stringify(snapshot2);
114017
114480
  if (serialized === lastHistorySerializedRef.current) {
114481
+ lastCheapHashRef.current = cheapHash;
114018
114482
  return;
114019
114483
  }
114020
114484
  const previousSnapshot = lastHistorySnapshotRef.current;
114021
114485
  if (!previousSnapshot) {
114022
114486
  lastHistorySnapshotRef.current = cloneHistorySnapshot(snapshot2);
114023
114487
  lastHistorySerializedRef.current = serialized;
114488
+ lastCheapHashRef.current = cheapHash;
114024
114489
  updateHistoryAvailability();
114025
114490
  return;
114026
114491
  }
@@ -114031,13 +114496,18 @@ function useEditorHistory(input) {
114031
114496
  historyFutureRef.current = [];
114032
114497
  lastHistorySnapshotRef.current = cloneHistorySnapshot(snapshot2);
114033
114498
  lastHistorySerializedRef.current = serialized;
114499
+ lastCheapHashRef.current = cheapHash;
114034
114500
  updateHistoryAvailability();
114035
114501
  }, [
114502
+ activeSlideIndex,
114036
114503
  buildHistorySnapshot,
114504
+ canvasSize.height,
114505
+ canvasSize.width,
114037
114506
  error2,
114038
114507
  hasActivePointerInteraction,
114039
114508
  loading2,
114040
114509
  pointerCommitNonce,
114510
+ slides,
114041
114511
  updateHistoryAvailability
114042
114512
  ]);
114043
114513
  return {
@@ -117749,7 +118219,8 @@ async function storeAudienceContent(content) {
117749
118219
  const tx = db.transaction(STORE_NAME2, "readwrite");
117750
118220
  const store = tx.objectStore(STORE_NAME2);
117751
118221
  const bytes = content instanceof Uint8Array ? content : new Uint8Array(content);
117752
- store.put(bytes, CONTENT_KEY);
118222
+ const record = { bytes, createdAt: Date.now() };
118223
+ store.put(record, CONTENT_KEY);
117753
118224
  tx.oncomplete = () => {
117754
118225
  db.close();
117755
118226
  resolve2();
@@ -117782,14 +118253,34 @@ async function clearAudienceContent() {
117782
118253
  var PRESENTER_CHANNEL_NAME = "pptx-viewer-presenter";
117783
118254
  var AUDIENCE_HASH = "#pptx-audience";
117784
118255
  var PRESENTER_MSG_ORIGIN = "pptx-viewer-presenter";
118256
+ var AUDIENCE_NONCE_KEY = "nonce";
118257
+ function generateSessionId() {
118258
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
118259
+ return crypto.randomUUID();
118260
+ }
118261
+ return `s${Date.now().toString(36)}${Math.random().toString(36).slice(2, 10)}`;
118262
+ }
118263
+ function parseAudienceNonce() {
118264
+ const hash = window.location.hash;
118265
+ if (!hash.startsWith(AUDIENCE_HASH)) {
118266
+ return null;
118267
+ }
118268
+ const trailing = hash.slice(AUDIENCE_HASH.length);
118269
+ if (!trailing) {
118270
+ return null;
118271
+ }
118272
+ const params2 = new URLSearchParams(trailing.replace(/^[&;?]/, ""));
118273
+ return params2.get(AUDIENCE_NONCE_KEY);
118274
+ }
117785
118275
  function isAudienceTab() {
117786
- return window.location.hash === AUDIENCE_HASH;
118276
+ return window.location.hash.startsWith(AUDIENCE_HASH);
117787
118277
  }
117788
118278
  function usePresenterWindow(input) {
117789
118279
  const { currentSlideIndex, isPresenterMode, content } = input;
117790
118280
  const audienceWindowRef = useRef(null);
117791
118281
  const channelRef = useRef(null);
117792
118282
  const pollTimerRef = useRef(null);
118283
+ const sessionIdRef = useRef("");
117793
118284
  const getChannel2 = useCallback(() => {
117794
118285
  if (!channelRef.current) {
117795
118286
  channelRef.current = new BroadcastChannel(PRESENTER_CHANNEL_NAME);
@@ -117801,10 +118292,14 @@ function usePresenterWindow(input) {
117801
118292
  }, []);
117802
118293
  const syncSlideToAudience = useCallback(
117803
118294
  (slideIndex) => {
118295
+ if (!sessionIdRef.current) {
118296
+ return;
118297
+ }
117804
118298
  const msg = {
117805
118299
  origin: PRESENTER_MSG_ORIGIN,
117806
118300
  type: "presenter-slide-change",
117807
- slideIndex
118301
+ slideIndex,
118302
+ sessionId: sessionIdRef.current
117808
118303
  };
117809
118304
  try {
117810
118305
  getChannel2().postMessage(msg);
@@ -117814,13 +118309,16 @@ function usePresenterWindow(input) {
117814
118309
  [getChannel2]
117815
118310
  );
117816
118311
  const closeAudienceWindow = useCallback(() => {
117817
- try {
117818
- const exitMsg = {
117819
- origin: PRESENTER_MSG_ORIGIN,
117820
- type: "presenter-exit"
117821
- };
117822
- getChannel2().postMessage(exitMsg);
117823
- } catch {
118312
+ if (sessionIdRef.current) {
118313
+ try {
118314
+ const exitMsg = {
118315
+ origin: PRESENTER_MSG_ORIGIN,
118316
+ type: "presenter-exit",
118317
+ sessionId: sessionIdRef.current
118318
+ };
118319
+ getChannel2().postMessage(exitMsg);
118320
+ } catch {
118321
+ }
117824
118322
  }
117825
118323
  const win = audienceWindowRef.current;
117826
118324
  if (win && !win.closed) {
@@ -117830,6 +118328,7 @@ function usePresenterWindow(input) {
117830
118328
  }
117831
118329
  }
117832
118330
  audienceWindowRef.current = null;
118331
+ sessionIdRef.current = "";
117833
118332
  if (pollTimerRef.current !== null) {
117834
118333
  clearInterval(pollTimerRef.current);
117835
118334
  pollTimerRef.current = null;
@@ -117840,20 +118339,53 @@ function usePresenterWindow(input) {
117840
118339
  if (isAudienceWindowOpen()) {
117841
118340
  closeAudienceWindow();
117842
118341
  }
117843
- if (content) {
117844
- void storeAudienceContent(content);
117845
- }
117846
- const url = new URL(window.location.href);
117847
- url.hash = AUDIENCE_HASH;
117848
- const win = window.open(url.toString(), "_blank");
117849
- if (!win) {
118342
+ const blankWin = window.open("about:blank", "_blank");
118343
+ if (!blankWin) {
117850
118344
  return false;
117851
118345
  }
117852
- audienceWindowRef.current = win;
118346
+ audienceWindowRef.current = blankWin;
118347
+ const sessionId = generateSessionId();
118348
+ sessionIdRef.current = sessionId;
118349
+ const audienceUrl = new URL(window.location.href);
118350
+ const params2 = new URLSearchParams();
118351
+ params2.set(AUDIENCE_NONCE_KEY, sessionId);
118352
+ audienceUrl.hash = `${AUDIENCE_HASH}&${params2.toString()}`;
118353
+ const navigateOrClose = (ok) => {
118354
+ const win = audienceWindowRef.current;
118355
+ if (!win || win.closed) {
118356
+ return;
118357
+ }
118358
+ if (!ok) {
118359
+ try {
118360
+ win.close();
118361
+ } catch {
118362
+ }
118363
+ audienceWindowRef.current = null;
118364
+ sessionIdRef.current = "";
118365
+ return;
118366
+ }
118367
+ try {
118368
+ win.location.replace(audienceUrl.toString());
118369
+ } catch {
118370
+ try {
118371
+ win.close();
118372
+ } catch {
118373
+ }
118374
+ audienceWindowRef.current = null;
118375
+ sessionIdRef.current = "";
118376
+ }
118377
+ };
118378
+ if (content) {
118379
+ void storeAudienceContent(content).then(() => navigateOrClose(true)).catch(() => navigateOrClose(false));
118380
+ } else {
118381
+ navigateOrClose(true);
118382
+ }
117853
118383
  window.setTimeout(() => syncSlideToAudience(currentSlideIndex), 1500);
117854
118384
  pollTimerRef.current = setInterval(() => {
117855
- if (win.closed) {
118385
+ const win = audienceWindowRef.current;
118386
+ if (!win || win.closed) {
117856
118387
  audienceWindowRef.current = null;
118388
+ sessionIdRef.current = "";
117857
118389
  if (pollTimerRef.current !== null) {
117858
118390
  clearInterval(pollTimerRef.current);
117859
118391
  pollTimerRef.current = null;
@@ -117881,6 +118413,13 @@ function usePresenterWindow(input) {
117881
118413
  closeAudienceWindow();
117882
118414
  }
117883
118415
  }, [isPresenterMode, closeAudienceWindow]);
118416
+ useEffect(() => {
118417
+ const handleBeforeUnload = () => {
118418
+ void clearAudienceContent();
118419
+ };
118420
+ window.addEventListener("beforeunload", handleBeforeUnload);
118421
+ return () => window.removeEventListener("beforeunload", handleBeforeUnload);
118422
+ }, []);
117884
118423
  return {
117885
118424
  openAudienceWindow,
117886
118425
  closeAudienceWindow,
@@ -117918,6 +118457,7 @@ function useAudienceMode(input) {
117918
118457
  if (!isAudienceTab()) {
117919
118458
  return;
117920
118459
  }
118460
+ const expectedSessionId = parseAudienceNonce();
117921
118461
  let channel;
117922
118462
  try {
117923
118463
  channel = new BroadcastChannel(PRESENTER_CHANNEL_NAME);
@@ -117929,6 +118469,9 @@ function useAudienceMode(input) {
117929
118469
  if (!data || data.origin !== PRESENTER_MSG_ORIGIN) {
117930
118470
  return;
117931
118471
  }
118472
+ if (expectedSessionId && data.sessionId !== expectedSessionId) {
118473
+ return;
118474
+ }
117932
118475
  if (data.type === "presenter-slide-change") {
117933
118476
  onSetActiveSlideIndex(data.slideIndex);
117934
118477
  }
@@ -118862,6 +119405,12 @@ function useTouchGestures(input) {
118862
119405
  callbacksRef.current = callbacks;
118863
119406
  const scaleRef = useRef(currentScale);
118864
119407
  scaleRef.current = currentScale;
119408
+ const [targetVersion, setTargetVersion] = useState(0);
119409
+ const lastTargetRef = useRef(null);
119410
+ if (targetRef.current !== lastTargetRef.current) {
119411
+ lastTargetRef.current = targetRef.current;
119412
+ queueMicrotask(() => setTargetVersion((v) => v + 1));
119413
+ }
118865
119414
  useEffect(() => {
118866
119415
  const el = targetRef.current;
118867
119416
  if (!el || !enabled) {
@@ -118950,7 +119499,7 @@ function useTouchGestures(input) {
118950
119499
  el.removeEventListener("touchcancel", handleTouchCancel);
118951
119500
  cancelLongPress();
118952
119501
  };
118953
- }, [targetRef, enabled]);
119502
+ }, [targetRef, enabled, targetVersion]);
118954
119503
  }
118955
119504
 
118956
119505
  // src/viewer/utils/dom-helpers.ts
@@ -118971,11 +119520,31 @@ function safeConfirm(message) {
118971
119520
  return false;
118972
119521
  }
118973
119522
  }
119523
+ function sanitizeDownloadFilename(input) {
119524
+ if (typeof input !== "string" || input.trim().length === 0) {
119525
+ return "presentation.pptx";
119526
+ }
119527
+ let cleaned = input.replace(/[\x00-\x1f\x7f"\\/:*?<>|]/g, "_").replace(/\.\./g, "__").replace(/^\.+/, "").trim();
119528
+ if (cleaned.length === 0) {
119529
+ return "presentation.pptx";
119530
+ }
119531
+ if (cleaned.length > 200) {
119532
+ const dot = cleaned.lastIndexOf(".");
119533
+ if (dot > 0 && cleaned.length - dot <= 16) {
119534
+ const ext = cleaned.slice(dot);
119535
+ cleaned = cleaned.slice(0, 200 - ext.length) + ext;
119536
+ } else {
119537
+ cleaned = cleaned.slice(0, 200);
119538
+ }
119539
+ }
119540
+ return cleaned;
119541
+ }
118974
119542
  function downloadBlob(blob, filename) {
119543
+ const safeName = sanitizeDownloadFilename(filename);
118975
119544
  const url = URL.createObjectURL(blob);
118976
119545
  const a2 = document.createElement("a");
118977
119546
  a2.href = url;
118978
- a2.download = filename;
119547
+ a2.download = safeName;
118979
119548
  document.body.appendChild(a2);
118980
119549
  a2.click();
118981
119550
  setTimeout(() => {
@@ -119406,27 +119975,82 @@ function openAutosaveDb2() {
119406
119975
  req.onerror = () => reject(req.error);
119407
119976
  });
119408
119977
  }
119409
- async function saveToIndexedDb(filePath, data) {
119978
+ async function deleteOldestAutosaveEntry() {
119410
119979
  const db = await openAutosaveDb2();
119411
- return new Promise((resolve2, reject) => {
119412
- const tx = db.transaction(STORE_NAME3, "readwrite");
119413
- const store = tx.objectStore(STORE_NAME3);
119414
- store.put({
119415
- key: filePath,
119416
- data,
119417
- timestamp: Date.now(),
119418
- size: data.byteLength
119419
- });
119420
- tx.oncomplete = () => {
119421
- db.close();
119422
- resolve2(true);
119423
- };
119424
- tx.onerror = () => {
119425
- db.close();
119426
- reject(tx.error);
119427
- };
119980
+ return new Promise((resolve2) => {
119981
+ try {
119982
+ const tx = db.transaction(STORE_NAME3, "readwrite");
119983
+ const store = tx.objectStore(STORE_NAME3);
119984
+ let oldestKey = null;
119985
+ let oldestTimestamp = Infinity;
119986
+ const cursorReq = store.openCursor();
119987
+ cursorReq.onsuccess = () => {
119988
+ const cursor = cursorReq.result;
119989
+ if (cursor) {
119990
+ const value = cursor.value;
119991
+ if (typeof value.timestamp === "number" && value.timestamp < oldestTimestamp) {
119992
+ oldestTimestamp = value.timestamp;
119993
+ oldestKey = cursor.primaryKey;
119994
+ }
119995
+ cursor.continue();
119996
+ } else if (oldestKey !== null) {
119997
+ store.delete(oldestKey);
119998
+ }
119999
+ };
120000
+ tx.oncomplete = () => {
120001
+ db.close();
120002
+ resolve2(oldestKey !== null);
120003
+ };
120004
+ tx.onerror = () => {
120005
+ db.close();
120006
+ resolve2(false);
120007
+ };
120008
+ } catch {
120009
+ try {
120010
+ db.close();
120011
+ } catch {
120012
+ }
120013
+ resolve2(false);
120014
+ }
119428
120015
  });
119429
120016
  }
120017
+ function putAutosaveRecord(filePath, data) {
120018
+ return openAutosaveDb2().then(
120019
+ (db) => new Promise((resolve2, reject) => {
120020
+ const tx = db.transaction(STORE_NAME3, "readwrite");
120021
+ const store = tx.objectStore(STORE_NAME3);
120022
+ store.put({
120023
+ key: filePath,
120024
+ data,
120025
+ timestamp: Date.now(),
120026
+ size: data.byteLength
120027
+ });
120028
+ tx.oncomplete = () => {
120029
+ db.close();
120030
+ resolve2(true);
120031
+ };
120032
+ tx.onerror = () => {
120033
+ db.close();
120034
+ reject(tx.error);
120035
+ };
120036
+ })
120037
+ );
120038
+ }
120039
+ async function saveToIndexedDb(filePath, data) {
120040
+ try {
120041
+ return await putAutosaveRecord(filePath, data);
120042
+ } catch (err) {
120043
+ const errName = err instanceof Error || err instanceof DOMException ? err.name : "";
120044
+ if (errName !== "QuotaExceededError") {
120045
+ throw err;
120046
+ }
120047
+ const deleted = await deleteOldestAutosaveEntry();
120048
+ if (!deleted) {
120049
+ throw err;
120050
+ }
120051
+ return putAutosaveRecord(filePath, data);
120052
+ }
120053
+ }
119430
120054
  function useAutosave(input) {
119431
120055
  const {
119432
120056
  isDirty,
@@ -119543,6 +120167,25 @@ function collectReferencedFontFamilies(slides) {
119543
120167
  }
119544
120168
  return families;
119545
120169
  }
120170
+ var FONT_NAME_UNSAFE_CHARS = /["\\\n\r;}<>]/;
120171
+ var FONT_FORMAT_ALLOWED = /* @__PURE__ */ new Set([
120172
+ "truetype",
120173
+ "opentype",
120174
+ "woff",
120175
+ "woff2",
120176
+ "svg",
120177
+ "embedded-opentype"
120178
+ ]);
120179
+ var FONT_DATA_URL_PATTERN = /^data:font\/[a-z0-9+.-]+(?:;charset=[a-z0-9-]+)?;base64,[A-Za-z0-9+/=]+$/i;
120180
+ function isFontDataUrlSafe(url) {
120181
+ if (typeof url !== "string" || url.length === 0) {
120182
+ return false;
120183
+ }
120184
+ if (url.startsWith("blob:")) {
120185
+ return true;
120186
+ }
120187
+ return FONT_DATA_URL_PATTERN.test(url);
120188
+ }
119546
120189
  function useFontInjection({ embeddedFonts, slides }) {
119547
120190
  useEffect(() => {
119548
120191
  if (!embeddedFonts.length) {
@@ -119550,17 +120193,28 @@ function useFontInjection({ embeddedFonts, slides }) {
119550
120193
  }
119551
120194
  const styleEl = document.createElement("style");
119552
120195
  styleEl.id = EMBEDDED_FONTS_STYLE_ID;
119553
- const cssRules = embeddedFonts.map((font) => {
120196
+ const cssRules = embeddedFonts.flatMap((font) => {
120197
+ if (typeof font.name !== "string" || font.name.length === 0 || FONT_NAME_UNSAFE_CHARS.test(font.name)) {
120198
+ return [];
120199
+ }
120200
+ if (!isFontDataUrlSafe(font.dataUrl)) {
120201
+ return [];
120202
+ }
120203
+ const fontFormat = font.format ?? "truetype";
120204
+ if (!FONT_FORMAT_ALLOWED.has(fontFormat)) {
120205
+ return [];
120206
+ }
119554
120207
  const fontWeight = font.bold ? "700" : "400";
119555
120208
  const fontStyleCss = font.italic ? "italic" : "normal";
119556
- const fontFormat = font.format ?? "truetype";
119557
- return `@font-face {
120209
+ return [
120210
+ `@font-face {
119558
120211
  font-family: "${font.name}";
119559
120212
  src: url("${font.dataUrl}") format("${fontFormat}");
119560
120213
  font-weight: ${fontWeight};
119561
120214
  font-style: ${fontStyleCss};
119562
120215
  font-display: swap;
119563
- }`;
120216
+ }`
120217
+ ];
119564
120218
  }).join("\n");
119565
120219
  styleEl.textContent = cssRules;
119566
120220
  document.head.appendChild(styleEl);
@@ -119589,7 +120243,7 @@ function useFontInjection({ embeddedFonts, slides }) {
119589
120243
  const linkEl = document.createElement("link");
119590
120244
  linkEl.id = GOOGLE_FONTS_LINK_ID;
119591
120245
  linkEl.rel = "stylesheet";
119592
- linkEl.href = `https://fonts.googleapis.com/css2?${googleFamilies.map((f) => `family=${GOOGLE_FONTS_AVAILABLE[f]}`).join("&")}&display=swap`;
120246
+ linkEl.href = `https://fonts.googleapis.com/css2?${googleFamilies.map((f) => `family=${encodeURIComponent(GOOGLE_FONTS_AVAILABLE[f])}`).join("&")}&display=swap`;
119593
120247
  document.head.appendChild(linkEl);
119594
120248
  return () => {
119595
120249
  const existing = document.getElementById(GOOGLE_FONTS_LINK_ID);
@@ -119605,13 +120259,18 @@ function useFontInjection({ embeddedFonts, slides }) {
119605
120259
  }
119606
120260
  const styleEl = document.createElement("style");
119607
120261
  styleEl.id = SYMBOL_FONTS_STYLE_ID;
119608
- const rules = neededSymbolFonts.map(
119609
- (font) => `@font-face {
120262
+ const rules = neededSymbolFonts.flatMap((font) => {
120263
+ if (typeof font !== "string" || FONT_NAME_UNSAFE_CHARS.test(font)) {
120264
+ return [];
120265
+ }
120266
+ return [
120267
+ `@font-face {
119610
120268
  font-family: "${font}";
119611
120269
  src: local("${font}"), local("${font} Regular");
119612
120270
  font-display: swap;
119613
120271
  }`
119614
- ).join("\n");
120272
+ ];
120273
+ }).join("\n");
119615
120274
  styleEl.textContent = rules;
119616
120275
  document.head.appendChild(styleEl);
119617
120276
  return () => {
@@ -119754,16 +120413,17 @@ function useLoadContent({
119754
120413
  `[pptx] Large file detected (${fileSizeMB.toFixed(1)} MB). Loading may use significant memory.`
119755
120414
  );
119756
120415
  }
119757
- if (handlerRef.current) {
119758
- handlerRef.current.dispose();
119759
- handlerRef.current = null;
119760
- }
120416
+ const previousHandler = handlerRef.current;
119761
120417
  const handler = new PptxHandler();
119762
120418
  const parsed = await handler.load(buffer);
119763
120419
  if (cancelled || token !== renderTokenRef.current) {
119764
120420
  handler.dispose();
119765
120421
  return;
119766
120422
  }
120423
+ if (previousHandler) {
120424
+ previousHandler.dispose();
120425
+ }
120426
+ handlerRef.current = null;
119767
120427
  const mediaElements = [];
119768
120428
  for (const slide of parsed.slides) {
119769
120429
  collectMediaElements(slide.elements, mediaElements);
@@ -119808,6 +120468,7 @@ function useLoadContent({
119808
120468
  })
119809
120469
  );
119810
120470
  const { paths: imagePaths, refs: imageRefs } = collectImagePaths(parsed.slides);
120471
+ let nextSlides = parsed.slides;
119811
120472
  if (imagePaths.size > 0) {
119812
120473
  const resolvedMap = /* @__PURE__ */ new Map();
119813
120474
  await Promise.all(
@@ -119821,15 +120482,47 @@ function useLoadContent({
119821
120482
  }
119822
120483
  })
119823
120484
  );
120485
+ const elementPatches = /* @__PURE__ */ new Map();
119824
120486
  for (const ref of imageRefs) {
119825
120487
  const url = resolvedMap.get(ref.path);
119826
- if (url) {
119827
- ref.element[ref.field] = url;
120488
+ if (!url) {
120489
+ continue;
119828
120490
  }
120491
+ const id2 = ref.element.id;
120492
+ const existing = elementPatches.get(id2) ?? {};
120493
+ existing[ref.field] = url;
120494
+ elementPatches.set(id2, existing);
120495
+ }
120496
+ if (elementPatches.size > 0) {
120497
+ const patchElements = (elements) => {
120498
+ let mutated = false;
120499
+ const next = elements.map((el) => {
120500
+ let updated = el;
120501
+ const patch = elementPatches.get(el.id);
120502
+ if (patch) {
120503
+ updated = { ...el, ...patch };
120504
+ }
120505
+ if (updated.type === "group" && updated.children?.length) {
120506
+ const newChildren = patchElements(updated.children);
120507
+ if (newChildren !== updated.children) {
120508
+ updated = { ...updated, children: newChildren };
120509
+ }
120510
+ }
120511
+ if (updated !== el) {
120512
+ mutated = true;
120513
+ }
120514
+ return updated;
120515
+ });
120516
+ return mutated ? next : elements;
120517
+ };
120518
+ nextSlides = parsed.slides.map((s) => {
120519
+ const newElements = patchElements(s.elements);
120520
+ return newElements === s.elements ? s : { ...s, elements: newElements };
120521
+ });
119829
120522
  }
119830
120523
  }
119831
120524
  handlerRef.current = handler;
119832
- setSlides(parsed.slides);
120525
+ setSlides(nextSlides);
119833
120526
  setTemplateElementsBySlideId({});
119834
120527
  setCanvasSize({
119835
120528
  width: parsed.width ?? DEFAULT_CANVAS_WIDTH,
@@ -121003,7 +121696,19 @@ function injectFontFaces(svg, fontFaces) {
121003
121696
  if (!fontFaces.length) {
121004
121697
  return svg;
121005
121698
  }
121006
- const styleBlock = `<style type="text/css">${fontFaces.map((f) => f.css).join("\n")}</style>`;
121699
+ const safeFontFaces = fontFaces.filter((f) => {
121700
+ if (f.css.toLowerCase().includes("</style")) {
121701
+ console.warn(
121702
+ `[export-svg] Dropping @font-face entry for "${f.family}" containing "</style" \u2014 would break out of the <style> block.`
121703
+ );
121704
+ return false;
121705
+ }
121706
+ return true;
121707
+ });
121708
+ if (!safeFontFaces.length) {
121709
+ return svg;
121710
+ }
121711
+ const styleBlock = `<style type="text/css">${safeFontFaces.map((f) => f.css).join("\n")}</style>`;
121007
121712
  if (svg.includes("<defs>")) {
121008
121713
  return svg.replace("<defs>", `<defs>${styleBlock}`);
121009
121714
  }
@@ -121329,7 +122034,7 @@ function useExportHandlers(input) {
121329
122034
  activeSlideIndexForGuides,
121330
122035
  modalControls
121331
122036
  });
121332
- const handleExportPng = async () => {
122037
+ const handleExportPng = useCallback(async () => {
121333
122038
  const stageEl = canvasStageRef.current;
121334
122039
  if (!stageEl) {
121335
122040
  return;
@@ -121341,8 +122046,8 @@ function useExportHandlers(input) {
121341
122046
  } catch (err) {
121342
122047
  console.error("[PowerPointViewer] PNG export failed:", err);
121343
122048
  }
121344
- };
121345
- const handleExportPdf = async () => {
122049
+ }, [canvasStageRef, activeSlideIndex, activeSlide?.backgroundColor]);
122050
+ const handleExportPdf = useCallback(async () => {
121346
122051
  if (!canvasStageRef.current) {
121347
122052
  return;
121348
122053
  }
@@ -121383,8 +122088,8 @@ function useExportHandlers(input) {
121383
122088
  exportAbortRef.current = null;
121384
122089
  setExportModalOpen(false);
121385
122090
  }
121386
- };
121387
- const handleExportNotesPdf = async () => {
122091
+ }, [canvasStageRef, slides.length, setActiveSlideIndex, activeSlideIndex]);
122092
+ const handleExportNotesPdf = useCallback(async () => {
121388
122093
  if (!canvasStageRef.current) {
121389
122094
  return;
121390
122095
  }
@@ -121427,8 +122132,8 @@ function useExportHandlers(input) {
121427
122132
  exportAbortRef.current = null;
121428
122133
  setExportModalOpen(false);
121429
122134
  }
121430
- };
121431
- const handleCopySlideAsImage = async () => {
122135
+ }, [canvasStageRef, slides, setActiveSlideIndex, activeSlideIndex]);
122136
+ const handleCopySlideAsImage = useCallback(async () => {
121432
122137
  const stageEl = canvasStageRef.current;
121433
122138
  if (!stageEl) {
121434
122139
  return;
@@ -121440,8 +122145,8 @@ function useExportHandlers(input) {
121440
122145
  } catch (err) {
121441
122146
  console.error("[PowerPointViewer] Copy slide as image failed:", err);
121442
122147
  }
121443
- };
121444
- const handleExportVideo = async () => {
122148
+ }, [canvasStageRef, activeSlide?.backgroundColor]);
122149
+ const handleExportVideo = useCallback(async () => {
121445
122150
  if (!canvasStageRef.current) {
121446
122151
  return;
121447
122152
  }
@@ -121483,8 +122188,8 @@ function useExportHandlers(input) {
121483
122188
  exportAbortRef.current = null;
121484
122189
  setExportModalOpen(false);
121485
122190
  }
121486
- };
121487
- const handleExportGif = async () => {
122191
+ }, [canvasStageRef, slides.length, setActiveSlideIndex, activeSlideIndex]);
122192
+ const handleExportGif = useCallback(async () => {
121488
122193
  if (!canvasStageRef.current) {
121489
122194
  return;
121490
122195
  }
@@ -121522,7 +122227,7 @@ function useExportHandlers(input) {
121522
122227
  exportAbortRef.current = null;
121523
122228
  setExportModalOpen(false);
121524
122229
  }
121525
- };
122230
+ }, [canvasStageRef, slides.length, setActiveSlideIndex, activeSlideIndex]);
121526
122231
  const handleCancelExport = useCallback(() => {
121527
122232
  exportAbortRef.current?.abort();
121528
122233
  exportAbortRef.current = null;
@@ -121548,6 +122253,15 @@ function useExportHandlers(input) {
121548
122253
  exportStatusMessage
121549
122254
  };
121550
122255
  }
122256
+ function escapeHtmlAttr(value) {
122257
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
122258
+ }
122259
+ function safeDataImageSrc(src) {
122260
+ if (typeof src !== "string" || !src.startsWith("data:image/")) {
122261
+ return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgAAIAAAUAAen63NgAAAAASUVORK5CYII=";
122262
+ }
122263
+ return escapeHtmlAttr(src);
122264
+ }
121551
122265
  function openPrintWindow(title, bodyHtml, orientation, colorFilter, frameSlides) {
121552
122266
  const printWindow = window.open("", "_blank", "noopener,noreferrer");
121553
122267
  if (!printWindow) {
@@ -121730,7 +122444,7 @@ function usePrintHandlers(input) {
121730
122444
  const slideImages = slideIndices.map((idx) => allImages[idx]).filter(Boolean);
121731
122445
  if (settings.printWhat === "slides") {
121732
122446
  const bodyHtml = slideImages.map(
121733
- (img, i3) => `<section class="page slide-page"><img class="slide-img" src="${img}" alt="Slide ${slideIndices[i3] + 1}" /></section>`
122447
+ (img, i3) => `<section class="page slide-page"><img class="slide-img" src="${safeDataImageSrc(img)}" alt="Slide ${slideIndices[i3] + 1}" /></section>`
121734
122448
  ).join("");
121735
122449
  openPrintWindow(
121736
122450
  "Slides",
@@ -121746,7 +122460,7 @@ function usePrintHandlers(input) {
121746
122460
  const idx = slideIndices[i3];
121747
122461
  const notes = slides[idx]?.notes?.trim() || "";
121748
122462
  return `<section class="page notes-page">
121749
- <img class="notes-slide" src="${img}" alt="Slide ${idx + 1}" />
122463
+ <img class="notes-slide" src="${safeDataImageSrc(img)}" alt="Slide ${idx + 1}" />
121750
122464
  <div class="notes-text">${escapeHtml2(notes)}</div>
121751
122465
  </section>`;
121752
122466
  }).join("");
@@ -121778,14 +122492,14 @@ function usePrintHandlers(input) {
121778
122492
  if (isThreePerPage) {
121779
122493
  const rows = Array.from({ length: spp }, (_, cellIndex) => {
121780
122494
  const img = pageImgs[cellIndex];
121781
- const slideCell = img ? `<div class="handout-cell"><img src="${img}" alt="Slide ${slideIndices[i3 + cellIndex] + 1}" /></div>` : `<div class="handout-cell"></div>`;
122495
+ const slideCell = img ? `<div class="handout-cell"><img src="${safeDataImageSrc(img)}" alt="Slide ${slideIndices[i3 + cellIndex] + 1}" /></div>` : `<div class="handout-cell"></div>`;
121782
122496
  return `<div class="handout-row-3">${slideCell}${buildNoteLines()}</div>`;
121783
122497
  }).join("");
121784
122498
  pages.push(`<section class="page"><div class="handout-grid-3">${rows}</div></section>`);
121785
122499
  } else {
121786
122500
  const cells = Array.from({ length: spp }, (_, cellIndex) => {
121787
122501
  const img = pageImgs[cellIndex];
121788
- return img ? `<div class="handout-cell"><img src="${img}" alt="Slide ${slideIndices[i3 + cellIndex] + 1}" /></div>` : `<div class="handout-cell"></div>`;
122502
+ return img ? `<div class="handout-cell"><img src="${safeDataImageSrc(img)}" alt="Slide ${slideIndices[i3 + cellIndex] + 1}" /></div>` : `<div class="handout-cell"></div>`;
121789
122503
  }).join("");
121790
122504
  pages.push(
121791
122505
  `<section class="page"><div class="handout-grid" style="grid-template-columns: repeat(${grid.columns}, minmax(0, 1fr)); grid-template-rows: repeat(${grid.rows}, minmax(0, 1fr));">${cells}</div></section>`
@@ -124261,7 +124975,7 @@ scheduler/cjs/scheduler.development.js:
124261
124975
  * LICENSE file in the root directory of this source tree.
124262
124976
  *)
124263
124977
 
124264
- @react-three/fiber/dist/events-760a1017.esm.js:
124978
+ @react-three/fiber/dist/events-b389eeca.esm.js:
124265
124979
  (**
124266
124980
  * @license React
124267
124981
  * react-reconciler-constants.production.js