@needle-tools/three 0.145.4 → 0.146.2

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 (393) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +32586 -35951
  3. package/build/three.js +32600 -35965
  4. package/build/three.min.js +6 -7
  5. package/build/three.module.js +1547 -1154
  6. package/examples/js/animation/AnimationClipCreator.js +0 -8
  7. package/examples/js/animation/CCDIKSolver.js +49 -66
  8. package/examples/js/animation/MMDAnimationHelper.js +66 -137
  9. package/examples/js/animation/MMDPhysics.js +70 -134
  10. package/examples/js/cameras/CinematicCamera.js +33 -22
  11. package/examples/js/controls/ArcballControls.js +138 -405
  12. package/examples/js/controls/DragControls.js +8 -33
  13. package/examples/js/controls/FirstPersonControls.js +32 -54
  14. package/examples/js/controls/FlyControls.js +29 -55
  15. package/examples/js/controls/OrbitControls.js +85 -95
  16. package/examples/js/controls/PointerLockControls.js +5 -14
  17. package/examples/js/controls/TrackballControls.js +33 -86
  18. package/examples/js/controls/TransformControls.js +84 -169
  19. package/examples/js/csm/CSM.js +4 -39
  20. package/examples/js/csm/CSMFrustum.js +3 -9
  21. package/examples/js/csm/CSMHelper.js +24 -4
  22. package/examples/js/csm/CSMShader.js +2 -6
  23. package/examples/js/curves/CurveExtras.js +27 -27
  24. package/examples/js/curves/NURBSCurve.js +4 -16
  25. package/examples/js/curves/NURBSSurface.js +3 -9
  26. package/examples/js/curves/NURBSUtils.js +8 -45
  27. package/examples/js/effects/AnaglyphEffect.js +4 -18
  28. package/examples/js/effects/AsciiEffect.js +32 -31
  29. package/examples/js/effects/OutlineEffect.js +26 -30
  30. package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
  31. package/examples/js/effects/PeppersGhostEffect.js +12 -39
  32. package/examples/js/effects/StereoEffect.js +0 -4
  33. package/examples/js/environments/RoomEnvironment.js +12 -10
  34. package/examples/js/exporters/ColladaExporter.js +48 -65
  35. package/examples/js/exporters/DRACOExporter.js +22 -22
  36. package/examples/js/exporters/EXRExporter.js +15 -18
  37. package/examples/js/exporters/GLTFExporter.js +143 -261
  38. package/examples/js/exporters/MMDExporter.js +5 -12
  39. package/examples/js/exporters/OBJExporter.js +42 -33
  40. package/examples/js/exporters/PLYExporter.js +38 -33
  41. package/examples/js/exporters/STLExporter.js +5 -7
  42. package/examples/js/exporters/USDZExporter.js +110 -25
  43. package/examples/js/geometries/BoxLineGeometry.js +0 -1
  44. package/examples/js/geometries/ConvexGeometry.js +11 -6
  45. package/examples/js/geometries/DecalGeometry.js +53 -20
  46. package/examples/js/geometries/LightningStrike.js +54 -67
  47. package/examples/js/geometries/ParametricGeometries.js +8 -7
  48. package/examples/js/geometries/ParametricGeometry.js +25 -12
  49. package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
  50. package/examples/js/geometries/TeapotGeometry.js +54 -50
  51. package/examples/js/geometries/TextGeometry.js +6 -4
  52. package/examples/js/helpers/LightProbeHelper.js +1 -2
  53. package/examples/js/helpers/OctreeHelper.js +22 -20
  54. package/examples/js/helpers/PositionalAudioHelper.js +8 -6
  55. package/examples/js/helpers/RectAreaLightHelper.js +6 -7
  56. package/examples/js/helpers/VertexNormalsHelper.js +15 -13
  57. package/examples/js/helpers/VertexTangentsHelper.js +15 -9
  58. package/examples/js/helpers/ViewHelper.js +31 -16
  59. package/examples/js/interactive/HTMLMesh.js +22 -33
  60. package/examples/js/interactive/InteractiveGroup.js +6 -12
  61. package/examples/js/interactive/SelectionBox.js +3 -70
  62. package/examples/js/interactive/SelectionHelper.js +0 -8
  63. package/examples/js/lights/LightProbeGenerator.js +32 -39
  64. package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
  65. package/examples/js/lines/LineGeometry.js +3 -5
  66. package/examples/js/lines/LineMaterial.js +4 -11
  67. package/examples/js/lines/LineSegments2.js +38 -89
  68. package/examples/js/lines/LineSegmentsGeometry.js +7 -28
  69. package/examples/js/lines/Wireframe.js +2 -7
  70. package/examples/js/lines/WireframeGeometry2.js +3 -1
  71. package/examples/js/loaders/3DMLoader.js +58 -155
  72. package/examples/js/loaders/3MFLoader.js +72 -106
  73. package/examples/js/loaders/AMFLoader.js +0 -25
  74. package/examples/js/loaders/BVHLoader.js +44 -43
  75. package/examples/js/loaders/BasisTextureLoader.js +16 -46
  76. package/examples/js/loaders/ColladaLoader.js +201 -359
  77. package/examples/js/loaders/DDSLoader.js +24 -25
  78. package/examples/js/loaders/DRACOLoader.js +29 -66
  79. package/examples/js/loaders/EXRLoader.js +67 -164
  80. package/examples/js/loaders/FBXLoader.js +286 -441
  81. package/examples/js/loaders/FontLoader.js +6 -15
  82. package/examples/js/loaders/GCodeLoader.js +15 -16
  83. package/examples/js/loaders/GLTFLoader.js +354 -405
  84. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
  85. package/examples/js/loaders/KMZLoader.js +3 -7
  86. package/examples/js/loaders/KTXLoader.js +12 -30
  87. package/examples/js/loaders/LDrawLoader.js +178 -289
  88. package/examples/js/loaders/LUT3dlLoader.js +7 -11
  89. package/examples/js/loaders/LUTCubeLoader.js +0 -8
  90. package/examples/js/loaders/LWOLoader.js +59 -124
  91. package/examples/js/loaders/LogLuvLoader.js +27 -77
  92. package/examples/js/loaders/LottieLoader.js +4 -4
  93. package/examples/js/loaders/MD2Loader.js +26 -27
  94. package/examples/js/loaders/MDDLoader.js +6 -10
  95. package/examples/js/loaders/MMDLoader.js +180 -189
  96. package/examples/js/loaders/MTLLoader.js +18 -47
  97. package/examples/js/loaders/MaterialXLoader.js +392 -0
  98. package/examples/js/loaders/NRRDLoader.js +44 -84
  99. package/examples/js/loaders/OBJLoader.js +50 -65
  100. package/examples/js/loaders/PCDLoader.js +34 -29
  101. package/examples/js/loaders/PDBLoader.js +17 -13
  102. package/examples/js/loaders/PLYLoader.js +9 -39
  103. package/examples/js/loaders/PRWMLoader.js +11 -22
  104. package/examples/js/loaders/PVRLoader.js +7 -16
  105. package/examples/js/loaders/RGBELoader.js +36 -61
  106. package/examples/js/loaders/RGBMLoader.js +26 -87
  107. package/examples/js/loaders/STLLoader.js +20 -27
  108. package/examples/js/loaders/SVGLoader.js +361 -233
  109. package/examples/js/loaders/TDSLoader.js +81 -118
  110. package/examples/js/loaders/TGALoader.js +39 -41
  111. package/examples/js/loaders/TIFFLoader.js +0 -1
  112. package/examples/js/loaders/TTFLoader.js +0 -8
  113. package/examples/js/loaders/TiltLoader.js +14 -15
  114. package/examples/js/loaders/VOXLoader.js +8 -16
  115. package/examples/js/loaders/VRMLLoader.js +243 -340
  116. package/examples/js/loaders/VTKLoader.js +101 -118
  117. package/examples/js/loaders/XYZLoader.js +2 -4
  118. package/examples/js/loaders/lwo/IFFParser.js +55 -136
  119. package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
  120. package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
  121. package/examples/js/materials/MeshGouraudMaterial.js +15 -13
  122. package/examples/js/math/Capsule.js +0 -17
  123. package/examples/js/math/ColorConverter.js +3 -3
  124. package/examples/js/math/ConvexHull.js +183 -139
  125. package/examples/js/math/ImprovedNoise.js +1 -1
  126. package/examples/js/math/Lut.js +8 -15
  127. package/examples/js/math/MeshSurfaceSampler.js +6 -28
  128. package/examples/js/math/OBB.js +90 -49
  129. package/examples/js/math/Octree.js +2 -57
  130. package/examples/js/math/SimplexNoise.js +74 -88
  131. package/examples/js/misc/ConvexObjectBreaker.js +37 -48
  132. package/examples/js/misc/GPUComputationRenderer.js +14 -18
  133. package/examples/js/misc/Gyroscope.js +5 -9
  134. package/examples/js/misc/MD2Character.js +14 -23
  135. package/examples/js/misc/MD2CharacterComplex.js +73 -54
  136. package/examples/js/misc/MorphAnimMesh.js +0 -6
  137. package/examples/js/misc/MorphBlendMesh.js +3 -30
  138. package/examples/js/misc/ProgressiveLightMap.js +47 -43
  139. package/examples/js/misc/RollerCoaster.js +17 -24
  140. package/examples/js/misc/TubePainter.js +18 -12
  141. package/examples/js/misc/Volume.js +16 -45
  142. package/examples/js/misc/VolumeSlice.js +14 -24
  143. package/examples/js/modifiers/CurveModifier.js +19 -21
  144. package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
  145. package/examples/js/modifiers/SimplifyModifier.js +56 -59
  146. package/examples/js/modifiers/TessellateModifier.js +2 -9
  147. package/examples/js/objects/GroundProjectedEnv.js +2 -14
  148. package/examples/js/objects/Lensflare.js +47 -38
  149. package/examples/js/objects/LightningStorm.js +10 -13
  150. package/examples/js/objects/MarchingCubes.js +80 -59
  151. package/examples/js/objects/Reflector.js +22 -20
  152. package/examples/js/objects/ReflectorForSSRPass.js +19 -23
  153. package/examples/js/objects/Refractor.js +52 -30
  154. package/examples/js/objects/ShadowMesh.js +1 -2
  155. package/examples/js/objects/Sky.js +2 -7
  156. package/examples/js/objects/Water.js +23 -18
  157. package/examples/js/objects/Water2.js +20 -19
  158. package/examples/js/physics/AmmoPhysics.js +23 -20
  159. package/examples/js/physics/OimoPhysics.js +19 -17
  160. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
  161. package/examples/js/postprocessing/AfterimagePass.js +19 -12
  162. package/examples/js/postprocessing/BloomPass.js +38 -17
  163. package/examples/js/postprocessing/BokehPass.js +29 -12
  164. package/examples/js/postprocessing/ClearPass.js +1 -6
  165. package/examples/js/postprocessing/CubeTexturePass.js +12 -9
  166. package/examples/js/postprocessing/DotScreenPass.js +7 -5
  167. package/examples/js/postprocessing/EffectComposer.js +25 -32
  168. package/examples/js/postprocessing/FilmPass.js +7 -5
  169. package/examples/js/postprocessing/GlitchPass.js +10 -11
  170. package/examples/js/postprocessing/HalftonePass.js +9 -9
  171. package/examples/js/postprocessing/LUTPass.js +2 -15
  172. package/examples/js/postprocessing/MaskPass.js +20 -17
  173. package/examples/js/postprocessing/OutlinePass.js +45 -36
  174. package/examples/js/postprocessing/Pass.js +11 -14
  175. package/examples/js/postprocessing/RenderPass.js +3 -7
  176. package/examples/js/postprocessing/SAOPass.js +40 -32
  177. package/examples/js/postprocessing/SMAAPass.js +34 -17
  178. package/examples/js/postprocessing/SSAARenderPass.js +14 -14
  179. package/examples/js/postprocessing/SSAOPass.js +56 -42
  180. package/examples/js/postprocessing/SSRPass.js +78 -61
  181. package/examples/js/postprocessing/SavePass.js +14 -6
  182. package/examples/js/postprocessing/ShaderPass.js +9 -8
  183. package/examples/js/postprocessing/TAARenderPass.js +11 -9
  184. package/examples/js/postprocessing/TexturePass.js +7 -4
  185. package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
  186. package/examples/js/renderers/CSS2DRenderer.js +2 -21
  187. package/examples/js/renderers/CSS3DRenderer.js +3 -24
  188. package/examples/js/renderers/Projector.js +29 -85
  189. package/examples/js/renderers/SVGRenderer.js +4 -50
  190. package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
  191. package/examples/js/shaders/AfterimageShader.js +3 -6
  192. package/examples/js/shaders/BasicShader.js +3 -6
  193. package/examples/js/shaders/BleachBypassShader.js +3 -6
  194. package/examples/js/shaders/BlendShader.js +3 -6
  195. package/examples/js/shaders/BokehShader.js +3 -6
  196. package/examples/js/shaders/BokehShader2.js +4 -13
  197. package/examples/js/shaders/BrightnessContrastShader.js +3 -6
  198. package/examples/js/shaders/ColorCorrectionShader.js +2 -6
  199. package/examples/js/shaders/ColorifyShader.js +2 -6
  200. package/examples/js/shaders/ConvolutionShader.js +5 -10
  201. package/examples/js/shaders/CopyShader.js +3 -6
  202. package/examples/js/shaders/DOFMipMapShader.js +3 -6
  203. package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
  204. package/examples/js/shaders/DigitalGlitch.js +3 -6
  205. package/examples/js/shaders/DotScreenShader.js +2 -6
  206. package/examples/js/shaders/FXAAShader.js +1 -3
  207. package/examples/js/shaders/FilmShader.js +3 -6
  208. package/examples/js/shaders/FocusShader.js +3 -6
  209. package/examples/js/shaders/FreiChenShader.js +2 -6
  210. package/examples/js/shaders/GammaCorrectionShader.js +3 -6
  211. package/examples/js/shaders/GodRaysShader.js +11 -24
  212. package/examples/js/shaders/HalftoneShader.js +3 -6
  213. package/examples/js/shaders/HorizontalBlurShader.js +3 -6
  214. package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
  215. package/examples/js/shaders/HueSaturationShader.js +3 -6
  216. package/examples/js/shaders/KaleidoShader.js +3 -6
  217. package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
  218. package/examples/js/shaders/LuminosityShader.js +3 -6
  219. package/examples/js/shaders/MMDToonShader.js +2 -6
  220. package/examples/js/shaders/MirrorShader.js +3 -6
  221. package/examples/js/shaders/NormalMapShader.js +2 -6
  222. package/examples/js/shaders/RGBShiftShader.js +3 -6
  223. package/examples/js/shaders/SAOShader.js +2 -6
  224. package/examples/js/shaders/SMAAShader.js +6 -18
  225. package/examples/js/shaders/SSAOShader.js +2 -6
  226. package/examples/js/shaders/SSRShader.js +6 -18
  227. package/examples/js/shaders/SepiaShader.js +3 -6
  228. package/examples/js/shaders/SobelOperatorShader.js +2 -6
  229. package/examples/js/shaders/TechnicolorShader.js +3 -6
  230. package/examples/js/shaders/ToneMapShader.js +3 -6
  231. package/examples/js/shaders/ToonShader.js +8 -24
  232. package/examples/js/shaders/TriangleBlurShader.js +2 -6
  233. package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
  234. package/examples/js/shaders/VelocityShader.js +126 -0
  235. package/examples/js/shaders/VerticalBlurShader.js +3 -6
  236. package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
  237. package/examples/js/shaders/VignetteShader.js +3 -6
  238. package/examples/js/shaders/VolumeShader.js +2 -6
  239. package/examples/js/shaders/WaterRefractionShader.js +2 -6
  240. package/examples/js/textures/FlakesTexture.js +0 -1
  241. package/examples/js/utils/BufferGeometryUtils.js +234 -168
  242. package/examples/js/utils/CameraUtils.js +5 -20
  243. package/examples/js/utils/GPUStatsPanel.js +3 -12
  244. package/examples/js/utils/GeometryCompressionUtils.js +19 -44
  245. package/examples/js/utils/GeometryUtils.js +13 -18
  246. package/examples/js/utils/LDrawUtils.js +8 -11
  247. package/examples/js/utils/PackedPhongMaterial.js +6 -4
  248. package/examples/js/utils/SceneUtils.js +117 -6
  249. package/examples/js/utils/ShadowMapViewer.js +17 -14
  250. package/examples/js/utils/SkeletonUtils.js +13 -27
  251. package/examples/js/utils/UVsDebug.js +20 -12
  252. package/examples/js/utils/WorkerPool.js +1 -11
  253. package/examples/jsm/animation/CCDIKSolver.js +1 -1
  254. package/examples/jsm/capabilities/WebGPU.js +3 -1
  255. package/examples/jsm/controls/OrbitControls.js +44 -4
  256. package/examples/jsm/exporters/GLTFExporter.js +17 -131
  257. package/examples/jsm/exporters/USDZExporter.js +75 -19
  258. package/examples/jsm/interactive/HTMLMesh.js +2 -0
  259. package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
  260. package/examples/jsm/loaders/3DMLoader.js +1 -2
  261. package/examples/jsm/loaders/ColladaLoader.js +28 -0
  262. package/examples/jsm/loaders/FBXLoader.js +16 -2
  263. package/examples/jsm/loaders/GLTFLoader.js +204 -377
  264. package/examples/jsm/loaders/KTX2Loader.js +68 -29
  265. package/examples/jsm/loaders/LDrawLoader.js +14 -13
  266. package/examples/jsm/loaders/LottieLoader.js +4 -2
  267. package/examples/jsm/loaders/MaterialXLoader.js +728 -0
  268. package/examples/jsm/loaders/PCDLoader.js +1 -1
  269. package/examples/jsm/loaders/PLYLoader.js +68 -16
  270. package/examples/jsm/loaders/SVGLoader.js +227 -14
  271. package/examples/jsm/loaders/USDZLoader.js +31 -16
  272. package/examples/jsm/nodes/Nodes.js +14 -2
  273. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  274. package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
  275. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  276. package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
  277. package/examples/jsm/nodes/core/Node.js +1 -1
  278. package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
  279. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  280. package/examples/jsm/nodes/core/NodeVarying.js +7 -4
  281. package/examples/jsm/nodes/core/VaryingNode.js +6 -4
  282. package/examples/jsm/nodes/core/constants.js +13 -13
  283. package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
  284. package/examples/jsm/nodes/display/ViewportNode.js +106 -0
  285. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  286. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  287. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
  288. package/examples/jsm/nodes/materials/Materials.js +9 -7
  289. package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
  290. package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
  291. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
  292. package/examples/jsm/nodes/math/MathNode.js +5 -0
  293. package/examples/jsm/nodes/math/OperatorNode.js +6 -1
  294. package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
  295. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
  296. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
  297. package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
  298. package/examples/jsm/nodes/utils/JoinNode.js +8 -2
  299. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
  300. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  301. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
  302. package/examples/jsm/nodes/utils/TimerNode.js +1 -1
  303. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
  304. package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
  305. package/examples/jsm/postprocessing/BloomPass.js +22 -3
  306. package/examples/jsm/postprocessing/BokehPass.js +18 -4
  307. package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
  308. package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
  309. package/examples/jsm/postprocessing/EffectComposer.js +9 -0
  310. package/examples/jsm/postprocessing/FilmPass.js +8 -0
  311. package/examples/jsm/postprocessing/GlitchPass.js +13 -1
  312. package/examples/jsm/postprocessing/HalftonePass.js +8 -0
  313. package/examples/jsm/postprocessing/OutlinePass.js +10 -0
  314. package/examples/jsm/postprocessing/Pass.js +2 -0
  315. package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
  316. package/examples/jsm/postprocessing/SAOPass.js +20 -0
  317. package/examples/jsm/postprocessing/SMAAPass.js +16 -0
  318. package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
  319. package/examples/jsm/postprocessing/SavePass.js +17 -1
  320. package/examples/jsm/postprocessing/ShaderPass.js +8 -0
  321. package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
  322. package/examples/jsm/postprocessing/TexturePass.js +8 -0
  323. package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
  324. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
  325. package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
  326. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
  327. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
  328. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
  329. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
  330. package/examples/jsm/shaders/MMDToonShader.js +0 -2
  331. package/examples/jsm/shaders/VelocityShader.js +128 -0
  332. package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
  333. package/examples/jsm/utils/SceneUtils.js +129 -4
  334. package/examples/jsm/utils/TextureUtils.js +85 -0
  335. package/examples/jsm/webxr/OculusHandModel.js +1 -1
  336. package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
  337. package/package.json +11 -12
  338. package/src/Three.js +1 -0
  339. package/src/audio/AudioContext.js +5 -5
  340. package/src/cameras/CubeCamera.js +14 -14
  341. package/src/constants.js +1 -1
  342. package/src/core/InstancedBufferGeometry.js +1 -7
  343. package/src/extras/Earcut.js +67 -67
  344. package/src/helpers/DirectionalLightHelper.js +5 -1
  345. package/src/helpers/HemisphereLightHelper.js +4 -1
  346. package/src/helpers/PointLightHelper.js +2 -1
  347. package/src/helpers/SpotLightHelper.js +4 -2
  348. package/src/lights/PointLight.js +2 -2
  349. package/src/lights/SpotLight.js +2 -2
  350. package/src/loaders/FileLoader.js +4 -1
  351. package/src/loaders/ObjectLoader.js +5 -1
  352. package/src/materials/Material.js +1 -1
  353. package/src/math/Color.js +5 -5
  354. package/src/math/Matrix3.js +53 -18
  355. package/src/math/Ray.js +2 -5
  356. package/src/math/Sphere.js +19 -26
  357. package/src/objects/InstancedMesh.js +7 -0
  358. package/src/objects/LOD.js +25 -6
  359. package/src/renderers/WebGL3DRenderTarget.js +1 -1
  360. package/src/renderers/WebGLArrayRenderTarget.js +1 -1
  361. package/src/renderers/WebGLCubeRenderTarget.js +1 -1
  362. package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
  363. package/src/renderers/WebGLRenderTarget.js +1 -1
  364. package/src/renderers/WebGLRenderer.js +36 -62
  365. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
  366. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
  367. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
  368. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
  369. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
  370. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
  371. package/src/renderers/shaders/ShaderChunk.js +3 -0
  372. package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
  373. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  374. package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
  375. package/src/renderers/shaders/ShaderLib.js +20 -6
  376. package/src/renderers/shaders/UniformsLib.js +1 -1
  377. package/src/renderers/shaders/UniformsUtils.js +15 -0
  378. package/src/renderers/webgl/WebGLAttributes.js +2 -0
  379. package/src/renderers/webgl/WebGLBackground.js +15 -7
  380. package/src/renderers/webgl/WebGLLights.js +0 -4
  381. package/src/renderers/webgl/WebGLMaterials.js +2 -1
  382. package/src/renderers/webgl/WebGLShadowMap.js +3 -1
  383. package/src/renderers/webgl/WebGLState.js +31 -1
  384. package/src/renderers/webgl/WebGLTextures.js +71 -18
  385. package/src/renderers/webgl/WebGLUniforms.js +116 -20
  386. package/src/renderers/webgl/WebGLUtils.js +1 -1
  387. package/src/renderers/webxr/WebXRController.js +46 -13
  388. package/src/renderers/webxr/WebXRManager.js +85 -3
  389. package/src/scenes/Scene.js +8 -0
  390. package/src/textures/CompressedArrayTexture.js +18 -0
  391. package/examples/js/libs/lottie_canvas.js +0 -12751
  392. package/examples/js/shaders/PixelShader.js +0 -51
  393. package/examples/jsm/shaders/PixelShader.js +0 -44
@@ -1,3 +1,5 @@
1
+ import { sRGBEncoding, LinearSRGBColorSpace, SRGBColorSpace } from '../../constants.js';
2
+
1
3
  /**
2
4
  * Uniform Utilities
3
5
  */
@@ -73,6 +75,19 @@ export function cloneUniformsGroups( src ) {
73
75
 
74
76
  }
75
77
 
78
+ export function getUnlitUniformColorSpace( renderer ) {
79
+
80
+ if ( renderer.getRenderTarget() === null ) {
81
+
82
+ // https://github.com/mrdoob/three.js/pull/23937#issuecomment-1111067398
83
+ return renderer.outputEncoding === sRGBEncoding ? SRGBColorSpace : LinearSRGBColorSpace;
84
+
85
+ }
86
+
87
+ return LinearSRGBColorSpace;
88
+
89
+ }
90
+
76
91
  // Legacy
77
92
 
78
93
  const UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };
@@ -112,6 +112,8 @@ function WebGLAttributes( gl, capabilities ) {
112
112
 
113
113
  }
114
114
 
115
+ attribute.onUploadCallback();
116
+
115
117
  }
116
118
 
117
119
  //
@@ -5,9 +5,11 @@ import { ShaderMaterial } from '../../materials/ShaderMaterial.js';
5
5
  import { Color } from '../../math/Color.js';
6
6
  import { Mesh } from '../../objects/Mesh.js';
7
7
  import { ShaderLib } from '../shaders/ShaderLib.js';
8
- import { cloneUniforms } from '../shaders/UniformsUtils.js';
8
+ import { cloneUniforms, getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
9
9
 
10
- function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipliedAlpha ) {
10
+ const _rgb = { r: 0, b: 0, g: 0 };
11
+
12
+ function WebGLBackground( renderer, cubemaps, cubeuvmaps, state, objects, alpha, premultipliedAlpha ) {
11
13
 
12
14
  const clearColor = new Color( 0x000000 );
13
15
  let clearAlpha = alpha === true ? 0 : 1;
@@ -26,7 +28,8 @@ function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipli
26
28
 
27
29
  if ( background && background.isTexture ) {
28
30
 
29
- background = cubemaps.get( background );
31
+ const usePMREM = scene.backgroundBlurriness > 0; // use PMREM if the user wants to blur the background
32
+ background = ( usePMREM ? cubeuvmaps : cubemaps ).get( background );
30
33
 
31
34
  }
32
35
 
@@ -67,9 +70,9 @@ function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipli
67
70
  new BoxGeometry( 1, 1, 1 ),
68
71
  new ShaderMaterial( {
69
72
  name: 'BackgroundCubeMaterial',
70
- uniforms: cloneUniforms( ShaderLib.cube.uniforms ),
71
- vertexShader: ShaderLib.cube.vertexShader,
72
- fragmentShader: ShaderLib.cube.fragmentShader,
73
+ uniforms: cloneUniforms( ShaderLib.backgroundCube.uniforms ),
74
+ vertexShader: ShaderLib.backgroundCube.vertexShader,
75
+ fragmentShader: ShaderLib.backgroundCube.fragmentShader,
73
76
  side: BackSide,
74
77
  depthTest: false,
75
78
  depthWrite: false,
@@ -103,6 +106,8 @@ function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipli
103
106
 
104
107
  boxMesh.material.uniforms.envMap.value = background;
105
108
  boxMesh.material.uniforms.flipEnvMap.value = ( background.isCubeTexture && background.isRenderTargetTexture === false ) ? - 1 : 1;
109
+ boxMesh.material.uniforms.backgroundBlurriness.value = scene.backgroundBlurriness;
110
+ boxMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
106
111
 
107
112
  if ( currentBackground !== background ||
108
113
  currentBackgroundVersion !== background.version ||
@@ -157,6 +162,7 @@ function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipli
157
162
  }
158
163
 
159
164
  planeMesh.material.uniforms.t2D.value = background;
165
+ planeMesh.material.uniforms.backgroundIntensity.value = scene.backgroundIntensity;
160
166
 
161
167
  if ( background.matrixAutoUpdate === true ) {
162
168
 
@@ -189,7 +195,9 @@ function WebGLBackground( renderer, cubemaps, state, objects, alpha, premultipli
189
195
 
190
196
  function setClear( color, alpha ) {
191
197
 
192
- state.buffers.color.setClear( color.r, color.g, color.b, alpha, premultipliedAlpha );
198
+ color.getRGB( _rgb, getUnlitUniformColorSpace( renderer ) );
199
+
200
+ state.buffers.color.setClear( _rgb.r, _rgb.g, _rgb.b, alpha, premultipliedAlpha );
193
201
 
194
202
  }
195
203
 
@@ -333,10 +333,6 @@ function WebGLLights( extensions, capabilities ) {
333
333
 
334
334
  const uniforms = cache.get( light );
335
335
 
336
- // (a) intensity is the total visible light emitted
337
- //uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) );
338
-
339
- // (b) intensity is the brightness of the light
340
336
  uniforms.color.copy( color ).multiplyScalar( intensity );
341
337
 
342
338
  uniforms.halfWidth.set( light.width * 0.5, 0.0, 0.0 );
@@ -1,10 +1,11 @@
1
1
  import { BackSide } from '../../constants.js';
2
+ import { getUnlitUniformColorSpace } from '../shaders/UniformsUtils.js';
2
3
 
3
4
  function WebGLMaterials( renderer, properties ) {
4
5
 
5
6
  function refreshFogUniforms( uniforms, fog ) {
6
7
 
7
- uniforms.fogColor.value.copy( fog.color );
8
+ fog.color.getRGB( uniforms.fogColor.value, getUnlitUniformColorSpace( renderer ) );
8
9
 
9
10
  if ( fog.isFog ) {
10
11
 
@@ -244,7 +244,8 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
244
244
 
245
245
  if ( ( _renderer.localClippingEnabled && material.clipShadows === true && Array.isArray( material.clippingPlanes ) && material.clippingPlanes.length !== 0 ) ||
246
246
  ( material.displacementMap && material.displacementScale !== 0 ) ||
247
- ( material.alphaMap && material.alphaTest > 0 ) ) {
247
+ ( material.alphaMap && material.alphaTest > 0 ) ||
248
+ ( material.map && material.alphaTest > 0 ) ) {
248
249
 
249
250
  // in this case we need a unique material instance reflecting the
250
251
  // appropriate state
@@ -288,6 +289,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
288
289
 
289
290
  result.alphaMap = material.alphaMap;
290
291
  result.alphaTest = material.alphaTest;
292
+ result.map = material.map;
291
293
 
292
294
  result.clipShadows = material.clipShadows;
293
295
  result.clippingPlanes = material.clippingPlanes;
@@ -718,7 +718,7 @@ function WebGLState( gl, extensions, capabilities ) {
718
718
  }
719
719
 
720
720
  currentBlending = blending;
721
- currentPremultipledAlpha = null;
721
+ currentPremultipledAlpha = false;
722
722
 
723
723
  }
724
724
 
@@ -952,6 +952,20 @@ function WebGLState( gl, extensions, capabilities ) {
952
952
 
953
953
  }
954
954
 
955
+ function compressedTexImage3D() {
956
+
957
+ try {
958
+
959
+ gl.compressedTexImage3D.apply( gl, arguments );
960
+
961
+ } catch ( error ) {
962
+
963
+ console.error( 'THREE.WebGLState:', error );
964
+
965
+ }
966
+
967
+ }
968
+
955
969
  function texSubImage2D() {
956
970
 
957
971
  try {
@@ -994,6 +1008,20 @@ function WebGLState( gl, extensions, capabilities ) {
994
1008
 
995
1009
  }
996
1010
 
1011
+ function compressedTexSubImage3D() {
1012
+
1013
+ try {
1014
+
1015
+ gl.compressedTexSubImage3D.apply( gl, arguments );
1016
+
1017
+ } catch ( error ) {
1018
+
1019
+ console.error( 'THREE.WebGLState:', error );
1020
+
1021
+ }
1022
+
1023
+ }
1024
+
997
1025
  function texStorage2D() {
998
1026
 
999
1027
  try {
@@ -1239,6 +1267,7 @@ function WebGLState( gl, extensions, capabilities ) {
1239
1267
  bindTexture: bindTexture,
1240
1268
  unbindTexture: unbindTexture,
1241
1269
  compressedTexImage2D: compressedTexImage2D,
1270
+ compressedTexImage3D: compressedTexImage3D,
1242
1271
  texImage2D: texImage2D,
1243
1272
  texImage3D: texImage3D,
1244
1273
 
@@ -1250,6 +1279,7 @@ function WebGLState( gl, extensions, capabilities ) {
1250
1279
  texSubImage2D: texSubImage2D,
1251
1280
  texSubImage3D: texSubImage3D,
1252
1281
  compressedTexSubImage2D: compressedTexSubImage2D,
1282
+ compressedTexSubImage3D: compressedTexSubImage3D,
1253
1283
 
1254
1284
  scissor: scissor,
1255
1285
  viewport: viewport,
@@ -11,7 +11,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
11
11
  const maxTextureSize = capabilities.maxTextureSize;
12
12
  const maxSamples = capabilities.maxSamples;
13
13
  const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
14
- const supportsInvalidateFramebuffer = /OculusBrowser/g.test( navigator.userAgent );
14
+ const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );
15
15
 
16
16
  const _videoTextures = new WeakMap();
17
17
  let _canvas;
@@ -415,6 +415,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
415
415
 
416
416
  array.push( texture.wrapS );
417
417
  array.push( texture.wrapT );
418
+ array.push( texture.wrapR || 0 );
418
419
  array.push( texture.magFilter );
419
420
  array.push( texture.minFilter );
420
421
  array.push( texture.anisotropy );
@@ -671,7 +672,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
671
672
 
672
673
  let textureType = _gl.TEXTURE_2D;
673
674
 
674
- if ( texture.isDataArrayTexture ) textureType = _gl.TEXTURE_2D_ARRAY;
675
+ if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) textureType = _gl.TEXTURE_2D_ARRAY;
675
676
  if ( texture.isData3DTexture ) textureType = _gl.TEXTURE_3D;
676
677
 
677
678
  const forceUpload = initTexture( textureProperties, texture );
@@ -853,45 +854,97 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
853
854
 
854
855
  } else if ( texture.isCompressedTexture ) {
855
856
 
856
- if ( useTexStorage && allocateMemory ) {
857
+ if ( texture.isCompressedArrayTexture ) {
857
858
 
858
- state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
859
+ if ( useTexStorage && allocateMemory ) {
859
860
 
860
- }
861
+ state.texStorage3D( _gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height, image.depth );
861
862
 
862
- for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
863
+ }
863
864
 
864
- mipmap = mipmaps[ i ];
865
+ for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
865
866
 
866
- if ( texture.format !== RGBAFormat ) {
867
+ mipmap = mipmaps[ i ];
867
868
 
868
- if ( glFormat !== null ) {
869
+ if ( texture.format !== RGBAFormat ) {
869
870
 
870
- if ( useTexStorage ) {
871
+ if ( glFormat !== null ) {
872
+
873
+ if ( useTexStorage ) {
874
+
875
+ state.compressedTexSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, mipmap.data, 0, 0 );
871
876
 
872
- state.compressedTexSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
877
+ } else {
878
+
879
+ state.compressedTexImage3D( _gl.TEXTURE_2D_ARRAY, i, glInternalFormat, mipmap.width, mipmap.height, image.depth, 0, mipmap.data, 0, 0 );
880
+
881
+ }
873
882
 
874
883
  } else {
875
884
 
876
- state.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
885
+ console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
877
886
 
878
887
  }
879
888
 
880
889
  } else {
881
890
 
882
- console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
891
+ if ( useTexStorage ) {
892
+
893
+ state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, i, 0, 0, 0, mipmap.width, mipmap.height, image.depth, glFormat, glType, mipmap.data );
894
+
895
+ } else {
896
+
897
+ state.texImage3D( _gl.TEXTURE_2D_ARRAY, i, glInternalFormat, mipmap.width, mipmap.height, image.depth, 0, glFormat, glType, mipmap.data );
898
+
899
+ }
883
900
 
884
901
  }
885
902
 
886
- } else {
903
+ }
887
904
 
888
- if ( useTexStorage ) {
905
+ } else {
889
906
 
890
- state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
907
+ if ( useTexStorage && allocateMemory ) {
908
+
909
+ state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
910
+
911
+ }
912
+
913
+ for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
914
+
915
+ mipmap = mipmaps[ i ];
916
+
917
+ if ( texture.format !== RGBAFormat ) {
918
+
919
+ if ( glFormat !== null ) {
920
+
921
+ if ( useTexStorage ) {
922
+
923
+ state.compressedTexSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, mipmap.data );
924
+
925
+ } else {
926
+
927
+ state.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );
928
+
929
+ }
930
+
931
+ } else {
932
+
933
+ console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );
934
+
935
+ }
891
936
 
892
937
  } else {
893
938
 
894
- state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
939
+ if ( useTexStorage ) {
940
+
941
+ state.texSubImage2D( _gl.TEXTURE_2D, i, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
942
+
943
+ } else {
944
+
945
+ state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
946
+
947
+ }
895
948
 
896
949
  }
897
950
 
@@ -1269,7 +1322,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
1269
1322
 
1270
1323
  multisampledRTTExt.framebufferTexture2DMultisampleEXT( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0, getRenderTargetSamples( renderTarget ) );
1271
1324
 
1272
- } else {
1325
+ } else if ( textureTarget === _gl.TEXTURE_2D || ( textureTarget >= _gl.TEXTURE_CUBE_MAP_POSITIVE_X && textureTarget <= _gl.TEXTURE_CUBE_MAP_NEGATIVE_Z ) ) { // see #24753
1273
1326
 
1274
1327
  _gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0 );
1275
1328
 
@@ -362,17 +362,32 @@ function setValueV1i( gl, v ) {
362
362
 
363
363
  }
364
364
 
365
- // Single integer / boolean vector (from flat array)
365
+ // Single integer / boolean vector (from flat array or THREE.VectorN)
366
366
 
367
367
  function setValueV2i( gl, v ) {
368
368
 
369
369
  const cache = this.cache;
370
370
 
371
- if ( arraysEqual( cache, v ) ) return;
371
+ if ( v.x !== undefined ) {
372
372
 
373
- gl.uniform2iv( this.addr, v );
373
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
374
+
375
+ gl.uniform2i( this.addr, v.x, v.y );
376
+
377
+ cache[ 0 ] = v.x;
378
+ cache[ 1 ] = v.y;
374
379
 
375
- copyArray( cache, v );
380
+ }
381
+
382
+ } else {
383
+
384
+ if ( arraysEqual( cache, v ) ) return;
385
+
386
+ gl.uniform2iv( this.addr, v );
387
+
388
+ copyArray( cache, v );
389
+
390
+ }
376
391
 
377
392
  }
378
393
 
@@ -380,11 +395,27 @@ function setValueV3i( gl, v ) {
380
395
 
381
396
  const cache = this.cache;
382
397
 
383
- if ( arraysEqual( cache, v ) ) return;
398
+ if ( v.x !== undefined ) {
384
399
 
385
- gl.uniform3iv( this.addr, v );
400
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
401
+
402
+ gl.uniform3i( this.addr, v.x, v.y, v.z );
403
+
404
+ cache[ 0 ] = v.x;
405
+ cache[ 1 ] = v.y;
406
+ cache[ 2 ] = v.z;
407
+
408
+ }
386
409
 
387
- copyArray( cache, v );
410
+ } else {
411
+
412
+ if ( arraysEqual( cache, v ) ) return;
413
+
414
+ gl.uniform3iv( this.addr, v );
415
+
416
+ copyArray( cache, v );
417
+
418
+ }
388
419
 
389
420
  }
390
421
 
@@ -392,11 +423,28 @@ function setValueV4i( gl, v ) {
392
423
 
393
424
  const cache = this.cache;
394
425
 
395
- if ( arraysEqual( cache, v ) ) return;
426
+ if ( v.x !== undefined ) {
396
427
 
397
- gl.uniform4iv( this.addr, v );
428
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
398
429
 
399
- copyArray( cache, v );
430
+ gl.uniform4i( this.addr, v.x, v.y, v.z, v.w );
431
+
432
+ cache[ 0 ] = v.x;
433
+ cache[ 1 ] = v.y;
434
+ cache[ 2 ] = v.z;
435
+ cache[ 3 ] = v.w;
436
+
437
+ }
438
+
439
+ } else {
440
+
441
+ if ( arraysEqual( cache, v ) ) return;
442
+
443
+ gl.uniform4iv( this.addr, v );
444
+
445
+ copyArray( cache, v );
446
+
447
+ }
400
448
 
401
449
  }
402
450
 
@@ -414,17 +462,32 @@ function setValueV1ui( gl, v ) {
414
462
 
415
463
  }
416
464
 
417
- // Single unsigned integer vector (from flat array)
465
+ // Single unsigned integer vector (from flat array or THREE.VectorN)
418
466
 
419
467
  function setValueV2ui( gl, v ) {
420
468
 
421
469
  const cache = this.cache;
422
470
 
423
- if ( arraysEqual( cache, v ) ) return;
471
+ if ( v.x !== undefined ) {
424
472
 
425
- gl.uniform2uiv( this.addr, v );
473
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {
474
+
475
+ gl.uniform2ui( this.addr, v.x, v.y );
476
+
477
+ cache[ 0 ] = v.x;
478
+ cache[ 1 ] = v.y;
426
479
 
427
- copyArray( cache, v );
480
+ }
481
+
482
+ } else {
483
+
484
+ if ( arraysEqual( cache, v ) ) return;
485
+
486
+ gl.uniform2uiv( this.addr, v );
487
+
488
+ copyArray( cache, v );
489
+
490
+ }
428
491
 
429
492
  }
430
493
 
@@ -432,11 +495,27 @@ function setValueV3ui( gl, v ) {
432
495
 
433
496
  const cache = this.cache;
434
497
 
435
- if ( arraysEqual( cache, v ) ) return;
498
+ if ( v.x !== undefined ) {
436
499
 
437
- gl.uniform3uiv( this.addr, v );
500
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {
501
+
502
+ gl.uniform3ui( this.addr, v.x, v.y, v.z );
503
+
504
+ cache[ 0 ] = v.x;
505
+ cache[ 1 ] = v.y;
506
+ cache[ 2 ] = v.z;
507
+
508
+ }
438
509
 
439
- copyArray( cache, v );
510
+ } else {
511
+
512
+ if ( arraysEqual( cache, v ) ) return;
513
+
514
+ gl.uniform3uiv( this.addr, v );
515
+
516
+ copyArray( cache, v );
517
+
518
+ }
440
519
 
441
520
  }
442
521
 
@@ -444,11 +523,28 @@ function setValueV4ui( gl, v ) {
444
523
 
445
524
  const cache = this.cache;
446
525
 
447
- if ( arraysEqual( cache, v ) ) return;
526
+ if ( v.x !== undefined ) {
448
527
 
449
- gl.uniform4uiv( this.addr, v );
528
+ if ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {
450
529
 
451
- copyArray( cache, v );
530
+ gl.uniform4ui( this.addr, v.x, v.y, v.z, v.w );
531
+
532
+ cache[ 0 ] = v.x;
533
+ cache[ 1 ] = v.y;
534
+ cache[ 2 ] = v.z;
535
+ cache[ 3 ] = v.w;
536
+
537
+ }
538
+
539
+ } else {
540
+
541
+ if ( arraysEqual( cache, v ) ) return;
542
+
543
+ gl.uniform4uiv( this.addr, v );
544
+
545
+ copyArray( cache, v );
546
+
547
+ }
452
548
 
453
549
  }
454
550
 
@@ -43,7 +43,6 @@ function WebGLUtils( gl, extensions, capabilities ) {
43
43
  if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
44
44
  if ( p === DepthFormat ) return gl.DEPTH_COMPONENT;
45
45
  if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;
46
- if ( p === RedFormat ) return gl.RED;
47
46
 
48
47
  // @deprecated since r137
49
48
 
@@ -74,6 +73,7 @@ function WebGLUtils( gl, extensions, capabilities ) {
74
73
 
75
74
  // WebGL2 formats.
76
75
 
76
+ if ( p === RedFormat ) return gl.RED;
77
77
  if ( p === RedIntegerFormat ) return gl.RED_INTEGER;
78
78
  if ( p === RGFormat ) return gl.RG;
79
79
  if ( p === RGIntegerFormat ) return gl.RG_INTEGER;
@@ -90,6 +90,31 @@ class WebXRController {
90
90
 
91
91
  }
92
92
 
93
+ connect( inputSource ) {
94
+
95
+ if ( inputSource && inputSource.hand ) {
96
+
97
+ const hand = this._hand;
98
+
99
+ if ( hand ) {
100
+
101
+ for ( const inputjoint of inputSource.hand.values() ) {
102
+
103
+ // Initialize hand with joints when connected
104
+ this._getHandJoint( hand, inputjoint );
105
+
106
+ }
107
+
108
+ }
109
+
110
+ }
111
+
112
+ this.dispatchEvent( { type: 'connected', data: inputSource } );
113
+
114
+ return this;
115
+
116
+ }
117
+
93
118
  disconnect( inputSource ) {
94
119
 
95
120
  this.dispatchEvent( { type: 'disconnected', data: inputSource } );
@@ -137,19 +162,8 @@ class WebXRController {
137
162
  // Update the joints groups with the XRJoint poses
138
163
  const jointPose = frame.getJointPose( inputjoint, referenceSpace );
139
164
 
140
- if ( hand.joints[ inputjoint.jointName ] === undefined ) {
141
-
142
- // The transform of this joint will be updated with the joint pose on each frame
143
- const joint = new Group();
144
- joint.matrixAutoUpdate = false;
145
- joint.visible = false;
146
- hand.joints[ inputjoint.jointName ] = joint;
147
- // ??
148
- hand.add( joint );
149
-
150
- }
151
-
152
- const joint = hand.joints[ inputjoint.jointName ];
165
+ // The transform of this joint will be updated with the joint pose on each frame
166
+ const joint = this._getHandJoint( hand, inputjoint );
153
167
 
154
168
  if ( jointPose !== null ) {
155
169
 
@@ -301,6 +315,25 @@ class WebXRController {
301
315
 
302
316
  }
303
317
 
318
+ // private method
319
+
320
+ _getHandJoint( hand, inputjoint ) {
321
+
322
+ if ( hand.joints[ inputjoint.jointName ] === undefined ) {
323
+
324
+ const joint = new Group();
325
+ joint.matrixAutoUpdate = false;
326
+ joint.visible = false;
327
+ hand.joints[ inputjoint.jointName ] = joint;
328
+
329
+ hand.add( joint );
330
+
331
+ }
332
+
333
+ return hand.joints[ inputjoint.jointName ];
334
+
335
+ }
336
+
304
337
  }
305
338
 
306
339