super-three 0.147.0 → 0.152.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 (757) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +36408 -21117
  3. package/build/three.js +37007 -21715
  4. package/build/three.min.js +3 -2
  5. package/build/three.module.js +6387 -5510
  6. package/build/three.module.min.js +6 -0
  7. package/examples/jsm/animation/AnimationClipCreator.js +5 -3
  8. package/examples/jsm/capabilities/WebGPU.js +2 -4
  9. package/examples/jsm/controls/ArcballControls.js +1828 -1821
  10. package/examples/jsm/controls/MapControls.js +28 -0
  11. package/examples/jsm/controls/OrbitControls.js +20 -45
  12. package/examples/jsm/controls/PointerLockControls.js +70 -65
  13. package/examples/jsm/controls/TrackballControls.js +18 -4
  14. package/examples/jsm/controls/TransformControls.js +0 -1
  15. package/examples/jsm/csm/CSM.js +11 -3
  16. package/examples/jsm/csm/CSMShader.js +7 -6
  17. package/examples/jsm/effects/AsciiEffect.js +3 -6
  18. package/examples/jsm/effects/OutlineEffect.js +1 -15
  19. package/examples/jsm/exporters/ColladaExporter.js +26 -14
  20. package/examples/jsm/exporters/DRACOExporter.js +53 -11
  21. package/examples/jsm/exporters/EXRExporter.js +3 -9
  22. package/examples/jsm/exporters/GLTFExporter.js +524 -111
  23. package/examples/jsm/exporters/KTX2Exporter.js +34 -23
  24. package/examples/jsm/exporters/MMDExporter.js +1 -1
  25. package/examples/jsm/exporters/PLYExporter.js +8 -1
  26. package/examples/jsm/exporters/STLExporter.js +8 -4
  27. package/examples/jsm/exporters/USDZExporter.js +22 -3
  28. package/examples/jsm/geometries/ConvexGeometry.js +0 -6
  29. package/examples/jsm/geometries/ParametricGeometry.js +10 -0
  30. package/examples/jsm/helpers/OctreeHelper.js +1 -0
  31. package/examples/jsm/helpers/ViewHelper.js +70 -56
  32. package/examples/jsm/interactive/HTMLMesh.js +16 -3
  33. package/examples/jsm/interactive/InteractiveGroup.js +1 -1
  34. package/examples/{js → jsm}/libs/basis/README.md +4 -4
  35. package/examples/jsm/libs/draco/draco_decoder.js +34 -0
  36. package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
  37. package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
  38. package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
  39. package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
  40. package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
  41. package/examples/jsm/libs/lil-gui.module.min.js +2 -2
  42. package/examples/jsm/libs/tween.module.js +803 -0
  43. package/examples/jsm/lights/IESSpotLight.js +25 -0
  44. package/examples/jsm/lights/LightProbeGenerator.js +11 -9
  45. package/examples/jsm/lines/LineSegments2.js +12 -10
  46. package/examples/jsm/loaders/3DMLoader.js +8 -5
  47. package/examples/jsm/loaders/3MFLoader.js +12 -11
  48. package/examples/jsm/loaders/AMFLoader.js +2 -3
  49. package/examples/jsm/loaders/BVHLoader.js +2 -2
  50. package/examples/jsm/loaders/ColladaLoader.js +15 -16
  51. package/examples/jsm/loaders/DRACOLoader.js +67 -18
  52. package/examples/jsm/loaders/EXRLoader.js +23 -24
  53. package/examples/jsm/loaders/FBXLoader.js +32 -50
  54. package/examples/jsm/loaders/GCodeLoader.js +1 -2
  55. package/examples/jsm/loaders/GLTFLoader.js +249 -215
  56. package/examples/jsm/loaders/HDRCubeTextureLoader.js +4 -4
  57. package/examples/jsm/loaders/IESLoader.js +337 -0
  58. package/examples/jsm/loaders/KMZLoader.js +4 -4
  59. package/examples/jsm/loaders/KTX2Loader.js +41 -24
  60. package/examples/jsm/loaders/LDrawLoader.js +20 -18
  61. package/examples/jsm/loaders/LWOLoader.js +12 -29
  62. package/examples/jsm/loaders/LottieLoader.js +3 -1
  63. package/examples/jsm/loaders/MMDLoader.js +17 -13
  64. package/examples/jsm/loaders/MTLLoader.js +2 -2
  65. package/examples/jsm/loaders/MaterialXLoader.js +9 -3
  66. package/examples/jsm/loaders/NRRDLoader.js +33 -5
  67. package/examples/jsm/loaders/OBJLoader.js +1 -1
  68. package/examples/jsm/loaders/PCDLoader.js +1 -2
  69. package/examples/jsm/loaders/PLYLoader.js +238 -105
  70. package/examples/jsm/loaders/RGBELoader.js +3 -3
  71. package/examples/jsm/loaders/STLLoader.js +1 -2
  72. package/examples/jsm/loaders/SVGLoader.js +36 -27
  73. package/examples/jsm/loaders/TTFLoader.js +1 -8
  74. package/examples/jsm/loaders/TiltLoader.js +13 -7
  75. package/examples/jsm/loaders/USDZLoader.js +5 -5
  76. package/examples/jsm/loaders/VOXLoader.js +8 -2
  77. package/examples/jsm/loaders/VRMLLoader.js +5 -13
  78. package/examples/jsm/loaders/VTKLoader.js +7 -6
  79. package/examples/jsm/loaders/lwo/IFFParser.js +19 -19
  80. package/examples/jsm/materials/MeshGouraudMaterial.js +0 -3
  81. package/examples/jsm/math/MeshSurfaceSampler.js +0 -6
  82. package/examples/jsm/misc/ConvexObjectBreaker.js +2 -8
  83. package/examples/jsm/misc/GPUComputationRenderer.js +5 -5
  84. package/examples/jsm/misc/MD2Character.js +2 -2
  85. package/examples/jsm/misc/MD2CharacterComplex.js +2 -2
  86. package/examples/jsm/misc/ProgressiveLightMap.js +12 -10
  87. package/examples/jsm/misc/RollerCoaster.js +7 -1
  88. package/examples/jsm/misc/Volume.js +20 -5
  89. package/examples/jsm/modifiers/CurveModifier.js +1 -0
  90. package/examples/jsm/modifiers/TessellateModifier.js +19 -19
  91. package/examples/jsm/nodes/Nodes.js +143 -335
  92. package/examples/jsm/nodes/accessors/BitangentNode.js +43 -16
  93. package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
  94. package/examples/jsm/nodes/accessors/CameraNode.js +12 -2
  95. package/examples/jsm/nodes/accessors/CubeTextureNode.js +27 -33
  96. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +58 -0
  97. package/examples/jsm/nodes/accessors/InstanceNode.js +17 -21
  98. package/examples/jsm/nodes/accessors/MaterialNode.js +155 -38
  99. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +16 -0
  100. package/examples/jsm/nodes/accessors/ModelNode.js +11 -0
  101. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +12 -8
  102. package/examples/jsm/nodes/accessors/NormalNode.js +35 -19
  103. package/examples/jsm/nodes/accessors/Object3DNode.js +32 -12
  104. package/examples/jsm/nodes/accessors/PointUVNode.js +6 -1
  105. package/examples/jsm/nodes/accessors/PositionNode.js +38 -23
  106. package/examples/jsm/nodes/accessors/ReferenceNode.js +21 -14
  107. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +11 -7
  108. package/examples/jsm/nodes/accessors/SkinningNode.js +43 -40
  109. package/examples/jsm/nodes/accessors/StorageBufferNode.js +6 -0
  110. package/examples/jsm/nodes/accessors/TangentNode.js +28 -20
  111. package/examples/jsm/nodes/accessors/TextureNode.js +80 -12
  112. package/examples/jsm/nodes/accessors/UVNode.js +6 -0
  113. package/examples/jsm/nodes/accessors/UserDataNode.js +6 -0
  114. package/examples/jsm/nodes/{core → code}/CodeNode.js +27 -2
  115. package/examples/jsm/nodes/code/ExpressionNode.js +37 -0
  116. package/examples/jsm/nodes/{core → code}/FunctionCallNode.js +15 -1
  117. package/examples/jsm/nodes/{core → code}/FunctionNode.js +8 -7
  118. package/examples/jsm/nodes/code/ScriptableNode.js +488 -0
  119. package/examples/jsm/nodes/code/ScriptableValueNode.js +167 -0
  120. package/examples/jsm/nodes/core/ArrayUniformNode.js +3 -0
  121. package/examples/jsm/nodes/core/AttributeNode.js +16 -8
  122. package/examples/jsm/nodes/core/BypassNode.js +9 -2
  123. package/examples/jsm/nodes/core/CacheNode.js +46 -0
  124. package/examples/jsm/nodes/core/ConstNode.js +3 -0
  125. package/examples/jsm/nodes/core/ContextNode.js +8 -1
  126. package/examples/jsm/nodes/core/InputNode.js +26 -5
  127. package/examples/jsm/nodes/core/InstanceIndexNode.js +6 -1
  128. package/examples/jsm/nodes/core/LightingModel.js +16 -0
  129. package/examples/jsm/nodes/core/Node.js +128 -34
  130. package/examples/jsm/nodes/core/NodeBuilder.js +209 -118
  131. package/examples/jsm/nodes/core/NodeCache.js +26 -0
  132. package/examples/jsm/nodes/core/NodeFrame.js +56 -5
  133. package/examples/jsm/nodes/core/NodeUtils.js +105 -28
  134. package/examples/jsm/nodes/core/PropertyNode.js +19 -2
  135. package/examples/jsm/nodes/core/StackNode.js +92 -0
  136. package/examples/jsm/nodes/core/TempNode.js +11 -3
  137. package/examples/jsm/nodes/core/UniformNode.js +15 -0
  138. package/examples/jsm/nodes/core/VarNode.js +21 -29
  139. package/examples/jsm/nodes/core/VaryingNode.js +15 -2
  140. package/examples/jsm/nodes/core/constants.js +6 -0
  141. package/examples/jsm/nodes/display/BlendModeNode.js +25 -11
  142. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +30 -14
  143. package/examples/jsm/nodes/display/ColorSpaceNode.js +39 -27
  144. package/examples/jsm/nodes/display/FrontFacingNode.js +7 -1
  145. package/examples/jsm/nodes/display/NormalMapNode.js +31 -18
  146. package/examples/jsm/nodes/display/PosterizeNode.js +10 -3
  147. package/examples/jsm/nodes/display/ToneMappingNode.js +92 -11
  148. package/examples/jsm/nodes/display/ViewportNode.js +27 -18
  149. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +30 -0
  150. package/examples/jsm/nodes/display/ViewportTextureNode.js +61 -0
  151. package/examples/jsm/nodes/fog/FogExp2Node.js +35 -0
  152. package/examples/jsm/nodes/fog/FogNode.js +12 -6
  153. package/examples/jsm/nodes/fog/FogRangeNode.js +12 -5
  154. package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +30 -0
  155. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -13
  156. package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  157. package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -6
  158. package/examples/jsm/nodes/functions/BSDF/D_GGX.js +4 -4
  159. package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +3 -3
  160. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +7 -5
  161. package/examples/jsm/nodes/functions/PhongLightingModel.js +28 -0
  162. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +33 -36
  163. package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +4 -3
  164. package/examples/jsm/nodes/functions/material/getRoughness.js +4 -4
  165. package/examples/jsm/nodes/geometry/RangeNode.js +32 -19
  166. package/examples/jsm/nodes/gpgpu/ComputeNode.js +9 -2
  167. package/examples/jsm/nodes/lighting/AONode.js +5 -3
  168. package/examples/jsm/nodes/lighting/AmbientLightNode.js +27 -0
  169. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +112 -6
  170. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +43 -0
  171. package/examples/jsm/nodes/lighting/EnvironmentNode.js +104 -34
  172. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +15 -10
  173. package/examples/jsm/nodes/lighting/IESSpotLightNode.js +39 -0
  174. package/examples/jsm/nodes/lighting/LightNode.js +57 -0
  175. package/examples/jsm/nodes/lighting/LightUtils.js +17 -0
  176. package/examples/jsm/nodes/lighting/LightingContextNode.js +30 -8
  177. package/examples/jsm/nodes/lighting/LightingNode.js +3 -1
  178. package/examples/jsm/nodes/lighting/LightsNode.js +18 -10
  179. package/examples/jsm/nodes/lighting/PointLightNode.js +71 -0
  180. package/examples/jsm/nodes/lighting/SpotLightNode.js +92 -0
  181. package/examples/jsm/nodes/loaders/NodeLoader.js +5 -4
  182. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +4 -20
  183. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +6 -9
  184. package/examples/jsm/nodes/materials/Materials.js +11 -55
  185. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +5 -11
  186. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +48 -0
  187. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +74 -0
  188. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
  189. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +21 -96
  190. package/examples/jsm/nodes/materials/NodeMaterial.js +244 -61
  191. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +7 -1
  192. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +29 -25
  193. package/examples/jsm/nodes/materialx/MaterialXNodes.js +31 -22
  194. package/examples/jsm/nodes/materialx/lib/mx_hsv.js +1 -1
  195. package/examples/jsm/nodes/materialx/lib/mx_noise.js +2 -1
  196. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +2 -1
  197. package/examples/jsm/nodes/math/CondNode.js +43 -17
  198. package/examples/jsm/nodes/math/MathNode.js +178 -73
  199. package/examples/jsm/nodes/math/OperatorNode.js +52 -2
  200. package/examples/jsm/nodes/procedural/CheckerNode.js +14 -6
  201. package/examples/jsm/nodes/shadernode/ShaderNode.js +158 -42
  202. package/examples/jsm/nodes/utils/ArrayElementNode.js +4 -2
  203. package/examples/jsm/nodes/utils/ConvertNode.js +19 -1
  204. package/examples/jsm/nodes/utils/DiscardNode.js +26 -0
  205. package/examples/jsm/nodes/utils/EquirectUVNode.js +11 -4
  206. package/examples/jsm/nodes/utils/JoinNode.js +4 -1
  207. package/examples/jsm/nodes/utils/MatcapUVNode.js +11 -4
  208. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +18 -5
  209. package/examples/jsm/nodes/utils/OscNode.js +21 -14
  210. package/examples/jsm/nodes/utils/PackingNode.js +55 -0
  211. package/examples/jsm/nodes/utils/RemapNode.js +13 -5
  212. package/examples/jsm/nodes/utils/RotateUVNode.js +18 -7
  213. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +37 -0
  214. package/examples/jsm/nodes/utils/SplitNode.js +7 -5
  215. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +15 -30
  216. package/examples/jsm/nodes/utils/TimerNode.js +16 -6
  217. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +21 -10
  218. package/examples/jsm/objects/GroundProjectedSkybox.js +172 -0
  219. package/examples/jsm/objects/Reflector.js +4 -4
  220. package/examples/jsm/objects/Refractor.js +4 -4
  221. package/examples/jsm/objects/ShadowMesh.js +3 -3
  222. package/examples/jsm/physics/AmmoPhysics.js +27 -28
  223. package/examples/jsm/physics/{OimoPhysics.js → RapierPhysics.js} +59 -51
  224. package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +0 -8
  225. package/examples/jsm/postprocessing/AfterimagePass.js +0 -2
  226. package/examples/jsm/postprocessing/BloomPass.js +0 -2
  227. package/examples/jsm/postprocessing/BokehPass.js +0 -6
  228. package/examples/jsm/postprocessing/DotScreenPass.js +0 -2
  229. package/examples/jsm/postprocessing/EffectComposer.js +3 -94
  230. package/examples/jsm/postprocessing/FilmPass.js +0 -2
  231. package/examples/jsm/postprocessing/GlitchPass.js +0 -2
  232. package/examples/jsm/postprocessing/HalftonePass.js +0 -6
  233. package/examples/jsm/postprocessing/OutlinePass.js +0 -1
  234. package/examples/jsm/postprocessing/Pass.js +2 -0
  235. package/examples/jsm/postprocessing/SAOPass.js +0 -24
  236. package/examples/jsm/postprocessing/SMAAPass.js +0 -6
  237. package/examples/jsm/postprocessing/SSAARenderPass.js +13 -5
  238. package/examples/jsm/postprocessing/SSAOPass.js +0 -12
  239. package/examples/jsm/postprocessing/SSRPass.js +0 -6
  240. package/examples/jsm/postprocessing/SavePass.js +0 -2
  241. package/examples/jsm/postprocessing/TexturePass.js +0 -2
  242. package/examples/jsm/postprocessing/UnrealBloomPass.js +0 -8
  243. package/examples/jsm/renderers/CSS2DRenderer.js +6 -1
  244. package/examples/jsm/renderers/CSS3DRenderer.js +27 -5
  245. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +35 -31
  246. package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +2 -2
  247. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +14 -4
  248. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +72 -55
  249. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +34 -19
  250. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +1 -1
  251. package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +158 -26
  252. package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +1 -1
  253. package/examples/jsm/renderers/webgpu/WebGPUProperties.js +6 -0
  254. package/examples/jsm/renderers/webgpu/WebGPURenderLists.js +30 -14
  255. package/examples/jsm/renderers/webgpu/WebGPURenderObject.js +40 -0
  256. package/examples/jsm/renderers/webgpu/WebGPURenderObjects.js +50 -0
  257. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +49 -111
  258. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +40 -62
  259. package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +14 -26
  260. package/examples/jsm/renderers/webgpu/WebGPURenderTarget.js +15 -0
  261. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +244 -100
  262. package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +3 -1
  263. package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +2 -4
  264. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +2 -0
  265. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +366 -110
  266. package/examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js +1 -1
  267. package/examples/jsm/renderers/webgpu/WebGPUUtils.js +13 -6
  268. package/examples/jsm/renderers/webgpu/WebGPUWeakMap.js +83 -0
  269. package/examples/jsm/renderers/webgpu/constants.js +68 -6
  270. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +74 -57
  271. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +241 -22
  272. package/examples/jsm/shaders/MMDToonShader.js +15 -4
  273. package/examples/jsm/shaders/RGBShiftShader.js +2 -2
  274. package/examples/jsm/shaders/VelocityShader.js +1 -1
  275. package/examples/jsm/utils/BufferGeometryUtils.js +37 -35
  276. package/examples/jsm/utils/LDrawUtils.js +4 -4
  277. package/examples/jsm/utils/PackedPhongMaterial.js +5 -78
  278. package/examples/jsm/utils/SceneUtils.js +8 -4
  279. package/examples/jsm/utils/SkeletonUtils.js +27 -210
  280. package/examples/jsm/webxr/VRButton.js +1 -2
  281. package/examples/jsm/webxr/XRButton.js +198 -0
  282. package/package.json +33 -87
  283. package/src/Three.Legacy.js +19 -110
  284. package/src/Three.js +4 -3
  285. package/src/animation/AnimationUtils.js +13 -1
  286. package/src/animation/PropertyBinding.js +2 -2
  287. package/src/audio/Audio.js +7 -2
  288. package/src/constants.js +10 -2
  289. package/src/core/BufferAttribute.js +147 -8
  290. package/src/core/BufferGeometry.js +3 -9
  291. package/src/core/GLBufferAttribute.js +2 -0
  292. package/src/core/InterleavedBufferAttribute.js +1 -1
  293. package/src/core/Object3D.js +36 -7
  294. package/src/extras/DataUtils.js +7 -1
  295. package/src/extras/ImageUtils.js +2 -2
  296. package/src/extras/PMREMGenerator.js +5 -5
  297. package/src/extras/curves/LineCurve.js +6 -4
  298. package/src/extras/curves/LineCurve3.js +13 -0
  299. package/src/geometries/BoxGeometry.js +10 -0
  300. package/src/geometries/CircleGeometry.js +11 -1
  301. package/src/geometries/ConeGeometry.js +1 -1
  302. package/src/geometries/CylinderGeometry.js +11 -1
  303. package/src/geometries/EdgesGeometry.js +10 -0
  304. package/src/geometries/ExtrudeGeometry.js +11 -1
  305. package/src/geometries/LatheGeometry.js +10 -0
  306. package/src/geometries/PlaneGeometry.js +10 -0
  307. package/src/geometries/PolyhedronGeometry.js +10 -0
  308. package/src/geometries/RingGeometry.js +11 -1
  309. package/src/geometries/ShapeGeometry.js +10 -0
  310. package/src/geometries/SphereGeometry.js +12 -2
  311. package/src/geometries/TorusGeometry.js +11 -1
  312. package/src/geometries/TorusKnotGeometry.js +10 -0
  313. package/src/geometries/TubeGeometry.js +10 -0
  314. package/src/geometries/WireframeGeometry.js +10 -0
  315. package/src/helpers/Box3Helper.js +1 -2
  316. package/src/lights/DirectionalLight.js +1 -1
  317. package/src/lights/HemisphereLight.js +1 -1
  318. package/src/lights/SpotLight.js +1 -1
  319. package/src/loaders/AudioLoader.js +14 -8
  320. package/src/loaders/DataTextureLoader.js +5 -1
  321. package/src/loaders/MaterialLoader.js +4 -0
  322. package/src/loaders/ObjectLoader.js +9 -2
  323. package/src/materials/LineBasicMaterial.js +4 -0
  324. package/src/materials/Material.js +6 -3
  325. package/src/materials/MeshDistanceMaterial.js +0 -9
  326. package/src/materials/ShaderMaterial.js +6 -1
  327. package/src/math/Box2.js +3 -2
  328. package/src/math/Box3.js +49 -64
  329. package/src/math/Color.js +72 -55
  330. package/src/math/ColorManagement.js +75 -16
  331. package/src/math/Euler.js +2 -11
  332. package/src/math/Frustum.js +13 -3
  333. package/src/math/MathUtils.js +27 -1
  334. package/src/math/Plane.js +2 -2
  335. package/src/math/Quaternion.js +6 -0
  336. package/src/math/Ray.js +7 -7
  337. package/src/math/Triangle.js +37 -7
  338. package/src/math/Vector2.js +16 -0
  339. package/src/math/Vector3.js +10 -0
  340. package/src/math/interpolants/CubicInterpolant.js +1 -2
  341. package/src/objects/InstancedMesh.js +79 -1
  342. package/src/objects/Mesh.js +101 -73
  343. package/src/objects/SkinnedMesh.js +95 -8
  344. package/src/objects/Sprite.js +1 -1
  345. package/src/renderers/WebGLCubeRenderTarget.js +12 -3
  346. package/src/renderers/WebGLMultipleRenderTargets.js +4 -2
  347. package/src/renderers/WebGLRenderTarget.js +14 -2
  348. package/src/renderers/WebGLRenderer.js +1340 -1258
  349. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +1 -1
  350. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
  351. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +0 -271
  352. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +5 -5
  353. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +2 -10
  354. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +5 -5
  355. package/src/renderers/shaders/ShaderChunk/common.glsl.js +32 -0
  356. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +1 -1
  357. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +1 -1
  358. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +1 -1
  359. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +1 -1
  360. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
  361. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +1 -1
  362. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -11
  363. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +13 -13
  364. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +256 -10
  365. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -11
  366. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +9 -1
  367. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +10 -2
  368. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +1 -1
  369. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +32 -10
  370. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +5 -13
  371. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +7 -7
  372. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +11 -5
  373. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +1 -1
  374. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +4 -11
  375. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +2 -2
  376. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +39 -34
  377. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +1 -1
  378. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +2 -2
  379. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +91 -11
  380. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +108 -1
  381. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +128 -6
  382. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +111 -1
  383. package/src/renderers/shaders/ShaderChunk.js +0 -6
  384. package/src/renderers/shaders/ShaderLib/background.glsl.js +0 -8
  385. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +5 -0
  386. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -4
  387. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -3
  388. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +3 -3
  389. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -3
  390. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +8 -12
  391. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -3
  392. package/src/renderers/shaders/ShaderLib/points.glsl.js +13 -0
  393. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +5 -0
  394. package/src/renderers/shaders/ShaderLib.js +15 -4
  395. package/src/renderers/shaders/UniformsLib.js +25 -15
  396. package/src/renderers/shaders/UniformsUtils.js +12 -3
  397. package/src/renderers/webgl/WebGLBackground.js +23 -12
  398. package/src/renderers/webgl/WebGLCapabilities.js +1 -2
  399. package/src/renderers/webgl/WebGLClipping.js +7 -3
  400. package/src/renderers/webgl/WebGLLights.js +2 -2
  401. package/src/renderers/webgl/WebGLMaterials.js +105 -234
  402. package/src/renderers/webgl/WebGLMorphtargets.js +1 -1
  403. package/src/renderers/webgl/WebGLProgram.js +111 -48
  404. package/src/renderers/webgl/WebGLPrograms.js +200 -129
  405. package/src/renderers/webgl/WebGLRenderStates.js +2 -2
  406. package/src/renderers/webgl/WebGLShadowMap.js +40 -27
  407. package/src/renderers/webgl/WebGLState.js +23 -9
  408. package/src/renderers/webgl/WebGLTextures.js +21 -19
  409. package/src/renderers/webgl/WebGLUniformsGroups.js +74 -33
  410. package/src/renderers/webgl/WebGLUtils.js +41 -29
  411. package/src/renderers/webxr/WebXRController.js +3 -0
  412. package/src/renderers/webxr/WebXRManager.js +70 -48
  413. package/src/scenes/Scene.js +4 -6
  414. package/src/textures/CompressedTexture.js +2 -2
  415. package/src/textures/CubeTexture.js +2 -2
  416. package/src/textures/DataTexture.js +2 -2
  417. package/src/textures/Texture.js +41 -12
  418. package/src/utils.js +13 -1
  419. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
  420. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
  421. package/examples/fonts/open-sans/open-sans.css +0 -9
  422. package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
  423. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +0 -3966
  424. package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
  425. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
  426. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
  427. package/examples/fonts/tabler-icons/tabler-icons.min.css +0 -4
  428. package/examples/js/animation/AnimationClipCreator.js +0 -89
  429. package/examples/js/animation/CCDIKSolver.js +0 -416
  430. package/examples/js/animation/MMDAnimationHelper.js +0 -1046
  431. package/examples/js/animation/MMDPhysics.js +0 -1174
  432. package/examples/js/cameras/CinematicCamera.js +0 -168
  433. package/examples/js/controls/ArcballControls.js +0 -2770
  434. package/examples/js/controls/DragControls.js +0 -205
  435. package/examples/js/controls/FirstPersonControls.js +0 -312
  436. package/examples/js/controls/FlyControls.js +0 -321
  437. package/examples/js/controls/OrbitControls.js +0 -1101
  438. package/examples/js/controls/PointerLockControls.js +0 -144
  439. package/examples/js/controls/TrackballControls.js +0 -729
  440. package/examples/js/controls/TransformControls.js +0 -1301
  441. package/examples/js/csm/CSM.js +0 -347
  442. package/examples/js/csm/CSMFrustum.js +0 -127
  443. package/examples/js/csm/CSMHelper.js +0 -165
  444. package/examples/js/csm/CSMShader.js +0 -253
  445. package/examples/js/curves/CurveExtras.js +0 -348
  446. package/examples/js/curves/NURBSCurve.js +0 -63
  447. package/examples/js/curves/NURBSSurface.js +0 -48
  448. package/examples/js/curves/NURBSUtils.js +0 -439
  449. package/examples/js/effects/AnaglyphEffect.js +0 -86
  450. package/examples/js/effects/AsciiEffect.js +0 -260
  451. package/examples/js/effects/OutlineEffect.js +0 -450
  452. package/examples/js/effects/ParallaxBarrierEffect.js +0 -62
  453. package/examples/js/effects/PeppersGhostEffect.js +0 -139
  454. package/examples/js/effects/StereoEffect.js +0 -46
  455. package/examples/js/environments/DebugEnvironment.js +0 -53
  456. package/examples/js/environments/RoomEnvironment.js +0 -124
  457. package/examples/js/exporters/ColladaExporter.js +0 -487
  458. package/examples/js/exporters/DRACOExporter.js +0 -212
  459. package/examples/js/exporters/EXRExporter.js +0 -455
  460. package/examples/js/exporters/GLTFExporter.js +0 -2367
  461. package/examples/js/exporters/MMDExporter.js +0 -187
  462. package/examples/js/exporters/OBJExporter.js +0 -260
  463. package/examples/js/exporters/PLYExporter.js +0 -427
  464. package/examples/js/exporters/STLExporter.js +0 -188
  465. package/examples/js/exporters/USDZExporter.js +0 -608
  466. package/examples/js/geometries/BoxLineGeometry.js +0 -59
  467. package/examples/js/geometries/ConvexGeometry.js +0 -53
  468. package/examples/js/geometries/DecalGeometry.js +0 -324
  469. package/examples/js/geometries/LightningStrike.js +0 -861
  470. package/examples/js/geometries/ParametricGeometries.js +0 -216
  471. package/examples/js/geometries/ParametricGeometry.js +0 -121
  472. package/examples/js/geometries/RoundedBoxGeometry.js +0 -142
  473. package/examples/js/geometries/TeapotGeometry.js +0 -335
  474. package/examples/js/geometries/TextGeometry.js +0 -53
  475. package/examples/js/helpers/LightProbeHelper.js +0 -48
  476. package/examples/js/helpers/OctreeHelper.js +0 -76
  477. package/examples/js/helpers/PositionalAudioHelper.js +0 -91
  478. package/examples/js/helpers/RectAreaLightHelper.js +0 -73
  479. package/examples/js/helpers/VertexNormalsHelper.js +0 -74
  480. package/examples/js/helpers/VertexTangentsHelper.js +0 -68
  481. package/examples/js/helpers/ViewHelper.js +0 -281
  482. package/examples/js/interactive/HTMLMesh.js +0 -497
  483. package/examples/js/interactive/InteractiveGroup.js +0 -95
  484. package/examples/js/interactive/SelectionBox.js +0 -195
  485. package/examples/js/interactive/SelectionHelper.js +0 -83
  486. package/examples/js/libs/chevrotain.min.js +0 -3
  487. package/examples/js/libs/draco/draco_decoder.js +0 -52
  488. package/examples/js/libs/draco/draco_decoder.wasm +0 -0
  489. package/examples/js/libs/draco/draco_wasm_wrapper.js +0 -104
  490. package/examples/js/libs/draco/gltf/draco_decoder.js +0 -48
  491. package/examples/js/libs/draco/gltf/draco_decoder.wasm +0 -0
  492. package/examples/js/libs/draco/gltf/draco_wasm_wrapper.js +0 -104
  493. package/examples/js/libs/fflate.min.js +0 -7
  494. package/examples/js/libs/ktx-parse.umd.js +0 -1
  495. package/examples/js/libs/meshopt_decoder.js +0 -188
  496. package/examples/js/libs/opentype.min.js +0 -1
  497. package/examples/js/libs/stats.min.js +0 -5
  498. package/examples/js/lights/LightProbeGenerator.js +0 -221
  499. package/examples/js/lights/RectAreaLightUniformsLib.js +0 -60
  500. package/examples/js/lines/Line2.js +0 -19
  501. package/examples/js/lines/LineGeometry.js +0 -69
  502. package/examples/js/lines/LineMaterial.js +0 -635
  503. package/examples/js/lines/LineSegments2.js +0 -313
  504. package/examples/js/lines/LineSegmentsGeometry.js +0 -198
  505. package/examples/js/lines/Wireframe.js +0 -47
  506. package/examples/js/lines/WireframeGeometry2.js +0 -20
  507. package/examples/js/loaders/3DMLoader.js +0 -1273
  508. package/examples/js/loaders/3MFLoader.js +0 -1306
  509. package/examples/js/loaders/AMFLoader.js +0 -504
  510. package/examples/js/loaders/BVHLoader.js +0 -395
  511. package/examples/js/loaders/BasisTextureLoader.js +0 -706
  512. package/examples/js/loaders/ColladaLoader.js +0 -3690
  513. package/examples/js/loaders/DDSLoader.js +0 -244
  514. package/examples/js/loaders/DRACOLoader.js +0 -511
  515. package/examples/js/loaders/EXRLoader.js +0 -2039
  516. package/examples/js/loaders/FBXLoader.js +0 -3681
  517. package/examples/js/loaders/FontLoader.js +0 -160
  518. package/examples/js/loaders/GCodeLoader.js +0 -255
  519. package/examples/js/loaders/GLTFLoader.js +0 -3862
  520. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -87
  521. package/examples/js/loaders/KMZLoader.js +0 -121
  522. package/examples/js/loaders/KTXLoader.js +0 -159
  523. package/examples/js/loaders/LDrawLoader.js +0 -2263
  524. package/examples/js/loaders/LUT3dlLoader.js +0 -135
  525. package/examples/js/loaders/LUTCubeLoader.js +0 -132
  526. package/examples/js/loaders/LWOLoader.js +0 -901
  527. package/examples/js/loaders/LogLuvLoader.js +0 -715
  528. package/examples/js/loaders/LottieLoader.js +0 -62
  529. package/examples/js/loaders/MD2Loader.js +0 -248
  530. package/examples/js/loaders/MDDLoader.js +0 -91
  531. package/examples/js/loaders/MMDLoader.js +0 -1915
  532. package/examples/js/loaders/MTLLoader.js +0 -472
  533. package/examples/js/loaders/NRRDLoader.js +0 -609
  534. package/examples/js/loaders/OBJLoader.js +0 -789
  535. package/examples/js/loaders/PCDLoader.js +0 -413
  536. package/examples/js/loaders/PDBLoader.js +0 -317
  537. package/examples/js/loaders/PLYLoader.js +0 -576
  538. package/examples/js/loaders/PRWMLoader.js +0 -249
  539. package/examples/js/loaders/PVRLoader.js +0 -218
  540. package/examples/js/loaders/RGBELoader.js +0 -442
  541. package/examples/js/loaders/RGBMLoader.js +0 -1354
  542. package/examples/js/loaders/STLLoader.js +0 -364
  543. package/examples/js/loaders/SVGLoader.js +0 -2783
  544. package/examples/js/loaders/TDSLoader.js +0 -992
  545. package/examples/js/loaders/TGALoader.js +0 -484
  546. package/examples/js/loaders/TIFFLoader.js +0 -30
  547. package/examples/js/loaders/TTFLoader.js +0 -203
  548. package/examples/js/loaders/TiltLoader.js +0 -459
  549. package/examples/js/loaders/VOXLoader.js +0 -240
  550. package/examples/js/loaders/VRMLLoader.js +0 -3140
  551. package/examples/js/loaders/VTKLoader.js +0 -1078
  552. package/examples/js/loaders/XYZLoader.js +0 -89
  553. package/examples/js/loaders/lwo/IFFParser.js +0 -1067
  554. package/examples/js/loaders/lwo/LWO2Parser.js +0 -397
  555. package/examples/js/loaders/lwo/LWO3Parser.js +0 -360
  556. package/examples/js/materials/MeshGouraudMaterial.js +0 -387
  557. package/examples/js/math/Capsule.js +0 -103
  558. package/examples/js/math/ColorConverter.js +0 -33
  559. package/examples/js/math/ConvexHull.js +0 -1154
  560. package/examples/js/math/ImprovedNoise.js +0 -66
  561. package/examples/js/math/Lut.js +0 -164
  562. package/examples/js/math/MeshSurfaceSampler.js +0 -171
  563. package/examples/js/math/OBB.js +0 -382
  564. package/examples/js/math/Octree.js +0 -410
  565. package/examples/js/math/SimplexNoise.js +0 -445
  566. package/examples/js/misc/ConvexObjectBreaker.js +0 -474
  567. package/examples/js/misc/GPUComputationRenderer.js +0 -393
  568. package/examples/js/misc/Gyroscope.js +0 -56
  569. package/examples/js/misc/MD2Character.js +0 -235
  570. package/examples/js/misc/MD2CharacterComplex.js +0 -513
  571. package/examples/js/misc/MorphAnimMesh.js +0 -63
  572. package/examples/js/misc/MorphBlendMesh.js +0 -265
  573. package/examples/js/misc/ProgressiveLightMap.js +0 -335
  574. package/examples/js/misc/RollerCoaster.js +0 -430
  575. package/examples/js/misc/TubePainter.js +0 -167
  576. package/examples/js/misc/Volume.js +0 -437
  577. package/examples/js/misc/VolumeSlice.js +0 -214
  578. package/examples/js/modifiers/CurveModifier.js +0 -309
  579. package/examples/js/modifiers/EdgeSplitModifier.js +0 -228
  580. package/examples/js/modifiers/SimplifyModifier.js +0 -465
  581. package/examples/js/modifiers/TessellateModifier.js +0 -276
  582. package/examples/js/objects/GroundProjectedEnv.js +0 -181
  583. package/examples/js/objects/Lensflare.js +0 -356
  584. package/examples/js/objects/LightningStorm.js +0 -206
  585. package/examples/js/objects/MarchingCubes.js +0 -759
  586. package/examples/js/objects/Reflector.js +0 -216
  587. package/examples/js/objects/ReflectorForSSRPass.js +0 -315
  588. package/examples/js/objects/Refractor.js +0 -283
  589. package/examples/js/objects/ShadowMesh.js +0 -59
  590. package/examples/js/objects/Sky.js +0 -218
  591. package/examples/js/objects/Water.js +0 -292
  592. package/examples/js/objects/Water2.js +0 -307
  593. package/examples/js/physics/AmmoPhysics.js +0 -259
  594. package/examples/js/physics/OimoPhysics.js +0 -217
  595. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +0 -335
  596. package/examples/js/postprocessing/AfterimagePass.js +0 -77
  597. package/examples/js/postprocessing/BloomPass.js +0 -135
  598. package/examples/js/postprocessing/BokehPass.js +0 -120
  599. package/examples/js/postprocessing/ClearPass.js +0 -39
  600. package/examples/js/postprocessing/CubeTexturePass.js +0 -60
  601. package/examples/js/postprocessing/DotScreenPass.js +0 -51
  602. package/examples/js/postprocessing/EffectComposer.js +0 -272
  603. package/examples/js/postprocessing/FilmPass.js +0 -52
  604. package/examples/js/postprocessing/GlitchPass.js +0 -104
  605. package/examples/js/postprocessing/HalftonePass.js +0 -75
  606. package/examples/js/postprocessing/LUTPass.js +0 -171
  607. package/examples/js/postprocessing/MaskPass.js +0 -95
  608. package/examples/js/postprocessing/OutlinePass.js +0 -598
  609. package/examples/js/postprocessing/Pass.js +0 -72
  610. package/examples/js/postprocessing/RenderPass.js +0 -70
  611. package/examples/js/postprocessing/RenderPixelatedPass.js +0 -215
  612. package/examples/js/postprocessing/SAOPass.js +0 -374
  613. package/examples/js/postprocessing/SMAAPass.js +0 -170
  614. package/examples/js/postprocessing/SSAARenderPass.js +0 -156
  615. package/examples/js/postprocessing/SSAOPass.js +0 -365
  616. package/examples/js/postprocessing/SSRPass.js +0 -567
  617. package/examples/js/postprocessing/SavePass.js +0 -59
  618. package/examples/js/postprocessing/ShaderPass.js +0 -64
  619. package/examples/js/postprocessing/TAARenderPass.js +0 -130
  620. package/examples/js/postprocessing/TexturePass.js +0 -49
  621. package/examples/js/postprocessing/UnrealBloomPass.js +0 -375
  622. package/examples/js/renderers/CSS2DRenderer.js +0 -178
  623. package/examples/js/renderers/CSS3DRenderer.js +0 -237
  624. package/examples/js/renderers/Projector.js +0 -818
  625. package/examples/js/renderers/SVGRenderer.js +0 -491
  626. package/examples/js/shaders/ACESFilmicToneMappingShader.js +0 -89
  627. package/examples/js/shaders/AfterimageShader.js +0 -60
  628. package/examples/js/shaders/BasicShader.js +0 -27
  629. package/examples/js/shaders/BleachBypassShader.js +0 -62
  630. package/examples/js/shaders/BlendShader.js +0 -54
  631. package/examples/js/shaders/BokehShader.js +0 -156
  632. package/examples/js/shaders/BokehShader2.js +0 -419
  633. package/examples/js/shaders/BrightnessContrastShader.js +0 -58
  634. package/examples/js/shaders/ColorCorrectionShader.js +0 -52
  635. package/examples/js/shaders/ColorifyShader.js +0 -47
  636. package/examples/js/shaders/ConvolutionShader.js +0 -92
  637. package/examples/js/shaders/CopyShader.js +0 -45
  638. package/examples/js/shaders/DOFMipMapShader.js +0 -60
  639. package/examples/js/shaders/DepthLimitedBlurShader.js +0 -173
  640. package/examples/js/shaders/DigitalGlitch.js +0 -127
  641. package/examples/js/shaders/DotScreenShader.js +0 -72
  642. package/examples/js/shaders/FXAAShader.js +0 -284
  643. package/examples/js/shaders/FilmShader.js +0 -110
  644. package/examples/js/shaders/FocusShader.js +0 -95
  645. package/examples/js/shaders/FreiChenShader.js +0 -93
  646. package/examples/js/shaders/GammaCorrectionShader.js +0 -41
  647. package/examples/js/shaders/GodRaysShader.js +0 -284
  648. package/examples/js/shaders/HalftoneShader.js +0 -336
  649. package/examples/js/shaders/HorizontalBlurShader.js +0 -59
  650. package/examples/js/shaders/HorizontalTiltShiftShader.js +0 -65
  651. package/examples/js/shaders/HueSaturationShader.js +0 -69
  652. package/examples/js/shaders/KaleidoShader.js +0 -60
  653. package/examples/js/shaders/LuminosityHighPassShader.js +0 -67
  654. package/examples/js/shaders/LuminosityShader.js +0 -46
  655. package/examples/js/shaders/MMDToonShader.js +0 -94
  656. package/examples/js/shaders/MirrorShader.js +0 -56
  657. package/examples/js/shaders/NormalMapShader.js +0 -55
  658. package/examples/js/shaders/RGBShiftShader.js +0 -56
  659. package/examples/js/shaders/SAOShader.js +0 -209
  660. package/examples/js/shaders/SMAAShader.js +0 -454
  661. package/examples/js/shaders/SSAOShader.js +0 -295
  662. package/examples/js/shaders/SSRShader.js +0 -381
  663. package/examples/js/shaders/SepiaShader.js +0 -52
  664. package/examples/js/shaders/SobelOperatorShader.js +0 -88
  665. package/examples/js/shaders/SubsurfaceScatteringShader.js +0 -49
  666. package/examples/js/shaders/TechnicolorShader.js +0 -43
  667. package/examples/js/shaders/ToneMapShader.js +0 -84
  668. package/examples/js/shaders/ToonShader.js +0 -335
  669. package/examples/js/shaders/TriangleBlurShader.js +0 -70
  670. package/examples/js/shaders/UnpackDepthRGBAShader.js +0 -47
  671. package/examples/js/shaders/VelocityShader.js +0 -126
  672. package/examples/js/shaders/VerticalBlurShader.js +0 -59
  673. package/examples/js/shaders/VerticalTiltShiftShader.js +0 -65
  674. package/examples/js/shaders/VignetteShader.js +0 -53
  675. package/examples/js/shaders/VolumeShader.js +0 -296
  676. package/examples/js/shaders/WaterRefractionShader.js +0 -84
  677. package/examples/js/textures/FlakesTexture.js +0 -40
  678. package/examples/js/utils/BufferGeometryUtils.js +0 -1160
  679. package/examples/js/utils/CameraUtils.js +0 -71
  680. package/examples/js/utils/GPUStatsPanel.js +0 -125
  681. package/examples/js/utils/GeometryCompressionUtils.js +0 -549
  682. package/examples/js/utils/GeometryUtils.js +0 -168
  683. package/examples/js/utils/LDrawUtils.js +0 -179
  684. package/examples/js/utils/PackedPhongMaterial.js +0 -109
  685. package/examples/js/utils/SceneUtils.js +0 -214
  686. package/examples/js/utils/ShadowMapViewer.js +0 -183
  687. package/examples/js/utils/SkeletonUtils.js +0 -493
  688. package/examples/js/utils/UVsDebug.js +0 -143
  689. package/examples/js/utils/WorkerPool.js +0 -105
  690. package/examples/jsm/libs/OimoPhysics/OimoPhysics.js +0 -37071
  691. package/examples/jsm/libs/OimoPhysics/index.js +0 -43
  692. package/examples/jsm/libs/flow.module.js +0 -4552
  693. package/examples/jsm/libs/tween.module.min.js +0 -3
  694. package/examples/jsm/loaders/BasisTextureLoader.js +0 -790
  695. package/examples/jsm/loaders/IFCLoader.js +0 -2431
  696. package/examples/jsm/loaders/ifc/web-ifc-api.js +0 -47504
  697. package/examples/jsm/loaders/ifc/web-ifc.wasm +0 -0
  698. package/examples/jsm/node-editor/NodeEditor.js +0 -857
  699. package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +0 -14
  700. package/examples/jsm/node-editor/accessors/NormalEditor.js +0 -30
  701. package/examples/jsm/node-editor/accessors/PositionEditor.js +0 -30
  702. package/examples/jsm/node-editor/accessors/UVEditor.js +0 -25
  703. package/examples/jsm/node-editor/core/BaseNode.js +0 -96
  704. package/examples/jsm/node-editor/core/DataFile.js +0 -59
  705. package/examples/jsm/node-editor/core/FileEditor.js +0 -20
  706. package/examples/jsm/node-editor/core/FileURLEditor.js +0 -29
  707. package/examples/jsm/node-editor/display/BlendEditor.js +0 -44
  708. package/examples/jsm/node-editor/display/NormalMapEditor.js +0 -49
  709. package/examples/jsm/node-editor/examples/animate-uv.json +0 -1
  710. package/examples/jsm/node-editor/examples/fake-top-light.json +0 -1
  711. package/examples/jsm/node-editor/examples/matcap.json +0 -1
  712. package/examples/jsm/node-editor/examples/oscillator-color.json +0 -1
  713. package/examples/jsm/node-editor/examples/rim.json +0 -1
  714. package/examples/jsm/node-editor/inputs/ColorEditor.js +0 -96
  715. package/examples/jsm/node-editor/inputs/FloatEditor.js +0 -23
  716. package/examples/jsm/node-editor/inputs/SliderEditor.js +0 -67
  717. package/examples/jsm/node-editor/inputs/TextureEditor.js +0 -155
  718. package/examples/jsm/node-editor/inputs/Vector2Editor.js +0 -28
  719. package/examples/jsm/node-editor/inputs/Vector3Editor.js +0 -30
  720. package/examples/jsm/node-editor/inputs/Vector4Editor.js +0 -37
  721. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +0 -84
  722. package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +0 -102
  723. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +0 -118
  724. package/examples/jsm/node-editor/math/AngleEditor.js +0 -40
  725. package/examples/jsm/node-editor/math/DotEditor.js +0 -35
  726. package/examples/jsm/node-editor/math/InvertEditor.js +0 -39
  727. package/examples/jsm/node-editor/math/LimiterEditor.js +0 -62
  728. package/examples/jsm/node-editor/math/NormalizeEditor.js +0 -28
  729. package/examples/jsm/node-editor/math/OperatorEditor.js +0 -63
  730. package/examples/jsm/node-editor/math/PowerEditor.js +0 -44
  731. package/examples/jsm/node-editor/math/TrigonometryEditor.js +0 -45
  732. package/examples/jsm/node-editor/procedural/CheckerEditor.js +0 -27
  733. package/examples/jsm/node-editor/scene/MeshEditor.js +0 -102
  734. package/examples/jsm/node-editor/scene/Object3DEditor.js +0 -160
  735. package/examples/jsm/node-editor/scene/PointsEditor.js +0 -99
  736. package/examples/jsm/node-editor/utils/JoinEditor.js +0 -58
  737. package/examples/jsm/node-editor/utils/OscillatorEditor.js +0 -43
  738. package/examples/jsm/node-editor/utils/PreviewEditor.js +0 -170
  739. package/examples/jsm/node-editor/utils/SplitEditor.js +0 -39
  740. package/examples/jsm/node-editor/utils/TimerEditor.js +0 -58
  741. package/examples/jsm/nodes/core/ExpressionNode.js +0 -32
  742. package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +0 -22
  743. package/examples/jsm/nodes/lighting/PunctualLightNode.js +0 -68
  744. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +0 -301
  745. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +0 -149
  746. package/examples/jsm/objects/GroundProjectedEnv.js +0 -186
  747. package/examples/jsm/renderers/webgpu/WebGPUObjects.js +0 -36
  748. package/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js +0 -7
  749. package/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js +0 -10
  750. package/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js +0 -7
  751. /package/examples/{js → jsm}/libs/ammo.wasm.js +0 -0
  752. /package/examples/{js → jsm}/libs/ammo.wasm.wasm +0 -0
  753. /package/examples/{js → jsm}/libs/basis/basis_transcoder.js +0 -0
  754. /package/examples/{js → jsm}/libs/basis/basis_transcoder.wasm +0 -0
  755. /package/examples/{js → jsm}/libs/draco/README.md +0 -0
  756. /package/examples/{js → jsm}/libs/draco/draco_encoder.js +0 -0
  757. /package/examples/{js → jsm}/libs/draco/gltf/draco_encoder.js +0 -0
@@ -1,20 +1,21 @@
1
1
  import {
2
2
  REVISION,
3
3
  BackSide,
4
- DoubleSide,
5
4
  FrontSide,
5
+ DoubleSide,
6
6
  RGBAFormat,
7
7
  HalfFloatType,
8
8
  FloatType,
9
9
  UnsignedByteType,
10
- LinearEncoding,
11
10
  NoToneMapping,
12
- LinearMipmapLinearFilter
11
+ LinearMipmapLinearFilter,
12
+ SRGBColorSpace,
13
+ LinearSRGBColorSpace,
14
+ sRGBEncoding,
15
+ LinearEncoding
13
16
  } from '../constants.js';
14
- import { floorPowerOfTwo } from '../math/MathUtils.js';
15
17
  import { Frustum } from '../math/Frustum.js';
16
18
  import { Matrix4 } from '../math/Matrix4.js';
17
- import { Vector2 } from '../math/Vector2.js';
18
19
  import { Vector3 } from '../math/Vector3.js';
19
20
  import { Vector4 } from '../math/Vector4.js';
20
21
  import { WebGLAnimation } from './webgl/WebGLAnimation.js';
@@ -56,1138 +57,1154 @@ function createCanvasElement() {
56
57
 
57
58
  }
58
59
 
59
- function WebGLRenderer( parameters = {} ) {
60
+ class WebGLRenderer {
60
61
 
61
- this.isWebGLRenderer = true;
62
+ constructor( parameters = {} ) {
62
63
 
63
- const _canvas = parameters.canvas !== undefined ? parameters.canvas : createCanvasElement(),
64
- _context = parameters.context !== undefined ? parameters.context : null,
64
+ const {
65
+ canvas = createCanvasElement(),
66
+ context = null,
67
+ depth = true,
68
+ stencil = true,
69
+ alpha = false,
70
+ antialias = false,
71
+ premultipliedAlpha = true,
72
+ preserveDrawingBuffer = false,
73
+ powerPreference = 'default',
74
+ failIfMajorPerformanceCaveat = false,
75
+ } = parameters;
65
76
 
66
- _depth = parameters.depth !== undefined ? parameters.depth : true,
67
- _stencil = parameters.stencil !== undefined ? parameters.stencil : true,
68
- _antialias = parameters.antialias !== undefined ? parameters.antialias : false,
69
- _premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,
70
- _preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false,
71
- _powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default',
72
- _failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false;
77
+ this.isWebGLRenderer = true;
73
78
 
74
- let _alpha;
79
+ let _alpha;
75
80
 
76
- if ( _context !== null ) {
81
+ if ( context !== null ) {
77
82
 
78
- _alpha = _context.getContextAttributes().alpha;
83
+ _alpha = context.getContextAttributes().alpha;
79
84
 
80
- } else {
85
+ } else {
81
86
 
82
- _alpha = parameters.alpha !== undefined ? parameters.alpha : false;
87
+ _alpha = alpha;
83
88
 
84
- }
89
+ }
85
90
 
86
- let currentRenderList = null;
87
- let currentRenderState = null;
91
+ let currentRenderList = null;
92
+ let currentRenderState = null;
88
93
 
89
- // render() can be called from within a callback triggered by another render.
90
- // We track this so that the nested render call gets its list and state isolated from the parent render call.
94
+ // render() can be called from within a callback triggered by another render.
95
+ // We track this so that the nested render call gets its list and state isolated from the parent render call.
91
96
 
92
- const renderListStack = [];
93
- const renderStateStack = [];
97
+ const renderListStack = [];
98
+ const renderStateStack = [];
94
99
 
95
- // public properties
100
+ // public properties
96
101
 
97
- this.domElement = _canvas;
102
+ this.domElement = canvas;
98
103
 
99
- // Debug configuration container
100
- this.debug = {
104
+ // Debug configuration container
105
+ this.debug = {
101
106
 
102
- /**
103
- * Enables error checking and reporting when shader programs are being compiled
104
- * @type {boolean}
105
- */
106
- checkShaderErrors: true
107
- };
107
+ /**
108
+ * Enables error checking and reporting when shader programs are being compiled
109
+ * @type {boolean}
110
+ */
111
+ checkShaderErrors: true,
112
+ /**
113
+ * Callback for custom error reporting.
114
+ * @type {?Function}
115
+ */
116
+ onShaderError: null
117
+ };
108
118
 
109
- // clearing
119
+ // clearing
110
120
 
111
- this.autoClear = true;
112
- this.autoClearColor = true;
113
- this.autoClearDepth = true;
114
- this.autoClearStencil = true;
121
+ this.autoClear = true;
122
+ this.autoClearColor = true;
123
+ this.autoClearDepth = true;
124
+ this.autoClearStencil = true;
115
125
 
116
- // scene graph
126
+ // scene graph
117
127
 
118
- this.sortObjects = true;
128
+ this.sortObjects = true;
119
129
 
120
- // user-defined clipping
130
+ // user-defined clipping
121
131
 
122
- this.clippingPlanes = [];
123
- this.localClippingEnabled = false;
132
+ this.clippingPlanes = [];
133
+ this.localClippingEnabled = false;
124
134
 
125
- // physically based shading
135
+ // physically based shading
126
136
 
127
- this.outputEncoding = LinearEncoding;
137
+ this.outputColorSpace = SRGBColorSpace;
128
138
 
129
- // physical lights
139
+ // physical lights
130
140
 
131
- this.physicallyCorrectLights = false;
141
+ this.useLegacyLights = true;
132
142
 
133
- // tone mapping
143
+ // tone mapping
134
144
 
135
- this.toneMapping = NoToneMapping;
136
- this.toneMappingExposure = 1.0;
145
+ this.toneMapping = NoToneMapping;
146
+ this.toneMappingExposure = 1.0;
137
147
 
138
- // internal properties
148
+ // internal properties
139
149
 
140
- const _this = this;
150
+ const _this = this;
141
151
 
142
- let _isContextLost = false;
152
+ let _isContextLost = false;
143
153
 
144
- // internal state cache
154
+ // internal state cache
145
155
 
146
- let _currentActiveCubeFace = 0;
147
- let _currentActiveMipmapLevel = 0;
148
- let _currentRenderTarget = null;
149
- let _currentMaterialId = - 1;
156
+ let _currentActiveCubeFace = 0;
157
+ let _currentActiveMipmapLevel = 0;
158
+ let _currentRenderTarget = null;
159
+ let _currentMaterialId = - 1;
150
160
 
151
- let _currentCamera = null;
161
+ let _currentCamera = null;
152
162
 
153
- const _currentViewport = new Vector4();
154
- const _currentScissor = new Vector4();
155
- let _currentScissorTest = null;
163
+ const _currentViewport = new Vector4();
164
+ const _currentScissor = new Vector4();
165
+ let _currentScissorTest = null;
156
166
 
157
- //
167
+ //
158
168
 
159
- let _width = _canvas.width;
160
- let _height = _canvas.height;
169
+ let _width = canvas.width;
170
+ let _height = canvas.height;
161
171
 
162
- let _pixelRatio = 1;
163
- let _opaqueSort = null;
164
- let _transparentSort = null;
172
+ let _pixelRatio = 1;
173
+ let _opaqueSort = null;
174
+ let _transparentSort = null;
165
175
 
166
- const _viewport = new Vector4( 0, 0, _width, _height );
167
- const _scissor = new Vector4( 0, 0, _width, _height );
168
- let _scissorTest = false;
176
+ const _viewport = new Vector4( 0, 0, _width, _height );
177
+ const _scissor = new Vector4( 0, 0, _width, _height );
178
+ let _scissorTest = false;
169
179
 
170
- // frustum
180
+ // frustum
171
181
 
172
- const _frustum = new Frustum();
182
+ const _frustum = new Frustum();
173
183
 
174
- // clipping
184
+ // clipping
175
185
 
176
- let _clippingEnabled = false;
177
- let _localClippingEnabled = false;
186
+ let _clippingEnabled = false;
187
+ let _localClippingEnabled = false;
178
188
 
179
- // transmission
189
+ // transmission
180
190
 
181
- let _transmissionRenderTarget = null;
191
+ let _transmissionRenderTarget = null;
182
192
 
183
- // camera matrices cache
193
+ // camera matrices cache
184
194
 
185
- const _projScreenMatrix = new Matrix4();
195
+ const _projScreenMatrix = new Matrix4();
186
196
 
187
- const _vector2 = new Vector2();
188
- const _vector3 = new Vector3();
197
+ const _vector3 = new Vector3();
189
198
 
190
- const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
199
+ const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
191
200
 
192
- function getTargetPixelRatio() {
201
+ function getTargetPixelRatio() {
193
202
 
194
- return _currentRenderTarget === null ? _pixelRatio : 1;
203
+ return _currentRenderTarget === null ? _pixelRatio : 1;
195
204
 
196
- }
205
+ }
197
206
 
198
- // initialize
207
+ // initialize
199
208
 
200
- let _gl = _context;
209
+ let _gl = context;
201
210
 
202
- function getContext( contextNames, contextAttributes ) {
211
+ function getContext( contextNames, contextAttributes ) {
203
212
 
204
- for ( let i = 0; i < contextNames.length; i ++ ) {
213
+ for ( let i = 0; i < contextNames.length; i ++ ) {
205
214
 
206
- const contextName = contextNames[ i ];
207
- const context = _canvas.getContext( contextName, contextAttributes );
208
- if ( context !== null ) return context;
215
+ const contextName = contextNames[ i ];
216
+ const context = canvas.getContext( contextName, contextAttributes );
217
+ if ( context !== null ) return context;
209
218
 
210
- }
219
+ }
211
220
 
212
- return null;
221
+ return null;
213
222
 
214
- }
223
+ }
215
224
 
216
- try {
217
-
218
- const contextAttributes = {
219
- alpha: true,
220
- depth: _depth,
221
- stencil: _stencil,
222
- antialias: _antialias,
223
- premultipliedAlpha: _premultipliedAlpha,
224
- preserveDrawingBuffer: _preserveDrawingBuffer,
225
- powerPreference: _powerPreference,
226
- failIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat
227
- };
225
+ try {
226
+
227
+ const contextAttributes = {
228
+ alpha: true,
229
+ depth,
230
+ stencil,
231
+ antialias,
232
+ premultipliedAlpha,
233
+ preserveDrawingBuffer,
234
+ powerPreference,
235
+ failIfMajorPerformanceCaveat,
236
+ };
228
237
 
229
- // OffscreenCanvas does not have setAttribute, see #22811
230
- if ( 'setAttribute' in _canvas ) _canvas.setAttribute( 'data-engine', `three.js r${REVISION}` );
238
+ // OffscreenCanvas does not have setAttribute, see #22811
239
+ if ( 'setAttribute' in canvas ) canvas.setAttribute( 'data-engine', `three.js r${REVISION}` );
231
240
 
232
- // event listeners must be registered before WebGL context is created, see #12753
233
- _canvas.addEventListener( 'webglcontextlost', onContextLost, false );
234
- _canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );
235
- _canvas.addEventListener( 'webglcontextcreationerror', onContextCreationError, false );
241
+ // event listeners must be registered before WebGL context is created, see #12753
242
+ canvas.addEventListener( 'webglcontextlost', onContextLost, false );
243
+ canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );
244
+ canvas.addEventListener( 'webglcontextcreationerror', onContextCreationError, false );
236
245
 
237
- if ( _gl === null ) {
246
+ if ( _gl === null ) {
238
247
 
239
- const contextNames = [ 'webgl2', 'webgl', 'experimental-webgl' ];
248
+ const contextNames = [ 'webgl2', 'webgl', 'experimental-webgl' ];
240
249
 
241
- if ( _this.isWebGL1Renderer === true ) {
250
+ if ( _this.isWebGL1Renderer === true ) {
242
251
 
243
- contextNames.shift();
252
+ contextNames.shift();
244
253
 
245
- }
254
+ }
246
255
 
247
- _gl = getContext( contextNames, contextAttributes );
256
+ _gl = getContext( contextNames, contextAttributes );
248
257
 
249
- if ( _gl === null ) {
258
+ if ( _gl === null ) {
250
259
 
251
- if ( getContext( contextNames ) ) {
260
+ if ( getContext( contextNames ) ) {
252
261
 
253
- throw new Error( 'Error creating WebGL context with your selected attributes.' );
262
+ throw new Error( 'Error creating WebGL context with your selected attributes.' );
254
263
 
255
- } else {
264
+ } else {
256
265
 
257
- throw new Error( 'Error creating WebGL context.' );
266
+ throw new Error( 'Error creating WebGL context.' );
267
+
268
+ }
258
269
 
259
270
  }
260
271
 
261
272
  }
262
273
 
263
- }
274
+ // Some experimental-webgl implementations do not have getShaderPrecisionFormat
264
275
 
265
- // Some experimental-webgl implementations do not have getShaderPrecisionFormat
276
+ if ( _gl.getShaderPrecisionFormat === undefined ) {
266
277
 
267
- if ( _gl.getShaderPrecisionFormat === undefined ) {
278
+ _gl.getShaderPrecisionFormat = function () {
268
279
 
269
- _gl.getShaderPrecisionFormat = function () {
280
+ return { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };
270
281
 
271
- return { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };
282
+ };
272
283
 
273
- };
284
+ }
274
285
 
275
- }
286
+ } catch ( error ) {
276
287
 
277
- } catch ( error ) {
288
+ console.error( 'THREE.WebGLRenderer: ' + error.message );
289
+ throw error;
278
290
 
279
- console.error( 'THREE.WebGLRenderer: ' + error.message );
280
- throw error;
291
+ }
281
292
 
282
- }
293
+ let extensions, capabilities, state, info;
294
+ let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
295
+ let programCache, materials, renderLists, renderStates, clipping, shadowMap;
283
296
 
284
- let extensions, capabilities, state, info;
285
- let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
286
- let programCache, materials, renderLists, renderStates, clipping, shadowMap;
297
+ let background, morphtargets, bufferRenderer, indexedBufferRenderer;
287
298
 
288
- let background, morphtargets, bufferRenderer, indexedBufferRenderer;
299
+ let utils, bindingStates, uniformsGroups;
289
300
 
290
- let utils, bindingStates, uniformsGroups;
301
+ function initGLContext() {
291
302
 
292
- function initGLContext() {
303
+ extensions = new WebGLExtensions( _gl );
293
304
 
294
- extensions = new WebGLExtensions( _gl );
305
+ capabilities = new WebGLCapabilities( _gl, extensions, parameters );
295
306
 
296
- capabilities = new WebGLCapabilities( _gl, extensions, parameters );
307
+ extensions.init( capabilities );
297
308
 
298
- extensions.init( capabilities );
309
+ utils = new WebGLUtils( _gl, extensions, capabilities );
299
310
 
300
- utils = new WebGLUtils( _gl, extensions, capabilities );
311
+ state = new WebGLState( _gl, extensions, capabilities );
301
312
 
302
- state = new WebGLState( _gl, extensions, capabilities );
313
+ info = new WebGLInfo( _gl );
314
+ properties = new WebGLProperties();
315
+ textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
316
+ cubemaps = new WebGLCubeMaps( _this );
317
+ cubeuvmaps = new WebGLCubeUVMaps( _this );
318
+ attributes = new WebGLAttributes( _gl, capabilities );
319
+ bindingStates = new WebGLBindingStates( _gl, extensions, attributes, capabilities );
320
+ geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
321
+ objects = new WebGLObjects( _gl, geometries, attributes, info );
322
+ morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
323
+ clipping = new WebGLClipping( properties );
324
+ programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
325
+ materials = new WebGLMaterials( _this, properties );
326
+ renderLists = new WebGLRenderLists();
327
+ renderStates = new WebGLRenderStates( extensions, capabilities );
328
+ background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
329
+ shadowMap = new WebGLShadowMap( _this, objects, capabilities );
330
+ uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
303
331
 
304
- info = new WebGLInfo( _gl );
305
- properties = new WebGLProperties();
306
- textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
307
- cubemaps = new WebGLCubeMaps( _this );
308
- cubeuvmaps = new WebGLCubeUVMaps( _this );
309
- attributes = new WebGLAttributes( _gl, capabilities );
310
- bindingStates = new WebGLBindingStates( _gl, extensions, attributes, capabilities );
311
- geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
312
- objects = new WebGLObjects( _gl, geometries, attributes, info );
313
- morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
314
- clipping = new WebGLClipping( properties );
315
- programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
316
- materials = new WebGLMaterials( _this, properties );
317
- renderLists = new WebGLRenderLists();
318
- renderStates = new WebGLRenderStates( extensions, capabilities );
319
- background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, _premultipliedAlpha );
320
- shadowMap = new WebGLShadowMap( _this, objects, capabilities );
321
- uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
332
+ bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );
333
+ indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities );
322
334
 
323
- bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );
324
- indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities );
335
+ info.programs = programCache.programs;
325
336
 
326
- info.programs = programCache.programs;
337
+ _this.capabilities = capabilities;
338
+ _this.extensions = extensions;
339
+ _this.properties = properties;
340
+ _this.renderLists = renderLists;
341
+ _this.shadowMap = shadowMap;
342
+ _this.state = state;
343
+ _this.info = info;
327
344
 
328
- _this.capabilities = capabilities;
329
- _this.extensions = extensions;
330
- _this.properties = properties;
331
- _this.renderLists = renderLists;
332
- _this.shadowMap = shadowMap;
333
- _this.state = state;
334
- _this.info = info;
345
+ }
335
346
 
336
- }
347
+ initGLContext();
337
348
 
338
- initGLContext();
349
+ // xr
339
350
 
340
- const xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl ) : new WebVRManager( _this );
351
+ const xr = ( typeof navigator !== 'undefined' && 'xr' in navigator ) ? new WebXRManager( _this, _gl ) : new WebVRManager( _this );
341
352
 
342
- this.xr = xr;
353
+ this.xr = xr;
343
354
 
344
- // API
355
+ // API
345
356
 
346
- this.getContext = function () {
357
+ this.getContext = function () {
347
358
 
348
- return _gl;
359
+ return _gl;
349
360
 
350
- };
361
+ };
351
362
 
352
- this.getContextAttributes = function () {
363
+ this.getContextAttributes = function () {
353
364
 
354
- return _gl.getContextAttributes();
365
+ return _gl.getContextAttributes();
355
366
 
356
- };
367
+ };
357
368
 
358
- this.forceContextLoss = function () {
369
+ this.forceContextLoss = function () {
359
370
 
360
- const extension = extensions.get( 'WEBGL_lose_context' );
361
- if ( extension ) extension.loseContext();
371
+ const extension = extensions.get( 'WEBGL_lose_context' );
372
+ if ( extension ) extension.loseContext();
362
373
 
363
- };
374
+ };
364
375
 
365
- this.forceContextRestore = function () {
376
+ this.forceContextRestore = function () {
366
377
 
367
- const extension = extensions.get( 'WEBGL_lose_context' );
368
- if ( extension ) extension.restoreContext();
378
+ const extension = extensions.get( 'WEBGL_lose_context' );
379
+ if ( extension ) extension.restoreContext();
369
380
 
370
- };
381
+ };
371
382
 
372
- this.getPixelRatio = function () {
383
+ this.getPixelRatio = function () {
373
384
 
374
- return _pixelRatio;
385
+ return _pixelRatio;
375
386
 
376
- };
387
+ };
377
388
 
378
- this.setPixelRatio = function ( value ) {
389
+ this.setPixelRatio = function ( value ) {
379
390
 
380
- if ( value === undefined ) return;
391
+ if ( value === undefined ) return;
381
392
 
382
- _pixelRatio = value;
393
+ _pixelRatio = value;
383
394
 
384
- this.setSize( _width, _height, false );
395
+ this.setSize( _width, _height, false );
385
396
 
386
- };
397
+ };
387
398
 
388
- this.getSize = function ( target ) {
399
+ this.getSize = function ( target ) {
389
400
 
390
- return target.set( _width, _height );
401
+ return target.set( _width, _height );
391
402
 
392
- };
403
+ };
393
404
 
394
- this.setSize = function ( width, height, updateStyle ) {
405
+ this.setSize = function ( width, height, updateStyle = true ) {
395
406
 
396
- if ( xr.isPresenting ) {
407
+ if ( xr.isPresenting ) {
397
408
 
398
- console.warn( 'THREE.WebGLRenderer: Can\'t change size while VR device is presenting.' );
399
- return;
409
+ console.warn( 'THREE.WebGLRenderer: Can\'t change size while VR device is presenting.' );
410
+ return;
400
411
 
401
- }
412
+ }
402
413
 
403
- _width = width;
404
- _height = height;
414
+ _width = width;
415
+ _height = height;
405
416
 
406
- _canvas.width = Math.floor( width * _pixelRatio );
407
- _canvas.height = Math.floor( height * _pixelRatio );
417
+ canvas.width = Math.floor( width * _pixelRatio );
418
+ canvas.height = Math.floor( height * _pixelRatio );
408
419
 
409
- if ( updateStyle !== false ) {
420
+ if ( updateStyle === true ) {
410
421
 
411
- _canvas.style.width = width + 'px';
412
- _canvas.style.height = height + 'px';
422
+ canvas.style.width = width + 'px';
423
+ canvas.style.height = height + 'px';
413
424
 
414
- }
425
+ }
415
426
 
416
- this.setViewport( 0, 0, width, height );
427
+ this.setViewport( 0, 0, width, height );
417
428
 
418
- };
429
+ };
419
430
 
420
- this.getDrawingBufferSize = function ( target ) {
431
+ this.getDrawingBufferSize = function ( target ) {
421
432
 
422
- return target.set( _width * _pixelRatio, _height * _pixelRatio ).floor();
433
+ return target.set( _width * _pixelRatio, _height * _pixelRatio ).floor();
423
434
 
424
- };
435
+ };
425
436
 
426
- this.setDrawingBufferSize = function ( width, height, pixelRatio ) {
437
+ this.setDrawingBufferSize = function ( width, height, pixelRatio ) {
427
438
 
428
- _width = width;
429
- _height = height;
439
+ _width = width;
440
+ _height = height;
430
441
 
431
- _pixelRatio = pixelRatio;
442
+ _pixelRatio = pixelRatio;
432
443
 
433
- _canvas.width = Math.floor( width * pixelRatio );
434
- _canvas.height = Math.floor( height * pixelRatio );
444
+ canvas.width = Math.floor( width * pixelRatio );
445
+ canvas.height = Math.floor( height * pixelRatio );
435
446
 
436
- this.setViewport( 0, 0, width, height );
447
+ this.setViewport( 0, 0, width, height );
437
448
 
438
- };
449
+ };
439
450
 
440
- this.getCurrentViewport = function ( target ) {
451
+ this.getCurrentViewport = function ( target ) {
441
452
 
442
- return target.copy( _currentViewport );
453
+ return target.copy( _currentViewport );
443
454
 
444
- };
455
+ };
445
456
 
446
- this.getViewport = function ( target ) {
457
+ this.getViewport = function ( target ) {
447
458
 
448
- return target.copy( _viewport );
459
+ return target.copy( _viewport );
449
460
 
450
- };
461
+ };
451
462
 
452
- this.setViewport = function ( x, y, width, height ) {
463
+ this.setViewport = function ( x, y, width, height ) {
453
464
 
454
- if ( x.isVector4 ) {
465
+ if ( x.isVector4 ) {
455
466
 
456
- _viewport.set( x.x, x.y, x.z, x.w );
467
+ _viewport.set( x.x, x.y, x.z, x.w );
457
468
 
458
- } else {
469
+ } else {
459
470
 
460
- _viewport.set( x, y, width, height );
471
+ _viewport.set( x, y, width, height );
461
472
 
462
- }
473
+ }
474
+
475
+ state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );
463
476
 
464
- state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );
477
+ };
465
478
 
466
- };
479
+ this.getScissor = function ( target ) {
467
480
 
468
- this.getScissor = function ( target ) {
481
+ return target.copy( _scissor );
469
482
 
470
- return target.copy( _scissor );
483
+ };
471
484
 
472
- };
485
+ this.setScissor = function ( x, y, width, height ) {
473
486
 
474
- this.setScissor = function ( x, y, width, height ) {
487
+ if ( x.isVector4 ) {
475
488
 
476
- if ( x.isVector4 ) {
489
+ _scissor.set( x.x, x.y, x.z, x.w );
477
490
 
478
- _scissor.set( x.x, x.y, x.z, x.w );
491
+ } else {
479
492
 
480
- } else {
493
+ _scissor.set( x, y, width, height );
481
494
 
482
- _scissor.set( x, y, width, height );
495
+ }
483
496
 
484
- }
497
+ state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );
485
498
 
486
- state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );
499
+ };
487
500
 
488
- };
501
+ this.getScissorTest = function () {
489
502
 
490
- this.getScissorTest = function () {
503
+ return _scissorTest;
491
504
 
492
- return _scissorTest;
505
+ };
493
506
 
494
- };
507
+ this.setScissorTest = function ( boolean ) {
495
508
 
496
- this.setScissorTest = function ( boolean ) {
509
+ state.setScissorTest( _scissorTest = boolean );
497
510
 
498
- state.setScissorTest( _scissorTest = boolean );
511
+ };
499
512
 
500
- };
513
+ this.setOpaqueSort = function ( method ) {
501
514
 
502
- this.setOpaqueSort = function ( method ) {
515
+ _opaqueSort = method;
503
516
 
504
- _opaqueSort = method;
517
+ };
505
518
 
506
- };
519
+ this.setTransparentSort = function ( method ) {
507
520
 
508
- this.setTransparentSort = function ( method ) {
521
+ _transparentSort = method;
509
522
 
510
- _transparentSort = method;
523
+ };
511
524
 
512
- };
525
+ // Clearing
513
526
 
514
- // Clearing
527
+ this.getClearColor = function ( target ) {
515
528
 
516
- this.getClearColor = function ( target ) {
529
+ return target.copy( background.getClearColor() );
517
530
 
518
- return target.copy( background.getClearColor() );
531
+ };
519
532
 
520
- };
533
+ this.setClearColor = function () {
521
534
 
522
- this.setClearColor = function () {
535
+ background.setClearColor.apply( background, arguments );
523
536
 
524
- background.setClearColor.apply( background, arguments );
537
+ };
525
538
 
526
- };
539
+ this.getClearAlpha = function () {
527
540
 
528
- this.getClearAlpha = function () {
541
+ return background.getClearAlpha();
529
542
 
530
- return background.getClearAlpha();
543
+ };
531
544
 
532
- };
545
+ this.setClearAlpha = function () {
533
546
 
534
- this.setClearAlpha = function () {
547
+ background.setClearAlpha.apply( background, arguments );
535
548
 
536
- background.setClearAlpha.apply( background, arguments );
549
+ };
537
550
 
538
- };
551
+ this.clear = function ( color = true, depth = true, stencil = true ) {
539
552
 
540
- this.clear = function ( color = true, depth = true, stencil = true ) {
553
+ let bits = 0;
541
554
 
542
- let bits = 0;
555
+ if ( color ) bits |= _gl.COLOR_BUFFER_BIT;
556
+ if ( depth ) bits |= _gl.DEPTH_BUFFER_BIT;
557
+ if ( stencil ) bits |= _gl.STENCIL_BUFFER_BIT;
543
558
 
544
- if ( color ) bits |= _gl.COLOR_BUFFER_BIT;
545
- if ( depth ) bits |= _gl.DEPTH_BUFFER_BIT;
546
- if ( stencil ) bits |= _gl.STENCIL_BUFFER_BIT;
559
+ _gl.clear( bits );
547
560
 
548
- _gl.clear( bits );
561
+ };
549
562
 
550
- };
563
+ this.clearColor = function () {
551
564
 
552
- this.clearColor = function () {
565
+ this.clear( true, false, false );
553
566
 
554
- this.clear( true, false, false );
567
+ };
555
568
 
556
- };
569
+ this.clearDepth = function () {
557
570
 
558
- this.clearDepth = function () {
571
+ this.clear( false, true, false );
559
572
 
560
- this.clear( false, true, false );
573
+ };
561
574
 
562
- };
575
+ this.clearStencil = function () {
563
576
 
564
- this.clearStencil = function () {
577
+ this.clear( false, false, true );
565
578
 
566
- this.clear( false, false, true );
579
+ };
567
580
 
568
- };
581
+ //
569
582
 
570
- //
583
+ this.dispose = function () {
571
584
 
572
- this.dispose = function () {
585
+ canvas.removeEventListener( 'webglcontextlost', onContextLost, false );
586
+ canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );
587
+ canvas.removeEventListener( 'webglcontextcreationerror', onContextCreationError, false );
573
588
 
574
- _canvas.removeEventListener( 'webglcontextlost', onContextLost, false );
575
- _canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );
576
- _canvas.removeEventListener( 'webglcontextcreationerror', onContextCreationError, false );
589
+ renderLists.dispose();
590
+ renderStates.dispose();
591
+ properties.dispose();
592
+ cubemaps.dispose();
593
+ cubeuvmaps.dispose();
594
+ objects.dispose();
595
+ bindingStates.dispose();
596
+ uniformsGroups.dispose();
597
+ programCache.dispose();
577
598
 
578
- renderLists.dispose();
579
- renderStates.dispose();
580
- properties.dispose();
581
- cubemaps.dispose();
582
- cubeuvmaps.dispose();
583
- objects.dispose();
584
- bindingStates.dispose();
585
- uniformsGroups.dispose();
586
- programCache.dispose();
599
+ xr.dispose();
587
600
 
588
- xr.dispose();
601
+ xr.removeEventListener( 'sessionstart', onXRSessionStart );
602
+ xr.removeEventListener( 'sessionend', onXRSessionEnd );
589
603
 
590
- xr.removeEventListener( 'sessionstart', onXRSessionStart );
591
- xr.removeEventListener( 'sessionend', onXRSessionEnd );
604
+ if ( _transmissionRenderTarget ) {
592
605
 
593
- if ( _transmissionRenderTarget ) {
606
+ _transmissionRenderTarget.dispose();
607
+ _transmissionRenderTarget = null;
594
608
 
595
- _transmissionRenderTarget.dispose();
596
- _transmissionRenderTarget = null;
609
+ }
597
610
 
598
- }
611
+ animation.stop();
599
612
 
600
- animation.stop();
613
+ };
601
614
 
602
- };
615
+ // Events
603
616
 
604
- // Events
617
+ function onContextLost( event ) {
605
618
 
606
- function onContextLost( event ) {
619
+ event.preventDefault();
607
620
 
608
- event.preventDefault();
621
+ console.log( 'THREE.WebGLRenderer: Context Lost.' );
609
622
 
610
- console.log( 'THREE.WebGLRenderer: Context Lost.' );
623
+ _isContextLost = true;
611
624
 
612
- _isContextLost = true;
625
+ }
613
626
 
614
- }
627
+ function onContextRestore( /* event */ ) {
615
628
 
616
- function onContextRestore( /* event */ ) {
629
+ console.log( 'THREE.WebGLRenderer: Context Restored.' );
617
630
 
618
- console.log( 'THREE.WebGLRenderer: Context Restored.' );
631
+ _isContextLost = false;
619
632
 
620
- _isContextLost = false;
633
+ const infoAutoReset = info.autoReset;
634
+ const shadowMapEnabled = shadowMap.enabled;
635
+ const shadowMapAutoUpdate = shadowMap.autoUpdate;
636
+ const shadowMapNeedsUpdate = shadowMap.needsUpdate;
637
+ const shadowMapType = shadowMap.type;
621
638
 
622
- const infoAutoReset = info.autoReset;
623
- const shadowMapEnabled = shadowMap.enabled;
624
- const shadowMapAutoUpdate = shadowMap.autoUpdate;
625
- const shadowMapNeedsUpdate = shadowMap.needsUpdate;
626
- const shadowMapType = shadowMap.type;
639
+ initGLContext();
627
640
 
628
- initGLContext();
641
+ info.autoReset = infoAutoReset;
642
+ shadowMap.enabled = shadowMapEnabled;
643
+ shadowMap.autoUpdate = shadowMapAutoUpdate;
644
+ shadowMap.needsUpdate = shadowMapNeedsUpdate;
645
+ shadowMap.type = shadowMapType;
629
646
 
630
- info.autoReset = infoAutoReset;
631
- shadowMap.enabled = shadowMapEnabled;
632
- shadowMap.autoUpdate = shadowMapAutoUpdate;
633
- shadowMap.needsUpdate = shadowMapNeedsUpdate;
634
- shadowMap.type = shadowMapType;
647
+ }
635
648
 
636
- }
649
+ function onContextCreationError( event ) {
637
650
 
638
- function onContextCreationError( event ) {
651
+ console.error( 'THREE.WebGLRenderer: A WebGL context could not be created. Reason: ', event.statusMessage );
639
652
 
640
- console.error( 'THREE.WebGLRenderer: A WebGL context could not be created. Reason: ', event.statusMessage );
653
+ }
641
654
 
642
- }
655
+ function onMaterialDispose( event ) {
643
656
 
644
- function onMaterialDispose( event ) {
657
+ const material = event.target;
645
658
 
646
- const material = event.target;
659
+ material.removeEventListener( 'dispose', onMaterialDispose );
647
660
 
648
- material.removeEventListener( 'dispose', onMaterialDispose );
661
+ deallocateMaterial( material );
649
662
 
650
- deallocateMaterial( material );
663
+ }
651
664
 
652
- }
665
+ // Buffer deallocation
653
666
 
654
- // Buffer deallocation
667
+ function deallocateMaterial( material ) {
655
668
 
656
- function deallocateMaterial( material ) {
669
+ releaseMaterialProgramReferences( material );
657
670
 
658
- releaseMaterialProgramReferences( material );
671
+ properties.remove( material );
659
672
 
660
- properties.remove( material );
673
+ }
661
674
 
662
- }
663
675
 
676
+ function releaseMaterialProgramReferences( material ) {
664
677
 
665
- function releaseMaterialProgramReferences( material ) {
678
+ const programs = properties.get( material ).programs;
666
679
 
667
- const programs = properties.get( material ).programs;
680
+ if ( programs !== undefined ) {
668
681
 
669
- if ( programs !== undefined ) {
682
+ programs.forEach( function ( program ) {
670
683
 
671
- programs.forEach( function ( program ) {
684
+ programCache.releaseProgram( program );
672
685
 
673
- programCache.releaseProgram( program );
686
+ } );
674
687
 
675
- } );
688
+ if ( material.isShaderMaterial ) {
676
689
 
677
- if ( material.isShaderMaterial ) {
690
+ programCache.releaseShaderCache( material );
678
691
 
679
- programCache.releaseShaderCache( material );
692
+ }
680
693
 
681
694
  }
682
695
 
683
696
  }
684
697
 
685
- }
698
+ // Buffer rendering
686
699
 
687
- // Buffer rendering
700
+ this.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) {
688
701
 
689
- this.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) {
702
+ if ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)
690
703
 
691
- if ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)
704
+ const frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 );
692
705
 
693
- const frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 );
706
+ const program = setProgram( camera, scene, geometry, material, object );
694
707
 
695
- const program = setProgram( camera, scene, geometry, material, object );
708
+ state.setMaterial( material, frontFaceCW );
696
709
 
697
- state.setMaterial( material, frontFaceCW );
710
+ //
698
711
 
699
- //
712
+ let index = geometry.index;
713
+ let rangeFactor = 1;
700
714
 
701
- let index = geometry.index;
702
- let rangeFactor = 1;
715
+ if ( material.wireframe === true ) {
703
716
 
704
- if ( material.wireframe === true ) {
717
+ index = geometries.getWireframeAttribute( geometry );
718
+ rangeFactor = 2;
705
719
 
706
- index = geometries.getWireframeAttribute( geometry );
707
- rangeFactor = 2;
720
+ }
708
721
 
709
- }
722
+ //
710
723
 
711
- //
724
+ const drawRange = geometry.drawRange;
725
+ const position = geometry.attributes.position;
712
726
 
713
- const drawRange = geometry.drawRange;
714
- const position = geometry.attributes.position;
727
+ let drawStart = drawRange.start * rangeFactor;
728
+ let drawEnd = ( drawRange.start + drawRange.count ) * rangeFactor;
715
729
 
716
- let drawStart = drawRange.start * rangeFactor;
717
- let drawEnd = ( drawRange.start + drawRange.count ) * rangeFactor;
730
+ if ( group !== null ) {
718
731
 
719
- if ( group !== null ) {
732
+ drawStart = Math.max( drawStart, group.start * rangeFactor );
733
+ drawEnd = Math.min( drawEnd, ( group.start + group.count ) * rangeFactor );
720
734
 
721
- drawStart = Math.max( drawStart, group.start * rangeFactor );
722
- drawEnd = Math.min( drawEnd, ( group.start + group.count ) * rangeFactor );
735
+ }
723
736
 
724
- }
737
+ if ( index !== null ) {
725
738
 
726
- if ( index !== null ) {
739
+ drawStart = Math.max( drawStart, 0 );
740
+ drawEnd = Math.min( drawEnd, index.count );
727
741
 
728
- drawStart = Math.max( drawStart, 0 );
729
- drawEnd = Math.min( drawEnd, index.count );
742
+ } else if ( position !== undefined && position !== null ) {
730
743
 
731
- } else if ( position !== undefined && position !== null ) {
744
+ drawStart = Math.max( drawStart, 0 );
745
+ drawEnd = Math.min( drawEnd, position.count );
732
746
 
733
- drawStart = Math.max( drawStart, 0 );
734
- drawEnd = Math.min( drawEnd, position.count );
747
+ }
735
748
 
736
- }
749
+ const drawCount = drawEnd - drawStart;
737
750
 
738
- const drawCount = drawEnd - drawStart;
751
+ if ( drawCount < 0 || drawCount === Infinity ) return;
739
752
 
740
- if ( drawCount < 0 || drawCount === Infinity ) return;
753
+ //
741
754
 
742
- //
755
+ bindingStates.setup( object, material, program, geometry, index );
743
756
 
744
- bindingStates.setup( object, material, program, geometry, index );
757
+ let attribute;
758
+ let renderer = bufferRenderer;
745
759
 
746
- let attribute;
747
- let renderer = bufferRenderer;
760
+ if ( index !== null ) {
748
761
 
749
- if ( index !== null ) {
762
+ attribute = attributes.get( index );
750
763
 
751
- attribute = attributes.get( index );
764
+ renderer = indexedBufferRenderer;
765
+ renderer.setIndex( attribute );
752
766
 
753
- renderer = indexedBufferRenderer;
754
- renderer.setIndex( attribute );
767
+ }
755
768
 
756
- }
769
+ //
757
770
 
758
- //
771
+ if ( object.isMesh ) {
759
772
 
760
- if ( object.isMesh ) {
773
+ if ( material.wireframe === true ) {
761
774
 
762
- if ( material.wireframe === true ) {
775
+ state.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() );
776
+ renderer.setMode( _gl.LINES );
763
777
 
764
- state.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() );
765
- renderer.setMode( _gl.LINES );
778
+ } else {
766
779
 
767
- } else {
780
+ renderer.setMode( _gl.TRIANGLES );
768
781
 
769
- renderer.setMode( _gl.TRIANGLES );
782
+ }
770
783
 
771
- }
784
+ } else if ( object.isLine ) {
772
785
 
773
- } else if ( object.isLine ) {
786
+ let lineWidth = material.linewidth;
774
787
 
775
- let lineWidth = material.linewidth;
788
+ if ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material
776
789
 
777
- if ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material
790
+ state.setLineWidth( lineWidth * getTargetPixelRatio() );
778
791
 
779
- state.setLineWidth( lineWidth * getTargetPixelRatio() );
792
+ if ( object.isLineSegments ) {
780
793
 
781
- if ( object.isLineSegments ) {
794
+ renderer.setMode( _gl.LINES );
782
795
 
783
- renderer.setMode( _gl.LINES );
796
+ } else if ( object.isLineLoop ) {
784
797
 
785
- } else if ( object.isLineLoop ) {
798
+ renderer.setMode( _gl.LINE_LOOP );
786
799
 
787
- renderer.setMode( _gl.LINE_LOOP );
800
+ } else {
788
801
 
789
- } else {
802
+ renderer.setMode( _gl.LINE_STRIP );
790
803
 
791
- renderer.setMode( _gl.LINE_STRIP );
804
+ }
792
805
 
793
- }
806
+ } else if ( object.isPoints ) {
794
807
 
795
- } else if ( object.isPoints ) {
808
+ renderer.setMode( _gl.POINTS );
796
809
 
797
- renderer.setMode( _gl.POINTS );
810
+ } else if ( object.isSprite ) {
798
811
 
799
- } else if ( object.isSprite ) {
812
+ renderer.setMode( _gl.TRIANGLES );
800
813
 
801
- renderer.setMode( _gl.TRIANGLES );
814
+ }
802
815
 
803
- }
816
+ if ( object.isInstancedMesh ) {
804
817
 
805
- if ( object.isInstancedMesh ) {
818
+ renderer.renderInstances( drawStart, drawCount, object.count );
806
819
 
807
- renderer.renderInstances( drawStart, drawCount, object.count );
820
+ } else if ( geometry.isInstancedBufferGeometry ) {
808
821
 
809
- } else if ( geometry.isInstancedBufferGeometry ) {
822
+ const maxInstanceCount = geometry._maxInstanceCount !== undefined ? geometry._maxInstanceCount : Infinity;
823
+ const instanceCount = Math.min( geometry.instanceCount, maxInstanceCount );
810
824
 
811
- const maxInstanceCount = geometry._maxInstanceCount !== undefined ? geometry._maxInstanceCount : Infinity;
812
- const instanceCount = Math.min( geometry.instanceCount, maxInstanceCount );
825
+ renderer.renderInstances( drawStart, drawCount, instanceCount );
813
826
 
814
- renderer.renderInstances( drawStart, drawCount, instanceCount );
827
+ } else {
815
828
 
816
- } else {
829
+ renderer.render( drawStart, drawCount );
817
830
 
818
- renderer.render( drawStart, drawCount );
831
+ }
819
832
 
820
- }
833
+ };
821
834
 
822
- };
835
+ // Compile
823
836
 
824
- // Compile
837
+ this.compile = function ( scene, camera ) {
825
838
 
826
- this.compile = function ( scene, camera ) {
839
+ function prepare( material, scene, object ) {
827
840
 
828
- function prepare( material, scene, object ) {
841
+ if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
829
842
 
830
- if ( material.transparent === true && material.side === DoubleSide ) {
843
+ material.side = BackSide;
844
+ material.needsUpdate = true;
845
+ getProgram( material, scene, object );
831
846
 
832
- material.side = BackSide;
833
- material.needsUpdate = true;
834
- getProgram( material, scene, object );
847
+ material.side = FrontSide;
848
+ material.needsUpdate = true;
849
+ getProgram( material, scene, object );
835
850
 
836
- material.side = FrontSide;
837
- material.needsUpdate = true;
838
- getProgram( material, scene, object );
851
+ material.side = DoubleSide;
839
852
 
840
- material.side = DoubleSide;
853
+ } else {
841
854
 
842
- } else {
855
+ getProgram( material, scene, object );
843
856
 
844
- getProgram( material, scene, object );
857
+ }
845
858
 
846
859
  }
847
860
 
848
- }
861
+ currentRenderState = renderStates.get( scene );
862
+ currentRenderState.init();
849
863
 
850
- currentRenderState = renderStates.get( scene );
851
- currentRenderState.init();
864
+ renderStateStack.push( currentRenderState );
852
865
 
853
- renderStateStack.push( currentRenderState );
866
+ scene.traverseVisible( function ( object ) {
854
867
 
855
- scene.traverseVisible( function ( object ) {
868
+ if ( object.isLight && object.layers.test( camera.layers ) ) {
856
869
 
857
- if ( object.isLight && object.layers.test( camera.layers ) ) {
870
+ currentRenderState.pushLight( object );
858
871
 
859
- currentRenderState.pushLight( object );
872
+ if ( object.castShadow ) {
860
873
 
861
- if ( object.castShadow ) {
874
+ currentRenderState.pushShadow( object );
862
875
 
863
- currentRenderState.pushShadow( object );
876
+ }
864
877
 
865
878
  }
866
879
 
867
- }
880
+ } );
868
881
 
869
- } );
882
+ currentRenderState.setupLights( _this.useLegacyLights );
870
883
 
871
- currentRenderState.setupLights( _this.physicallyCorrectLights );
884
+ scene.traverse( function ( object ) {
872
885
 
873
- scene.traverse( function ( object ) {
886
+ const material = object.material;
874
887
 
875
- const material = object.material;
888
+ if ( material ) {
876
889
 
877
- if ( material ) {
890
+ if ( Array.isArray( material ) ) {
878
891
 
879
- if ( Array.isArray( material ) ) {
892
+ for ( let i = 0; i < material.length; i ++ ) {
880
893
 
881
- for ( let i = 0; i < material.length; i ++ ) {
894
+ const material2 = material[ i ];
882
895
 
883
- const material2 = material[ i ];
896
+ prepare( material2, scene, object );
884
897
 
885
- prepare( material2, scene, object );
898
+ }
886
899
 
887
- }
900
+ } else {
888
901
 
889
- } else {
902
+ prepare( material, scene, object );
890
903
 
891
- prepare( material, scene, object );
904
+ }
892
905
 
893
906
  }
894
907
 
895
- }
908
+ } );
896
909
 
897
- } );
910
+ renderStateStack.pop();
911
+ currentRenderState = null;
898
912
 
899
- renderStateStack.pop();
900
- currentRenderState = null;
913
+ };
901
914
 
902
- };
915
+ // Animation Loop
903
916
 
904
- // Animation Loop
917
+ let onAnimationFrameCallback = null;
905
918
 
906
- let onAnimationFrameCallback = null;
919
+ function onAnimationFrame( time ) {
907
920
 
908
- function onAnimationFrame( time ) {
921
+ if ( onAnimationFrameCallback ) onAnimationFrameCallback( time );
909
922
 
910
- if ( onAnimationFrameCallback ) onAnimationFrameCallback( time );
923
+ }
911
924
 
912
- }
925
+ function onXRSessionStart() {
913
926
 
914
- function onXRSessionStart() {
927
+ animation.stop();
915
928
 
916
- animation.stop();
929
+ }
917
930
 
918
- }
931
+ function onXRSessionEnd() {
919
932
 
920
- function onXRSessionEnd() {
933
+ animation.start();
921
934
 
922
- animation.start();
935
+ }
923
936
 
924
- }
937
+ const animation = new WebGLAnimation();
938
+ animation.setAnimationLoop( onAnimationFrame );
925
939
 
926
- const animation = new WebGLAnimation();
927
- animation.setAnimationLoop( onAnimationFrame );
940
+ if ( typeof self !== 'undefined' ) animation.setContext( self );
928
941
 
929
- if ( typeof self !== 'undefined' ) animation.setContext( self );
942
+ this.setAnimationLoop = function ( callback ) {
930
943
 
931
- this.setAnimationLoop = function ( callback ) {
944
+ onAnimationFrameCallback = callback;
945
+ xr.setAnimationLoop( callback );
932
946
 
933
- onAnimationFrameCallback = callback;
934
- xr.setAnimationLoop( callback );
947
+ ( callback === null ) ? animation.stop() : animation.start();
935
948
 
936
- ( callback === null ) ? animation.stop() : animation.start();
949
+ };
937
950
 
938
- };
951
+ xr.addEventListener( 'sessionstart', onXRSessionStart );
952
+ xr.addEventListener( 'sessionend', onXRSessionEnd );
939
953
 
940
- xr.addEventListener( 'sessionstart', onXRSessionStart );
941
- xr.addEventListener( 'sessionend', onXRSessionEnd );
954
+ // Rendering
942
955
 
943
- // Rendering
956
+ this.render = function ( scene, camera ) {
944
957
 
945
- this.render = function ( scene, camera ) {
958
+ if ( camera !== undefined && camera.isCamera !== true ) {
946
959
 
947
- if ( camera !== undefined && camera.isCamera !== true ) {
960
+ console.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' );
961
+ return;
948
962
 
949
- console.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' );
950
- return;
963
+ }
951
964
 
952
- }
965
+ if ( _isContextLost === true ) return;
953
966
 
954
- if ( _isContextLost === true ) return;
967
+ // update scene graph
955
968
 
956
- // update scene graph
969
+ if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
957
970
 
958
- if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
971
+ // update camera matrices and frustum
959
972
 
960
- // update camera matrices and frustum
973
+ if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
961
974
 
962
- if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
975
+ if ( xr.enabled === true && xr.isPresenting === true ) {
963
976
 
964
- if ( xr.enabled === true && xr.isPresenting === true ) {
977
+ if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera );
965
978
 
966
- if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera );
979
+ camera = xr.getCamera(); // use XR camera for rendering
967
980
 
968
- camera = xr.getCamera(); // use XR camera for rendering
981
+ }
969
982
 
970
- }
983
+ //
984
+ if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget );
971
985
 
972
- //
973
- if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget );
986
+ currentRenderState = renderStates.get( scene, renderStateStack.length );
987
+ currentRenderState.init();
974
988
 
975
- currentRenderState = renderStates.get( scene, renderStateStack.length );
976
- currentRenderState.init();
989
+ renderStateStack.push( currentRenderState );
977
990
 
978
- renderStateStack.push( currentRenderState );
991
+ _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
992
+ _frustum.setFromProjectionMatrix( _projScreenMatrix );
979
993
 
980
- _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
981
- _frustum.setFromProjectionMatrix( _projScreenMatrix );
994
+ _localClippingEnabled = this.localClippingEnabled;
995
+ _clippingEnabled = clipping.init( this.clippingPlanes, _localClippingEnabled );
982
996
 
983
- _localClippingEnabled = this.localClippingEnabled;
984
- _clippingEnabled = clipping.init( this.clippingPlanes, _localClippingEnabled, camera );
997
+ currentRenderList = renderLists.get( scene, renderListStack.length );
998
+ currentRenderList.init();
985
999
 
986
- currentRenderList = renderLists.get( scene, renderListStack.length );
987
- currentRenderList.init();
1000
+ renderListStack.push( currentRenderList );
988
1001
 
989
- renderListStack.push( currentRenderList );
1002
+ projectObject( scene, camera, 0, _this.sortObjects );
990
1003
 
991
- projectObject( scene, camera, 0, _this.sortObjects );
1004
+ currentRenderList.finish();
992
1005
 
993
- currentRenderList.finish();
1006
+ if ( _this.sortObjects === true ) {
994
1007
 
995
- if ( _this.sortObjects === true ) {
1008
+ currentRenderList.sort( _opaqueSort, _transparentSort );
996
1009
 
997
- currentRenderList.sort( _opaqueSort, _transparentSort );
1010
+ }
998
1011
 
999
- }
1012
+ //
1000
1013
 
1001
- //
1014
+ if ( _clippingEnabled === true ) clipping.beginShadows();
1002
1015
 
1003
- if ( _clippingEnabled === true ) clipping.beginShadows();
1016
+ const shadowsArray = currentRenderState.state.shadowsArray;
1004
1017
 
1005
- const shadowsArray = currentRenderState.state.shadowsArray;
1018
+ shadowMap.render( shadowsArray, scene, camera );
1006
1019
 
1007
- shadowMap.render( shadowsArray, scene, camera );
1020
+ if ( _clippingEnabled === true ) clipping.endShadows();
1008
1021
 
1009
- if ( _clippingEnabled === true ) clipping.endShadows();
1022
+ //
1010
1023
 
1011
- //
1024
+ if ( this.info.autoReset === true ) this.info.reset();
1012
1025
 
1013
- if ( this.info.autoReset === true ) this.info.reset();
1026
+ //
1014
1027
 
1015
- //
1028
+ background.render( currentRenderList, scene );
1016
1029
 
1017
- background.render( currentRenderList, scene );
1030
+ // render scene
1018
1031
 
1019
- // render scene
1032
+ currentRenderState.setupLights( _this.useLegacyLights );
1020
1033
 
1021
- currentRenderState.setupLights( _this.physicallyCorrectLights );
1034
+ if ( camera.isArrayCamera ) {
1022
1035
 
1023
- if ( camera.isArrayCamera ) {
1036
+ const cameras = camera.cameras;
1024
1037
 
1025
- const cameras = camera.cameras;
1038
+ for ( let i = 0, l = cameras.length; i < l; i ++ ) {
1026
1039
 
1027
- for ( let i = 0, l = cameras.length; i < l; i ++ ) {
1040
+ const camera2 = cameras[ i ];
1028
1041
 
1029
- const camera2 = cameras[ i ];
1042
+ renderScene( currentRenderList, scene, camera2, camera2.viewport );
1030
1043
 
1031
- renderScene( currentRenderList, scene, camera2, camera2.viewport );
1044
+ }
1032
1045
 
1033
- }
1046
+ } else {
1034
1047
 
1035
- } else {
1048
+ renderScene( currentRenderList, scene, camera );
1036
1049
 
1037
- renderScene( currentRenderList, scene, camera );
1050
+ }
1038
1051
 
1039
- }
1052
+ //
1040
1053
 
1041
- //
1054
+ if ( _currentRenderTarget !== null ) {
1042
1055
 
1043
- if ( _currentRenderTarget !== null ) {
1056
+ // resolve multisample renderbuffers to a single-sample texture if necessary
1044
1057
 
1045
- // resolve multisample renderbuffers to a single-sample texture if necessary
1058
+ textures.updateMultisampleRenderTarget( _currentRenderTarget );
1046
1059
 
1047
- textures.updateMultisampleRenderTarget( _currentRenderTarget );
1060
+ // Generate mipmap if we're using any kind of mipmap filtering
1048
1061
 
1049
- // Generate mipmap if we're using any kind of mipmap filtering
1062
+ textures.updateRenderTargetMipmap( _currentRenderTarget );
1050
1063
 
1051
- textures.updateRenderTargetMipmap( _currentRenderTarget );
1064
+ }
1052
1065
 
1053
- }
1066
+ //
1054
1067
 
1055
- //
1068
+ if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
1056
1069
 
1057
- if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
1070
+ if ( xr.enabled && xr.submitFrame ) {
1058
1071
 
1059
- if ( xr.enabled && xr.submitFrame ) {
1072
+ xr.submitFrame();
1060
1073
 
1061
- xr.submitFrame();
1074
+ }
1075
+ // _gl.finish();
1062
1076
 
1063
- }
1064
- // _gl.finish();
1077
+ bindingStates.resetDefaultState();
1078
+ _currentMaterialId = - 1;
1079
+ _currentCamera = null;
1065
1080
 
1066
- bindingStates.resetDefaultState();
1067
- _currentMaterialId = - 1;
1068
- _currentCamera = null;
1081
+ renderStateStack.pop();
1069
1082
 
1070
- renderStateStack.pop();
1083
+ if ( renderStateStack.length > 0 ) {
1071
1084
 
1072
- if ( renderStateStack.length > 0 ) {
1085
+ currentRenderState = renderStateStack[ renderStateStack.length - 1 ];
1073
1086
 
1074
- currentRenderState = renderStateStack[ renderStateStack.length - 1 ];
1087
+ } else {
1075
1088
 
1076
- } else {
1089
+ currentRenderState = null;
1077
1090
 
1078
- currentRenderState = null;
1091
+ }
1079
1092
 
1080
- }
1093
+ renderListStack.pop();
1081
1094
 
1082
- renderListStack.pop();
1095
+ if ( renderListStack.length > 0 ) {
1083
1096
 
1084
- if ( renderListStack.length > 0 ) {
1097
+ currentRenderList = renderListStack[ renderListStack.length - 1 ];
1085
1098
 
1086
- currentRenderList = renderListStack[ renderListStack.length - 1 ];
1099
+ } else {
1087
1100
 
1088
- } else {
1101
+ currentRenderList = null;
1089
1102
 
1090
- currentRenderList = null;
1103
+ }
1091
1104
 
1092
- }
1105
+ };
1093
1106
 
1094
- };
1107
+ function projectObject( object, camera, groupOrder, sortObjects ) {
1095
1108
 
1096
- function projectObject( object, camera, groupOrder, sortObjects ) {
1109
+ if ( object.visible === false ) return;
1097
1110
 
1098
- if ( object.visible === false ) return;
1111
+ const visible = object.layers.test( camera.layers );
1099
1112
 
1100
- const visible = object.layers.test( camera.layers );
1113
+ if ( visible ) {
1101
1114
 
1102
- if ( visible ) {
1115
+ if ( object.isGroup ) {
1103
1116
 
1104
- if ( object.isGroup ) {
1117
+ groupOrder = object.renderOrder;
1105
1118
 
1106
- groupOrder = object.renderOrder;
1119
+ } else if ( object.isLOD ) {
1107
1120
 
1108
- } else if ( object.isLOD ) {
1121
+ if ( object.autoUpdate === true ) object.update( camera );
1109
1122
 
1110
- if ( object.autoUpdate === true ) object.update( camera );
1123
+ } else if ( object.isLight ) {
1111
1124
 
1112
- } else if ( object.isLight ) {
1125
+ currentRenderState.pushLight( object );
1113
1126
 
1114
- currentRenderState.pushLight( object );
1127
+ if ( object.castShadow ) {
1115
1128
 
1116
- if ( object.castShadow ) {
1129
+ currentRenderState.pushShadow( object );
1117
1130
 
1118
- currentRenderState.pushShadow( object );
1131
+ }
1119
1132
 
1120
- }
1133
+ } else if ( object.isSprite ) {
1121
1134
 
1122
- } else if ( object.isSprite ) {
1135
+ if ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {
1123
1136
 
1124
- if ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {
1137
+ if ( sortObjects ) {
1125
1138
 
1126
- if ( sortObjects ) {
1139
+ _vector3.setFromMatrixPosition( object.matrixWorld )
1140
+ .applyMatrix4( _projScreenMatrix );
1127
1141
 
1128
- _vector3.setFromMatrixPosition( object.matrixWorld )
1129
- .applyMatrix4( _projScreenMatrix );
1142
+ }
1130
1143
 
1131
- }
1144
+ const geometry = objects.update( object );
1145
+ const material = object.material;
1132
1146
 
1133
- const geometry = objects.update( object );
1134
- const material = object.material;
1147
+ if ( material.visible ) {
1135
1148
 
1136
- if ( material.visible ) {
1149
+ currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
1137
1150
 
1138
- currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
1151
+ }
1139
1152
 
1140
1153
  }
1141
1154
 
1142
- }
1155
+ } else if ( object.isMesh || object.isLine || object.isPoints ) {
1143
1156
 
1144
- } else if ( object.isMesh || object.isLine || object.isPoints ) {
1157
+ if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {
1145
1158
 
1146
- if ( object.isSkinnedMesh ) {
1159
+ if ( object.isSkinnedMesh ) {
1147
1160
 
1148
- // update skeleton only once in a frame
1161
+ // update skeleton only once in a frame
1149
1162
 
1150
- if ( object.skeleton.frame !== info.render.frame ) {
1163
+ if ( object.skeleton.frame !== info.render.frame ) {
1151
1164
 
1152
- object.skeleton.update();
1153
- object.skeleton.frame = info.render.frame;
1165
+ object.skeleton.update();
1166
+ object.skeleton.frame = info.render.frame;
1154
1167
 
1155
- }
1168
+ }
1156
1169
 
1157
- }
1170
+ }
1158
1171
 
1159
- if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {
1172
+ const geometry = objects.update( object );
1173
+ const material = object.material;
1160
1174
 
1161
- if ( sortObjects ) {
1175
+ if ( sortObjects ) {
1162
1176
 
1163
- _vector3.setFromMatrixPosition( object.matrixWorld )
1164
- .applyMatrix4( _projScreenMatrix );
1177
+ if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
1165
1178
 
1166
- }
1179
+ _vector3
1180
+ .copy( geometry.boundingSphere.center )
1181
+ .applyMatrix4( object.matrixWorld )
1182
+ .applyMatrix4( _projScreenMatrix );
1167
1183
 
1168
- const geometry = objects.update( object );
1169
- const material = object.material;
1184
+ }
1170
1185
 
1171
- if ( Array.isArray( material ) ) {
1186
+ if ( Array.isArray( material ) ) {
1172
1187
 
1173
- const groups = geometry.groups;
1188
+ const groups = geometry.groups;
1174
1189
 
1175
- for ( let i = 0, l = groups.length; i < l; i ++ ) {
1190
+ for ( let i = 0, l = groups.length; i < l; i ++ ) {
1176
1191
 
1177
- const group = groups[ i ];
1178
- const groupMaterial = material[ group.materialIndex ];
1192
+ const group = groups[ i ];
1193
+ const groupMaterial = material[ group.materialIndex ];
1179
1194
 
1180
- if ( groupMaterial && groupMaterial.visible ) {
1195
+ if ( groupMaterial && groupMaterial.visible ) {
1181
1196
 
1182
- currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group );
1197
+ currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group );
1198
+
1199
+ }
1183
1200
 
1184
1201
  }
1185
1202
 
1186
- }
1203
+ } else if ( material.visible ) {
1187
1204
 
1188
- } else if ( material.visible ) {
1205
+ currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
1189
1206
 
1190
- currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
1207
+ }
1191
1208
 
1192
1209
  }
1193
1210
 
@@ -1195,1090 +1212,1155 @@ function WebGLRenderer( parameters = {} ) {
1195
1212
 
1196
1213
  }
1197
1214
 
1198
- }
1215
+ const children = object.children;
1199
1216
 
1200
- const children = object.children;
1217
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
1201
1218
 
1202
- for ( let i = 0, l = children.length; i < l; i ++ ) {
1219
+ projectObject( children[ i ], camera, groupOrder, sortObjects );
1203
1220
 
1204
- projectObject( children[ i ], camera, groupOrder, sortObjects );
1221
+ }
1205
1222
 
1206
1223
  }
1207
1224
 
1208
- }
1225
+ function renderScene( currentRenderList, scene, camera, viewport ) {
1209
1226
 
1210
- function renderScene( currentRenderList, scene, camera, viewport ) {
1227
+ const opaqueObjects = currentRenderList.opaque;
1228
+ const transmissiveObjects = currentRenderList.transmissive;
1229
+ const transparentObjects = currentRenderList.transparent;
1211
1230
 
1212
- const opaqueObjects = currentRenderList.opaque;
1213
- const transmissiveObjects = currentRenderList.transmissive;
1214
- const transparentObjects = currentRenderList.transparent;
1231
+ currentRenderState.setupLightsView( camera );
1215
1232
 
1216
- currentRenderState.setupLightsView( camera );
1233
+ if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
1217
1234
 
1218
- if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, scene, camera );
1235
+ if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
1219
1236
 
1220
- if ( viewport ) state.viewport( _currentViewport.copy( viewport ) );
1237
+ if ( viewport ) state.viewport( _currentViewport.copy( viewport ) );
1221
1238
 
1222
- if ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );
1223
- if ( transmissiveObjects.length > 0 ) renderObjects( transmissiveObjects, scene, camera );
1224
- if ( transparentObjects.length > 0 ) renderObjects( transparentObjects, scene, camera );
1239
+ if ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );
1240
+ if ( transmissiveObjects.length > 0 ) renderObjects( transmissiveObjects, scene, camera );
1241
+ if ( transparentObjects.length > 0 ) renderObjects( transparentObjects, scene, camera );
1225
1242
 
1226
- // Ensure depth buffer writing is enabled so it can be cleared on next render
1243
+ // Ensure depth buffer writing is enabled so it can be cleared on next render
1227
1244
 
1228
- state.buffers.depth.setTest( true );
1229
- state.buffers.depth.setMask( true );
1230
- state.buffers.color.setMask( true );
1245
+ state.buffers.depth.setTest( true );
1246
+ state.buffers.depth.setMask( true );
1247
+ state.buffers.color.setMask( true );
1231
1248
 
1232
- state.setPolygonOffset( false );
1249
+ state.setPolygonOffset( false );
1233
1250
 
1234
- }
1251
+ }
1235
1252
 
1236
- function renderTransmissionPass( opaqueObjects, scene, camera ) {
1253
+ function renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera ) {
1237
1254
 
1238
- const isWebGL2 = capabilities.isWebGL2;
1255
+ if ( _transmissionRenderTarget === null ) {
1239
1256
 
1240
- if ( _transmissionRenderTarget === null ) {
1257
+ const isWebGL2 = capabilities.isWebGL2;
1241
1258
 
1242
- _transmissionRenderTarget = new WebGLRenderTarget( 1, 1, {
1243
- generateMipmaps: true,
1244
- type: extensions.has( 'EXT_color_buffer_half_float' ) ? HalfFloatType : UnsignedByteType,
1245
- minFilter: LinearMipmapLinearFilter,
1246
- samples: ( isWebGL2 && _antialias === true ) ? 4 : 0
1247
- } );
1259
+ _transmissionRenderTarget = new WebGLRenderTarget( 1024, 1024, {
1260
+ generateMipmaps: true,
1261
+ type: extensions.has( 'EXT_color_buffer_half_float' ) ? HalfFloatType : UnsignedByteType,
1262
+ minFilter: LinearMipmapLinearFilter,
1263
+ samples: ( isWebGL2 && antialias === true ) ? 4 : 0
1264
+ } );
1248
1265
 
1249
- }
1266
+ // debug
1250
1267
 
1251
- _this.getDrawingBufferSize( _vector2 );
1268
+ /*
1269
+ const geometry = new PlaneGeometry();
1270
+ const material = new MeshBasicMaterial( { map: _transmissionRenderTarget.texture } );
1252
1271
 
1253
- if ( isWebGL2 ) {
1272
+ const mesh = new Mesh( geometry, material );
1273
+ scene.add( mesh );
1274
+ */
1254
1275
 
1255
- _transmissionRenderTarget.setSize( _vector2.x, _vector2.y );
1276
+ }
1256
1277
 
1257
- } else {
1278
+ //
1258
1279
 
1259
- _transmissionRenderTarget.setSize( floorPowerOfTwo( _vector2.x ), floorPowerOfTwo( _vector2.y ) );
1280
+ const currentRenderTarget = _this.getRenderTarget();
1281
+ _this.setRenderTarget( _transmissionRenderTarget );
1282
+ _this.clear();
1260
1283
 
1261
- }
1284
+ // Turn off the features which can affect the frag color for opaque objects pass.
1285
+ // Otherwise they are applied twice in opaque objects pass and transmission objects pass.
1286
+ const currentToneMapping = _this.toneMapping;
1287
+ _this.toneMapping = NoToneMapping;
1262
1288
 
1263
- //
1289
+ renderObjects( opaqueObjects, scene, camera );
1264
1290
 
1265
- const currentRenderTarget = _this.getRenderTarget();
1266
- _this.setRenderTarget( _transmissionRenderTarget );
1267
- _this.clear();
1291
+ textures.updateMultisampleRenderTarget( _transmissionRenderTarget );
1292
+ textures.updateRenderTargetMipmap( _transmissionRenderTarget );
1268
1293
 
1269
- // Turn off the features which can affect the frag color for opaque objects pass.
1270
- // Otherwise they are applied twice in opaque objects pass and transmission objects pass.
1271
- const currentToneMapping = _this.toneMapping;
1272
- _this.toneMapping = NoToneMapping;
1294
+ let renderTargetNeedsUpdate = false;
1273
1295
 
1274
- renderObjects( opaqueObjects, scene, camera );
1296
+ for ( let i = 0, l = transmissiveObjects.length; i < l; i ++ ) {
1275
1297
 
1276
- _this.toneMapping = currentToneMapping;
1298
+ const renderItem = transmissiveObjects[ i ];
1277
1299
 
1278
- textures.updateMultisampleRenderTarget( _transmissionRenderTarget );
1279
- textures.updateRenderTargetMipmap( _transmissionRenderTarget );
1300
+ const object = renderItem.object;
1301
+ const geometry = renderItem.geometry;
1302
+ const material = renderItem.material;
1303
+ const group = renderItem.group;
1280
1304
 
1281
- _this.setRenderTarget( currentRenderTarget );
1305
+ if ( material.side === DoubleSide && object.layers.test( camera.layers ) ) {
1282
1306
 
1283
- }
1307
+ const currentSide = material.side;
1284
1308
 
1285
- function renderObjects( renderList, scene, camera ) {
1309
+ material.side = BackSide;
1310
+ material.needsUpdate = true;
1286
1311
 
1287
- const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;
1312
+ renderObject( object, scene, camera, geometry, material, group );
1288
1313
 
1289
- for ( let i = 0, l = renderList.length; i < l; i ++ ) {
1314
+ material.side = currentSide;
1315
+ material.needsUpdate = true;
1290
1316
 
1291
- const renderItem = renderList[ i ];
1317
+ renderTargetNeedsUpdate = true;
1292
1318
 
1293
- const object = renderItem.object;
1294
- const geometry = renderItem.geometry;
1295
- const material = overrideMaterial === null ? renderItem.material : overrideMaterial;
1296
- const group = renderItem.group;
1319
+ }
1297
1320
 
1298
- if ( object.layers.test( camera.layers ) ) {
1321
+ }
1299
1322
 
1300
- renderObject( object, scene, camera, geometry, material, group );
1323
+ if ( renderTargetNeedsUpdate === true ) {
1324
+
1325
+ textures.updateMultisampleRenderTarget( _transmissionRenderTarget );
1326
+ textures.updateRenderTargetMipmap( _transmissionRenderTarget );
1301
1327
 
1302
1328
  }
1303
1329
 
1304
- }
1330
+ _this.setRenderTarget( currentRenderTarget );
1305
1331
 
1306
- }
1332
+ _this.toneMapping = currentToneMapping;
1307
1333
 
1308
- function renderObject( object, scene, camera, geometry, material, group ) {
1334
+ }
1309
1335
 
1310
- object.onBeforeRender( _this, scene, camera, geometry, material, group );
1336
+ function renderObjects( renderList, scene, camera ) {
1311
1337
 
1312
- object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
1313
- object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
1338
+ const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;
1314
1339
 
1315
- material.onBeforeRender( _this, scene, camera, geometry, object, group );
1340
+ for ( let i = 0, l = renderList.length; i < l; i ++ ) {
1316
1341
 
1317
- if ( material.transparent === true && material.side === DoubleSide ) {
1342
+ const renderItem = renderList[ i ];
1318
1343
 
1319
- material.side = BackSide;
1320
- material.needsUpdate = true;
1321
- _this.renderBufferDirect( camera, scene, geometry, material, object, group );
1344
+ const object = renderItem.object;
1345
+ const geometry = renderItem.geometry;
1346
+ const material = overrideMaterial === null ? renderItem.material : overrideMaterial;
1347
+ const group = renderItem.group;
1322
1348
 
1323
- material.side = FrontSide;
1324
- material.needsUpdate = true;
1325
- _this.renderBufferDirect( camera, scene, geometry, material, object, group );
1349
+ if ( object.layers.test( camera.layers ) ) {
1326
1350
 
1327
- material.side = DoubleSide;
1351
+ renderObject( object, scene, camera, geometry, material, group );
1328
1352
 
1329
- } else {
1353
+ }
1330
1354
 
1331
- _this.renderBufferDirect( camera, scene, geometry, material, object, group );
1355
+ }
1332
1356
 
1333
1357
  }
1334
1358
 
1335
- object.onAfterRender( _this, scene, camera, geometry, material, group );
1359
+ function renderObject( object, scene, camera, geometry, material, group ) {
1336
1360
 
1337
- }
1361
+ object.onBeforeRender( _this, scene, camera, geometry, material, group );
1362
+
1363
+ object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
1364
+ object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
1338
1365
 
1339
- function getProgram( material, scene, object ) {
1366
+ material.onBeforeRender( _this, scene, camera, geometry, object, group );
1340
1367
 
1341
- if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...
1368
+ if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
1342
1369
 
1343
- const materialProperties = properties.get( material );
1370
+ material.side = BackSide;
1371
+ material.needsUpdate = true;
1372
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
1344
1373
 
1345
- const lights = currentRenderState.state.lights;
1346
- const shadowsArray = currentRenderState.state.shadowsArray;
1374
+ material.side = FrontSide;
1375
+ material.needsUpdate = true;
1376
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
1347
1377
 
1348
- const lightsStateVersion = lights.state.version;
1378
+ material.side = DoubleSide;
1349
1379
 
1350
- const parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, object );
1351
- const programCacheKey = programCache.getProgramCacheKey( parameters );
1380
+ } else {
1352
1381
 
1353
- let programs = materialProperties.programs;
1382
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
1354
1383
 
1355
- // always update environment and fog - changing these trigger an getProgram call, but it's possible that the program doesn't change
1384
+ }
1356
1385
 
1357
- materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
1358
- materialProperties.fog = scene.fog;
1359
- materialProperties.envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || materialProperties.environment );
1386
+ object.onAfterRender( _this, scene, camera, geometry, material, group );
1360
1387
 
1361
- if ( programs === undefined ) {
1388
+ }
1362
1389
 
1363
- // new material
1390
+ function getProgram( material, scene, object ) {
1364
1391
 
1365
- material.addEventListener( 'dispose', onMaterialDispose );
1392
+ if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...
1366
1393
 
1367
- programs = new Map();
1368
- materialProperties.programs = programs;
1394
+ const materialProperties = properties.get( material );
1369
1395
 
1370
- }
1396
+ const lights = currentRenderState.state.lights;
1397
+ const shadowsArray = currentRenderState.state.shadowsArray;
1398
+
1399
+ const lightsStateVersion = lights.state.version;
1371
1400
 
1372
- let program = programs.get( programCacheKey );
1401
+ const parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, object );
1402
+ const programCacheKey = programCache.getProgramCacheKey( parameters );
1373
1403
 
1374
- if ( program !== undefined ) {
1404
+ let programs = materialProperties.programs;
1375
1405
 
1376
- // early out if program and light state is identical
1406
+ // always update environment and fog - changing these trigger an getProgram call, but it's possible that the program doesn't change
1377
1407
 
1378
- if ( materialProperties.currentProgram === program && materialProperties.lightsStateVersion === lightsStateVersion ) {
1408
+ materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
1409
+ materialProperties.fog = scene.fog;
1410
+ materialProperties.envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || materialProperties.environment );
1379
1411
 
1380
- updateCommonMaterialProperties( material, parameters );
1412
+ if ( programs === undefined ) {
1381
1413
 
1382
- return program;
1414
+ // new material
1415
+
1416
+ material.addEventListener( 'dispose', onMaterialDispose );
1417
+
1418
+ programs = new Map();
1419
+ materialProperties.programs = programs;
1383
1420
 
1384
1421
  }
1385
1422
 
1386
- } else {
1423
+ let program = programs.get( programCacheKey );
1387
1424
 
1388
- parameters.uniforms = programCache.getUniforms( material );
1425
+ if ( program !== undefined ) {
1389
1426
 
1390
- material.onBuild( object, parameters, _this );
1427
+ // early out if program and light state is identical
1391
1428
 
1392
- material.onBeforeCompile( parameters, _this );
1429
+ if ( materialProperties.currentProgram === program && materialProperties.lightsStateVersion === lightsStateVersion ) {
1393
1430
 
1394
- program = programCache.acquireProgram( parameters, programCacheKey );
1395
- programs.set( programCacheKey, program );
1431
+ updateCommonMaterialProperties( material, parameters );
1396
1432
 
1397
- materialProperties.uniforms = parameters.uniforms;
1433
+ return program;
1398
1434
 
1399
- }
1435
+ }
1400
1436
 
1401
- const uniforms = materialProperties.uniforms;
1437
+ } else {
1402
1438
 
1403
- if ( ( ! material.isShaderMaterial && ! material.isRawShaderMaterial ) || material.clipping === true ) {
1439
+ parameters.uniforms = programCache.getUniforms( material );
1404
1440
 
1405
- uniforms.clippingPlanes = clipping.uniform;
1441
+ material.onBuild( object, parameters, _this );
1406
1442
 
1407
- }
1443
+ material.onBeforeCompile( parameters, _this );
1408
1444
 
1409
- updateCommonMaterialProperties( material, parameters );
1445
+ program = programCache.acquireProgram( parameters, programCacheKey );
1446
+ programs.set( programCacheKey, program );
1410
1447
 
1411
- // store the light setup it was created for
1448
+ materialProperties.uniforms = parameters.uniforms;
1412
1449
 
1413
- materialProperties.needsLights = materialNeedsLights( material );
1414
- materialProperties.lightsStateVersion = lightsStateVersion;
1450
+ }
1415
1451
 
1416
- if ( materialProperties.needsLights ) {
1452
+ const uniforms = materialProperties.uniforms;
1417
1453
 
1418
- // wire up the material to this renderer's lighting state
1454
+ if ( ( ! material.isShaderMaterial && ! material.isRawShaderMaterial ) || material.clipping === true ) {
1419
1455
 
1420
- uniforms.ambientLightColor.value = lights.state.ambient;
1421
- uniforms.lightProbe.value = lights.state.probe;
1422
- uniforms.directionalLights.value = lights.state.directional;
1423
- uniforms.directionalLightShadows.value = lights.state.directionalShadow;
1424
- uniforms.spotLights.value = lights.state.spot;
1425
- uniforms.spotLightShadows.value = lights.state.spotShadow;
1426
- uniforms.rectAreaLights.value = lights.state.rectArea;
1427
- uniforms.ltc_1.value = lights.state.rectAreaLTC1;
1428
- uniforms.ltc_2.value = lights.state.rectAreaLTC2;
1429
- uniforms.pointLights.value = lights.state.point;
1430
- uniforms.pointLightShadows.value = lights.state.pointShadow;
1431
- uniforms.hemisphereLights.value = lights.state.hemi;
1456
+ uniforms.clippingPlanes = clipping.uniform;
1432
1457
 
1433
- uniforms.directionalShadowMap.value = lights.state.directionalShadowMap;
1434
- uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;
1435
- uniforms.spotShadowMap.value = lights.state.spotShadowMap;
1436
- uniforms.spotLightMatrix.value = lights.state.spotLightMatrix;
1437
- uniforms.spotLightMap.value = lights.state.spotLightMap;
1438
- uniforms.pointShadowMap.value = lights.state.pointShadowMap;
1439
- uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
1440
- // TODO (abelnation): add area lights shadow info to uniforms
1458
+ }
1441
1459
 
1442
- }
1460
+ updateCommonMaterialProperties( material, parameters );
1443
1461
 
1444
- const progUniforms = program.getUniforms();
1445
- const uniformsList = WebGLUniforms.seqWithValue( progUniforms.seq, uniforms );
1462
+ // store the light setup it was created for
1446
1463
 
1447
- materialProperties.currentProgram = program;
1448
- materialProperties.uniformsList = uniformsList;
1464
+ materialProperties.needsLights = materialNeedsLights( material );
1465
+ materialProperties.lightsStateVersion = lightsStateVersion;
1449
1466
 
1450
- return program;
1467
+ if ( materialProperties.needsLights ) {
1451
1468
 
1452
- }
1469
+ // wire up the material to this renderer's lighting state
1470
+
1471
+ uniforms.ambientLightColor.value = lights.state.ambient;
1472
+ uniforms.lightProbe.value = lights.state.probe;
1473
+ uniforms.directionalLights.value = lights.state.directional;
1474
+ uniforms.directionalLightShadows.value = lights.state.directionalShadow;
1475
+ uniforms.spotLights.value = lights.state.spot;
1476
+ uniforms.spotLightShadows.value = lights.state.spotShadow;
1477
+ uniforms.rectAreaLights.value = lights.state.rectArea;
1478
+ uniforms.ltc_1.value = lights.state.rectAreaLTC1;
1479
+ uniforms.ltc_2.value = lights.state.rectAreaLTC2;
1480
+ uniforms.pointLights.value = lights.state.point;
1481
+ uniforms.pointLightShadows.value = lights.state.pointShadow;
1482
+ uniforms.hemisphereLights.value = lights.state.hemi;
1483
+
1484
+ uniforms.directionalShadowMap.value = lights.state.directionalShadowMap;
1485
+ uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;
1486
+ uniforms.spotShadowMap.value = lights.state.spotShadowMap;
1487
+ uniforms.spotLightMatrix.value = lights.state.spotLightMatrix;
1488
+ uniforms.spotLightMap.value = lights.state.spotLightMap;
1489
+ uniforms.pointShadowMap.value = lights.state.pointShadowMap;
1490
+ uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
1491
+ // TODO (abelnation): add area lights shadow info to uniforms
1453
1492
 
1454
- function updateCommonMaterialProperties( material, parameters ) {
1493
+ }
1455
1494
 
1456
- const materialProperties = properties.get( material );
1495
+ const progUniforms = program.getUniforms();
1496
+ const uniformsList = WebGLUniforms.seqWithValue( progUniforms.seq, uniforms );
1457
1497
 
1458
- materialProperties.outputEncoding = parameters.outputEncoding;
1459
- materialProperties.instancing = parameters.instancing;
1460
- materialProperties.skinning = parameters.skinning;
1461
- materialProperties.morphTargets = parameters.morphTargets;
1462
- materialProperties.morphNormals = parameters.morphNormals;
1463
- materialProperties.morphColors = parameters.morphColors;
1464
- materialProperties.morphTargetsCount = parameters.morphTargetsCount;
1465
- materialProperties.numClippingPlanes = parameters.numClippingPlanes;
1466
- materialProperties.numIntersection = parameters.numClipIntersection;
1467
- materialProperties.vertexAlphas = parameters.vertexAlphas;
1468
- materialProperties.vertexTangents = parameters.vertexTangents;
1469
- materialProperties.toneMapping = parameters.toneMapping;
1498
+ materialProperties.currentProgram = program;
1499
+ materialProperties.uniformsList = uniformsList;
1470
1500
 
1471
- }
1501
+ return program;
1472
1502
 
1473
- function setProgram( camera, scene, geometry, material, object ) {
1503
+ }
1474
1504
 
1475
- if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...
1505
+ function updateCommonMaterialProperties( material, parameters ) {
1476
1506
 
1477
- textures.resetTextureUnits();
1507
+ const materialProperties = properties.get( material );
1478
1508
 
1479
- const fog = scene.fog;
1480
- const environment = material.isMeshStandardMaterial ? scene.environment : null;
1481
- const encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.encoding : LinearEncoding );
1482
- const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
1483
- const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
1484
- const vertexTangents = !! material.normalMap && !! geometry.attributes.tangent;
1485
- const morphTargets = !! geometry.morphAttributes.position;
1486
- const morphNormals = !! geometry.morphAttributes.normal;
1487
- const morphColors = !! geometry.morphAttributes.color;
1488
- const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping;
1509
+ materialProperties.outputColorSpace = parameters.outputColorSpace;
1510
+ materialProperties.instancing = parameters.instancing;
1511
+ materialProperties.skinning = parameters.skinning;
1512
+ materialProperties.morphTargets = parameters.morphTargets;
1513
+ materialProperties.morphNormals = parameters.morphNormals;
1514
+ materialProperties.morphColors = parameters.morphColors;
1515
+ materialProperties.morphTargetsCount = parameters.morphTargetsCount;
1516
+ materialProperties.numClippingPlanes = parameters.numClippingPlanes;
1517
+ materialProperties.numIntersection = parameters.numClipIntersection;
1518
+ materialProperties.vertexAlphas = parameters.vertexAlphas;
1519
+ materialProperties.vertexTangents = parameters.vertexTangents;
1520
+ materialProperties.toneMapping = parameters.toneMapping;
1489
1521
 
1490
- const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
1491
- const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
1522
+ }
1492
1523
 
1493
- const materialProperties = properties.get( material );
1494
- const lights = currentRenderState.state.lights;
1524
+ function setProgram( camera, scene, geometry, material, object ) {
1495
1525
 
1496
- if ( _clippingEnabled === true ) {
1526
+ if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...
1497
1527
 
1498
- if ( _localClippingEnabled === true || camera !== _currentCamera ) {
1528
+ textures.resetTextureUnits();
1499
1529
 
1500
- const useCache =
1501
- camera === _currentCamera &&
1502
- material.id === _currentMaterialId;
1530
+ const fog = scene.fog;
1531
+ const environment = material.isMeshStandardMaterial ? scene.environment : null;
1532
+ const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace );
1533
+ const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
1534
+ const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
1535
+ const vertexTangents = !! material.normalMap && !! geometry.attributes.tangent;
1536
+ const morphTargets = !! geometry.morphAttributes.position;
1537
+ const morphNormals = !! geometry.morphAttributes.normal;
1538
+ const morphColors = !! geometry.morphAttributes.color;
1539
+ const toneMapping = material.toneMapped ? _this.toneMapping : NoToneMapping;
1503
1540
 
1504
- // we might want to call this function with some ClippingGroup
1505
- // object instead of the material, once it becomes feasible
1506
- // (#8465, #8379)
1507
- clipping.setState( material, camera, useCache );
1541
+ const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
1542
+ const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
1508
1543
 
1509
- }
1544
+ const materialProperties = properties.get( material );
1545
+ const lights = currentRenderState.state.lights;
1510
1546
 
1511
- }
1547
+ if ( _clippingEnabled === true ) {
1512
1548
 
1513
- //
1549
+ if ( _localClippingEnabled === true || camera !== _currentCamera ) {
1514
1550
 
1515
- let needsProgramChange = false;
1551
+ const useCache =
1552
+ camera === _currentCamera &&
1553
+ material.id === _currentMaterialId;
1516
1554
 
1517
- if ( material.version === materialProperties.__version ) {
1555
+ // we might want to call this function with some ClippingGroup
1556
+ // object instead of the material, once it becomes feasible
1557
+ // (#8465, #8379)
1558
+ clipping.setState( material, camera, useCache );
1518
1559
 
1519
- if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) {
1560
+ }
1520
1561
 
1521
- needsProgramChange = true;
1562
+ }
1522
1563
 
1523
- } else if ( materialProperties.outputEncoding !== encoding ) {
1564
+ //
1524
1565
 
1525
- needsProgramChange = true;
1566
+ let needsProgramChange = false;
1526
1567
 
1527
- } else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
1568
+ if ( material.version === materialProperties.__version ) {
1528
1569
 
1529
- needsProgramChange = true;
1570
+ if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) {
1530
1571
 
1531
- } else if ( ! object.isInstancedMesh && materialProperties.instancing === true ) {
1572
+ needsProgramChange = true;
1532
1573
 
1533
- needsProgramChange = true;
1574
+ } else if ( materialProperties.outputColorSpace !== colorSpace ) {
1534
1575
 
1535
- } else if ( object.isSkinnedMesh && materialProperties.skinning === false ) {
1576
+ needsProgramChange = true;
1536
1577
 
1537
- needsProgramChange = true;
1578
+ } else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
1538
1579
 
1539
- } else if ( ! object.isSkinnedMesh && materialProperties.skinning === true ) {
1580
+ needsProgramChange = true;
1540
1581
 
1541
- needsProgramChange = true;
1582
+ } else if ( ! object.isInstancedMesh && materialProperties.instancing === true ) {
1542
1583
 
1543
- } else if ( materialProperties.envMap !== envMap ) {
1584
+ needsProgramChange = true;
1544
1585
 
1545
- needsProgramChange = true;
1586
+ } else if ( object.isSkinnedMesh && materialProperties.skinning === false ) {
1546
1587
 
1547
- } else if ( material.fog === true && materialProperties.fog !== fog ) {
1588
+ needsProgramChange = true;
1548
1589
 
1549
- needsProgramChange = true;
1590
+ } else if ( ! object.isSkinnedMesh && materialProperties.skinning === true ) {
1550
1591
 
1551
- } else if ( materialProperties.numClippingPlanes !== undefined &&
1552
- ( materialProperties.numClippingPlanes !== clipping.numPlanes ||
1553
- materialProperties.numIntersection !== clipping.numIntersection ) ) {
1592
+ needsProgramChange = true;
1554
1593
 
1555
- needsProgramChange = true;
1594
+ } else if ( materialProperties.envMap !== envMap ) {
1556
1595
 
1557
- } else if ( materialProperties.vertexAlphas !== vertexAlphas ) {
1596
+ needsProgramChange = true;
1558
1597
 
1559
- needsProgramChange = true;
1598
+ } else if ( material.fog === true && materialProperties.fog !== fog ) {
1560
1599
 
1561
- } else if ( materialProperties.vertexTangents !== vertexTangents ) {
1600
+ needsProgramChange = true;
1562
1601
 
1563
- needsProgramChange = true;
1602
+ } else if ( materialProperties.numClippingPlanes !== undefined &&
1603
+ ( materialProperties.numClippingPlanes !== clipping.numPlanes ||
1604
+ materialProperties.numIntersection !== clipping.numIntersection ) ) {
1564
1605
 
1565
- } else if ( materialProperties.morphTargets !== morphTargets ) {
1606
+ needsProgramChange = true;
1566
1607
 
1567
- needsProgramChange = true;
1608
+ } else if ( materialProperties.vertexAlphas !== vertexAlphas ) {
1568
1609
 
1569
- } else if ( materialProperties.morphNormals !== morphNormals ) {
1610
+ needsProgramChange = true;
1570
1611
 
1571
- needsProgramChange = true;
1612
+ } else if ( materialProperties.vertexTangents !== vertexTangents ) {
1572
1613
 
1573
- } else if ( materialProperties.morphColors !== morphColors ) {
1614
+ needsProgramChange = true;
1574
1615
 
1575
- needsProgramChange = true;
1616
+ } else if ( materialProperties.morphTargets !== morphTargets ) {
1576
1617
 
1577
- } else if ( materialProperties.toneMapping !== toneMapping ) {
1618
+ needsProgramChange = true;
1578
1619
 
1579
- needsProgramChange = true;
1620
+ } else if ( materialProperties.morphNormals !== morphNormals ) {
1580
1621
 
1581
- } else if ( capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount ) {
1622
+ needsProgramChange = true;
1582
1623
 
1583
- needsProgramChange = true;
1624
+ } else if ( materialProperties.morphColors !== morphColors ) {
1584
1625
 
1585
- }
1626
+ needsProgramChange = true;
1586
1627
 
1587
- } else {
1628
+ } else if ( materialProperties.toneMapping !== toneMapping ) {
1588
1629
 
1589
- needsProgramChange = true;
1590
- materialProperties.__version = material.version;
1630
+ needsProgramChange = true;
1591
1631
 
1592
- }
1632
+ } else if ( capabilities.isWebGL2 === true && materialProperties.morphTargetsCount !== morphTargetsCount ) {
1593
1633
 
1594
- //
1634
+ needsProgramChange = true;
1595
1635
 
1596
- let program = materialProperties.currentProgram;
1636
+ }
1597
1637
 
1598
- if ( needsProgramChange === true ) {
1638
+ } else {
1599
1639
 
1600
- program = getProgram( material, scene, object );
1640
+ needsProgramChange = true;
1641
+ materialProperties.__version = material.version;
1601
1642
 
1602
- }
1643
+ }
1603
1644
 
1604
- let refreshProgram = false;
1605
- let refreshMaterial = false;
1606
- let refreshLights = false;
1645
+ //
1607
1646
 
1608
- const p_uniforms = program.getUniforms(),
1609
- m_uniforms = materialProperties.uniforms;
1647
+ let program = materialProperties.currentProgram;
1610
1648
 
1611
- if ( state.useProgram( program.program ) ) {
1649
+ if ( needsProgramChange === true ) {
1612
1650
 
1613
- refreshProgram = true;
1614
- refreshMaterial = true;
1615
- refreshLights = true;
1651
+ program = getProgram( material, scene, object );
1616
1652
 
1617
- }
1653
+ }
1618
1654
 
1619
- if ( material.id !== _currentMaterialId ) {
1655
+ let refreshProgram = false;
1656
+ let refreshMaterial = false;
1657
+ let refreshLights = false;
1620
1658
 
1621
- _currentMaterialId = material.id;
1659
+ const p_uniforms = program.getUniforms(),
1660
+ m_uniforms = materialProperties.uniforms;
1622
1661
 
1623
- refreshMaterial = true;
1662
+ if ( state.useProgram( program.program ) ) {
1624
1663
 
1625
- }
1664
+ refreshProgram = true;
1665
+ refreshMaterial = true;
1666
+ refreshLights = true;
1626
1667
 
1627
- if ( refreshProgram || _currentCamera !== camera ) {
1668
+ }
1628
1669
 
1629
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
1670
+ if ( material.id !== _currentMaterialId ) {
1630
1671
 
1631
- if ( capabilities.logarithmicDepthBuffer ) {
1672
+ _currentMaterialId = material.id;
1632
1673
 
1633
- p_uniforms.setValue( _gl, 'logDepthBufFC',
1634
- 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
1674
+ refreshMaterial = true;
1635
1675
 
1636
1676
  }
1637
1677
 
1638
- if ( _currentCamera !== camera ) {
1678
+ if ( refreshProgram || _currentCamera !== camera ) {
1639
1679
 
1640
- _currentCamera = camera;
1680
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
1641
1681
 
1642
- // lighting uniforms depend on the camera so enforce an update
1643
- // now, in case this material supports lights - or later, when
1644
- // the next material that does gets activated:
1682
+ if ( capabilities.logarithmicDepthBuffer ) {
1645
1683
 
1646
- refreshMaterial = true; // set to true on material change
1647
- refreshLights = true; // remains set until update done
1684
+ p_uniforms.setValue( _gl, 'logDepthBufFC',
1685
+ 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
1648
1686
 
1649
- }
1687
+ }
1688
+
1689
+ if ( _currentCamera !== camera ) {
1690
+
1691
+ _currentCamera = camera;
1692
+
1693
+ // lighting uniforms depend on the camera so enforce an update
1694
+ // now, in case this material supports lights - or later, when
1695
+ // the next material that does gets activated:
1650
1696
 
1651
- // load material specific uniforms
1652
- // (shader material also gets them for the sake of genericity)
1697
+ refreshMaterial = true; // set to true on material change
1698
+ refreshLights = true; // remains set until update done
1653
1699
 
1654
- if ( material.isShaderMaterial ||
1655
- material.isMeshPhongMaterial ||
1656
- material.isMeshToonMaterial ||
1657
- material.isMeshStandardMaterial ||
1658
- material.envMap ) {
1700
+ }
1701
+
1702
+ // load material specific uniforms
1703
+ // (shader material also gets them for the sake of genericity)
1659
1704
 
1660
- const uCamPos = p_uniforms.map.cameraPosition;
1705
+ if ( material.isShaderMaterial ||
1706
+ material.isMeshPhongMaterial ||
1707
+ material.isMeshToonMaterial ||
1708
+ material.isMeshStandardMaterial ||
1709
+ material.envMap ) {
1661
1710
 
1662
- if ( uCamPos !== undefined ) {
1711
+ const uCamPos = p_uniforms.map.cameraPosition;
1663
1712
 
1664
- uCamPos.setValue( _gl,
1665
- _vector3.setFromMatrixPosition( camera.matrixWorld ) );
1713
+ if ( uCamPos !== undefined ) {
1714
+
1715
+ uCamPos.setValue( _gl,
1716
+ _vector3.setFromMatrixPosition( camera.matrixWorld ) );
1717
+
1718
+ }
1666
1719
 
1667
1720
  }
1668
1721
 
1669
- }
1722
+ if ( material.isMeshPhongMaterial ||
1723
+ material.isMeshToonMaterial ||
1724
+ material.isMeshLambertMaterial ||
1725
+ material.isMeshBasicMaterial ||
1726
+ material.isMeshStandardMaterial ||
1727
+ material.isShaderMaterial ) {
1670
1728
 
1671
- if ( material.isMeshPhongMaterial ||
1672
- material.isMeshToonMaterial ||
1673
- material.isMeshLambertMaterial ||
1674
- material.isMeshBasicMaterial ||
1675
- material.isMeshStandardMaterial ||
1676
- material.isShaderMaterial ) {
1729
+ p_uniforms.setValue( _gl, 'isOrthographic', camera.isOrthographicCamera === true );
1677
1730
 
1678
- p_uniforms.setValue( _gl, 'isOrthographic', camera.isOrthographicCamera === true );
1731
+ }
1679
1732
 
1680
- }
1733
+ if ( material.isMeshPhongMaterial ||
1734
+ material.isMeshToonMaterial ||
1735
+ material.isMeshLambertMaterial ||
1736
+ material.isMeshBasicMaterial ||
1737
+ material.isMeshStandardMaterial ||
1738
+ material.isShaderMaterial ||
1739
+ material.isShadowMaterial ||
1740
+ object.isSkinnedMesh ) {
1681
1741
 
1682
- if ( material.isMeshPhongMaterial ||
1683
- material.isMeshToonMaterial ||
1684
- material.isMeshLambertMaterial ||
1685
- material.isMeshBasicMaterial ||
1686
- material.isMeshStandardMaterial ||
1687
- material.isShaderMaterial ||
1688
- material.isShadowMaterial ||
1689
- object.isSkinnedMesh ) {
1742
+ p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
1690
1743
 
1691
- p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
1744
+ }
1692
1745
 
1693
1746
  }
1694
1747
 
1695
- }
1748
+ // skinning and morph target uniforms must be set even if material didn't change
1749
+ // auto-setting of texture unit for bone and morph texture must go before other textures
1750
+ // otherwise textures used for skinning and morphing can take over texture units reserved for other material textures
1696
1751
 
1697
- // skinning and morph target uniforms must be set even if material didn't change
1698
- // auto-setting of texture unit for bone and morph texture must go before other textures
1699
- // otherwise textures used for skinning and morphing can take over texture units reserved for other material textures
1752
+ if ( object.isSkinnedMesh ) {
1700
1753
 
1701
- if ( object.isSkinnedMesh ) {
1754
+ p_uniforms.setOptional( _gl, object, 'bindMatrix' );
1755
+ p_uniforms.setOptional( _gl, object, 'bindMatrixInverse' );
1702
1756
 
1703
- p_uniforms.setOptional( _gl, object, 'bindMatrix' );
1704
- p_uniforms.setOptional( _gl, object, 'bindMatrixInverse' );
1757
+ const skeleton = object.skeleton;
1705
1758
 
1706
- const skeleton = object.skeleton;
1759
+ if ( skeleton ) {
1707
1760
 
1708
- if ( skeleton ) {
1761
+ if ( capabilities.floatVertexTextures ) {
1709
1762
 
1710
- if ( capabilities.floatVertexTextures ) {
1763
+ if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
1711
1764
 
1712
- if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
1765
+ p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
1766
+ p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
1713
1767
 
1714
- p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
1715
- p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
1768
+ } else {
1716
1769
 
1717
- } else {
1770
+ console.warn( 'THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.' );
1718
1771
 
1719
- console.warn( 'THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.' );
1772
+ }
1720
1773
 
1721
1774
  }
1722
1775
 
1723
1776
  }
1724
1777
 
1725
- }
1778
+ const morphAttributes = geometry.morphAttributes;
1726
1779
 
1727
- const morphAttributes = geometry.morphAttributes;
1780
+ if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined && capabilities.isWebGL2 === true ) ) {
1728
1781
 
1729
- if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined && capabilities.isWebGL2 === true ) ) {
1782
+ morphtargets.update( object, geometry, program );
1730
1783
 
1731
- morphtargets.update( object, geometry, material, program );
1784
+ }
1732
1785
 
1733
- }
1786
+ if ( refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow ) {
1734
1787
 
1735
- if ( refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow ) {
1788
+ materialProperties.receiveShadow = object.receiveShadow;
1789
+ p_uniforms.setValue( _gl, 'receiveShadow', object.receiveShadow );
1736
1790
 
1737
- materialProperties.receiveShadow = object.receiveShadow;
1738
- p_uniforms.setValue( _gl, 'receiveShadow', object.receiveShadow );
1791
+ }
1739
1792
 
1740
- }
1793
+ // https://github.com/mrdoob/three.js/pull/24467#issuecomment-1209031512
1741
1794
 
1742
- // https://github.com/mrdoob/three.js/pull/24467#issuecomment-1209031512
1795
+ if ( material.isMeshGouraudMaterial && material.envMap !== null ) {
1743
1796
 
1744
- if ( material.isMeshGouraudMaterial && material.envMap !== null ) {
1797
+ m_uniforms.envMap.value = envMap;
1745
1798
 
1746
- m_uniforms.envMap.value = envMap;
1799
+ m_uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
1747
1800
 
1748
- m_uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
1801
+ }
1749
1802
 
1750
- }
1803
+ if ( refreshMaterial ) {
1751
1804
 
1752
- if ( refreshMaterial ) {
1805
+ p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
1753
1806
 
1754
- p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
1807
+ if ( materialProperties.needsLights ) {
1755
1808
 
1756
- if ( materialProperties.needsLights ) {
1809
+ // the current material requires lighting info
1757
1810
 
1758
- // the current material requires lighting info
1811
+ // note: all lighting uniforms are always set correctly
1812
+ // they simply reference the renderer's state for their
1813
+ // values
1814
+ //
1815
+ // use the current material's .needsUpdate flags to set
1816
+ // the GL state when required
1759
1817
 
1760
- // note: all lighting uniforms are always set correctly
1761
- // they simply reference the renderer's state for their
1762
- // values
1763
- //
1764
- // use the current material's .needsUpdate flags to set
1765
- // the GL state when required
1818
+ markUniformsLightsNeedsUpdate( m_uniforms, refreshLights );
1766
1819
 
1767
- markUniformsLightsNeedsUpdate( m_uniforms, refreshLights );
1820
+ }
1768
1821
 
1769
- }
1822
+ // refresh uniforms common to several materials
1770
1823
 
1771
- // refresh uniforms common to several materials
1824
+ if ( fog && material.fog === true ) {
1772
1825
 
1773
- if ( fog && material.fog === true ) {
1826
+ materials.refreshFogUniforms( m_uniforms, fog );
1774
1827
 
1775
- materials.refreshFogUniforms( m_uniforms, fog );
1828
+ }
1776
1829
 
1777
- }
1830
+ materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, _transmissionRenderTarget );
1778
1831
 
1779
- materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, _transmissionRenderTarget );
1832
+ WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
1780
1833
 
1781
- WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
1834
+ }
1782
1835
 
1783
- }
1836
+ if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {
1784
1837
 
1785
- if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {
1838
+ WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
1839
+ material.uniformsNeedUpdate = false;
1786
1840
 
1787
- WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
1788
- material.uniformsNeedUpdate = false;
1841
+ }
1789
1842
 
1790
- }
1843
+ if ( material.isSpriteMaterial ) {
1791
1844
 
1792
- if ( material.isSpriteMaterial ) {
1845
+ p_uniforms.setValue( _gl, 'center', object.center );
1793
1846
 
1794
- p_uniforms.setValue( _gl, 'center', object.center );
1847
+ }
1795
1848
 
1796
- }
1849
+ // common matrices
1797
1850
 
1798
- // common matrices
1851
+ p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
1852
+ p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
1853
+ p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
1799
1854
 
1800
- p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
1801
- p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
1802
- p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
1855
+ // UBOs
1803
1856
 
1804
- // UBOs
1857
+ if ( material.isShaderMaterial || material.isRawShaderMaterial ) {
1805
1858
 
1806
- if ( material.isShaderMaterial || material.isRawShaderMaterial ) {
1859
+ const groups = material.uniformsGroups;
1807
1860
 
1808
- const groups = material.uniformsGroups;
1861
+ for ( let i = 0, l = groups.length; i < l; i ++ ) {
1809
1862
 
1810
- for ( let i = 0, l = groups.length; i < l; i ++ ) {
1863
+ if ( capabilities.isWebGL2 ) {
1811
1864
 
1812
- if ( capabilities.isWebGL2 ) {
1865
+ const group = groups[ i ];
1813
1866
 
1814
- const group = groups[ i ];
1867
+ uniformsGroups.update( group, program );
1868
+ uniformsGroups.bind( group, program );
1815
1869
 
1816
- uniformsGroups.update( group, program );
1817
- uniformsGroups.bind( group, program );
1870
+ } else {
1818
1871
 
1819
- } else {
1872
+ console.warn( 'THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.' );
1820
1873
 
1821
- console.warn( 'THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.' );
1874
+ }
1822
1875
 
1823
1876
  }
1824
1877
 
1825
1878
  }
1826
1879
 
1880
+ return program;
1881
+
1827
1882
  }
1828
1883
 
1829
- return program;
1884
+ // If uniforms are marked as clean, they don't need to be loaded to the GPU.
1830
1885
 
1831
- }
1886
+ function markUniformsLightsNeedsUpdate( uniforms, value ) {
1832
1887
 
1833
- // If uniforms are marked as clean, they don't need to be loaded to the GPU.
1888
+ uniforms.ambientLightColor.needsUpdate = value;
1889
+ uniforms.lightProbe.needsUpdate = value;
1834
1890
 
1835
- function markUniformsLightsNeedsUpdate( uniforms, value ) {
1891
+ uniforms.directionalLights.needsUpdate = value;
1892
+ uniforms.directionalLightShadows.needsUpdate = value;
1893
+ uniforms.pointLights.needsUpdate = value;
1894
+ uniforms.pointLightShadows.needsUpdate = value;
1895
+ uniforms.spotLights.needsUpdate = value;
1896
+ uniforms.spotLightShadows.needsUpdate = value;
1897
+ uniforms.rectAreaLights.needsUpdate = value;
1898
+ uniforms.hemisphereLights.needsUpdate = value;
1836
1899
 
1837
- uniforms.ambientLightColor.needsUpdate = value;
1838
- uniforms.lightProbe.needsUpdate = value;
1900
+ }
1839
1901
 
1840
- uniforms.directionalLights.needsUpdate = value;
1841
- uniforms.directionalLightShadows.needsUpdate = value;
1842
- uniforms.pointLights.needsUpdate = value;
1843
- uniforms.pointLightShadows.needsUpdate = value;
1844
- uniforms.spotLights.needsUpdate = value;
1845
- uniforms.spotLightShadows.needsUpdate = value;
1846
- uniforms.rectAreaLights.needsUpdate = value;
1847
- uniforms.hemisphereLights.needsUpdate = value;
1902
+ function materialNeedsLights( material ) {
1848
1903
 
1849
- }
1904
+ return material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial ||
1905
+ material.isMeshStandardMaterial || material.isShadowMaterial ||
1906
+ ( material.isShaderMaterial && material.lights === true );
1850
1907
 
1851
- function materialNeedsLights( material ) {
1908
+ }
1852
1909
 
1853
- return material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial ||
1854
- material.isMeshStandardMaterial || material.isShadowMaterial ||
1855
- ( material.isShaderMaterial && material.lights === true );
1910
+ this.setTexture2D = ( function () {
1856
1911
 
1857
- }
1912
+ var warned = false;
1858
1913
 
1859
- this.setTexture2D = ( function () {
1914
+ // backwards compatibility: peel texture.texture
1915
+ return function setTexture2D( texture, slot ) {
1860
1916
 
1861
- var warned = false;
1917
+ if ( texture && texture.isWebGLRenderTarget ) {
1862
1918
 
1863
- // backwards compatibility: peel texture.texture
1864
- return function setTexture2D( texture, slot ) {
1919
+ if ( ! warned ) {
1865
1920
 
1866
- if ( texture && texture.isWebGLRenderTarget ) {
1921
+ console.warn( "THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead." );
1922
+ warned = true;
1867
1923
 
1868
- if ( ! warned ) {
1924
+ }
1869
1925
 
1870
- console.warn( "THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead." );
1871
- warned = true;
1926
+ texture = texture.texture;
1872
1927
 
1873
1928
  }
1874
1929
 
1875
- texture = texture.texture;
1930
+ textures.setTexture2D( texture, slot );
1876
1931
 
1877
- }
1878
-
1879
- textures.setTexture2D( texture, slot );
1932
+ };
1880
1933
 
1881
- };
1934
+ }() );
1882
1935
 
1883
- }() );
1936
+ this.getActiveCubeFace = function () {
1884
1937
 
1885
- this.getActiveCubeFace = function () {
1938
+ return _currentActiveCubeFace;
1886
1939
 
1887
- return _currentActiveCubeFace;
1940
+ };
1888
1941
 
1889
- };
1942
+ this.getActiveMipmapLevel = function () {
1890
1943
 
1891
- this.getActiveMipmapLevel = function () {
1944
+ return _currentActiveMipmapLevel;
1892
1945
 
1893
- return _currentActiveMipmapLevel;
1946
+ };
1894
1947
 
1895
- };
1948
+ this.getRenderTarget = function () {
1896
1949
 
1897
- this.getRenderTarget = function () {
1950
+ return _currentRenderTarget;
1898
1951
 
1899
- return _currentRenderTarget;
1952
+ };
1900
1953
 
1901
- };
1954
+ this.setRenderTargetTextures = function ( renderTarget, colorTexture, depthTexture ) {
1902
1955
 
1903
- this.setRenderTargetTextures = function ( renderTarget, colorTexture, depthTexture ) {
1956
+ properties.get( renderTarget.texture ).__webglTexture = colorTexture;
1957
+ properties.get( renderTarget.depthTexture ).__webglTexture = depthTexture;
1904
1958
 
1905
- properties.get( renderTarget.texture ).__webglTexture = colorTexture;
1906
- properties.get( renderTarget.depthTexture ).__webglTexture = depthTexture;
1959
+ const renderTargetProperties = properties.get( renderTarget );
1960
+ renderTargetProperties.__hasExternalTextures = true;
1907
1961
 
1908
- const renderTargetProperties = properties.get( renderTarget );
1909
- renderTargetProperties.__hasExternalTextures = true;
1962
+ if ( renderTargetProperties.__hasExternalTextures ) {
1910
1963
 
1911
- if ( renderTargetProperties.__hasExternalTextures ) {
1964
+ renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
1912
1965
 
1913
- renderTargetProperties.__autoAllocateDepthBuffer = depthTexture === undefined;
1966
+ if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
1914
1967
 
1915
- if ( ! renderTargetProperties.__autoAllocateDepthBuffer ) {
1968
+ // The multisample_render_to_texture extension doesn't work properly if there
1969
+ // are midframe flushes and an external depth buffer. Disable use of the extension.
1970
+ if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
1916
1971
 
1917
- // The multisample_render_to_texture extension doesn't work properly if there
1918
- // are midframe flushes and an external depth buffer. Disable use of the extension.
1919
- if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) {
1972
+ console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
1973
+ renderTargetProperties.__useRenderToTexture = false;
1920
1974
 
1921
- console.warn( 'THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided' );
1922
- renderTargetProperties.__useRenderToTexture = false;
1975
+ }
1923
1976
 
1924
1977
  }
1925
1978
 
1926
1979
  }
1927
1980
 
1928
- }
1981
+ };
1982
+
1983
+ this.setRenderTargetFramebuffer = function ( renderTarget, defaultFramebuffer ) {
1984
+
1985
+ const renderTargetProperties = properties.get( renderTarget );
1986
+ renderTargetProperties.__webglFramebuffer = defaultFramebuffer;
1987
+ renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined;
1929
1988
 
1930
- };
1989
+ };
1931
1990
 
1932
- this.setRenderTargetFramebuffer = function ( renderTarget, defaultFramebuffer ) {
1991
+ this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
1933
1992
 
1934
- const renderTargetProperties = properties.get( renderTarget );
1935
- renderTargetProperties.__webglFramebuffer = defaultFramebuffer;
1936
- renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined;
1993
+ _currentRenderTarget = renderTarget;
1994
+ _currentActiveCubeFace = activeCubeFace;
1995
+ _currentActiveMipmapLevel = activeMipmapLevel;
1937
1996
 
1938
- };
1997
+ let useDefaultFramebuffer = true;
1998
+ let framebuffer = null;
1999
+ let isCube = false;
2000
+ let isRenderTarget3D = false;
1939
2001
 
1940
- this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
2002
+ if ( renderTarget ) {
1941
2003
 
1942
- _currentRenderTarget = renderTarget;
1943
- _currentActiveCubeFace = activeCubeFace;
1944
- _currentActiveMipmapLevel = activeMipmapLevel;
2004
+ const renderTargetProperties = properties.get( renderTarget );
1945
2005
 
1946
- let useDefaultFramebuffer = true;
1947
- let framebuffer = null;
1948
- let isCube = false;
1949
- let isRenderTarget3D = false;
2006
+ if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) {
1950
2007
 
1951
- if ( renderTarget ) {
2008
+ // We need to make sure to rebind the framebuffer.
2009
+ state.bindFramebuffer( _gl.FRAMEBUFFER, null );
2010
+ useDefaultFramebuffer = false;
1952
2011
 
1953
- const renderTargetProperties = properties.get( renderTarget );
2012
+ } else if ( renderTargetProperties.__webglFramebuffer === undefined ) {
1954
2013
 
1955
- if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) {
2014
+ textures.setupRenderTarget( renderTarget );
1956
2015
 
1957
- // We need to make sure to rebind the framebuffer.
1958
- state.bindFramebuffer( _gl.FRAMEBUFFER, null );
1959
- useDefaultFramebuffer = false;
2016
+ } else if ( renderTargetProperties.__hasExternalTextures ) {
1960
2017
 
1961
- } else if ( renderTargetProperties.__webglFramebuffer === undefined ) {
2018
+ // Color and depth texture must be rebound in order for the swapchain to update.
2019
+ textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
1962
2020
 
1963
- textures.setupRenderTarget( renderTarget );
2021
+ }
1964
2022
 
1965
- } else if ( renderTargetProperties.__hasExternalTextures ) {
2023
+ const texture = renderTarget.texture;
1966
2024
 
1967
- // Color and depth texture must be rebound in order for the swapchain to update.
1968
- textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
2025
+ if ( texture.isData3DTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
1969
2026
 
1970
- }
2027
+ isRenderTarget3D = true;
1971
2028
 
1972
- const texture = renderTarget.texture;
2029
+ }
1973
2030
 
1974
- if ( texture.isData3DTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
2031
+ const __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer;
1975
2032
 
1976
- isRenderTarget3D = true;
2033
+ if ( renderTarget.isWebGLCubeRenderTarget ) {
1977
2034
 
1978
- }
2035
+ framebuffer = __webglFramebuffer[ activeCubeFace ];
2036
+ isCube = true;
2037
+
2038
+ } else if ( ( capabilities.isWebGL2 && renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
1979
2039
 
1980
- const __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer;
2040
+ framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;
1981
2041
 
1982
- if ( renderTarget.isWebGLCubeRenderTarget ) {
2042
+ } else {
1983
2043
 
1984
- framebuffer = __webglFramebuffer[ activeCubeFace ];
1985
- isCube = true;
2044
+ framebuffer = __webglFramebuffer;
1986
2045
 
1987
- } else if ( ( capabilities.isWebGL2 && renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
2046
+ }
1988
2047
 
1989
- framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;
2048
+ _currentViewport.copy( renderTarget.viewport );
2049
+ _currentScissor.copy( renderTarget.scissor );
2050
+ _currentScissorTest = renderTarget.scissorTest;
1990
2051
 
1991
2052
  } else {
1992
2053
 
1993
- framebuffer = __webglFramebuffer;
2054
+ _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor();
2055
+ _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor();
2056
+ _currentScissorTest = _scissorTest;
1994
2057
 
1995
2058
  }
1996
2059
 
1997
- _currentViewport.copy( renderTarget.viewport );
1998
- _currentScissor.copy( renderTarget.scissor );
1999
- _currentScissorTest = renderTarget.scissorTest;
2060
+ const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2000
2061
 
2001
- } else {
2062
+ if ( framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer ) {
2002
2063
 
2003
- _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor();
2004
- _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor();
2005
- _currentScissorTest = _scissorTest;
2064
+ state.drawBuffers( renderTarget, framebuffer );
2006
2065
 
2007
- }
2066
+ }
2008
2067
 
2009
- const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2068
+ state.viewport( _currentViewport );
2069
+ state.scissor( _currentScissor );
2070
+ state.setScissorTest( _currentScissorTest );
2010
2071
 
2011
- if ( framebufferBound && capabilities.drawBuffers && useDefaultFramebuffer ) {
2072
+ if ( isCube ) {
2012
2073
 
2013
- state.drawBuffers( renderTarget, framebuffer );
2074
+ const textureProperties = properties.get( renderTarget.texture );
2075
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + activeCubeFace, textureProperties.__webglTexture, activeMipmapLevel );
2014
2076
 
2015
- }
2077
+ } else if ( isRenderTarget3D ) {
2016
2078
 
2017
- state.viewport( _currentViewport );
2018
- state.scissor( _currentScissor );
2019
- state.setScissorTest( _currentScissorTest );
2079
+ const textureProperties = properties.get( renderTarget.texture );
2080
+ const layer = activeCubeFace || 0;
2081
+ _gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, activeMipmapLevel || 0, layer );
2020
2082
 
2021
- if ( isCube ) {
2083
+ }
2022
2084
 
2023
- const textureProperties = properties.get( renderTarget.texture );
2024
- _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + activeCubeFace, textureProperties.__webglTexture, activeMipmapLevel );
2085
+ _currentMaterialId = - 1; // reset current material to ensure correct uniform bindings
2025
2086
 
2026
- } else if ( isRenderTarget3D ) {
2087
+ };
2027
2088
 
2028
- const textureProperties = properties.get( renderTarget.texture );
2029
- const layer = activeCubeFace || 0;
2030
- _gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, textureProperties.__webglTexture, activeMipmapLevel || 0, layer );
2089
+ this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
2031
2090
 
2032
- }
2091
+ if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
2033
2092
 
2034
- _currentMaterialId = - 1; // reset current material to ensure correct uniform bindings
2093
+ console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
2094
+ return;
2035
2095
 
2036
- };
2096
+ }
2037
2097
 
2038
- this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {
2098
+ let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
2039
2099
 
2040
- if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
2100
+ if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {
2041
2101
 
2042
- console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
2043
- return;
2102
+ framebuffer = framebuffer[ activeCubeFaceIndex ];
2044
2103
 
2045
- }
2104
+ }
2046
2105
 
2047
- let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
2106
+ if ( framebuffer ) {
2048
2107
 
2049
- if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {
2108
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2050
2109
 
2051
- framebuffer = framebuffer[ activeCubeFaceIndex ];
2110
+ try {
2052
2111
 
2053
- }
2112
+ const texture = renderTarget.texture;
2113
+ const textureFormat = texture.format;
2114
+ const textureType = texture.type;
2054
2115
 
2055
- if ( framebuffer ) {
2116
+ if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {
2056
2117
 
2057
- state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2118
+ console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
2119
+ return;
2058
2120
 
2059
- try {
2121
+ }
2060
2122
 
2061
- const texture = renderTarget.texture;
2062
- const textureFormat = texture.format;
2063
- const textureType = texture.type;
2123
+ const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || ( capabilities.isWebGL2 && extensions.has( 'EXT_color_buffer_float' ) ) );
2064
2124
 
2065
- if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {
2125
+ if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
2126
+ ! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.has( 'OES_texture_float' ) || extensions.has( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox
2127
+ ! halfFloatSupportedByExt ) {
2066
2128
 
2067
- console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
2068
- return;
2129
+ console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
2130
+ return;
2069
2131
 
2070
- }
2132
+ }
2071
2133
 
2072
- const halfFloatSupportedByExt = ( textureType === HalfFloatType ) && ( extensions.has( 'EXT_color_buffer_half_float' ) || ( capabilities.isWebGL2 && extensions.has( 'EXT_color_buffer_float' ) ) );
2134
+ // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
2073
2135
 
2074
- if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // Edge and Chrome Mac < 52 (#9513)
2075
- ! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.has( 'OES_texture_float' ) || extensions.has( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox
2076
- ! halfFloatSupportedByExt ) {
2136
+ if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
2077
2137
 
2078
- console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
2079
- return;
2138
+ _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );
2080
2139
 
2081
- }
2140
+ }
2082
2141
 
2083
- // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
2142
+ } finally {
2084
2143
 
2085
- if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
2144
+ // restore framebuffer of current render target if necessary
2086
2145
 
2087
- _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );
2146
+ const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
2147
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2088
2148
 
2089
2149
  }
2090
2150
 
2091
- } finally {
2151
+ }
2092
2152
 
2093
- // restore framebuffer of current render target if necessary
2153
+ };
2094
2154
 
2095
- const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
2096
- state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2155
+ this.copyFramebufferToTexture = function ( position, texture, level = 0 ) {
2097
2156
 
2098
- }
2157
+ const levelScale = Math.pow( 2, - level );
2158
+ const width = Math.floor( texture.image.width * levelScale );
2159
+ const height = Math.floor( texture.image.height * levelScale );
2099
2160
 
2100
- }
2161
+ textures.setTexture2D( texture, 0 );
2101
2162
 
2102
- };
2163
+ _gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, position.x, position.y, width, height );
2103
2164
 
2104
- this.copyFramebufferToTexture = function ( position, texture, level = 0 ) {
2165
+ state.unbindTexture();
2105
2166
 
2106
- const levelScale = Math.pow( 2, - level );
2107
- const width = Math.floor( texture.image.width * levelScale );
2108
- const height = Math.floor( texture.image.height * levelScale );
2167
+ };
2109
2168
 
2110
- textures.setTexture2D( texture, 0 );
2169
+ this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level = 0 ) {
2111
2170
 
2112
- _gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, position.x, position.y, width, height );
2171
+ const width = srcTexture.image.width;
2172
+ const height = srcTexture.image.height;
2173
+ const glFormat = utils.convert( dstTexture.format );
2174
+ const glType = utils.convert( dstTexture.type );
2113
2175
 
2114
- state.unbindTexture();
2176
+ textures.setTexture2D( dstTexture, 0 );
2115
2177
 
2116
- };
2178
+ // As another texture upload may have changed pixelStorei
2179
+ // parameters, make sure they are correct for the dstTexture
2180
+ _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
2181
+ _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
2182
+ _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
2117
2183
 
2118
- this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level = 0 ) {
2184
+ if ( srcTexture.isDataTexture ) {
2119
2185
 
2120
- const width = srcTexture.image.width;
2121
- const height = srcTexture.image.height;
2122
- const glFormat = utils.convert( dstTexture.format );
2123
- const glType = utils.convert( dstTexture.type );
2186
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );
2124
2187
 
2125
- textures.setTexture2D( dstTexture, 0 );
2188
+ } else {
2126
2189
 
2127
- // As another texture upload may have changed pixelStorei
2128
- // parameters, make sure they are correct for the dstTexture
2129
- _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
2130
- _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
2131
- _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
2190
+ if ( srcTexture.isCompressedTexture ) {
2132
2191
 
2133
- if ( srcTexture.isDataTexture ) {
2192
+ _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );
2134
2193
 
2135
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );
2194
+ } else {
2136
2195
 
2137
- } else {
2196
+ _gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );
2138
2197
 
2139
- if ( srcTexture.isCompressedTexture ) {
2198
+ }
2199
+
2200
+ }
2140
2201
 
2141
- _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );
2202
+ // Generate mipmaps only when copying level 0
2203
+ if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
2142
2204
 
2143
- } else {
2205
+ state.unbindTexture();
2206
+
2207
+ };
2208
+
2209
+ this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) {
2144
2210
 
2145
- _gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );
2211
+ if ( _this.isWebGL1Renderer ) {
2212
+
2213
+ console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.' );
2214
+ return;
2146
2215
 
2147
2216
  }
2148
2217
 
2149
- }
2218
+ const width = sourceBox.max.x - sourceBox.min.x + 1;
2219
+ const height = sourceBox.max.y - sourceBox.min.y + 1;
2220
+ const depth = sourceBox.max.z - sourceBox.min.z + 1;
2221
+ const glFormat = utils.convert( dstTexture.format );
2222
+ const glType = utils.convert( dstTexture.type );
2223
+ let glTarget;
2150
2224
 
2151
- // Generate mipmaps only when copying level 0
2152
- if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );
2225
+ if ( dstTexture.isData3DTexture ) {
2153
2226
 
2154
- state.unbindTexture();
2227
+ textures.setTexture3D( dstTexture, 0 );
2228
+ glTarget = _gl.TEXTURE_3D;
2155
2229
 
2156
- };
2230
+ } else if ( dstTexture.isDataArrayTexture ) {
2157
2231
 
2158
- this.copyTextureToTexture3D = function ( sourceBox, position, srcTexture, dstTexture, level = 0 ) {
2232
+ textures.setTexture2DArray( dstTexture, 0 );
2233
+ glTarget = _gl.TEXTURE_2D_ARRAY;
2159
2234
 
2160
- if ( _this.isWebGL1Renderer ) {
2235
+ } else {
2161
2236
 
2162
- console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.' );
2163
- return;
2237
+ console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.' );
2238
+ return;
2164
2239
 
2165
- }
2240
+ }
2166
2241
 
2167
- const width = sourceBox.max.x - sourceBox.min.x + 1;
2168
- const height = sourceBox.max.y - sourceBox.min.y + 1;
2169
- const depth = sourceBox.max.z - sourceBox.min.z + 1;
2170
- const glFormat = utils.convert( dstTexture.format );
2171
- const glType = utils.convert( dstTexture.type );
2172
- let glTarget;
2242
+ _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
2243
+ _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
2244
+ _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
2173
2245
 
2174
- if ( dstTexture.isData3DTexture ) {
2246
+ const unpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
2247
+ const unpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
2248
+ const unpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
2249
+ const unpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
2250
+ const unpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
2175
2251
 
2176
- textures.setTexture3D( dstTexture, 0 );
2177
- glTarget = _gl.TEXTURE_3D;
2252
+ const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ 0 ] : srcTexture.image;
2178
2253
 
2179
- } else if ( dstTexture.isDataArrayTexture ) {
2254
+ _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
2255
+ _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
2256
+ _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, sourceBox.min.x );
2257
+ _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, sourceBox.min.y );
2258
+ _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, sourceBox.min.z );
2180
2259
 
2181
- textures.setTexture2DArray( dstTexture, 0 );
2182
- glTarget = _gl.TEXTURE_2D_ARRAY;
2260
+ if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
2183
2261
 
2184
- } else {
2262
+ _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image.data );
2185
2263
 
2186
- console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.' );
2187
- return;
2264
+ } else {
2188
2265
 
2189
- }
2266
+ if ( srcTexture.isCompressedArrayTexture ) {
2190
2267
 
2191
- _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
2192
- _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
2193
- _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
2268
+ console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.' );
2269
+ _gl.compressedTexSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data );
2194
2270
 
2195
- const unpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
2196
- const unpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
2197
- const unpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
2198
- const unpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
2199
- const unpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
2271
+ } else {
2200
2272
 
2201
- const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ 0 ] : srcTexture.image;
2273
+ _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image );
2202
2274
 
2203
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
2204
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
2205
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, sourceBox.min.x );
2206
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, sourceBox.min.y );
2207
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, sourceBox.min.z );
2275
+ }
2208
2276
 
2209
- if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
2277
+ }
2210
2278
 
2211
- _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image.data );
2279
+ _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, unpackRowLen );
2280
+ _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, unpackImageHeight );
2281
+ _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, unpackSkipPixels );
2282
+ _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, unpackSkipRows );
2283
+ _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, unpackSkipImages );
2212
2284
 
2213
- } else {
2285
+ // Generate mipmaps only when copying level 0
2286
+ if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
2214
2287
 
2215
- if ( srcTexture.isCompressedArrayTexture ) {
2288
+ state.unbindTexture();
2216
2289
 
2217
- console.warn( 'THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.' );
2218
- _gl.compressedTexSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, image.data );
2290
+ };
2219
2291
 
2220
- } else {
2292
+ this.initTexture = function ( texture ) {
2221
2293
 
2222
- _gl.texSubImage3D( glTarget, level, position.x, position.y, position.z, width, height, depth, glFormat, glType, image );
2294
+ if ( texture.isCubeTexture ) {
2223
2295
 
2224
- }
2296
+ textures.setTextureCube( texture, 0 );
2225
2297
 
2226
- }
2298
+ } else if ( texture.isData3DTexture ) {
2227
2299
 
2228
- _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, unpackRowLen );
2229
- _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, unpackImageHeight );
2230
- _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, unpackSkipPixels );
2231
- _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, unpackSkipRows );
2232
- _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, unpackSkipImages );
2300
+ textures.setTexture3D( texture, 0 );
2233
2301
 
2234
- // Generate mipmaps only when copying level 0
2235
- if ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( glTarget );
2302
+ } else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
2236
2303
 
2237
- state.unbindTexture();
2304
+ textures.setTexture2DArray( texture, 0 );
2238
2305
 
2239
- };
2306
+ } else {
2307
+
2308
+ textures.setTexture2D( texture, 0 );
2240
2309
 
2241
- this.initTexture = function ( texture ) {
2310
+ }
2242
2311
 
2243
- if ( texture.isCubeTexture ) {
2312
+ state.unbindTexture();
2244
2313
 
2245
- textures.setTextureCube( texture, 0 );
2314
+ };
2246
2315
 
2247
- } else if ( texture.isData3DTexture ) {
2316
+ this.resetState = function () {
2248
2317
 
2249
- textures.setTexture3D( texture, 0 );
2318
+ _currentActiveCubeFace = 0;
2319
+ _currentActiveMipmapLevel = 0;
2320
+ _currentRenderTarget = null;
2250
2321
 
2251
- } else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
2322
+ state.reset();
2323
+ bindingStates.reset();
2252
2324
 
2253
- textures.setTexture2DArray( texture, 0 );
2325
+ };
2254
2326
 
2255
- } else {
2327
+ if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
2256
2328
 
2257
- textures.setTexture2D( texture, 0 );
2329
+ __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
2258
2330
 
2259
2331
  }
2260
2332
 
2261
- state.unbindTexture();
2333
+ }
2262
2334
 
2263
- };
2335
+ get physicallyCorrectLights() { // @deprecated, r150
2264
2336
 
2265
- this.resetState = function () {
2337
+ console.warn( 'THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
2338
+ return ! this.useLegacyLights;
2266
2339
 
2267
- _currentActiveCubeFace = 0;
2268
- _currentActiveMipmapLevel = 0;
2269
- _currentRenderTarget = null;
2340
+ }
2270
2341
 
2271
- state.reset();
2272
- bindingStates.reset();
2342
+ set physicallyCorrectLights( value ) { // @deprecated, r150
2273
2343
 
2274
- };
2344
+ console.warn( 'THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
2345
+ this.useLegacyLights = ! value;
2275
2346
 
2276
- if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
2347
+ }
2277
2348
 
2278
- __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
2349
+ get outputEncoding() { // @deprecated, r152
2350
+
2351
+ console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
2352
+ return this.outputColorSpace === SRGBColorSpace ? sRGBEncoding : LinearEncoding;
2353
+
2354
+ }
2355
+
2356
+ set outputEncoding( encoding ) { // @deprecated, r152
2357
+
2358
+ console.warn( 'THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.' );
2359
+ this.outputColorSpace = encoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
2279
2360
 
2280
2361
  }
2281
2362
 
2282
2363
  }
2283
2364
 
2365
+
2284
2366
  export { WebGLRenderer };