super-three 0.144.0 → 0.147.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 (450) hide show
  1. package/README.md +1 -1
  2. package/build/three.cjs +735 -387
  3. package/build/three.js +735 -387
  4. package/build/three.min.js +1 -1
  5. package/build/three.module.js +910 -408
  6. package/examples/js/animation/AnimationClipCreator.js +0 -8
  7. package/examples/js/animation/CCDIKSolver.js +50 -67
  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 +125 -99
  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 +85 -170
  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 +141 -317
  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 +113 -27
  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 +25 -39
  60. package/examples/js/interactive/InteractiveGroup.js +9 -14
  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 +40 -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 +228 -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 +287 -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 +409 -706
  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/NRRDLoader.js +44 -84
  98. package/examples/js/loaders/OBJLoader.js +50 -65
  99. package/examples/js/loaders/PCDLoader.js +34 -29
  100. package/examples/js/loaders/PDBLoader.js +17 -13
  101. package/examples/js/loaders/PLYLoader.js +62 -48
  102. package/examples/js/loaders/PRWMLoader.js +11 -22
  103. package/examples/js/loaders/PVRLoader.js +7 -16
  104. package/examples/js/loaders/RGBELoader.js +36 -61
  105. package/examples/js/loaders/RGBMLoader.js +26 -87
  106. package/examples/js/loaders/STLLoader.js +20 -27
  107. package/examples/js/loaders/SVGLoader.js +361 -233
  108. package/examples/js/loaders/TDSLoader.js +81 -118
  109. package/examples/js/loaders/TGALoader.js +39 -41
  110. package/examples/js/loaders/TIFFLoader.js +0 -1
  111. package/examples/js/loaders/TTFLoader.js +0 -8
  112. package/examples/js/loaders/TiltLoader.js +14 -15
  113. package/examples/js/loaders/VOXLoader.js +8 -16
  114. package/examples/js/loaders/VRMLLoader.js +243 -340
  115. package/examples/js/loaders/VTKLoader.js +101 -118
  116. package/examples/js/loaders/XYZLoader.js +2 -4
  117. package/examples/js/loaders/lwo/IFFParser.js +55 -136
  118. package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
  119. package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
  120. package/examples/js/materials/MeshGouraudMaterial.js +15 -13
  121. package/examples/js/math/Capsule.js +0 -17
  122. package/examples/js/math/ColorConverter.js +3 -3
  123. package/examples/js/math/ConvexHull.js +185 -141
  124. package/examples/js/math/ImprovedNoise.js +1 -1
  125. package/examples/js/math/Lut.js +8 -15
  126. package/examples/js/math/MeshSurfaceSampler.js +6 -28
  127. package/examples/js/math/OBB.js +90 -49
  128. package/examples/js/math/Octree.js +2 -57
  129. package/examples/js/math/SimplexNoise.js +74 -88
  130. package/examples/js/misc/ConvexObjectBreaker.js +37 -48
  131. package/examples/js/misc/GPUComputationRenderer.js +26 -16
  132. package/examples/js/misc/Gyroscope.js +5 -9
  133. package/examples/js/misc/MD2Character.js +14 -23
  134. package/examples/js/misc/MD2CharacterComplex.js +73 -54
  135. package/examples/js/misc/MorphAnimMesh.js +0 -6
  136. package/examples/js/misc/MorphBlendMesh.js +3 -30
  137. package/examples/js/misc/ProgressiveLightMap.js +47 -43
  138. package/examples/js/misc/RollerCoaster.js +17 -24
  139. package/examples/js/misc/TubePainter.js +18 -12
  140. package/examples/js/misc/Volume.js +16 -45
  141. package/examples/js/misc/VolumeSlice.js +14 -24
  142. package/examples/js/modifiers/CurveModifier.js +19 -21
  143. package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
  144. package/examples/js/modifiers/SimplifyModifier.js +56 -59
  145. package/examples/js/modifiers/TessellateModifier.js +2 -9
  146. package/examples/js/objects/GroundProjectedEnv.js +2 -14
  147. package/examples/js/objects/Lensflare.js +47 -38
  148. package/examples/js/objects/LightningStorm.js +10 -13
  149. package/examples/js/objects/MarchingCubes.js +80 -59
  150. package/examples/js/objects/Reflector.js +22 -20
  151. package/examples/js/objects/ReflectorForSSRPass.js +19 -23
  152. package/examples/js/objects/Refractor.js +52 -30
  153. package/examples/js/objects/ShadowMesh.js +1 -2
  154. package/examples/js/objects/Sky.js +2 -7
  155. package/examples/js/objects/Water.js +23 -18
  156. package/examples/js/objects/Water2.js +20 -19
  157. package/examples/js/physics/AmmoPhysics.js +23 -20
  158. package/examples/js/physics/OimoPhysics.js +19 -17
  159. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
  160. package/examples/js/postprocessing/AfterimagePass.js +19 -12
  161. package/examples/js/postprocessing/BloomPass.js +38 -17
  162. package/examples/js/postprocessing/BokehPass.js +29 -12
  163. package/examples/js/postprocessing/ClearPass.js +1 -6
  164. package/examples/js/postprocessing/CubeTexturePass.js +12 -9
  165. package/examples/js/postprocessing/DotScreenPass.js +7 -5
  166. package/examples/js/postprocessing/EffectComposer.js +25 -32
  167. package/examples/js/postprocessing/FilmPass.js +7 -5
  168. package/examples/js/postprocessing/GlitchPass.js +10 -11
  169. package/examples/js/postprocessing/HalftonePass.js +9 -9
  170. package/examples/js/postprocessing/LUTPass.js +2 -15
  171. package/examples/js/postprocessing/MaskPass.js +20 -17
  172. package/examples/js/postprocessing/OutlinePass.js +45 -36
  173. package/examples/js/postprocessing/Pass.js +11 -14
  174. package/examples/js/postprocessing/RenderPass.js +3 -7
  175. package/examples/js/postprocessing/RenderPixelatedPass.js +215 -0
  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 -8
  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 +236 -170
  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 +27 -3
  254. package/examples/jsm/animation/MMDPhysics.js +25 -0
  255. package/examples/jsm/capabilities/WebGPU.js +3 -1
  256. package/examples/jsm/controls/FirstPersonControls.js +20 -20
  257. package/examples/jsm/controls/FlyControls.js +16 -17
  258. package/examples/jsm/controls/OrbitControls.js +44 -4
  259. package/examples/jsm/controls/TrackballControls.js +14 -2
  260. package/examples/jsm/controls/TransformControls.js +1 -1
  261. package/examples/jsm/csm/CSM.js +1 -0
  262. package/examples/jsm/csm/CSMHelper.js +30 -0
  263. package/examples/jsm/exporters/GLTFExporter.js +0 -79
  264. package/examples/jsm/exporters/USDZExporter.js +93 -1
  265. package/examples/jsm/helpers/OctreeHelper.js +22 -8
  266. package/examples/jsm/helpers/VertexNormalsHelper.js +7 -1
  267. package/examples/jsm/helpers/VertexTangentsHelper.js +7 -0
  268. package/examples/jsm/helpers/ViewHelper.js +24 -0
  269. package/examples/jsm/interactive/HTMLMesh.js +5 -6
  270. package/examples/jsm/interactive/InteractiveGroup.js +4 -2
  271. package/examples/jsm/libs/flow.module.js +610 -160
  272. package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
  273. package/examples/jsm/lines/LineSegments2.js +4 -0
  274. package/examples/jsm/loaders/3DMLoader.js +1 -2
  275. package/examples/jsm/loaders/ColladaLoader.js +28 -0
  276. package/examples/jsm/loaders/FBXLoader.js +18 -2
  277. package/examples/jsm/loaders/GLTFLoader.js +269 -428
  278. package/examples/jsm/loaders/KTX2Loader.js +68 -29
  279. package/examples/jsm/loaders/LDrawLoader.js +14 -13
  280. package/examples/jsm/loaders/LottieLoader.js +4 -2
  281. package/examples/jsm/loaders/MaterialXLoader.js +728 -0
  282. package/examples/jsm/loaders/PCDLoader.js +1 -1
  283. package/examples/jsm/loaders/PLYLoader.js +68 -16
  284. package/examples/jsm/loaders/SVGLoader.js +227 -14
  285. package/examples/jsm/loaders/USDZLoader.js +351 -111
  286. package/examples/jsm/loaders/VRMLLoader.js +13 -1
  287. package/examples/jsm/math/ConvexHull.js +4 -4
  288. package/examples/jsm/math/Octree.js +1 -1
  289. package/examples/jsm/node-editor/NodeEditor.js +91 -12
  290. package/examples/jsm/node-editor/core/BaseNode.js +10 -3
  291. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +6 -9
  292. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +6 -9
  293. package/examples/jsm/node-editor/math/AngleEditor.js +3 -3
  294. package/examples/jsm/node-editor/math/InvertEditor.js +2 -2
  295. package/examples/jsm/node-editor/scene/MeshEditor.js +11 -8
  296. package/examples/jsm/node-editor/utils/PreviewEditor.js +4 -0
  297. package/examples/jsm/nodes/Nodes.js +30 -3
  298. package/examples/jsm/nodes/accessors/BitangentNode.js +62 -0
  299. package/examples/jsm/nodes/accessors/NormalNode.js +6 -6
  300. package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
  301. package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
  302. package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
  303. package/examples/jsm/nodes/accessors/SkinningNode.js +8 -1
  304. package/examples/jsm/nodes/accessors/TangentNode.js +95 -0
  305. package/examples/jsm/nodes/core/AttributeNode.js +31 -8
  306. package/examples/jsm/nodes/core/Node.js +1 -1
  307. package/examples/jsm/nodes/core/NodeBuilder.js +55 -6
  308. package/examples/jsm/nodes/core/NodeFrame.js +2 -2
  309. package/examples/jsm/nodes/core/NodeVarying.js +7 -4
  310. package/examples/jsm/nodes/core/VaryingNode.js +6 -4
  311. package/examples/jsm/nodes/core/constants.js +13 -13
  312. package/examples/jsm/nodes/display/BlendModeNode.js +85 -0
  313. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -12
  314. package/examples/jsm/nodes/display/NormalMapNode.js +19 -12
  315. package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
  316. package/examples/jsm/nodes/display/ViewportNode.js +106 -0
  317. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +5 -5
  318. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +3 -3
  319. package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +2 -2
  320. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  321. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  322. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
  323. package/examples/jsm/nodes/materials/Materials.js +9 -7
  324. package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
  325. package/examples/jsm/nodes/materialx/{Disclaimer.md → DISCLAIMER.md} +1 -1
  326. package/examples/jsm/nodes/materialx/MaterialXNodes.js +59 -0
  327. package/examples/jsm/nodes/materialx/{functions/lib → lib}/mx_hsv.js +1 -1
  328. package/examples/jsm/nodes/materialx/{functions/lib → lib}/mx_noise.js +13 -3
  329. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
  330. package/examples/jsm/nodes/math/MathNode.js +5 -5
  331. package/examples/jsm/nodes/math/OperatorNode.js +16 -3
  332. package/examples/jsm/nodes/shadernode/ShaderNode.js +35 -20
  333. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +87 -63
  334. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +29 -0
  335. package/examples/jsm/nodes/utils/ConvertNode.js +15 -14
  336. package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
  337. package/examples/jsm/nodes/utils/JoinNode.js +8 -2
  338. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
  339. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  340. package/examples/jsm/nodes/utils/OscNode.js +2 -2
  341. package/examples/jsm/nodes/utils/RemapNode.js +34 -0
  342. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
  343. package/examples/jsm/nodes/utils/TimerNode.js +21 -1
  344. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
  345. package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
  346. package/examples/jsm/postprocessing/BloomPass.js +22 -3
  347. package/examples/jsm/postprocessing/BokehPass.js +18 -4
  348. package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
  349. package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
  350. package/examples/jsm/postprocessing/EffectComposer.js +9 -0
  351. package/examples/jsm/postprocessing/FilmPass.js +8 -0
  352. package/examples/jsm/postprocessing/GlitchPass.js +13 -1
  353. package/examples/jsm/postprocessing/HalftonePass.js +8 -0
  354. package/examples/jsm/postprocessing/OutlinePass.js +21 -1
  355. package/examples/jsm/postprocessing/Pass.js +2 -0
  356. package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
  357. package/examples/jsm/postprocessing/SAOPass.js +20 -0
  358. package/examples/jsm/postprocessing/SMAAPass.js +16 -0
  359. package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
  360. package/examples/jsm/postprocessing/SavePass.js +17 -1
  361. package/examples/jsm/postprocessing/ShaderPass.js +8 -0
  362. package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
  363. package/examples/jsm/postprocessing/TexturePass.js +8 -0
  364. package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
  365. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +56 -35
  366. package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
  367. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
  368. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
  369. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
  370. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +41 -9
  371. package/examples/jsm/shaders/MMDToonShader.js +0 -2
  372. package/examples/jsm/shaders/VelocityShader.js +128 -0
  373. package/examples/jsm/utils/BufferGeometryUtils.js +174 -42
  374. package/examples/jsm/utils/SceneUtils.js +129 -4
  375. package/examples/jsm/webxr/OculusHandModel.js +3 -2
  376. package/examples/jsm/webxr/XRHandMeshModel.js +8 -3
  377. package/package.json +13 -13
  378. package/src/Three.js +1 -0
  379. package/src/animation/PropertyBinding.js +7 -0
  380. package/src/audio/AudioContext.js +5 -5
  381. package/src/cameras/CubeCamera.js +14 -14
  382. package/src/constants.js +1 -1
  383. package/src/core/InstancedBufferGeometry.js +1 -7
  384. package/src/core/InterleavedBufferAttribute.js +4 -4
  385. package/src/extras/Earcut.js +67 -67
  386. package/src/geometries/PolyhedronGeometry.js +1 -1
  387. package/src/geometries/ShapeGeometry.js +1 -1
  388. package/src/helpers/ArrowHelper.js +9 -0
  389. package/src/helpers/Box3Helper.js +7 -0
  390. package/src/helpers/BoxHelper.js +7 -1
  391. package/src/helpers/DirectionalLightHelper.js +5 -1
  392. package/src/helpers/GridHelper.js +7 -0
  393. package/src/helpers/HemisphereLightHelper.js +4 -1
  394. package/src/helpers/PlaneHelper.js +9 -0
  395. package/src/helpers/PointLightHelper.js +2 -1
  396. package/src/helpers/PolarGridHelper.js +7 -0
  397. package/src/helpers/SkeletonHelper.js +7 -0
  398. package/src/helpers/SpotLightHelper.js +4 -2
  399. package/src/lights/LightShadow.js +1 -2
  400. package/src/lights/PointLight.js +2 -2
  401. package/src/lights/SpotLight.js +2 -2
  402. package/src/loaders/FileLoader.js +4 -1
  403. package/src/loaders/ObjectLoader.js +5 -1
  404. package/src/materials/Material.js +1 -1
  405. package/src/materials/MeshPhysicalMaterial.js +1 -1
  406. package/src/math/Color.js +5 -5
  407. package/src/math/Matrix3.js +53 -18
  408. package/src/math/Ray.js +2 -5
  409. package/src/math/Sphere.js +36 -21
  410. package/src/objects/InstancedMesh.js +7 -0
  411. package/src/objects/LOD.js +25 -6
  412. package/src/renderers/WebGL3DRenderTarget.js +1 -1
  413. package/src/renderers/WebGLArrayRenderTarget.js +1 -1
  414. package/src/renderers/WebGLCubeRenderTarget.js +1 -1
  415. package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
  416. package/src/renderers/WebGLRenderTarget.js +1 -1
  417. package/src/renderers/WebGLRenderer.js +36 -62
  418. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
  419. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
  420. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
  421. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
  422. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
  423. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -4
  424. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
  425. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +2 -2
  426. package/src/renderers/shaders/ShaderChunk.js +3 -0
  427. package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
  428. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
  429. package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
  430. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +0 -3
  431. package/src/renderers/shaders/ShaderLib.js +20 -6
  432. package/src/renderers/shaders/UniformsLib.js +1 -1
  433. package/src/renderers/shaders/UniformsUtils.js +15 -0
  434. package/src/renderers/webgl/WebGLAttributes.js +2 -0
  435. package/src/renderers/webgl/WebGLBackground.js +15 -7
  436. package/src/renderers/webgl/WebGLLights.js +0 -4
  437. package/src/renderers/webgl/WebGLMaterials.js +2 -1
  438. package/src/renderers/webgl/WebGLShadowMap.js +3 -1
  439. package/src/renderers/webgl/WebGLState.js +78 -41
  440. package/src/renderers/webgl/WebGLTextures.js +94 -39
  441. package/src/renderers/webgl/WebGLUniforms.js +152 -24
  442. package/src/renderers/webgl/WebGLUtils.js +1 -1
  443. package/src/renderers/webxr/WebXRController.js +46 -13
  444. package/src/renderers/webxr/WebXRManager.js +70 -2
  445. package/src/scenes/Scene.js +8 -0
  446. package/src/textures/CompressedArrayTexture.js +18 -0
  447. package/src/textures/Texture.js +2 -1
  448. package/examples/js/libs/lottie_canvas.js +0 -12751
  449. package/examples/js/shaders/PixelShader.js +0 -51
  450. package/examples/jsm/shaders/PixelShader.js +0 -44
@@ -12,6 +12,7 @@ import {
12
12
  FrontSide,
13
13
  Group,
14
14
  ImageBitmapLoader,
15
+ InstancedMesh,
15
16
  InterleavedBuffer,
16
17
  InterleavedBufferAttribute,
17
18
  Interpolant,
@@ -52,7 +53,6 @@ import {
52
53
  SkinnedMesh,
53
54
  Sphere,
54
55
  SpotLight,
55
- TangentSpaceNormalMap,
56
56
  Texture,
57
57
  TextureLoader,
58
58
  TriangleFanDrawMode,
@@ -147,6 +147,12 @@ class GLTFLoader extends Loader {
147
147
 
148
148
  } );
149
149
 
150
+ this.register( function ( parser ) {
151
+
152
+ return new GLTFMeshGpuInstancing( parser );
153
+
154
+ } );
155
+
150
156
  }
151
157
 
152
158
  load( url, onLoad, onProgress, onError ) {
@@ -277,15 +283,15 @@ class GLTFLoader extends Loader {
277
283
 
278
284
  parse( data, path, onLoad, onError ) {
279
285
 
280
- let content;
286
+ let json;
281
287
  const extensions = {};
282
288
  const plugins = {};
283
289
 
284
290
  if ( typeof data === 'string' ) {
285
291
 
286
- content = data;
292
+ json = JSON.parse( data );
287
293
 
288
- } else {
294
+ } else if ( data instanceof ArrayBuffer ) {
289
295
 
290
296
  const magic = LoaderUtils.decodeText( new Uint8Array( data, 0, 4 ) );
291
297
 
@@ -302,17 +308,19 @@ class GLTFLoader extends Loader {
302
308
 
303
309
  }
304
310
 
305
- content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content;
311
+ json = JSON.parse( extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content );
306
312
 
307
313
  } else {
308
314
 
309
- content = LoaderUtils.decodeText( new Uint8Array( data ) );
315
+ json = JSON.parse( LoaderUtils.decodeText( new Uint8Array( data ) ) );
310
316
 
311
317
  }
312
318
 
313
- }
319
+ } else {
314
320
 
315
- const json = JSON.parse( content );
321
+ json = data;
322
+
323
+ }
316
324
 
317
325
  if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) {
318
326
 
@@ -360,10 +368,6 @@ class GLTFLoader extends Loader {
360
368
  extensions[ extensionName ] = new GLTFMaterialsUnlitExtension();
361
369
  break;
362
370
 
363
- case EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:
364
- extensions[ extensionName ] = new GLTFMaterialsPbrSpecularGlossinessExtension();
365
- break;
366
-
367
371
  case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:
368
372
  extensions[ extensionName ] = new GLTFDracoMeshCompressionExtension( json, this.dracoLoader );
369
373
  break;
@@ -456,7 +460,6 @@ const EXTENSIONS = {
456
460
  KHR_LIGHTS_PUNCTUAL: 'KHR_lights_punctual',
457
461
  KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
458
462
  KHR_MATERIALS_IOR: 'KHR_materials_ior',
459
- KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',
460
463
  KHR_MATERIALS_SHEEN: 'KHR_materials_sheen',
461
464
  KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
462
465
  KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
@@ -468,7 +471,8 @@ const EXTENSIONS = {
468
471
  KHR_MESH_QUANTIZATION: 'KHR_mesh_quantization',
469
472
  KHR_MATERIALS_EMISSIVE_STRENGTH: 'KHR_materials_emissive_strength',
470
473
  EXT_TEXTURE_WEBP: 'EXT_texture_webp',
471
- EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression'
474
+ EXT_MESHOPT_COMPRESSION: 'EXT_meshopt_compression',
475
+ EXT_MESH_GPU_INSTANCING: 'EXT_mesh_gpu_instancing'
472
476
  };
473
477
 
474
478
  /**
@@ -566,6 +570,8 @@ class GLTFLightsExtension {
566
570
 
567
571
  lightNode.decay = 2;
568
572
 
573
+ assignExtrasToUserData( lightNode, lightDef );
574
+
569
575
  if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity;
570
576
 
571
577
  lightNode.name = parser.createUniqueName( lightDef.name || ( 'light_' + lightIndex ) );
@@ -578,6 +584,14 @@ class GLTFLightsExtension {
578
584
 
579
585
  }
580
586
 
587
+ getDependency( type, index ) {
588
+
589
+ if ( type !== 'light' ) return;
590
+
591
+ return this._loadLight( index );
592
+
593
+ }
594
+
581
595
  createNodeAttachment( nodeIndex ) {
582
596
 
583
597
  const self = this;
@@ -1044,7 +1058,7 @@ class GLTFMaterialsVolumeExtension {
1044
1058
 
1045
1059
  }
1046
1060
 
1047
- materialParams.attenuationDistance = extension.attenuationDistance || 0;
1061
+ materialParams.attenuationDistance = extension.attenuationDistance || Infinity;
1048
1062
 
1049
1063
  const colorArray = extension.attenuationColor || [ 1, 1, 1 ];
1050
1064
  materialParams.attenuationColor = new Color( colorArray[ 0 ], colorArray[ 1 ], colorArray[ 2 ] );
@@ -1384,6 +1398,160 @@ class GLTFMeshoptCompression {
1384
1398
 
1385
1399
  }
1386
1400
 
1401
+ /**
1402
+ * GPU Instancing Extension
1403
+ *
1404
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_mesh_gpu_instancing
1405
+ *
1406
+ */
1407
+ class GLTFMeshGpuInstancing {
1408
+
1409
+ constructor( parser ) {
1410
+
1411
+ this.name = EXTENSIONS.EXT_MESH_GPU_INSTANCING;
1412
+ this.parser = parser;
1413
+
1414
+ }
1415
+
1416
+ createNodeMesh( nodeIndex ) {
1417
+
1418
+ const json = this.parser.json;
1419
+ const nodeDef = json.nodes[ nodeIndex ];
1420
+
1421
+ if ( ! nodeDef.extensions || ! nodeDef.extensions[ this.name ] ||
1422
+ nodeDef.mesh === undefined ) {
1423
+
1424
+ return null;
1425
+
1426
+ }
1427
+
1428
+ const meshDef = json.meshes[ nodeDef.mesh ];
1429
+
1430
+ // No Points or Lines + Instancing support yet
1431
+
1432
+ for ( const primitive of meshDef.primitives ) {
1433
+
1434
+ if ( primitive.mode !== WEBGL_CONSTANTS.TRIANGLES &&
1435
+ primitive.mode !== WEBGL_CONSTANTS.TRIANGLE_STRIP &&
1436
+ primitive.mode !== WEBGL_CONSTANTS.TRIANGLE_FAN &&
1437
+ primitive.mode !== undefined ) {
1438
+
1439
+ return null;
1440
+
1441
+ }
1442
+
1443
+ }
1444
+
1445
+ const extensionDef = nodeDef.extensions[ this.name ];
1446
+ const attributesDef = extensionDef.attributes;
1447
+
1448
+ // @TODO: Can we support InstancedMesh + SkinnedMesh?
1449
+
1450
+ const pending = [];
1451
+ const attributes = {};
1452
+
1453
+ for ( const key in attributesDef ) {
1454
+
1455
+ pending.push( this.parser.getDependency( 'accessor', attributesDef[ key ] ).then( accessor => {
1456
+
1457
+ attributes[ key ] = accessor;
1458
+ return attributes[ key ];
1459
+
1460
+ } ) );
1461
+
1462
+ }
1463
+
1464
+ if ( pending.length < 1 ) {
1465
+
1466
+ return null;
1467
+
1468
+ }
1469
+
1470
+ pending.push( this.parser.createNodeMesh( nodeIndex ) );
1471
+
1472
+ return Promise.all( pending ).then( results => {
1473
+
1474
+ const nodeObject = results.pop();
1475
+ const meshes = nodeObject.isGroup ? nodeObject.children : [ nodeObject ];
1476
+ const count = results[ 0 ].count; // All attribute counts should be same
1477
+ const instancedMeshes = [];
1478
+
1479
+ for ( const mesh of meshes ) {
1480
+
1481
+ // Temporal variables
1482
+ const m = new Matrix4();
1483
+ const p = new Vector3();
1484
+ const q = new Quaternion();
1485
+ const s = new Vector3( 1, 1, 1 );
1486
+
1487
+ const instancedMesh = new InstancedMesh( mesh.geometry, mesh.material, count );
1488
+
1489
+ for ( let i = 0; i < count; i ++ ) {
1490
+
1491
+ if ( attributes.TRANSLATION ) {
1492
+
1493
+ p.fromBufferAttribute( attributes.TRANSLATION, i );
1494
+
1495
+ }
1496
+
1497
+ if ( attributes.ROTATION ) {
1498
+
1499
+ q.fromBufferAttribute( attributes.ROTATION, i );
1500
+
1501
+ }
1502
+
1503
+ if ( attributes.SCALE ) {
1504
+
1505
+ s.fromBufferAttribute( attributes.SCALE, i );
1506
+
1507
+ }
1508
+
1509
+ instancedMesh.setMatrixAt( i, m.compose( p, q, s ) );
1510
+
1511
+ }
1512
+
1513
+ // Add instance attributes to the geometry, excluding TRS.
1514
+ for ( const attributeName in attributes ) {
1515
+
1516
+ if ( attributeName !== 'TRANSLATION' &&
1517
+ attributeName !== 'ROTATION' &&
1518
+ attributeName !== 'SCALE' ) {
1519
+
1520
+ mesh.geometry.setAttribute( attributeName, attributes[ attributeName ] );
1521
+
1522
+ }
1523
+
1524
+ }
1525
+
1526
+ // Just in case
1527
+ Object3D.prototype.copy.call( instancedMesh, mesh );
1528
+
1529
+ // https://github.com/mrdoob/three.js/issues/18334
1530
+ instancedMesh.frustumCulled = false;
1531
+ this.parser.assignFinalMaterial( instancedMesh );
1532
+
1533
+ instancedMeshes.push( instancedMesh );
1534
+
1535
+ }
1536
+
1537
+ if ( nodeObject.isGroup ) {
1538
+
1539
+ nodeObject.clear();
1540
+
1541
+ nodeObject.add( ... instancedMeshes );
1542
+
1543
+ return nodeObject;
1544
+
1545
+ }
1546
+
1547
+ return instancedMeshes[ 0 ];
1548
+
1549
+ } );
1550
+
1551
+ }
1552
+
1553
+ }
1554
+
1387
1555
  /* BINARY EXTENSION */
1388
1556
  const BINARY_EXTENSION_HEADER_MAGIC = 'glTF';
1389
1557
  const BINARY_EXTENSION_HEADER_LENGTH = 12;
@@ -1594,335 +1762,6 @@ class GLTFTextureTransformExtension {
1594
1762
 
1595
1763
  }
1596
1764
 
1597
- /**
1598
- * Specular-Glossiness Extension
1599
- *
1600
- * Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness
1601
- */
1602
-
1603
- /**
1604
- * A sub class of StandardMaterial with some of the functionality
1605
- * changed via the `onBeforeCompile` callback
1606
- * @pailhead
1607
- */
1608
- class GLTFMeshStandardSGMaterial extends MeshStandardMaterial {
1609
-
1610
- constructor( params ) {
1611
-
1612
- super();
1613
-
1614
- this.isGLTFSpecularGlossinessMaterial = true;
1615
-
1616
- //various chunks that need replacing
1617
- const specularMapParsFragmentChunk = [
1618
- '#ifdef USE_SPECULARMAP',
1619
- ' uniform sampler2D specularMap;',
1620
- '#endif'
1621
- ].join( '\n' );
1622
-
1623
- const glossinessMapParsFragmentChunk = [
1624
- '#ifdef USE_GLOSSINESSMAP',
1625
- ' uniform sampler2D glossinessMap;',
1626
- '#endif'
1627
- ].join( '\n' );
1628
-
1629
- const specularMapFragmentChunk = [
1630
- 'vec3 specularFactor = specular;',
1631
- '#ifdef USE_SPECULARMAP',
1632
- ' vec4 texelSpecular = texture2D( specularMap, vUv );',
1633
- ' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture',
1634
- ' specularFactor *= texelSpecular.rgb;',
1635
- '#endif'
1636
- ].join( '\n' );
1637
-
1638
- const glossinessMapFragmentChunk = [
1639
- 'float glossinessFactor = glossiness;',
1640
- '#ifdef USE_GLOSSINESSMAP',
1641
- ' vec4 texelGlossiness = texture2D( glossinessMap, vUv );',
1642
- ' // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture',
1643
- ' glossinessFactor *= texelGlossiness.a;',
1644
- '#endif'
1645
- ].join( '\n' );
1646
-
1647
- const lightPhysicalFragmentChunk = [
1648
- 'PhysicalMaterial material;',
1649
- 'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );',
1650
- 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );',
1651
- 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );',
1652
- 'material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.',
1653
- 'material.roughness += geometryRoughness;',
1654
- 'material.roughness = min( material.roughness, 1.0 );',
1655
- 'material.specularColor = specularFactor;',
1656
- ].join( '\n' );
1657
-
1658
- const uniforms = {
1659
- specular: { value: new Color().setHex( 0xffffff ) },
1660
- glossiness: { value: 1 },
1661
- specularMap: { value: null },
1662
- glossinessMap: { value: null }
1663
- };
1664
-
1665
- this._extraUniforms = uniforms;
1666
-
1667
- this.onBeforeCompile = function ( shader ) {
1668
-
1669
- for ( const uniformName in uniforms ) {
1670
-
1671
- shader.uniforms[ uniformName ] = uniforms[ uniformName ];
1672
-
1673
- }
1674
-
1675
- shader.fragmentShader = shader.fragmentShader
1676
- .replace( 'uniform float roughness;', 'uniform vec3 specular;' )
1677
- .replace( 'uniform float metalness;', 'uniform float glossiness;' )
1678
- .replace( '#include <roughnessmap_pars_fragment>', specularMapParsFragmentChunk )
1679
- .replace( '#include <metalnessmap_pars_fragment>', glossinessMapParsFragmentChunk )
1680
- .replace( '#include <roughnessmap_fragment>', specularMapFragmentChunk )
1681
- .replace( '#include <metalnessmap_fragment>', glossinessMapFragmentChunk )
1682
- .replace( '#include <lights_physical_fragment>', lightPhysicalFragmentChunk );
1683
-
1684
- };
1685
-
1686
- Object.defineProperties( this, {
1687
-
1688
- specular: {
1689
- get: function () {
1690
-
1691
- return uniforms.specular.value;
1692
-
1693
- },
1694
- set: function ( v ) {
1695
-
1696
- uniforms.specular.value = v;
1697
-
1698
- }
1699
- },
1700
-
1701
- specularMap: {
1702
- get: function () {
1703
-
1704
- return uniforms.specularMap.value;
1705
-
1706
- },
1707
- set: function ( v ) {
1708
-
1709
- uniforms.specularMap.value = v;
1710
-
1711
- if ( v ) {
1712
-
1713
- this.defines.USE_SPECULARMAP = ''; // USE_UV is set by the renderer for specular maps
1714
-
1715
- } else {
1716
-
1717
- delete this.defines.USE_SPECULARMAP;
1718
-
1719
- }
1720
-
1721
- }
1722
- },
1723
-
1724
- glossiness: {
1725
- get: function () {
1726
-
1727
- return uniforms.glossiness.value;
1728
-
1729
- },
1730
- set: function ( v ) {
1731
-
1732
- uniforms.glossiness.value = v;
1733
-
1734
- }
1735
- },
1736
-
1737
- glossinessMap: {
1738
- get: function () {
1739
-
1740
- return uniforms.glossinessMap.value;
1741
-
1742
- },
1743
- set: function ( v ) {
1744
-
1745
- uniforms.glossinessMap.value = v;
1746
-
1747
- if ( v ) {
1748
-
1749
- this.defines.USE_GLOSSINESSMAP = '';
1750
- this.defines.USE_UV = '';
1751
-
1752
- } else {
1753
-
1754
- delete this.defines.USE_GLOSSINESSMAP;
1755
- delete this.defines.USE_UV;
1756
-
1757
- }
1758
-
1759
- }
1760
- }
1761
-
1762
- } );
1763
-
1764
- delete this.metalness;
1765
- delete this.roughness;
1766
- delete this.metalnessMap;
1767
- delete this.roughnessMap;
1768
-
1769
- this.setValues( params );
1770
-
1771
- }
1772
-
1773
- copy( source ) {
1774
-
1775
- super.copy( source );
1776
-
1777
- this.specularMap = source.specularMap;
1778
- this.specular.copy( source.specular );
1779
- this.glossinessMap = source.glossinessMap;
1780
- this.glossiness = source.glossiness;
1781
- delete this.metalness;
1782
- delete this.roughness;
1783
- delete this.metalnessMap;
1784
- delete this.roughnessMap;
1785
- return this;
1786
-
1787
- }
1788
-
1789
- }
1790
-
1791
-
1792
- class GLTFMaterialsPbrSpecularGlossinessExtension {
1793
-
1794
- constructor() {
1795
-
1796
- this.name = EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS;
1797
-
1798
- this.specularGlossinessParams = [
1799
- 'color',
1800
- 'map',
1801
- 'lightMap',
1802
- 'lightMapIntensity',
1803
- 'aoMap',
1804
- 'aoMapIntensity',
1805
- 'emissive',
1806
- 'emissiveIntensity',
1807
- 'emissiveMap',
1808
- 'bumpMap',
1809
- 'bumpScale',
1810
- 'normalMap',
1811
- 'normalMapType',
1812
- 'displacementMap',
1813
- 'displacementScale',
1814
- 'displacementBias',
1815
- 'specularMap',
1816
- 'specular',
1817
- 'glossinessMap',
1818
- 'glossiness',
1819
- 'alphaMap',
1820
- 'envMap',
1821
- 'envMapIntensity'
1822
- ];
1823
-
1824
- }
1825
-
1826
- getMaterialType() {
1827
-
1828
- return GLTFMeshStandardSGMaterial;
1829
-
1830
- }
1831
-
1832
- extendParams( materialParams, materialDef, parser ) {
1833
-
1834
- const pbrSpecularGlossiness = materialDef.extensions[ this.name ];
1835
-
1836
- materialParams.color = new Color( 1.0, 1.0, 1.0 );
1837
- materialParams.opacity = 1.0;
1838
-
1839
- const pending = [];
1840
-
1841
- if ( Array.isArray( pbrSpecularGlossiness.diffuseFactor ) ) {
1842
-
1843
- const array = pbrSpecularGlossiness.diffuseFactor;
1844
-
1845
- materialParams.color.fromArray( array );
1846
- materialParams.opacity = array[ 3 ];
1847
-
1848
- }
1849
-
1850
- if ( pbrSpecularGlossiness.diffuseTexture !== undefined ) {
1851
-
1852
- pending.push( parser.assignTexture( materialParams, 'map', pbrSpecularGlossiness.diffuseTexture, sRGBEncoding ) );
1853
-
1854
- }
1855
-
1856
- materialParams.emissive = new Color( 0.0, 0.0, 0.0 );
1857
- materialParams.glossiness = pbrSpecularGlossiness.glossinessFactor !== undefined ? pbrSpecularGlossiness.glossinessFactor : 1.0;
1858
- materialParams.specular = new Color( 1.0, 1.0, 1.0 );
1859
-
1860
- if ( Array.isArray( pbrSpecularGlossiness.specularFactor ) ) {
1861
-
1862
- materialParams.specular.fromArray( pbrSpecularGlossiness.specularFactor );
1863
-
1864
- }
1865
-
1866
- if ( pbrSpecularGlossiness.specularGlossinessTexture !== undefined ) {
1867
-
1868
- const specGlossMapDef = pbrSpecularGlossiness.specularGlossinessTexture;
1869
- pending.push( parser.assignTexture( materialParams, 'glossinessMap', specGlossMapDef ) );
1870
- pending.push( parser.assignTexture( materialParams, 'specularMap', specGlossMapDef, sRGBEncoding ) );
1871
-
1872
- }
1873
-
1874
- return Promise.all( pending );
1875
-
1876
- }
1877
-
1878
- createMaterial( materialParams ) {
1879
-
1880
- const material = new GLTFMeshStandardSGMaterial( materialParams );
1881
- material.fog = true;
1882
-
1883
- material.color = materialParams.color;
1884
-
1885
- material.map = materialParams.map === undefined ? null : materialParams.map;
1886
-
1887
- material.lightMap = null;
1888
- material.lightMapIntensity = 1.0;
1889
-
1890
- material.aoMap = materialParams.aoMap === undefined ? null : materialParams.aoMap;
1891
- material.aoMapIntensity = 1.0;
1892
-
1893
- material.emissive = materialParams.emissive;
1894
- material.emissiveIntensity = materialParams.emissiveIntensity === undefined ? 1.0 : materialParams.emissiveIntensity;
1895
- material.emissiveMap = materialParams.emissiveMap === undefined ? null : materialParams.emissiveMap;
1896
-
1897
- material.bumpMap = materialParams.bumpMap === undefined ? null : materialParams.bumpMap;
1898
- material.bumpScale = 1;
1899
-
1900
- material.normalMap = materialParams.normalMap === undefined ? null : materialParams.normalMap;
1901
- material.normalMapType = TangentSpaceNormalMap;
1902
-
1903
- if ( materialParams.normalScale ) material.normalScale = materialParams.normalScale;
1904
-
1905
- material.displacementMap = null;
1906
- material.displacementScale = 1;
1907
- material.displacementBias = 0;
1908
-
1909
- material.specularMap = materialParams.specularMap === undefined ? null : materialParams.specularMap;
1910
- material.specular = materialParams.specular;
1911
-
1912
- material.glossinessMap = materialParams.glossinessMap === undefined ? null : materialParams.glossinessMap;
1913
- material.glossiness = materialParams.glossiness;
1914
-
1915
- material.alphaMap = null;
1916
-
1917
- material.envMap = materialParams.envMap === undefined ? null : materialParams.envMap;
1918
- material.envMapIntensity = 1.0;
1919
-
1920
- return material;
1921
-
1922
- }
1923
-
1924
- }
1925
-
1926
1765
  /**
1927
1766
  * Mesh Quantization Extension
1928
1767
  *
@@ -2423,10 +2262,18 @@ class GLTFParser {
2423
2262
 
2424
2263
  // Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
2425
2264
  // expensive work of uploading a texture to the GPU off the main thread.
2265
+
2266
+ let isSafari = false;
2267
+ let isFirefox = false;
2268
+ let firefoxVersion = - 1;
2426
2269
 
2427
- const isSafari = /^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === true;
2428
- const isFirefox = navigator.userAgent.indexOf( 'Firefox' ) > - 1;
2429
- const firefoxVersion = isFirefox ? navigator.userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
2270
+ if ( typeof navigator !== 'undefined' ) {
2271
+
2272
+ isSafari = /^((?!chrome|android).)*safari/i.test( navigator.userAgent ) === true;
2273
+ isFirefox = navigator.userAgent.indexOf( 'Firefox' ) > - 1;
2274
+ firefoxVersion = isFirefox ? navigator.userAgent.match( /Firefox\/([0-9]+)\./ )[ 1 ] : - 1;
2275
+
2276
+ }
2430
2277
 
2431
2278
  if ( typeof createImageBitmap === 'undefined' || isSafari || ( isFirefox && firefoxVersion < 98 ) ) {
2432
2279
 
@@ -2751,7 +2598,19 @@ class GLTFParser {
2751
2598
  break;
2752
2599
 
2753
2600
  default:
2754
- throw new Error( 'Unknown type: ' + type );
2601
+ dependency = this._invokeOne( function ( ext ) {
2602
+
2603
+ return ext != this && ext.getDependency && ext.getDependency( type, index );
2604
+
2605
+ } );
2606
+
2607
+ if ( ! dependency ) {
2608
+
2609
+ throw new Error( 'Unknown type: ' + type );
2610
+
2611
+ }
2612
+
2613
+ break;
2755
2614
 
2756
2615
  }
2757
2616
 
@@ -2861,10 +2720,12 @@ class GLTFParser {
2861
2720
 
2862
2721
  if ( accessorDef.bufferView === undefined && accessorDef.sparse === undefined ) {
2863
2722
 
2864
- // Ignore empty accessors, which may be used to declare runtime
2865
- // information about attributes coming from another source (e.g. Draco
2866
- // compression extension).
2867
- return Promise.resolve( null );
2723
+ const itemSize = WEBGL_TYPE_SIZES[ accessorDef.type ];
2724
+ const TypedArray = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
2725
+ const normalized = accessorDef.normalized === true;
2726
+
2727
+ const array = new TypedArray( accessorDef.count * itemSize );
2728
+ return Promise.resolve( new BufferAttribute( array, itemSize, normalized ) );
2868
2729
 
2869
2730
  }
2870
2731
 
@@ -2982,7 +2843,7 @@ class GLTFParser {
2982
2843
  /**
2983
2844
  * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
2984
2845
  * @param {number} textureIndex
2985
- * @return {Promise<THREE.Texture>}
2846
+ * @return {Promise<THREE.Texture|null>}
2986
2847
  */
2987
2848
  loadTexture( textureIndex ) {
2988
2849
 
@@ -3026,7 +2887,7 @@ class GLTFParser {
3026
2887
 
3027
2888
  texture.flipY = false;
3028
2889
 
3029
- if ( textureDef.name ) texture.name = textureDef.name;
2890
+ texture.name = textureDef.name || sourceDef.name || '';
3030
2891
 
3031
2892
  const samplers = json.samplers || {};
3032
2893
  const sampler = samplers[ textureDef.sampler ] || {};
@@ -3152,6 +3013,8 @@ class GLTFParser {
3152
3013
 
3153
3014
  return this.getDependency( 'texture', mapDef.index ).then( function ( texture ) {
3154
3015
 
3016
+ if ( ! texture ) return null;
3017
+
3155
3018
  // Materials sample aoMap from UV set 1 and other maps from UV set 0 - this can't be configured
3156
3019
  // However, we will copy UV set 0 to UV set 1 on demand for aoMap
3157
3020
  if ( mapDef.texCoord !== undefined && mapDef.texCoord != 0 && ! ( mapName === 'aoMap' && mapDef.texCoord == 1 ) ) {
@@ -3250,7 +3113,6 @@ class GLTFParser {
3250
3113
 
3251
3114
  let cacheKey = 'ClonedMaterial:' + material.uuid + ':';
3252
3115
 
3253
- if ( material.isGLTFSpecularGlossinessMaterial ) cacheKey += 'specular-glossiness:';
3254
3116
  if ( useDerivativeTangents ) cacheKey += 'derivative-tangents:';
3255
3117
  if ( useVertexColors ) cacheKey += 'vertex-colors:';
3256
3118
  if ( useFlatShading ) cacheKey += 'flat-shading:';
@@ -3318,13 +3180,7 @@ class GLTFParser {
3318
3180
 
3319
3181
  const pending = [];
3320
3182
 
3321
- if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ] ) {
3322
-
3323
- const sgExtension = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ];
3324
- materialType = sgExtension.getMaterialType();
3325
- pending.push( sgExtension.extendParams( materialParams, materialDef, parser ) );
3326
-
3327
- } else if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) {
3183
+ if ( materialExtensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ] ) {
3328
3184
 
3329
3185
  const kmuExtension = extensions[ EXTENSIONS.KHR_MATERIALS_UNLIT ];
3330
3186
  materialType = kmuExtension.getMaterialType();
@@ -3448,17 +3304,7 @@ class GLTFParser {
3448
3304
 
3449
3305
  return Promise.all( pending ).then( function () {
3450
3306
 
3451
- let material;
3452
-
3453
- if ( materialType === GLTFMeshStandardSGMaterial ) {
3454
-
3455
- material = extensions[ EXTENSIONS.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS ].createMaterial( materialParams );
3456
-
3457
- } else {
3458
-
3459
- material = new materialType( materialParams );
3460
-
3461
- }
3307
+ const material = new materialType( materialParams );
3462
3308
 
3463
3309
  if ( materialDef.name ) material.name = materialDef.name;
3464
3310
 
@@ -3747,25 +3593,65 @@ class GLTFParser {
3747
3593
  /**
3748
3594
  * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
3749
3595
  * @param {number} skinIndex
3750
- * @return {Promise<Object>}
3596
+ * @return {Promise<Skeleton>}
3751
3597
  */
3752
3598
  loadSkin( skinIndex ) {
3753
3599
 
3754
3600
  const skinDef = this.json.skins[ skinIndex ];
3755
3601
 
3756
- const skinEntry = { joints: skinDef.joints };
3602
+ const pending = [];
3603
+
3604
+ for ( let i = 0, il = skinDef.joints.length; i < il; i ++ ) {
3605
+
3606
+ pending.push( this.getDependency( 'node', skinDef.joints[ i ] ) );
3757
3607
 
3758
- if ( skinDef.inverseBindMatrices === undefined ) {
3608
+ }
3609
+
3610
+ if ( skinDef.inverseBindMatrices !== undefined ) {
3611
+
3612
+ pending.push( this.getDependency( 'accessor', skinDef.inverseBindMatrices ) );
3613
+
3614
+ } else {
3759
3615
 
3760
- return Promise.resolve( skinEntry );
3616
+ pending.push( null );
3761
3617
 
3762
3618
  }
3763
3619
 
3764
- return this.getDependency( 'accessor', skinDef.inverseBindMatrices ).then( function ( accessor ) {
3620
+ return Promise.all( pending ).then( function ( results ) {
3621
+
3622
+ const inverseBindMatrices = results.pop();
3623
+ const jointNodes = results;
3624
+
3625
+ const bones = [];
3626
+ const boneInverses = [];
3627
+
3628
+ for ( let i = 0, il = jointNodes.length; i < il; i ++ ) {
3629
+
3630
+ const jointNode = jointNodes[ i ];
3765
3631
 
3766
- skinEntry.inverseBindMatrices = accessor;
3632
+ if ( jointNode ) {
3767
3633
 
3768
- return skinEntry;
3634
+ bones.push( jointNode );
3635
+
3636
+ const mat = new Matrix4();
3637
+
3638
+ if ( inverseBindMatrices !== null ) {
3639
+
3640
+ mat.fromArray( inverseBindMatrices.array, i * 16 );
3641
+
3642
+ }
3643
+
3644
+ boneInverses.push( mat );
3645
+
3646
+ } else {
3647
+
3648
+ console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinDef.joints[ i ] );
3649
+
3650
+ }
3651
+
3652
+ }
3653
+
3654
+ return new Skeleton( bones, boneInverses );
3769
3655
 
3770
3656
  } );
3771
3657
 
@@ -4202,58 +4088,13 @@ function buildNodeHierarchy( nodeId, parentObject, json, parser ) {
4202
4088
 
4203
4089
  // build skeleton here as well
4204
4090
 
4205
- let skinEntry;
4206
-
4207
- return parser.getDependency( 'skin', nodeDef.skin ).then( function ( skin ) {
4208
-
4209
- skinEntry = skin;
4210
-
4211
- const pendingJoints = [];
4212
-
4213
- for ( let i = 0, il = skinEntry.joints.length; i < il; i ++ ) {
4214
-
4215
- pendingJoints.push( parser.getDependency( 'node', skinEntry.joints[ i ] ) );
4216
-
4217
- }
4218
-
4219
- return Promise.all( pendingJoints );
4220
-
4221
- } ).then( function ( jointNodes ) {
4091
+ return parser.getDependency( 'skin', nodeDef.skin ).then( function ( skeleton ) {
4222
4092
 
4223
4093
  node.traverse( function ( mesh ) {
4224
4094
 
4225
- if ( ! mesh.isMesh ) return;
4226
-
4227
- const bones = [];
4228
- const boneInverses = [];
4229
-
4230
- for ( let j = 0, jl = jointNodes.length; j < jl; j ++ ) {
4231
-
4232
- const jointNode = jointNodes[ j ];
4233
-
4234
- if ( jointNode ) {
4235
-
4236
- bones.push( jointNode );
4237
-
4238
- const mat = new Matrix4();
4239
-
4240
- if ( skinEntry.inverseBindMatrices !== undefined ) {
4241
-
4242
- mat.fromArray( skinEntry.inverseBindMatrices.array, j * 16 );
4243
-
4244
- }
4245
-
4246
- boneInverses.push( mat );
4247
-
4248
- } else {
4249
-
4250
- console.warn( 'THREE.GLTFLoader: Joint "%s" could not be found.', skinEntry.joints[ j ] );
4251
-
4252
- }
4253
-
4254
- }
4095
+ if ( ! mesh.isSkinnedMesh ) return;
4255
4096
 
4256
- mesh.bind( new Skeleton( bones, boneInverses ), mesh.matrixWorld );
4097
+ mesh.bind( skeleton, mesh.matrixWorld );
4257
4098
 
4258
4099
  } );
4259
4100