vc-spaces365-threejs 0.180.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 (1120) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -0
  3. package/build/three.cjs +77750 -0
  4. package/build/three.core.js +58846 -0
  5. package/build/three.core.min.js +6 -0
  6. package/build/three.module.js +18484 -0
  7. package/build/three.module.min.js +6 -0
  8. package/build/three.tsl.js +636 -0
  9. package/build/three.tsl.min.js +6 -0
  10. package/build/three.webgpu.js +77332 -0
  11. package/build/three.webgpu.min.js +6 -0
  12. package/build/three.webgpu.nodes.js +77103 -0
  13. package/build/three.webgpu.nodes.min.js +6 -0
  14. package/examples/fonts/LICENSE +13 -0
  15. package/examples/fonts/README.md +11 -0
  16. package/examples/fonts/droid/NOTICE +190 -0
  17. package/examples/fonts/droid/README.txt +18 -0
  18. package/examples/fonts/droid/droid_sans_bold.typeface.json +1 -0
  19. package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +1 -0
  20. package/examples/fonts/droid/droid_sans_regular.typeface.json +1 -0
  21. package/examples/fonts/droid/droid_serif_bold.typeface.json +1 -0
  22. package/examples/fonts/droid/droid_serif_regular.typeface.json +1 -0
  23. package/examples/fonts/gentilis_bold.typeface.json +1 -0
  24. package/examples/fonts/gentilis_regular.typeface.json +1 -0
  25. package/examples/fonts/helvetiker_bold.typeface.json +1 -0
  26. package/examples/fonts/helvetiker_regular.typeface.json +1 -0
  27. package/examples/fonts/optimer_bold.typeface.json +1 -0
  28. package/examples/fonts/optimer_regular.typeface.json +1 -0
  29. package/examples/fonts/ttf/README.md +9 -0
  30. package/examples/fonts/ttf/kenpixel.ttf +0 -0
  31. package/examples/jsm/Addons.js +285 -0
  32. package/examples/jsm/animation/AnimationClipCreator.js +168 -0
  33. package/examples/jsm/animation/CCDIKSolver.js +591 -0
  34. package/examples/jsm/capabilities/WebGL.js +113 -0
  35. package/examples/jsm/capabilities/WebGPU.js +59 -0
  36. package/examples/jsm/controls/ArcballControls.js +3536 -0
  37. package/examples/jsm/controls/DragControls.js +452 -0
  38. package/examples/jsm/controls/FirstPersonControls.js +447 -0
  39. package/examples/jsm/controls/FlyControls.js +380 -0
  40. package/examples/jsm/controls/MapControls.js +62 -0
  41. package/examples/jsm/controls/OrbitControls.js +1860 -0
  42. package/examples/jsm/controls/PointerLockControls.js +264 -0
  43. package/examples/jsm/controls/TrackballControls.js +1001 -0
  44. package/examples/jsm/controls/TransformControls.js +1918 -0
  45. package/examples/jsm/csm/CSM.js +597 -0
  46. package/examples/jsm/csm/CSMFrustum.js +209 -0
  47. package/examples/jsm/csm/CSMHelper.js +243 -0
  48. package/examples/jsm/csm/CSMShader.js +307 -0
  49. package/examples/jsm/csm/CSMShadowNode.js +599 -0
  50. package/examples/jsm/curves/CurveExtras.js +694 -0
  51. package/examples/jsm/curves/NURBSCurve.js +155 -0
  52. package/examples/jsm/curves/NURBSSurface.js +98 -0
  53. package/examples/jsm/curves/NURBSUtils.js +532 -0
  54. package/examples/jsm/curves/NURBSVolume.js +82 -0
  55. package/examples/jsm/effects/AnaglyphEffect.js +179 -0
  56. package/examples/jsm/effects/AsciiEffect.js +310 -0
  57. package/examples/jsm/effects/OutlineEffect.js +489 -0
  58. package/examples/jsm/effects/ParallaxBarrierEffect.js +155 -0
  59. package/examples/jsm/effects/StereoEffect.js +91 -0
  60. package/examples/jsm/environments/DebugEnvironment.js +102 -0
  61. package/examples/jsm/environments/RoomEnvironment.js +182 -0
  62. package/examples/jsm/exporters/DRACOExporter.js +311 -0
  63. package/examples/jsm/exporters/EXRExporter.js +618 -0
  64. package/examples/jsm/exporters/GLTFExporter.js +3595 -0
  65. package/examples/jsm/exporters/KTX2Exporter.js +347 -0
  66. package/examples/jsm/exporters/OBJExporter.js +308 -0
  67. package/examples/jsm/exporters/PLYExporter.js +562 -0
  68. package/examples/jsm/exporters/STLExporter.js +221 -0
  69. package/examples/jsm/exporters/USDZExporter.js +1228 -0
  70. package/examples/jsm/geometries/BoxLineGeometry.js +92 -0
  71. package/examples/jsm/geometries/ConvexGeometry.js +72 -0
  72. package/examples/jsm/geometries/DecalGeometry.js +420 -0
  73. package/examples/jsm/geometries/ParametricFunctions.js +100 -0
  74. package/examples/jsm/geometries/ParametricGeometry.js +172 -0
  75. package/examples/jsm/geometries/RoundedBoxGeometry.js +216 -0
  76. package/examples/jsm/geometries/TeapotGeometry.js +689 -0
  77. package/examples/jsm/geometries/TextGeometry.js +83 -0
  78. package/examples/jsm/helpers/LightProbeHelper.js +165 -0
  79. package/examples/jsm/helpers/LightProbeHelperGPU.js +102 -0
  80. package/examples/jsm/helpers/OctreeHelper.js +109 -0
  81. package/examples/jsm/helpers/PositionalAudioHelper.js +169 -0
  82. package/examples/jsm/helpers/RapierHelper.js +59 -0
  83. package/examples/jsm/helpers/RectAreaLightHelper.js +118 -0
  84. package/examples/jsm/helpers/TextureHelper.js +265 -0
  85. package/examples/jsm/helpers/TextureHelperGPU.js +214 -0
  86. package/examples/jsm/helpers/VertexNormalsHelper.js +155 -0
  87. package/examples/jsm/helpers/VertexTangentsHelper.js +133 -0
  88. package/examples/jsm/helpers/ViewHelper.js +422 -0
  89. package/examples/jsm/interactive/HTMLMesh.js +605 -0
  90. package/examples/jsm/interactive/InteractiveGroup.js +224 -0
  91. package/examples/jsm/interactive/SelectionBox.js +294 -0
  92. package/examples/jsm/interactive/SelectionHelper.js +150 -0
  93. package/examples/jsm/libs/ammo.wasm.js +822 -0
  94. package/examples/jsm/libs/ammo.wasm.wasm +0 -0
  95. package/examples/jsm/libs/basis/README.md +46 -0
  96. package/examples/jsm/libs/basis/basis_transcoder.js +19 -0
  97. package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
  98. package/examples/jsm/libs/chevrotain.module.min.js +141 -0
  99. package/examples/jsm/libs/demuxer_mp4.js +109 -0
  100. package/examples/jsm/libs/draco/README.md +32 -0
  101. package/examples/jsm/libs/draco/draco_decoder.js +34 -0
  102. package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
  103. package/examples/jsm/libs/draco/draco_encoder.js +33 -0
  104. package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
  105. package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
  106. package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
  107. package/examples/jsm/libs/draco/gltf/draco_encoder.js +33 -0
  108. package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
  109. package/examples/jsm/libs/ecsy.module.js +1792 -0
  110. package/examples/jsm/libs/fflate.module.js +2672 -0
  111. package/examples/jsm/libs/ktx-parse.module.js +1 -0
  112. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  113. package/examples/jsm/libs/lottie_canvas.module.js +14849 -0
  114. package/examples/jsm/libs/meshopt_decoder.module.js +195 -0
  115. package/examples/jsm/libs/mikktspace.module.js +128 -0
  116. package/examples/jsm/libs/motion-controllers.module.js +397 -0
  117. package/examples/jsm/libs/opentype.module.js +14506 -0
  118. package/examples/jsm/libs/potpack.module.js +125 -0
  119. package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -0
  120. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +16 -0
  121. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  122. package/examples/jsm/libs/stats.module.js +167 -0
  123. package/examples/jsm/libs/surfaceNet.js +201 -0
  124. package/examples/jsm/libs/tween.module.js +876 -0
  125. package/examples/jsm/libs/utif.module.js +1665 -0
  126. package/examples/jsm/libs/zstddec.module.js +1 -0
  127. package/examples/jsm/lighting/TiledLighting.js +42 -0
  128. package/examples/jsm/lights/LightProbeGenerator.js +337 -0
  129. package/examples/jsm/lights/RectAreaLightTexturesLib.js +127 -0
  130. package/examples/jsm/lights/RectAreaLightUniformsLib.js +40 -0
  131. package/examples/jsm/lines/Line2.js +56 -0
  132. package/examples/jsm/lines/LineGeometry.js +157 -0
  133. package/examples/jsm/lines/LineMaterial.js +697 -0
  134. package/examples/jsm/lines/LineSegments2.js +426 -0
  135. package/examples/jsm/lines/LineSegmentsGeometry.js +298 -0
  136. package/examples/jsm/lines/Wireframe.js +108 -0
  137. package/examples/jsm/lines/WireframeGeometry2.js +49 -0
  138. package/examples/jsm/lines/webgpu/Line2.js +46 -0
  139. package/examples/jsm/lines/webgpu/LineSegments2.js +411 -0
  140. package/examples/jsm/lines/webgpu/Wireframe.js +86 -0
  141. package/examples/jsm/loaders/3DMLoader.js +1835 -0
  142. package/examples/jsm/loaders/3MFLoader.js +1621 -0
  143. package/examples/jsm/loaders/AMFLoader.js +541 -0
  144. package/examples/jsm/loaders/BVHLoader.js +484 -0
  145. package/examples/jsm/loaders/ColladaLoader.js +4155 -0
  146. package/examples/jsm/loaders/DDSLoader.js +385 -0
  147. package/examples/jsm/loaders/DRACOLoader.js +688 -0
  148. package/examples/jsm/loaders/EXRLoader.js +2784 -0
  149. package/examples/jsm/loaders/FBXLoader.js +4382 -0
  150. package/examples/jsm/loaders/FontLoader.js +242 -0
  151. package/examples/jsm/loaders/GCodeLoader.js +292 -0
  152. package/examples/jsm/loaders/GLTFLoader.js +4890 -0
  153. package/examples/jsm/loaders/HDRCubeTextureLoader.js +164 -0
  154. package/examples/jsm/loaders/HDRLoader.js +486 -0
  155. package/examples/jsm/loaders/IESLoader.js +379 -0
  156. package/examples/jsm/loaders/KMZLoader.js +163 -0
  157. package/examples/jsm/loaders/KTX2Loader.js +1228 -0
  158. package/examples/jsm/loaders/KTXLoader.js +197 -0
  159. package/examples/jsm/loaders/LDrawLoader.js +2519 -0
  160. package/examples/jsm/loaders/LUT3dlLoader.js +205 -0
  161. package/examples/jsm/loaders/LUTCubeLoader.js +190 -0
  162. package/examples/jsm/loaders/LUTImageLoader.js +190 -0
  163. package/examples/jsm/loaders/LWOLoader.js +1079 -0
  164. package/examples/jsm/loaders/LottieLoader.js +130 -0
  165. package/examples/jsm/loaders/MD2Loader.js +435 -0
  166. package/examples/jsm/loaders/MDDLoader.js +147 -0
  167. package/examples/jsm/loaders/MTLLoader.js +593 -0
  168. package/examples/jsm/loaders/MaterialXLoader.js +1087 -0
  169. package/examples/jsm/loaders/NRRDLoader.js +718 -0
  170. package/examples/jsm/loaders/OBJLoader.js +955 -0
  171. package/examples/jsm/loaders/PCDLoader.js +618 -0
  172. package/examples/jsm/loaders/PDBLoader.js +272 -0
  173. package/examples/jsm/loaders/PLYLoader.js +805 -0
  174. package/examples/jsm/loaders/PVRLoader.js +270 -0
  175. package/examples/jsm/loaders/RGBELoader.js +18 -0
  176. package/examples/jsm/loaders/STLLoader.js +421 -0
  177. package/examples/jsm/loaders/SVGLoader.js +3267 -0
  178. package/examples/jsm/loaders/TDSLoader.js +1144 -0
  179. package/examples/jsm/loaders/TGALoader.js +540 -0
  180. package/examples/jsm/loaders/TIFFLoader.js +59 -0
  181. package/examples/jsm/loaders/TTFLoader.js +261 -0
  182. package/examples/jsm/loaders/USDLoader.js +219 -0
  183. package/examples/jsm/loaders/USDZLoader.js +16 -0
  184. package/examples/jsm/loaders/UltraHDRLoader.js +630 -0
  185. package/examples/jsm/loaders/VOXLoader.js +376 -0
  186. package/examples/jsm/loaders/VRMLLoader.js +3569 -0
  187. package/examples/jsm/loaders/VTKLoader.js +1276 -0
  188. package/examples/jsm/loaders/XYZLoader.js +143 -0
  189. package/examples/jsm/loaders/lwo/IFFParser.js +1217 -0
  190. package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
  191. package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
  192. package/examples/jsm/loaders/usd/USDAParser.js +741 -0
  193. package/examples/jsm/loaders/usd/USDCParser.js +17 -0
  194. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +183 -0
  195. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +154 -0
  196. package/examples/jsm/materials/MeshGouraudMaterial.js +434 -0
  197. package/examples/jsm/materials/MeshPostProcessingMaterial.js +167 -0
  198. package/examples/jsm/materials/WoodNodeMaterial.js +533 -0
  199. package/examples/jsm/math/Capsule.js +159 -0
  200. package/examples/jsm/math/ColorConverter.js +58 -0
  201. package/examples/jsm/math/ColorSpaces.js +147 -0
  202. package/examples/jsm/math/ConvexHull.js +1695 -0
  203. package/examples/jsm/math/ImprovedNoise.js +88 -0
  204. package/examples/jsm/math/Lut.js +317 -0
  205. package/examples/jsm/math/MeshSurfaceSampler.js +315 -0
  206. package/examples/jsm/math/OBB.js +535 -0
  207. package/examples/jsm/math/Octree.js +692 -0
  208. package/examples/jsm/math/SimplexNoise.js +470 -0
  209. package/examples/jsm/misc/ConvexObjectBreaker.js +539 -0
  210. package/examples/jsm/misc/GPUComputationRenderer.js +506 -0
  211. package/examples/jsm/misc/Gyroscope.js +78 -0
  212. package/examples/jsm/misc/MD2Character.js +391 -0
  213. package/examples/jsm/misc/MD2CharacterComplex.js +740 -0
  214. package/examples/jsm/misc/MorphAnimMesh.js +119 -0
  215. package/examples/jsm/misc/MorphBlendMesh.js +425 -0
  216. package/examples/jsm/misc/ProgressiveLightMap.js +370 -0
  217. package/examples/jsm/misc/ProgressiveLightMapGPU.js +322 -0
  218. package/examples/jsm/misc/RollerCoaster.js +623 -0
  219. package/examples/jsm/misc/TubePainter.js +256 -0
  220. package/examples/jsm/misc/Volume.js +521 -0
  221. package/examples/jsm/misc/VolumeSlice.js +276 -0
  222. package/examples/jsm/modifiers/CurveModifier.js +374 -0
  223. package/examples/jsm/modifiers/CurveModifierGPU.js +256 -0
  224. package/examples/jsm/modifiers/EdgeSplitModifier.js +299 -0
  225. package/examples/jsm/modifiers/SimplifyModifier.js +632 -0
  226. package/examples/jsm/modifiers/TessellateModifier.js +340 -0
  227. package/examples/jsm/objects/GroundedSkybox.js +69 -0
  228. package/examples/jsm/objects/Lensflare.js +489 -0
  229. package/examples/jsm/objects/LensflareMesh.js +376 -0
  230. package/examples/jsm/objects/MarchingCubes.js +1261 -0
  231. package/examples/jsm/objects/Reflector.js +338 -0
  232. package/examples/jsm/objects/ReflectorForSSRPass.js +393 -0
  233. package/examples/jsm/objects/Refractor.js +389 -0
  234. package/examples/jsm/objects/ShadowMesh.js +130 -0
  235. package/examples/jsm/objects/Sky.js +237 -0
  236. package/examples/jsm/objects/SkyMesh.js +243 -0
  237. package/examples/jsm/objects/Water.js +373 -0
  238. package/examples/jsm/objects/Water2.js +401 -0
  239. package/examples/jsm/objects/Water2Mesh.js +199 -0
  240. package/examples/jsm/objects/WaterMesh.js +196 -0
  241. package/examples/jsm/offscreen/jank.js +45 -0
  242. package/examples/jsm/offscreen/offscreen.js +8 -0
  243. package/examples/jsm/offscreen/scene.js +86 -0
  244. package/examples/jsm/physics/AmmoPhysics.js +354 -0
  245. package/examples/jsm/physics/JoltPhysics.js +330 -0
  246. package/examples/jsm/physics/RapierPhysics.js +432 -0
  247. package/examples/jsm/postprocessing/AfterimagePass.js +185 -0
  248. package/examples/jsm/postprocessing/BloomPass.js +274 -0
  249. package/examples/jsm/postprocessing/BokehPass.js +218 -0
  250. package/examples/jsm/postprocessing/ClearPass.js +97 -0
  251. package/examples/jsm/postprocessing/CubeTexturePass.js +146 -0
  252. package/examples/jsm/postprocessing/DotScreenPass.js +114 -0
  253. package/examples/jsm/postprocessing/EffectComposer.js +363 -0
  254. package/examples/jsm/postprocessing/FXAAPass.js +40 -0
  255. package/examples/jsm/postprocessing/FilmPass.js +113 -0
  256. package/examples/jsm/postprocessing/GTAOPass.js +727 -0
  257. package/examples/jsm/postprocessing/GlitchPass.js +177 -0
  258. package/examples/jsm/postprocessing/HalftonePass.js +134 -0
  259. package/examples/jsm/postprocessing/LUTPass.js +138 -0
  260. package/examples/jsm/postprocessing/MaskPass.js +195 -0
  261. package/examples/jsm/postprocessing/OutlinePass.js +776 -0
  262. package/examples/jsm/postprocessing/OutputPass.js +139 -0
  263. package/examples/jsm/postprocessing/Pass.js +191 -0
  264. package/examples/jsm/postprocessing/RenderPass.js +183 -0
  265. package/examples/jsm/postprocessing/RenderPixelatedPass.js +314 -0
  266. package/examples/jsm/postprocessing/RenderTransitionPass.js +267 -0
  267. package/examples/jsm/postprocessing/SAOPass.js +407 -0
  268. package/examples/jsm/postprocessing/SMAAPass.js +230 -0
  269. package/examples/jsm/postprocessing/SSAARenderPass.js +313 -0
  270. package/examples/jsm/postprocessing/SSAOPass.js +527 -0
  271. package/examples/jsm/postprocessing/SSRPass.js +856 -0
  272. package/examples/jsm/postprocessing/SavePass.js +132 -0
  273. package/examples/jsm/postprocessing/ShaderPass.js +135 -0
  274. package/examples/jsm/postprocessing/TAARenderPass.js +243 -0
  275. package/examples/jsm/postprocessing/TexturePass.js +131 -0
  276. package/examples/jsm/postprocessing/UnrealBloomPass.js +492 -0
  277. package/examples/jsm/renderers/CSS2DRenderer.js +317 -0
  278. package/examples/jsm/renderers/CSS3DRenderer.js +453 -0
  279. package/examples/jsm/renderers/Projector.js +936 -0
  280. package/examples/jsm/renderers/SVGRenderer.js +685 -0
  281. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +96 -0
  282. package/examples/jsm/shaders/AfterimageShader.js +63 -0
  283. package/examples/jsm/shaders/BasicShader.js +36 -0
  284. package/examples/jsm/shaders/BleachBypassShader.js +68 -0
  285. package/examples/jsm/shaders/BlendShader.js +56 -0
  286. package/examples/jsm/shaders/BokehShader.js +151 -0
  287. package/examples/jsm/shaders/BokehShader2.js +404 -0
  288. package/examples/jsm/shaders/BrightnessContrastShader.js +62 -0
  289. package/examples/jsm/shaders/ColorCorrectionShader.js +59 -0
  290. package/examples/jsm/shaders/ColorifyShader.js +57 -0
  291. package/examples/jsm/shaders/ConvolutionShader.js +74 -0
  292. package/examples/jsm/shaders/CopyShader.js +52 -0
  293. package/examples/jsm/shaders/DOFMipMapShader.js +63 -0
  294. package/examples/jsm/shaders/DepthLimitedBlurShader.js +180 -0
  295. package/examples/jsm/shaders/DigitalGlitch.js +104 -0
  296. package/examples/jsm/shaders/DotScreenShader.js +75 -0
  297. package/examples/jsm/shaders/ExposureShader.js +51 -0
  298. package/examples/jsm/shaders/FXAAShader.js +298 -0
  299. package/examples/jsm/shaders/FilmShader.js +72 -0
  300. package/examples/jsm/shaders/FocusShader.js +94 -0
  301. package/examples/jsm/shaders/FreiChenShader.js +103 -0
  302. package/examples/jsm/shaders/GTAOShader.js +421 -0
  303. package/examples/jsm/shaders/GammaCorrectionShader.js +52 -0
  304. package/examples/jsm/shaders/GodRaysShader.js +333 -0
  305. package/examples/jsm/shaders/HalftoneShader.js +321 -0
  306. package/examples/jsm/shaders/HorizontalBlurShader.js +68 -0
  307. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +70 -0
  308. package/examples/jsm/shaders/HueSaturationShader.js +74 -0
  309. package/examples/jsm/shaders/KaleidoShader.js +65 -0
  310. package/examples/jsm/shaders/LuminosityHighPassShader.js +68 -0
  311. package/examples/jsm/shaders/LuminosityShader.js +54 -0
  312. package/examples/jsm/shaders/MirrorShader.js +62 -0
  313. package/examples/jsm/shaders/NormalMapShader.js +60 -0
  314. package/examples/jsm/shaders/OutputShader.js +103 -0
  315. package/examples/jsm/shaders/PoissonDenoiseShader.js +235 -0
  316. package/examples/jsm/shaders/RGBShiftShader.js +61 -0
  317. package/examples/jsm/shaders/SAOShader.js +188 -0
  318. package/examples/jsm/shaders/SMAAShader.js +489 -0
  319. package/examples/jsm/shaders/SSAOShader.js +321 -0
  320. package/examples/jsm/shaders/SSRShader.js +395 -0
  321. package/examples/jsm/shaders/SepiaShader.js +57 -0
  322. package/examples/jsm/shaders/SobelOperatorShader.js +98 -0
  323. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +95 -0
  324. package/examples/jsm/shaders/TechnicolorShader.js +51 -0
  325. package/examples/jsm/shaders/ToonShader.js +349 -0
  326. package/examples/jsm/shaders/TriangleBlurShader.js +79 -0
  327. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +62 -0
  328. package/examples/jsm/shaders/VelocityShader.js +137 -0
  329. package/examples/jsm/shaders/VerticalBlurShader.js +66 -0
  330. package/examples/jsm/shaders/VerticalTiltShiftShader.js +70 -0
  331. package/examples/jsm/shaders/VignetteShader.js +56 -0
  332. package/examples/jsm/shaders/VolumeShader.js +298 -0
  333. package/examples/jsm/shaders/WaterRefractionShader.js +106 -0
  334. package/examples/jsm/textures/FlakesTexture.js +54 -0
  335. package/examples/jsm/textures/IESTexture.js +101 -0
  336. package/examples/jsm/transpiler/AST.js +631 -0
  337. package/examples/jsm/transpiler/GLSLDecoder.js +1171 -0
  338. package/examples/jsm/transpiler/Linker.js +327 -0
  339. package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -0
  340. package/examples/jsm/transpiler/TSLEncoder.js +933 -0
  341. package/examples/jsm/transpiler/Transpiler.js +67 -0
  342. package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
  343. package/examples/jsm/transpiler/WGSLEncoder.js +812 -0
  344. package/examples/jsm/tsl/display/AfterImageNode.js +242 -0
  345. package/examples/jsm/tsl/display/AnaglyphPassNode.js +107 -0
  346. package/examples/jsm/tsl/display/AnamorphicNode.js +281 -0
  347. package/examples/jsm/tsl/display/BleachBypass.js +33 -0
  348. package/examples/jsm/tsl/display/BloomNode.js +520 -0
  349. package/examples/jsm/tsl/display/ChromaticAberrationNode.js +207 -0
  350. package/examples/jsm/tsl/display/DenoiseNode.js +332 -0
  351. package/examples/jsm/tsl/display/DepthOfFieldNode.js +547 -0
  352. package/examples/jsm/tsl/display/DotScreenNode.js +104 -0
  353. package/examples/jsm/tsl/display/FXAANode.js +365 -0
  354. package/examples/jsm/tsl/display/FilmNode.js +101 -0
  355. package/examples/jsm/tsl/display/GTAONode.js +530 -0
  356. package/examples/jsm/tsl/display/GaussianBlurNode.js +378 -0
  357. package/examples/jsm/tsl/display/LensflareNode.js +279 -0
  358. package/examples/jsm/tsl/display/Lut3DNode.js +109 -0
  359. package/examples/jsm/tsl/display/MotionBlur.js +33 -0
  360. package/examples/jsm/tsl/display/OutlineNode.js +751 -0
  361. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +89 -0
  362. package/examples/jsm/tsl/display/PixelationPassNode.js +334 -0
  363. package/examples/jsm/tsl/display/RGBShiftNode.js +96 -0
  364. package/examples/jsm/tsl/display/SMAANode.js +768 -0
  365. package/examples/jsm/tsl/display/SSAAPassNode.js +358 -0
  366. package/examples/jsm/tsl/display/SSGINode.js +650 -0
  367. package/examples/jsm/tsl/display/SSRNode.js +654 -0
  368. package/examples/jsm/tsl/display/Sepia.js +24 -0
  369. package/examples/jsm/tsl/display/SobelOperatorNode.js +168 -0
  370. package/examples/jsm/tsl/display/StereoCompositePassNode.js +185 -0
  371. package/examples/jsm/tsl/display/StereoPassNode.js +120 -0
  372. package/examples/jsm/tsl/display/TRAANode.js +461 -0
  373. package/examples/jsm/tsl/display/TransitionNode.js +141 -0
  374. package/examples/jsm/tsl/display/boxBlur.js +64 -0
  375. package/examples/jsm/tsl/display/hashBlur.js +53 -0
  376. package/examples/jsm/tsl/lighting/TiledLightsNode.js +422 -0
  377. package/examples/jsm/tsl/math/Bayer.js +34 -0
  378. package/examples/jsm/tsl/shadows/TileShadowNode.js +456 -0
  379. package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +212 -0
  380. package/examples/jsm/tsl/utils/Raymarching.js +70 -0
  381. package/examples/jsm/utils/BufferGeometryUtils.js +1435 -0
  382. package/examples/jsm/utils/CameraUtils.js +82 -0
  383. package/examples/jsm/utils/GeometryCompressionUtils.js +547 -0
  384. package/examples/jsm/utils/GeometryUtils.js +226 -0
  385. package/examples/jsm/utils/LDrawUtils.js +211 -0
  386. package/examples/jsm/utils/SceneOptimizer.js +458 -0
  387. package/examples/jsm/utils/SceneUtils.js +363 -0
  388. package/examples/jsm/utils/ShadowMapViewer.js +230 -0
  389. package/examples/jsm/utils/ShadowMapViewerGPU.js +233 -0
  390. package/examples/jsm/utils/SkeletonUtils.js +490 -0
  391. package/examples/jsm/utils/SortUtils.js +175 -0
  392. package/examples/jsm/utils/UVsDebug.js +173 -0
  393. package/examples/jsm/utils/WebGLTextureUtils.js +115 -0
  394. package/examples/jsm/utils/WebGPUTextureUtils.js +81 -0
  395. package/examples/jsm/utils/WorkerPool.js +167 -0
  396. package/examples/jsm/webxr/ARButton.js +251 -0
  397. package/examples/jsm/webxr/OculusHandModel.js +194 -0
  398. package/examples/jsm/webxr/OculusHandPointerModel.js +539 -0
  399. package/examples/jsm/webxr/Text2D.js +52 -0
  400. package/examples/jsm/webxr/VRButton.js +264 -0
  401. package/examples/jsm/webxr/XRButton.js +246 -0
  402. package/examples/jsm/webxr/XRControllerModelFactory.js +403 -0
  403. package/examples/jsm/webxr/XREstimatedLight.js +254 -0
  404. package/examples/jsm/webxr/XRHandMeshModel.js +151 -0
  405. package/examples/jsm/webxr/XRHandModelFactory.js +197 -0
  406. package/examples/jsm/webxr/XRHandPrimitiveModel.js +147 -0
  407. package/examples/jsm/webxr/XRPlanes.js +118 -0
  408. package/package.json +134 -0
  409. package/src/Three.Core.js +185 -0
  410. package/src/Three.Legacy.js +0 -0
  411. package/src/Three.TSL.js +629 -0
  412. package/src/Three.WebGPU.Nodes.js +24 -0
  413. package/src/Three.WebGPU.js +26 -0
  414. package/src/Three.js +9 -0
  415. package/src/animation/AnimationAction.js +932 -0
  416. package/src/animation/AnimationClip.js +628 -0
  417. package/src/animation/AnimationMixer.js +854 -0
  418. package/src/animation/AnimationObjectGroup.js +411 -0
  419. package/src/animation/AnimationUtils.js +506 -0
  420. package/src/animation/KeyframeTrack.js +597 -0
  421. package/src/animation/PropertyBinding.js +794 -0
  422. package/src/animation/PropertyMixer.js +385 -0
  423. package/src/animation/tracks/BooleanKeyframeTrack.js +55 -0
  424. package/src/animation/tracks/ColorKeyframeTrack.js +36 -0
  425. package/src/animation/tracks/NumberKeyframeTrack.js +36 -0
  426. package/src/animation/tracks/QuaternionKeyframeTrack.js +51 -0
  427. package/src/animation/tracks/StringKeyframeTrack.js +55 -0
  428. package/src/animation/tracks/VectorKeyframeTrack.js +36 -0
  429. package/src/audio/Audio.js +778 -0
  430. package/src/audio/AudioAnalyser.js +97 -0
  431. package/src/audio/AudioContext.js +40 -0
  432. package/src/audio/AudioListener.js +216 -0
  433. package/src/audio/PositionalAudio.js +253 -0
  434. package/src/cameras/ArrayCamera.js +54 -0
  435. package/src/cameras/Camera.js +130 -0
  436. package/src/cameras/CubeCamera.js +239 -0
  437. package/src/cameras/OrthographicCamera.js +245 -0
  438. package/src/cameras/PerspectiveCamera.js +407 -0
  439. package/src/cameras/StereoCamera.js +146 -0
  440. package/src/constants.js +1675 -0
  441. package/src/core/BufferAttribute.js +1044 -0
  442. package/src/core/BufferGeometry.js +1446 -0
  443. package/src/core/Clock.js +128 -0
  444. package/src/core/EventDispatcher.js +131 -0
  445. package/src/core/GLBufferAttribute.js +171 -0
  446. package/src/core/InstancedBufferAttribute.js +68 -0
  447. package/src/core/InstancedBufferGeometry.js +60 -0
  448. package/src/core/InstancedInterleavedBuffer.js +74 -0
  449. package/src/core/InterleavedBuffer.js +291 -0
  450. package/src/core/InterleavedBufferAttribute.js +549 -0
  451. package/src/core/Layers.js +121 -0
  452. package/src/core/Object3D.js +1619 -0
  453. package/src/core/Raycaster.js +262 -0
  454. package/src/core/RenderTarget.js +392 -0
  455. package/src/core/RenderTarget3D.js +48 -0
  456. package/src/core/Timer.js +184 -0
  457. package/src/core/Uniform.js +46 -0
  458. package/src/core/UniformsGroup.js +180 -0
  459. package/src/extras/Controls.js +120 -0
  460. package/src/extras/DataUtils.js +217 -0
  461. package/src/extras/Earcut.js +22 -0
  462. package/src/extras/ImageUtils.js +137 -0
  463. package/src/extras/PMREMGenerator.js +966 -0
  464. package/src/extras/ShapeUtils.js +114 -0
  465. package/src/extras/TextureUtils.js +293 -0
  466. package/src/extras/core/Curve.js +517 -0
  467. package/src/extras/core/CurvePath.js +296 -0
  468. package/src/extras/core/Interpolations.js +105 -0
  469. package/src/extras/core/Path.js +329 -0
  470. package/src/extras/core/Shape.js +165 -0
  471. package/src/extras/core/ShapePath.js +367 -0
  472. package/src/extras/curves/ArcCurve.js +39 -0
  473. package/src/extras/curves/CatmullRomCurve3.js +326 -0
  474. package/src/extras/curves/CubicBezierCurve.js +145 -0
  475. package/src/extras/curves/CubicBezierCurve3.js +129 -0
  476. package/src/extras/curves/Curves.js +10 -0
  477. package/src/extras/curves/EllipseCurve.js +258 -0
  478. package/src/extras/curves/LineCurve.js +128 -0
  479. package/src/extras/curves/LineCurve3.js +128 -0
  480. package/src/extras/curves/QuadraticBezierCurve.js +133 -0
  481. package/src/extras/curves/QuadraticBezierCurve3.js +118 -0
  482. package/src/extras/curves/SplineCurve.js +145 -0
  483. package/src/extras/lib/earcut.js +685 -0
  484. package/src/geometries/BoxGeometry.js +218 -0
  485. package/src/geometries/CapsuleGeometry.js +217 -0
  486. package/src/geometries/CircleGeometry.js +141 -0
  487. package/src/geometries/ConeGeometry.js +69 -0
  488. package/src/geometries/CylinderGeometry.js +332 -0
  489. package/src/geometries/DodecahedronGeometry.js +98 -0
  490. package/src/geometries/EdgesGeometry.js +180 -0
  491. package/src/geometries/ExtrudeGeometry.js +909 -0
  492. package/src/geometries/Geometries.js +21 -0
  493. package/src/geometries/IcosahedronGeometry.js +74 -0
  494. package/src/geometries/LatheGeometry.js +229 -0
  495. package/src/geometries/OctahedronGeometry.js +69 -0
  496. package/src/geometries/PlaneGeometry.js +132 -0
  497. package/src/geometries/PolyhedronGeometry.js +348 -0
  498. package/src/geometries/RingGeometry.js +164 -0
  499. package/src/geometries/ShapeGeometry.js +232 -0
  500. package/src/geometries/SphereGeometry.js +174 -0
  501. package/src/geometries/TetrahedronGeometry.js +66 -0
  502. package/src/geometries/TorusGeometry.js +155 -0
  503. package/src/geometries/TorusKnotGeometry.js +205 -0
  504. package/src/geometries/TubeGeometry.js +252 -0
  505. package/src/geometries/WireframeGeometry.js +179 -0
  506. package/src/helpers/ArrowHelper.js +171 -0
  507. package/src/helpers/AxesHelper.js +96 -0
  508. package/src/helpers/Box3Helper.js +83 -0
  509. package/src/helpers/BoxHelper.js +149 -0
  510. package/src/helpers/CameraHelper.js +342 -0
  511. package/src/helpers/DirectionalLightHelper.js +145 -0
  512. package/src/helpers/GridHelper.js +82 -0
  513. package/src/helpers/HemisphereLightHelper.js +127 -0
  514. package/src/helpers/PlaneHelper.js +96 -0
  515. package/src/helpers/PointLightHelper.js +135 -0
  516. package/src/helpers/PolarGridHelper.js +126 -0
  517. package/src/helpers/SkeletonHelper.js +194 -0
  518. package/src/helpers/SpotLightHelper.js +151 -0
  519. package/src/lights/AmbientLight.js +42 -0
  520. package/src/lights/DirectionalLight.js +100 -0
  521. package/src/lights/DirectionalLightShadow.js +31 -0
  522. package/src/lights/HemisphereLight.js +66 -0
  523. package/src/lights/Light.js +95 -0
  524. package/src/lights/LightProbe.js +90 -0
  525. package/src/lights/LightShadow.js +338 -0
  526. package/src/lights/PointLight.js +116 -0
  527. package/src/lights/PointLightShadow.js +117 -0
  528. package/src/lights/RectAreaLight.js +115 -0
  529. package/src/lights/SpotLight.js +173 -0
  530. package/src/lights/SpotLightShadow.js +80 -0
  531. package/src/lights/webgpu/IESSpotLight.js +46 -0
  532. package/src/lights/webgpu/ProjectorLight.js +46 -0
  533. package/src/loaders/AnimationLoader.js +98 -0
  534. package/src/loaders/AudioLoader.js +98 -0
  535. package/src/loaders/BufferGeometryLoader.js +242 -0
  536. package/src/loaders/Cache.js +87 -0
  537. package/src/loaders/CompressedTextureLoader.js +167 -0
  538. package/src/loaders/CubeTextureLoader.js +103 -0
  539. package/src/loaders/DataTextureLoader.js +172 -0
  540. package/src/loaders/FileLoader.js +368 -0
  541. package/src/loaders/IESLoader.js +327 -0
  542. package/src/loaders/ImageBitmapLoader.js +220 -0
  543. package/src/loaders/ImageLoader.js +168 -0
  544. package/src/loaders/Loader.js +216 -0
  545. package/src/loaders/LoaderUtils.js +59 -0
  546. package/src/loaders/LoadingManager.js +307 -0
  547. package/src/loaders/MaterialLoader.js +438 -0
  548. package/src/loaders/ObjectLoader.js +1264 -0
  549. package/src/loaders/TextureLoader.js +74 -0
  550. package/src/loaders/nodes/NodeLoader.js +194 -0
  551. package/src/loaders/nodes/NodeMaterialLoader.js +108 -0
  552. package/src/loaders/nodes/NodeObjectLoader.js +151 -0
  553. package/src/materials/LineBasicMaterial.js +122 -0
  554. package/src/materials/LineDashedMaterial.js +86 -0
  555. package/src/materials/Material.js +1015 -0
  556. package/src/materials/Materials.js +39 -0
  557. package/src/materials/MeshBasicMaterial.js +249 -0
  558. package/src/materials/MeshDepthMaterial.js +147 -0
  559. package/src/materials/MeshDistanceMaterial.js +119 -0
  560. package/src/materials/MeshLambertMaterial.js +392 -0
  561. package/src/materials/MeshMatcapMaterial.js +223 -0
  562. package/src/materials/MeshNormalMaterial.js +174 -0
  563. package/src/materials/MeshPhongMaterial.js +411 -0
  564. package/src/materials/MeshPhysicalMaterial.js +535 -0
  565. package/src/materials/MeshStandardMaterial.js +424 -0
  566. package/src/materials/MeshToonMaterial.js +320 -0
  567. package/src/materials/PointsMaterial.js +139 -0
  568. package/src/materials/RawShaderMaterial.js +42 -0
  569. package/src/materials/ShaderMaterial.js +394 -0
  570. package/src/materials/ShadowMaterial.js +91 -0
  571. package/src/materials/SpriteMaterial.js +136 -0
  572. package/src/materials/nodes/Line2NodeMaterial.js +542 -0
  573. package/src/materials/nodes/LineBasicNodeMaterial.js +46 -0
  574. package/src/materials/nodes/LineDashedNodeMaterial.js +132 -0
  575. package/src/materials/nodes/MeshBasicNodeMaterial.js +134 -0
  576. package/src/materials/nodes/MeshLambertNodeMaterial.js +82 -0
  577. package/src/materials/nodes/MeshMatcapNodeMaterial.js +77 -0
  578. package/src/materials/nodes/MeshNormalNodeMaterial.js +67 -0
  579. package/src/materials/nodes/MeshPhongNodeMaterial.js +141 -0
  580. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +518 -0
  581. package/src/materials/nodes/MeshSSSNodeMaterial.js +175 -0
  582. package/src/materials/nodes/MeshStandardNodeMaterial.js +186 -0
  583. package/src/materials/nodes/MeshToonNodeMaterial.js +66 -0
  584. package/src/materials/nodes/NodeMaterial.js +1271 -0
  585. package/src/materials/nodes/NodeMaterials.js +21 -0
  586. package/src/materials/nodes/PointsNodeMaterial.js +211 -0
  587. package/src/materials/nodes/ShadowNodeMaterial.js +76 -0
  588. package/src/materials/nodes/SpriteNodeMaterial.js +186 -0
  589. package/src/materials/nodes/VolumeNodeMaterial.js +81 -0
  590. package/src/materials/nodes/manager/NodeMaterialObserver.js +612 -0
  591. package/src/math/Box2.js +381 -0
  592. package/src/math/Box3.js +805 -0
  593. package/src/math/Color.js +967 -0
  594. package/src/math/ColorManagement.js +215 -0
  595. package/src/math/Cylindrical.js +120 -0
  596. package/src/math/Euler.js +449 -0
  597. package/src/math/Frustum.js +285 -0
  598. package/src/math/FrustumArray.js +258 -0
  599. package/src/math/Interpolant.js +320 -0
  600. package/src/math/Line3.js +336 -0
  601. package/src/math/MathUtils.js +751 -0
  602. package/src/math/Matrix2.js +124 -0
  603. package/src/math/Matrix3.js +613 -0
  604. package/src/math/Matrix4.js +1301 -0
  605. package/src/math/Plane.js +367 -0
  606. package/src/math/Quaternion.js +943 -0
  607. package/src/math/Ray.js +655 -0
  608. package/src/math/Sphere.js +420 -0
  609. package/src/math/Spherical.js +147 -0
  610. package/src/math/SphericalHarmonics3.js +341 -0
  611. package/src/math/Triangle.js +539 -0
  612. package/src/math/Vector2.js +866 -0
  613. package/src/math/Vector3.js +1261 -0
  614. package/src/math/Vector4.js +1063 -0
  615. package/src/math/interpolants/CubicInterpolant.js +159 -0
  616. package/src/math/interpolants/DiscreteInterpolant.js +34 -0
  617. package/src/math/interpolants/LinearInterpolant.js +51 -0
  618. package/src/math/interpolants/QuaternionLinearInterpolant.js +48 -0
  619. package/src/nodes/Nodes.js +148 -0
  620. package/src/nodes/TSL.js +173 -0
  621. package/src/nodes/accessors/AccessorsUtils.js +53 -0
  622. package/src/nodes/accessors/Arrays.js +68 -0
  623. package/src/nodes/accessors/BatchNode.js +163 -0
  624. package/src/nodes/accessors/Bitangent.js +82 -0
  625. package/src/nodes/accessors/BufferAttributeNode.js +340 -0
  626. package/src/nodes/accessors/BufferNode.js +101 -0
  627. package/src/nodes/accessors/BuiltinNode.js +63 -0
  628. package/src/nodes/accessors/Camera.js +282 -0
  629. package/src/nodes/accessors/ClippingNode.js +255 -0
  630. package/src/nodes/accessors/CubeTextureNode.js +190 -0
  631. package/src/nodes/accessors/InstanceNode.js +244 -0
  632. package/src/nodes/accessors/InstancedMeshNode.js +50 -0
  633. package/src/nodes/accessors/Lights.js +129 -0
  634. package/src/nodes/accessors/MaterialNode.js +775 -0
  635. package/src/nodes/accessors/MaterialProperties.js +59 -0
  636. package/src/nodes/accessors/MaterialReferenceNode.js +85 -0
  637. package/src/nodes/accessors/ModelNode.js +184 -0
  638. package/src/nodes/accessors/ModelViewProjectionNode.js +13 -0
  639. package/src/nodes/accessors/MorphNode.js +310 -0
  640. package/src/nodes/accessors/Normal.js +243 -0
  641. package/src/nodes/accessors/Object3DNode.js +268 -0
  642. package/src/nodes/accessors/PointUVNode.js +55 -0
  643. package/src/nodes/accessors/Position.js +74 -0
  644. package/src/nodes/accessors/ReferenceBaseNode.js +357 -0
  645. package/src/nodes/accessors/ReferenceNode.js +424 -0
  646. package/src/nodes/accessors/ReflectVector.js +36 -0
  647. package/src/nodes/accessors/RendererReferenceNode.js +79 -0
  648. package/src/nodes/accessors/SceneNode.js +145 -0
  649. package/src/nodes/accessors/SkinningNode.js +327 -0
  650. package/src/nodes/accessors/StorageBufferNode.js +416 -0
  651. package/src/nodes/accessors/StorageTextureNode.js +242 -0
  652. package/src/nodes/accessors/Tangent.js +70 -0
  653. package/src/nodes/accessors/TangentUtils.js +46 -0
  654. package/src/nodes/accessors/Texture3DNode.js +199 -0
  655. package/src/nodes/accessors/TextureBicubic.js +92 -0
  656. package/src/nodes/accessors/TextureNode.js +894 -0
  657. package/src/nodes/accessors/TextureSizeNode.js +77 -0
  658. package/src/nodes/accessors/UV.js +11 -0
  659. package/src/nodes/accessors/UniformArrayNode.js +348 -0
  660. package/src/nodes/accessors/UserDataNode.js +77 -0
  661. package/src/nodes/accessors/VelocityNode.js +224 -0
  662. package/src/nodes/accessors/VertexColorNode.js +110 -0
  663. package/src/nodes/code/CodeNode.js +181 -0
  664. package/src/nodes/code/ExpressionNode.js +68 -0
  665. package/src/nodes/code/FunctionCallNode.js +187 -0
  666. package/src/nodes/code/FunctionNode.js +183 -0
  667. package/src/nodes/code/ScriptableNode.js +726 -0
  668. package/src/nodes/code/ScriptableValueNode.js +253 -0
  669. package/src/nodes/core/ArrayNode.js +154 -0
  670. package/src/nodes/core/AssignNode.js +202 -0
  671. package/src/nodes/core/AttributeNode.js +168 -0
  672. package/src/nodes/core/BypassNode.js +93 -0
  673. package/src/nodes/core/CacheNode.js +100 -0
  674. package/src/nodes/core/ConstNode.js +67 -0
  675. package/src/nodes/core/ContextNode.js +190 -0
  676. package/src/nodes/core/IndexNode.js +164 -0
  677. package/src/nodes/core/InputNode.js +136 -0
  678. package/src/nodes/core/LightingModel.js +77 -0
  679. package/src/nodes/core/MRTNode.js +150 -0
  680. package/src/nodes/core/Node.js +959 -0
  681. package/src/nodes/core/NodeAttribute.js +53 -0
  682. package/src/nodes/core/NodeBuilder.js +2968 -0
  683. package/src/nodes/core/NodeCache.js +75 -0
  684. package/src/nodes/core/NodeCode.js +46 -0
  685. package/src/nodes/core/NodeFrame.js +306 -0
  686. package/src/nodes/core/NodeFunction.js +69 -0
  687. package/src/nodes/core/NodeFunctionInput.js +61 -0
  688. package/src/nodes/core/NodeParser.js +23 -0
  689. package/src/nodes/core/NodeUniform.js +91 -0
  690. package/src/nodes/core/NodeUtils.js +480 -0
  691. package/src/nodes/core/NodeVar.js +60 -0
  692. package/src/nodes/core/NodeVarying.js +63 -0
  693. package/src/nodes/core/OutputStructNode.js +103 -0
  694. package/src/nodes/core/ParameterNode.js +94 -0
  695. package/src/nodes/core/PropertyNode.js +344 -0
  696. package/src/nodes/core/StackNode.js +376 -0
  697. package/src/nodes/core/StructNode.js +120 -0
  698. package/src/nodes/core/StructType.js +13 -0
  699. package/src/nodes/core/StructTypeNode.js +154 -0
  700. package/src/nodes/core/SubBuildNode.js +89 -0
  701. package/src/nodes/core/TempNode.js +88 -0
  702. package/src/nodes/core/UniformGroupNode.js +137 -0
  703. package/src/nodes/core/UniformNode.js +243 -0
  704. package/src/nodes/core/VarNode.js +284 -0
  705. package/src/nodes/core/VaryingNode.js +227 -0
  706. package/src/nodes/core/constants.js +68 -0
  707. package/src/nodes/display/BlendModes.js +235 -0
  708. package/src/nodes/display/BumpMapNode.js +117 -0
  709. package/src/nodes/display/ColorAdjustment.js +141 -0
  710. package/src/nodes/display/ColorSpaceFunctions.js +54 -0
  711. package/src/nodes/display/ColorSpaceNode.js +164 -0
  712. package/src/nodes/display/FrontFacingNode.js +102 -0
  713. package/src/nodes/display/NormalMapNode.js +118 -0
  714. package/src/nodes/display/PassNode.js +905 -0
  715. package/src/nodes/display/PosterizeNode.js +65 -0
  716. package/src/nodes/display/RenderOutputNode.js +124 -0
  717. package/src/nodes/display/ScreenNode.js +290 -0
  718. package/src/nodes/display/ToneMappingFunctions.js +242 -0
  719. package/src/nodes/display/ToneMappingNode.js +121 -0
  720. package/src/nodes/display/ToonOutlinePassNode.js +183 -0
  721. package/src/nodes/display/ViewportDepthNode.js +294 -0
  722. package/src/nodes/display/ViewportDepthTextureNode.js +67 -0
  723. package/src/nodes/display/ViewportSharedTextureNode.js +73 -0
  724. package/src/nodes/display/ViewportTextureNode.js +228 -0
  725. package/src/nodes/fog/Fog.js +114 -0
  726. package/src/nodes/functions/BSDF/BRDF_GGX.js +55 -0
  727. package/src/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
  728. package/src/nodes/functions/BSDF/BRDF_Sheen.js +57 -0
  729. package/src/nodes/functions/BSDF/DFGApprox.js +30 -0
  730. package/src/nodes/functions/BSDF/D_GGX.js +23 -0
  731. package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
  732. package/src/nodes/functions/BSDF/EnvironmentBRDF.js +13 -0
  733. package/src/nodes/functions/BSDF/F_Schlick.js +16 -0
  734. package/src/nodes/functions/BSDF/LTC.js +175 -0
  735. package/src/nodes/functions/BSDF/Schlick_to_F0.js +21 -0
  736. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +26 -0
  737. package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
  738. package/src/nodes/functions/BasicLightingModel.js +100 -0
  739. package/src/nodes/functions/PhongLightingModel.js +99 -0
  740. package/src/nodes/functions/PhysicalLightingModel.js +796 -0
  741. package/src/nodes/functions/ShadowMaskModel.js +58 -0
  742. package/src/nodes/functions/ToonLightingModel.js +70 -0
  743. package/src/nodes/functions/VolumetricLightingModel.js +183 -0
  744. package/src/nodes/functions/material/getAlphaHashThreshold.js +68 -0
  745. package/src/nodes/functions/material/getGeometryRoughness.js +19 -0
  746. package/src/nodes/functions/material/getParallaxCorrectNormal.js +37 -0
  747. package/src/nodes/functions/material/getRoughness.js +18 -0
  748. package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
  749. package/src/nodes/geometry/RangeNode.js +172 -0
  750. package/src/nodes/gpgpu/AtomicFunctionNode.js +274 -0
  751. package/src/nodes/gpgpu/BarrierNode.js +89 -0
  752. package/src/nodes/gpgpu/ComputeBuiltinNode.js +228 -0
  753. package/src/nodes/gpgpu/ComputeNode.js +273 -0
  754. package/src/nodes/gpgpu/SubgroupFunctionNode.js +430 -0
  755. package/src/nodes/gpgpu/WorkgroupInfoNode.js +234 -0
  756. package/src/nodes/lighting/AONode.js +45 -0
  757. package/src/nodes/lighting/AmbientLightNode.js +35 -0
  758. package/src/nodes/lighting/AnalyticLightNode.js +256 -0
  759. package/src/nodes/lighting/BasicEnvironmentNode.js +49 -0
  760. package/src/nodes/lighting/BasicLightMapNode.js +49 -0
  761. package/src/nodes/lighting/DirectionalLightNode.js +39 -0
  762. package/src/nodes/lighting/EnvironmentNode.js +153 -0
  763. package/src/nodes/lighting/HemisphereLightNode.js +87 -0
  764. package/src/nodes/lighting/IESSpotLightNode.js +49 -0
  765. package/src/nodes/lighting/IrradianceNode.js +44 -0
  766. package/src/nodes/lighting/LightProbeNode.js +73 -0
  767. package/src/nodes/lighting/LightUtils.js +25 -0
  768. package/src/nodes/lighting/LightingContextNode.js +115 -0
  769. package/src/nodes/lighting/LightingNode.js +36 -0
  770. package/src/nodes/lighting/LightsNode.js +455 -0
  771. package/src/nodes/lighting/PointLightNode.js +102 -0
  772. package/src/nodes/lighting/PointShadowNode.js +306 -0
  773. package/src/nodes/lighting/ProjectorLightNode.js +91 -0
  774. package/src/nodes/lighting/RectAreaLightNode.js +133 -0
  775. package/src/nodes/lighting/ShadowBaseNode.js +81 -0
  776. package/src/nodes/lighting/ShadowFilterNode.js +274 -0
  777. package/src/nodes/lighting/ShadowNode.js +745 -0
  778. package/src/nodes/lighting/SpotLightNode.js +168 -0
  779. package/src/nodes/materialx/DISCLAIMER.md +199 -0
  780. package/src/nodes/materialx/MaterialXNodes.js +197 -0
  781. package/src/nodes/materialx/lib/mx_hsv.js +127 -0
  782. package/src/nodes/materialx/lib/mx_noise.js +1491 -0
  783. package/src/nodes/materialx/lib/mx_transform_color.js +23 -0
  784. package/src/nodes/math/BitcastNode.js +156 -0
  785. package/src/nodes/math/ConditionalNode.js +245 -0
  786. package/src/nodes/math/Hash.js +21 -0
  787. package/src/nodes/math/MathNode.js +1167 -0
  788. package/src/nodes/math/MathUtils.js +54 -0
  789. package/src/nodes/math/OperatorNode.js +751 -0
  790. package/src/nodes/math/TriNoise3D.js +71 -0
  791. package/src/nodes/parsers/GLSLNodeFunction.js +168 -0
  792. package/src/nodes/parsers/GLSLNodeParser.js +25 -0
  793. package/src/nodes/pmrem/PMREMNode.js +397 -0
  794. package/src/nodes/pmrem/PMREMUtils.js +288 -0
  795. package/src/nodes/procedural/Checker.js +22 -0
  796. package/src/nodes/shapes/Shapes.js +33 -0
  797. package/src/nodes/tsl/TSLBase.js +35 -0
  798. package/src/nodes/tsl/TSLCore.js +1209 -0
  799. package/src/nodes/utils/ArrayElementNode.js +77 -0
  800. package/src/nodes/utils/ConvertNode.js +100 -0
  801. package/src/nodes/utils/CubeMapNode.js +237 -0
  802. package/src/nodes/utils/DebugNode.js +83 -0
  803. package/src/nodes/utils/Discard.js +24 -0
  804. package/src/nodes/utils/EquirectUV.js +27 -0
  805. package/src/nodes/utils/EventNode.js +83 -0
  806. package/src/nodes/utils/FlipNode.js +106 -0
  807. package/src/nodes/utils/FunctionOverloadingNode.js +152 -0
  808. package/src/nodes/utils/JoinNode.js +117 -0
  809. package/src/nodes/utils/LoopNode.js +354 -0
  810. package/src/nodes/utils/MatcapUV.js +22 -0
  811. package/src/nodes/utils/MaxMipLevelNode.js +103 -0
  812. package/src/nodes/utils/MemberNode.js +120 -0
  813. package/src/nodes/utils/Oscillators.js +41 -0
  814. package/src/nodes/utils/Packing.js +21 -0
  815. package/src/nodes/utils/PostProcessingUtils.js +95 -0
  816. package/src/nodes/utils/RTTNode.js +279 -0
  817. package/src/nodes/utils/ReflectorNode.js +623 -0
  818. package/src/nodes/utils/RemapNode.js +125 -0
  819. package/src/nodes/utils/RotateNode.js +103 -0
  820. package/src/nodes/utils/SampleNode.js +91 -0
  821. package/src/nodes/utils/SetNode.js +108 -0
  822. package/src/nodes/utils/SplitNode.js +179 -0
  823. package/src/nodes/utils/SpriteSheetUVNode.js +90 -0
  824. package/src/nodes/utils/SpriteUtils.js +63 -0
  825. package/src/nodes/utils/StorageArrayElementNode.js +143 -0
  826. package/src/nodes/utils/Timer.js +26 -0
  827. package/src/nodes/utils/TriplanarTextures.js +65 -0
  828. package/src/nodes/utils/UVUtils.js +39 -0
  829. package/src/nodes/utils/ViewportUtils.js +26 -0
  830. package/src/objects/BatchedMesh.js +1654 -0
  831. package/src/objects/Bone.js +41 -0
  832. package/src/objects/ClippingGroup.js +68 -0
  833. package/src/objects/Group.js +41 -0
  834. package/src/objects/InstancedMesh.js +395 -0
  835. package/src/objects/LOD.js +329 -0
  836. package/src/objects/Line.js +329 -0
  837. package/src/objects/LineLoop.js +37 -0
  838. package/src/objects/LineSegments.js +74 -0
  839. package/src/objects/Mesh.js +496 -0
  840. package/src/objects/Points.js +228 -0
  841. package/src/objects/Skeleton.js +383 -0
  842. package/src/objects/SkinnedMesh.js +352 -0
  843. package/src/objects/Sprite.js +245 -0
  844. package/src/renderers/WebGL3DRenderTarget.js +48 -0
  845. package/src/renderers/WebGLArrayRenderTarget.js +48 -0
  846. package/src/renderers/WebGLCubeRenderTarget.js +182 -0
  847. package/src/renderers/WebGLRenderTarget.js +34 -0
  848. package/src/renderers/WebGLRenderer.js +3508 -0
  849. package/src/renderers/common/Animation.js +147 -0
  850. package/src/renderers/common/Attributes.js +118 -0
  851. package/src/renderers/common/Backend.js +685 -0
  852. package/src/renderers/common/Background.js +212 -0
  853. package/src/renderers/common/BindGroup.js +61 -0
  854. package/src/renderers/common/Binding.js +60 -0
  855. package/src/renderers/common/Bindings.js +343 -0
  856. package/src/renderers/common/Buffer.js +87 -0
  857. package/src/renderers/common/BufferUtils.js +58 -0
  858. package/src/renderers/common/BundleGroup.js +83 -0
  859. package/src/renderers/common/ChainMap.js +98 -0
  860. package/src/renderers/common/ClippingContext.js +262 -0
  861. package/src/renderers/common/Color4.js +77 -0
  862. package/src/renderers/common/ComputePipeline.js +41 -0
  863. package/src/renderers/common/Constants.js +15 -0
  864. package/src/renderers/common/CubeRenderTarget.js +103 -0
  865. package/src/renderers/common/DataMap.js +90 -0
  866. package/src/renderers/common/Geometries.js +344 -0
  867. package/src/renderers/common/IndirectStorageBufferAttribute.js +38 -0
  868. package/src/renderers/common/Info.js +172 -0
  869. package/src/renderers/common/Lighting.js +73 -0
  870. package/src/renderers/common/Pipeline.js +35 -0
  871. package/src/renderers/common/Pipelines.js +465 -0
  872. package/src/renderers/common/PostProcessing.js +245 -0
  873. package/src/renderers/common/ProgrammableStage.js +78 -0
  874. package/src/renderers/common/QuadMesh.js +106 -0
  875. package/src/renderers/common/RenderBundle.js +24 -0
  876. package/src/renderers/common/RenderBundles.js +67 -0
  877. package/src/renderers/common/RenderContext.js +265 -0
  878. package/src/renderers/common/RenderContexts.js +116 -0
  879. package/src/renderers/common/RenderList.js +400 -0
  880. package/src/renderers/common/RenderLists.js +77 -0
  881. package/src/renderers/common/RenderObject.js +901 -0
  882. package/src/renderers/common/RenderObjects.js +202 -0
  883. package/src/renderers/common/RenderPipeline.js +40 -0
  884. package/src/renderers/common/Renderer.js +3125 -0
  885. package/src/renderers/common/RendererUtils.js +191 -0
  886. package/src/renderers/common/SampledTexture.js +144 -0
  887. package/src/renderers/common/Sampler.js +139 -0
  888. package/src/renderers/common/Storage3DTexture.js +100 -0
  889. package/src/renderers/common/StorageArrayTexture.js +84 -0
  890. package/src/renderers/common/StorageBuffer.js +41 -0
  891. package/src/renderers/common/StorageBufferAttribute.js +46 -0
  892. package/src/renderers/common/StorageInstancedBufferAttribute.js +46 -0
  893. package/src/renderers/common/StorageTexture.js +78 -0
  894. package/src/renderers/common/Textures.js +491 -0
  895. package/src/renderers/common/TimestampQueryPool.js +99 -0
  896. package/src/renderers/common/Uniform.js +367 -0
  897. package/src/renderers/common/UniformBuffer.js +34 -0
  898. package/src/renderers/common/UniformsGroup.js +487 -0
  899. package/src/renderers/common/XRManager.js +1676 -0
  900. package/src/renderers/common/XRRenderTarget.js +91 -0
  901. package/src/renderers/common/extras/PMREMGenerator.js +946 -0
  902. package/src/renderers/common/nodes/NodeBuilderState.js +152 -0
  903. package/src/renderers/common/nodes/NodeLibrary.js +196 -0
  904. package/src/renderers/common/nodes/NodeSampledTexture.js +140 -0
  905. package/src/renderers/common/nodes/NodeSampler.js +50 -0
  906. package/src/renderers/common/nodes/NodeStorageBuffer.js +61 -0
  907. package/src/renderers/common/nodes/NodeUniform.js +418 -0
  908. package/src/renderers/common/nodes/NodeUniformBuffer.js +53 -0
  909. package/src/renderers/common/nodes/NodeUniformsGroup.js +51 -0
  910. package/src/renderers/common/nodes/Nodes.js +819 -0
  911. package/src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js +7 -0
  912. package/src/renderers/shaders/ShaderChunk/alphahash_pars_fragment.glsl.js +68 -0
  913. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -0
  914. package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -0
  915. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +16 -0
  916. package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -0
  917. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +26 -0
  918. package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -0
  919. package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +49 -0
  920. package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
  921. package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +9 -0
  922. package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -0
  923. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +33 -0
  924. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +43 -0
  925. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -0
  926. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +10 -0
  927. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -0
  928. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +78 -0
  929. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -0
  930. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -0
  931. package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -0
  932. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +11 -0
  933. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +11 -0
  934. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +11 -0
  935. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +31 -0
  936. package/src/renderers/shaders/ShaderChunk/colorspace_fragment.glsl.js +3 -0
  937. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +15 -0
  938. package/src/renderers/shaders/ShaderChunk/common.glsl.js +137 -0
  939. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +186 -0
  940. package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -0
  941. package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -0
  942. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +63 -0
  943. package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -0
  944. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -0
  945. package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -0
  946. package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -0
  947. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +17 -0
  948. package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -0
  949. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +15 -0
  950. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +62 -0
  951. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -0
  952. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -0
  953. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +69 -0
  954. package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -0
  955. package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -0
  956. package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -0
  957. package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -0
  958. package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -0
  959. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -0
  960. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +120 -0
  961. package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
  962. package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -0
  963. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +209 -0
  964. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +13 -0
  965. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +40 -0
  966. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
  967. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +28 -0
  968. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +254 -0
  969. package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -0
  970. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +32 -0
  971. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +157 -0
  972. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +563 -0
  973. package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -0
  974. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +26 -0
  975. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -0
  976. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -0
  977. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +8 -0
  978. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +8 -0
  979. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +17 -0
  980. package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +7 -0
  981. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +27 -0
  982. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +27 -0
  983. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -0
  984. package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -0
  985. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -0
  986. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  987. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +16 -0
  988. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +26 -0
  989. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +16 -0
  990. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +76 -0
  991. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +33 -0
  992. package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -0
  993. package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -0
  994. package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -0
  995. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -0
  996. package/src/renderers/shaders/ShaderChunk/opaque_fragment.glsl.js +11 -0
  997. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +100 -0
  998. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +8 -0
  999. package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +19 -0
  1000. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -0
  1001. package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -0
  1002. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +337 -0
  1003. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +71 -0
  1004. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +68 -0
  1005. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -0
  1006. package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -0
  1007. package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +25 -0
  1008. package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -0
  1009. package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -0
  1010. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -0
  1011. package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -0
  1012. package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -0
  1013. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +200 -0
  1014. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -0
  1015. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +235 -0
  1016. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +119 -0
  1017. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +145 -0
  1018. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +122 -0
  1019. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +21 -0
  1020. package/src/renderers/shaders/ShaderChunk.js +270 -0
  1021. package/src/renderers/shaders/ShaderLib/background.glsl.js +40 -0
  1022. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +63 -0
  1023. package/src/renderers/shaders/ShaderLib/cube.glsl.js +36 -0
  1024. package/src/renderers/shaders/ShaderLib/depth.glsl.js +114 -0
  1025. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +78 -0
  1026. package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -0
  1027. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +76 -0
  1028. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +116 -0
  1029. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +125 -0
  1030. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +112 -0
  1031. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +87 -0
  1032. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +127 -0
  1033. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +229 -0
  1034. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +119 -0
  1035. package/src/renderers/shaders/ShaderLib/points.glsl.js +87 -0
  1036. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +58 -0
  1037. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +79 -0
  1038. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +53 -0
  1039. package/src/renderers/shaders/ShaderLib.js +361 -0
  1040. package/src/renderers/shaders/UniformsLib.js +235 -0
  1041. package/src/renderers/shaders/UniformsUtils.js +112 -0
  1042. package/src/renderers/webgl/WebGLAnimation.js +53 -0
  1043. package/src/renderers/webgl/WebGLAttributes.js +237 -0
  1044. package/src/renderers/webgl/WebGLBackground.js +303 -0
  1045. package/src/renderers/webgl/WebGLBindingStates.js +594 -0
  1046. package/src/renderers/webgl/WebGLBufferRenderer.js +89 -0
  1047. package/src/renderers/webgl/WebGLCapabilities.js +145 -0
  1048. package/src/renderers/webgl/WebGLClipping.js +171 -0
  1049. package/src/renderers/webgl/WebGLCubeMaps.js +99 -0
  1050. package/src/renderers/webgl/WebGLCubeUVMaps.js +134 -0
  1051. package/src/renderers/webgl/WebGLExtensions.js +84 -0
  1052. package/src/renderers/webgl/WebGLGeometries.js +183 -0
  1053. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +100 -0
  1054. package/src/renderers/webgl/WebGLInfo.js +73 -0
  1055. package/src/renderers/webgl/WebGLLights.js +571 -0
  1056. package/src/renderers/webgl/WebGLMaterials.js +591 -0
  1057. package/src/renderers/webgl/WebGLMorphtargets.js +168 -0
  1058. package/src/renderers/webgl/WebGLObjects.js +92 -0
  1059. package/src/renderers/webgl/WebGLProgram.js +1091 -0
  1060. package/src/renderers/webgl/WebGLPrograms.js +667 -0
  1061. package/src/renderers/webgl/WebGLProperties.js +55 -0
  1062. package/src/renderers/webgl/WebGLRenderLists.js +238 -0
  1063. package/src/renderers/webgl/WebGLRenderStates.js +116 -0
  1064. package/src/renderers/webgl/WebGLShader.js +12 -0
  1065. package/src/renderers/webgl/WebGLShaderCache.js +124 -0
  1066. package/src/renderers/webgl/WebGLShadowMap.js +436 -0
  1067. package/src/renderers/webgl/WebGLState.js +1332 -0
  1068. package/src/renderers/webgl/WebGLTextures.js +2342 -0
  1069. package/src/renderers/webgl/WebGLUniforms.js +1166 -0
  1070. package/src/renderers/webgl/WebGLUniformsGroups.js +394 -0
  1071. package/src/renderers/webgl/WebGLUtils.js +213 -0
  1072. package/src/renderers/webgl-fallback/WebGLBackend.js +2633 -0
  1073. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +140 -0
  1074. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +1517 -0
  1075. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +325 -0
  1076. package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +64 -0
  1077. package/src/renderers/webgl-fallback/utils/WebGLConstants.js +14 -0
  1078. package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +83 -0
  1079. package/src/renderers/webgl-fallback/utils/WebGLState.js +1144 -0
  1080. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1304 -0
  1081. package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +366 -0
  1082. package/src/renderers/webgl-fallback/utils/WebGLUtils.js +313 -0
  1083. package/src/renderers/webgpu/WebGPUBackend.js +2456 -0
  1084. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +69 -0
  1085. package/src/renderers/webgpu/WebGPURenderer.js +106 -0
  1086. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +66 -0
  1087. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +100 -0
  1088. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +2248 -0
  1089. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +187 -0
  1090. package/src/renderers/webgpu/nodes/WGSLNodeParser.js +25 -0
  1091. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +449 -0
  1092. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +484 -0
  1093. package/src/renderers/webgpu/utils/WebGPUConstants.js +339 -0
  1094. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +781 -0
  1095. package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +439 -0
  1096. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +1505 -0
  1097. package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +287 -0
  1098. package/src/renderers/webgpu/utils/WebGPUUtils.js +227 -0
  1099. package/src/renderers/webxr/WebXRController.js +428 -0
  1100. package/src/renderers/webxr/WebXRDepthSensing.js +155 -0
  1101. package/src/renderers/webxr/WebXRManager.js +1103 -0
  1102. package/src/scenes/Fog.js +98 -0
  1103. package/src/scenes/FogExp2.js +86 -0
  1104. package/src/scenes/Scene.js +165 -0
  1105. package/src/textures/CanvasTexture.js +45 -0
  1106. package/src/textures/CompressedArrayTexture.js +89 -0
  1107. package/src/textures/CompressedCubeTexture.js +48 -0
  1108. package/src/textures/CompressedTexture.js +86 -0
  1109. package/src/textures/CubeTexture.js +81 -0
  1110. package/src/textures/Data3DTexture.js +112 -0
  1111. package/src/textures/DataArrayTexture.js +134 -0
  1112. package/src/textures/DataTexture.js +87 -0
  1113. package/src/textures/DepthTexture.js +104 -0
  1114. package/src/textures/ExternalTexture.js +56 -0
  1115. package/src/textures/FramebufferTexture.js +85 -0
  1116. package/src/textures/Source.js +230 -0
  1117. package/src/textures/Texture.js +801 -0
  1118. package/src/textures/VideoFrameTexture.js +72 -0
  1119. package/src/textures/VideoTexture.js +125 -0
  1120. package/src/utils.js +216 -0
@@ -0,0 +1,3508 @@
1
+ import {
2
+ REVISION,
3
+ BackSide,
4
+ FrontSide,
5
+ DoubleSide,
6
+ HalfFloatType,
7
+ UnsignedByteType,
8
+ NoToneMapping,
9
+ LinearMipmapLinearFilter,
10
+ SRGBColorSpace,
11
+ LinearSRGBColorSpace,
12
+ RGBAIntegerFormat,
13
+ RGIntegerFormat,
14
+ RedIntegerFormat,
15
+ UnsignedIntType,
16
+ UnsignedShortType,
17
+ UnsignedInt248Type,
18
+ UnsignedShort4444Type,
19
+ UnsignedShort5551Type,
20
+ WebGLCoordinateSystem
21
+ } from '../constants.js';
22
+ import { Color } from '../math/Color.js';
23
+ import { Frustum } from '../math/Frustum.js';
24
+ import { Matrix4 } from '../math/Matrix4.js';
25
+ import { Vector3 } from '../math/Vector3.js';
26
+ import { Vector4 } from '../math/Vector4.js';
27
+ import { WebGLAnimation } from './webgl/WebGLAnimation.js';
28
+ import { WebGLAttributes } from './webgl/WebGLAttributes.js';
29
+ import { WebGLBackground } from './webgl/WebGLBackground.js';
30
+ import { WebGLBindingStates } from './webgl/WebGLBindingStates.js';
31
+ import { WebGLBufferRenderer } from './webgl/WebGLBufferRenderer.js';
32
+ import { WebGLCapabilities } from './webgl/WebGLCapabilities.js';
33
+ import { WebGLClipping } from './webgl/WebGLClipping.js';
34
+ import { WebGLCubeMaps } from './webgl/WebGLCubeMaps.js';
35
+ import { WebGLCubeUVMaps } from './webgl/WebGLCubeUVMaps.js';
36
+ import { WebGLExtensions } from './webgl/WebGLExtensions.js';
37
+ import { WebGLGeometries } from './webgl/WebGLGeometries.js';
38
+ import { WebGLIndexedBufferRenderer } from './webgl/WebGLIndexedBufferRenderer.js';
39
+ import { WebGLInfo } from './webgl/WebGLInfo.js';
40
+ import { WebGLMorphtargets } from './webgl/WebGLMorphtargets.js';
41
+ import { WebGLObjects } from './webgl/WebGLObjects.js';
42
+ import { WebGLPrograms } from './webgl/WebGLPrograms.js';
43
+ import { WebGLProperties } from './webgl/WebGLProperties.js';
44
+ import { WebGLRenderLists } from './webgl/WebGLRenderLists.js';
45
+ import { WebGLRenderStates } from './webgl/WebGLRenderStates.js';
46
+ import { WebGLRenderTarget } from './WebGLRenderTarget.js';
47
+ import { WebGLShadowMap } from './webgl/WebGLShadowMap.js';
48
+ import { WebGLState } from './webgl/WebGLState.js';
49
+ import { WebGLTextures } from './webgl/WebGLTextures.js';
50
+ import { WebGLUniforms } from './webgl/WebGLUniforms.js';
51
+ import { WebGLUtils } from './webgl/WebGLUtils.js';
52
+ import { WebXRManager } from './webxr/WebXRManager.js';
53
+ import { WebGLMaterials } from './webgl/WebGLMaterials.js';
54
+ import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
55
+ import { createCanvasElement, probeAsync, warnOnce, error, warn, log } from '../utils.js';
56
+ import { ColorManagement } from '../math/ColorManagement.js';
57
+
58
+ /**
59
+ * This renderer uses WebGL 2 to display scenes.
60
+ *
61
+ * WebGL 1 is not supported since `r163`.
62
+ */
63
+ class WebGLRenderer {
64
+
65
+ /**
66
+ * Constructs a new WebGL renderer.
67
+ *
68
+ * @param {WebGLRenderer~Options} [parameters] - The configuration parameter.
69
+ */
70
+ constructor( parameters = {} ) {
71
+
72
+ const {
73
+ canvas = createCanvasElement(),
74
+ context = null,
75
+ depth = true,
76
+ stencil = false,
77
+ alpha = false,
78
+ antialias = false,
79
+ premultipliedAlpha = true,
80
+ preserveDrawingBuffer = false,
81
+ powerPreference = 'default',
82
+ failIfMajorPerformanceCaveat = false,
83
+ reversedDepthBuffer = false,
84
+ } = parameters;
85
+
86
+ /**
87
+ * This flag can be used for type testing.
88
+ *
89
+ * @type {boolean}
90
+ * @readonly
91
+ * @default true
92
+ */
93
+ this.isWebGLRenderer = true;
94
+
95
+ let _alpha;
96
+
97
+ if ( context !== null ) {
98
+
99
+ if ( typeof WebGLRenderingContext !== 'undefined' && context instanceof WebGLRenderingContext ) {
100
+
101
+ throw new Error( 'THREE.WebGLRenderer: WebGL 1 is not supported since r163.' );
102
+
103
+ }
104
+
105
+ _alpha = context.getContextAttributes().alpha;
106
+
107
+ } else {
108
+
109
+ _alpha = alpha;
110
+
111
+ }
112
+
113
+ const uintClearColor = new Uint32Array( 4 );
114
+ const intClearColor = new Int32Array( 4 );
115
+
116
+ let currentRenderList = null;
117
+ let currentRenderState = null;
118
+
119
+ // render() can be called from within a callback triggered by another render.
120
+ // We track this so that the nested render call gets its list and state isolated from the parent render call.
121
+
122
+ const renderListStack = [];
123
+ const renderStateStack = [];
124
+
125
+ // public properties
126
+
127
+ /**
128
+ * A canvas where the renderer draws its output.This is automatically created by the renderer
129
+ * in the constructor (if not provided already); you just need to add it to your page like so:
130
+ * ```js
131
+ * document.body.appendChild( renderer.domElement );
132
+ * ```
133
+ *
134
+ * @type {HTMLCanvasElement|OffscreenCanvas}
135
+ */
136
+ this.domElement = canvas;
137
+
138
+ /**
139
+ * A object with debug configuration settings.
140
+ *
141
+ * - `checkShaderErrors`: If it is `true`, defines whether material shader programs are
142
+ * checked for errors during compilation and linkage process. It may be useful to disable
143
+ * this check in production for performance gain. It is strongly recommended to keep these
144
+ * checks enabled during development. If the shader does not compile and link - it will not
145
+ * work and associated material will not render.
146
+ * - `onShaderError(gl, program, glVertexShader,glFragmentShader)`: A callback function that
147
+ * can be used for custom error reporting. The callback receives the WebGL context, an instance
148
+ * of WebGLProgram as well two instances of WebGLShader representing the vertex and fragment shader.
149
+ * Assigning a custom function disables the default error reporting.
150
+ *
151
+ * @type {Object}
152
+ */
153
+ this.debug = {
154
+
155
+ /**
156
+ * Enables error checking and reporting when shader programs are being compiled.
157
+ * @type {boolean}
158
+ */
159
+ checkShaderErrors: true,
160
+ /**
161
+ * Callback for custom error reporting.
162
+ * @type {?Function}
163
+ */
164
+ onShaderError: null
165
+ };
166
+
167
+ // clearing
168
+
169
+ /**
170
+ * Whether the renderer should automatically clear its output before rendering a frame or not.
171
+ *
172
+ * @type {boolean}
173
+ * @default true
174
+ */
175
+ this.autoClear = true;
176
+
177
+ /**
178
+ * If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear
179
+ * the color buffer or not.
180
+ *
181
+ * @type {boolean}
182
+ * @default true
183
+ */
184
+ this.autoClearColor = true;
185
+
186
+ /**
187
+ * If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear
188
+ * the depth buffer or not.
189
+ *
190
+ * @type {boolean}
191
+ * @default true
192
+ */
193
+ this.autoClearDepth = true;
194
+
195
+ /**
196
+ * If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear
197
+ * the stencil buffer or not.
198
+ *
199
+ * @type {boolean}
200
+ * @default true
201
+ */
202
+ this.autoClearStencil = true;
203
+
204
+ // scene graph
205
+
206
+ /**
207
+ * Whether the renderer should sort objects or not.
208
+ *
209
+ * Note: Sorting is used to attempt to properly render objects that have some
210
+ * degree of transparency. By definition, sorting objects may not work in all
211
+ * cases. Depending on the needs of application, it may be necessary to turn
212
+ * off sorting and use other methods to deal with transparency rendering e.g.
213
+ * manually determining each object's rendering order.
214
+ *
215
+ * @type {boolean}
216
+ * @default true
217
+ */
218
+ this.sortObjects = true;
219
+
220
+ // user-defined clipping
221
+
222
+ /**
223
+ * User-defined clipping planes specified in world space. These planes apply globally.
224
+ * Points in space whose dot product with the plane is negative are cut away.
225
+ *
226
+ * @type {Array<Plane>}
227
+ */
228
+ this.clippingPlanes = [];
229
+
230
+ /**
231
+ * Whether the renderer respects object-level clipping planes or not.
232
+ *
233
+ * @type {boolean}
234
+ * @default false
235
+ */
236
+ this.localClippingEnabled = false;
237
+
238
+ // tone mapping
239
+
240
+ /**
241
+ * The tone mapping technique of the renderer.
242
+ *
243
+ * @type {(NoToneMapping|LinearToneMapping|ReinhardToneMapping|CineonToneMapping|ACESFilmicToneMapping|CustomToneMapping|AgXToneMapping|NeutralToneMapping)}
244
+ * @default NoToneMapping
245
+ */
246
+ this.toneMapping = NoToneMapping;
247
+
248
+ /**
249
+ * Exposure level of tone mapping.
250
+ *
251
+ * @type {number}
252
+ * @default 1
253
+ */
254
+ this.toneMappingExposure = 1.0;
255
+
256
+ // transmission
257
+
258
+ /**
259
+ * The normalized resolution scale for the transmission render target, measured in percentage
260
+ * of viewport dimensions. Lowering this value can result in significant performance improvements
261
+ * when using {@link MeshPhysicalMaterial#transmission}.
262
+ *
263
+ * @type {number}
264
+ * @default 1
265
+ */
266
+ this.transmissionResolutionScale = 1.0;
267
+
268
+ // internal properties
269
+
270
+ const _this = this;
271
+
272
+ let _isContextLost = false;
273
+
274
+ // internal state cache
275
+
276
+ this._outputColorSpace = SRGBColorSpace;
277
+
278
+ let _currentActiveCubeFace = 0;
279
+ let _currentActiveMipmapLevel = 0;
280
+ let _currentRenderTarget = null;
281
+ let _currentMaterialId = - 1;
282
+
283
+ let _currentCamera = null;
284
+
285
+ const _currentViewport = new Vector4();
286
+ const _currentScissor = new Vector4();
287
+ let _currentScissorTest = null;
288
+
289
+ const _currentClearColor = new Color( 0x000000 );
290
+ let _currentClearAlpha = 0;
291
+
292
+ //
293
+
294
+ let _width = canvas.width;
295
+ let _height = canvas.height;
296
+
297
+ let _pixelRatio = 1;
298
+ let _opaqueSort = null;
299
+ let _transparentSort = null;
300
+
301
+ const _viewport = new Vector4( 0, 0, _width, _height );
302
+ const _scissor = new Vector4( 0, 0, _width, _height );
303
+ let _scissorTest = false;
304
+
305
+ // frustum
306
+
307
+ const _frustum = new Frustum();
308
+
309
+ // clipping
310
+
311
+ let _clippingEnabled = false;
312
+ let _localClippingEnabled = false;
313
+
314
+ // camera matrices cache
315
+
316
+ const _projScreenMatrix = new Matrix4();
317
+
318
+ const _vector3 = new Vector3();
319
+
320
+ const _vector4 = new Vector4();
321
+
322
+ const _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };
323
+
324
+ let _renderBackground = false;
325
+
326
+ function getTargetPixelRatio() {
327
+
328
+ return _currentRenderTarget === null ? _pixelRatio : 1;
329
+
330
+ }
331
+
332
+ // initialize
333
+
334
+ let _gl = context;
335
+
336
+ function getContext( contextName, contextAttributes ) {
337
+
338
+ return canvas.getContext( contextName, contextAttributes );
339
+
340
+ }
341
+
342
+ try {
343
+
344
+ const contextAttributes = {
345
+ alpha: true,
346
+ depth,
347
+ stencil,
348
+ antialias,
349
+ premultipliedAlpha,
350
+ preserveDrawingBuffer,
351
+ powerPreference,
352
+ failIfMajorPerformanceCaveat,
353
+ };
354
+
355
+ // OffscreenCanvas does not have setAttribute, see #22811
356
+ if ( 'setAttribute' in canvas ) canvas.setAttribute( 'data-engine', `three.js r${REVISION}` );
357
+
358
+ // event listeners must be registered before WebGL context is created, see #12753
359
+ canvas.addEventListener( 'webglcontextlost', onContextLost, false );
360
+ canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );
361
+ canvas.addEventListener( 'webglcontextcreationerror', onContextCreationError, false );
362
+
363
+ if ( _gl === null ) {
364
+
365
+ const contextName = 'webgl2';
366
+
367
+ _gl = getContext( contextName, contextAttributes );
368
+
369
+ if ( _gl === null ) {
370
+
371
+ if ( getContext( contextName ) ) {
372
+
373
+ throw new Error( 'Error creating WebGL context with your selected attributes.' );
374
+
375
+ } else {
376
+
377
+ throw new Error( 'Error creating WebGL context.' );
378
+
379
+ }
380
+
381
+ }
382
+
383
+ }
384
+
385
+ } catch ( error ) {
386
+
387
+ error( 'WebGLRenderer: ' + error.message );
388
+ throw error;
389
+
390
+ }
391
+
392
+ let extensions, capabilities, state, info;
393
+ let properties, textures, cubemaps, cubeuvmaps, attributes, geometries, objects;
394
+ let programCache, materials, renderLists, renderStates, clipping, shadowMap;
395
+
396
+ let background, morphtargets, bufferRenderer, indexedBufferRenderer;
397
+
398
+ let utils, bindingStates, uniformsGroups;
399
+
400
+ function initGLContext() {
401
+
402
+ extensions = new WebGLExtensions( _gl );
403
+ extensions.init();
404
+
405
+ utils = new WebGLUtils( _gl, extensions );
406
+
407
+ capabilities = new WebGLCapabilities( _gl, extensions, parameters, utils );
408
+
409
+ state = new WebGLState( _gl, extensions );
410
+
411
+ if ( capabilities.reversedDepthBuffer && reversedDepthBuffer ) {
412
+
413
+ state.buffers.depth.setReversed( true );
414
+
415
+ }
416
+
417
+ info = new WebGLInfo( _gl );
418
+ properties = new WebGLProperties();
419
+ textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );
420
+ cubemaps = new WebGLCubeMaps( _this );
421
+ cubeuvmaps = new WebGLCubeUVMaps( _this );
422
+ attributes = new WebGLAttributes( _gl );
423
+ bindingStates = new WebGLBindingStates( _gl, attributes );
424
+ geometries = new WebGLGeometries( _gl, attributes, info, bindingStates );
425
+ objects = new WebGLObjects( _gl, geometries, attributes, info );
426
+ morphtargets = new WebGLMorphtargets( _gl, capabilities, textures );
427
+ clipping = new WebGLClipping( properties );
428
+ programCache = new WebGLPrograms( _this, cubemaps, cubeuvmaps, extensions, capabilities, bindingStates, clipping );
429
+ materials = new WebGLMaterials( _this, properties );
430
+ renderLists = new WebGLRenderLists();
431
+ renderStates = new WebGLRenderStates( extensions );
432
+ background = new WebGLBackground( _this, cubemaps, cubeuvmaps, state, objects, _alpha, premultipliedAlpha );
433
+ shadowMap = new WebGLShadowMap( _this, objects, capabilities );
434
+ uniformsGroups = new WebGLUniformsGroups( _gl, info, capabilities, state );
435
+
436
+ bufferRenderer = new WebGLBufferRenderer( _gl, extensions, info );
437
+ indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info );
438
+
439
+ info.programs = programCache.programs;
440
+
441
+ /**
442
+ * Holds details about the capabilities of the current rendering context.
443
+ *
444
+ * @name WebGLRenderer#capabilities
445
+ * @type {WebGLRenderer~Capabilities}
446
+ */
447
+ _this.capabilities = capabilities;
448
+
449
+ /**
450
+ * Provides methods for retrieving and testing WebGL extensions.
451
+ *
452
+ * - `get(extensionName:string)`: Used to check whether a WebGL extension is supported
453
+ * and return the extension object if available.
454
+ * - `has(extensionName:string)`: returns `true` if the extension is supported.
455
+ *
456
+ * @name WebGLRenderer#extensions
457
+ * @type {Object}
458
+ */
459
+ _this.extensions = extensions;
460
+
461
+ /**
462
+ * Used to track properties of other objects like native WebGL objects.
463
+ *
464
+ * @name WebGLRenderer#properties
465
+ * @type {Object}
466
+ */
467
+ _this.properties = properties;
468
+
469
+ /**
470
+ * Manages the render lists of the renderer.
471
+ *
472
+ * @name WebGLRenderer#renderLists
473
+ * @type {Object}
474
+ */
475
+ _this.renderLists = renderLists;
476
+
477
+
478
+
479
+ /**
480
+ * Interface for managing shadows.
481
+ *
482
+ * @name WebGLRenderer#shadowMap
483
+ * @type {WebGLRenderer~ShadowMap}
484
+ */
485
+ _this.shadowMap = shadowMap;
486
+
487
+ /**
488
+ * Interface for managing the WebGL state.
489
+ *
490
+ * @name WebGLRenderer#state
491
+ * @type {Object}
492
+ */
493
+ _this.state = state;
494
+
495
+ /**
496
+ * Holds a series of statistical information about the GPU memory
497
+ * and the rendering process. Useful for debugging and monitoring.
498
+ *
499
+ * By default these data are reset at each render call but when having
500
+ * multiple render passes per frame (e.g. when using post processing) it can
501
+ * be preferred to reset with a custom pattern. First, set `autoReset` to
502
+ * `false`.
503
+ * ```js
504
+ * renderer.info.autoReset = false;
505
+ * ```
506
+ * Call `reset()` whenever you have finished to render a single frame.
507
+ * ```js
508
+ * renderer.info.reset();
509
+ * ```
510
+ *
511
+ * @name WebGLRenderer#info
512
+ * @type {WebGLRenderer~Info}
513
+ */
514
+ _this.info = info;
515
+
516
+ }
517
+
518
+ initGLContext();
519
+
520
+ // xr
521
+
522
+ const xr = new WebXRManager( _this, _gl );
523
+
524
+ /**
525
+ * A reference to the XR manager.
526
+ *
527
+ * @type {WebXRManager}
528
+ */
529
+ this.xr = xr;
530
+
531
+ /**
532
+ * Returns the rendering context.
533
+ *
534
+ * @return {WebGL2RenderingContext} The rendering context.
535
+ */
536
+ this.getContext = function () {
537
+
538
+ return _gl;
539
+
540
+ };
541
+
542
+ /**
543
+ * Returns the rendering context attributes.
544
+ *
545
+ * @return {WebGLContextAttributes} The rendering context attributes.
546
+ */
547
+ this.getContextAttributes = function () {
548
+
549
+ return _gl.getContextAttributes();
550
+
551
+ };
552
+
553
+ /**
554
+ * Simulates a loss of the WebGL context. This requires support for the `WEBGL_lose_context` extension.
555
+ */
556
+ this.forceContextLoss = function () {
557
+
558
+ const extension = extensions.get( 'WEBGL_lose_context' );
559
+ if ( extension ) extension.loseContext();
560
+
561
+ };
562
+
563
+ /**
564
+ * Simulates a restore of the WebGL context. This requires support for the `WEBGL_lose_context` extension.
565
+ */
566
+ this.forceContextRestore = function () {
567
+
568
+ const extension = extensions.get( 'WEBGL_lose_context' );
569
+ if ( extension ) extension.restoreContext();
570
+
571
+ };
572
+
573
+ /**
574
+ * Returns the pixel ratio.
575
+ *
576
+ * @return {number} The pixel ratio.
577
+ */
578
+ this.getPixelRatio = function () {
579
+
580
+ return _pixelRatio;
581
+
582
+ };
583
+
584
+ /**
585
+ * Sets the given pixel ratio and resizes the canvas if necessary.
586
+ *
587
+ * @param {number} value - The pixel ratio.
588
+ */
589
+ this.setPixelRatio = function ( value ) {
590
+
591
+ if ( value === undefined ) return;
592
+
593
+ _pixelRatio = value;
594
+
595
+ this.setSize( _width, _height, false );
596
+
597
+ };
598
+
599
+ /**
600
+ * Returns the renderer's size in logical pixels. This method does not honor the pixel ratio.
601
+ *
602
+ * @param {Vector2} target - The method writes the result in this target object.
603
+ * @return {Vector2} The renderer's size in logical pixels.
604
+ */
605
+ this.getSize = function ( target ) {
606
+
607
+ return target.set( _width, _height );
608
+
609
+ };
610
+
611
+ /**
612
+ * Resizes the output canvas to (width, height) with device pixel ratio taken
613
+ * into account, and also sets the viewport to fit that size, starting in (0,
614
+ * 0). Setting `updateStyle` to false prevents any style changes to the output canvas.
615
+ *
616
+ * @param {number} width - The width in logical pixels.
617
+ * @param {number} height - The height in logical pixels.
618
+ * @param {boolean} [updateStyle=true] - Whether to update the `style` attribute of the canvas or not.
619
+ */
620
+ this.setSize = function ( width, height, updateStyle = true ) {
621
+
622
+ if ( xr.isPresenting ) {
623
+
624
+ warn( 'WebGLRenderer: Can\'t change size while VR device is presenting.' );
625
+ return;
626
+
627
+ }
628
+
629
+ _width = width;
630
+ _height = height;
631
+
632
+ canvas.width = Math.floor( width * _pixelRatio );
633
+ canvas.height = Math.floor( height * _pixelRatio );
634
+
635
+ if ( updateStyle === true ) {
636
+
637
+ canvas.style.width = width + 'px';
638
+ canvas.style.height = height + 'px';
639
+
640
+ }
641
+
642
+ this.setViewport( 0, 0, width, height );
643
+
644
+ };
645
+
646
+ /**
647
+ * Returns the drawing buffer size in physical pixels. This method honors the pixel ratio.
648
+ *
649
+ * @param {Vector2} target - The method writes the result in this target object.
650
+ * @return {Vector2} The drawing buffer size.
651
+ */
652
+ this.getDrawingBufferSize = function ( target ) {
653
+
654
+ return target.set( _width * _pixelRatio, _height * _pixelRatio ).floor();
655
+
656
+ };
657
+
658
+ /**
659
+ * This method allows to define the drawing buffer size by specifying
660
+ * width, height and pixel ratio all at once. The size of the drawing
661
+ * buffer is computed with this formula:
662
+ * ```js
663
+ * size.x = width * pixelRatio;
664
+ * size.y = height * pixelRatio;
665
+ * ```
666
+ *
667
+ * @param {number} width - The width in logical pixels.
668
+ * @param {number} height - The height in logical pixels.
669
+ * @param {number} pixelRatio - The pixel ratio.
670
+ */
671
+ this.setDrawingBufferSize = function ( width, height, pixelRatio ) {
672
+
673
+ _width = width;
674
+ _height = height;
675
+
676
+ _pixelRatio = pixelRatio;
677
+
678
+ canvas.width = Math.floor( width * pixelRatio );
679
+ canvas.height = Math.floor( height * pixelRatio );
680
+
681
+ this.setViewport( 0, 0, width, height );
682
+
683
+ };
684
+
685
+ /**
686
+ * Returns the current viewport definition.
687
+ *
688
+ * @param {Vector2} target - The method writes the result in this target object.
689
+ * @return {Vector2} The current viewport definition.
690
+ */
691
+ this.getCurrentViewport = function ( target ) {
692
+
693
+ return target.copy( _currentViewport );
694
+
695
+ };
696
+
697
+ /**
698
+ * Returns the viewport definition.
699
+ *
700
+ * @param {Vector4} target - The method writes the result in this target object.
701
+ * @return {Vector4} The viewport definition.
702
+ */
703
+ this.getViewport = function ( target ) {
704
+
705
+ return target.copy( _viewport );
706
+
707
+ };
708
+
709
+ /**
710
+ * Sets the viewport to render from `(x, y)` to `(x + width, y + height)`.
711
+ *
712
+ * @param {number | Vector4} x - The horizontal coordinate for the lower left corner of the viewport origin in logical pixel unit.
713
+ * Or alternatively a four-component vector specifying all the parameters of the viewport.
714
+ * @param {number} y - The vertical coordinate for the lower left corner of the viewport origin in logical pixel unit.
715
+ * @param {number} width - The width of the viewport in logical pixel unit.
716
+ * @param {number} height - The height of the viewport in logical pixel unit.
717
+ */
718
+ this.setViewport = function ( x, y, width, height ) {
719
+
720
+ if ( x.isVector4 ) {
721
+
722
+ _viewport.set( x.x, x.y, x.z, x.w );
723
+
724
+ } else {
725
+
726
+ _viewport.set( x, y, width, height );
727
+
728
+ }
729
+
730
+ state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).round() );
731
+
732
+ };
733
+
734
+ /**
735
+ * Returns the scissor region.
736
+ *
737
+ * @param {Vector4} target - The method writes the result in this target object.
738
+ * @return {Vector4} The scissor region.
739
+ */
740
+ this.getScissor = function ( target ) {
741
+
742
+ return target.copy( _scissor );
743
+
744
+ };
745
+
746
+ /**
747
+ * Sets the scissor region to render from `(x, y)` to `(x + width, y + height)`.
748
+ *
749
+ * @param {number | Vector4} x - The horizontal coordinate for the lower left corner of the scissor region origin in logical pixel unit.
750
+ * Or alternatively a four-component vector specifying all the parameters of the scissor region.
751
+ * @param {number} y - The vertical coordinate for the lower left corner of the scissor region origin in logical pixel unit.
752
+ * @param {number} width - The width of the scissor region in logical pixel unit.
753
+ * @param {number} height - The height of the scissor region in logical pixel unit.
754
+ */
755
+ this.setScissor = function ( x, y, width, height ) {
756
+
757
+ if ( x.isVector4 ) {
758
+
759
+ _scissor.set( x.x, x.y, x.z, x.w );
760
+
761
+ } else {
762
+
763
+ _scissor.set( x, y, width, height );
764
+
765
+ }
766
+
767
+ state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).round() );
768
+
769
+ };
770
+
771
+ /**
772
+ * Returns `true` if the scissor test is enabled.
773
+ *
774
+ * @return {boolean} Whether the scissor test is enabled or not.
775
+ */
776
+ this.getScissorTest = function () {
777
+
778
+ return _scissorTest;
779
+
780
+ };
781
+
782
+ /**
783
+ * Enable or disable the scissor test. When this is enabled, only the pixels
784
+ * within the defined scissor area will be affected by further renderer
785
+ * actions.
786
+ *
787
+ * @param {boolean} boolean - Whether the scissor test is enabled or not.
788
+ */
789
+ this.setScissorTest = function ( boolean ) {
790
+
791
+ state.setScissorTest( _scissorTest = boolean );
792
+
793
+ };
794
+
795
+ /**
796
+ * Sets a custom opaque sort function for the render lists. Pass `null`
797
+ * to use the default `painterSortStable` function.
798
+ *
799
+ * @param {?Function} method - The opaque sort function.
800
+ */
801
+ this.setOpaqueSort = function ( method ) {
802
+
803
+ _opaqueSort = method;
804
+
805
+ };
806
+
807
+ /**
808
+ * Sets a custom transparent sort function for the render lists. Pass `null`
809
+ * to use the default `reversePainterSortStable` function.
810
+ *
811
+ * @param {?Function} method - The opaque sort function.
812
+ */
813
+ this.setTransparentSort = function ( method ) {
814
+
815
+ _transparentSort = method;
816
+
817
+ };
818
+
819
+ // Clearing
820
+
821
+ /**
822
+ * Returns the clear color.
823
+ *
824
+ * @param {Color} target - The method writes the result in this target object.
825
+ * @return {Color} The clear color.
826
+ */
827
+ this.getClearColor = function ( target ) {
828
+
829
+ return target.copy( background.getClearColor() );
830
+
831
+ };
832
+
833
+ /**
834
+ * Sets the clear color and alpha.
835
+ *
836
+ * @param {Color} color - The clear color.
837
+ * @param {number} [alpha=1] - The clear alpha.
838
+ */
839
+ this.setClearColor = function () {
840
+
841
+ background.setClearColor( ...arguments );
842
+
843
+ };
844
+
845
+ /**
846
+ * Returns the clear alpha. Ranges within `[0,1]`.
847
+ *
848
+ * @return {number} The clear alpha.
849
+ */
850
+ this.getClearAlpha = function () {
851
+
852
+ return background.getClearAlpha();
853
+
854
+ };
855
+
856
+ /**
857
+ * Sets the clear alpha.
858
+ *
859
+ * @param {number} alpha - The clear alpha.
860
+ */
861
+ this.setClearAlpha = function () {
862
+
863
+ background.setClearAlpha( ...arguments );
864
+
865
+ };
866
+
867
+ /**
868
+ * Tells the renderer to clear its color, depth or stencil drawing buffer(s).
869
+ * This method initializes the buffers to the current clear color values.
870
+ *
871
+ * @param {boolean} [color=true] - Whether the color buffer should be cleared or not.
872
+ * @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not.
873
+ * @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not.
874
+ */
875
+ this.clear = function ( color = true, depth = true, stencil = true ) {
876
+
877
+ let bits = 0;
878
+
879
+ if ( color ) {
880
+
881
+ // check if we're trying to clear an integer target
882
+ let isIntegerFormat = false;
883
+ if ( _currentRenderTarget !== null ) {
884
+
885
+ const targetFormat = _currentRenderTarget.texture.format;
886
+ isIntegerFormat = targetFormat === RGBAIntegerFormat ||
887
+ targetFormat === RGIntegerFormat ||
888
+ targetFormat === RedIntegerFormat;
889
+
890
+ }
891
+
892
+ // use the appropriate clear functions to clear the target if it's a signed
893
+ // or unsigned integer target
894
+ if ( isIntegerFormat ) {
895
+
896
+ const targetType = _currentRenderTarget.texture.type;
897
+ const isUnsignedType = targetType === UnsignedByteType ||
898
+ targetType === UnsignedIntType ||
899
+ targetType === UnsignedShortType ||
900
+ targetType === UnsignedInt248Type ||
901
+ targetType === UnsignedShort4444Type ||
902
+ targetType === UnsignedShort5551Type;
903
+
904
+ const clearColor = background.getClearColor();
905
+ const a = background.getClearAlpha();
906
+ const r = clearColor.r;
907
+ const g = clearColor.g;
908
+ const b = clearColor.b;
909
+
910
+ if ( isUnsignedType ) {
911
+
912
+ uintClearColor[ 0 ] = r;
913
+ uintClearColor[ 1 ] = g;
914
+ uintClearColor[ 2 ] = b;
915
+ uintClearColor[ 3 ] = a;
916
+ _gl.clearBufferuiv( _gl.COLOR, 0, uintClearColor );
917
+
918
+ } else {
919
+
920
+ intClearColor[ 0 ] = r;
921
+ intClearColor[ 1 ] = g;
922
+ intClearColor[ 2 ] = b;
923
+ intClearColor[ 3 ] = a;
924
+ _gl.clearBufferiv( _gl.COLOR, 0, intClearColor );
925
+
926
+ }
927
+
928
+ } else {
929
+
930
+ bits |= _gl.COLOR_BUFFER_BIT;
931
+
932
+ }
933
+
934
+ }
935
+
936
+ if ( depth ) {
937
+
938
+ bits |= _gl.DEPTH_BUFFER_BIT;
939
+
940
+ }
941
+
942
+ if ( stencil ) {
943
+
944
+ bits |= _gl.STENCIL_BUFFER_BIT;
945
+ this.state.buffers.stencil.setMask( 0xffffffff );
946
+
947
+ }
948
+
949
+ _gl.clear( bits );
950
+
951
+ };
952
+
953
+ /**
954
+ * Clears the color buffer. Equivalent to calling `renderer.clear( true, false, false )`.
955
+ */
956
+ this.clearColor = function () {
957
+
958
+ this.clear( true, false, false );
959
+
960
+ };
961
+
962
+ /**
963
+ * Clears the depth buffer. Equivalent to calling `renderer.clear( false, true, false )`.
964
+ */
965
+ this.clearDepth = function () {
966
+
967
+ this.clear( false, true, false );
968
+
969
+ };
970
+
971
+ /**
972
+ * Clears the stencil buffer. Equivalent to calling `renderer.clear( false, false, true )`.
973
+ */
974
+ this.clearStencil = function () {
975
+
976
+ this.clear( false, false, true );
977
+
978
+ };
979
+
980
+ /**
981
+ * Frees the GPU-related resources allocated by this instance. Call this
982
+ * method whenever this instance is no longer used in your app.
983
+ */
984
+ this.dispose = function () {
985
+
986
+ canvas.removeEventListener( 'webglcontextlost', onContextLost, false );
987
+ canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );
988
+ canvas.removeEventListener( 'webglcontextcreationerror', onContextCreationError, false );
989
+
990
+ background.dispose();
991
+ renderLists.dispose();
992
+ renderStates.dispose();
993
+ properties.dispose();
994
+ cubemaps.dispose();
995
+ cubeuvmaps.dispose();
996
+ objects.dispose();
997
+ bindingStates.dispose();
998
+ uniformsGroups.dispose();
999
+ programCache.dispose();
1000
+
1001
+ xr.dispose();
1002
+
1003
+ xr.removeEventListener( 'sessionstart', onXRSessionStart );
1004
+ xr.removeEventListener( 'sessionend', onXRSessionEnd );
1005
+
1006
+ animation.stop();
1007
+
1008
+ };
1009
+
1010
+ // Events
1011
+
1012
+ function onContextLost( event ) {
1013
+
1014
+ event.preventDefault();
1015
+
1016
+ log( 'WebGLRenderer: Context Lost.' );
1017
+
1018
+ _isContextLost = true;
1019
+
1020
+ }
1021
+
1022
+ function onContextRestore( /* event */ ) {
1023
+
1024
+ log( 'WebGLRenderer: Context Restored.' );
1025
+
1026
+ _isContextLost = false;
1027
+
1028
+ const infoAutoReset = info.autoReset;
1029
+ const shadowMapEnabled = shadowMap.enabled;
1030
+ const shadowMapAutoUpdate = shadowMap.autoUpdate;
1031
+ const shadowMapNeedsUpdate = shadowMap.needsUpdate;
1032
+ const shadowMapType = shadowMap.type;
1033
+
1034
+ initGLContext();
1035
+
1036
+ info.autoReset = infoAutoReset;
1037
+ shadowMap.enabled = shadowMapEnabled;
1038
+ shadowMap.autoUpdate = shadowMapAutoUpdate;
1039
+ shadowMap.needsUpdate = shadowMapNeedsUpdate;
1040
+ shadowMap.type = shadowMapType;
1041
+
1042
+ }
1043
+
1044
+ function onContextCreationError( event ) {
1045
+
1046
+ error( 'WebGLRenderer: A WebGL context could not be created. Reason: ', event.statusMessage );
1047
+
1048
+ }
1049
+
1050
+ function onMaterialDispose( event ) {
1051
+
1052
+ const material = event.target;
1053
+
1054
+ material.removeEventListener( 'dispose', onMaterialDispose );
1055
+
1056
+ deallocateMaterial( material );
1057
+
1058
+ }
1059
+
1060
+ // Buffer deallocation
1061
+
1062
+ function deallocateMaterial( material ) {
1063
+
1064
+ releaseMaterialProgramReferences( material );
1065
+
1066
+ properties.remove( material );
1067
+
1068
+ }
1069
+
1070
+
1071
+ function releaseMaterialProgramReferences( material ) {
1072
+
1073
+ const programs = properties.get( material ).programs;
1074
+
1075
+ if ( programs !== undefined ) {
1076
+
1077
+ programs.forEach( function ( program ) {
1078
+
1079
+ programCache.releaseProgram( program );
1080
+
1081
+ } );
1082
+
1083
+ if ( material.isShaderMaterial ) {
1084
+
1085
+ programCache.releaseShaderCache( material );
1086
+
1087
+ }
1088
+
1089
+ }
1090
+
1091
+ }
1092
+
1093
+ // Buffer rendering
1094
+
1095
+ this.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) {
1096
+
1097
+ if ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)
1098
+
1099
+ const frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 );
1100
+
1101
+ const program = setProgram( camera, scene, geometry, material, object );
1102
+
1103
+ state.setMaterial( material, frontFaceCW );
1104
+
1105
+ //
1106
+
1107
+ let index = geometry.index;
1108
+ let rangeFactor = 1;
1109
+
1110
+ if ( material.wireframe === true ) {
1111
+
1112
+ index = geometries.getWireframeAttribute( geometry );
1113
+
1114
+ if ( index === undefined ) return;
1115
+
1116
+ rangeFactor = 2;
1117
+
1118
+ }
1119
+
1120
+ //
1121
+
1122
+ const drawRange = geometry.drawRange;
1123
+ const position = geometry.attributes.position;
1124
+
1125
+ let drawStart = drawRange.start * rangeFactor;
1126
+ let drawEnd = ( drawRange.start + drawRange.count ) * rangeFactor;
1127
+
1128
+ if ( group !== null ) {
1129
+
1130
+ drawStart = Math.max( drawStart, group.start * rangeFactor );
1131
+ drawEnd = Math.min( drawEnd, ( group.start + group.count ) * rangeFactor );
1132
+
1133
+ }
1134
+
1135
+ if ( index !== null ) {
1136
+
1137
+ drawStart = Math.max( drawStart, 0 );
1138
+ drawEnd = Math.min( drawEnd, index.count );
1139
+
1140
+ } else if ( position !== undefined && position !== null ) {
1141
+
1142
+ drawStart = Math.max( drawStart, 0 );
1143
+ drawEnd = Math.min( drawEnd, position.count );
1144
+
1145
+ }
1146
+
1147
+ const drawCount = drawEnd - drawStart;
1148
+
1149
+ if ( drawCount < 0 || drawCount === Infinity ) return;
1150
+
1151
+ //
1152
+
1153
+ bindingStates.setup( object, material, program, geometry, index );
1154
+
1155
+ let attribute;
1156
+ let renderer = bufferRenderer;
1157
+
1158
+ if ( index !== null ) {
1159
+
1160
+ attribute = attributes.get( index );
1161
+
1162
+ renderer = indexedBufferRenderer;
1163
+ renderer.setIndex( attribute );
1164
+
1165
+ }
1166
+
1167
+ //
1168
+
1169
+ if ( object.isMesh ) {
1170
+
1171
+ if ( material.wireframe === true ) {
1172
+
1173
+ state.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() );
1174
+ renderer.setMode( _gl.LINES );
1175
+
1176
+ } else {
1177
+
1178
+ renderer.setMode( _gl.TRIANGLES );
1179
+
1180
+ }
1181
+
1182
+ } else if ( object.isLine ) {
1183
+
1184
+ let lineWidth = material.linewidth;
1185
+
1186
+ if ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material
1187
+
1188
+ state.setLineWidth( lineWidth * getTargetPixelRatio() );
1189
+
1190
+ if ( object.isLineSegments ) {
1191
+
1192
+ renderer.setMode( _gl.LINES );
1193
+
1194
+ } else if ( object.isLineLoop ) {
1195
+
1196
+ renderer.setMode( _gl.LINE_LOOP );
1197
+
1198
+ } else {
1199
+
1200
+ renderer.setMode( _gl.LINE_STRIP );
1201
+
1202
+ }
1203
+
1204
+ } else if ( object.isPoints ) {
1205
+
1206
+ renderer.setMode( _gl.POINTS );
1207
+
1208
+ } else if ( object.isSprite ) {
1209
+
1210
+ renderer.setMode( _gl.TRIANGLES );
1211
+
1212
+ }
1213
+
1214
+ if ( object.isBatchedMesh ) {
1215
+
1216
+ if ( object._multiDrawInstances !== null ) {
1217
+
1218
+ // @deprecated, r174
1219
+ warnOnce( 'WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.' );
1220
+ renderer.renderMultiDrawInstances( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount, object._multiDrawInstances );
1221
+
1222
+ } else {
1223
+
1224
+ if ( ! extensions.get( 'WEBGL_multi_draw' ) ) {
1225
+
1226
+ const starts = object._multiDrawStarts;
1227
+ const counts = object._multiDrawCounts;
1228
+ const drawCount = object._multiDrawCount;
1229
+ const bytesPerElement = index ? attributes.get( index ).bytesPerElement : 1;
1230
+ const uniforms = properties.get( material ).currentProgram.getUniforms();
1231
+ for ( let i = 0; i < drawCount; i ++ ) {
1232
+
1233
+ uniforms.setValue( _gl, '_gl_DrawID', i );
1234
+ renderer.render( starts[ i ] / bytesPerElement, counts[ i ] );
1235
+
1236
+ }
1237
+
1238
+ } else {
1239
+
1240
+ renderer.renderMultiDraw( object._multiDrawStarts, object._multiDrawCounts, object._multiDrawCount );
1241
+
1242
+ }
1243
+
1244
+ }
1245
+
1246
+ } else if ( object.isInstancedMesh ) {
1247
+
1248
+ renderer.renderInstances( drawStart, drawCount, object.count );
1249
+
1250
+ } else if ( geometry.isInstancedBufferGeometry ) {
1251
+
1252
+ const maxInstanceCount = geometry._maxInstanceCount !== undefined ? geometry._maxInstanceCount : Infinity;
1253
+ const instanceCount = Math.min( geometry.instanceCount, maxInstanceCount );
1254
+
1255
+ renderer.renderInstances( drawStart, drawCount, instanceCount );
1256
+
1257
+ } else {
1258
+
1259
+ renderer.render( drawStart, drawCount );
1260
+
1261
+ }
1262
+
1263
+ };
1264
+
1265
+ // Compile
1266
+
1267
+ function prepareMaterial( material, scene, object ) {
1268
+
1269
+ if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
1270
+
1271
+ material.side = BackSide;
1272
+ material.needsUpdate = true;
1273
+ getProgram( material, scene, object );
1274
+
1275
+ material.side = FrontSide;
1276
+ material.needsUpdate = true;
1277
+ getProgram( material, scene, object );
1278
+
1279
+ material.side = DoubleSide;
1280
+
1281
+ } else {
1282
+
1283
+ getProgram( material, scene, object );
1284
+
1285
+ }
1286
+
1287
+ }
1288
+
1289
+ /**
1290
+ * Compiles all materials in the scene with the camera. This is useful to precompile shaders
1291
+ * before the first rendering. If you want to add a 3D object to an existing scene, use the third
1292
+ * optional parameter for applying the target scene.
1293
+ *
1294
+ * Note that the (target) scene's lighting and environment must be configured before calling this method.
1295
+ *
1296
+ * @param {Object3D} scene - The scene or another type of 3D object to precompile.
1297
+ * @param {Camera} camera - The camera.
1298
+ * @param {?Scene} [targetScene=null] - The target scene.
1299
+ * @return {Set<Material>} The precompiled materials.
1300
+ */
1301
+ this.compile = function ( scene, camera, targetScene = null ) {
1302
+
1303
+ if ( targetScene === null ) targetScene = scene;
1304
+
1305
+ currentRenderState = renderStates.get( targetScene );
1306
+ currentRenderState.init( camera );
1307
+
1308
+ renderStateStack.push( currentRenderState );
1309
+
1310
+ // gather lights from both the target scene and the new object that will be added to the scene.
1311
+
1312
+ targetScene.traverseVisible( function ( object ) {
1313
+
1314
+ if ( object.isLight && object.layers.test( camera.layers ) ) {
1315
+
1316
+ currentRenderState.pushLight( object );
1317
+
1318
+ if ( object.castShadow ) {
1319
+
1320
+ currentRenderState.pushShadow( object );
1321
+
1322
+ }
1323
+
1324
+ }
1325
+
1326
+ } );
1327
+
1328
+ if ( scene !== targetScene ) {
1329
+
1330
+ scene.traverseVisible( function ( object ) {
1331
+
1332
+ if ( object.isLight && object.layers.test( camera.layers ) ) {
1333
+
1334
+ currentRenderState.pushLight( object );
1335
+
1336
+ if ( object.castShadow ) {
1337
+
1338
+ currentRenderState.pushShadow( object );
1339
+
1340
+ }
1341
+
1342
+ }
1343
+
1344
+ } );
1345
+
1346
+ }
1347
+
1348
+ currentRenderState.setupLights();
1349
+
1350
+ // Only initialize materials in the new scene, not the targetScene.
1351
+
1352
+ const materials = new Set();
1353
+
1354
+ scene.traverse( function ( object ) {
1355
+
1356
+ if ( ! ( object.isMesh || object.isPoints || object.isLine || object.isSprite ) ) {
1357
+
1358
+ return;
1359
+
1360
+ }
1361
+
1362
+ const material = object.material;
1363
+
1364
+ if ( material ) {
1365
+
1366
+ if ( Array.isArray( material ) ) {
1367
+
1368
+ for ( let i = 0; i < material.length; i ++ ) {
1369
+
1370
+ const material2 = material[ i ];
1371
+
1372
+ prepareMaterial( material2, targetScene, object );
1373
+ materials.add( material2 );
1374
+
1375
+ }
1376
+
1377
+ } else {
1378
+
1379
+ prepareMaterial( material, targetScene, object );
1380
+ materials.add( material );
1381
+
1382
+ }
1383
+
1384
+ }
1385
+
1386
+ } );
1387
+
1388
+ currentRenderState = renderStateStack.pop();
1389
+
1390
+ return materials;
1391
+
1392
+ };
1393
+
1394
+ // compileAsync
1395
+
1396
+ /**
1397
+ * Asynchronous version of {@link WebGLRenderer#compile}.
1398
+ *
1399
+ * This method makes use of the `KHR_parallel_shader_compile` WebGL extension. Hence,
1400
+ * it is recommended to use this version of `compile()` whenever possible.
1401
+ *
1402
+ * @async
1403
+ * @param {Object3D} scene - The scene or another type of 3D object to precompile.
1404
+ * @param {Camera} camera - The camera.
1405
+ * @param {?Scene} [targetScene=null] - The target scene.
1406
+ * @return {Promise} A Promise that resolves when the given scene can be rendered without unnecessary stalling due to shader compilation.
1407
+ */
1408
+ this.compileAsync = function ( scene, camera, targetScene = null ) {
1409
+
1410
+ const materials = this.compile( scene, camera, targetScene );
1411
+
1412
+ // Wait for all the materials in the new object to indicate that they're
1413
+ // ready to be used before resolving the promise.
1414
+
1415
+ return new Promise( ( resolve ) => {
1416
+
1417
+ function checkMaterialsReady() {
1418
+
1419
+ materials.forEach( function ( material ) {
1420
+
1421
+ const materialProperties = properties.get( material );
1422
+ const program = materialProperties.currentProgram;
1423
+
1424
+ if ( program.isReady() ) {
1425
+
1426
+ // remove any programs that report they're ready to use from the list
1427
+ materials.delete( material );
1428
+
1429
+ }
1430
+
1431
+ } );
1432
+
1433
+ // once the list of compiling materials is empty, call the callback
1434
+
1435
+ if ( materials.size === 0 ) {
1436
+
1437
+ resolve( scene );
1438
+ return;
1439
+
1440
+ }
1441
+
1442
+ // if some materials are still not ready, wait a bit and check again
1443
+
1444
+ setTimeout( checkMaterialsReady, 10 );
1445
+
1446
+ }
1447
+
1448
+ if ( extensions.get( 'KHR_parallel_shader_compile' ) !== null ) {
1449
+
1450
+ // If we can check the compilation status of the materials without
1451
+ // blocking then do so right away.
1452
+
1453
+ checkMaterialsReady();
1454
+
1455
+ } else {
1456
+
1457
+ // Otherwise start by waiting a bit to give the materials we just
1458
+ // initialized a chance to finish.
1459
+
1460
+ setTimeout( checkMaterialsReady, 10 );
1461
+
1462
+ }
1463
+
1464
+ } );
1465
+
1466
+ };
1467
+
1468
+ // Animation Loop
1469
+
1470
+ let onAnimationFrameCallback = null;
1471
+
1472
+ function onAnimationFrame( time ) {
1473
+
1474
+ if ( onAnimationFrameCallback ) onAnimationFrameCallback( time );
1475
+
1476
+ }
1477
+
1478
+ function onXRSessionStart() {
1479
+
1480
+ animation.stop();
1481
+
1482
+ }
1483
+
1484
+ function onXRSessionEnd() {
1485
+
1486
+ animation.start();
1487
+
1488
+ }
1489
+
1490
+ const animation = new WebGLAnimation();
1491
+ animation.setAnimationLoop( onAnimationFrame );
1492
+
1493
+ if ( typeof self !== 'undefined' ) animation.setContext( self );
1494
+
1495
+ /**
1496
+ * Applications are advised to always define the animation loop
1497
+ * with this method and not manually with `requestAnimationFrame()`
1498
+ * for best compatibility.
1499
+ *
1500
+ * @param {?onAnimationCallback} callback - The application's animation loop.
1501
+ */
1502
+ this.setAnimationLoop = function ( callback ) {
1503
+
1504
+ onAnimationFrameCallback = callback;
1505
+ xr.setAnimationLoop( callback );
1506
+
1507
+ ( callback === null ) ? animation.stop() : animation.start();
1508
+
1509
+ };
1510
+
1511
+ xr.addEventListener( 'sessionstart', onXRSessionStart );
1512
+ xr.addEventListener( 'sessionend', onXRSessionEnd );
1513
+
1514
+ // Rendering
1515
+
1516
+ /**
1517
+ * Renders the given scene (or other type of 3D object) using the given camera.
1518
+ *
1519
+ * The render is done to a previously specified render target set by calling {@link WebGLRenderer#setRenderTarget}
1520
+ * or to the canvas as usual.
1521
+ *
1522
+ * By default render buffers are cleared before rendering but you can prevent
1523
+ * this by setting the property `autoClear` to `false`. If you want to prevent
1524
+ * only certain buffers being cleared you can `autoClearColor`, `autoClearDepth`
1525
+ * or `autoClearStencil` to `false`. To force a clear, use {@link WebGLRenderer#clear}.
1526
+ *
1527
+ * @param {Object3D} scene - The scene to render.
1528
+ * @param {Camera} camera - The camera.
1529
+ */
1530
+ this.render = function ( scene, camera ) {
1531
+
1532
+ if ( camera !== undefined && camera.isCamera !== true ) {
1533
+
1534
+ error( 'WebGLRenderer.render: camera is not an instance of THREE.Camera.' );
1535
+ return;
1536
+
1537
+ }
1538
+
1539
+ if ( _isContextLost === true ) return;
1540
+
1541
+ // update scene graph
1542
+
1543
+ if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
1544
+
1545
+ // update camera matrices and frustum
1546
+
1547
+ if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
1548
+
1549
+ if ( xr.enabled === true && xr.isPresenting === true ) {
1550
+
1551
+ if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera );
1552
+
1553
+ camera = xr.getCamera(); // use XR camera for rendering
1554
+
1555
+ }
1556
+
1557
+ //
1558
+ if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, _currentRenderTarget );
1559
+
1560
+ currentRenderState = renderStates.get( scene, renderStateStack.length );
1561
+ currentRenderState.init( camera );
1562
+
1563
+ renderStateStack.push( currentRenderState );
1564
+
1565
+ _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
1566
+ _frustum.setFromProjectionMatrix( _projScreenMatrix, WebGLCoordinateSystem, camera.reversedDepth );
1567
+
1568
+ _localClippingEnabled = this.localClippingEnabled;
1569
+ _clippingEnabled = clipping.init( this.clippingPlanes, _localClippingEnabled );
1570
+
1571
+ currentRenderList = renderLists.get( scene, renderListStack.length );
1572
+ currentRenderList.init();
1573
+
1574
+ renderListStack.push( currentRenderList );
1575
+
1576
+ if ( xr.enabled === true && xr.isPresenting === true ) {
1577
+
1578
+ const depthSensingMesh = _this.xr.getDepthSensingMesh();
1579
+
1580
+ if ( depthSensingMesh !== null ) {
1581
+
1582
+ projectObject( depthSensingMesh, camera, - Infinity, _this.sortObjects );
1583
+
1584
+ }
1585
+
1586
+ }
1587
+
1588
+ projectObject( scene, camera, 0, _this.sortObjects );
1589
+
1590
+ currentRenderList.finish();
1591
+
1592
+ if ( _this.sortObjects === true ) {
1593
+
1594
+ currentRenderList.sort( _opaqueSort, _transparentSort );
1595
+
1596
+ }
1597
+
1598
+ _renderBackground = xr.enabled === false || xr.isPresenting === false || xr.hasDepthSensing() === false;
1599
+ if ( _renderBackground ) {
1600
+
1601
+ background.addToRenderList( currentRenderList, scene );
1602
+
1603
+ }
1604
+
1605
+ //
1606
+
1607
+ this.info.render.frame ++;
1608
+
1609
+ if ( _clippingEnabled === true ) clipping.beginShadows();
1610
+
1611
+ const shadowsArray = currentRenderState.state.shadowsArray;
1612
+
1613
+ shadowMap.render( shadowsArray, scene, camera );
1614
+
1615
+ if ( _clippingEnabled === true ) clipping.endShadows();
1616
+
1617
+ //
1618
+
1619
+ if ( this.info.autoReset === true ) this.info.reset();
1620
+
1621
+ // render scene
1622
+
1623
+ const opaqueObjects = currentRenderList.opaque;
1624
+ const transmissiveObjects = currentRenderList.transmissive;
1625
+
1626
+ currentRenderState.setupLights(scene.iesProfiles);
1627
+
1628
+ if ( camera.isArrayCamera ) {
1629
+
1630
+ const cameras = camera.cameras;
1631
+
1632
+ if ( transmissiveObjects.length > 0 ) {
1633
+
1634
+ for ( let i = 0, l = cameras.length; i < l; i ++ ) {
1635
+
1636
+ const camera2 = cameras[ i ];
1637
+
1638
+ renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera2 );
1639
+
1640
+ }
1641
+
1642
+ }
1643
+
1644
+ if ( _renderBackground ) background.render( scene );
1645
+
1646
+ for ( let i = 0, l = cameras.length; i < l; i ++ ) {
1647
+
1648
+ const camera2 = cameras[ i ];
1649
+
1650
+ renderScene( currentRenderList, scene, camera2, camera2.viewport );
1651
+
1652
+ }
1653
+
1654
+ } else {
1655
+
1656
+ if ( transmissiveObjects.length > 0 ) renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera );
1657
+
1658
+ if ( _renderBackground ) background.render( scene );
1659
+
1660
+ renderScene( currentRenderList, scene, camera );
1661
+
1662
+ }
1663
+
1664
+ //
1665
+
1666
+ if ( _currentRenderTarget !== null && _currentActiveMipmapLevel === 0 ) {
1667
+
1668
+ // resolve multisample renderbuffers to a single-sample texture if necessary
1669
+
1670
+ textures.updateMultisampleRenderTarget( _currentRenderTarget );
1671
+
1672
+ // Generate mipmap if we're using any kind of mipmap filtering
1673
+
1674
+ textures.updateRenderTargetMipmap( _currentRenderTarget );
1675
+
1676
+ }
1677
+
1678
+ //
1679
+
1680
+ if ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );
1681
+
1682
+ // _gl.finish();
1683
+
1684
+ bindingStates.resetDefaultState();
1685
+ _currentMaterialId = - 1;
1686
+ _currentCamera = null;
1687
+
1688
+ renderStateStack.pop();
1689
+
1690
+ if ( renderStateStack.length > 0 ) {
1691
+
1692
+ currentRenderState = renderStateStack[ renderStateStack.length - 1 ];
1693
+
1694
+ if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, currentRenderState.state.camera );
1695
+
1696
+ } else {
1697
+
1698
+ currentRenderState = null;
1699
+
1700
+ }
1701
+
1702
+ renderListStack.pop();
1703
+
1704
+ if ( renderListStack.length > 0 ) {
1705
+
1706
+ currentRenderList = renderListStack[ renderListStack.length - 1 ];
1707
+
1708
+ } else {
1709
+
1710
+ currentRenderList = null;
1711
+
1712
+ }
1713
+
1714
+ };
1715
+
1716
+ function projectObject( object, camera, groupOrder, sortObjects ) {
1717
+
1718
+ if ( object.visible === false ) return;
1719
+
1720
+ const visible = object.layers.test( camera.layers );
1721
+
1722
+ if ( visible ) {
1723
+
1724
+ if ( object.isGroup ) {
1725
+
1726
+ groupOrder = object.renderOrder;
1727
+
1728
+ } else if ( object.isLOD ) {
1729
+
1730
+ if ( object.autoUpdate === true ) object.update( camera );
1731
+
1732
+ } else if ( object.isLight ) {
1733
+
1734
+ currentRenderState.pushLight( object );
1735
+
1736
+ if ( object.castShadow ) {
1737
+
1738
+ currentRenderState.pushShadow( object );
1739
+
1740
+ }
1741
+
1742
+ } else if ( object.isSprite ) {
1743
+
1744
+ if ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {
1745
+
1746
+ if ( sortObjects ) {
1747
+
1748
+ _vector4.setFromMatrixPosition( object.matrixWorld )
1749
+ .applyMatrix4( _projScreenMatrix );
1750
+
1751
+ }
1752
+
1753
+ const geometry = objects.update( object );
1754
+ const material = object.material;
1755
+
1756
+ if ( material.visible ) {
1757
+
1758
+ currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
1759
+
1760
+ }
1761
+
1762
+ }
1763
+
1764
+ } else if ( object.isMesh || object.isLine || object.isPoints ) {
1765
+
1766
+ if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {
1767
+
1768
+ const geometry = objects.update( object );
1769
+ const material = object.material;
1770
+
1771
+ if ( sortObjects ) {
1772
+
1773
+ if ( object.boundingSphere !== undefined ) {
1774
+
1775
+ if ( object.boundingSphere === null ) object.computeBoundingSphere();
1776
+ _vector4.copy( object.boundingSphere.center );
1777
+
1778
+ } else {
1779
+
1780
+ if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
1781
+ _vector4.copy( geometry.boundingSphere.center );
1782
+
1783
+ }
1784
+
1785
+ _vector4
1786
+ .applyMatrix4( object.matrixWorld )
1787
+ .applyMatrix4( _projScreenMatrix );
1788
+
1789
+ }
1790
+
1791
+ if ( Array.isArray( material ) ) {
1792
+
1793
+ const groups = geometry.groups;
1794
+
1795
+ for ( let i = 0, l = groups.length; i < l; i ++ ) {
1796
+
1797
+ const group = groups[ i ];
1798
+ const groupMaterial = material[ group.materialIndex ];
1799
+
1800
+ if ( groupMaterial && groupMaterial.visible ) {
1801
+
1802
+ currentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector4.z, group );
1803
+
1804
+ }
1805
+
1806
+ }
1807
+
1808
+ } else if ( material.visible ) {
1809
+
1810
+ currentRenderList.push( object, geometry, material, groupOrder, _vector4.z, null );
1811
+
1812
+ }
1813
+
1814
+ }
1815
+
1816
+ }
1817
+
1818
+ }
1819
+
1820
+ const children = object.children;
1821
+
1822
+ for ( let i = 0, l = children.length; i < l; i ++ ) {
1823
+
1824
+ projectObject( children[ i ], camera, groupOrder, sortObjects );
1825
+
1826
+ }
1827
+
1828
+ }
1829
+
1830
+ function renderScene( currentRenderList, scene, camera, viewport ) {
1831
+
1832
+ const opaqueObjects = currentRenderList.opaque;
1833
+ const transmissiveObjects = currentRenderList.transmissive;
1834
+ const transparentObjects = currentRenderList.transparent;
1835
+
1836
+ currentRenderState.setupLightsView( camera );
1837
+
1838
+ if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
1839
+
1840
+ if ( viewport ) state.viewport( _currentViewport.copy( viewport ) );
1841
+
1842
+ if ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );
1843
+ if ( transmissiveObjects.length > 0 ) renderObjects( transmissiveObjects, scene, camera );
1844
+ if ( transparentObjects.length > 0 ) renderObjects( transparentObjects, scene, camera );
1845
+
1846
+ // Ensure depth buffer writing is enabled so it can be cleared on next render
1847
+
1848
+ state.buffers.depth.setTest( true );
1849
+ state.buffers.depth.setMask( true );
1850
+ state.buffers.color.setMask( true );
1851
+
1852
+ state.setPolygonOffset( false );
1853
+
1854
+ }
1855
+
1856
+ function renderTransmissionPass( opaqueObjects, transmissiveObjects, scene, camera ) {
1857
+
1858
+ const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;
1859
+
1860
+ if ( overrideMaterial !== null ) {
1861
+
1862
+ return;
1863
+
1864
+ }
1865
+
1866
+ if ( currentRenderState.state.transmissionRenderTarget[ camera.id ] === undefined ) {
1867
+
1868
+ currentRenderState.state.transmissionRenderTarget[ camera.id ] = new WebGLRenderTarget( 1, 1, {
1869
+ generateMipmaps: true,
1870
+ type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
1871
+ minFilter: LinearMipmapLinearFilter,
1872
+ samples: 4,
1873
+ stencilBuffer: stencil,
1874
+ resolveDepthBuffer: false,
1875
+ resolveStencilBuffer: false,
1876
+ colorSpace: ColorManagement.workingColorSpace,
1877
+ } );
1878
+
1879
+ // debug
1880
+
1881
+ /*
1882
+ const geometry = new PlaneGeometry();
1883
+ const material = new MeshBasicMaterial( { map: _transmissionRenderTarget.texture } );
1884
+
1885
+ const mesh = new Mesh( geometry, material );
1886
+ scene.add( mesh );
1887
+ */
1888
+
1889
+ }
1890
+
1891
+ const transmissionRenderTarget = currentRenderState.state.transmissionRenderTarget[ camera.id ];
1892
+
1893
+ const activeViewport = camera.viewport || _currentViewport;
1894
+ transmissionRenderTarget.setSize( activeViewport.z * _this.transmissionResolutionScale, activeViewport.w * _this.transmissionResolutionScale );
1895
+
1896
+ //
1897
+
1898
+ const currentRenderTarget = _this.getRenderTarget();
1899
+ const currentActiveCubeFace = _this.getActiveCubeFace();
1900
+ const currentActiveMipmapLevel = _this.getActiveMipmapLevel();
1901
+
1902
+ _this.setRenderTarget( transmissionRenderTarget );
1903
+
1904
+ _this.getClearColor( _currentClearColor );
1905
+ _currentClearAlpha = _this.getClearAlpha();
1906
+ if ( _currentClearAlpha < 1 ) _this.setClearColor( 0xffffff, 0.5 );
1907
+
1908
+ _this.clear();
1909
+
1910
+ if ( _renderBackground ) background.render( scene );
1911
+
1912
+ // Turn off the features which can affect the frag color for opaque objects pass.
1913
+ // Otherwise they are applied twice in opaque objects pass and transmission objects pass.
1914
+ const currentToneMapping = _this.toneMapping;
1915
+ _this.toneMapping = NoToneMapping;
1916
+
1917
+ // Remove viewport from camera to avoid nested render calls resetting viewport to it (e.g Reflector).
1918
+ // Transmission render pass requires viewport to match the transmissionRenderTarget.
1919
+ const currentCameraViewport = camera.viewport;
1920
+ if ( camera.viewport !== undefined ) camera.viewport = undefined;
1921
+
1922
+ currentRenderState.setupLightsView( camera );
1923
+
1924
+ if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, camera );
1925
+
1926
+ renderObjects( opaqueObjects, scene, camera );
1927
+
1928
+ textures.updateMultisampleRenderTarget( transmissionRenderTarget );
1929
+ textures.updateRenderTargetMipmap( transmissionRenderTarget );
1930
+
1931
+ if ( extensions.has( 'WEBGL_multisampled_render_to_texture' ) === false ) { // see #28131
1932
+
1933
+ let renderTargetNeedsUpdate = false;
1934
+
1935
+ for ( let i = 0, l = transmissiveObjects.length; i < l; i ++ ) {
1936
+
1937
+ const renderItem = transmissiveObjects[ i ];
1938
+
1939
+ const object = renderItem.object;
1940
+ const geometry = renderItem.geometry;
1941
+ const material = renderItem.material;
1942
+ const group = renderItem.group;
1943
+
1944
+ if ( material.side === DoubleSide && object.layers.test( camera.layers ) ) {
1945
+
1946
+ const currentSide = material.side;
1947
+
1948
+ material.side = BackSide;
1949
+ material.needsUpdate = true;
1950
+
1951
+ renderObject( object, scene, camera, geometry, material, group );
1952
+
1953
+ material.side = currentSide;
1954
+ material.needsUpdate = true;
1955
+
1956
+ renderTargetNeedsUpdate = true;
1957
+
1958
+ }
1959
+
1960
+ }
1961
+
1962
+ if ( renderTargetNeedsUpdate === true ) {
1963
+
1964
+ textures.updateMultisampleRenderTarget( transmissionRenderTarget );
1965
+ textures.updateRenderTargetMipmap( transmissionRenderTarget );
1966
+
1967
+ }
1968
+
1969
+ }
1970
+
1971
+ _this.setRenderTarget( currentRenderTarget, currentActiveCubeFace, currentActiveMipmapLevel );
1972
+
1973
+ _this.setClearColor( _currentClearColor, _currentClearAlpha );
1974
+
1975
+ if ( currentCameraViewport !== undefined ) camera.viewport = currentCameraViewport;
1976
+
1977
+ _this.toneMapping = currentToneMapping;
1978
+
1979
+ }
1980
+
1981
+ function renderObjects( renderList, scene, camera ) {
1982
+
1983
+ const overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;
1984
+
1985
+ for ( let i = 0, l = renderList.length; i < l; i ++ ) {
1986
+
1987
+ const renderItem = renderList[ i ];
1988
+
1989
+ const object = renderItem.object;
1990
+ const geometry = renderItem.geometry;
1991
+ const group = renderItem.group;
1992
+ let material = renderItem.material;
1993
+
1994
+ if ( material.allowOverride === true && overrideMaterial !== null ) {
1995
+
1996
+ material = overrideMaterial;
1997
+
1998
+ }
1999
+
2000
+ if ( object.layers.test( camera.layers ) ) {
2001
+
2002
+ renderObject( object, scene, camera, geometry, material, group );
2003
+
2004
+ }
2005
+
2006
+ }
2007
+
2008
+ }
2009
+
2010
+ function renderObject( object, scene, camera, geometry, material, group ) {
2011
+
2012
+ object.onBeforeRender( _this, scene, camera, geometry, material, group );
2013
+
2014
+ object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
2015
+ object.normalMatrix.getNormalMatrix( object.modelViewMatrix );
2016
+
2017
+ material.onBeforeRender( _this, scene, camera, geometry, object, group );
2018
+
2019
+ if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {
2020
+
2021
+ material.side = BackSide;
2022
+ material.needsUpdate = true;
2023
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
2024
+
2025
+ material.side = FrontSide;
2026
+ material.needsUpdate = true;
2027
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
2028
+
2029
+ material.side = DoubleSide;
2030
+
2031
+ } else {
2032
+
2033
+ _this.renderBufferDirect( camera, scene, geometry, material, object, group );
2034
+
2035
+ }
2036
+
2037
+ object.onAfterRender( _this, scene, camera, geometry, material, group );
2038
+
2039
+ }
2040
+
2041
+ function getProgram( material, scene, object ) {
2042
+
2043
+ if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...
2044
+
2045
+ const materialProperties = properties.get( material );
2046
+
2047
+ const lights = currentRenderState.state.lights;
2048
+ const shadowsArray = currentRenderState.state.shadowsArray;
2049
+
2050
+ const lightsStateVersion = lights.state.version;
2051
+
2052
+ const parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, object );
2053
+ const programCacheKey = programCache.getProgramCacheKey( parameters );
2054
+
2055
+ let programs = materialProperties.programs;
2056
+
2057
+ // always update environment and fog - changing these trigger an getProgram call, but it's possible that the program doesn't change
2058
+
2059
+ materialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;
2060
+ materialProperties.fog = scene.fog;
2061
+ materialProperties.envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || materialProperties.environment );
2062
+ materialProperties.envMapRotation = ( materialProperties.environment !== null && material.envMap === null ) ? scene.environmentRotation : material.envMapRotation;
2063
+
2064
+ if ( programs === undefined ) {
2065
+
2066
+ // new material
2067
+
2068
+ material.addEventListener( 'dispose', onMaterialDispose );
2069
+
2070
+ programs = new Map();
2071
+ materialProperties.programs = programs;
2072
+
2073
+ }
2074
+
2075
+ let program = programs.get( programCacheKey );
2076
+
2077
+ if ( program !== undefined ) {
2078
+
2079
+ // early out if program and light state is identical
2080
+
2081
+ if ( materialProperties.currentProgram === program && materialProperties.lightsStateVersion === lightsStateVersion ) {
2082
+
2083
+ updateCommonMaterialProperties( material, parameters );
2084
+
2085
+ return program;
2086
+
2087
+ }
2088
+
2089
+ } else {
2090
+
2091
+ parameters.uniforms = programCache.getUniforms( material );
2092
+
2093
+ material.onBeforeCompile( parameters, _this );
2094
+
2095
+ program = programCache.acquireProgram( parameters, programCacheKey );
2096
+ programs.set( programCacheKey, program );
2097
+
2098
+ materialProperties.uniforms = parameters.uniforms;
2099
+
2100
+ }
2101
+
2102
+ const uniforms = materialProperties.uniforms;
2103
+
2104
+ if ( ( ! material.isShaderMaterial && ! material.isRawShaderMaterial ) || material.clipping === true ) {
2105
+
2106
+ uniforms.clippingPlanes = clipping.uniform;
2107
+
2108
+ }
2109
+
2110
+ updateCommonMaterialProperties( material, parameters );
2111
+
2112
+ // store the light setup it was created for
2113
+
2114
+ materialProperties.needsLights = materialNeedsLights( material );
2115
+ materialProperties.lightsStateVersion = lightsStateVersion;
2116
+
2117
+ if ( materialProperties.needsLights ) {
2118
+
2119
+ // wire up the material to this renderer's lighting state
2120
+
2121
+ uniforms.ambientLightColor.value = lights.state.ambient;
2122
+ uniforms.lightProbe.value = lights.state.probe;
2123
+ uniforms.directionalLights.value = lights.state.directional;
2124
+ uniforms.directionalLightShadows.value = lights.state.directionalShadow;
2125
+ uniforms.spotLights.value = lights.state.spot;
2126
+ uniforms.spotLightShadows.value = lights.state.spotShadow;
2127
+ uniforms.rectAreaLights.value = lights.state.rectArea;
2128
+ uniforms.ltc_1.value = lights.state.rectAreaLTC1;
2129
+ uniforms.ltc_2.value = lights.state.rectAreaLTC2;
2130
+ uniforms.pointLights.value = lights.state.point;
2131
+ uniforms.pointLightShadows.value = lights.state.pointShadow;
2132
+ uniforms.hemisphereLights.value = lights.state.hemi;
2133
+
2134
+ uniforms.directionalShadowMap.value = lights.state.directionalShadowMap;
2135
+ uniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;
2136
+ uniforms.iesProfiles.value = lights.state.iesProfiles;
2137
+ // uniforms.numIESProfiles.value = lights.state.iesProfiles?.image?.height ?? 0;
2138
+ uniforms.numIESProfiles.value = ( lights.state.iesProfiles === null ) ? 0 : lights.state.iesProfiles.image.height;
2139
+ uniforms.spotShadowMap.value = lights.state.spotShadowMap;
2140
+ uniforms.spotLightMatrix.value = lights.state.spotLightMatrix;
2141
+ uniforms.spotLightMap.value = lights.state.spotLightMap;
2142
+ uniforms.pointShadowMap.value = lights.state.pointShadowMap;
2143
+ uniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;
2144
+ // TODO (abelnation): add area lights shadow info to uniforms
2145
+
2146
+ }
2147
+
2148
+ materialProperties.currentProgram = program;
2149
+ materialProperties.uniformsList = null;
2150
+
2151
+ return program;
2152
+
2153
+ }
2154
+
2155
+ function getUniformList( materialProperties ) {
2156
+
2157
+ if ( materialProperties.uniformsList === null ) {
2158
+
2159
+ const progUniforms = materialProperties.currentProgram.getUniforms();
2160
+ materialProperties.uniformsList = WebGLUniforms.seqWithValue( progUniforms.seq, materialProperties.uniforms );
2161
+
2162
+ }
2163
+
2164
+ return materialProperties.uniformsList;
2165
+
2166
+ }
2167
+
2168
+ function updateCommonMaterialProperties( material, parameters ) {
2169
+
2170
+ const materialProperties = properties.get( material );
2171
+
2172
+ materialProperties.outputColorSpace = parameters.outputColorSpace;
2173
+ materialProperties.batching = parameters.batching;
2174
+ materialProperties.batchingColor = parameters.batchingColor;
2175
+ materialProperties.instancing = parameters.instancing;
2176
+ materialProperties.instancingColor = parameters.instancingColor;
2177
+ materialProperties.instancingMorph = parameters.instancingMorph;
2178
+ materialProperties.skinning = parameters.skinning;
2179
+ materialProperties.morphTargets = parameters.morphTargets;
2180
+ materialProperties.morphNormals = parameters.morphNormals;
2181
+ materialProperties.morphColors = parameters.morphColors;
2182
+ materialProperties.morphTargetsCount = parameters.morphTargetsCount;
2183
+ materialProperties.numClippingPlanes = parameters.numClippingPlanes;
2184
+ materialProperties.numIntersection = parameters.numClipIntersection;
2185
+ materialProperties.vertexAlphas = parameters.vertexAlphas;
2186
+ materialProperties.vertexTangents = parameters.vertexTangents;
2187
+ materialProperties.toneMapping = parameters.toneMapping;
2188
+
2189
+ }
2190
+
2191
+ function setProgram( camera, scene, geometry, material, object ) {
2192
+
2193
+ if ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...
2194
+
2195
+ textures.resetTextureUnits();
2196
+
2197
+ const fog = scene.fog;
2198
+ const environment = material.isMeshStandardMaterial ? scene.environment : null;
2199
+ const colorSpace = ( _currentRenderTarget === null ) ? _this.outputColorSpace : ( _currentRenderTarget.isXRRenderTarget === true ? _currentRenderTarget.texture.colorSpace : LinearSRGBColorSpace );
2200
+ const envMap = ( material.isMeshStandardMaterial ? cubeuvmaps : cubemaps ).get( material.envMap || environment );
2201
+ const vertexAlphas = material.vertexColors === true && !! geometry.attributes.color && geometry.attributes.color.itemSize === 4;
2202
+ const vertexTangents = !! geometry.attributes.tangent && ( !! material.normalMap || material.anisotropy > 0 );
2203
+ const morphTargets = !! geometry.morphAttributes.position;
2204
+ const morphNormals = !! geometry.morphAttributes.normal;
2205
+ const morphColors = !! geometry.morphAttributes.color;
2206
+
2207
+ let toneMapping = NoToneMapping;
2208
+
2209
+ if ( material.toneMapped ) {
2210
+
2211
+ if ( _currentRenderTarget === null || _currentRenderTarget.isXRRenderTarget === true ) {
2212
+
2213
+ toneMapping = _this.toneMapping;
2214
+
2215
+ }
2216
+
2217
+ }
2218
+
2219
+ const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
2220
+ const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
2221
+
2222
+ const materialProperties = properties.get( material );
2223
+ const lights = currentRenderState.state.lights;
2224
+
2225
+ if ( _clippingEnabled === true ) {
2226
+
2227
+ if ( _localClippingEnabled === true || camera !== _currentCamera ) {
2228
+
2229
+ const useCache =
2230
+ camera === _currentCamera &&
2231
+ material.id === _currentMaterialId;
2232
+
2233
+ // we might want to call this function with some ClippingGroup
2234
+ // object instead of the material, once it becomes feasible
2235
+ // (#8465, #8379)
2236
+ clipping.setState( material, camera, useCache );
2237
+
2238
+ }
2239
+
2240
+ }
2241
+
2242
+ //
2243
+
2244
+ let needsProgramChange = false;
2245
+
2246
+ if ( material.version === materialProperties.__version ) {
2247
+
2248
+ if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) {
2249
+
2250
+ needsProgramChange = true;
2251
+
2252
+ } else if ( materialProperties.outputColorSpace !== colorSpace ) {
2253
+
2254
+ needsProgramChange = true;
2255
+
2256
+ } else if ( object.isBatchedMesh && materialProperties.batching === false ) {
2257
+
2258
+ needsProgramChange = true;
2259
+
2260
+ } else if ( ! object.isBatchedMesh && materialProperties.batching === true ) {
2261
+
2262
+ needsProgramChange = true;
2263
+
2264
+ } else if ( object.isBatchedMesh && materialProperties.batchingColor === true && object.colorTexture === null ) {
2265
+
2266
+ needsProgramChange = true;
2267
+
2268
+ } else if ( object.isBatchedMesh && materialProperties.batchingColor === false && object.colorTexture !== null ) {
2269
+
2270
+ needsProgramChange = true;
2271
+
2272
+ } else if ( object.isInstancedMesh && materialProperties.instancing === false ) {
2273
+
2274
+ needsProgramChange = true;
2275
+
2276
+ } else if ( ! object.isInstancedMesh && materialProperties.instancing === true ) {
2277
+
2278
+ needsProgramChange = true;
2279
+
2280
+ } else if ( object.isSkinnedMesh && materialProperties.skinning === false ) {
2281
+
2282
+ needsProgramChange = true;
2283
+
2284
+ } else if ( ! object.isSkinnedMesh && materialProperties.skinning === true ) {
2285
+
2286
+ needsProgramChange = true;
2287
+
2288
+ } else if ( object.isInstancedMesh && materialProperties.instancingColor === true && object.instanceColor === null ) {
2289
+
2290
+ needsProgramChange = true;
2291
+
2292
+ } else if ( object.isInstancedMesh && materialProperties.instancingColor === false && object.instanceColor !== null ) {
2293
+
2294
+ needsProgramChange = true;
2295
+
2296
+ } else if ( object.isInstancedMesh && materialProperties.instancingMorph === true && object.morphTexture === null ) {
2297
+
2298
+ needsProgramChange = true;
2299
+
2300
+ } else if ( object.isInstancedMesh && materialProperties.instancingMorph === false && object.morphTexture !== null ) {
2301
+
2302
+ needsProgramChange = true;
2303
+
2304
+ } else if ( materialProperties.envMap !== envMap ) {
2305
+
2306
+ needsProgramChange = true;
2307
+
2308
+ } else if ( material.fog === true && materialProperties.fog !== fog ) {
2309
+
2310
+ needsProgramChange = true;
2311
+
2312
+ } else if ( materialProperties.numClippingPlanes !== undefined &&
2313
+ ( materialProperties.numClippingPlanes !== clipping.numPlanes ||
2314
+ materialProperties.numIntersection !== clipping.numIntersection ) ) {
2315
+
2316
+ needsProgramChange = true;
2317
+
2318
+ } else if ( materialProperties.vertexAlphas !== vertexAlphas ) {
2319
+
2320
+ needsProgramChange = true;
2321
+
2322
+ } else if ( materialProperties.vertexTangents !== vertexTangents ) {
2323
+
2324
+ needsProgramChange = true;
2325
+
2326
+ } else if ( materialProperties.morphTargets !== morphTargets ) {
2327
+
2328
+ needsProgramChange = true;
2329
+
2330
+ } else if ( materialProperties.morphNormals !== morphNormals ) {
2331
+
2332
+ needsProgramChange = true;
2333
+
2334
+ } else if ( materialProperties.morphColors !== morphColors ) {
2335
+
2336
+ needsProgramChange = true;
2337
+
2338
+ } else if ( materialProperties.toneMapping !== toneMapping ) {
2339
+
2340
+ needsProgramChange = true;
2341
+
2342
+ } else if ( materialProperties.morphTargetsCount !== morphTargetsCount ) {
2343
+
2344
+ needsProgramChange = true;
2345
+
2346
+ }
2347
+
2348
+ } else {
2349
+
2350
+ needsProgramChange = true;
2351
+ materialProperties.__version = material.version;
2352
+
2353
+ }
2354
+
2355
+ //
2356
+
2357
+ let program = materialProperties.currentProgram;
2358
+
2359
+ if ( needsProgramChange === true ) {
2360
+
2361
+ program = getProgram( material, scene, object );
2362
+
2363
+ }
2364
+
2365
+ let refreshProgram = false;
2366
+ let refreshMaterial = false;
2367
+ let refreshLights = false;
2368
+
2369
+ const p_uniforms = program.getUniforms(),
2370
+ m_uniforms = materialProperties.uniforms;
2371
+
2372
+ if ( state.useProgram( program.program ) ) {
2373
+
2374
+ refreshProgram = true;
2375
+ refreshMaterial = true;
2376
+ refreshLights = true;
2377
+
2378
+ }
2379
+
2380
+ if ( material.id !== _currentMaterialId ) {
2381
+
2382
+ _currentMaterialId = material.id;
2383
+
2384
+ refreshMaterial = true;
2385
+
2386
+ }
2387
+
2388
+ if ( refreshProgram || _currentCamera !== camera ) {
2389
+
2390
+ // common camera uniforms
2391
+
2392
+ const reversedDepthBuffer = state.buffers.depth.getReversed();
2393
+
2394
+ if ( reversedDepthBuffer && camera.reversedDepth !== true ) {
2395
+
2396
+ camera._reversedDepth = true;
2397
+ camera.updateProjectionMatrix();
2398
+
2399
+ }
2400
+
2401
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
2402
+
2403
+ p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
2404
+
2405
+ const uCamPos = p_uniforms.map.cameraPosition;
2406
+
2407
+ if ( uCamPos !== undefined ) {
2408
+
2409
+ uCamPos.setValue( _gl, _vector3.setFromMatrixPosition( camera.matrixWorld ) );
2410
+
2411
+ }
2412
+
2413
+ if ( capabilities.logarithmicDepthBuffer ) {
2414
+
2415
+ p_uniforms.setValue( _gl, 'logDepthBufFC',
2416
+ 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
2417
+
2418
+ }
2419
+
2420
+ // consider moving isOrthographic to UniformLib and WebGLMaterials, see https://github.com/mrdoob/three.js/pull/26467#issuecomment-1645185067
2421
+
2422
+ if ( material.isMeshPhongMaterial ||
2423
+ material.isMeshToonMaterial ||
2424
+ material.isMeshLambertMaterial ||
2425
+ material.isMeshBasicMaterial ||
2426
+ material.isMeshStandardMaterial ||
2427
+ material.isShaderMaterial ) {
2428
+
2429
+ p_uniforms.setValue( _gl, 'isOrthographic', camera.isOrthographicCamera === true );
2430
+
2431
+ }
2432
+
2433
+ if ( _currentCamera !== camera ) {
2434
+
2435
+ _currentCamera = camera;
2436
+
2437
+ // lighting uniforms depend on the camera so enforce an update
2438
+ // now, in case this material supports lights - or later, when
2439
+ // the next material that does gets activated:
2440
+
2441
+ refreshMaterial = true; // set to true on material change
2442
+ refreshLights = true; // remains set until update done
2443
+
2444
+ }
2445
+
2446
+ }
2447
+
2448
+ // skinning and morph target uniforms must be set even if material didn't change
2449
+ // auto-setting of texture unit for bone and morph texture must go before other textures
2450
+ // otherwise textures used for skinning and morphing can take over texture units reserved for other material textures
2451
+
2452
+ if ( object.isSkinnedMesh ) {
2453
+
2454
+ p_uniforms.setOptional( _gl, object, 'bindMatrix' );
2455
+ p_uniforms.setOptional( _gl, object, 'bindMatrixInverse' );
2456
+
2457
+ const skeleton = object.skeleton;
2458
+
2459
+ if ( skeleton ) {
2460
+
2461
+ if ( skeleton.boneTexture === null ) skeleton.computeBoneTexture();
2462
+
2463
+ p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
2464
+
2465
+ }
2466
+
2467
+ }
2468
+
2469
+ if ( object.isBatchedMesh ) {
2470
+
2471
+ p_uniforms.setOptional( _gl, object, 'batchingTexture' );
2472
+ p_uniforms.setValue( _gl, 'batchingTexture', object._matricesTexture, textures );
2473
+
2474
+ p_uniforms.setOptional( _gl, object, 'batchingIdTexture' );
2475
+ p_uniforms.setValue( _gl, 'batchingIdTexture', object._indirectTexture, textures );
2476
+
2477
+ p_uniforms.setOptional( _gl, object, 'batchingColorTexture' );
2478
+ if ( object._colorsTexture !== null ) {
2479
+
2480
+ p_uniforms.setValue( _gl, 'batchingColorTexture', object._colorsTexture, textures );
2481
+
2482
+ }
2483
+
2484
+ }
2485
+
2486
+ const morphAttributes = geometry.morphAttributes;
2487
+
2488
+ if ( morphAttributes.position !== undefined || morphAttributes.normal !== undefined || ( morphAttributes.color !== undefined ) ) {
2489
+
2490
+ morphtargets.update( object, geometry, program );
2491
+
2492
+ }
2493
+
2494
+ if ( refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow ) {
2495
+
2496
+ materialProperties.receiveShadow = object.receiveShadow;
2497
+ p_uniforms.setValue( _gl, 'receiveShadow', object.receiveShadow );
2498
+
2499
+ }
2500
+
2501
+ // https://github.com/mrdoob/three.js/pull/24467#issuecomment-1209031512
2502
+
2503
+ if ( material.isMeshGouraudMaterial && material.envMap !== null ) {
2504
+
2505
+ m_uniforms.envMap.value = envMap;
2506
+
2507
+ m_uniforms.flipEnvMap.value = ( envMap.isCubeTexture && envMap.isRenderTargetTexture === false ) ? - 1 : 1;
2508
+
2509
+ }
2510
+
2511
+ if ( material.isMeshStandardMaterial && material.envMap === null && scene.environment !== null ) {
2512
+
2513
+ m_uniforms.envMapIntensity.value = scene.environmentIntensity;
2514
+
2515
+ }
2516
+
2517
+ if ( refreshMaterial ) {
2518
+
2519
+ p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
2520
+
2521
+ if ( materialProperties.needsLights ) {
2522
+
2523
+ // the current material requires lighting info
2524
+
2525
+ // note: all lighting uniforms are always set correctly
2526
+ // they simply reference the renderer's state for their
2527
+ // values
2528
+ //
2529
+ // use the current material's .needsUpdate flags to set
2530
+ // the GL state when required
2531
+
2532
+ markUniformsLightsNeedsUpdate( m_uniforms, refreshLights );
2533
+
2534
+ }
2535
+
2536
+ // refresh uniforms common to several materials
2537
+
2538
+ if ( fog && material.fog === true ) {
2539
+
2540
+ materials.refreshFogUniforms( m_uniforms, fog );
2541
+
2542
+ }
2543
+
2544
+ materials.refreshMaterialUniforms( m_uniforms, material, _pixelRatio, _height, currentRenderState.state.transmissionRenderTarget[ camera.id ] );
2545
+
2546
+ WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
2547
+
2548
+ }
2549
+
2550
+ if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {
2551
+
2552
+ WebGLUniforms.upload( _gl, getUniformList( materialProperties ), m_uniforms, textures );
2553
+ material.uniformsNeedUpdate = false;
2554
+
2555
+ }
2556
+
2557
+ if ( material.isSpriteMaterial ) {
2558
+
2559
+ p_uniforms.setValue( _gl, 'center', object.center );
2560
+
2561
+ }
2562
+
2563
+ // common matrices
2564
+
2565
+ p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
2566
+ p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
2567
+ p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
2568
+
2569
+ // UBOs
2570
+
2571
+ if ( material.isShaderMaterial || material.isRawShaderMaterial ) {
2572
+
2573
+ const groups = material.uniformsGroups;
2574
+
2575
+ for ( let i = 0, l = groups.length; i < l; i ++ ) {
2576
+
2577
+ const group = groups[ i ];
2578
+
2579
+ uniformsGroups.update( group, program );
2580
+ uniformsGroups.bind( group, program );
2581
+
2582
+ }
2583
+
2584
+ }
2585
+
2586
+ return program;
2587
+
2588
+ }
2589
+
2590
+ // If uniforms are marked as clean, they don't need to be loaded to the GPU.
2591
+
2592
+ function markUniformsLightsNeedsUpdate( uniforms, value ) {
2593
+
2594
+ uniforms.ambientLightColor.needsUpdate = value;
2595
+ uniforms.lightProbe.needsUpdate = value;
2596
+
2597
+ uniforms.directionalLights.needsUpdate = value;
2598
+ uniforms.directionalLightShadows.needsUpdate = value;
2599
+ uniforms.pointLights.needsUpdate = value;
2600
+ uniforms.pointLightShadows.needsUpdate = value;
2601
+ uniforms.spotLights.needsUpdate = value;
2602
+ uniforms.spotLightShadows.needsUpdate = value;
2603
+ uniforms.rectAreaLights.needsUpdate = value;
2604
+ uniforms.hemisphereLights.needsUpdate = value;
2605
+
2606
+ }
2607
+
2608
+ function materialNeedsLights( material ) {
2609
+
2610
+ return material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial ||
2611
+ material.isMeshStandardMaterial || material.isShadowMaterial ||
2612
+ ( material.isShaderMaterial && material.lights === true );
2613
+
2614
+ }
2615
+
2616
+ /**
2617
+ * Returns the active cube face.
2618
+ *
2619
+ * @return {number} The active cube face.
2620
+ */
2621
+ this.getActiveCubeFace = function () {
2622
+
2623
+ return _currentActiveCubeFace;
2624
+
2625
+ };
2626
+
2627
+ /**
2628
+ * Returns the active mipmap level.
2629
+ *
2630
+ * @return {number} The active mipmap level.
2631
+ */
2632
+ this.getActiveMipmapLevel = function () {
2633
+
2634
+ return _currentActiveMipmapLevel;
2635
+
2636
+ };
2637
+
2638
+ /**
2639
+ * Returns the active render target.
2640
+ *
2641
+ * @return {?WebGLRenderTarget} The active render target. Returns `null` if no render target
2642
+ * is currently set.
2643
+ */
2644
+ this.getRenderTarget = function () {
2645
+
2646
+ return _currentRenderTarget;
2647
+
2648
+ };
2649
+
2650
+ this.setRenderTargetTextures = function ( renderTarget, colorTexture, depthTexture ) {
2651
+
2652
+ const renderTargetProperties = properties.get( renderTarget );
2653
+
2654
+ renderTargetProperties.__autoAllocateDepthBuffer = renderTarget.resolveDepthBuffer === false;
2655
+ if ( renderTargetProperties.__autoAllocateDepthBuffer === false ) {
2656
+
2657
+ // The multisample_render_to_texture extension doesn't work properly if there
2658
+ // are midframe flushes and an external depth buffer. Disable use of the extension.
2659
+ renderTargetProperties.__useRenderToTexture = false;
2660
+
2661
+ }
2662
+
2663
+ properties.get( renderTarget.texture ).__webglTexture = colorTexture;
2664
+ properties.get( renderTarget.depthTexture ).__webglTexture = renderTargetProperties.__autoAllocateDepthBuffer ? undefined : depthTexture;
2665
+
2666
+ renderTargetProperties.__hasExternalTextures = true;
2667
+
2668
+ };
2669
+
2670
+ this.setRenderTargetFramebuffer = function ( renderTarget, defaultFramebuffer ) {
2671
+
2672
+ const renderTargetProperties = properties.get( renderTarget );
2673
+ renderTargetProperties.__webglFramebuffer = defaultFramebuffer;
2674
+ renderTargetProperties.__useDefaultFramebuffer = defaultFramebuffer === undefined;
2675
+
2676
+ };
2677
+
2678
+ const _scratchFrameBuffer = _gl.createFramebuffer();
2679
+
2680
+ /**
2681
+ * Sets the active rendertarget.
2682
+ *
2683
+ * @param {?WebGLRenderTarget} renderTarget - The render target to set. When `null` is given,
2684
+ * the canvas is set as the active render target instead.
2685
+ * @param {number} [activeCubeFace=0] - The active cube face when using a cube render target.
2686
+ * Indicates the z layer to render in to when using 3D or array render targets.
2687
+ * @param {number} [activeMipmapLevel=0] - The active mipmap level.
2688
+ */
2689
+ this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
2690
+
2691
+ _currentRenderTarget = renderTarget;
2692
+ _currentActiveCubeFace = activeCubeFace;
2693
+ _currentActiveMipmapLevel = activeMipmapLevel;
2694
+
2695
+ let useDefaultFramebuffer = true;
2696
+ let framebuffer = null;
2697
+ let isCube = false;
2698
+ let isRenderTarget3D = false;
2699
+
2700
+ if ( renderTarget ) {
2701
+
2702
+ const renderTargetProperties = properties.get( renderTarget );
2703
+
2704
+ if ( renderTargetProperties.__useDefaultFramebuffer !== undefined ) {
2705
+
2706
+ // We need to make sure to rebind the framebuffer.
2707
+ state.bindFramebuffer( _gl.FRAMEBUFFER, null );
2708
+ useDefaultFramebuffer = false;
2709
+
2710
+ } else if ( renderTargetProperties.__webglFramebuffer === undefined ) {
2711
+
2712
+ textures.setupRenderTarget( renderTarget );
2713
+
2714
+ } else if ( renderTargetProperties.__hasExternalTextures ) {
2715
+
2716
+ // Color and depth texture must be rebound in order for the swapchain to update.
2717
+ textures.rebindTextures( renderTarget, properties.get( renderTarget.texture ).__webglTexture, properties.get( renderTarget.depthTexture ).__webglTexture );
2718
+
2719
+ } else if ( renderTarget.depthBuffer ) {
2720
+
2721
+ // check if the depth texture is already bound to the frame buffer and that it's been initialized
2722
+ const depthTexture = renderTarget.depthTexture;
2723
+ if ( renderTargetProperties.__boundDepthTexture !== depthTexture ) {
2724
+
2725
+ // check if the depth texture is compatible
2726
+ if (
2727
+ depthTexture !== null &&
2728
+ properties.has( depthTexture ) &&
2729
+ ( renderTarget.width !== depthTexture.image.width || renderTarget.height !== depthTexture.image.height )
2730
+ ) {
2731
+
2732
+ throw new Error( 'WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.' );
2733
+
2734
+ }
2735
+
2736
+ // Swap the depth buffer to the currently attached one
2737
+ textures.setupDepthRenderbuffer( renderTarget );
2738
+
2739
+ }
2740
+
2741
+ }
2742
+
2743
+ const texture = renderTarget.texture;
2744
+
2745
+ if ( texture.isData3DTexture || texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
2746
+
2747
+ isRenderTarget3D = true;
2748
+
2749
+ }
2750
+
2751
+ const __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer;
2752
+
2753
+ if ( renderTarget.isWebGLCubeRenderTarget ) {
2754
+
2755
+ if ( Array.isArray( __webglFramebuffer[ activeCubeFace ] ) ) {
2756
+
2757
+ framebuffer = __webglFramebuffer[ activeCubeFace ][ activeMipmapLevel ];
2758
+
2759
+ } else {
2760
+
2761
+ framebuffer = __webglFramebuffer[ activeCubeFace ];
2762
+
2763
+ }
2764
+
2765
+ isCube = true;
2766
+
2767
+ } else if ( ( renderTarget.samples > 0 ) && textures.useMultisampledRTT( renderTarget ) === false ) {
2768
+
2769
+ framebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;
2770
+
2771
+ } else {
2772
+
2773
+ if ( Array.isArray( __webglFramebuffer ) ) {
2774
+
2775
+ framebuffer = __webglFramebuffer[ activeMipmapLevel ];
2776
+
2777
+ } else {
2778
+
2779
+ framebuffer = __webglFramebuffer;
2780
+
2781
+ }
2782
+
2783
+ }
2784
+
2785
+ _currentViewport.copy( renderTarget.viewport );
2786
+ _currentScissor.copy( renderTarget.scissor );
2787
+ _currentScissorTest = renderTarget.scissorTest;
2788
+
2789
+ } else {
2790
+
2791
+ _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor();
2792
+ _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor();
2793
+ _currentScissorTest = _scissorTest;
2794
+
2795
+ }
2796
+
2797
+ // Use a scratch frame buffer if rendering to a mip level to avoid depth buffers
2798
+ // being bound that are different sizes.
2799
+ if ( activeMipmapLevel !== 0 ) {
2800
+
2801
+ framebuffer = _scratchFrameBuffer;
2802
+
2803
+ }
2804
+
2805
+ const framebufferBound = state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2806
+
2807
+ if ( framebufferBound && useDefaultFramebuffer ) {
2808
+
2809
+ state.drawBuffers( renderTarget, framebuffer );
2810
+
2811
+ }
2812
+
2813
+ state.viewport( _currentViewport );
2814
+ state.scissor( _currentScissor );
2815
+ state.setScissorTest( _currentScissorTest );
2816
+
2817
+ if ( isCube ) {
2818
+
2819
+ const textureProperties = properties.get( renderTarget.texture );
2820
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + activeCubeFace, textureProperties.__webglTexture, activeMipmapLevel );
2821
+
2822
+ } else if ( isRenderTarget3D ) {
2823
+
2824
+ const layer = activeCubeFace;
2825
+
2826
+ for ( let i = 0; i < renderTarget.textures.length; i ++ ) {
2827
+
2828
+ const textureProperties = properties.get( renderTarget.textures[ i ] );
2829
+
2830
+ _gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, textureProperties.__webglTexture, activeMipmapLevel, layer );
2831
+
2832
+ }
2833
+
2834
+ } else if ( renderTarget !== null && activeMipmapLevel !== 0 ) {
2835
+
2836
+ // Only bind the frame buffer if we are using a scratch frame buffer to render to a mipmap.
2837
+ // If we rebind the texture when using a multi sample buffer then an error about inconsistent samples will be thrown.
2838
+ const textureProperties = properties.get( renderTarget.texture );
2839
+ _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, textureProperties.__webglTexture, activeMipmapLevel );
2840
+
2841
+ }
2842
+
2843
+ _currentMaterialId = - 1; // reset current material to ensure correct uniform bindings
2844
+
2845
+ };
2846
+
2847
+ /**
2848
+ * Reads the pixel data from the given render target into the given buffer.
2849
+ *
2850
+ * @param {WebGLRenderTarget} renderTarget - The render target to read from.
2851
+ * @param {number} x - The `x` coordinate of the copy region's origin.
2852
+ * @param {number} y - The `y` coordinate of the copy region's origin.
2853
+ * @param {number} width - The width of the copy region.
2854
+ * @param {number} height - The height of the copy region.
2855
+ * @param {TypedArray} buffer - The result buffer.
2856
+ * @param {number} [activeCubeFaceIndex] - The active cube face index.
2857
+ * @param {number} [textureIndex=0] - The texture index of an MRT render target.
2858
+ */
2859
+ this.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex = 0 ) {
2860
+
2861
+ if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
2862
+
2863
+ error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
2864
+ return;
2865
+
2866
+ }
2867
+
2868
+ let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
2869
+
2870
+ if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {
2871
+
2872
+ framebuffer = framebuffer[ activeCubeFaceIndex ];
2873
+
2874
+ }
2875
+
2876
+ if ( framebuffer ) {
2877
+
2878
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2879
+
2880
+ try {
2881
+
2882
+ const texture = renderTarget.textures[ textureIndex ];
2883
+ const textureFormat = texture.format;
2884
+ const textureType = texture.type;
2885
+
2886
+ if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
2887
+
2888
+ error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
2889
+ return;
2890
+
2891
+ }
2892
+
2893
+ if ( ! capabilities.textureTypeReadable( textureType ) ) {
2894
+
2895
+ error( 'WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );
2896
+ return;
2897
+
2898
+ }
2899
+
2900
+ // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
2901
+
2902
+ if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
2903
+
2904
+ // when using MRT, select the correct color buffer for the subsequent read command
2905
+
2906
+ if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
2907
+
2908
+ _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );
2909
+
2910
+ }
2911
+
2912
+ } finally {
2913
+
2914
+ // restore framebuffer of current render target if necessary
2915
+
2916
+ const framebuffer = ( _currentRenderTarget !== null ) ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
2917
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2918
+
2919
+ }
2920
+
2921
+ }
2922
+
2923
+ };
2924
+
2925
+ /**
2926
+ * Asynchronous, non-blocking version of {@link WebGLRenderer#readRenderTargetPixels}.
2927
+ *
2928
+ * It is recommended to use this version of `readRenderTargetPixels()` whenever possible.
2929
+ *
2930
+ * @async
2931
+ * @param {WebGLRenderTarget} renderTarget - The render target to read from.
2932
+ * @param {number} x - The `x` coordinate of the copy region's origin.
2933
+ * @param {number} y - The `y` coordinate of the copy region's origin.
2934
+ * @param {number} width - The width of the copy region.
2935
+ * @param {number} height - The height of the copy region.
2936
+ * @param {TypedArray} buffer - The result buffer.
2937
+ * @param {number} [activeCubeFaceIndex] - The active cube face index.
2938
+ * @param {number} [textureIndex=0] - The texture index of an MRT render target.
2939
+ * @return {Promise<TypedArray>} A Promise that resolves when the read has been finished. The resolve provides the read data as a typed array.
2940
+ */
2941
+ this.readRenderTargetPixelsAsync = async function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex, textureIndex = 0 ) {
2942
+
2943
+ if ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {
2944
+
2945
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );
2946
+
2947
+ }
2948
+
2949
+ let framebuffer = properties.get( renderTarget ).__webglFramebuffer;
2950
+ if ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {
2951
+
2952
+ framebuffer = framebuffer[ activeCubeFaceIndex ];
2953
+
2954
+ }
2955
+
2956
+ if ( framebuffer ) {
2957
+
2958
+ // the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)
2959
+ if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
2960
+
2961
+ // set the active frame buffer to the one we want to read
2962
+ state.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
2963
+
2964
+ const texture = renderTarget.textures[ textureIndex ];
2965
+ const textureFormat = texture.format;
2966
+ const textureType = texture.type;
2967
+
2968
+ if ( ! capabilities.textureFormatReadable( textureFormat ) ) {
2969
+
2970
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.' );
2971
+
2972
+ }
2973
+
2974
+ if ( ! capabilities.textureTypeReadable( textureType ) ) {
2975
+
2976
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.' );
2977
+
2978
+ }
2979
+
2980
+ const glBuffer = _gl.createBuffer();
2981
+ _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
2982
+ _gl.bufferData( _gl.PIXEL_PACK_BUFFER, buffer.byteLength, _gl.STREAM_READ );
2983
+
2984
+ // when using MRT, select the correct color buffer for the subsequent read command
2985
+
2986
+ if ( renderTarget.textures.length > 1 ) _gl.readBuffer( _gl.COLOR_ATTACHMENT0 + textureIndex );
2987
+
2988
+ _gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), 0 );
2989
+
2990
+ // reset the frame buffer to the currently set buffer before waiting
2991
+ const currFramebuffer = _currentRenderTarget !== null ? properties.get( _currentRenderTarget ).__webglFramebuffer : null;
2992
+ state.bindFramebuffer( _gl.FRAMEBUFFER, currFramebuffer );
2993
+
2994
+ // check if the commands have finished every 8 ms
2995
+ const sync = _gl.fenceSync( _gl.SYNC_GPU_COMMANDS_COMPLETE, 0 );
2996
+
2997
+ _gl.flush();
2998
+
2999
+ await probeAsync( _gl, sync, 4 );
3000
+
3001
+ // read the data and delete the buffer
3002
+ _gl.bindBuffer( _gl.PIXEL_PACK_BUFFER, glBuffer );
3003
+ _gl.getBufferSubData( _gl.PIXEL_PACK_BUFFER, 0, buffer );
3004
+ _gl.deleteBuffer( glBuffer );
3005
+ _gl.deleteSync( sync );
3006
+
3007
+ return buffer;
3008
+
3009
+ } else {
3010
+
3011
+ throw new Error( 'THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.' );
3012
+
3013
+ }
3014
+
3015
+ }
3016
+
3017
+ };
3018
+
3019
+ /**
3020
+ * Copies pixels from the current bound framebuffer into the given texture.
3021
+ *
3022
+ * @param {FramebufferTexture} texture - The texture.
3023
+ * @param {?Vector2} [position=null] - The start position of the copy operation.
3024
+ * @param {number} [level=0] - The mip level. The default represents the base mip.
3025
+ */
3026
+ this.copyFramebufferToTexture = function ( texture, position = null, level = 0 ) {
3027
+
3028
+ const levelScale = Math.pow( 2, - level );
3029
+ const width = Math.floor( texture.image.width * levelScale );
3030
+ const height = Math.floor( texture.image.height * levelScale );
3031
+
3032
+ const x = position !== null ? position.x : 0;
3033
+ const y = position !== null ? position.y : 0;
3034
+
3035
+ textures.setTexture2D( texture, 0 );
3036
+
3037
+ _gl.copyTexSubImage2D( _gl.TEXTURE_2D, level, 0, 0, x, y, width, height );
3038
+
3039
+ state.unbindTexture();
3040
+
3041
+ };
3042
+
3043
+ const _srcFramebuffer = _gl.createFramebuffer();
3044
+ const _dstFramebuffer = _gl.createFramebuffer();
3045
+
3046
+ /**
3047
+ * Copies data of the given source texture into a destination texture.
3048
+ *
3049
+ * When using render target textures as `srcTexture` and `dstTexture`, you must make sure both render targets are initialized
3050
+ * {@link WebGLRenderer#initRenderTarget}.
3051
+ *
3052
+ * @param {Texture} srcTexture - The source texture.
3053
+ * @param {Texture} dstTexture - The destination texture.
3054
+ * @param {?(Box2|Box3)} [srcRegion=null] - A bounding box which describes the source region. Can be two or three-dimensional.
3055
+ * @param {?(Vector2|Vector3)} [dstPosition=null] - A vector that represents the origin of the destination region. Can be two or three-dimensional.
3056
+ * @param {number} [srcLevel=0] - The source mipmap level to copy.
3057
+ * @param {?number} [dstLevel=null] - The destination mipmap level.
3058
+ */
3059
+ this.copyTextureToTexture = function ( srcTexture, dstTexture, srcRegion = null, dstPosition = null, srcLevel = 0, dstLevel = null ) {
3060
+
3061
+ // support the previous signature with just a single dst mipmap level
3062
+ if ( dstLevel === null ) {
3063
+
3064
+ if ( srcLevel !== 0 ) {
3065
+
3066
+ // @deprecated, r171
3067
+ warnOnce( 'WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels.' );
3068
+ dstLevel = srcLevel;
3069
+ srcLevel = 0;
3070
+
3071
+ } else {
3072
+
3073
+ dstLevel = 0;
3074
+
3075
+ }
3076
+
3077
+ }
3078
+
3079
+ // gather the necessary dimensions to copy
3080
+ let width, height, depth, minX, minY, minZ;
3081
+ let dstX, dstY, dstZ;
3082
+ const image = srcTexture.isCompressedTexture ? srcTexture.mipmaps[ dstLevel ] : srcTexture.image;
3083
+ if ( srcRegion !== null ) {
3084
+
3085
+ width = srcRegion.max.x - srcRegion.min.x;
3086
+ height = srcRegion.max.y - srcRegion.min.y;
3087
+ depth = srcRegion.isBox3 ? srcRegion.max.z - srcRegion.min.z : 1;
3088
+ minX = srcRegion.min.x;
3089
+ minY = srcRegion.min.y;
3090
+ minZ = srcRegion.isBox3 ? srcRegion.min.z : 0;
3091
+
3092
+ } else {
3093
+
3094
+ const levelScale = Math.pow( 2, - srcLevel );
3095
+ width = Math.floor( image.width * levelScale );
3096
+ height = Math.floor( image.height * levelScale );
3097
+ if ( srcTexture.isDataArrayTexture ) {
3098
+
3099
+ depth = image.depth;
3100
+
3101
+ } else if ( srcTexture.isData3DTexture ) {
3102
+
3103
+ depth = Math.floor( image.depth * levelScale );
3104
+
3105
+ } else {
3106
+
3107
+ depth = 1;
3108
+
3109
+ }
3110
+
3111
+ minX = 0;
3112
+ minY = 0;
3113
+ minZ = 0;
3114
+
3115
+ }
3116
+
3117
+ if ( dstPosition !== null ) {
3118
+
3119
+ dstX = dstPosition.x;
3120
+ dstY = dstPosition.y;
3121
+ dstZ = dstPosition.z;
3122
+
3123
+ } else {
3124
+
3125
+ dstX = 0;
3126
+ dstY = 0;
3127
+ dstZ = 0;
3128
+
3129
+ }
3130
+
3131
+ // Set up the destination target
3132
+ const glFormat = utils.convert( dstTexture.format );
3133
+ const glType = utils.convert( dstTexture.type );
3134
+ let glTarget;
3135
+
3136
+ if ( dstTexture.isData3DTexture ) {
3137
+
3138
+ textures.setTexture3D( dstTexture, 0 );
3139
+ glTarget = _gl.TEXTURE_3D;
3140
+
3141
+ } else if ( dstTexture.isDataArrayTexture || dstTexture.isCompressedArrayTexture ) {
3142
+
3143
+ textures.setTexture2DArray( dstTexture, 0 );
3144
+ glTarget = _gl.TEXTURE_2D_ARRAY;
3145
+
3146
+ } else {
3147
+
3148
+ textures.setTexture2D( dstTexture, 0 );
3149
+ glTarget = _gl.TEXTURE_2D;
3150
+
3151
+ }
3152
+
3153
+ _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );
3154
+ _gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );
3155
+ _gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );
3156
+
3157
+ // used for copying data from cpu
3158
+ const currentUnpackRowLen = _gl.getParameter( _gl.UNPACK_ROW_LENGTH );
3159
+ const currentUnpackImageHeight = _gl.getParameter( _gl.UNPACK_IMAGE_HEIGHT );
3160
+ const currentUnpackSkipPixels = _gl.getParameter( _gl.UNPACK_SKIP_PIXELS );
3161
+ const currentUnpackSkipRows = _gl.getParameter( _gl.UNPACK_SKIP_ROWS );
3162
+ const currentUnpackSkipImages = _gl.getParameter( _gl.UNPACK_SKIP_IMAGES );
3163
+
3164
+ _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, image.width );
3165
+ _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, image.height );
3166
+ _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, minX );
3167
+ _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, minY );
3168
+ _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, minZ );
3169
+
3170
+ // set up the src texture
3171
+ const isSrc3D = srcTexture.isDataArrayTexture || srcTexture.isData3DTexture;
3172
+ const isDst3D = dstTexture.isDataArrayTexture || dstTexture.isData3DTexture;
3173
+ if ( srcTexture.isDepthTexture ) {
3174
+
3175
+ const srcTextureProperties = properties.get( srcTexture );
3176
+ const dstTextureProperties = properties.get( dstTexture );
3177
+ const srcRenderTargetProperties = properties.get( srcTextureProperties.__renderTarget );
3178
+ const dstRenderTargetProperties = properties.get( dstTextureProperties.__renderTarget );
3179
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, srcRenderTargetProperties.__webglFramebuffer );
3180
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, dstRenderTargetProperties.__webglFramebuffer );
3181
+
3182
+ for ( let i = 0; i < depth; i ++ ) {
3183
+
3184
+ // if the source or destination are a 3d target then a layer needs to be bound
3185
+ if ( isSrc3D ) {
3186
+
3187
+ _gl.framebufferTextureLayer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( srcTexture ).__webglTexture, srcLevel, minZ + i );
3188
+ _gl.framebufferTextureLayer( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, properties.get( dstTexture ).__webglTexture, dstLevel, dstZ + i );
3189
+
3190
+ }
3191
+
3192
+ _gl.blitFramebuffer( minX, minY, width, height, dstX, dstY, width, height, _gl.DEPTH_BUFFER_BIT, _gl.NEAREST );
3193
+
3194
+ }
3195
+
3196
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
3197
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
3198
+
3199
+ } else if ( srcLevel !== 0 || srcTexture.isRenderTargetTexture || properties.has( srcTexture ) ) {
3200
+
3201
+ // get the appropriate frame buffers
3202
+ const srcTextureProperties = properties.get( srcTexture );
3203
+ const dstTextureProperties = properties.get( dstTexture );
3204
+
3205
+ // bind the frame buffer targets
3206
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, _srcFramebuffer );
3207
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, _dstFramebuffer );
3208
+
3209
+ for ( let i = 0; i < depth; i ++ ) {
3210
+
3211
+ // assign the correct layers and mip maps to the frame buffers
3212
+ if ( isSrc3D ) {
3213
+
3214
+ _gl.framebufferTextureLayer( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, srcTextureProperties.__webglTexture, srcLevel, minZ + i );
3215
+
3216
+ } else {
3217
+
3218
+ _gl.framebufferTexture2D( _gl.READ_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, srcTextureProperties.__webglTexture, srcLevel );
3219
+
3220
+ }
3221
+
3222
+ if ( isDst3D ) {
3223
+
3224
+ _gl.framebufferTextureLayer( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, dstTextureProperties.__webglTexture, dstLevel, dstZ + i );
3225
+
3226
+ } else {
3227
+
3228
+ _gl.framebufferTexture2D( _gl.DRAW_FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, dstTextureProperties.__webglTexture, dstLevel );
3229
+
3230
+ }
3231
+
3232
+ // copy the data using the fastest function that can achieve the copy
3233
+ if ( srcLevel !== 0 ) {
3234
+
3235
+ _gl.blitFramebuffer( minX, minY, width, height, dstX, dstY, width, height, _gl.COLOR_BUFFER_BIT, _gl.NEAREST );
3236
+
3237
+ } else if ( isDst3D ) {
3238
+
3239
+ _gl.copyTexSubImage3D( glTarget, dstLevel, dstX, dstY, dstZ + i, minX, minY, width, height );
3240
+
3241
+ } else {
3242
+
3243
+ _gl.copyTexSubImage2D( glTarget, dstLevel, dstX, dstY, minX, minY, width, height );
3244
+
3245
+ }
3246
+
3247
+ }
3248
+
3249
+ // unbind read, draw buffers
3250
+ state.bindFramebuffer( _gl.READ_FRAMEBUFFER, null );
3251
+ state.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, null );
3252
+
3253
+ } else {
3254
+
3255
+ if ( isDst3D ) {
3256
+
3257
+ // copy data into the 3d texture
3258
+ if ( srcTexture.isDataTexture || srcTexture.isData3DTexture ) {
3259
+
3260
+ _gl.texSubImage3D( glTarget, dstLevel, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image.data );
3261
+
3262
+ } else if ( dstTexture.isCompressedArrayTexture ) {
3263
+
3264
+ _gl.compressedTexSubImage3D( glTarget, dstLevel, dstX, dstY, dstZ, width, height, depth, glFormat, image.data );
3265
+
3266
+ } else {
3267
+
3268
+ _gl.texSubImage3D( glTarget, dstLevel, dstX, dstY, dstZ, width, height, depth, glFormat, glType, image );
3269
+
3270
+ }
3271
+
3272
+ } else {
3273
+
3274
+ // copy data into the 2d texture
3275
+ if ( srcTexture.isDataTexture ) {
3276
+
3277
+ _gl.texSubImage2D( _gl.TEXTURE_2D, dstLevel, dstX, dstY, width, height, glFormat, glType, image.data );
3278
+
3279
+ } else if ( srcTexture.isCompressedTexture ) {
3280
+
3281
+ _gl.compressedTexSubImage2D( _gl.TEXTURE_2D, dstLevel, dstX, dstY, image.width, image.height, glFormat, image.data );
3282
+
3283
+ } else {
3284
+
3285
+ _gl.texSubImage2D( _gl.TEXTURE_2D, dstLevel, dstX, dstY, width, height, glFormat, glType, image );
3286
+
3287
+ }
3288
+
3289
+ }
3290
+
3291
+ }
3292
+
3293
+ // reset values
3294
+ _gl.pixelStorei( _gl.UNPACK_ROW_LENGTH, currentUnpackRowLen );
3295
+ _gl.pixelStorei( _gl.UNPACK_IMAGE_HEIGHT, currentUnpackImageHeight );
3296
+ _gl.pixelStorei( _gl.UNPACK_SKIP_PIXELS, currentUnpackSkipPixels );
3297
+ _gl.pixelStorei( _gl.UNPACK_SKIP_ROWS, currentUnpackSkipRows );
3298
+ _gl.pixelStorei( _gl.UNPACK_SKIP_IMAGES, currentUnpackSkipImages );
3299
+
3300
+ // Generate mipmaps only when copying level 0
3301
+ if ( dstLevel === 0 && dstTexture.generateMipmaps ) {
3302
+
3303
+ _gl.generateMipmap( glTarget );
3304
+
3305
+ }
3306
+
3307
+ state.unbindTexture();
3308
+
3309
+ };
3310
+
3311
+ /**
3312
+ * Initializes the given WebGLRenderTarget memory. Useful for initializing a render target so data
3313
+ * can be copied into it using {@link WebGLRenderer#copyTextureToTexture} before it has been
3314
+ * rendered to.
3315
+ *
3316
+ * @param {WebGLRenderTarget} target - The render target.
3317
+ */
3318
+ this.initRenderTarget = function ( target ) {
3319
+
3320
+ if ( properties.get( target ).__webglFramebuffer === undefined ) {
3321
+
3322
+ textures.setupRenderTarget( target );
3323
+
3324
+ }
3325
+
3326
+ };
3327
+
3328
+ /**
3329
+ * Initializes the given texture. Useful for preloading a texture rather than waiting until first
3330
+ * render (which can cause noticeable lags due to decode and GPU upload overhead).
3331
+ *
3332
+ * @param {Texture} texture - The texture.
3333
+ */
3334
+ this.initTexture = function ( texture ) {
3335
+
3336
+ if ( texture.isCubeTexture ) {
3337
+
3338
+ textures.setTextureCube( texture, 0 );
3339
+
3340
+ } else if ( texture.isData3DTexture ) {
3341
+
3342
+ textures.setTexture3D( texture, 0 );
3343
+
3344
+ } else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
3345
+
3346
+ textures.setTexture2DArray( texture, 0 );
3347
+
3348
+ } else {
3349
+
3350
+ textures.setTexture2D( texture, 0 );
3351
+
3352
+ }
3353
+
3354
+ state.unbindTexture();
3355
+
3356
+ };
3357
+
3358
+ /**
3359
+ * Can be used to reset the internal WebGL state. This method is mostly
3360
+ * relevant for applications which share a single WebGL context across
3361
+ * multiple WebGL libraries.
3362
+ */
3363
+ this.resetState = function () {
3364
+
3365
+ _currentActiveCubeFace = 0;
3366
+ _currentActiveMipmapLevel = 0;
3367
+ _currentRenderTarget = null;
3368
+
3369
+ state.reset();
3370
+ bindingStates.reset();
3371
+
3372
+ };
3373
+
3374
+ if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {
3375
+
3376
+ __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) );
3377
+
3378
+ }
3379
+
3380
+ }
3381
+
3382
+ /**
3383
+ * Defines the coordinate system of the renderer.
3384
+ *
3385
+ * In `WebGLRenderer`, the value is always `WebGLCoordinateSystem`.
3386
+ *
3387
+ * @type {WebGLCoordinateSystem|WebGPUCoordinateSystem}
3388
+ * @default WebGLCoordinateSystem
3389
+ * @readonly
3390
+ */
3391
+ get coordinateSystem() {
3392
+
3393
+ return WebGLCoordinateSystem;
3394
+
3395
+ }
3396
+
3397
+ /**
3398
+ * Defines the output color space of the renderer.
3399
+ *
3400
+ * @type {SRGBColorSpace|LinearSRGBColorSpace}
3401
+ * @default SRGBColorSpace
3402
+ */
3403
+ get outputColorSpace() {
3404
+
3405
+ return this._outputColorSpace;
3406
+
3407
+ }
3408
+
3409
+ set outputColorSpace( colorSpace ) {
3410
+
3411
+ this._outputColorSpace = colorSpace;
3412
+
3413
+ const gl = this.getContext();
3414
+ gl.drawingBufferColorSpace = ColorManagement._getDrawingBufferColorSpace( colorSpace );
3415
+ gl.unpackColorSpace = ColorManagement._getUnpackColorSpace();
3416
+
3417
+ }
3418
+
3419
+ }
3420
+
3421
+ // JSDoc
3422
+
3423
+ /**
3424
+ * WebGLRenderer options.
3425
+ *
3426
+ * @typedef {Object} WebGLRenderer~Options
3427
+ * @property {HTMLCanvasElement|OffscreenCanvas} [canvas=null] - A canvas element where the renderer draws its output. If not passed in here, a new canvas element will be created by the renderer.
3428
+ * @property {WebGL2RenderingContext} [context=null] - Can be used to attach an existing rendering context to this renderer.
3429
+ * @property {('highp'|'mediump'|'lowp')} [precision='highp'] - The default shader precision. Uses `highp` if supported by the device.
3430
+ * @property {boolean} [alpha=false] - Controls the default clear alpha value. When set to`true`, the value is `0`. Otherwise it's `1`.
3431
+ * @property {boolean} [premultipliedAlpha=true] Whether the renderer will assume colors have premultiplied alpha or not.
3432
+ * @property {boolean} [antialias=false] Whether to use the default MSAA or not.
3433
+ * @property {boolean} [stencil=false] Whether the drawing buffer has a stencil buffer of at least 8 bits or not.
3434
+ * @property {boolean} [preserveDrawingBuffer=false] Whether to preserve the buffer until manually cleared or overwritten.
3435
+ * @property {('default'|'low-power'|'high-performance')} [powerPreference='default'] Provides a hint to the user agent indicating what configuration of GPU is suitable for this WebGL context.
3436
+ * @property {boolean} [failIfMajorPerformanceCaveat=false] Whether the renderer creation will fail upon low performance is detected.
3437
+ * @property {boolean} [depth=true] Whether the drawing buffer has a depth buffer of at least 16 bits.
3438
+ * @property {boolean} [logarithmicDepthBuffer=false] Whether to use a logarithmic depth buffer. It may be necessary to use this if dealing with huge differences in scale in a single scene.
3439
+ * Note that this setting uses `gl_FragDepth` if available which disables the Early Fragment Test optimization and can cause a decrease in performance.
3440
+ * @property {boolean} [reversedDepthBuffer=false] Whether to use a reverse depth buffer. Requires the `EXT_clip_control` extension.
3441
+ * This is a more faster and accurate version than logarithmic depth buffer.
3442
+ **/
3443
+
3444
+ /**
3445
+ * WebGLRenderer Capabilities.
3446
+ *
3447
+ * @typedef {Object} WebGLRenderer~Capabilities
3448
+ * @property {Function} getMaxAnisotropy - Returns the maximum available anisotropy.
3449
+ * @property {Function} getMaxPrecision - Returns the maximum available precision for vertex and fragment shaders.
3450
+ * @property {boolean} logarithmicDepthBuffer - `true` if `logarithmicDepthBuffer` was set to `true` in the constructor.
3451
+ * @property {number} maxAttributes - The number of shader attributes that can be used by the vertex shader.
3452
+ * @property {number} maxCubemapSize - Maximum height * width of cube map textures that a shader can use.
3453
+ * @property {number} maxFragmentUniforms - The number of uniforms that can be used by a fragment shader.
3454
+ * @property {number} maxSamples - Maximum number of samples in context of Multisample anti-aliasing (MSAA).
3455
+ * @property {number} maxTextures - The maximum number of textures that can be used by a shader.
3456
+ * @property {number} maxTextureSize - Maximum height * width of a texture that a shader use.
3457
+ * @property {number} maxVaryings - The number of varying vectors that can used by shaders.
3458
+ * @property {number} maxVertexTextures - The number of textures that can be used in a vertex shader.
3459
+ * @property {number} maxVertexUniforms - The maximum number of uniforms that can be used in a vertex shader.
3460
+ * @property {string} precision - The shader precision currently being used by the renderer.
3461
+ * @property {boolean} reversedDepthBuffer - `true` if `reversedDepthBuffer` was set to `true` in the constructor
3462
+ * and the rendering context supports `EXT_clip_control`.
3463
+ * @property {boolean} vertexTextures - `true` if vertex textures can be used.
3464
+ **/
3465
+
3466
+ /**
3467
+ * WebGLRenderer Info Memory
3468
+ *
3469
+ * @typedef {Object} WebGLRenderer~InfoMemory
3470
+ * @property {number} geometries - The number of active geometries.
3471
+ * @property {number} textures - The number of active textures.
3472
+ **/
3473
+
3474
+ /**
3475
+ * WebGLRenderer Info Render
3476
+ *
3477
+ * @typedef {Object} WebGLRenderer~InfoRender
3478
+ * @property {number} frame - The frame ID.
3479
+ * @property {number} calls - The number of draw calls per frame.
3480
+ * @property {number} triangles - The number of rendered triangles primitives per frame.
3481
+ * @property {number} points - The number of rendered points primitives per frame.
3482
+ * @property {number} lines - The number of rendered lines primitives per frame.
3483
+ **/
3484
+
3485
+ /**
3486
+ * WebGLRenderer Info
3487
+ *
3488
+ * @typedef {Object} WebGLRenderer~Info
3489
+ * @property {boolean} [autoReset=true] - Whether to automatically reset the info by the renderer or not.
3490
+ * @property {WebGLRenderer~InfoMemory} memory - Information about allocated objects.
3491
+ * @property {WebGLRenderer~InfoRender} render - Information about rendered objects.
3492
+ * @property {?Array<WebGLProgram>} programs - An array `WebGLProgram`s used for rendering.
3493
+ * @property {Function} reset - Resets the info object for the next frame.
3494
+ **/
3495
+
3496
+ /**
3497
+ * WebGLRenderer Shadow Map.
3498
+ *
3499
+ * @typedef {Object} WebGLRenderer~ShadowMap
3500
+ * @property {boolean} [enabled=false] - If set to `true`, use shadow maps in the scene.
3501
+ * @property {boolean} [autoUpdate=true] - Enables automatic updates to the shadows in the scene.
3502
+ * If you do not require dynamic lighting / shadows, you may set this to `false`.
3503
+ * @property {boolean} [needsUpdate=false] - When set to `true`, shadow maps in the scene
3504
+ * will be updated in the next `render` call.
3505
+ * @property {(BasicShadowMap|PCFShadowMap|PCFSoftShadowMap|VSMShadowMap)} [type=PCFShadowMap] - Defines the shadow map type.
3506
+ **/
3507
+
3508
+ export { WebGLRenderer };