super-three 0.169.0 → 0.170.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/build/three.cjs +989 -1131
  2. package/build/three.module.js +990 -1128
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +8398 -9842
  5. package/build/three.webgpu.min.js +1 -1
  6. package/build/three.webgpu.nodes.js +8398 -9842
  7. package/build/three.webgpu.nodes.min.js +1 -1
  8. package/examples/jsm/Addons.js +3 -3
  9. package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
  10. package/examples/jsm/animation/MMDPhysics.js +2 -0
  11. package/examples/jsm/controls/TransformControls.js +22 -6
  12. package/examples/jsm/csm/CSM.js +2 -2
  13. package/examples/jsm/csm/CSMFrustum.js +7 -4
  14. package/examples/jsm/csm/CSMHelper.js +2 -0
  15. package/examples/jsm/csm/CSMShadowNode.js +435 -0
  16. package/examples/jsm/curves/NURBSCurve.js +34 -3
  17. package/examples/jsm/exporters/GLTFExporter.js +138 -71
  18. package/examples/jsm/exporters/KTX2Exporter.js +35 -12
  19. package/examples/jsm/exporters/MMDExporter.js +6 -0
  20. package/examples/jsm/exporters/USDZExporter.js +21 -3
  21. package/examples/jsm/geometries/DecalGeometry.js +65 -20
  22. package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
  23. package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
  24. package/examples/jsm/interactive/HTMLMesh.js +1 -0
  25. package/examples/jsm/lighting/TiledLighting.js +18 -0
  26. package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
  27. package/examples/jsm/lines/LineMaterial.js +7 -2
  28. package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
  29. package/examples/jsm/lines/webgpu/LineSegments2.js +0 -15
  30. package/examples/jsm/lines/webgpu/Wireframe.js +56 -0
  31. package/examples/jsm/loaders/3DMLoader.js +1 -0
  32. package/examples/jsm/loaders/3MFLoader.js +91 -0
  33. package/examples/jsm/loaders/FBXLoader.js +12 -2
  34. package/examples/jsm/loaders/GLTFLoader.js +2 -0
  35. package/examples/jsm/loaders/KTX2Loader.js +140 -49
  36. package/examples/jsm/loaders/LDrawLoader.js +22 -136
  37. package/examples/jsm/loaders/LottieLoader.js +1 -0
  38. package/examples/jsm/loaders/MMDLoader.js +9 -2
  39. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
  40. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
  41. package/examples/jsm/materials/MeshGouraudMaterial.js +6 -2
  42. package/examples/jsm/math/ColorSpaces.js +76 -0
  43. package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
  44. package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
  45. package/examples/jsm/misc/VolumeSlice.js +1 -0
  46. package/examples/jsm/objects/WaterMesh.js +8 -8
  47. package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
  48. package/examples/jsm/postprocessing/SSRPass.js +6 -0
  49. package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
  50. package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
  51. package/examples/jsm/shaders/FXAAShader.js +225 -224
  52. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  53. package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +17 -20
  54. package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
  55. package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
  56. package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
  57. package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +11 -40
  58. package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +18 -41
  59. package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +2 -8
  60. package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
  61. package/examples/jsm/tsl/display/FXAANode.js +316 -0
  62. package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +2 -6
  63. package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +30 -70
  64. package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +74 -36
  65. package/examples/jsm/tsl/display/LensflareNode.js +161 -0
  66. package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +1 -4
  67. package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
  68. package/examples/jsm/tsl/display/OutlineNode.js +434 -0
  69. package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +1 -5
  70. package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +3 -15
  71. package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +1 -6
  72. package/examples/jsm/tsl/display/SMAANode.js +620 -0
  73. package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
  74. package/examples/jsm/tsl/display/SSRNode.js +343 -0
  75. package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
  76. package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +3 -11
  77. package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
  78. package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
  79. package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
  80. package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +1 -6
  81. package/examples/jsm/tsl/display/hashBlur.js +24 -0
  82. package/examples/jsm/tsl/lighting/TiledLightsNode.js +392 -0
  83. package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
  84. package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
  85. package/examples/jsm/webxr/Text2D.js +6 -6
  86. package/package.json +2 -2
  87. package/src/Three.WebGPU.Nodes.js +4 -0
  88. package/src/Three.WebGPU.js +4 -0
  89. package/src/constants.js +1 -6
  90. package/src/core/BufferGeometry.js +44 -6
  91. package/src/geometries/CylinderGeometry.js +2 -2
  92. package/src/materials/LineBasicMaterial.js +6 -2
  93. package/src/materials/LineDashedMaterial.js +6 -2
  94. package/src/materials/Material.js +14 -1
  95. package/src/materials/MeshBasicMaterial.js +6 -2
  96. package/src/materials/MeshDepthMaterial.js +6 -2
  97. package/src/materials/MeshDistanceMaterial.js +6 -2
  98. package/src/materials/MeshLambertMaterial.js +6 -2
  99. package/src/materials/MeshMatcapMaterial.js +6 -2
  100. package/src/materials/MeshNormalMaterial.js +6 -2
  101. package/src/materials/MeshPhongMaterial.js +6 -2
  102. package/src/materials/MeshPhysicalMaterial.js +6 -2
  103. package/src/materials/MeshStandardMaterial.js +6 -2
  104. package/src/materials/MeshToonMaterial.js +6 -2
  105. package/src/materials/PointsMaterial.js +6 -2
  106. package/src/materials/RawShaderMaterial.js +6 -2
  107. package/src/materials/ShaderMaterial.js +6 -2
  108. package/src/materials/ShadowMaterial.js +6 -2
  109. package/src/materials/SpriteMaterial.js +6 -2
  110. package/src/materials/nodes/NodeMaterial.js +31 -9
  111. package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
  112. package/src/materials/nodes/manager/NodeMaterialObserver.js +111 -2
  113. package/src/math/ColorManagement.js +118 -85
  114. package/src/math/Vector4.js +11 -0
  115. package/src/nodes/Nodes.js +1 -21
  116. package/src/nodes/TSL.js +6 -24
  117. package/src/nodes/accessors/Camera.js +0 -1
  118. package/src/nodes/accessors/SceneNode.js +35 -1
  119. package/src/nodes/accessors/StorageBufferNode.js +32 -10
  120. package/src/nodes/accessors/VelocityNode.js +13 -3
  121. package/src/nodes/code/FunctionCallNode.js +16 -5
  122. package/src/nodes/code/ScriptableNode.js +4 -4
  123. package/src/nodes/core/Node.js +1 -0
  124. package/src/nodes/core/NodeBuilder.js +29 -5
  125. package/src/nodes/core/VarNode.js +15 -3
  126. package/src/nodes/display/ColorAdjustment.js +53 -4
  127. package/src/nodes/display/ColorSpaceFunctions.js +5 -5
  128. package/src/nodes/display/ColorSpaceNode.js +27 -39
  129. package/src/nodes/display/PassNode.js +6 -4
  130. package/src/nodes/display/ToneMappingNode.js +1 -1
  131. package/src/nodes/display/ViewportDepthNode.js +33 -1
  132. package/src/nodes/functions/PhysicalLightingModel.js +21 -15
  133. package/src/nodes/functions/material/getAlphaHashThreshold.js +64 -0
  134. package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
  135. package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
  136. package/src/nodes/gpgpu/ComputeNode.js +9 -1
  137. package/src/nodes/lighting/AnalyticLightNode.js +12 -416
  138. package/src/nodes/lighting/LightsNode.js +24 -12
  139. package/src/nodes/lighting/PointLightNode.js +36 -26
  140. package/src/nodes/lighting/RectAreaLightNode.js +3 -0
  141. package/src/nodes/lighting/ShadowNode.js +484 -0
  142. package/src/nodes/utils/LoopNode.js +2 -2
  143. package/src/nodes/utils/Oscillators.js +6 -0
  144. package/src/nodes/utils/PostProcessingUtils.js +89 -0
  145. package/src/nodes/utils/ReflectorNode.js +101 -15
  146. package/src/nodes/utils/Timer.js +29 -0
  147. package/src/objects/BatchedMesh.js +458 -241
  148. package/src/renderers/WebGLRenderer.js +121 -126
  149. package/src/renderers/common/Attributes.js +4 -0
  150. package/src/renderers/common/Backend.js +2 -0
  151. package/src/renderers/common/Background.js +14 -4
  152. package/src/renderers/common/Bindings.js +3 -2
  153. package/src/renderers/common/Constants.js +2 -1
  154. package/src/renderers/common/Geometries.js +20 -0
  155. package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
  156. package/src/renderers/common/Lighting.js +45 -0
  157. package/src/renderers/common/PostProcessingUtils.js +86 -0
  158. package/src/renderers/common/RenderList.js +39 -11
  159. package/src/renderers/common/RenderLists.js +4 -2
  160. package/src/renderers/common/RenderObject.js +18 -1
  161. package/src/renderers/common/Renderer.js +165 -26
  162. package/src/renderers/common/Textures.js +30 -14
  163. package/src/renderers/common/nodes/NodeLibrary.js +1 -14
  164. package/src/renderers/common/nodes/Nodes.js +2 -2
  165. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
  166. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
  167. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
  168. package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
  169. package/src/renderers/webgl/WebGLCapabilities.js +0 -7
  170. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
  171. package/src/renderers/webgl/WebGLProgram.js +24 -28
  172. package/src/renderers/webgl/WebGLPrograms.js +5 -2
  173. package/src/renderers/webgl/WebGLState.js +37 -1
  174. package/src/renderers/webgl/WebGLTextures.js +29 -12
  175. package/src/renderers/webgl-fallback/WebGLBackend.js +98 -31
  176. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
  177. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +33 -8
  178. package/src/renderers/webgpu/WebGPUBackend.js +105 -25
  179. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
  180. package/src/renderers/webgpu/WebGPURenderer.js +1 -1
  181. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
  182. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -8
  183. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +10 -20
  184. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
  185. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
  186. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +24 -6
  187. package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
  188. package/src/renderers/webxr/WebXRManager.js +4 -4
  189. package/examples/jsm/cameras/CinematicCamera.js +0 -208
  190. package/src/nodes/display/FXAANode.js +0 -332
  191. package/src/nodes/utils/OscNode.js +0 -85
  192. package/src/nodes/utils/TimerNode.js +0 -97
  193. package/src/renderers/webvr/WebVRManager.js +0 -495
  194. package/src/renderers/webvr/WebVRUtils.js +0 -66
  195. /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
@@ -3,7 +3,7 @@
3
3
  * Copyright 2010-2024 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
- const REVISION = '169';
6
+ const REVISION = '170';
7
7
 
8
8
  const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
9
9
  const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
@@ -168,15 +168,10 @@ const ObjectSpaceNormalMap = 1;
168
168
  const NoColorSpace = '';
169
169
  const SRGBColorSpace = 'srgb';
170
170
  const LinearSRGBColorSpace = 'srgb-linear';
171
- const DisplayP3ColorSpace = 'display-p3';
172
- const LinearDisplayP3ColorSpace = 'display-p3-linear';
173
171
 
174
172
  const LinearTransfer = 'linear';
175
173
  const SRGBTransfer = 'srgb';
176
174
 
177
- const Rec709Primaries = 'rec709';
178
- const P3Primaries = 'p3';
179
-
180
175
  const ZeroStencilOp = 0;
181
176
  const KeepStencilOp = 7680;
182
177
  const ReplaceStencilOp = 7681;
@@ -1624,121 +1619,82 @@ function toReversedProjectionMatrix( projectionMatrix ) {
1624
1619
 
1625
1620
  }
1626
1621
 
1627
- /**
1628
- * Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
1629
- * or clipping. Based on W3C specifications for sRGB and Display P3,
1630
- * and ICC specifications for the D50 connection space. Values in/out
1631
- * are _linear_ sRGB and _linear_ Display P3.
1632
- *
1633
- * Note that both sRGB and Display P3 use the sRGB transfer functions.
1634
- *
1635
- * Reference:
1636
- * - http://www.russellcottrell.com/photo/matrixCalculator.htm
1637
- */
1638
-
1639
- const LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = /*@__PURE__*/ new Matrix3().set(
1640
- 0.8224621, 0.177538, 0.0,
1641
- 0.0331941, 0.9668058, 0.0,
1642
- 0.0170827, 0.0723974, 0.9105199,
1643
- );
1644
-
1645
- const LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = /*@__PURE__*/ new Matrix3().set(
1646
- 1.2249401, - 0.2249404, 0.0,
1647
- - 0.0420569, 1.0420571, 0.0,
1648
- - 0.0196376, - 0.0786361, 1.0982735
1649
- );
1650
-
1651
- /**
1652
- * Defines supported color spaces by transfer function and primaries,
1653
- * and provides conversions to/from the Linear-sRGB reference space.
1654
- */
1655
- const COLOR_SPACES = {
1656
- [ LinearSRGBColorSpace ]: {
1657
- transfer: LinearTransfer,
1658
- primaries: Rec709Primaries,
1659
- luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
1660
- toReference: ( color ) => color,
1661
- fromReference: ( color ) => color,
1662
- },
1663
- [ SRGBColorSpace ]: {
1664
- transfer: SRGBTransfer,
1665
- primaries: Rec709Primaries,
1666
- luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
1667
- toReference: ( color ) => color.convertSRGBToLinear(),
1668
- fromReference: ( color ) => color.convertLinearToSRGB(),
1669
- },
1670
- [ LinearDisplayP3ColorSpace ]: {
1671
- transfer: LinearTransfer,
1672
- primaries: P3Primaries,
1673
- luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
1674
- toReference: ( color ) => color.applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1675
- fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ),
1676
- },
1677
- [ DisplayP3ColorSpace ]: {
1678
- transfer: SRGBTransfer,
1679
- primaries: P3Primaries,
1680
- luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
1681
- toReference: ( color ) => color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
1682
- fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB(),
1683
- },
1684
- };
1685
-
1686
- const SUPPORTED_WORKING_COLOR_SPACES = new Set( [ LinearSRGBColorSpace, LinearDisplayP3ColorSpace ] );
1687
-
1688
1622
  const ColorManagement = {
1689
1623
 
1690
1624
  enabled: true,
1691
1625
 
1692
- _workingColorSpace: LinearSRGBColorSpace,
1626
+ workingColorSpace: LinearSRGBColorSpace,
1693
1627
 
1694
- get workingColorSpace() {
1628
+ /**
1629
+ * Implementations of supported color spaces.
1630
+ *
1631
+ * Required:
1632
+ * - primaries: chromaticity coordinates [ rx ry gx gy bx by ]
1633
+ * - whitePoint: reference white [ x y ]
1634
+ * - transfer: transfer function (pre-defined)
1635
+ * - toXYZ: Matrix3 RGB to XYZ transform
1636
+ * - fromXYZ: Matrix3 XYZ to RGB transform
1637
+ * - luminanceCoefficients: RGB luminance coefficients
1638
+ *
1639
+ * Optional:
1640
+ * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace }
1641
+ * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
1642
+ *
1643
+ * Reference:
1644
+ * - https://www.russellcottrell.com/photo/matrixCalculator.htm
1645
+ */
1646
+ spaces: {},
1695
1647
 
1696
- return this._workingColorSpace;
1648
+ convert: function ( color, sourceColorSpace, targetColorSpace ) {
1697
1649
 
1698
- },
1650
+ if ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
1699
1651
 
1700
- set workingColorSpace( colorSpace ) {
1652
+ return color;
1653
+
1654
+ }
1701
1655
 
1702
- if ( ! SUPPORTED_WORKING_COLOR_SPACES.has( colorSpace ) ) {
1656
+ if ( this.spaces[ sourceColorSpace ].transfer === SRGBTransfer ) {
1703
1657
 
1704
- throw new Error( `Unsupported working color space, "${ colorSpace }".` );
1658
+ color.r = SRGBToLinear( color.r );
1659
+ color.g = SRGBToLinear( color.g );
1660
+ color.b = SRGBToLinear( color.b );
1705
1661
 
1706
1662
  }
1707
1663
 
1708
- this._workingColorSpace = colorSpace;
1664
+ if ( this.spaces[ sourceColorSpace ].primaries !== this.spaces[ targetColorSpace ].primaries ) {
1709
1665
 
1710
- },
1666
+ color.applyMatrix3( this.spaces[ sourceColorSpace ].toXYZ );
1667
+ color.applyMatrix3( this.spaces[ targetColorSpace ].fromXYZ );
1711
1668
 
1712
- convert: function ( color, sourceColorSpace, targetColorSpace ) {
1669
+ }
1713
1670
 
1714
- if ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
1671
+ if ( this.spaces[ targetColorSpace ].transfer === SRGBTransfer ) {
1715
1672
 
1716
- return color;
1673
+ color.r = LinearToSRGB( color.r );
1674
+ color.g = LinearToSRGB( color.g );
1675
+ color.b = LinearToSRGB( color.b );
1717
1676
 
1718
1677
  }
1719
1678
 
1720
- const sourceToReference = COLOR_SPACES[ sourceColorSpace ].toReference;
1721
- const targetFromReference = COLOR_SPACES[ targetColorSpace ].fromReference;
1722
-
1723
- return targetFromReference( sourceToReference( color ) );
1679
+ return color;
1724
1680
 
1725
1681
  },
1726
1682
 
1727
1683
  fromWorkingColorSpace: function ( color, targetColorSpace ) {
1728
1684
 
1729
- return this.convert( color, this._workingColorSpace, targetColorSpace );
1685
+ return this.convert( color, this.workingColorSpace, targetColorSpace );
1730
1686
 
1731
1687
  },
1732
1688
 
1733
1689
  toWorkingColorSpace: function ( color, sourceColorSpace ) {
1734
1690
 
1735
- return this.convert( color, sourceColorSpace, this._workingColorSpace );
1691
+ return this.convert( color, sourceColorSpace, this.workingColorSpace );
1736
1692
 
1737
1693
  },
1738
1694
 
1739
1695
  getPrimaries: function ( colorSpace ) {
1740
1696
 
1741
- return COLOR_SPACES[ colorSpace ].primaries;
1697
+ return this.spaces[ colorSpace ].primaries;
1742
1698
 
1743
1699
  },
1744
1700
 
@@ -1746,18 +1702,45 @@ const ColorManagement = {
1746
1702
 
1747
1703
  if ( colorSpace === NoColorSpace ) return LinearTransfer;
1748
1704
 
1749
- return COLOR_SPACES[ colorSpace ].transfer;
1705
+ return this.spaces[ colorSpace ].transfer;
1750
1706
 
1751
1707
  },
1752
1708
 
1753
- getLuminanceCoefficients: function ( target, colorSpace = this._workingColorSpace ) {
1709
+ getLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {
1754
1710
 
1755
- return target.fromArray( COLOR_SPACES[ colorSpace ].luminanceCoefficients );
1711
+ return target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );
1756
1712
 
1757
1713
  },
1758
1714
 
1759
- };
1715
+ define: function ( colorSpaces ) {
1760
1716
 
1717
+ Object.assign( this.spaces, colorSpaces );
1718
+
1719
+ },
1720
+
1721
+ // Internal APIs
1722
+
1723
+ _getMatrix: function ( targetMatrix, sourceColorSpace, targetColorSpace ) {
1724
+
1725
+ return targetMatrix
1726
+ .copy( this.spaces[ sourceColorSpace ].toXYZ )
1727
+ .multiply( this.spaces[ targetColorSpace ].fromXYZ );
1728
+
1729
+ },
1730
+
1731
+ _getDrawingBufferColorSpace: function ( colorSpace ) {
1732
+
1733
+ return this.spaces[ colorSpace ].outputColorSpaceConfig.drawingBufferColorSpace;
1734
+
1735
+ },
1736
+
1737
+ _getUnpackColorSpace: function ( colorSpace = this.workingColorSpace ) {
1738
+
1739
+ return this.spaces[ colorSpace ].workingColorSpaceConfig.unpackColorSpace;
1740
+
1741
+ }
1742
+
1743
+ };
1761
1744
 
1762
1745
  function SRGBToLinear( c ) {
1763
1746
 
@@ -1771,6 +1754,51 @@ function LinearToSRGB( c ) {
1771
1754
 
1772
1755
  }
1773
1756
 
1757
+ /******************************************************************************
1758
+ * sRGB definitions
1759
+ */
1760
+
1761
+ const REC709_PRIMARIES = [ 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 ];
1762
+ const REC709_LUMINANCE_COEFFICIENTS = [ 0.2126, 0.7152, 0.0722 ];
1763
+ const D65 = [ 0.3127, 0.3290 ];
1764
+
1765
+ const LINEAR_REC709_TO_XYZ = /*@__PURE__*/ new Matrix3().set(
1766
+ 0.4123908, 0.3575843, 0.1804808,
1767
+ 0.2126390, 0.7151687, 0.0721923,
1768
+ 0.0193308, 0.1191948, 0.9505322
1769
+ );
1770
+
1771
+ const XYZ_TO_LINEAR_REC709 = /*@__PURE__*/ new Matrix3().set(
1772
+ 3.2409699, - 1.5373832, - 0.4986108,
1773
+ - 0.9692436, 1.8759675, 0.0415551,
1774
+ 0.0556301, - 0.2039770, 1.0569715
1775
+ );
1776
+
1777
+ ColorManagement.define( {
1778
+
1779
+ [ LinearSRGBColorSpace ]: {
1780
+ primaries: REC709_PRIMARIES,
1781
+ whitePoint: D65,
1782
+ transfer: LinearTransfer,
1783
+ toXYZ: LINEAR_REC709_TO_XYZ,
1784
+ fromXYZ: XYZ_TO_LINEAR_REC709,
1785
+ luminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,
1786
+ workingColorSpaceConfig: { unpackColorSpace: SRGBColorSpace },
1787
+ outputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }
1788
+ },
1789
+
1790
+ [ SRGBColorSpace ]: {
1791
+ primaries: REC709_PRIMARIES,
1792
+ whitePoint: D65,
1793
+ transfer: SRGBTransfer,
1794
+ toXYZ: LINEAR_REC709_TO_XYZ,
1795
+ fromXYZ: XYZ_TO_LINEAR_REC709,
1796
+ luminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,
1797
+ outputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }
1798
+ },
1799
+
1800
+ } );
1801
+
1774
1802
  let _canvas;
1775
1803
 
1776
1804
  class ImageUtils {
@@ -2573,6 +2601,17 @@ class Vector4 {
2573
2601
 
2574
2602
  }
2575
2603
 
2604
+ divide( v ) {
2605
+
2606
+ this.x /= v.x;
2607
+ this.y /= v.y;
2608
+ this.z /= v.z;
2609
+ this.w /= v.w;
2610
+
2611
+ return this;
2612
+
2613
+ }
2614
+
2576
2615
  divideScalar( scalar ) {
2577
2616
 
2578
2617
  return this.multiplyScalar( 1 / scalar );
@@ -9160,6 +9199,20 @@ let _materialId = 0;
9160
9199
 
9161
9200
  class Material extends EventDispatcher {
9162
9201
 
9202
+ static get type() {
9203
+
9204
+ return 'Material';
9205
+
9206
+ }
9207
+
9208
+ get type() {
9209
+
9210
+ return this.constructor.type;
9211
+
9212
+ }
9213
+
9214
+ set type( _value ) { /* */ }
9215
+
9163
9216
  constructor() {
9164
9217
 
9165
9218
  super();
@@ -9171,7 +9224,6 @@ class Material extends EventDispatcher {
9171
9224
  this.uuid = generateUUID();
9172
9225
 
9173
9226
  this.name = '';
9174
- this.type = 'Material';
9175
9227
 
9176
9228
  this.blending = NormalBlending;
9177
9229
  this.side = FrontSide;
@@ -9683,14 +9735,18 @@ class Material extends EventDispatcher {
9683
9735
 
9684
9736
  class MeshBasicMaterial extends Material {
9685
9737
 
9738
+ static get type() {
9739
+
9740
+ return 'MeshBasicMaterial';
9741
+
9742
+ }
9743
+
9686
9744
  constructor( parameters ) {
9687
9745
 
9688
9746
  super();
9689
9747
 
9690
9748
  this.isMeshBasicMaterial = true;
9691
9749
 
9692
- this.type = 'MeshBasicMaterial';
9693
-
9694
9750
  this.color = new Color( 0xffffff ); // emissive
9695
9751
 
9696
9752
  this.map = null;
@@ -10563,6 +10619,7 @@ class BufferGeometry extends EventDispatcher {
10563
10619
  this.type = 'BufferGeometry';
10564
10620
 
10565
10621
  this.index = null;
10622
+ this.indirect = null;
10566
10623
  this.attributes = {};
10567
10624
 
10568
10625
  this.morphAttributes = {};
@@ -10601,6 +10658,20 @@ class BufferGeometry extends EventDispatcher {
10601
10658
 
10602
10659
  }
10603
10660
 
10661
+ setIndirect( indirect ) {
10662
+
10663
+ this.indirect = indirect;
10664
+
10665
+ return this;
10666
+
10667
+ }
10668
+
10669
+ getIndirect() {
10670
+
10671
+ return this.indirect;
10672
+
10673
+ }
10674
+
10604
10675
  getAttribute( name ) {
10605
10676
 
10606
10677
  return this.attributes[ name ];
@@ -10800,16 +10871,39 @@ class BufferGeometry extends EventDispatcher {
10800
10871
 
10801
10872
  setFromPoints( points ) {
10802
10873
 
10803
- const position = [];
10874
+ const positionAttribute = this.getAttribute( 'position' );
10804
10875
 
10805
- for ( let i = 0, l = points.length; i < l; i ++ ) {
10876
+ if ( positionAttribute === undefined ) {
10806
10877
 
10807
- const point = points[ i ];
10808
- position.push( point.x, point.y, point.z || 0 );
10878
+ const position = [];
10809
10879
 
10810
- }
10880
+ for ( let i = 0, l = points.length; i < l; i ++ ) {
10881
+
10882
+ const point = points[ i ];
10883
+ position.push( point.x, point.y, point.z || 0 );
10884
+
10885
+ }
10886
+
10887
+ this.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
10888
+
10889
+ } else {
10890
+
10891
+ for ( let i = 0, l = positionAttribute.count; i < l; i ++ ) {
10892
+
10893
+ const point = points[ i ];
10894
+ positionAttribute.setXYZ( i, point.x, point.y, point.z || 0 );
10895
+
10896
+ }
10897
+
10898
+ if ( points.length > positionAttribute.count ) {
10811
10899
 
10812
- this.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
10900
+ console.warn( 'THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.' );
10901
+
10902
+ }
10903
+
10904
+ positionAttribute.needsUpdate = true;
10905
+
10906
+ }
10813
10907
 
10814
10908
  return this;
10815
10909
 
@@ -12289,14 +12383,18 @@ var default_fragment = "void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0
12289
12383
 
12290
12384
  class ShaderMaterial extends Material {
12291
12385
 
12386
+ static get type() {
12387
+
12388
+ return 'ShaderMaterial';
12389
+
12390
+ }
12391
+
12292
12392
  constructor( parameters ) {
12293
12393
 
12294
12394
  super();
12295
12395
 
12296
12396
  this.isShaderMaterial = true;
12297
12397
 
12298
- this.type = 'ShaderMaterial';
12299
-
12300
12398
  this.defines = {};
12301
12399
  this.uniforms = {};
12302
12400
  this.uniformsGroups = [];
@@ -13937,13 +14035,13 @@ var displacementmap_pars_vertex = "#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler
13937
14035
 
13938
14036
  var displacementmap_vertex = "#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif";
13939
14037
 
13940
- var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif";
14038
+ var emissivemap_fragment = "#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif";
13941
14039
 
13942
14040
  var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif";
13943
14041
 
13944
14042
  var colorspace_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );";
13945
14043
 
13946
- var colorspace_pars_fragment = "\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn 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}";
14044
+ var colorspace_pars_fragment = "vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn 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\treturn 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}";
13947
14045
 
13948
14046
  var envmap_fragment = "#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif";
13949
14047
 
@@ -14001,7 +14099,7 @@ var logdepthbuf_pars_vertex = "#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDept
14001
14099
 
14002
14100
  var logdepthbuf_vertex = "#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif";
14003
14101
 
14004
- var map_fragment = "#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif";
14102
+ var map_fragment = "#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif";
14005
14103
 
14006
14104
  var map_pars_fragment = "#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif";
14007
14105
 
@@ -15809,15 +15907,11 @@ function WebGLBufferRenderer( gl, extensions, info ) {
15809
15907
  let elementCount = 0;
15810
15908
  for ( let i = 0; i < drawCount; i ++ ) {
15811
15909
 
15812
- elementCount += counts[ i ];
15910
+ elementCount += counts[ i ] * primcount[ i ];
15813
15911
 
15814
15912
  }
15815
15913
 
15816
- for ( let i = 0; i < primcount.length; i ++ ) {
15817
-
15818
- info.update( elementCount, mode, primcount[ i ] );
15819
-
15820
- }
15914
+ info.update( elementCount, mode, 1 );
15821
15915
 
15822
15916
  }
15823
15917
 
@@ -15927,13 +16021,6 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
15927
16021
  const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
15928
16022
  const reverseDepthBuffer = parameters.reverseDepthBuffer === true && extensions.has( 'EXT_clip_control' );
15929
16023
 
15930
- if ( reverseDepthBuffer === true ) {
15931
-
15932
- const ext = extensions.get( 'EXT_clip_control' );
15933
- ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );
15934
-
15935
- }
15936
-
15937
16024
  const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
15938
16025
  const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
15939
16026
  const maxTextureSize = gl.getParameter( gl.MAX_TEXTURE_SIZE );
@@ -17759,15 +17846,11 @@ function WebGLIndexedBufferRenderer( gl, extensions, info ) {
17759
17846
  let elementCount = 0;
17760
17847
  for ( let i = 0; i < drawCount; i ++ ) {
17761
17848
 
17762
- elementCount += counts[ i ];
17849
+ elementCount += counts[ i ] * primcount[ i ];
17763
17850
 
17764
17851
  }
17765
17852
 
17766
- for ( let i = 0; i < primcount.length; i ++ ) {
17767
-
17768
- info.update( elementCount, mode, primcount[ i ] );
17769
-
17770
- }
17853
+ info.update( elementCount, mode, 1 );
17771
17854
 
17772
17855
  }
17773
17856
 
@@ -19447,40 +19530,25 @@ function handleSource( string, errorLine ) {
19447
19530
 
19448
19531
  }
19449
19532
 
19450
- function getEncodingComponents( colorSpace ) {
19451
-
19452
- const workingPrimaries = ColorManagement.getPrimaries( ColorManagement.workingColorSpace );
19453
- const encodingPrimaries = ColorManagement.getPrimaries( colorSpace );
19454
-
19455
- let gamutMapping;
19456
-
19457
- if ( workingPrimaries === encodingPrimaries ) {
19458
-
19459
- gamutMapping = '';
19460
-
19461
- } else if ( workingPrimaries === P3Primaries && encodingPrimaries === Rec709Primaries ) {
19462
-
19463
- gamutMapping = 'LinearDisplayP3ToLinearSRGB';
19533
+ const _m0 = /*@__PURE__*/ new Matrix3();
19464
19534
 
19465
- } else if ( workingPrimaries === Rec709Primaries && encodingPrimaries === P3Primaries ) {
19535
+ function getEncodingComponents( colorSpace ) {
19466
19536
 
19467
- gamutMapping = 'LinearSRGBToLinearDisplayP3';
19537
+ ColorManagement._getMatrix( _m0, ColorManagement.workingColorSpace, colorSpace );
19468
19538
 
19469
- }
19539
+ const encodingMatrix = `mat3( ${ _m0.elements.map( ( v ) => v.toFixed( 4 ) ) } )`;
19470
19540
 
19471
- switch ( colorSpace ) {
19541
+ switch ( ColorManagement.getTransfer( colorSpace ) ) {
19472
19542
 
19473
- case LinearSRGBColorSpace:
19474
- case LinearDisplayP3ColorSpace:
19475
- return [ gamutMapping, 'LinearTransferOETF' ];
19543
+ case LinearTransfer:
19544
+ return [ encodingMatrix, 'LinearTransferOETF' ];
19476
19545
 
19477
- case SRGBColorSpace:
19478
- case DisplayP3ColorSpace:
19479
- return [ gamutMapping, 'sRGBTransferOETF' ];
19546
+ case SRGBTransfer:
19547
+ return [ encodingMatrix, 'sRGBTransferOETF' ];
19480
19548
 
19481
19549
  default:
19482
- console.warn( 'THREE.WebGLProgram: Unsupported color space:', colorSpace );
19483
- return [ gamutMapping, 'LinearTransferOETF' ];
19550
+ console.warn( 'THREE.WebGLProgram: Unsupported color space: ', colorSpace );
19551
+ return [ encodingMatrix, 'LinearTransferOETF' ];
19484
19552
 
19485
19553
  }
19486
19554
 
@@ -19513,7 +19581,16 @@ function getShaderErrors( gl, shader, type ) {
19513
19581
  function getTexelEncodingFunction( functionName, colorSpace ) {
19514
19582
 
19515
19583
  const components = getEncodingComponents( colorSpace );
19516
- return `vec4 ${functionName}( vec4 value ) { return ${components[ 0 ]}( ${components[ 1 ]}( value ) ); }`;
19584
+
19585
+ return [
19586
+
19587
+ `vec4 ${functionName}( vec4 value ) {`,
19588
+
19589
+ ` return ${components[ 1 ]}( vec4( value.rgb * ${components[ 0 ]}, value.a ) );`,
19590
+
19591
+ '}',
19592
+
19593
+ ].join( '\n' );
19517
19594
 
19518
19595
  }
19519
19596
 
@@ -20241,6 +20318,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
20241
20318
  parameters.numLightProbes > 0 ? '#define USE_LIGHT_PROBES' : '',
20242
20319
 
20243
20320
  parameters.decodeVideoTexture ? '#define DECODE_VIDEO_TEXTURE' : '',
20321
+ parameters.decodeVideoTextureEmissive ? '#define DECODE_VIDEO_TEXTURE_EMISSIVE' : '',
20244
20322
 
20245
20323
  parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',
20246
20324
  parameters.reverseDepthBuffer ? '#define USE_REVERSEDEPTHBUF' : '',
@@ -20684,7 +20762,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20684
20762
  const programs = [];
20685
20763
 
20686
20764
  const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
20687
- const reverseDepthBuffer = capabilities.reverseDepthBuffer;
20688
20765
  const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
20689
20766
 
20690
20767
  let precision = capabilities.precision;
@@ -20779,6 +20856,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
20779
20856
  }
20780
20857
 
20781
20858
  const currentRenderTarget = renderer.getRenderTarget();
20859
+ const reverseDepthBuffer = renderer.state.buffers.depth.getReversed();
20782
20860
 
20783
20861
  const numMultiviewViews = currentRenderTarget && currentRenderTarget.isWebGLMultiviewRenderTarget ? currentRenderTarget.numViews : 0;
20784
20862
 
@@ -21014,6 +21092,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
21014
21092
  toneMapping: toneMapping,
21015
21093
 
21016
21094
  decodeVideoTexture: HAS_MAP && ( material.map.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.map.colorSpace ) === SRGBTransfer ),
21095
+ decodeVideoTextureEmissive: HAS_EMISSIVEMAP && ( material.emissiveMap.isVideoTexture === true ) && ( ColorManagement.getTransfer( material.emissiveMap.colorSpace ) === SRGBTransfer ),
21017
21096
 
21018
21097
  premultipliedAlpha: material.premultipliedAlpha,
21019
21098
 
@@ -21231,8 +21310,10 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
21231
21310
  _programLayers.enable( 18 );
21232
21311
  if ( parameters.decodeVideoTexture )
21233
21312
  _programLayers.enable( 19 );
21234
- if ( parameters.alphaToCoverage )
21313
+ if ( parameters.decodeVideoTextureEmissive )
21235
21314
  _programLayers.enable( 20 );
21315
+ if ( parameters.alphaToCoverage )
21316
+ _programLayers.enable( 21 );
21236
21317
  if ( parameters.numMultiviewViews )
21237
21318
  _programLayers.enable( 21 );
21238
21319
 
@@ -22292,14 +22373,18 @@ function WebGLRenderStates( extensions ) {
22292
22373
 
22293
22374
  class MeshDepthMaterial extends Material {
22294
22375
 
22376
+ static get type() {
22377
+
22378
+ return 'MeshDepthMaterial';
22379
+
22380
+ }
22381
+
22295
22382
  constructor( parameters ) {
22296
22383
 
22297
22384
  super();
22298
22385
 
22299
22386
  this.isMeshDepthMaterial = true;
22300
22387
 
22301
- this.type = 'MeshDepthMaterial';
22302
-
22303
22388
  this.depthPacking = BasicDepthPacking;
22304
22389
 
22305
22390
  this.map = null;
@@ -22342,14 +22427,18 @@ class MeshDepthMaterial extends Material {
22342
22427
 
22343
22428
  class MeshDistanceMaterial extends Material {
22344
22429
 
22430
+ static get type() {
22431
+
22432
+ return 'MeshDistanceMaterial';
22433
+
22434
+ }
22435
+
22345
22436
  constructor( parameters ) {
22346
22437
 
22347
22438
  super();
22348
22439
 
22349
22440
  this.isMeshDistanceMaterial = true;
22350
22441
 
22351
- this.type = 'MeshDistanceMaterial';
22352
-
22353
22442
  this.map = null;
22354
22443
 
22355
22444
  this.alphaMap = null;
@@ -22804,7 +22893,7 @@ const reversedFuncs = {
22804
22893
  [ GreaterEqualDepth ]: LessEqualDepth,
22805
22894
  };
22806
22895
 
22807
- function WebGLState( gl ) {
22896
+ function WebGLState( gl, extensions ) {
22808
22897
 
22809
22898
  function ColorBuffer() {
22810
22899
 
@@ -22878,10 +22967,36 @@ function WebGLState( gl ) {
22878
22967
 
22879
22968
  setReversed: function ( value ) {
22880
22969
 
22970
+ if ( reversed !== value ) {
22971
+
22972
+ const ext = extensions.get( 'EXT_clip_control' );
22973
+
22974
+ if ( reversed ) {
22975
+
22976
+ ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );
22977
+
22978
+ } else {
22979
+
22980
+ ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.NEGATIVE_ONE_TO_ONE_EXT );
22981
+
22982
+ }
22983
+
22984
+ const oldDepth = currentDepthClear;
22985
+ currentDepthClear = null;
22986
+ this.setClear( oldDepth );
22987
+
22988
+ }
22989
+
22881
22990
  reversed = value;
22882
22991
 
22883
22992
  },
22884
22993
 
22994
+ getReversed: function () {
22995
+
22996
+ return reversed;
22997
+
22998
+ },
22999
+
22885
23000
  setTest: function ( depthTest ) {
22886
23001
 
22887
23002
  if ( depthTest ) {
@@ -22977,6 +23092,12 @@ function WebGLState( gl ) {
22977
23092
 
22978
23093
  if ( currentDepthClear !== depth ) {
22979
23094
 
23095
+ if ( reversed ) {
23096
+
23097
+ depth = 1 - depth;
23098
+
23099
+ }
23100
+
22980
23101
  gl.clearDepth( depth );
22981
23102
  currentDepthClear = depth;
22982
23103
 
@@ -22991,6 +23112,7 @@ function WebGLState( gl ) {
22991
23112
  currentDepthMask = null;
22992
23113
  currentDepthFunc = null;
22993
23114
  currentDepthClear = null;
23115
+ reversed = false;
22994
23116
 
22995
23117
  }
22996
23118
 
@@ -23961,6 +24083,9 @@ function WebGLState( gl ) {
23961
24083
 
23962
24084
  gl.depthMask( true );
23963
24085
  gl.depthFunc( gl.LESS );
24086
+
24087
+ depthBuffer.setReversed( false );
24088
+
23964
24089
  gl.clearDepth( 1 );
23965
24090
 
23966
24091
  gl.stencilMask( 0xffffffff );
@@ -24396,7 +24521,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24396
24521
 
24397
24522
  function textureNeedsGenerateMipmaps( texture ) {
24398
24523
 
24399
- return texture.generateMipmaps && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
24524
+ return texture.generateMipmaps;
24400
24525
 
24401
24526
  }
24402
24527
 
@@ -24406,6 +24531,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24406
24531
 
24407
24532
  }
24408
24533
 
24534
+ function getTargetType( texture ) {
24535
+
24536
+ if ( texture.isWebGLCubeRenderTarget ) return _gl.TEXTURE_CUBE_MAP;
24537
+ if ( texture.isWebGL3DRenderTarget ) return _gl.TEXTURE_3D;
24538
+ if ( texture.isWebGLArrayRenderTarget || texture.isCompressedArrayTexture ) return _gl.TEXTURE_2D_ARRAY;
24539
+ return _gl.TEXTURE_2D;
24540
+
24541
+ }
24542
+
24409
24543
  function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
24410
24544
 
24411
24545
  if ( internalFormatName !== null ) {
@@ -24665,6 +24799,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
24665
24799
 
24666
24800
  renderTarget.depthTexture.dispose();
24667
24801
 
24802
+ properties.remove( renderTarget.depthTexture );
24803
+
24668
24804
  }
24669
24805
 
24670
24806
  if ( renderTarget.isWebGLCubeRenderTarget ) {
@@ -25214,7 +25350,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25214
25350
  layerIndex * layerByteLength / mipmap.data.BYTES_PER_ELEMENT,
25215
25351
  ( layerIndex + 1 ) * layerByteLength / mipmap.data.BYTES_PER_ELEMENT
25216
25352
  );
25217
- state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, layerData, 0, 0 );
25353
+ state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, layerIndex, mipmap.width, mipmap.height, 1, glFormat, layerData );
25218
25354
 
25219
25355
  }
25220
25356
 
@@ -25222,7 +25358,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25222
25358
 
25223
25359
  } else {
25224
25360
 
25225
- state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
25361
+ state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data );
25226
25362
 
25227
25363
  }
25228
25364
 
@@ -25738,6 +25874,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25738
25874
  const glType = utils.convert( texture.type );
25739
25875
  const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType, texture.colorSpace );
25740
25876
  const renderTargetProperties = properties.get( renderTarget );
25877
+ const textureProperties = properties.get( texture );
25878
+
25879
+ textureProperties.__renderTarget = renderTarget;
25741
25880
 
25742
25881
  if ( ! renderTargetProperties.__hasExternalTextures ) {
25743
25882
 
@@ -25768,11 +25907,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25768
25907
 
25769
25908
  if ( multisampled ) {
25770
25909
 
25771
- multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ), 0, renderTarget.numViews );
25910
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, 0, getRenderTargetSamples( renderTarget ), 0, renderTarget.numViews );
25772
25911
 
25773
25912
  } else {
25774
25913
 
25775
- multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( texture ).__webglTexture, 0, 0, renderTarget.numViews );
25914
+ multiviewExt.framebufferTextureMultiviewOVR( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, 0, 0, renderTarget.numViews );
25776
25915
 
25777
25916
  }
25778
25917
 
@@ -25780,11 +25919,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25780
25919
 
25781
25920
  if ( multisampled ) {
25782
25921
 
25783
- multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
25922
+ multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, textureProperties.__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
25784
25923
 
25785
25924
  } else {
25786
25925
 
25787
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, level );
25926
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, textureProperties.__webglTexture, level );
25788
25927
 
25789
25928
  }
25790
25929
 
@@ -25927,8 +26066,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25927
26066
 
25928
26067
  }
25929
26068
 
26069
+ const textureProperties = properties.get( renderTarget.depthTexture );
26070
+ textureProperties.__renderTarget = renderTarget;
26071
+
25930
26072
  // upload an empty depth texture with framebuffer size
25931
- if ( ! properties.get( renderTarget.depthTexture ).__webglTexture ||
26073
+ if ( ! textureProperties.__webglTexture ||
25932
26074
  renderTarget.depthTexture.image.width !== renderTarget.width ||
25933
26075
  renderTarget.depthTexture.image.height !== renderTarget.height ) {
25934
26076
 
@@ -25949,7 +26091,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
25949
26091
 
25950
26092
  }
25951
26093
 
25952
- const webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;
26094
+ const webglDepthTexture = textureProperties.__webglTexture;
25953
26095
  const samples = getRenderTargetSamples( renderTarget );
25954
26096
 
25955
26097
  if ( renderTarget.isWebGLMultiviewRenderTarget === true ) {
@@ -26385,11 +26527,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
26385
26527
 
26386
26528
  if ( textureNeedsGenerateMipmaps( texture ) ) {
26387
26529
 
26388
- const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;
26530
+ const targetType = getTargetType( renderTarget );
26389
26531
  const webglTexture = properties.get( texture ).__webglTexture;
26390
26532
 
26391
- state.bindTexture( target, webglTexture );
26392
- generateMipmap( target );
26533
+ state.bindTexture( targetType, webglTexture );
26534
+ generateMipmap( targetType );
26393
26535
  state.unbindTexture();
26394
26536
 
26395
26537
  }
@@ -26836,20 +26978,6 @@ function WebGLUtils( gl, extensions ) {
26836
26978
 
26837
26979
  }
26838
26980
 
26839
- class Group extends Object3D {
26840
-
26841
- constructor() {
26842
-
26843
- super();
26844
-
26845
- this.isGroup = true;
26846
-
26847
- this.type = 'Group';
26848
-
26849
- }
26850
-
26851
- }
26852
-
26853
26981
  class ArrayCamera extends PerspectiveCamera {
26854
26982
 
26855
26983
  constructor( array = [] ) {
@@ -26864,553 +26992,6 @@ class ArrayCamera extends PerspectiveCamera {
26864
26992
 
26865
26993
  }
26866
26994
 
26867
- /**
26868
- * @author jsantell / https://www.jsantell.com/
26869
- * @author mrdoob / http://mrdoob.com/
26870
- */
26871
-
26872
-
26873
- var cameraLPos = new Vector3();
26874
- var cameraRPos = new Vector3();
26875
-
26876
- /**
26877
- * Assumes 2 cameras that are parallel and share an X-axis, and that
26878
- * the cameras' projection and world matrices have already been set.
26879
- * And that near and far planes are identical for both cameras.
26880
- * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765
26881
- */
26882
- function setProjectionFromUnion( camera, cameraL, cameraR ) {
26883
-
26884
- cameraLPos.setFromMatrixPosition( cameraL.matrixWorld );
26885
- cameraRPos.setFromMatrixPosition( cameraR.matrixWorld );
26886
-
26887
- var ipd = cameraLPos.distanceTo( cameraRPos );
26888
-
26889
- var projL = cameraL.projectionMatrix.elements;
26890
- var projR = cameraR.projectionMatrix.elements;
26891
-
26892
- // VR systems will have identical far and near planes, and
26893
- // most likely identical top and bottom frustum extents.
26894
- // Use the left camera for these values.
26895
- var near = projL[ 14 ] / ( projL[ 10 ] - 1 );
26896
- var far = projL[ 14 ] / ( projL[ 10 ] + 1 );
26897
- var topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];
26898
- var bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];
26899
-
26900
- var leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];
26901
- var rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];
26902
- var left = near * leftFov;
26903
- var right = near * rightFov;
26904
-
26905
- // Calculate the new camera's position offset from the
26906
- // left camera. xOffset should be roughly half `ipd`.
26907
- var zOffset = ipd / ( - leftFov + rightFov );
26908
- var xOffset = zOffset * - leftFov;
26909
-
26910
- // TODO: Better way to apply this offset?
26911
- cameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );
26912
- camera.translateX( xOffset );
26913
- camera.translateZ( zOffset );
26914
- camera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );
26915
- camera.matrixWorldInverse.copy( camera.matrixWorld ).invert();
26916
-
26917
- // Find the union of the frustum values of the cameras and scale
26918
- // the values so that the near plane's position does not change in world space,
26919
- // although must now be relative to the new union camera.
26920
- var near2 = near + zOffset;
26921
- var far2 = far + zOffset;
26922
- var left2 = left - xOffset;
26923
- var right2 = right + ( ipd - xOffset );
26924
- var top2 = topFov * far / far2 * near2;
26925
- var bottom2 = bottomFov * far / far2 * near2;
26926
-
26927
- camera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );
26928
-
26929
- }
26930
-
26931
- /**
26932
- * @author mrdoob / http://mrdoob.com/
26933
- */
26934
-
26935
-
26936
- function WebVRManager( renderer ) {
26937
-
26938
- var renderWidth, renderHeight;
26939
- var scope = this;
26940
-
26941
- var device = null;
26942
- var frameData = null;
26943
-
26944
- var poseTarget = null;
26945
-
26946
- var controllers = [];
26947
- var standingMatrix = new Matrix4();
26948
- var standingMatrixInverse = new Matrix4();
26949
-
26950
- var framebufferScaleFactor = 1.0;
26951
-
26952
- var referenceSpaceType = 'local-floor';
26953
-
26954
- if ( typeof window !== 'undefined' && 'VRFrameData' in window ) {
26955
-
26956
- frameData = new window.VRFrameData();
26957
- window.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );
26958
-
26959
- }
26960
-
26961
- var matrixWorldInverse = new Matrix4();
26962
- var tempQuaternion = new Quaternion();
26963
- var tempPosition = new Vector3();
26964
-
26965
- var cameraL = new PerspectiveCamera();
26966
- cameraL.viewport = new Vector4();
26967
- cameraL.layers.enable( 1 );
26968
-
26969
- var cameraR = new PerspectiveCamera();
26970
- cameraR.viewport = new Vector4();
26971
- cameraR.layers.enable( 2 );
26972
-
26973
- var cameraVR = new ArrayCamera( [ cameraL, cameraR ] );
26974
- cameraVR.layers.enable( 1 );
26975
- cameraVR.layers.enable( 2 );
26976
-
26977
- var currentSize = new Vector2(), currentPixelRatio;
26978
-
26979
- function onVRDisplayPresentChange() {
26980
-
26981
- var isPresenting = scope.isPresenting = device !== null && device.isPresenting === true;
26982
-
26983
- if ( isPresenting ) {
26984
-
26985
- var eyeParameters = device.getEyeParameters( 'left' );
26986
- renderWidth = 2 * eyeParameters.renderWidth * framebufferScaleFactor;
26987
- renderHeight = eyeParameters.renderHeight * framebufferScaleFactor;
26988
-
26989
- currentPixelRatio = renderer.getPixelRatio();
26990
- renderer.getSize( currentSize );
26991
-
26992
- renderer.setDrawingBufferSize( renderWidth, renderHeight, 1 );
26993
-
26994
- cameraL.viewport.set( 0, 0, renderWidth / 2, renderHeight );
26995
- cameraR.viewport.set( renderWidth / 2, 0, renderWidth / 2, renderHeight );
26996
-
26997
- animation.start();
26998
-
26999
- scope.dispatchEvent( { type: 'sessionstart' } );
27000
-
27001
- } else {
27002
-
27003
- if ( scope.enabled ) {
27004
-
27005
- renderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );
27006
-
27007
- }
27008
-
27009
- animation.stop();
27010
-
27011
- scope.dispatchEvent( { type: 'sessionend' } );
27012
-
27013
- }
27014
-
27015
- }
27016
-
27017
- //
27018
-
27019
- var triggers = [];
27020
- var grips = [];
27021
-
27022
- function findGamepad( id ) {
27023
-
27024
- var gamepads = navigator.getGamepads && navigator.getGamepads();
27025
-
27026
- for ( var i = 0, l = gamepads.length; i < l; i ++ ) {
27027
-
27028
- var gamepad = gamepads[ i ];
27029
-
27030
- if ( gamepad && ( gamepad.id === 'Daydream Controller' ||
27031
- gamepad.id === 'Gear VR Controller' || gamepad.id === 'Oculus Go Controller' ||
27032
- gamepad.id === 'OpenVR Gamepad' || gamepad.id.startsWith( 'Oculus Touch' ) ||
27033
- gamepad.id.startsWith( 'HTC Vive Focus' ) ||
27034
- gamepad.id.startsWith( 'Spatial Controller' ) ) ) {
27035
-
27036
- var hand = gamepad.hand;
27037
-
27038
- if ( id === 0 && ( hand === '' || hand === 'right' ) ) return gamepad;
27039
- if ( id === 1 && ( hand === 'left' ) ) return gamepad;
27040
-
27041
- }
27042
-
27043
- }
27044
-
27045
- }
27046
-
27047
- function updateControllers() {
27048
-
27049
- for ( var i = 0; i < controllers.length; i ++ ) {
27050
-
27051
- var controller = controllers[ i ];
27052
-
27053
- var gamepad = findGamepad( i );
27054
-
27055
- if ( gamepad !== undefined && gamepad.pose !== undefined ) {
27056
-
27057
- if ( gamepad.pose === null ) return;
27058
-
27059
- // Pose
27060
-
27061
- var pose = gamepad.pose;
27062
-
27063
- if ( pose.hasPosition === false ) controller.position.set( 0.2, - 0.6, - 0.05 );
27064
-
27065
- if ( pose.position !== null ) controller.position.fromArray( pose.position );
27066
- if ( pose.orientation !== null ) controller.quaternion.fromArray( pose.orientation );
27067
- controller.matrix.compose( controller.position, controller.quaternion, controller.scale );
27068
- controller.matrix.premultiply( standingMatrix );
27069
- controller.matrix.decompose( controller.position, controller.quaternion, controller.scale );
27070
- controller.matrixWorldNeedsUpdate = true;
27071
- controller.visible = true;
27072
-
27073
- // Trigger
27074
-
27075
- var buttonId = gamepad.id === 'Daydream Controller' ? 0 : 1;
27076
-
27077
- if ( triggers[ i ] === undefined ) triggers[ i ] = false;
27078
-
27079
- if ( triggers[ i ] !== gamepad.buttons[ buttonId ].pressed ) {
27080
-
27081
- triggers[ i ] = gamepad.buttons[ buttonId ].pressed;
27082
-
27083
- if ( triggers[ i ] === true ) {
27084
-
27085
- controller.dispatchEvent( { type: 'selectstart' } );
27086
-
27087
- } else {
27088
-
27089
- controller.dispatchEvent( { type: 'selectend' } );
27090
- controller.dispatchEvent( { type: 'select' } );
27091
-
27092
- }
27093
-
27094
- }
27095
-
27096
- // Grip
27097
- buttonId = 2;
27098
-
27099
- if ( grips[ i ] === undefined ) grips[ i ] = false;
27100
-
27101
- // Skip if the grip button doesn't exist on this controller
27102
- if ( gamepad.buttons[ buttonId ] !== undefined ) {
27103
-
27104
- if ( grips[ i ] !== gamepad.buttons[ buttonId ].pressed ) {
27105
-
27106
- grips[ i ] = gamepad.buttons[ buttonId ].pressed;
27107
-
27108
- if ( grips[ i ] === true ) {
27109
-
27110
- controller.dispatchEvent( { type: 'squeezestart' } );
27111
-
27112
- } else {
27113
-
27114
- controller.dispatchEvent( { type: 'squeezeend' } );
27115
- controller.dispatchEvent( { type: 'squeeze' } );
27116
-
27117
- }
27118
-
27119
- }
27120
-
27121
- }
27122
-
27123
- } else {
27124
-
27125
- controller.visible = false;
27126
-
27127
- }
27128
-
27129
- }
27130
-
27131
- }
27132
-
27133
- function updateViewportFromBounds( viewport, bounds ) {
27134
-
27135
- if ( bounds !== null && bounds.length === 4 ) {
27136
-
27137
- viewport.set( bounds[ 0 ] * renderWidth, bounds[ 1 ] * renderHeight, bounds[ 2 ] * renderWidth, bounds[ 3 ] * renderHeight );
27138
-
27139
- }
27140
-
27141
- }
27142
-
27143
- //
27144
-
27145
- this.enabled = false;
27146
-
27147
- this.getController = function ( id ) {
27148
-
27149
- var controller = controllers[ id ];
27150
-
27151
- if ( controller === undefined ) {
27152
-
27153
- controller = new Group();
27154
- controller.matrixAutoUpdate = false;
27155
- controller.visible = false;
27156
-
27157
- controllers[ id ] = controller;
27158
-
27159
- }
27160
-
27161
- return controller;
27162
-
27163
- };
27164
-
27165
- this.getDevice = function () {
27166
-
27167
- return device;
27168
-
27169
- };
27170
-
27171
- this.setDevice = function ( value ) {
27172
-
27173
- if ( value !== undefined ) device = value;
27174
-
27175
- animation.setContext( value );
27176
-
27177
- };
27178
-
27179
- this.setFramebufferScaleFactor = function ( value ) {
27180
-
27181
- framebufferScaleFactor = value;
27182
-
27183
- };
27184
-
27185
- this.setReferenceSpaceType = function ( value ) {
27186
-
27187
- referenceSpaceType = value;
27188
-
27189
- };
27190
-
27191
- this.setPoseTarget = function ( object ) {
27192
-
27193
- if ( object !== undefined ) poseTarget = object;
27194
-
27195
- };
27196
-
27197
- //
27198
-
27199
- this.cameraAutoUpdate = true;
27200
-
27201
- this.updateCamera = function ( camera ) {
27202
-
27203
- var userHeight = referenceSpaceType === 'local-floor' ? 1.6 : 0;
27204
-
27205
- device.depthNear = camera.near;
27206
- device.depthFar = camera.far;
27207
-
27208
- device.getFrameData( frameData );
27209
-
27210
- //
27211
-
27212
- if ( referenceSpaceType === 'local-floor' ) {
27213
-
27214
- var stageParameters = device.stageParameters;
27215
-
27216
- if ( stageParameters ) {
27217
-
27218
- standingMatrix.fromArray( stageParameters.sittingToStandingTransform );
27219
-
27220
- } else {
27221
-
27222
- standingMatrix.makeTranslation( 0, userHeight, 0 );
27223
-
27224
- }
27225
-
27226
- }
27227
-
27228
-
27229
- var pose = frameData.pose;
27230
- var poseObject = poseTarget !== null ? poseTarget : camera;
27231
-
27232
- // We want to manipulate poseObject by its position and quaternion components since users may rely on them.
27233
- poseObject.matrix.copy( standingMatrix );
27234
- poseObject.matrix.decompose( poseObject.position, poseObject.quaternion, poseObject.scale );
27235
-
27236
- if ( pose.orientation !== null ) {
27237
-
27238
- tempQuaternion.fromArray( pose.orientation );
27239
- poseObject.quaternion.multiply( tempQuaternion );
27240
-
27241
- }
27242
-
27243
- if ( pose.position !== null ) {
27244
-
27245
- tempQuaternion.setFromRotationMatrix( standingMatrix );
27246
- tempPosition.fromArray( pose.position );
27247
- tempPosition.applyQuaternion( tempQuaternion );
27248
- poseObject.position.add( tempPosition );
27249
-
27250
- }
27251
-
27252
- poseObject.updateMatrixWorld();
27253
-
27254
- var children = poseObject.children;
27255
- for ( var i = 0, l = children.length; i < l; i ++ ) {
27256
-
27257
- children[ i ].updateMatrixWorld( true );
27258
-
27259
- }
27260
-
27261
- //
27262
-
27263
- cameraL.near = camera.near;
27264
- cameraR.near = camera.near;
27265
-
27266
- cameraL.far = camera.far;
27267
- cameraR.far = camera.far;
27268
-
27269
- cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix );
27270
- cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix );
27271
-
27272
- // TODO (mrdoob) Double check this code
27273
-
27274
- standingMatrixInverse.copy( standingMatrix ).invert();
27275
-
27276
- if ( referenceSpaceType === 'local-floor' ) {
27277
-
27278
- cameraL.matrixWorldInverse.multiply( standingMatrixInverse );
27279
- cameraR.matrixWorldInverse.multiply( standingMatrixInverse );
27280
-
27281
- }
27282
-
27283
- var parent = poseObject.parent;
27284
-
27285
- if ( parent !== null ) {
27286
-
27287
- matrixWorldInverse.copy( parent.matrixWorld ).invert();
27288
-
27289
- cameraL.matrixWorldInverse.multiply( matrixWorldInverse );
27290
- cameraR.matrixWorldInverse.multiply( matrixWorldInverse );
27291
-
27292
- }
27293
-
27294
- // envMap and Mirror needs camera.matrixWorld
27295
-
27296
- cameraL.matrixWorld.copy( cameraL.matrixWorldInverse ).invert();
27297
- cameraR.matrixWorld.copy( cameraR.matrixWorldInverse ).invert();
27298
-
27299
- cameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix );
27300
- cameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix );
27301
-
27302
- setProjectionFromUnion( cameraVR, cameraL, cameraR );
27303
-
27304
- //
27305
-
27306
- var layers = device.getLayers();
27307
-
27308
- if ( layers.length ) {
27309
-
27310
- var layer = layers[ 0 ];
27311
-
27312
- updateViewportFromBounds( cameraL.viewport, layer.leftBounds );
27313
- updateViewportFromBounds( cameraR.viewport, layer.rightBounds );
27314
-
27315
- }
27316
-
27317
- updateControllers();
27318
-
27319
- return cameraVR;
27320
-
27321
- };
27322
-
27323
- this.getCamera = function () {
27324
-
27325
- return cameraVR;
27326
-
27327
- };
27328
-
27329
- // Dummy getFoveation/setFoveation to have the same API as WebXR
27330
-
27331
- this.getFoveation = function () {
27332
-
27333
- return 1;
27334
-
27335
- };
27336
-
27337
- this.setFoveation = function ( foveation ) {
27338
-
27339
- if ( foveation !== 1 ) {
27340
-
27341
- console.warn( 'THREE.WebVRManager: setFoveation() not used in WebVR.' );
27342
-
27343
- }
27344
-
27345
- };
27346
-
27347
- // Dummy getEnvironmentBlendMode to have the same API as WebXR
27348
-
27349
- this.getEnvironmentBlendMode = function () {
27350
-
27351
- if ( scope.isPresenting ) {
27352
-
27353
- return 'opaque';
27354
-
27355
- }
27356
-
27357
- };
27358
-
27359
- //
27360
-
27361
- this.getStandingMatrix = function () {
27362
-
27363
- return standingMatrix;
27364
-
27365
- };
27366
-
27367
- this.isPresenting = false;
27368
-
27369
- // Animation Loop
27370
-
27371
- var animation = new WebGLAnimation();
27372
-
27373
- this.setAnimationLoop = function ( callback ) {
27374
-
27375
- animation.setAnimationLoop( callback );
27376
-
27377
- if ( this.isPresenting ) animation.start();
27378
-
27379
- };
27380
-
27381
- this.submitFrame = function () {
27382
-
27383
- if ( this.isPresenting ) device.submitFrame();
27384
-
27385
- };
27386
-
27387
- this.dispose = function () {
27388
-
27389
- if ( typeof window !== 'undefined' ) {
27390
-
27391
- window.removeEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange );
27392
-
27393
- }
27394
-
27395
- };
27396
-
27397
- // DEPRECATED
27398
-
27399
- this.setFrameOfReferenceType = function () {
27400
-
27401
- console.warn( 'THREE.WebVRManager: setFrameOfReferenceType() has been deprecated.' );
27402
-
27403
- };
27404
-
27405
- }
27406
-
27407
- Object.assign( WebVRManager.prototype, {
27408
- addEventListener: EventDispatcher.prototype.addEventListener,
27409
- hasEventListener: EventDispatcher.prototype.hasEventListener,
27410
- removeEventListener: EventDispatcher.prototype.removeEventListener,
27411
- dispatchEvent: EventDispatcher.prototype.dispatchEvent
27412
- } );
27413
-
27414
26995
  /**
27415
26996
  * @author fernandojsg / http://fernandojsg.com
27416
26997
  * @author Takahiro https://github.com/takahirox
@@ -27444,6 +27025,20 @@ class WebGLMultiviewRenderTarget extends WebGLRenderTarget {
27444
27025
 
27445
27026
  WebGLMultiviewRenderTarget.prototype.isWebGLMultiviewRenderTarget = true;
27446
27027
 
27028
+ class Group extends Object3D {
27029
+
27030
+ constructor() {
27031
+
27032
+ super();
27033
+
27034
+ this.isGroup = true;
27035
+
27036
+ this.type = 'Group';
27037
+
27038
+ }
27039
+
27040
+ }
27041
+
27447
27042
  const _moveEvent = { type: 'move' };
27448
27043
 
27449
27044
  class WebXRController {
@@ -27928,18 +27523,14 @@ class WebXRManager extends EventDispatcher {
27928
27523
  //
27929
27524
 
27930
27525
  const cameraL = new PerspectiveCamera();
27931
- cameraL.layers.enable( 1 );
27932
27526
  cameraL.viewport = new Vector4();
27933
27527
 
27934
27528
  const cameraR = new PerspectiveCamera();
27935
- cameraR.layers.enable( 2 );
27936
27529
  cameraR.viewport = new Vector4();
27937
27530
 
27938
27531
  const cameras = [ cameraL, cameraR ];
27939
27532
 
27940
27533
  const cameraXR = new ArrayCamera();
27941
- cameraXR.layers.enable( 1 );
27942
- cameraXR.layers.enable( 2 );
27943
27534
 
27944
27535
  let _currentDepthNear = null;
27945
27536
  let _currentDepthFar = null;
@@ -28505,6 +28096,10 @@ class WebXRManager extends EventDispatcher {
28505
28096
 
28506
28097
  }
28507
28098
 
28099
+ cameraL.layers.mask = camera.layers.mask | 0b010;
28100
+ cameraR.layers.mask = camera.layers.mask | 0b100;
28101
+ cameraXR.layers.mask = cameraL.layers.mask | cameraR.layers.mask;
28102
+
28508
28103
  const cameras = cameraXR.cameras;
28509
28104
  var object = poseTarget || camera;
28510
28105
  const parent = object.parent;
@@ -29760,6 +29355,7 @@ class WebGLRenderer {
29760
29355
  preserveDrawingBuffer = false,
29761
29356
  powerPreference = 'default',
29762
29357
  failIfMajorPerformanceCaveat = false,
29358
+ reverseDepthBuffer = false,
29763
29359
  multiviewStereo = false,
29764
29360
  } = parameters;
29765
29361
 
@@ -29980,9 +29576,13 @@ class WebGLRenderer {
29980
29576
 
29981
29577
  capabilities = new WebGLCapabilities( _gl, extensions, parameters, utils );
29982
29578
 
29983
- state = new WebGLState( _gl );
29579
+ state = new WebGLState( _gl, extensions );
29580
+
29581
+ if ( capabilities.reverseDepthBuffer && reverseDepthBuffer ) {
29984
29582
 
29985
- if ( capabilities.reverseDepthBuffer ) state.buffers.depth.setReversed( true );
29583
+ state.buffers.depth.setReversed( true );
29584
+
29585
+ }
29986
29586
 
29987
29587
  info = new WebGLInfo( _gl );
29988
29588
  properties = new WebGLProperties();
@@ -30023,7 +29623,7 @@ class WebGLRenderer {
30023
29623
 
30024
29624
  // xr
30025
29625
 
30026
- const xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl, extensions, multiviewStereo ) : new WebVRManager( _this );
29626
+ const xr = new WebXRManager( _this, _gl );
30027
29627
 
30028
29628
  this.xr = xr;
30029
29629
 
@@ -30287,7 +29887,6 @@ class WebGLRenderer {
30287
29887
  if ( depth ) {
30288
29888
 
30289
29889
  bits |= _gl.DEPTH_BUFFER_BIT;
30290
- _gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
30291
29890
 
30292
29891
  }
30293
29892
 
@@ -30983,13 +30582,6 @@ class WebGLRenderer {
30983
30582
 
30984
30583
  if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
30985
30584
 
30986
- textures.runDeferredUploads();
30987
-
30988
- if ( xr.enabled && xr.submitFrame ) {
30989
-
30990
- xr.submitFrame();
30991
-
30992
- }
30993
30585
  // _gl.finish();
30994
30586
 
30995
30587
  bindingStates.resetDefaultState();
@@ -31702,7 +31294,9 @@ class WebGLRenderer {
31702
31294
 
31703
31295
  } else {
31704
31296
 
31705
- if ( capabilities.reverseDepthBuffer ) {
31297
+ const reverseDepthBuffer = state.buffers.depth.getReversed();
31298
+
31299
+ if ( reverseDepthBuffer ) {
31706
31300
 
31707
31301
  _currentProjectionMatrix.copy( camera.projectionMatrix );
31708
31302
 
@@ -32334,21 +31928,27 @@ class WebGLRenderer {
32334
31928
 
32335
31929
  }
32336
31930
 
32337
- let width, height, minX, minY;
32338
- let dstX, dstY;
31931
+ // gather the necessary dimensions to copy
31932
+ let width, height, depth, minX, minY, minZ;
31933
+ let dstX, dstY, dstZ;
31934
+ const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
32339
31935
  if ( srcRegion !== null ) {
32340
31936
 
32341
31937
  width = srcRegion.max.x - srcRegion.min.x;
32342
31938
  height = srcRegion.max.y - srcRegion.min.y;
31939
+ depth = srcRegion.isBox3 ? srcRegion.max.z - srcRegion.min.z : 1;
32343
31940
  minX = srcRegion.min.x;
32344
31941
  minY = srcRegion.min.y;
31942
+ minZ = srcRegion.isBox3 ? srcRegion.min.z : 0;
32345
31943
 
32346
31944
  } else {
32347
31945
 
32348
- width = srcTexture.image.width;
32349
- height = srcTexture.image.height;
31946
+ width = image.width;
31947
+ height = image.height;
31948
+ depth = image.depth || 1;
32350
31949
  minX = 0;
32351
31950
  minY = 0;
31951
+ minZ = 0;
32352
31952
 
32353
31953
  }
32354
31954
 
@@ -32356,177 +31956,143 @@ class WebGLRenderer {
32356
31956
 
32357
31957
  dstX = dstPosition.x;
32358
31958
  dstY = dstPosition.y;
31959
+ dstZ = dstPosition.z;
32359
31960
 
32360
31961
  } else {
32361
31962
 
32362
31963
  dstX = 0;
32363
31964
  dstY = 0;
31965
+ dstZ = 0;
32364
31966
 
32365
31967
  }
32366
31968
 
31969
+ // Set up the destination target
32367
31970
  const glFormat = utils.convert( dstTexture.format );
32368
31971
  const glType = utils.convert( dstTexture.type );
31972
+ let glTarget;
31973
+
31974
+ if ( dstTexture.isData3DTexture ) {
31975
+
31976
+ textures.setTexture3D( dstTexture, 0 );
31977
+ glTarget = _gl.TEXTURE_3D;
31978
+
31979
+ } else if ( dstTexture.isDataArrayTexture || dstTexture.isCompressedArrayTexture ) {
31980
+
31981
+ textures.setTexture2DArray( dstTexture, 0 );
31982
+ glTarget = _gl.TEXTURE_2D_ARRAY;
31983
+
31984
+ } else {
32369
31985
 
32370
- textures.setTexture2D( dstTexture, 0 );
31986
+ textures.setTexture2D( dstTexture, 0 );
31987
+ glTarget = _gl.TEXTURE_2D;
31988
+
31989
+ }
32371
31990
 
32372
- // As another texture upload may have changed pixelStorei
32373
- // parameters, make sure they are correct for the dstTexture
32374
31991
  _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
32375
31992
  _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
32376
31993
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
32377
31994
 
31995
+ // used for copying data from cpu
32378
31996
  const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
32379
31997
  const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
32380
31998
  const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
32381
31999
  const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
32382
32000
  const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
32383
32001
 
32384
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
32385
-
32386
32002
  _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
32387
32003
  _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
32388
32004
  _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
32389
32005
  _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
32006
+ _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
32390
32007
 
32391
- if ( srcTexture.isDataTexture ) {
32392
-
32393
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
32394
-
32395
- } else {
32396
-
32397
- if ( srcTexture.isCompressedTexture ) {
32008
+ // set up the src texture
32009
+ const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture;
32010
+ const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture;
32011
+ if ( srcTexture.isRenderTargetTexture || srcTexture.isDepthTexture ) {
32398
32012
 
32399
- _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
32013
+ const srcTextureProperties = properties.get( srcTexture );
32014
+ const dstTextureProperties = properties.get( dstTexture );
32015
+ const srcRenderTargetProperties = properties.get( srcTextureProperties.__renderTarget );
32016
+ const dstRenderTargetProperties = properties.get( dstTextureProperties.__renderTarget );
32400
32017
 
32401
- } else {
32018
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, srcRenderTargetProperties.__webglFramebuffer );
32019
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, dstRenderTargetProperties.__webglFramebuffer );
32402
32020
 
32403
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
32021
+ for ( let i = 0; i < depth; i ++ ) {
32404
32022
 
32405
- }
32406
-
32407
- }
32408
-
32409
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
32410
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
32411
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
32412
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
32413
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
32023
+ // if the source or destination are a 3d target then a layer needs to be bound
32024
+ if ( isSrc3D ) {
32414
32025
 
32415
- // Generate mipmaps only when copying level 0
32416
- if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
32026
+ _gl.framebufferTextureLayer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( srcTexture ).__webglTexture, level, minZ + i );
32417
32027
 
32418
- state.unbindTexture();
32028
+ }
32419
32029
 
32420
- };
32030
+ if ( srcTexture.isDepthTexture ) {
32421
32031
 
32422
- this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
32032
+ if ( isDst3D ) {
32423
32033
 
32424
- // support previous signature with source box first
32425
- if ( srcTexture.isTexture !== true ) {
32034
+ _gl.framebufferTextureLayer( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( dstTexture ).__webglTexture, level, dstZ + i );
32426
32035
 
32427
- // @deprecated, r165
32428
- warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
32036
+ }
32429
32037
 
32430
- srcRegion = arguments[ 0 ] || null;
32431
- dstPosition = arguments[ 1 ] || null;
32432
- srcTexture = arguments[ 2 ];
32433
- dstTexture = arguments[ 3 ];
32434
- level = arguments[ 4 ] || 0;
32038
+ _gl.blitFramebuffer( minX, minY, width, height, dstX, dstY, width, height, _gl.DEPTH_BUFFER_BIT, _gl.NEAREST );
32435
32039
 
32436
- }
32040
+ } else if ( isDst3D ) {
32437
32041
 
32438
- let width, height, depth, minX, minY, minZ;
32439
- let dstX, dstY, dstZ;
32440
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
32441
- if ( srcRegion !== null ) {
32442
-
32443
- width = srcRegion.max.x - srcRegion.min.x;
32444
- height = srcRegion.max.y - srcRegion.min.y;
32445
- depth = srcRegion.max.z - srcRegion.min.z;
32446
- minX = srcRegion.min.x;
32447
- minY = srcRegion.min.y;
32448
- minZ = srcRegion.min.z;
32042
+ _gl.copyTexSubImage3D( glTarget, level, dstX, dstY, dstZ + i, minX, minY, width, height );
32449
32043
 
32450
- } else {
32044
+ } else {
32451
32045
 
32452
- width = image.width;
32453
- height = image.height;
32454
- depth = image.depth;
32455
- minX = 0;
32456
- minY = 0;
32457
- minZ = 0;
32046
+ _gl.copyTexSubImage2D( glTarget, level, dstX, dstY, dstZ + i, minX, minY, width, height );
32458
32047
 
32459
- }
32048
+ }
32460
32049
 
32461
- if ( dstPosition !== null ) {
32050
+ }
32462
32051
 
32463
- dstX = dstPosition.x;
32464
- dstY = dstPosition.y;
32465
- dstZ = dstPosition.z;
32052
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
32053
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
32466
32054
 
32467
32055
  } else {
32468
32056
 
32469
- dstX = 0;
32470
- dstY = 0;
32471
- dstZ = 0;
32472
-
32473
- }
32474
-
32475
- const glFormat = utils.convert( dstTexture.format );
32476
- const glType = utils.convert( dstTexture.type );
32477
- let glTarget;
32478
-
32479
- if ( dstTexture.isData3DTexture ) {
32057
+ if ( isDst3D ) {
32480
32058
 
32481
- textures.setTexture3D( dstTexture, 0 );
32482
- glTarget = _gl.TEXTURE_3D;
32059
+ // copy data into the 3d texture
32060
+ if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
32483
32061
 
32484
- } else if ( dstTexture.isDataArrayTexture || dstTexture.isCompressedArrayTexture ) {
32062
+ _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
32485
32063
 
32486
- textures.setTexture2DArray( dstTexture, 0 );
32487
- glTarget = _gl.TEXTURE_2D_ARRAY;
32064
+ } else if ( dstTexture.isCompressedArrayTexture ) {
32488
32065
 
32489
- } else {
32490
-
32491
- console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.' );
32492
- return;
32066
+ _gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
32493
32067
 
32494
- }
32068
+ } else {
32495
32069
 
32496
- _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
32497
- _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
32498
- _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
32070
+ _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
32499
32071
 
32500
- const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
32501
- const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
32502
- const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
32503
- const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
32504
- const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
32072
+ }
32505
32073
 
32506
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
32507
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
32508
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
32509
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
32510
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
32074
+ } else {
32511
32075
 
32512
- if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
32076
+ // copy data into the 2d texture
32077
+ if ( srcTexture.isDataTexture ) {
32513
32078
 
32514
- _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
32079
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
32515
32080
 
32516
- } else {
32081
+ } else if ( srcTexture.isCompressedTexture ) {
32517
32082
 
32518
- if ( dstTexture.isCompressedArrayTexture ) {
32083
+ _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
32519
32084
 
32520
- _gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
32085
+ } else {
32521
32086
 
32522
- } else {
32087
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
32523
32088
 
32524
- _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
32089
+ }
32525
32090
 
32526
32091
  }
32527
32092
 
32528
32093
  }
32529
32094
 
32095
+ // reset values
32530
32096
  _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
32531
32097
  _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
32532
32098
  _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
@@ -32534,12 +32100,39 @@ class WebGLRenderer {
32534
32100
  _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
32535
32101
 
32536
32102
  // Generate mipmaps only when copying level 0
32537
- if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
32103
+ if ( level === 0 && dstTexture.generateMipmaps ) {
32104
+
32105
+ _gl.generateMipmap( glTarget );
32106
+
32107
+ }
32538
32108
 
32539
32109
  state.unbindTexture();
32540
32110
 
32541
32111
  };
32542
32112
 
32113
+ this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
32114
+
32115
+ // support previous signature with source box first
32116
+ if ( srcTexture.isTexture !== true ) {
32117
+
32118
+ // @deprecated, r165
32119
+ warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
32120
+
32121
+ srcRegion = arguments[ 0 ] || null;
32122
+ dstPosition = arguments[ 1 ] || null;
32123
+ srcTexture = arguments[ 2 ];
32124
+ dstTexture = arguments[ 3 ];
32125
+ level = arguments[ 4 ] || 0;
32126
+
32127
+ }
32128
+
32129
+ // @deprecated, r170
32130
+ warnOnce( 'WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.' );
32131
+
32132
+ return this.copyTextureToTexture( srcTexture, dstTexture, srcRegion, dstPosition, level );
32133
+
32134
+ };
32135
+
32543
32136
  this.initRenderTarget = function ( target ) {
32544
32137
 
32545
32138
  if ( properties.get( target ).__webglFramebuffer === undefined ) {
@@ -32610,8 +32203,8 @@ class WebGLRenderer {
32610
32203
  this._outputColorSpace = colorSpace;
32611
32204
 
32612
32205
  const gl = this.getContext();
32613
- gl.drawingBufferColorSpace = colorSpace === DisplayP3ColorSpace ? 'display-p3' : 'srgb';
32614
- gl.unpackColorSpace = ColorManagement.workingColorSpace === LinearDisplayP3ColorSpace ? 'display-p3' : 'srgb';
32206
+ gl.drawingBufferColorspace = ColorManagement._getDrawingBufferColorSpace( colorSpace );
32207
+ gl.unpackColorSpace = ColorManagement._getUnpackColorSpace();
32615
32208
 
32616
32209
  }
32617
32210
 
@@ -33257,14 +32850,18 @@ class InterleavedBufferAttribute {
33257
32850
 
33258
32851
  class SpriteMaterial extends Material {
33259
32852
 
32853
+ static get type() {
32854
+
32855
+ return 'SpriteMaterial';
32856
+
32857
+ }
32858
+
33260
32859
  constructor( parameters ) {
33261
32860
 
33262
32861
  super();
33263
32862
 
33264
32863
  this.isSpriteMaterial = true;
33265
32864
 
33266
- this.type = 'SpriteMaterial';
33267
-
33268
32865
  this.color = new Color( 0xffffff );
33269
32866
 
33270
32867
  this.map = null;
@@ -33985,7 +33582,7 @@ class DataTexture extends Texture {
33985
33582
  }
33986
33583
 
33987
33584
  const _offsetMatrix = /*@__PURE__*/ new Matrix4();
33988
- const _identityMatrix$1 = /*@__PURE__*/ new Matrix4();
33585
+ const _identityMatrix = /*@__PURE__*/ new Matrix4();
33989
33586
 
33990
33587
  class Skeleton {
33991
33588
 
@@ -34114,7 +33711,7 @@ class Skeleton {
34114
33711
 
34115
33712
  // compute the offset between the current and the original transform
34116
33713
 
34117
- const matrix = bones[ i ] ? bones[ i ].matrixWorld : _identityMatrix$1;
33714
+ const matrix = bones[ i ] ? bones[ i ].matrixWorld : _identityMatrix;
34118
33715
 
34119
33716
  _offsetMatrix.multiplyMatrices( matrix, boneInverses[ i ] );
34120
33717
  _offsetMatrix.toArray( boneMatrices, i * 16 );
@@ -34555,6 +34152,12 @@ class InstancedMesh extends Mesh {
34555
34152
 
34556
34153
  }
34557
34154
 
34155
+ function ascIdSort( a, b ) {
34156
+
34157
+ return a - b;
34158
+
34159
+ }
34160
+
34558
34161
  function sortOpaque( a, b ) {
34559
34162
 
34560
34163
  return a.z - b.z;
@@ -34577,7 +34180,7 @@ class MultiDrawRenderList {
34577
34180
 
34578
34181
  }
34579
34182
 
34580
- push( drawRange, z, index ) {
34183
+ push( start, count, z, index ) {
34581
34184
 
34582
34185
  const pool = this.pool;
34583
34186
  const list = this.list;
@@ -34598,8 +34201,8 @@ class MultiDrawRenderList {
34598
34201
  list.push( item );
34599
34202
  this.index ++;
34600
34203
 
34601
- item.start = drawRange.start;
34602
- item.count = drawRange.count;
34204
+ item.start = start;
34205
+ item.count = count;
34603
34206
  item.z = z;
34604
34207
  item.index = index;
34605
34208
 
@@ -34615,10 +34218,7 @@ class MultiDrawRenderList {
34615
34218
  }
34616
34219
 
34617
34220
  const _matrix$1 = /*@__PURE__*/ new Matrix4();
34618
- const _invMatrixWorld = /*@__PURE__*/ new Matrix4();
34619
- const _identityMatrix = /*@__PURE__*/ new Matrix4();
34620
34221
  const _whiteColor = /*@__PURE__*/ new Color( 1, 1, 1 );
34621
- const _projScreenMatrix$2 = /*@__PURE__*/ new Matrix4();
34622
34222
  const _frustum = /*@__PURE__*/ new Frustum();
34623
34223
  const _box$1 = /*@__PURE__*/ new Box3();
34624
34224
  const _sphere$2 = /*@__PURE__*/ new Sphere();
@@ -34629,13 +34229,6 @@ const _renderList = /*@__PURE__*/ new MultiDrawRenderList();
34629
34229
  const _mesh = /*@__PURE__*/ new Mesh();
34630
34230
  const _batchIntersects = [];
34631
34231
 
34632
- // @TODO: SkinnedMesh support?
34633
- // @TODO: geometry.groups support?
34634
- // @TODO: geometry.drawRange support?
34635
- // @TODO: geometry.morphAttributes support?
34636
- // @TODO: Support uniform parameter per geometry
34637
- // @TODO: Add an "optimize" function to pack geometry and remove data gaps
34638
-
34639
34232
  // copies data from attribute "src" into "target" starting at "targetOffset"
34640
34233
  function copyAttributeData( src, target, targetOffset = 0 ) {
34641
34234
 
@@ -34666,6 +34259,29 @@ function copyAttributeData( src, target, targetOffset = 0 ) {
34666
34259
 
34667
34260
  }
34668
34261
 
34262
+ // safely copies array contents to a potentially smaller array
34263
+ function copyArrayContents( src, target ) {
34264
+
34265
+ if ( src.constructor !== target.constructor ) {
34266
+
34267
+ // if arrays are of a different type (eg due to index size increasing) then data must be per-element copied
34268
+ const len = Math.min( src.length, target.length );
34269
+ for ( let i = 0; i < len; i ++ ) {
34270
+
34271
+ target[ i ] = src[ i ];
34272
+
34273
+ }
34274
+
34275
+ } else {
34276
+
34277
+ // if the arrays use the same data layout we can use a fast block copy
34278
+ const len = Math.min( src.length, target.length );
34279
+ target.set( new src.constructor( src.buffer, 0, len ) );
34280
+
34281
+ }
34282
+
34283
+ }
34284
+
34669
34285
  class BatchedMesh extends Mesh {
34670
34286
 
34671
34287
  get maxInstanceCount() {
@@ -34674,6 +34290,24 @@ class BatchedMesh extends Mesh {
34674
34290
 
34675
34291
  }
34676
34292
 
34293
+ get instanceCount() {
34294
+
34295
+ return this._instanceInfo.length - this._availableInstanceIds.length;
34296
+
34297
+ }
34298
+
34299
+ get unusedVertexCount() {
34300
+
34301
+ return this._maxVertexCount - this._nextVertexStart;
34302
+
34303
+ }
34304
+
34305
+ get unusedIndexCount() {
34306
+
34307
+ return this._maxIndexCount - this._nextIndexStart;
34308
+
34309
+ }
34310
+
34677
34311
  constructor( maxInstanceCount, maxVertexCount, maxIndexCount = maxVertexCount * 2, material ) {
34678
34312
 
34679
34313
  super( new BufferGeometry(), material );
@@ -34685,28 +34319,33 @@ class BatchedMesh extends Mesh {
34685
34319
  this.boundingSphere = null;
34686
34320
  this.customSort = null;
34687
34321
 
34688
- // stores visible, active, and geometry id per object
34689
- this._drawInfo = [];
34322
+ // stores visible, active, and geometry id per instance and reserved buffer ranges for geometries
34323
+ this._instanceInfo = [];
34324
+ this._geometryInfo = [];
34690
34325
 
34691
- // instance ids that have been set as inactive, and are available to be overwritten
34326
+ // instance, geometry ids that have been set as inactive, and are available to be overwritten
34692
34327
  this._availableInstanceIds = [];
34328
+ this._availableGeometryIds = [];
34329
+
34330
+ // used to track where the next point is that geometry should be inserted
34331
+ this._nextIndexStart = 0;
34332
+ this._nextVertexStart = 0;
34333
+ this._geometryCount = 0;
34693
34334
 
34694
- // geometry information
34695
- this._drawRanges = [];
34696
- this._reservedRanges = [];
34697
- this._bounds = [];
34335
+ // flags
34336
+ this._visibilityChanged = true;
34337
+ this._geometryInitialized = false;
34698
34338
 
34339
+ // cached user options
34699
34340
  this._maxInstanceCount = maxInstanceCount;
34700
34341
  this._maxVertexCount = maxVertexCount;
34701
34342
  this._maxIndexCount = maxIndexCount;
34702
34343
 
34703
- this._geometryInitialized = false;
34704
- this._geometryCount = 0;
34344
+ // buffers for multi draw
34705
34345
  this._multiDrawCounts = new Int32Array( maxInstanceCount );
34706
34346
  this._multiDrawStarts = new Int32Array( maxInstanceCount );
34707
34347
  this._multiDrawCount = 0;
34708
34348
  this._multiDrawInstances = null;
34709
- this._visibilityChanged = true;
34710
34349
 
34711
34350
  // Local matrix per geometry by using data texture
34712
34351
  this._matricesTexture = null;
@@ -34847,14 +34486,14 @@ class BatchedMesh extends Mesh {
34847
34486
  }
34848
34487
 
34849
34488
  const boundingBox = this.boundingBox;
34850
- const drawInfo = this._drawInfo;
34489
+ const instanceInfo = this._instanceInfo;
34851
34490
 
34852
34491
  boundingBox.makeEmpty();
34853
- for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34492
+ for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
34854
34493
 
34855
- if ( drawInfo[ i ].active === false ) continue;
34494
+ if ( instanceInfo[ i ].active === false ) continue;
34856
34495
 
34857
- const geometryId = drawInfo[ i ].geometryIndex;
34496
+ const geometryId = instanceInfo[ i ].geometryIndex;
34858
34497
  this.getMatrixAt( i, _matrix$1 );
34859
34498
  this.getBoundingBoxAt( geometryId, _box$1 ).applyMatrix4( _matrix$1 );
34860
34499
  boundingBox.union( _box$1 );
@@ -34872,14 +34511,14 @@ class BatchedMesh extends Mesh {
34872
34511
  }
34873
34512
 
34874
34513
  const boundingSphere = this.boundingSphere;
34875
- const drawInfo = this._drawInfo;
34514
+ const instanceInfo = this._instanceInfo;
34876
34515
 
34877
34516
  boundingSphere.makeEmpty();
34878
- for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34517
+ for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
34879
34518
 
34880
- if ( drawInfo[ i ].active === false ) continue;
34519
+ if ( instanceInfo[ i ].active === false ) continue;
34881
34520
 
34882
- const geometryId = drawInfo[ i ].geometryIndex;
34521
+ const geometryId = instanceInfo[ i ].geometryIndex;
34883
34522
  this.getMatrixAt( i, _matrix$1 );
34884
34523
  this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
34885
34524
  boundingSphere.union( _sphere$2 );
@@ -34890,7 +34529,7 @@ class BatchedMesh extends Mesh {
34890
34529
 
34891
34530
  addInstance( geometryId ) {
34892
34531
 
34893
- const atCapacity = this._drawInfo.length >= this.maxInstanceCount;
34532
+ const atCapacity = this._instanceInfo.length >= this.maxInstanceCount;
34894
34533
 
34895
34534
  // ensure we're not over geometry
34896
34535
  if ( atCapacity && this._availableInstanceIds.length === 0 ) {
@@ -34899,7 +34538,7 @@ class BatchedMesh extends Mesh {
34899
34538
 
34900
34539
  }
34901
34540
 
34902
- const instanceDrawInfo = {
34541
+ const instanceInfo = {
34903
34542
  visible: true,
34904
34543
  active: true,
34905
34544
  geometryIndex: geometryId,
@@ -34910,19 +34549,20 @@ class BatchedMesh extends Mesh {
34910
34549
  // Prioritize using previously freed instance ids
34911
34550
  if ( this._availableInstanceIds.length > 0 ) {
34912
34551
 
34913
- drawId = this._availableInstanceIds.pop();
34914
- this._drawInfo[ drawId ] = instanceDrawInfo;
34552
+ this._availableInstanceIds.sort( ascIdSort );
34553
+
34554
+ drawId = this._availableInstanceIds.shift();
34555
+ this._instanceInfo[ drawId ] = instanceInfo;
34915
34556
 
34916
34557
  } else {
34917
34558
 
34918
- drawId = this._drawInfo.length;
34919
- this._drawInfo.push( instanceDrawInfo );
34559
+ drawId = this._instanceInfo.length;
34560
+ this._instanceInfo.push( instanceInfo );
34920
34561
 
34921
34562
  }
34922
34563
 
34923
34564
  const matricesTexture = this._matricesTexture;
34924
- const matricesArray = matricesTexture.image.data;
34925
- _identityMatrix.toArray( matricesArray, drawId * 16 );
34565
+ _matrix$1.identity().toArray( matricesTexture.image.data, drawId * 16 );
34926
34566
  matricesTexture.needsUpdate = true;
34927
34567
 
34928
34568
  const colorsTexture = this._colorsTexture;
@@ -34933,91 +34573,54 @@ class BatchedMesh extends Mesh {
34933
34573
 
34934
34574
  }
34935
34575
 
34576
+ this._visibilityChanged = true;
34936
34577
  return drawId;
34937
34578
 
34938
34579
  }
34939
34580
 
34940
- addGeometry( geometry, vertexCount = - 1, indexCount = - 1 ) {
34581
+ addGeometry( geometry, reservedVertexCount = - 1, reservedIndexCount = - 1 ) {
34941
34582
 
34942
34583
  this._initializeGeometry( geometry );
34943
34584
 
34944
34585
  this._validateGeometry( geometry );
34945
34586
 
34946
- // ensure we're not over geometry
34947
- if ( this._drawInfo.length >= this._maxInstanceCount ) {
34948
-
34949
- throw new Error( 'BatchedMesh: Maximum item count reached.' );
34950
-
34951
- }
34952
-
34953
- // get the necessary range fo the geometry
34954
- const reservedRange = {
34587
+ const geometryInfo = {
34588
+ // geometry information
34955
34589
  vertexStart: - 1,
34956
34590
  vertexCount: - 1,
34591
+ reservedVertexCount: - 1,
34592
+
34957
34593
  indexStart: - 1,
34958
34594
  indexCount: - 1,
34959
- };
34960
-
34961
- let lastRange = null;
34962
- const reservedRanges = this._reservedRanges;
34963
- const drawRanges = this._drawRanges;
34964
- const bounds = this._bounds;
34965
- if ( this._geometryCount !== 0 ) {
34966
-
34967
- lastRange = reservedRanges[ reservedRanges.length - 1 ];
34968
-
34969
- }
34970
-
34971
- if ( vertexCount === - 1 ) {
34972
-
34973
- reservedRange.vertexCount = geometry.getAttribute( 'position' ).count;
34974
-
34975
- } else {
34976
-
34977
- reservedRange.vertexCount = vertexCount;
34978
-
34979
- }
34980
-
34981
- if ( lastRange === null ) {
34595
+ reservedIndexCount: - 1,
34982
34596
 
34983
- reservedRange.vertexStart = 0;
34597
+ // draw range information
34598
+ start: - 1,
34599
+ count: - 1,
34984
34600
 
34985
- } else {
34986
-
34987
- reservedRange.vertexStart = lastRange.vertexStart + lastRange.vertexCount;
34601
+ // state
34602
+ boundingBox: null,
34603
+ boundingSphere: null,
34604
+ active: true,
34605
+ };
34988
34606
 
34989
- }
34607
+ const geometryInfoList = this._geometryInfo;
34608
+ geometryInfo.vertexStart = this._nextVertexStart;
34609
+ geometryInfo.reservedVertexCount = reservedVertexCount === - 1 ? geometry.getAttribute( 'position' ).count : reservedVertexCount;
34990
34610
 
34991
34611
  const index = geometry.getIndex();
34992
34612
  const hasIndex = index !== null;
34993
34613
  if ( hasIndex ) {
34994
34614
 
34995
- if ( indexCount === - 1 ) {
34996
-
34997
- reservedRange.indexCount = index.count;
34998
-
34999
- } else {
35000
-
35001
- reservedRange.indexCount = indexCount;
35002
-
35003
- }
35004
-
35005
- if ( lastRange === null ) {
35006
-
35007
- reservedRange.indexStart = 0;
35008
-
35009
- } else {
35010
-
35011
- reservedRange.indexStart = lastRange.indexStart + lastRange.indexCount;
35012
-
35013
- }
34615
+ geometryInfo.indexStart = this._nextIndexStart;
34616
+ geometryInfo.reservedIndexCount = reservedIndexCount === - 1 ? index.count : reservedIndexCount;
35014
34617
 
35015
34618
  }
35016
34619
 
35017
34620
  if (
35018
- reservedRange.indexStart !== - 1 &&
35019
- reservedRange.indexStart + reservedRange.indexCount > this._maxIndexCount ||
35020
- reservedRange.vertexStart + reservedRange.vertexCount > this._maxVertexCount
34621
+ geometryInfo.indexStart !== - 1 &&
34622
+ geometryInfo.indexStart + geometryInfo.reservedIndexCount > this._maxIndexCount ||
34623
+ geometryInfo.vertexStart + geometryInfo.reservedVertexCount > this._maxVertexCount
35021
34624
  ) {
35022
34625
 
35023
34626
  throw new Error( 'BatchedMesh: Reserved space request exceeds the maximum buffer size.' );
@@ -35025,26 +34628,30 @@ class BatchedMesh extends Mesh {
35025
34628
  }
35026
34629
 
35027
34630
  // update id
35028
- const geometryId = this._geometryCount;
35029
- this._geometryCount ++;
35030
-
35031
- // add the reserved range and draw range objects
35032
- reservedRanges.push( reservedRange );
35033
- drawRanges.push( {
35034
- start: hasIndex ? reservedRange.indexStart : reservedRange.vertexStart,
35035
- count: - 1
35036
- } );
35037
- bounds.push( {
35038
- boxInitialized: false,
35039
- box: new Box3(),
34631
+ let geometryId;
34632
+ if ( this._availableGeometryIds.length > 0 ) {
35040
34633
 
35041
- sphereInitialized: false,
35042
- sphere: new Sphere()
35043
- } );
34634
+ this._availableGeometryIds.sort( ascIdSort );
34635
+
34636
+ geometryId = this._availableGeometryIds.shift();
34637
+ geometryInfoList[ geometryId ] = geometryInfo;
34638
+
34639
+
34640
+ } else {
34641
+
34642
+ geometryId = this._geometryCount;
34643
+ this._geometryCount ++;
34644
+ geometryInfoList.push( geometryInfo );
34645
+
34646
+ }
35044
34647
 
35045
34648
  // update the geometry
35046
34649
  this.setGeometryAt( geometryId, geometry );
35047
34650
 
34651
+ // increment the next geometry position
34652
+ this._nextIndexStart = geometryInfo.indexStart + geometryInfo.reservedIndexCount;
34653
+ this._nextVertexStart = geometryInfo.vertexStart + geometryInfo.reservedVertexCount;
34654
+
35048
34655
  return geometryId;
35049
34656
 
35050
34657
  }
@@ -35063,20 +34670,22 @@ class BatchedMesh extends Mesh {
35063
34670
  const hasIndex = batchGeometry.getIndex() !== null;
35064
34671
  const dstIndex = batchGeometry.getIndex();
35065
34672
  const srcIndex = geometry.getIndex();
35066
- const reservedRange = this._reservedRanges[ geometryId ];
34673
+ const geometryInfo = this._geometryInfo[ geometryId ];
35067
34674
  if (
35068
34675
  hasIndex &&
35069
- srcIndex.count > reservedRange.indexCount ||
35070
- geometry.attributes.position.count > reservedRange.vertexCount
34676
+ srcIndex.count > geometryInfo.reservedIndexCount ||
34677
+ geometry.attributes.position.count > geometryInfo.reservedVertexCount
35071
34678
  ) {
35072
34679
 
35073
34680
  throw new Error( 'BatchedMesh: Reserved space not large enough for provided geometry.' );
35074
34681
 
35075
34682
  }
35076
34683
 
35077
- // copy geometry over
35078
- const vertexStart = reservedRange.vertexStart;
35079
- const vertexCount = reservedRange.vertexCount;
34684
+ // copy geometry buffer data over
34685
+ const vertexStart = geometryInfo.vertexStart;
34686
+ const reservedVertexCount = geometryInfo.reservedVertexCount;
34687
+ geometryInfo.vertexCount = geometry.getAttribute( 'position' ).count;
34688
+
35080
34689
  for ( const attributeName in batchGeometry.attributes ) {
35081
34690
 
35082
34691
  // copy attribute data
@@ -35086,7 +34695,7 @@ class BatchedMesh extends Mesh {
35086
34695
 
35087
34696
  // fill the rest in with zeroes
35088
34697
  const itemSize = srcAttribute.itemSize;
35089
- for ( let i = srcAttribute.count, l = vertexCount; i < l; i ++ ) {
34698
+ for ( let i = srcAttribute.count, l = reservedVertexCount; i < l; i ++ ) {
35090
34699
 
35091
34700
  const index = vertexStart + i;
35092
34701
  for ( let c = 0; c < itemSize; c ++ ) {
@@ -35098,14 +34707,16 @@ class BatchedMesh extends Mesh {
35098
34707
  }
35099
34708
 
35100
34709
  dstAttribute.needsUpdate = true;
35101
- dstAttribute.addUpdateRange( vertexStart * itemSize, vertexCount * itemSize );
34710
+ dstAttribute.addUpdateRange( vertexStart * itemSize, reservedVertexCount * itemSize );
35102
34711
 
35103
34712
  }
35104
34713
 
35105
34714
  // copy index
35106
34715
  if ( hasIndex ) {
35107
34716
 
35108
- const indexStart = reservedRange.indexStart;
34717
+ const indexStart = geometryInfo.indexStart;
34718
+ const reservedIndexCount = geometryInfo.reservedIndexCount;
34719
+ geometryInfo.indexCount = geometry.getIndex().count;
35109
34720
 
35110
34721
  // copy index data over
35111
34722
  for ( let i = 0; i < srcIndex.count; i ++ ) {
@@ -35115,69 +34726,80 @@ class BatchedMesh extends Mesh {
35115
34726
  }
35116
34727
 
35117
34728
  // fill the rest in with zeroes
35118
- for ( let i = srcIndex.count, l = reservedRange.indexCount; i < l; i ++ ) {
34729
+ for ( let i = srcIndex.count, l = reservedIndexCount; i < l; i ++ ) {
35119
34730
 
35120
34731
  dstIndex.setX( indexStart + i, vertexStart );
35121
34732
 
35122
34733
  }
35123
34734
 
35124
34735
  dstIndex.needsUpdate = true;
35125
- dstIndex.addUpdateRange( indexStart, reservedRange.indexCount );
34736
+ dstIndex.addUpdateRange( indexStart, geometryInfo.reservedIndexCount );
35126
34737
 
35127
34738
  }
35128
34739
 
34740
+ // update the draw range
34741
+ geometryInfo.start = hasIndex ? geometryInfo.indexStart : geometryInfo.vertexStart;
34742
+ geometryInfo.count = hasIndex ? geometryInfo.indexCount : geometryInfo.vertexCount;
34743
+
35129
34744
  // store the bounding boxes
35130
- const bound = this._bounds[ geometryId ];
34745
+ geometryInfo.boundingBox = null;
35131
34746
  if ( geometry.boundingBox !== null ) {
35132
34747
 
35133
- bound.box.copy( geometry.boundingBox );
35134
- bound.boxInitialized = true;
35135
-
35136
- } else {
35137
-
35138
- bound.boxInitialized = false;
34748
+ geometryInfo.boundingBox = geometry.boundingBox.clone();
35139
34749
 
35140
34750
  }
35141
34751
 
34752
+ geometryInfo.boundingSphere = null;
35142
34753
  if ( geometry.boundingSphere !== null ) {
35143
34754
 
35144
- bound.sphere.copy( geometry.boundingSphere );
35145
- bound.sphereInitialized = true;
35146
-
35147
- } else {
35148
-
35149
- bound.sphereInitialized = false;
34755
+ geometryInfo.boundingSphere = geometry.boundingSphere.clone();
35150
34756
 
35151
34757
  }
35152
34758
 
35153
- // set drawRange count
35154
- const drawRange = this._drawRanges[ geometryId ];
35155
- const posAttr = geometry.getAttribute( 'position' );
35156
- drawRange.count = hasIndex ? srcIndex.count : posAttr.count;
35157
34759
  this._visibilityChanged = true;
35158
-
35159
34760
  return geometryId;
35160
34761
 
35161
34762
  }
35162
34763
 
35163
- /*
35164
34764
  deleteGeometry( geometryId ) {
35165
34765
 
35166
- // TODO: delete geometry and associated instances
34766
+ const geometryInfoList = this._geometryInfo;
34767
+ if ( geometryId >= geometryInfoList.length || geometryInfoList[ geometryId ].active === false ) {
34768
+
34769
+ return this;
34770
+
34771
+ }
34772
+
34773
+ // delete any instances associated with this geometry
34774
+ const instanceInfo = this._instanceInfo;
34775
+ for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
34776
+
34777
+ if ( instanceInfo[ i ].geometryIndex === geometryId ) {
34778
+
34779
+ this.deleteInstance( i );
34780
+
34781
+ }
34782
+
34783
+ }
34784
+
34785
+ geometryInfoList[ geometryId ].active = false;
34786
+ this._availableGeometryIds.push( geometryId );
34787
+ this._visibilityChanged = true;
34788
+
34789
+ return this;
35167
34790
 
35168
34791
  }
35169
- */
35170
34792
 
35171
34793
  deleteInstance( instanceId ) {
35172
34794
 
35173
- const drawInfo = this._drawInfo;
35174
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34795
+ const instanceInfo = this._instanceInfo;
34796
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
35175
34797
 
35176
34798
  return this;
35177
34799
 
35178
34800
  }
35179
34801
 
35180
- drawInfo[ instanceId ].active = false;
34802
+ instanceInfo[ instanceId ].active = false;
35181
34803
  this._availableInstanceIds.push( instanceId );
35182
34804
  this._visibilityChanged = true;
35183
34805
 
@@ -35185,6 +34807,95 @@ class BatchedMesh extends Mesh {
35185
34807
 
35186
34808
  }
35187
34809
 
34810
+ optimize() {
34811
+
34812
+ // track the next indices to copy data to
34813
+ let nextVertexStart = 0;
34814
+ let nextIndexStart = 0;
34815
+
34816
+ // Iterate over all geometry ranges in order sorted from earliest in the geometry buffer to latest
34817
+ // in the geometry buffer. Because draw range objects can be reused there is no guarantee of their order.
34818
+ const geometryInfoList = this._geometryInfo;
34819
+ const indices = geometryInfoList
34820
+ .map( ( e, i ) => i )
34821
+ .sort( ( a, b ) => {
34822
+
34823
+ return geometryInfoList[ a ].vertexStart - geometryInfoList[ b ].vertexStart;
34824
+
34825
+ } );
34826
+
34827
+ const geometry = this.geometry;
34828
+ for ( let i = 0, l = geometryInfoList.length; i < l; i ++ ) {
34829
+
34830
+ // if a geometry range is inactive then don't copy anything
34831
+ const index = indices[ i ];
34832
+ const geometryInfo = geometryInfoList[ index ];
34833
+ if ( geometryInfo.active === false ) {
34834
+
34835
+ continue;
34836
+
34837
+ }
34838
+
34839
+ // if a geometry contains an index buffer then shift it, as well
34840
+ if ( geometry.index !== null ) {
34841
+
34842
+ if ( geometryInfo.indexStart !== nextIndexStart ) {
34843
+
34844
+ const { indexStart, vertexStart, reservedIndexCount } = geometryInfo;
34845
+ const index = geometry.index;
34846
+ const array = index.array;
34847
+
34848
+ // shift the index pointers based on how the vertex data will shift
34849
+ // adjusting the index must happen first so the original vertex start value is available
34850
+ const elementDelta = nextVertexStart - vertexStart;
34851
+ for ( let j = indexStart; j < indexStart + reservedIndexCount; j ++ ) {
34852
+
34853
+ array[ j ] = array[ j ] + elementDelta;
34854
+
34855
+ }
34856
+
34857
+ index.array.copyWithin( nextIndexStart, indexStart, indexStart + reservedIndexCount );
34858
+ index.addUpdateRange( nextIndexStart, reservedIndexCount );
34859
+
34860
+ geometryInfo.indexStart = nextIndexStart;
34861
+
34862
+ }
34863
+
34864
+ nextIndexStart += geometryInfo.reservedIndexCount;
34865
+
34866
+ }
34867
+
34868
+ // if a geometry needs to be moved then copy attribute data to overwrite unused space
34869
+ if ( geometryInfo.vertexStart !== nextVertexStart ) {
34870
+
34871
+ const { vertexStart, reservedVertexCount } = geometryInfo;
34872
+ const attributes = geometry.attributes;
34873
+ for ( const key in attributes ) {
34874
+
34875
+ const attribute = attributes[ key ];
34876
+ const { array, itemSize } = attribute;
34877
+ array.copyWithin( nextVertexStart * itemSize, vertexStart * itemSize, ( vertexStart + reservedVertexCount ) * itemSize );
34878
+ attribute.addUpdateRange( nextVertexStart * itemSize, reservedVertexCount * itemSize );
34879
+
34880
+ }
34881
+
34882
+ geometryInfo.vertexStart = nextVertexStart;
34883
+
34884
+ }
34885
+
34886
+ nextVertexStart += geometryInfo.reservedVertexCount;
34887
+ geometryInfo.start = geometry.index ? geometryInfo.indexStart : geometryInfo.vertexStart;
34888
+
34889
+ // step the next geometry points to the shifted position
34890
+ this._nextIndexStart = geometry.index ? geometryInfo.indexStart + geometryInfo.reservedIndexCount : 0;
34891
+ this._nextVertexStart = geometryInfo.vertexStart + geometryInfo.reservedVertexCount;
34892
+
34893
+ }
34894
+
34895
+ return this;
34896
+
34897
+ }
34898
+
35188
34899
  // get bounding box and compute it if it doesn't exist
35189
34900
  getBoundingBoxAt( geometryId, target ) {
35190
34901
 
@@ -35195,17 +34906,14 @@ class BatchedMesh extends Mesh {
35195
34906
  }
35196
34907
 
35197
34908
  // compute bounding box
35198
- const bound = this._bounds[ geometryId ];
35199
- const box = bound.box;
35200
34909
  const geometry = this.geometry;
35201
- if ( bound.boxInitialized === false ) {
35202
-
35203
- box.makeEmpty();
34910
+ const geometryInfo = this._geometryInfo[ geometryId ];
34911
+ if ( geometryInfo.boundingBox === null ) {
35204
34912
 
34913
+ const box = new Box3();
35205
34914
  const index = geometry.index;
35206
34915
  const position = geometry.attributes.position;
35207
- const drawRange = this._drawRanges[ geometryId ];
35208
- for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
34916
+ for ( let i = geometryInfo.start, l = geometryInfo.start + geometryInfo.count; i < l; i ++ ) {
35209
34917
 
35210
34918
  let iv = i;
35211
34919
  if ( index ) {
@@ -35218,11 +34926,11 @@ class BatchedMesh extends Mesh {
35218
34926
 
35219
34927
  }
35220
34928
 
35221
- bound.boxInitialized = true;
34929
+ geometryInfo.boundingBox = box;
35222
34930
 
35223
34931
  }
35224
34932
 
35225
- target.copy( box );
34933
+ target.copy( geometryInfo.boundingBox );
35226
34934
  return target;
35227
34935
 
35228
34936
  }
@@ -35237,22 +34945,19 @@ class BatchedMesh extends Mesh {
35237
34945
  }
35238
34946
 
35239
34947
  // compute bounding sphere
35240
- const bound = this._bounds[ geometryId ];
35241
- const sphere = bound.sphere;
35242
34948
  const geometry = this.geometry;
35243
- if ( bound.sphereInitialized === false ) {
35244
-
35245
- sphere.makeEmpty();
34949
+ const geometryInfo = this._geometryInfo[ geometryId ];
34950
+ if ( geometryInfo.boundingSphere === null ) {
35246
34951
 
34952
+ const sphere = new Sphere();
35247
34953
  this.getBoundingBoxAt( geometryId, _box$1 );
35248
34954
  _box$1.getCenter( sphere.center );
35249
34955
 
35250
34956
  const index = geometry.index;
35251
34957
  const position = geometry.attributes.position;
35252
- const drawRange = this._drawRanges[ geometryId ];
35253
34958
 
35254
34959
  let maxRadiusSq = 0;
35255
- for ( let i = drawRange.start, l = drawRange.start + drawRange.count; i < l; i ++ ) {
34960
+ for ( let i = geometryInfo.start, l = geometryInfo.start + geometryInfo.count; i < l; i ++ ) {
35256
34961
 
35257
34962
  let iv = i;
35258
34963
  if ( index ) {
@@ -35267,24 +34972,21 @@ class BatchedMesh extends Mesh {
35267
34972
  }
35268
34973
 
35269
34974
  sphere.radius = Math.sqrt( maxRadiusSq );
35270
- bound.sphereInitialized = true;
34975
+ geometryInfo.boundingSphere = sphere;
35271
34976
 
35272
34977
  }
35273
34978
 
35274
- target.copy( sphere );
34979
+ target.copy( geometryInfo.boundingSphere );
35275
34980
  return target;
35276
34981
 
35277
34982
  }
35278
34983
 
35279
34984
  setMatrixAt( instanceId, matrix ) {
35280
34985
 
35281
- // @TODO: Map geometryId to index of the arrays because
35282
- // optimize() can make geometryId mismatch the index
35283
-
35284
- const drawInfo = this._drawInfo;
34986
+ const instanceInfo = this._instanceInfo;
35285
34987
  const matricesTexture = this._matricesTexture;
35286
34988
  const matricesArray = this._matricesTexture.image.data;
35287
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34989
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
35288
34990
 
35289
34991
  return this;
35290
34992
 
@@ -35299,9 +35001,9 @@ class BatchedMesh extends Mesh {
35299
35001
 
35300
35002
  getMatrixAt( instanceId, matrix ) {
35301
35003
 
35302
- const drawInfo = this._drawInfo;
35004
+ const instanceInfo = this._instanceInfo;
35303
35005
  const matricesArray = this._matricesTexture.image.data;
35304
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35006
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
35305
35007
 
35306
35008
  return null;
35307
35009
 
@@ -35319,13 +35021,10 @@ class BatchedMesh extends Mesh {
35319
35021
 
35320
35022
  }
35321
35023
 
35322
- // @TODO: Map id to index of the arrays because
35323
- // optimize() can make id mismatch the index
35324
-
35325
35024
  const colorsTexture = this._colorsTexture;
35326
35025
  const colorsArray = this._colorsTexture.image.data;
35327
- const drawInfo = this._drawInfo;
35328
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35026
+ const instanceInfo = this._instanceInfo;
35027
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
35329
35028
 
35330
35029
  return this;
35331
35030
 
@@ -35341,8 +35040,8 @@ class BatchedMesh extends Mesh {
35341
35040
  getColorAt( instanceId, color ) {
35342
35041
 
35343
35042
  const colorsArray = this._colorsTexture.image.data;
35344
- const drawInfo = this._drawInfo;
35345
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35043
+ const instanceInfo = this._instanceInfo;
35044
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
35346
35045
 
35347
35046
  return null;
35348
35047
 
@@ -35356,18 +35055,18 @@ class BatchedMesh extends Mesh {
35356
35055
 
35357
35056
  // if the geometry is out of range, not active, or visibility state
35358
35057
  // does not change then return early
35359
- const drawInfo = this._drawInfo;
35058
+ const instanceInfo = this._instanceInfo;
35360
35059
  if (
35361
- instanceId >= drawInfo.length ||
35362
- drawInfo[ instanceId ].active === false ||
35363
- drawInfo[ instanceId ].visible === value
35060
+ instanceId >= instanceInfo.length ||
35061
+ instanceInfo[ instanceId ].active === false ||
35062
+ instanceInfo[ instanceId ].visible === value
35364
35063
  ) {
35365
35064
 
35366
35065
  return this;
35367
35066
 
35368
35067
  }
35369
35068
 
35370
- drawInfo[ instanceId ].visible = value;
35069
+ instanceInfo[ instanceId ].visible = value;
35371
35070
  this._visibilityChanged = true;
35372
35071
 
35373
35072
  return this;
@@ -35377,35 +35076,36 @@ class BatchedMesh extends Mesh {
35377
35076
  getVisibleAt( instanceId ) {
35378
35077
 
35379
35078
  // return early if the geometry is out of range or not active
35380
- const drawInfo = this._drawInfo;
35381
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35079
+ const instanceInfo = this._instanceInfo;
35080
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
35382
35081
 
35383
35082
  return false;
35384
35083
 
35385
35084
  }
35386
35085
 
35387
- return drawInfo[ instanceId ].visible;
35086
+ return instanceInfo[ instanceId ].visible;
35388
35087
 
35389
35088
  }
35390
35089
 
35391
35090
  setGeometryIdAt( instanceId, geometryId ) {
35392
35091
 
35393
35092
  // return early if the geometry is out of range or not active
35394
- const drawInfo = this._drawInfo;
35395
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35093
+ const instanceInfo = this._instanceInfo;
35094
+ const geometryInfoList = this._geometryInfo;
35095
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
35396
35096
 
35397
35097
  return null;
35398
35098
 
35399
35099
  }
35400
35100
 
35401
35101
  // check if the provided geometryId is within the valid range
35402
- if ( geometryId < 0 || geometryId >= this._geometryCount ) {
35102
+ if ( geometryId >= geometryInfoList.length || geometryInfoList[ geometryId ].active === false ) {
35403
35103
 
35404
35104
  return null;
35405
35105
 
35406
35106
  }
35407
35107
 
35408
- drawInfo[ instanceId ].geometryIndex = geometryId;
35108
+ instanceInfo[ instanceId ].geometryIndex = geometryId;
35409
35109
 
35410
35110
  return this;
35411
35111
 
@@ -35413,14 +35113,14 @@ class BatchedMesh extends Mesh {
35413
35113
 
35414
35114
  getGeometryIdAt( instanceId ) {
35415
35115
 
35416
- const drawInfo = this._drawInfo;
35417
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35116
+ const instanceInfo = this._instanceInfo;
35117
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
35418
35118
 
35419
35119
  return - 1;
35420
35120
 
35421
35121
  }
35422
35122
 
35423
- return drawInfo[ instanceId ].geometryIndex;
35123
+ return instanceInfo[ instanceId ].geometryIndex;
35424
35124
 
35425
35125
  }
35426
35126
 
@@ -35432,19 +35132,136 @@ class BatchedMesh extends Mesh {
35432
35132
 
35433
35133
  }
35434
35134
 
35435
- const drawRange = this._drawRanges[ geometryId ];
35135
+ const geometryInfo = this._geometryInfo[ geometryId ];
35136
+ target.vertexStart = geometryInfo.vertexStart;
35137
+ target.vertexCount = geometryInfo.vertexCount;
35138
+ target.reservedVertexCount = geometryInfo.reservedVertexCount;
35139
+
35140
+ target.indexStart = geometryInfo.indexStart;
35141
+ target.indexCount = geometryInfo.indexCount;
35142
+ target.reservedIndexCount = geometryInfo.reservedIndexCount;
35436
35143
 
35437
- target.start = drawRange.start;
35438
- target.count = drawRange.count;
35144
+ target.start = geometryInfo.start;
35145
+ target.count = geometryInfo.count;
35439
35146
 
35440
35147
  return target;
35441
35148
 
35442
35149
  }
35443
35150
 
35151
+ setInstanceCount( maxInstanceCount ) {
35152
+
35153
+ // shrink the available instances as much as possible
35154
+ const availableInstanceIds = this._availableInstanceIds;
35155
+ const instanceInfo = this._instanceInfo;
35156
+ availableInstanceIds.sort( ascIdSort );
35157
+ while ( availableInstanceIds[ availableInstanceIds.length - 1 ] === instanceInfo.length ) {
35158
+
35159
+ instanceInfo.pop();
35160
+ availableInstanceIds.pop();
35161
+
35162
+ }
35163
+
35164
+ // throw an error if it can't be shrunk to the desired size
35165
+ if ( maxInstanceCount < instanceInfo.length ) {
35166
+
35167
+ throw new Error( `BatchedMesh: Instance ids outside the range ${ maxInstanceCount } are being used. Cannot shrink instance count.` );
35168
+
35169
+ }
35170
+
35171
+ // copy the multi draw counts
35172
+ const multiDrawCounts = new Int32Array( maxInstanceCount );
35173
+ const multiDrawStarts = new Int32Array( maxInstanceCount );
35174
+ copyArrayContents( this._multiDrawCounts, multiDrawCounts );
35175
+ copyArrayContents( this._multiDrawStarts, multiDrawStarts );
35176
+
35177
+ this._multiDrawCounts = multiDrawCounts;
35178
+ this._multiDrawStarts = multiDrawStarts;
35179
+ this._maxInstanceCount = maxInstanceCount;
35180
+
35181
+ // update texture data for instance sampling
35182
+ const indirectTexture = this._indirectTexture;
35183
+ const matricesTexture = this._matricesTexture;
35184
+ const colorsTexture = this._colorsTexture;
35185
+
35186
+ indirectTexture.dispose();
35187
+ this._initIndirectTexture();
35188
+ copyArrayContents( indirectTexture.image.data, this._indirectTexture.image.data );
35189
+
35190
+ matricesTexture.dispose();
35191
+ this._initMatricesTexture();
35192
+ copyArrayContents( matricesTexture.image.data, this._matricesTexture.image.data );
35193
+
35194
+ if ( colorsTexture ) {
35195
+
35196
+ colorsTexture.dispose();
35197
+ this._initColorsTexture();
35198
+ copyArrayContents( colorsTexture.image.data, this._colorsTexture.image.data );
35199
+
35200
+ }
35201
+
35202
+ }
35203
+
35204
+ setGeometrySize( maxVertexCount, maxIndexCount ) {
35205
+
35206
+ // Check if we can shrink to the requested vertex attribute size
35207
+ const validRanges = [ ...this._geometryInfo ].filter( info => info.active );
35208
+ const requiredVertexLength = Math.max( ...validRanges.map( range => range.vertexStart + range.reservedVertexCount ) );
35209
+ if ( requiredVertexLength > maxVertexCount ) {
35210
+
35211
+ throw new Error( `BatchedMesh: Geometry vertex values are being used outside the range ${ maxIndexCount }. Cannot shrink further.` );
35212
+
35213
+ }
35214
+
35215
+ // Check if we can shrink to the requested index attribute size
35216
+ if ( this.geometry.index ) {
35217
+
35218
+ const requiredIndexLength = Math.max( ...validRanges.map( range => range.indexStart + range.reservedIndexCount ) );
35219
+ if ( requiredIndexLength > maxIndexCount ) {
35220
+
35221
+ throw new Error( `BatchedMesh: Geometry index values are being used outside the range ${ maxIndexCount }. Cannot shrink further.` );
35222
+
35223
+ }
35224
+
35225
+ }
35226
+
35227
+ //
35228
+
35229
+ // dispose of the previous geometry
35230
+ const oldGeometry = this.geometry;
35231
+ oldGeometry.dispose();
35232
+
35233
+ // recreate the geometry needed based on the previous variant
35234
+ this._maxVertexCount = maxVertexCount;
35235
+ this._maxIndexCount = maxIndexCount;
35236
+
35237
+ if ( this._geometryInitialized ) {
35238
+
35239
+ this._geometryInitialized = false;
35240
+ this.geometry = new BufferGeometry();
35241
+ this._initializeGeometry( oldGeometry );
35242
+
35243
+ }
35244
+
35245
+ // copy data from the previous geometry
35246
+ const geometry = this.geometry;
35247
+ if ( oldGeometry.index ) {
35248
+
35249
+ copyArrayContents( oldGeometry.index.array, geometry.index.array );
35250
+
35251
+ }
35252
+
35253
+ for ( const key in oldGeometry.attributes ) {
35254
+
35255
+ copyArrayContents( oldGeometry.attributes[ key ].array, geometry.attributes[ key ].array );
35256
+
35257
+ }
35258
+
35259
+ }
35260
+
35444
35261
  raycast( raycaster, intersects ) {
35445
35262
 
35446
- const drawInfo = this._drawInfo;
35447
- const drawRanges = this._drawRanges;
35263
+ const instanceInfo = this._instanceInfo;
35264
+ const geometryInfoList = this._geometryInfo;
35448
35265
  const matrixWorld = this.matrixWorld;
35449
35266
  const batchGeometry = this.geometry;
35450
35267
 
@@ -35464,19 +35281,19 @@ class BatchedMesh extends Mesh {
35464
35281
 
35465
35282
  }
35466
35283
 
35467
- for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
35284
+ for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
35468
35285
 
35469
- if ( ! drawInfo[ i ].visible || ! drawInfo[ i ].active ) {
35286
+ if ( ! instanceInfo[ i ].visible || ! instanceInfo[ i ].active ) {
35470
35287
 
35471
35288
  continue;
35472
35289
 
35473
35290
  }
35474
35291
 
35475
- const geometryId = drawInfo[ i ].geometryIndex;
35476
- const drawRange = drawRanges[ geometryId ];
35477
- _mesh.geometry.setDrawRange( drawRange.start, drawRange.count );
35292
+ const geometryId = instanceInfo[ i ].geometryIndex;
35293
+ const geometryInfo = geometryInfoList[ geometryId ];
35294
+ _mesh.geometry.setDrawRange( geometryInfo.start, geometryInfo.count );
35478
35295
 
35479
- // ge the intersects
35296
+ // get the intersects
35480
35297
  this.getMatrixAt( i, _mesh.matrixWorld ).premultiply( matrixWorld );
35481
35298
  this.getBoundingBoxAt( geometryId, _mesh.geometry.boundingBox );
35482
35299
  this.getBoundingSphereAt( geometryId, _mesh.geometry.boundingSphere );
@@ -35513,17 +35330,13 @@ class BatchedMesh extends Mesh {
35513
35330
  this.boundingBox = source.boundingBox !== null ? source.boundingBox.clone() : null;
35514
35331
  this.boundingSphere = source.boundingSphere !== null ? source.boundingSphere.clone() : null;
35515
35332
 
35516
- this._drawRanges = source._drawRanges.map( range => ( { ...range } ) );
35517
- this._reservedRanges = source._reservedRanges.map( range => ( { ...range } ) );
35518
-
35519
- this._drawInfo = source._drawInfo.map( inf => ( { ...inf } ) );
35520
- this._bounds = source._bounds.map( bound => ( {
35521
- boxInitialized: bound.boxInitialized,
35522
- box: bound.box.clone(),
35333
+ this._geometryInfo = source._geometryInfo.map( info => ( {
35334
+ ...info,
35523
35335
 
35524
- sphereInitialized: bound.sphereInitialized,
35525
- sphere: bound.sphere.clone()
35336
+ boundingBox: info.boundingBox !== null ? info.boundingBox.clone() : null,
35337
+ boundingSphere: info.boundingSphere !== null ? info.boundingSphere.clone() : null,
35526
35338
  } ) );
35339
+ this._instanceInfo = source._instanceInfo.map( info => ( { ...info } ) );
35527
35340
 
35528
35341
  this._maxInstanceCount = source._maxInstanceCount;
35529
35342
  this._maxVertexCount = source._maxVertexCount;
@@ -35585,10 +35398,10 @@ class BatchedMesh extends Mesh {
35585
35398
  const index = geometry.getIndex();
35586
35399
  const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;
35587
35400
 
35588
- const drawInfo = this._drawInfo;
35401
+ const instanceInfo = this._instanceInfo;
35589
35402
  const multiDrawStarts = this._multiDrawStarts;
35590
35403
  const multiDrawCounts = this._multiDrawCounts;
35591
- const drawRanges = this._drawRanges;
35404
+ const geometryInfoList = this._geometryInfo;
35592
35405
  const perObjectFrustumCulled = this.perObjectFrustumCulled;
35593
35406
  const indirectTexture = this._indirectTexture;
35594
35407
  const indirectArray = indirectTexture.image.data;
@@ -35596,29 +35409,29 @@ class BatchedMesh extends Mesh {
35596
35409
  // prepare the frustum in the local frame
35597
35410
  if ( perObjectFrustumCulled ) {
35598
35411
 
35599
- _projScreenMatrix$2
35412
+ _matrix$1
35600
35413
  .multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse )
35601
35414
  .multiply( this.matrixWorld );
35602
35415
  _frustum.setFromProjectionMatrix(
35603
- _projScreenMatrix$2,
35416
+ _matrix$1,
35604
35417
  renderer.coordinateSystem
35605
35418
  );
35606
35419
 
35607
35420
  }
35608
35421
 
35609
- let count = 0;
35422
+ let multiDrawCount = 0;
35610
35423
  if ( this.sortObjects ) {
35611
35424
 
35612
35425
  // get the camera position in the local frame
35613
- _invMatrixWorld.copy( this.matrixWorld ).invert();
35614
- _vector$5.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _invMatrixWorld );
35615
- _forward.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ).transformDirection( _invMatrixWorld );
35426
+ _matrix$1.copy( this.matrixWorld ).invert();
35427
+ _vector$5.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _matrix$1 );
35428
+ _forward.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ).transformDirection( _matrix$1 );
35616
35429
 
35617
- for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
35430
+ for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
35618
35431
 
35619
- if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
35432
+ if ( instanceInfo[ i ].visible && instanceInfo[ i ].active ) {
35620
35433
 
35621
- const geometryId = drawInfo[ i ].geometryIndex;
35434
+ const geometryId = instanceInfo[ i ].geometryIndex;
35622
35435
 
35623
35436
  // get the bounds in world space
35624
35437
  this.getMatrixAt( i, _matrix$1 );
@@ -35635,8 +35448,9 @@ class BatchedMesh extends Mesh {
35635
35448
  if ( ! culled ) {
35636
35449
 
35637
35450
  // get the distance from camera used for sorting
35451
+ const geometryInfo = geometryInfoList[ geometryId ];
35638
35452
  const z = _temp.subVectors( _sphere$2.center, _vector$5 ).dot( _forward );
35639
- _renderList.push( drawRanges[ geometryId ], z, i );
35453
+ _renderList.push( geometryInfo.start, geometryInfo.count, z, i );
35640
35454
 
35641
35455
  }
35642
35456
 
@@ -35660,10 +35474,10 @@ class BatchedMesh extends Mesh {
35660
35474
  for ( let i = 0, l = list.length; i < l; i ++ ) {
35661
35475
 
35662
35476
  const item = list[ i ];
35663
- multiDrawStarts[ count ] = item.start * bytesPerElement;
35664
- multiDrawCounts[ count ] = item.count;
35665
- indirectArray[ count ] = item.index;
35666
- count ++;
35477
+ multiDrawStarts[ multiDrawCount ] = item.start * bytesPerElement;
35478
+ multiDrawCounts[ multiDrawCount ] = item.count;
35479
+ indirectArray[ multiDrawCount ] = item.index;
35480
+ multiDrawCount ++;
35667
35481
 
35668
35482
  }
35669
35483
 
@@ -35671,11 +35485,11 @@ class BatchedMesh extends Mesh {
35671
35485
 
35672
35486
  } else {
35673
35487
 
35674
- for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
35488
+ for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
35675
35489
 
35676
- if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
35490
+ if ( instanceInfo[ i ].visible && instanceInfo[ i ].active ) {
35677
35491
 
35678
- const geometryId = drawInfo[ i ].geometryIndex;
35492
+ const geometryId = instanceInfo[ i ].geometryIndex;
35679
35493
 
35680
35494
  // determine whether the batched geometry is within the frustum
35681
35495
  let culled = false;
@@ -35690,11 +35504,11 @@ class BatchedMesh extends Mesh {
35690
35504
 
35691
35505
  if ( ! culled ) {
35692
35506
 
35693
- const range = drawRanges[ geometryId ];
35694
- multiDrawStarts[ count ] = range.start * bytesPerElement;
35695
- multiDrawCounts[ count ] = range.count;
35696
- indirectArray[ count ] = i;
35697
- count ++;
35507
+ const geometryInfo = geometryInfoList[ geometryId ];
35508
+ multiDrawStarts[ multiDrawCount ] = geometryInfo.start * bytesPerElement;
35509
+ multiDrawCounts[ multiDrawCount ] = geometryInfo.count;
35510
+ indirectArray[ multiDrawCount ] = i;
35511
+ multiDrawCount ++;
35698
35512
 
35699
35513
  }
35700
35514
 
@@ -35705,7 +35519,7 @@ class BatchedMesh extends Mesh {
35705
35519
  }
35706
35520
 
35707
35521
  indirectTexture.needsUpdate = true;
35708
- this._multiDrawCount = count;
35522
+ this._multiDrawCount = multiDrawCount;
35709
35523
  this._visibilityChanged = false;
35710
35524
 
35711
35525
  }
@@ -35720,14 +35534,18 @@ class BatchedMesh extends Mesh {
35720
35534
 
35721
35535
  class LineBasicMaterial extends Material {
35722
35536
 
35537
+ static get type() {
35538
+
35539
+ return 'LineBasicMaterial';
35540
+
35541
+ }
35542
+
35723
35543
  constructor( parameters ) {
35724
35544
 
35725
35545
  super();
35726
35546
 
35727
35547
  this.isLineBasicMaterial = true;
35728
35548
 
35729
- this.type = 'LineBasicMaterial';
35730
-
35731
35549
  this.color = new Color( 0xffffff );
35732
35550
 
35733
35551
  this.map = null;
@@ -36065,14 +35883,18 @@ class LineLoop extends Line {
36065
35883
 
36066
35884
  class PointsMaterial extends Material {
36067
35885
 
35886
+ static get type() {
35887
+
35888
+ return 'PointsMaterial';
35889
+
35890
+ }
35891
+
36068
35892
  constructor( parameters ) {
36069
35893
 
36070
35894
  super();
36071
35895
 
36072
35896
  this.isPointsMaterial = true;
36073
35897
 
36074
- this.type = 'PointsMaterial';
36075
-
36076
35898
  this.color = new Color( 0xffffff );
36077
35899
 
36078
35900
  this.map = null;
@@ -38762,14 +38584,14 @@ class CylinderGeometry extends BufferGeometry {
38762
38584
 
38763
38585
  // faces
38764
38586
 
38765
- if ( radiusTop > 0 ) {
38587
+ if ( radiusTop > 0 || y !== 0 ) {
38766
38588
 
38767
38589
  indices.push( a, b, d );
38768
38590
  groupCount += 3;
38769
38591
 
38770
38592
  }
38771
38593
 
38772
- if ( radiusBottom > 0 ) {
38594
+ if ( radiusBottom > 0 || y !== heightSegments - 1 ) {
38773
38595
 
38774
38596
  indices.push( b, c, d );
38775
38597
  groupCount += 3;
@@ -42429,14 +42251,18 @@ var Geometries = /*#__PURE__*/Object.freeze({
42429
42251
 
42430
42252
  class ShadowMaterial extends Material {
42431
42253
 
42254
+ static get type() {
42255
+
42256
+ return 'ShadowMaterial';
42257
+
42258
+ }
42259
+
42432
42260
  constructor( parameters ) {
42433
42261
 
42434
42262
  super();
42435
42263
 
42436
42264
  this.isShadowMaterial = true;
42437
42265
 
42438
- this.type = 'ShadowMaterial';
42439
-
42440
42266
  this.color = new Color( 0x000000 );
42441
42267
  this.transparent = true;
42442
42268
 
@@ -42462,20 +42288,30 @@ class ShadowMaterial extends Material {
42462
42288
 
42463
42289
  class RawShaderMaterial extends ShaderMaterial {
42464
42290
 
42291
+ static get type() {
42292
+
42293
+ return 'RawShaderMaterial';
42294
+
42295
+ }
42296
+
42465
42297
  constructor( parameters ) {
42466
42298
 
42467
42299
  super( parameters );
42468
42300
 
42469
42301
  this.isRawShaderMaterial = true;
42470
42302
 
42471
- this.type = 'RawShaderMaterial';
42472
-
42473
42303
  }
42474
42304
 
42475
42305
  }
42476
42306
 
42477
42307
  class MeshStandardMaterial extends Material {
42478
42308
 
42309
+ static get type() {
42310
+
42311
+ return 'MeshStandardMaterial';
42312
+
42313
+ }
42314
+
42479
42315
  constructor( parameters ) {
42480
42316
 
42481
42317
  super();
@@ -42484,8 +42320,6 @@ class MeshStandardMaterial extends Material {
42484
42320
 
42485
42321
  this.defines = { 'STANDARD': '' };
42486
42322
 
42487
- this.type = 'MeshStandardMaterial';
42488
-
42489
42323
  this.color = new Color( 0xffffff ); // diffuse
42490
42324
  this.roughness = 1.0;
42491
42325
  this.metalness = 0.0;
@@ -42596,6 +42430,12 @@ class MeshStandardMaterial extends Material {
42596
42430
 
42597
42431
  class MeshPhysicalMaterial extends MeshStandardMaterial {
42598
42432
 
42433
+ static get type() {
42434
+
42435
+ return 'MeshPhysicalMaterial';
42436
+
42437
+ }
42438
+
42599
42439
  constructor( parameters ) {
42600
42440
 
42601
42441
  super();
@@ -42609,8 +42449,6 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
42609
42449
 
42610
42450
  };
42611
42451
 
42612
- this.type = 'MeshPhysicalMaterial';
42613
-
42614
42452
  this.anisotropyRotation = 0;
42615
42453
  this.anisotropyMap = null;
42616
42454
 
@@ -42834,14 +42672,18 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
42834
42672
 
42835
42673
  class MeshPhongMaterial extends Material {
42836
42674
 
42675
+ static get type() {
42676
+
42677
+ return 'MeshPhongMaterial';
42678
+
42679
+ }
42680
+
42837
42681
  constructor( parameters ) {
42838
42682
 
42839
42683
  super();
42840
42684
 
42841
42685
  this.isMeshPhongMaterial = true;
42842
42686
 
42843
- this.type = 'MeshPhongMaterial';
42844
-
42845
42687
  this.color = new Color( 0xffffff ); // diffuse
42846
42688
  this.specular = new Color( 0x111111 );
42847
42689
  this.shininess = 30;
@@ -42950,6 +42792,12 @@ class MeshPhongMaterial extends Material {
42950
42792
 
42951
42793
  class MeshToonMaterial extends Material {
42952
42794
 
42795
+ static get type() {
42796
+
42797
+ return 'MeshToonMaterial';
42798
+
42799
+ }
42800
+
42953
42801
  constructor( parameters ) {
42954
42802
 
42955
42803
  super();
@@ -42958,8 +42806,6 @@ class MeshToonMaterial extends Material {
42958
42806
 
42959
42807
  this.defines = { 'TOON': '' };
42960
42808
 
42961
- this.type = 'MeshToonMaterial';
42962
-
42963
42809
  this.color = new Color( 0xffffff );
42964
42810
 
42965
42811
  this.map = null;
@@ -43046,14 +42892,18 @@ class MeshToonMaterial extends Material {
43046
42892
 
43047
42893
  class MeshNormalMaterial extends Material {
43048
42894
 
42895
+ static get type() {
42896
+
42897
+ return 'MeshNormalMaterial';
42898
+
42899
+ }
42900
+
43049
42901
  constructor( parameters ) {
43050
42902
 
43051
42903
  super();
43052
42904
 
43053
42905
  this.isMeshNormalMaterial = true;
43054
42906
 
43055
- this.type = 'MeshNormalMaterial';
43056
-
43057
42907
  this.bumpMap = null;
43058
42908
  this.bumpScale = 1;
43059
42909
 
@@ -43102,14 +42952,18 @@ class MeshNormalMaterial extends Material {
43102
42952
 
43103
42953
  class MeshLambertMaterial extends Material {
43104
42954
 
42955
+ static get type() {
42956
+
42957
+ return 'MeshLambertMaterial';
42958
+
42959
+ }
42960
+
43105
42961
  constructor( parameters ) {
43106
42962
 
43107
42963
  super();
43108
42964
 
43109
42965
  this.isMeshLambertMaterial = true;
43110
42966
 
43111
- this.type = 'MeshLambertMaterial';
43112
-
43113
42967
  this.color = new Color( 0xffffff ); // diffuse
43114
42968
 
43115
42969
  this.map = null;
@@ -43214,6 +43068,12 @@ class MeshLambertMaterial extends Material {
43214
43068
 
43215
43069
  class MeshMatcapMaterial extends Material {
43216
43070
 
43071
+ static get type() {
43072
+
43073
+ return 'MeshMatcapMaterial';
43074
+
43075
+ }
43076
+
43217
43077
  constructor( parameters ) {
43218
43078
 
43219
43079
  super();
@@ -43222,8 +43082,6 @@ class MeshMatcapMaterial extends Material {
43222
43082
 
43223
43083
  this.defines = { 'MATCAP': '' };
43224
43084
 
43225
- this.type = 'MeshMatcapMaterial';
43226
-
43227
43085
  this.color = new Color( 0xffffff ); // diffuse
43228
43086
 
43229
43087
  this.matcap = null;
@@ -43289,14 +43147,18 @@ class MeshMatcapMaterial extends Material {
43289
43147
 
43290
43148
  class LineDashedMaterial extends LineBasicMaterial {
43291
43149
 
43150
+ static get type() {
43151
+
43152
+ return 'LineDashedMaterial';
43153
+
43154
+ }
43155
+
43292
43156
  constructor( parameters ) {
43293
43157
 
43294
43158
  super();
43295
43159
 
43296
43160
  this.isLineDashedMaterial = true;
43297
43161
 
43298
- this.type = 'LineDashedMaterial';
43299
-
43300
43162
  this.scale = 1;
43301
43163
  this.dashSize = 3;
43302
43164
  this.gapSize = 1;
@@ -55207,4 +55069,4 @@ if ( typeof window !== 'undefined' ) {
55207
55069
 
55208
55070
  }
55209
55071
 
55210
- export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BackSide, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, ColorManagement, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, ConstantAlphaFactor, ConstantColorFactor, Controls, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, FloatType, Fog, FogExp2, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils, Matrix2, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, P3Primaries, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, Path, PerspectiveCamera, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_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_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBDepthPacking, RGBFormat, RGBIntegerFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGDepthPacking, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, Rec709Primaries, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RenderTarget, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, Scene, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry, Texture, TextureLoader, TextureUtils, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, createCanvasElement };
55072
+ export { ACESFilmicToneMapping, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BackSide, BasicDepthPacking, BasicShadowMap, BatchedMesh, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, BufferAttribute, BufferGeometry, BufferGeometryLoader, ByteType, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, Color, ColorKeyframeTrack, ColorManagement, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, ConstantAlphaFactor, ConstantColorFactor, Controls, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DepthFormat, DepthStencilFormat, DepthTexture, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DiscreteInterpolant, DodecahedronGeometry, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, EqualCompare, EqualDepth, EqualStencilFunc, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExtrudeGeometry, FileLoader, Float16BufferAttribute, Float32BufferAttribute, FloatType, Fog, FogExp2, FramebufferTexture, FrontSide, Frustum, GLBufferAttribute, GLSL1, GLSL3, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightProbe, Line, Line3, LineBasicMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineLoop, LineSegments, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, MOUSE, Material, MaterialLoader, MathUtils, Matrix2, Matrix3, Matrix4, MaxEquation, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshMatcapMaterial, MeshNormalMaterial, MeshPhongMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshToonMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, NormalAnimationBlendMode, NormalBlending, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, PCFShadowMap, PCFSoftShadowMap, PMREMGenerator, Path, PerspectiveCamera, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, Points, PointsMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_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_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBDepthPacking, RGBFormat, RGBIntegerFormat, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGDepthPacking, RGFormat, RGIntegerFormat, RawShaderMaterial, Ray, Raycaster, RectAreaLight, RedFormat, RedIntegerFormat, ReinhardToneMapping, RenderTarget, RepeatWrapping, ReplaceStencilOp, ReverseSubtractEquation, RingGeometry, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, Scene, ShaderChunk, ShaderLib, ShaderMaterial, ShadowMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SpotLight, SpotLightHelper, Sprite, SpriteMaterial, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TOUCH, TangentSpaceNormalMap, TetrahedronGeometry, Texture, TextureLoader, TextureUtils, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, UniformsLib, UniformsUtils, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, VSMShadowMap, Vector2, Vector3, Vector4, VectorKeyframeTrack, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGLRenderer, WebGLUtils, WebGPUCoordinateSystem, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, createCanvasElement };