super-three 0.169.1 → 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 (193) hide show
  1. package/build/three.cjs +974 -562
  2. package/build/three.module.js +975 -559
  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 +120 -117
  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/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;
1701
1653
 
1702
- if ( ! SUPPORTED_WORKING_COLOR_SPACES.has( colorSpace ) ) {
1654
+ }
1703
1655
 
1704
- throw new Error( `Unsupported working color space, "${ colorSpace }".` );
1656
+ if ( this.spaces[ sourceColorSpace ].transfer === SRGBTransfer ) {
1657
+
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 ) {
1716
+
1717
+ Object.assign( this.spaces, colorSpaces );
1718
+
1719
+ },
1760
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 );
10811
10884
 
10812
- this.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
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 ) {
10899
+
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 = '';
19533
+ const _m0 = /*@__PURE__*/ new Matrix3();
19460
19534
 
19461
- } else if ( workingPrimaries === P3Primaries && encodingPrimaries === Rec709Primaries ) {
19462
-
19463
- gamutMapping = 'LinearDisplayP3ToLinearSRGB';
19464
-
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
  }
@@ -27381,18 +27523,14 @@ class WebXRManager extends EventDispatcher {
27381
27523
  //
27382
27524
 
27383
27525
  const cameraL = new PerspectiveCamera();
27384
- cameraL.layers.enable( 1 );
27385
27526
  cameraL.viewport = new Vector4();
27386
27527
 
27387
27528
  const cameraR = new PerspectiveCamera();
27388
- cameraR.layers.enable( 2 );
27389
27529
  cameraR.viewport = new Vector4();
27390
27530
 
27391
27531
  const cameras = [ cameraL, cameraR ];
27392
27532
 
27393
27533
  const cameraXR = new ArrayCamera();
27394
- cameraXR.layers.enable( 1 );
27395
- cameraXR.layers.enable( 2 );
27396
27534
 
27397
27535
  let _currentDepthNear = null;
27398
27536
  let _currentDepthFar = null;
@@ -27958,6 +28096,10 @@ class WebXRManager extends EventDispatcher {
27958
28096
 
27959
28097
  }
27960
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
+
27961
28103
  const cameras = cameraXR.cameras;
27962
28104
  var object = poseTarget || camera;
27963
28105
  const parent = object.parent;
@@ -29213,6 +29355,7 @@ class WebGLRenderer {
29213
29355
  preserveDrawingBuffer = false,
29214
29356
  powerPreference = 'default',
29215
29357
  failIfMajorPerformanceCaveat = false,
29358
+ reverseDepthBuffer = false,
29216
29359
  multiviewStereo = false,
29217
29360
  } = parameters;
29218
29361
 
@@ -29433,9 +29576,13 @@ class WebGLRenderer {
29433
29576
 
29434
29577
  capabilities = new WebGLCapabilities( _gl, extensions, parameters, utils );
29435
29578
 
29436
- state = new WebGLState( _gl );
29579
+ state = new WebGLState( _gl, extensions );
29580
+
29581
+ if ( capabilities.reverseDepthBuffer && reverseDepthBuffer ) {
29437
29582
 
29438
- if ( capabilities.reverseDepthBuffer ) state.buffers.depth.setReversed( true );
29583
+ state.buffers.depth.setReversed( true );
29584
+
29585
+ }
29439
29586
 
29440
29587
  info = new WebGLInfo( _gl );
29441
29588
  properties = new WebGLProperties();
@@ -29740,7 +29887,6 @@ class WebGLRenderer {
29740
29887
  if ( depth ) {
29741
29888
 
29742
29889
  bits |= _gl.DEPTH_BUFFER_BIT;
29743
- _gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
29744
29890
 
29745
29891
  }
29746
29892
 
@@ -31148,7 +31294,9 @@ class WebGLRenderer {
31148
31294
 
31149
31295
  } else {
31150
31296
 
31151
- if ( capabilities.reverseDepthBuffer ) {
31297
+ const reverseDepthBuffer = state.buffers.depth.getReversed();
31298
+
31299
+ if ( reverseDepthBuffer ) {
31152
31300
 
31153
31301
  _currentProjectionMatrix.copy( camera.projectionMatrix );
31154
31302
 
@@ -31780,21 +31928,27 @@ class WebGLRenderer {
31780
31928
 
31781
31929
  }
31782
31930
 
31783
- let width, height, minX, minY;
31784
- 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;
31785
31935
  if ( srcRegion !== null ) {
31786
31936
 
31787
31937
  width = srcRegion.max.x - srcRegion.min.x;
31788
31938
  height = srcRegion.max.y - srcRegion.min.y;
31939
+ depth = srcRegion.isBox3 ? srcRegion.max.z - srcRegion.min.z : 1;
31789
31940
  minX = srcRegion.min.x;
31790
31941
  minY = srcRegion.min.y;
31942
+ minZ = srcRegion.isBox3 ? srcRegion.min.z : 0;
31791
31943
 
31792
31944
  } else {
31793
31945
 
31794
- width = srcTexture.image.width;
31795
- height = srcTexture.image.height;
31946
+ width = image.width;
31947
+ height = image.height;
31948
+ depth = image.depth || 1;
31796
31949
  minX = 0;
31797
31950
  minY = 0;
31951
+ minZ = 0;
31798
31952
 
31799
31953
  }
31800
31954
 
@@ -31802,177 +31956,143 @@ class WebGLRenderer {
31802
31956
 
31803
31957
  dstX = dstPosition.x;
31804
31958
  dstY = dstPosition.y;
31959
+ dstZ = dstPosition.z;
31805
31960
 
31806
31961
  } else {
31807
31962
 
31808
31963
  dstX = 0;
31809
31964
  dstY = 0;
31965
+ dstZ = 0;
31810
31966
 
31811
31967
  }
31812
31968
 
31969
+ // Set up the destination target
31813
31970
  const glFormat = utils.convert( dstTexture.format );
31814
31971
  const glType = utils.convert( dstTexture.type );
31972
+ let glTarget;
31815
31973
 
31816
- textures.setTexture2D( dstTexture, 0 );
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 {
31985
+
31986
+ textures.setTexture2D( dstTexture, 0 );
31987
+ glTarget = _gl.TEXTURE_2D;
31988
+
31989
+ }
31817
31990
 
31818
- // As another texture upload may have changed pixelStorei
31819
- // parameters, make sure they are correct for the dstTexture
31820
31991
  _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
31821
31992
  _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
31822
31993
  _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
31823
31994
 
31995
+ // used for copying data from cpu
31824
31996
  const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
31825
31997
  const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
31826
31998
  const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
31827
31999
  const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
31828
32000
  const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
31829
32001
 
31830
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
31831
-
31832
32002
  _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
31833
32003
  _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
31834
32004
  _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
31835
32005
  _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
32006
+ _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
31836
32007
 
31837
- if ( srcTexture.isDataTexture ) {
31838
-
31839
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image.data );
31840
-
31841
- } else {
31842
-
31843
- if ( srcTexture.isCompressedTexture ) {
31844
-
31845
- _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
31846
-
31847
- } else {
31848
-
31849
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
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 ) {
31850
32012
 
31851
- }
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 );
31852
32017
 
31853
- }
32018
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, srcRenderTargetProperties.__webglFramebuffer );
32019
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, dstRenderTargetProperties.__webglFramebuffer );
31854
32020
 
31855
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
31856
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
31857
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
31858
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
31859
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
32021
+ for ( let i = 0; i < depth; i ++ ) {
31860
32022
 
31861
- // Generate mipmaps only when copying level 0
31862
- if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
32023
+ // if the source or destination are a 3d target then a layer needs to be bound
32024
+ if ( isSrc3D ) {
31863
32025
 
31864
- state.unbindTexture();
32026
+ _gl.framebufferTextureLayer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( srcTexture ).__webglTexture, level, minZ + i );
31865
32027
 
31866
- };
32028
+ }
31867
32029
 
31868
- this.copyTextureToTexture3D = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, level = 0 ) {
32030
+ if ( srcTexture.isDepthTexture ) {
31869
32031
 
31870
- // support previous signature with source box first
31871
- if ( srcTexture.isTexture !== true ) {
32032
+ if ( isDst3D ) {
31872
32033
 
31873
- // @deprecated, r165
31874
- warnOnce( 'WebGLRenderer: copyTextureToTexture3D function signature has changed.' );
32034
+ _gl.framebufferTextureLayer( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( dstTexture ).__webglTexture, level, dstZ + i );
31875
32035
 
31876
- srcRegion = arguments[ 0 ] || null;
31877
- dstPosition = arguments[ 1 ] || null;
31878
- srcTexture = arguments[ 2 ];
31879
- dstTexture = arguments[ 3 ];
31880
- level = arguments[ 4 ] || 0;
32036
+ }
31881
32037
 
31882
- }
32038
+ _gl.blitFramebuffer( minX, minY, width, height, dstX, dstY, width, height, _gl.DEPTH_BUFFER_BIT, _gl.NEAREST );
31883
32039
 
31884
- let width, height, depth, minX, minY, minZ;
31885
- let dstX, dstY, dstZ;
31886
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ level ] : srcTexture.image;
31887
- if ( srcRegion !== null ) {
32040
+ } else if ( isDst3D ) {
31888
32041
 
31889
- width = srcRegion.max.x - srcRegion.min.x;
31890
- height = srcRegion.max.y - srcRegion.min.y;
31891
- depth = srcRegion.max.z - srcRegion.min.z;
31892
- minX = srcRegion.min.x;
31893
- minY = srcRegion.min.y;
31894
- minZ = srcRegion.min.z;
32042
+ _gl.copyTexSubImage3D( glTarget, level, dstX, dstY, dstZ + i, minX, minY, width, height );
31895
32043
 
31896
- } else {
32044
+ } else {
31897
32045
 
31898
- width = image.width;
31899
- height = image.height;
31900
- depth = image.depth;
31901
- minX = 0;
31902
- minY = 0;
31903
- minZ = 0;
32046
+ _gl.copyTexSubImage2D( glTarget, level, dstX, dstY, dstZ + i, minX, minY, width, height );
31904
32047
 
31905
- }
32048
+ }
31906
32049
 
31907
- if ( dstPosition !== null ) {
32050
+ }
31908
32051
 
31909
- dstX = dstPosition.x;
31910
- dstY = dstPosition.y;
31911
- dstZ = dstPosition.z;
32052
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
32053
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
31912
32054
 
31913
32055
  } else {
31914
32056
 
31915
- dstX = 0;
31916
- dstY = 0;
31917
- dstZ = 0;
31918
-
31919
- }
31920
-
31921
- const glFormat = utils.convert( dstTexture.format );
31922
- const glType = utils.convert( dstTexture.type );
31923
- let glTarget;
31924
-
31925
- if ( dstTexture.isData3DTexture ) {
31926
-
31927
- textures.setTexture3D( dstTexture, 0 );
31928
- glTarget = _gl.TEXTURE_3D;
32057
+ if ( isDst3D ) {
31929
32058
 
31930
- } else if ( dstTexture.isDataArrayTexture || dstTexture.isCompressedArrayTexture ) {
32059
+ // copy data into the 3d texture
32060
+ if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
31931
32061
 
31932
- textures.setTexture2DArray( dstTexture, 0 );
31933
- glTarget = _gl.TEXTURE_2D_ARRAY;
32062
+ _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
31934
32063
 
31935
- } else {
32064
+ } else if ( dstTexture.isCompressedArrayTexture ) {
31936
32065
 
31937
- console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.' );
31938
- return;
32066
+ _gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
31939
32067
 
31940
- }
32068
+ } else {
31941
32069
 
31942
- _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
31943
- _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
31944
- _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
32070
+ _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
31945
32071
 
31946
- const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
31947
- const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
31948
- const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
31949
- const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
31950
- const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
32072
+ }
31951
32073
 
31952
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
31953
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
31954
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
31955
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
31956
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
32074
+ } else {
31957
32075
 
31958
- if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
32076
+ // copy data into the 2d texture
32077
+ if ( srcTexture.isDataTexture ) {
31959
32078
 
31960
- _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 );
31961
32080
 
31962
- } else {
32081
+ } else if ( srcTexture.isCompressedTexture ) {
31963
32082
 
31964
- if ( dstTexture.isCompressedArrayTexture ) {
32083
+ _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, image.width, image.height, glFormat, image.data );
31965
32084
 
31966
- _gl.compressedTexSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
32085
+ } else {
31967
32086
 
31968
- } else {
32087
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, dstX, dstY, width, height, glFormat, glType, image );
31969
32088
 
31970
- _gl.texSubImage3D( glTarget, level, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
32089
+ }
31971
32090
 
31972
32091
  }
31973
32092
 
31974
32093
  }
31975
32094
 
32095
+ // reset values
31976
32096
  _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
31977
32097
  _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
31978
32098
  _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
@@ -31980,12 +32100,39 @@ class WebGLRenderer {
31980
32100
  _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
31981
32101
 
31982
32102
  // Generate mipmaps only when copying level 0
31983
- if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
32103
+ if ( level === 0 && dstTexture.generateMipmaps ) {
32104
+
32105
+ _gl.generateMipmap( glTarget );
32106
+
32107
+ }
31984
32108
 
31985
32109
  state.unbindTexture();
31986
32110
 
31987
32111
  };
31988
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
+
31989
32136
  this.initRenderTarget = function ( target ) {
31990
32137
 
31991
32138
  if ( properties.get( target ).__webglFramebuffer === undefined ) {
@@ -32056,8 +32203,8 @@ class WebGLRenderer {
32056
32203
  this._outputColorSpace = colorSpace;
32057
32204
 
32058
32205
  const gl = this.getContext();
32059
- gl.drawingBufferColorSpace = colorSpace === DisplayP3ColorSpace ? 'display-p3' : 'srgb';
32060
- gl.unpackColorSpace = ColorManagement.workingColorSpace === LinearDisplayP3ColorSpace ? 'display-p3' : 'srgb';
32206
+ gl.drawingBufferColorspace = ColorManagement._getDrawingBufferColorSpace( colorSpace );
32207
+ gl.unpackColorSpace = ColorManagement._getUnpackColorSpace();
32061
32208
 
32062
32209
  }
32063
32210
 
@@ -32703,14 +32850,18 @@ class InterleavedBufferAttribute {
32703
32850
 
32704
32851
  class SpriteMaterial extends Material {
32705
32852
 
32853
+ static get type() {
32854
+
32855
+ return 'SpriteMaterial';
32856
+
32857
+ }
32858
+
32706
32859
  constructor( parameters ) {
32707
32860
 
32708
32861
  super();
32709
32862
 
32710
32863
  this.isSpriteMaterial = true;
32711
32864
 
32712
- this.type = 'SpriteMaterial';
32713
-
32714
32865
  this.color = new Color( 0xffffff );
32715
32866
 
32716
32867
  this.map = null;
@@ -33431,7 +33582,7 @@ class DataTexture extends Texture {
33431
33582
  }
33432
33583
 
33433
33584
  const _offsetMatrix = /*@__PURE__*/ new Matrix4();
33434
- const _identityMatrix$1 = /*@__PURE__*/ new Matrix4();
33585
+ const _identityMatrix = /*@__PURE__*/ new Matrix4();
33435
33586
 
33436
33587
  class Skeleton {
33437
33588
 
@@ -33560,7 +33711,7 @@ class Skeleton {
33560
33711
 
33561
33712
  // compute the offset between the current and the original transform
33562
33713
 
33563
- const matrix = bones[ i ] ? bones[ i ].matrixWorld : _identityMatrix$1;
33714
+ const matrix = bones[ i ] ? bones[ i ].matrixWorld : _identityMatrix;
33564
33715
 
33565
33716
  _offsetMatrix.multiplyMatrices( matrix, boneInverses[ i ] );
33566
33717
  _offsetMatrix.toArray( boneMatrices, i * 16 );
@@ -34001,6 +34152,12 @@ class InstancedMesh extends Mesh {
34001
34152
 
34002
34153
  }
34003
34154
 
34155
+ function ascIdSort( a, b ) {
34156
+
34157
+ return a - b;
34158
+
34159
+ }
34160
+
34004
34161
  function sortOpaque( a, b ) {
34005
34162
 
34006
34163
  return a.z - b.z;
@@ -34023,7 +34180,7 @@ class MultiDrawRenderList {
34023
34180
 
34024
34181
  }
34025
34182
 
34026
- push( drawRange, z, index ) {
34183
+ push( start, count, z, index ) {
34027
34184
 
34028
34185
  const pool = this.pool;
34029
34186
  const list = this.list;
@@ -34044,8 +34201,8 @@ class MultiDrawRenderList {
34044
34201
  list.push( item );
34045
34202
  this.index ++;
34046
34203
 
34047
- item.start = drawRange.start;
34048
- item.count = drawRange.count;
34204
+ item.start = start;
34205
+ item.count = count;
34049
34206
  item.z = z;
34050
34207
  item.index = index;
34051
34208
 
@@ -34061,10 +34218,7 @@ class MultiDrawRenderList {
34061
34218
  }
34062
34219
 
34063
34220
  const _matrix$1 = /*@__PURE__*/ new Matrix4();
34064
- const _invMatrixWorld = /*@__PURE__*/ new Matrix4();
34065
- const _identityMatrix = /*@__PURE__*/ new Matrix4();
34066
34221
  const _whiteColor = /*@__PURE__*/ new Color( 1, 1, 1 );
34067
- const _projScreenMatrix$2 = /*@__PURE__*/ new Matrix4();
34068
34222
  const _frustum = /*@__PURE__*/ new Frustum();
34069
34223
  const _box$1 = /*@__PURE__*/ new Box3();
34070
34224
  const _sphere$2 = /*@__PURE__*/ new Sphere();
@@ -34075,13 +34229,6 @@ const _renderList = /*@__PURE__*/ new MultiDrawRenderList();
34075
34229
  const _mesh = /*@__PURE__*/ new Mesh();
34076
34230
  const _batchIntersects = [];
34077
34231
 
34078
- // @TODO: SkinnedMesh support?
34079
- // @TODO: geometry.groups support?
34080
- // @TODO: geometry.drawRange support?
34081
- // @TODO: geometry.morphAttributes support?
34082
- // @TODO: Support uniform parameter per geometry
34083
- // @TODO: Add an "optimize" function to pack geometry and remove data gaps
34084
-
34085
34232
  // copies data from attribute "src" into "target" starting at "targetOffset"
34086
34233
  function copyAttributeData( src, target, targetOffset = 0 ) {
34087
34234
 
@@ -34112,6 +34259,29 @@ function copyAttributeData( src, target, targetOffset = 0 ) {
34112
34259
 
34113
34260
  }
34114
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
+
34115
34285
  class BatchedMesh extends Mesh {
34116
34286
 
34117
34287
  get maxInstanceCount() {
@@ -34120,6 +34290,24 @@ class BatchedMesh extends Mesh {
34120
34290
 
34121
34291
  }
34122
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
+
34123
34311
  constructor( maxInstanceCount, maxVertexCount, maxIndexCount = maxVertexCount * 2, material ) {
34124
34312
 
34125
34313
  super( new BufferGeometry(), material );
@@ -34131,28 +34319,33 @@ class BatchedMesh extends Mesh {
34131
34319
  this.boundingSphere = null;
34132
34320
  this.customSort = null;
34133
34321
 
34134
- // stores visible, active, and geometry id per object
34135
- this._drawInfo = [];
34322
+ // stores visible, active, and geometry id per instance and reserved buffer ranges for geometries
34323
+ this._instanceInfo = [];
34324
+ this._geometryInfo = [];
34136
34325
 
34137
- // 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
34138
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;
34139
34334
 
34140
- // geometry information
34141
- this._drawRanges = [];
34142
- this._reservedRanges = [];
34143
- this._bounds = [];
34335
+ // flags
34336
+ this._visibilityChanged = true;
34337
+ this._geometryInitialized = false;
34144
34338
 
34339
+ // cached user options
34145
34340
  this._maxInstanceCount = maxInstanceCount;
34146
34341
  this._maxVertexCount = maxVertexCount;
34147
34342
  this._maxIndexCount = maxIndexCount;
34148
34343
 
34149
- this._geometryInitialized = false;
34150
- this._geometryCount = 0;
34344
+ // buffers for multi draw
34151
34345
  this._multiDrawCounts = new Int32Array( maxInstanceCount );
34152
34346
  this._multiDrawStarts = new Int32Array( maxInstanceCount );
34153
34347
  this._multiDrawCount = 0;
34154
34348
  this._multiDrawInstances = null;
34155
- this._visibilityChanged = true;
34156
34349
 
34157
34350
  // Local matrix per geometry by using data texture
34158
34351
  this._matricesTexture = null;
@@ -34293,14 +34486,14 @@ class BatchedMesh extends Mesh {
34293
34486
  }
34294
34487
 
34295
34488
  const boundingBox = this.boundingBox;
34296
- const drawInfo = this._drawInfo;
34489
+ const instanceInfo = this._instanceInfo;
34297
34490
 
34298
34491
  boundingBox.makeEmpty();
34299
- for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34492
+ for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
34300
34493
 
34301
- if ( drawInfo[ i ].active === false ) continue;
34494
+ if ( instanceInfo[ i ].active === false ) continue;
34302
34495
 
34303
- const geometryId = drawInfo[ i ].geometryIndex;
34496
+ const geometryId = instanceInfo[ i ].geometryIndex;
34304
34497
  this.getMatrixAt( i, _matrix$1 );
34305
34498
  this.getBoundingBoxAt( geometryId, _box$1 ).applyMatrix4( _matrix$1 );
34306
34499
  boundingBox.union( _box$1 );
@@ -34318,14 +34511,14 @@ class BatchedMesh extends Mesh {
34318
34511
  }
34319
34512
 
34320
34513
  const boundingSphere = this.boundingSphere;
34321
- const drawInfo = this._drawInfo;
34514
+ const instanceInfo = this._instanceInfo;
34322
34515
 
34323
34516
  boundingSphere.makeEmpty();
34324
- for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
34517
+ for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
34325
34518
 
34326
- if ( drawInfo[ i ].active === false ) continue;
34519
+ if ( instanceInfo[ i ].active === false ) continue;
34327
34520
 
34328
- const geometryId = drawInfo[ i ].geometryIndex;
34521
+ const geometryId = instanceInfo[ i ].geometryIndex;
34329
34522
  this.getMatrixAt( i, _matrix$1 );
34330
34523
  this.getBoundingSphereAt( geometryId, _sphere$2 ).applyMatrix4( _matrix$1 );
34331
34524
  boundingSphere.union( _sphere$2 );
@@ -34336,7 +34529,7 @@ class BatchedMesh extends Mesh {
34336
34529
 
34337
34530
  addInstance( geometryId ) {
34338
34531
 
34339
- const atCapacity = this._drawInfo.length >= this.maxInstanceCount;
34532
+ const atCapacity = this._instanceInfo.length >= this.maxInstanceCount;
34340
34533
 
34341
34534
  // ensure we're not over geometry
34342
34535
  if ( atCapacity && this._availableInstanceIds.length === 0 ) {
@@ -34345,7 +34538,7 @@ class BatchedMesh extends Mesh {
34345
34538
 
34346
34539
  }
34347
34540
 
34348
- const instanceDrawInfo = {
34541
+ const instanceInfo = {
34349
34542
  visible: true,
34350
34543
  active: true,
34351
34544
  geometryIndex: geometryId,
@@ -34356,19 +34549,20 @@ class BatchedMesh extends Mesh {
34356
34549
  // Prioritize using previously freed instance ids
34357
34550
  if ( this._availableInstanceIds.length > 0 ) {
34358
34551
 
34359
- drawId = this._availableInstanceIds.pop();
34360
- this._drawInfo[ drawId ] = instanceDrawInfo;
34552
+ this._availableInstanceIds.sort( ascIdSort );
34553
+
34554
+ drawId = this._availableInstanceIds.shift();
34555
+ this._instanceInfo[ drawId ] = instanceInfo;
34361
34556
 
34362
34557
  } else {
34363
34558
 
34364
- drawId = this._drawInfo.length;
34365
- this._drawInfo.push( instanceDrawInfo );
34559
+ drawId = this._instanceInfo.length;
34560
+ this._instanceInfo.push( instanceInfo );
34366
34561
 
34367
34562
  }
34368
34563
 
34369
34564
  const matricesTexture = this._matricesTexture;
34370
- const matricesArray = matricesTexture.image.data;
34371
- _identityMatrix.toArray( matricesArray, drawId * 16 );
34565
+ _matrix$1.identity().toArray( matricesTexture.image.data, drawId * 16 );
34372
34566
  matricesTexture.needsUpdate = true;
34373
34567
 
34374
34568
  const colorsTexture = this._colorsTexture;
@@ -34379,91 +34573,54 @@ class BatchedMesh extends Mesh {
34379
34573
 
34380
34574
  }
34381
34575
 
34576
+ this._visibilityChanged = true;
34382
34577
  return drawId;
34383
34578
 
34384
34579
  }
34385
34580
 
34386
- addGeometry( geometry, vertexCount = - 1, indexCount = - 1 ) {
34581
+ addGeometry( geometry, reservedVertexCount = - 1, reservedIndexCount = - 1 ) {
34387
34582
 
34388
34583
  this._initializeGeometry( geometry );
34389
34584
 
34390
34585
  this._validateGeometry( geometry );
34391
34586
 
34392
- // ensure we're not over geometry
34393
- if ( this._drawInfo.length >= this._maxInstanceCount ) {
34394
-
34395
- throw new Error( 'BatchedMesh: Maximum item count reached.' );
34396
-
34397
- }
34398
-
34399
- // get the necessary range fo the geometry
34400
- const reservedRange = {
34587
+ const geometryInfo = {
34588
+ // geometry information
34401
34589
  vertexStart: - 1,
34402
34590
  vertexCount: - 1,
34591
+ reservedVertexCount: - 1,
34592
+
34403
34593
  indexStart: - 1,
34404
34594
  indexCount: - 1,
34405
- };
34406
-
34407
- let lastRange = null;
34408
- const reservedRanges = this._reservedRanges;
34409
- const drawRanges = this._drawRanges;
34410
- const bounds = this._bounds;
34411
- if ( this._geometryCount !== 0 ) {
34412
-
34413
- lastRange = reservedRanges[ reservedRanges.length - 1 ];
34414
-
34415
- }
34416
-
34417
- if ( vertexCount === - 1 ) {
34418
-
34419
- reservedRange.vertexCount = geometry.getAttribute( 'position' ).count;
34420
-
34421
- } else {
34422
-
34423
- reservedRange.vertexCount = vertexCount;
34424
-
34425
- }
34426
-
34427
- if ( lastRange === null ) {
34595
+ reservedIndexCount: - 1,
34428
34596
 
34429
- reservedRange.vertexStart = 0;
34597
+ // draw range information
34598
+ start: - 1,
34599
+ count: - 1,
34430
34600
 
34431
- } else {
34432
-
34433
- reservedRange.vertexStart = lastRange.vertexStart + lastRange.vertexCount;
34601
+ // state
34602
+ boundingBox: null,
34603
+ boundingSphere: null,
34604
+ active: true,
34605
+ };
34434
34606
 
34435
- }
34607
+ const geometryInfoList = this._geometryInfo;
34608
+ geometryInfo.vertexStart = this._nextVertexStart;
34609
+ geometryInfo.reservedVertexCount = reservedVertexCount === - 1 ? geometry.getAttribute( 'position' ).count : reservedVertexCount;
34436
34610
 
34437
34611
  const index = geometry.getIndex();
34438
34612
  const hasIndex = index !== null;
34439
34613
  if ( hasIndex ) {
34440
34614
 
34441
- if ( indexCount === - 1 ) {
34442
-
34443
- reservedRange.indexCount = index.count;
34444
-
34445
- } else {
34446
-
34447
- reservedRange.indexCount = indexCount;
34448
-
34449
- }
34450
-
34451
- if ( lastRange === null ) {
34452
-
34453
- reservedRange.indexStart = 0;
34454
-
34455
- } else {
34456
-
34457
- reservedRange.indexStart = lastRange.indexStart + lastRange.indexCount;
34458
-
34459
- }
34615
+ geometryInfo.indexStart = this._nextIndexStart;
34616
+ geometryInfo.reservedIndexCount = reservedIndexCount === - 1 ? index.count : reservedIndexCount;
34460
34617
 
34461
34618
  }
34462
34619
 
34463
34620
  if (
34464
- reservedRange.indexStart !== - 1 &&
34465
- reservedRange.indexStart + reservedRange.indexCount > this._maxIndexCount ||
34466
- reservedRange.vertexStart + reservedRange.vertexCount > this._maxVertexCount
34621
+ geometryInfo.indexStart !== - 1 &&
34622
+ geometryInfo.indexStart + geometryInfo.reservedIndexCount > this._maxIndexCount ||
34623
+ geometryInfo.vertexStart + geometryInfo.reservedVertexCount > this._maxVertexCount
34467
34624
  ) {
34468
34625
 
34469
34626
  throw new Error( 'BatchedMesh: Reserved space request exceeds the maximum buffer size.' );
@@ -34471,26 +34628,30 @@ class BatchedMesh extends Mesh {
34471
34628
  }
34472
34629
 
34473
34630
  // update id
34474
- const geometryId = this._geometryCount;
34475
- this._geometryCount ++;
34476
-
34477
- // add the reserved range and draw range objects
34478
- reservedRanges.push( reservedRange );
34479
- drawRanges.push( {
34480
- start: hasIndex ? reservedRange.indexStart : reservedRange.vertexStart,
34481
- count: - 1
34482
- } );
34483
- bounds.push( {
34484
- boxInitialized: false,
34485
- box: new Box3(),
34631
+ let geometryId;
34632
+ if ( this._availableGeometryIds.length > 0 ) {
34486
34633
 
34487
- sphereInitialized: false,
34488
- sphere: new Sphere()
34489
- } );
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
+ }
34490
34647
 
34491
34648
  // update the geometry
34492
34649
  this.setGeometryAt( geometryId, geometry );
34493
34650
 
34651
+ // increment the next geometry position
34652
+ this._nextIndexStart = geometryInfo.indexStart + geometryInfo.reservedIndexCount;
34653
+ this._nextVertexStart = geometryInfo.vertexStart + geometryInfo.reservedVertexCount;
34654
+
34494
34655
  return geometryId;
34495
34656
 
34496
34657
  }
@@ -34509,20 +34670,22 @@ class BatchedMesh extends Mesh {
34509
34670
  const hasIndex = batchGeometry.getIndex() !== null;
34510
34671
  const dstIndex = batchGeometry.getIndex();
34511
34672
  const srcIndex = geometry.getIndex();
34512
- const reservedRange = this._reservedRanges[ geometryId ];
34673
+ const geometryInfo = this._geometryInfo[ geometryId ];
34513
34674
  if (
34514
34675
  hasIndex &&
34515
- srcIndex.count > reservedRange.indexCount ||
34516
- geometry.attributes.position.count > reservedRange.vertexCount
34676
+ srcIndex.count > geometryInfo.reservedIndexCount ||
34677
+ geometry.attributes.position.count > geometryInfo.reservedVertexCount
34517
34678
  ) {
34518
34679
 
34519
34680
  throw new Error( 'BatchedMesh: Reserved space not large enough for provided geometry.' );
34520
34681
 
34521
34682
  }
34522
34683
 
34523
- // copy geometry over
34524
- const vertexStart = reservedRange.vertexStart;
34525
- 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
+
34526
34689
  for ( const attributeName in batchGeometry.attributes ) {
34527
34690
 
34528
34691
  // copy attribute data
@@ -34532,7 +34695,7 @@ class BatchedMesh extends Mesh {
34532
34695
 
34533
34696
  // fill the rest in with zeroes
34534
34697
  const itemSize = srcAttribute.itemSize;
34535
- for ( let i = srcAttribute.count, l = vertexCount; i < l; i ++ ) {
34698
+ for ( let i = srcAttribute.count, l = reservedVertexCount; i < l; i ++ ) {
34536
34699
 
34537
34700
  const index = vertexStart + i;
34538
34701
  for ( let c = 0; c < itemSize; c ++ ) {
@@ -34544,14 +34707,16 @@ class BatchedMesh extends Mesh {
34544
34707
  }
34545
34708
 
34546
34709
  dstAttribute.needsUpdate = true;
34547
- dstAttribute.addUpdateRange( vertexStart * itemSize, vertexCount * itemSize );
34710
+ dstAttribute.addUpdateRange( vertexStart * itemSize, reservedVertexCount * itemSize );
34548
34711
 
34549
34712
  }
34550
34713
 
34551
34714
  // copy index
34552
34715
  if ( hasIndex ) {
34553
34716
 
34554
- const indexStart = reservedRange.indexStart;
34717
+ const indexStart = geometryInfo.indexStart;
34718
+ const reservedIndexCount = geometryInfo.reservedIndexCount;
34719
+ geometryInfo.indexCount = geometry.getIndex().count;
34555
34720
 
34556
34721
  // copy index data over
34557
34722
  for ( let i = 0; i < srcIndex.count; i ++ ) {
@@ -34561,69 +34726,80 @@ class BatchedMesh extends Mesh {
34561
34726
  }
34562
34727
 
34563
34728
  // fill the rest in with zeroes
34564
- for ( let i = srcIndex.count, l = reservedRange.indexCount; i < l; i ++ ) {
34729
+ for ( let i = srcIndex.count, l = reservedIndexCount; i < l; i ++ ) {
34565
34730
 
34566
34731
  dstIndex.setX( indexStart + i, vertexStart );
34567
34732
 
34568
34733
  }
34569
34734
 
34570
34735
  dstIndex.needsUpdate = true;
34571
- dstIndex.addUpdateRange( indexStart, reservedRange.indexCount );
34736
+ dstIndex.addUpdateRange( indexStart, geometryInfo.reservedIndexCount );
34572
34737
 
34573
34738
  }
34574
34739
 
34740
+ // update the draw range
34741
+ geometryInfo.start = hasIndex ? geometryInfo.indexStart : geometryInfo.vertexStart;
34742
+ geometryInfo.count = hasIndex ? geometryInfo.indexCount : geometryInfo.vertexCount;
34743
+
34575
34744
  // store the bounding boxes
34576
- const bound = this._bounds[ geometryId ];
34745
+ geometryInfo.boundingBox = null;
34577
34746
  if ( geometry.boundingBox !== null ) {
34578
34747
 
34579
- bound.box.copy( geometry.boundingBox );
34580
- bound.boxInitialized = true;
34581
-
34582
- } else {
34583
-
34584
- bound.boxInitialized = false;
34748
+ geometryInfo.boundingBox = geometry.boundingBox.clone();
34585
34749
 
34586
34750
  }
34587
34751
 
34752
+ geometryInfo.boundingSphere = null;
34588
34753
  if ( geometry.boundingSphere !== null ) {
34589
34754
 
34590
- bound.sphere.copy( geometry.boundingSphere );
34591
- bound.sphereInitialized = true;
34592
-
34593
- } else {
34594
-
34595
- bound.sphereInitialized = false;
34755
+ geometryInfo.boundingSphere = geometry.boundingSphere.clone();
34596
34756
 
34597
34757
  }
34598
34758
 
34599
- // set drawRange count
34600
- const drawRange = this._drawRanges[ geometryId ];
34601
- const posAttr = geometry.getAttribute( 'position' );
34602
- drawRange.count = hasIndex ? srcIndex.count : posAttr.count;
34603
34759
  this._visibilityChanged = true;
34604
-
34605
34760
  return geometryId;
34606
34761
 
34607
34762
  }
34608
34763
 
34609
- /*
34610
34764
  deleteGeometry( geometryId ) {
34611
34765
 
34612
- // 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;
34613
34790
 
34614
34791
  }
34615
- */
34616
34792
 
34617
34793
  deleteInstance( instanceId ) {
34618
34794
 
34619
- const drawInfo = this._drawInfo;
34620
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34795
+ const instanceInfo = this._instanceInfo;
34796
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
34621
34797
 
34622
34798
  return this;
34623
34799
 
34624
34800
  }
34625
34801
 
34626
- drawInfo[ instanceId ].active = false;
34802
+ instanceInfo[ instanceId ].active = false;
34627
34803
  this._availableInstanceIds.push( instanceId );
34628
34804
  this._visibilityChanged = true;
34629
34805
 
@@ -34631,6 +34807,95 @@ class BatchedMesh extends Mesh {
34631
34807
 
34632
34808
  }
34633
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
+
34634
34899
  // get bounding box and compute it if it doesn't exist
34635
34900
  getBoundingBoxAt( geometryId, target ) {
34636
34901
 
@@ -34641,17 +34906,14 @@ class BatchedMesh extends Mesh {
34641
34906
  }
34642
34907
 
34643
34908
  // compute bounding box
34644
- const bound = this._bounds[ geometryId ];
34645
- const box = bound.box;
34646
34909
  const geometry = this.geometry;
34647
- if ( bound.boxInitialized === false ) {
34648
-
34649
- box.makeEmpty();
34910
+ const geometryInfo = this._geometryInfo[ geometryId ];
34911
+ if ( geometryInfo.boundingBox === null ) {
34650
34912
 
34913
+ const box = new Box3();
34651
34914
  const index = geometry.index;
34652
34915
  const position = geometry.attributes.position;
34653
- const drawRange = this._drawRanges[ geometryId ];
34654
- 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 ++ ) {
34655
34917
 
34656
34918
  let iv = i;
34657
34919
  if ( index ) {
@@ -34664,11 +34926,11 @@ class BatchedMesh extends Mesh {
34664
34926
 
34665
34927
  }
34666
34928
 
34667
- bound.boxInitialized = true;
34929
+ geometryInfo.boundingBox = box;
34668
34930
 
34669
34931
  }
34670
34932
 
34671
- target.copy( box );
34933
+ target.copy( geometryInfo.boundingBox );
34672
34934
  return target;
34673
34935
 
34674
34936
  }
@@ -34683,22 +34945,19 @@ class BatchedMesh extends Mesh {
34683
34945
  }
34684
34946
 
34685
34947
  // compute bounding sphere
34686
- const bound = this._bounds[ geometryId ];
34687
- const sphere = bound.sphere;
34688
34948
  const geometry = this.geometry;
34689
- if ( bound.sphereInitialized === false ) {
34690
-
34691
- sphere.makeEmpty();
34949
+ const geometryInfo = this._geometryInfo[ geometryId ];
34950
+ if ( geometryInfo.boundingSphere === null ) {
34692
34951
 
34952
+ const sphere = new Sphere();
34693
34953
  this.getBoundingBoxAt( geometryId, _box$1 );
34694
34954
  _box$1.getCenter( sphere.center );
34695
34955
 
34696
34956
  const index = geometry.index;
34697
34957
  const position = geometry.attributes.position;
34698
- const drawRange = this._drawRanges[ geometryId ];
34699
34958
 
34700
34959
  let maxRadiusSq = 0;
34701
- 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 ++ ) {
34702
34961
 
34703
34962
  let iv = i;
34704
34963
  if ( index ) {
@@ -34713,24 +34972,21 @@ class BatchedMesh extends Mesh {
34713
34972
  }
34714
34973
 
34715
34974
  sphere.radius = Math.sqrt( maxRadiusSq );
34716
- bound.sphereInitialized = true;
34975
+ geometryInfo.boundingSphere = sphere;
34717
34976
 
34718
34977
  }
34719
34978
 
34720
- target.copy( sphere );
34979
+ target.copy( geometryInfo.boundingSphere );
34721
34980
  return target;
34722
34981
 
34723
34982
  }
34724
34983
 
34725
34984
  setMatrixAt( instanceId, matrix ) {
34726
34985
 
34727
- // @TODO: Map geometryId to index of the arrays because
34728
- // optimize() can make geometryId mismatch the index
34729
-
34730
- const drawInfo = this._drawInfo;
34986
+ const instanceInfo = this._instanceInfo;
34731
34987
  const matricesTexture = this._matricesTexture;
34732
34988
  const matricesArray = this._matricesTexture.image.data;
34733
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
34989
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
34734
34990
 
34735
34991
  return this;
34736
34992
 
@@ -34745,9 +35001,9 @@ class BatchedMesh extends Mesh {
34745
35001
 
34746
35002
  getMatrixAt( instanceId, matrix ) {
34747
35003
 
34748
- const drawInfo = this._drawInfo;
35004
+ const instanceInfo = this._instanceInfo;
34749
35005
  const matricesArray = this._matricesTexture.image.data;
34750
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35006
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
34751
35007
 
34752
35008
  return null;
34753
35009
 
@@ -34765,13 +35021,10 @@ class BatchedMesh extends Mesh {
34765
35021
 
34766
35022
  }
34767
35023
 
34768
- // @TODO: Map id to index of the arrays because
34769
- // optimize() can make id mismatch the index
34770
-
34771
35024
  const colorsTexture = this._colorsTexture;
34772
35025
  const colorsArray = this._colorsTexture.image.data;
34773
- const drawInfo = this._drawInfo;
34774
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35026
+ const instanceInfo = this._instanceInfo;
35027
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
34775
35028
 
34776
35029
  return this;
34777
35030
 
@@ -34787,8 +35040,8 @@ class BatchedMesh extends Mesh {
34787
35040
  getColorAt( instanceId, color ) {
34788
35041
 
34789
35042
  const colorsArray = this._colorsTexture.image.data;
34790
- const drawInfo = this._drawInfo;
34791
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35043
+ const instanceInfo = this._instanceInfo;
35044
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
34792
35045
 
34793
35046
  return null;
34794
35047
 
@@ -34802,18 +35055,18 @@ class BatchedMesh extends Mesh {
34802
35055
 
34803
35056
  // if the geometry is out of range, not active, or visibility state
34804
35057
  // does not change then return early
34805
- const drawInfo = this._drawInfo;
35058
+ const instanceInfo = this._instanceInfo;
34806
35059
  if (
34807
- instanceId >= drawInfo.length ||
34808
- drawInfo[ instanceId ].active === false ||
34809
- drawInfo[ instanceId ].visible === value
35060
+ instanceId >= instanceInfo.length ||
35061
+ instanceInfo[ instanceId ].active === false ||
35062
+ instanceInfo[ instanceId ].visible === value
34810
35063
  ) {
34811
35064
 
34812
35065
  return this;
34813
35066
 
34814
35067
  }
34815
35068
 
34816
- drawInfo[ instanceId ].visible = value;
35069
+ instanceInfo[ instanceId ].visible = value;
34817
35070
  this._visibilityChanged = true;
34818
35071
 
34819
35072
  return this;
@@ -34823,35 +35076,36 @@ class BatchedMesh extends Mesh {
34823
35076
  getVisibleAt( instanceId ) {
34824
35077
 
34825
35078
  // return early if the geometry is out of range or not active
34826
- const drawInfo = this._drawInfo;
34827
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35079
+ const instanceInfo = this._instanceInfo;
35080
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
34828
35081
 
34829
35082
  return false;
34830
35083
 
34831
35084
  }
34832
35085
 
34833
- return drawInfo[ instanceId ].visible;
35086
+ return instanceInfo[ instanceId ].visible;
34834
35087
 
34835
35088
  }
34836
35089
 
34837
35090
  setGeometryIdAt( instanceId, geometryId ) {
34838
35091
 
34839
35092
  // return early if the geometry is out of range or not active
34840
- const drawInfo = this._drawInfo;
34841
- 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 ) {
34842
35096
 
34843
35097
  return null;
34844
35098
 
34845
35099
  }
34846
35100
 
34847
35101
  // check if the provided geometryId is within the valid range
34848
- if ( geometryId < 0 || geometryId >= this._geometryCount ) {
35102
+ if ( geometryId >= geometryInfoList.length || geometryInfoList[ geometryId ].active === false ) {
34849
35103
 
34850
35104
  return null;
34851
35105
 
34852
35106
  }
34853
35107
 
34854
- drawInfo[ instanceId ].geometryIndex = geometryId;
35108
+ instanceInfo[ instanceId ].geometryIndex = geometryId;
34855
35109
 
34856
35110
  return this;
34857
35111
 
@@ -34859,14 +35113,14 @@ class BatchedMesh extends Mesh {
34859
35113
 
34860
35114
  getGeometryIdAt( instanceId ) {
34861
35115
 
34862
- const drawInfo = this._drawInfo;
34863
- if ( instanceId >= drawInfo.length || drawInfo[ instanceId ].active === false ) {
35116
+ const instanceInfo = this._instanceInfo;
35117
+ if ( instanceId >= instanceInfo.length || instanceInfo[ instanceId ].active === false ) {
34864
35118
 
34865
35119
  return - 1;
34866
35120
 
34867
35121
  }
34868
35122
 
34869
- return drawInfo[ instanceId ].geometryIndex;
35123
+ return instanceInfo[ instanceId ].geometryIndex;
34870
35124
 
34871
35125
  }
34872
35126
 
@@ -34878,19 +35132,136 @@ class BatchedMesh extends Mesh {
34878
35132
 
34879
35133
  }
34880
35134
 
34881
- 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;
34882
35143
 
34883
- target.start = drawRange.start;
34884
- target.count = drawRange.count;
35144
+ target.start = geometryInfo.start;
35145
+ target.count = geometryInfo.count;
34885
35146
 
34886
35147
  return target;
34887
35148
 
34888
35149
  }
34889
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
+
34890
35261
  raycast( raycaster, intersects ) {
34891
35262
 
34892
- const drawInfo = this._drawInfo;
34893
- const drawRanges = this._drawRanges;
35263
+ const instanceInfo = this._instanceInfo;
35264
+ const geometryInfoList = this._geometryInfo;
34894
35265
  const matrixWorld = this.matrixWorld;
34895
35266
  const batchGeometry = this.geometry;
34896
35267
 
@@ -34910,19 +35281,19 @@ class BatchedMesh extends Mesh {
34910
35281
 
34911
35282
  }
34912
35283
 
34913
- for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
35284
+ for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
34914
35285
 
34915
- if ( ! drawInfo[ i ].visible || ! drawInfo[ i ].active ) {
35286
+ if ( ! instanceInfo[ i ].visible || ! instanceInfo[ i ].active ) {
34916
35287
 
34917
35288
  continue;
34918
35289
 
34919
35290
  }
34920
35291
 
34921
- const geometryId = drawInfo[ i ].geometryIndex;
34922
- const drawRange = drawRanges[ geometryId ];
34923
- _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 );
34924
35295
 
34925
- // ge the intersects
35296
+ // get the intersects
34926
35297
  this.getMatrixAt( i, _mesh.matrixWorld ).premultiply( matrixWorld );
34927
35298
  this.getBoundingBoxAt( geometryId, _mesh.geometry.boundingBox );
34928
35299
  this.getBoundingSphereAt( geometryId, _mesh.geometry.boundingSphere );
@@ -34959,17 +35330,13 @@ class BatchedMesh extends Mesh {
34959
35330
  this.boundingBox = source.boundingBox !== null ? source.boundingBox.clone() : null;
34960
35331
  this.boundingSphere = source.boundingSphere !== null ? source.boundingSphere.clone() : null;
34961
35332
 
34962
- this._drawRanges = source._drawRanges.map( range => ( { ...range } ) );
34963
- this._reservedRanges = source._reservedRanges.map( range => ( { ...range } ) );
34964
-
34965
- this._drawInfo = source._drawInfo.map( inf => ( { ...inf } ) );
34966
- this._bounds = source._bounds.map( bound => ( {
34967
- boxInitialized: bound.boxInitialized,
34968
- box: bound.box.clone(),
35333
+ this._geometryInfo = source._geometryInfo.map( info => ( {
35334
+ ...info,
34969
35335
 
34970
- sphereInitialized: bound.sphereInitialized,
34971
- sphere: bound.sphere.clone()
35336
+ boundingBox: info.boundingBox !== null ? info.boundingBox.clone() : null,
35337
+ boundingSphere: info.boundingSphere !== null ? info.boundingSphere.clone() : null,
34972
35338
  } ) );
35339
+ this._instanceInfo = source._instanceInfo.map( info => ( { ...info } ) );
34973
35340
 
34974
35341
  this._maxInstanceCount = source._maxInstanceCount;
34975
35342
  this._maxVertexCount = source._maxVertexCount;
@@ -35031,10 +35398,10 @@ class BatchedMesh extends Mesh {
35031
35398
  const index = geometry.getIndex();
35032
35399
  const bytesPerElement = index === null ? 1 : index.array.BYTES_PER_ELEMENT;
35033
35400
 
35034
- const drawInfo = this._drawInfo;
35401
+ const instanceInfo = this._instanceInfo;
35035
35402
  const multiDrawStarts = this._multiDrawStarts;
35036
35403
  const multiDrawCounts = this._multiDrawCounts;
35037
- const drawRanges = this._drawRanges;
35404
+ const geometryInfoList = this._geometryInfo;
35038
35405
  const perObjectFrustumCulled = this.perObjectFrustumCulled;
35039
35406
  const indirectTexture = this._indirectTexture;
35040
35407
  const indirectArray = indirectTexture.image.data;
@@ -35042,29 +35409,29 @@ class BatchedMesh extends Mesh {
35042
35409
  // prepare the frustum in the local frame
35043
35410
  if ( perObjectFrustumCulled ) {
35044
35411
 
35045
- _projScreenMatrix$2
35412
+ _matrix$1
35046
35413
  .multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse )
35047
35414
  .multiply( this.matrixWorld );
35048
35415
  _frustum.setFromProjectionMatrix(
35049
- _projScreenMatrix$2,
35416
+ _matrix$1,
35050
35417
  renderer.coordinateSystem
35051
35418
  );
35052
35419
 
35053
35420
  }
35054
35421
 
35055
- let count = 0;
35422
+ let multiDrawCount = 0;
35056
35423
  if ( this.sortObjects ) {
35057
35424
 
35058
35425
  // get the camera position in the local frame
35059
- _invMatrixWorld.copy( this.matrixWorld ).invert();
35060
- _vector$5.setFromMatrixPosition( camera.matrixWorld ).applyMatrix4( _invMatrixWorld );
35061
- _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 );
35062
35429
 
35063
- for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
35430
+ for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
35064
35431
 
35065
- if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
35432
+ if ( instanceInfo[ i ].visible && instanceInfo[ i ].active ) {
35066
35433
 
35067
- const geometryId = drawInfo[ i ].geometryIndex;
35434
+ const geometryId = instanceInfo[ i ].geometryIndex;
35068
35435
 
35069
35436
  // get the bounds in world space
35070
35437
  this.getMatrixAt( i, _matrix$1 );
@@ -35081,8 +35448,9 @@ class BatchedMesh extends Mesh {
35081
35448
  if ( ! culled ) {
35082
35449
 
35083
35450
  // get the distance from camera used for sorting
35451
+ const geometryInfo = geometryInfoList[ geometryId ];
35084
35452
  const z = _temp.subVectors( _sphere$2.center, _vector$5 ).dot( _forward );
35085
- _renderList.push( drawRanges[ geometryId ], z, i );
35453
+ _renderList.push( geometryInfo.start, geometryInfo.count, z, i );
35086
35454
 
35087
35455
  }
35088
35456
 
@@ -35106,10 +35474,10 @@ class BatchedMesh extends Mesh {
35106
35474
  for ( let i = 0, l = list.length; i < l; i ++ ) {
35107
35475
 
35108
35476
  const item = list[ i ];
35109
- multiDrawStarts[ count ] = item.start * bytesPerElement;
35110
- multiDrawCounts[ count ] = item.count;
35111
- indirectArray[ count ] = item.index;
35112
- count ++;
35477
+ multiDrawStarts[ multiDrawCount ] = item.start * bytesPerElement;
35478
+ multiDrawCounts[ multiDrawCount ] = item.count;
35479
+ indirectArray[ multiDrawCount ] = item.index;
35480
+ multiDrawCount ++;
35113
35481
 
35114
35482
  }
35115
35483
 
@@ -35117,11 +35485,11 @@ class BatchedMesh extends Mesh {
35117
35485
 
35118
35486
  } else {
35119
35487
 
35120
- for ( let i = 0, l = drawInfo.length; i < l; i ++ ) {
35488
+ for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
35121
35489
 
35122
- if ( drawInfo[ i ].visible && drawInfo[ i ].active ) {
35490
+ if ( instanceInfo[ i ].visible && instanceInfo[ i ].active ) {
35123
35491
 
35124
- const geometryId = drawInfo[ i ].geometryIndex;
35492
+ const geometryId = instanceInfo[ i ].geometryIndex;
35125
35493
 
35126
35494
  // determine whether the batched geometry is within the frustum
35127
35495
  let culled = false;
@@ -35136,11 +35504,11 @@ class BatchedMesh extends Mesh {
35136
35504
 
35137
35505
  if ( ! culled ) {
35138
35506
 
35139
- const range = drawRanges[ geometryId ];
35140
- multiDrawStarts[ count ] = range.start * bytesPerElement;
35141
- multiDrawCounts[ count ] = range.count;
35142
- indirectArray[ count ] = i;
35143
- count ++;
35507
+ const geometryInfo = geometryInfoList[ geometryId ];
35508
+ multiDrawStarts[ multiDrawCount ] = geometryInfo.start * bytesPerElement;
35509
+ multiDrawCounts[ multiDrawCount ] = geometryInfo.count;
35510
+ indirectArray[ multiDrawCount ] = i;
35511
+ multiDrawCount ++;
35144
35512
 
35145
35513
  }
35146
35514
 
@@ -35151,7 +35519,7 @@ class BatchedMesh extends Mesh {
35151
35519
  }
35152
35520
 
35153
35521
  indirectTexture.needsUpdate = true;
35154
- this._multiDrawCount = count;
35522
+ this._multiDrawCount = multiDrawCount;
35155
35523
  this._visibilityChanged = false;
35156
35524
 
35157
35525
  }
@@ -35166,14 +35534,18 @@ class BatchedMesh extends Mesh {
35166
35534
 
35167
35535
  class LineBasicMaterial extends Material {
35168
35536
 
35537
+ static get type() {
35538
+
35539
+ return 'LineBasicMaterial';
35540
+
35541
+ }
35542
+
35169
35543
  constructor( parameters ) {
35170
35544
 
35171
35545
  super();
35172
35546
 
35173
35547
  this.isLineBasicMaterial = true;
35174
35548
 
35175
- this.type = 'LineBasicMaterial';
35176
-
35177
35549
  this.color = new Color( 0xffffff );
35178
35550
 
35179
35551
  this.map = null;
@@ -35511,14 +35883,18 @@ class LineLoop extends Line {
35511
35883
 
35512
35884
  class PointsMaterial extends Material {
35513
35885
 
35886
+ static get type() {
35887
+
35888
+ return 'PointsMaterial';
35889
+
35890
+ }
35891
+
35514
35892
  constructor( parameters ) {
35515
35893
 
35516
35894
  super();
35517
35895
 
35518
35896
  this.isPointsMaterial = true;
35519
35897
 
35520
- this.type = 'PointsMaterial';
35521
-
35522
35898
  this.color = new Color( 0xffffff );
35523
35899
 
35524
35900
  this.map = null;
@@ -38208,14 +38584,14 @@ class CylinderGeometry extends BufferGeometry {
38208
38584
 
38209
38585
  // faces
38210
38586
 
38211
- if ( radiusTop > 0 ) {
38587
+ if ( radiusTop > 0 || y !== 0 ) {
38212
38588
 
38213
38589
  indices.push( a, b, d );
38214
38590
  groupCount += 3;
38215
38591
 
38216
38592
  }
38217
38593
 
38218
- if ( radiusBottom > 0 ) {
38594
+ if ( radiusBottom > 0 || y !== heightSegments - 1 ) {
38219
38595
 
38220
38596
  indices.push( b, c, d );
38221
38597
  groupCount += 3;
@@ -41875,14 +42251,18 @@ var Geometries = /*#__PURE__*/Object.freeze({
41875
42251
 
41876
42252
  class ShadowMaterial extends Material {
41877
42253
 
42254
+ static get type() {
42255
+
42256
+ return 'ShadowMaterial';
42257
+
42258
+ }
42259
+
41878
42260
  constructor( parameters ) {
41879
42261
 
41880
42262
  super();
41881
42263
 
41882
42264
  this.isShadowMaterial = true;
41883
42265
 
41884
- this.type = 'ShadowMaterial';
41885
-
41886
42266
  this.color = new Color( 0x000000 );
41887
42267
  this.transparent = true;
41888
42268
 
@@ -41908,20 +42288,30 @@ class ShadowMaterial extends Material {
41908
42288
 
41909
42289
  class RawShaderMaterial extends ShaderMaterial {
41910
42290
 
42291
+ static get type() {
42292
+
42293
+ return 'RawShaderMaterial';
42294
+
42295
+ }
42296
+
41911
42297
  constructor( parameters ) {
41912
42298
 
41913
42299
  super( parameters );
41914
42300
 
41915
42301
  this.isRawShaderMaterial = true;
41916
42302
 
41917
- this.type = 'RawShaderMaterial';
41918
-
41919
42303
  }
41920
42304
 
41921
42305
  }
41922
42306
 
41923
42307
  class MeshStandardMaterial extends Material {
41924
42308
 
42309
+ static get type() {
42310
+
42311
+ return 'MeshStandardMaterial';
42312
+
42313
+ }
42314
+
41925
42315
  constructor( parameters ) {
41926
42316
 
41927
42317
  super();
@@ -41930,8 +42320,6 @@ class MeshStandardMaterial extends Material {
41930
42320
 
41931
42321
  this.defines = { 'STANDARD': '' };
41932
42322
 
41933
- this.type = 'MeshStandardMaterial';
41934
-
41935
42323
  this.color = new Color( 0xffffff ); // diffuse
41936
42324
  this.roughness = 1.0;
41937
42325
  this.metalness = 0.0;
@@ -42042,6 +42430,12 @@ class MeshStandardMaterial extends Material {
42042
42430
 
42043
42431
  class MeshPhysicalMaterial extends MeshStandardMaterial {
42044
42432
 
42433
+ static get type() {
42434
+
42435
+ return 'MeshPhysicalMaterial';
42436
+
42437
+ }
42438
+
42045
42439
  constructor( parameters ) {
42046
42440
 
42047
42441
  super();
@@ -42055,8 +42449,6 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
42055
42449
 
42056
42450
  };
42057
42451
 
42058
- this.type = 'MeshPhysicalMaterial';
42059
-
42060
42452
  this.anisotropyRotation = 0;
42061
42453
  this.anisotropyMap = null;
42062
42454
 
@@ -42280,14 +42672,18 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
42280
42672
 
42281
42673
  class MeshPhongMaterial extends Material {
42282
42674
 
42675
+ static get type() {
42676
+
42677
+ return 'MeshPhongMaterial';
42678
+
42679
+ }
42680
+
42283
42681
  constructor( parameters ) {
42284
42682
 
42285
42683
  super();
42286
42684
 
42287
42685
  this.isMeshPhongMaterial = true;
42288
42686
 
42289
- this.type = 'MeshPhongMaterial';
42290
-
42291
42687
  this.color = new Color( 0xffffff ); // diffuse
42292
42688
  this.specular = new Color( 0x111111 );
42293
42689
  this.shininess = 30;
@@ -42396,6 +42792,12 @@ class MeshPhongMaterial extends Material {
42396
42792
 
42397
42793
  class MeshToonMaterial extends Material {
42398
42794
 
42795
+ static get type() {
42796
+
42797
+ return 'MeshToonMaterial';
42798
+
42799
+ }
42800
+
42399
42801
  constructor( parameters ) {
42400
42802
 
42401
42803
  super();
@@ -42404,8 +42806,6 @@ class MeshToonMaterial extends Material {
42404
42806
 
42405
42807
  this.defines = { 'TOON': '' };
42406
42808
 
42407
- this.type = 'MeshToonMaterial';
42408
-
42409
42809
  this.color = new Color( 0xffffff );
42410
42810
 
42411
42811
  this.map = null;
@@ -42492,14 +42892,18 @@ class MeshToonMaterial extends Material {
42492
42892
 
42493
42893
  class MeshNormalMaterial extends Material {
42494
42894
 
42895
+ static get type() {
42896
+
42897
+ return 'MeshNormalMaterial';
42898
+
42899
+ }
42900
+
42495
42901
  constructor( parameters ) {
42496
42902
 
42497
42903
  super();
42498
42904
 
42499
42905
  this.isMeshNormalMaterial = true;
42500
42906
 
42501
- this.type = 'MeshNormalMaterial';
42502
-
42503
42907
  this.bumpMap = null;
42504
42908
  this.bumpScale = 1;
42505
42909
 
@@ -42548,14 +42952,18 @@ class MeshNormalMaterial extends Material {
42548
42952
 
42549
42953
  class MeshLambertMaterial extends Material {
42550
42954
 
42955
+ static get type() {
42956
+
42957
+ return 'MeshLambertMaterial';
42958
+
42959
+ }
42960
+
42551
42961
  constructor( parameters ) {
42552
42962
 
42553
42963
  super();
42554
42964
 
42555
42965
  this.isMeshLambertMaterial = true;
42556
42966
 
42557
- this.type = 'MeshLambertMaterial';
42558
-
42559
42967
  this.color = new Color( 0xffffff ); // diffuse
42560
42968
 
42561
42969
  this.map = null;
@@ -42660,6 +43068,12 @@ class MeshLambertMaterial extends Material {
42660
43068
 
42661
43069
  class MeshMatcapMaterial extends Material {
42662
43070
 
43071
+ static get type() {
43072
+
43073
+ return 'MeshMatcapMaterial';
43074
+
43075
+ }
43076
+
42663
43077
  constructor( parameters ) {
42664
43078
 
42665
43079
  super();
@@ -42668,8 +43082,6 @@ class MeshMatcapMaterial extends Material {
42668
43082
 
42669
43083
  this.defines = { 'MATCAP': '' };
42670
43084
 
42671
- this.type = 'MeshMatcapMaterial';
42672
-
42673
43085
  this.color = new Color( 0xffffff ); // diffuse
42674
43086
 
42675
43087
  this.matcap = null;
@@ -42735,14 +43147,18 @@ class MeshMatcapMaterial extends Material {
42735
43147
 
42736
43148
  class LineDashedMaterial extends LineBasicMaterial {
42737
43149
 
43150
+ static get type() {
43151
+
43152
+ return 'LineDashedMaterial';
43153
+
43154
+ }
43155
+
42738
43156
  constructor( parameters ) {
42739
43157
 
42740
43158
  super();
42741
43159
 
42742
43160
  this.isLineDashedMaterial = true;
42743
43161
 
42744
- this.type = 'LineDashedMaterial';
42745
-
42746
43162
  this.scale = 1;
42747
43163
  this.dashSize = 3;
42748
43164
  this.gapSize = 1;
@@ -54653,4 +55069,4 @@ if ( typeof window !== 'undefined' ) {
54653
55069
 
54654
55070
  }
54655
55071
 
54656
- 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 };