super-three 0.155.0 → 0.157.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 (268) hide show
  1. package/build/three.cjs +361 -324
  2. package/build/three.js +361 -324
  3. package/build/three.min.js +2 -2
  4. package/build/three.module.js +354 -323
  5. package/build/three.module.min.js +1 -1
  6. package/examples/jsm/capabilities/WebGL.js +17 -0
  7. package/examples/jsm/controls/DragControls.js +3 -2
  8. package/examples/jsm/controls/OrbitControls.js +13 -5
  9. package/examples/jsm/csm/CSMShader.js +59 -21
  10. package/examples/jsm/exporters/EXRExporter.js +102 -24
  11. package/examples/jsm/exporters/GLTFExporter.js +1 -1
  12. package/examples/jsm/libs/rhino3dm/rhino3dm.js +8726 -4
  13. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +8737 -4
  14. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  15. package/examples/jsm/libs/tween.module.js +790 -735
  16. package/examples/jsm/libs/utif.module.js +1644 -1558
  17. package/examples/jsm/lights/LightProbeGenerator.js +37 -3
  18. package/examples/jsm/lines/LineMaterial.js +90 -156
  19. package/examples/jsm/loaders/3DMLoader.js +378 -104
  20. package/examples/jsm/loaders/DDSLoader.js +46 -3
  21. package/examples/jsm/loaders/EXRLoader.js +4 -4
  22. package/examples/jsm/loaders/FBXLoader.js +2 -0
  23. package/examples/jsm/loaders/GLTFLoader.js +18 -8
  24. package/examples/jsm/loaders/KTX2Loader.js +126 -77
  25. package/examples/jsm/loaders/LDrawLoader.js +22 -16
  26. package/examples/jsm/loaders/LogLuvLoader.js +2 -2
  27. package/examples/jsm/loaders/MMDLoader.js +10 -7
  28. package/examples/jsm/loaders/RGBELoader.js +48 -66
  29. package/examples/jsm/loaders/STLLoader.js +7 -0
  30. package/examples/jsm/loaders/USDZLoader.js +215 -12
  31. package/examples/jsm/materials/MeshGouraudMaterial.js +22 -18
  32. package/examples/jsm/nodes/Nodes.js +8 -1
  33. package/examples/jsm/nodes/accessors/BitangentNode.js +1 -1
  34. package/examples/jsm/nodes/accessors/BufferAttributeNode.js +30 -4
  35. package/examples/jsm/nodes/accessors/BufferNode.js +1 -1
  36. package/examples/jsm/nodes/accessors/CameraNode.js +1 -1
  37. package/examples/jsm/nodes/accessors/CubeTextureNode.js +19 -4
  38. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +4 -5
  39. package/examples/jsm/nodes/accessors/InstanceNode.js +2 -2
  40. package/examples/jsm/nodes/accessors/LineMaterialNode.js +29 -0
  41. package/examples/jsm/nodes/accessors/MaterialNode.js +23 -13
  42. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +12 -9
  43. package/examples/jsm/nodes/accessors/ModelNode.js +1 -1
  44. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +5 -4
  45. package/examples/jsm/nodes/accessors/MorphNode.js +4 -4
  46. package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
  47. package/examples/jsm/nodes/accessors/Object3DNode.js +3 -3
  48. package/examples/jsm/nodes/accessors/PointUVNode.js +1 -1
  49. package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
  50. package/examples/jsm/nodes/accessors/ReferenceNode.js +13 -7
  51. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -2
  52. package/examples/jsm/nodes/accessors/SceneNode.js +2 -2
  53. package/examples/jsm/nodes/accessors/SkinningNode.js +2 -2
  54. package/examples/jsm/nodes/accessors/StorageBufferNode.js +1 -1
  55. package/examples/jsm/nodes/accessors/TangentNode.js +1 -1
  56. package/examples/jsm/nodes/accessors/TextureBicubicNode.js +2 -2
  57. package/examples/jsm/nodes/accessors/TextureNode.js +18 -8
  58. package/examples/jsm/nodes/accessors/TextureSizeNode.js +2 -2
  59. package/examples/jsm/nodes/accessors/TextureStoreNode.js +29 -0
  60. package/examples/jsm/nodes/accessors/UVNode.js +1 -1
  61. package/examples/jsm/nodes/accessors/UserDataNode.js +2 -2
  62. package/examples/jsm/nodes/code/CodeNode.js +1 -1
  63. package/examples/jsm/nodes/code/ExpressionNode.js +1 -1
  64. package/examples/jsm/nodes/code/FunctionCallNode.js +1 -1
  65. package/examples/jsm/nodes/code/FunctionNode.js +18 -7
  66. package/examples/jsm/nodes/code/ScriptableNode.js +2 -2
  67. package/examples/jsm/nodes/code/ScriptableValueNode.js +2 -2
  68. package/examples/jsm/nodes/core/ArrayUniformNode.js +1 -1
  69. package/examples/jsm/nodes/core/AttributeNode.js +3 -3
  70. package/examples/jsm/nodes/core/BypassNode.js +1 -1
  71. package/examples/jsm/nodes/core/CacheNode.js +1 -1
  72. package/examples/jsm/nodes/core/ConstNode.js +1 -1
  73. package/examples/jsm/nodes/core/ContextNode.js +2 -2
  74. package/examples/jsm/nodes/core/IndexNode.js +1 -1
  75. package/examples/jsm/nodes/core/InputNode.js +1 -1
  76. package/examples/jsm/nodes/core/Node.js +45 -14
  77. package/examples/jsm/nodes/core/NodeBuilder.js +83 -15
  78. package/examples/jsm/nodes/core/NodeFrame.js +37 -14
  79. package/examples/jsm/nodes/core/NodeUniform.js +1 -1
  80. package/examples/jsm/nodes/core/OutputStructNode.js +62 -0
  81. package/examples/jsm/nodes/core/PropertyNode.js +3 -1
  82. package/examples/jsm/nodes/core/StackNode.js +5 -5
  83. package/examples/jsm/nodes/core/StructTypeNode.js +24 -0
  84. package/examples/jsm/nodes/core/TempNode.js +1 -1
  85. package/examples/jsm/nodes/core/UniformNode.js +3 -1
  86. package/examples/jsm/nodes/core/VarNode.js +1 -1
  87. package/examples/jsm/nodes/core/VaryingNode.js +1 -1
  88. package/examples/jsm/nodes/core/constants.js +1 -1
  89. package/examples/jsm/nodes/display/BlendModeNode.js +2 -2
  90. package/examples/jsm/nodes/display/BumpMapNode.js +2 -2
  91. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +2 -2
  92. package/examples/jsm/nodes/display/ColorSpaceNode.js +2 -2
  93. package/examples/jsm/nodes/display/FrontFacingNode.js +1 -1
  94. package/examples/jsm/nodes/display/NormalMapNode.js +2 -2
  95. package/examples/jsm/nodes/display/PosterizeNode.js +2 -2
  96. package/examples/jsm/nodes/display/ToneMappingNode.js +2 -2
  97. package/examples/jsm/nodes/display/ViewportDepthNode.js +2 -2
  98. package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +1 -1
  99. package/examples/jsm/nodes/display/ViewportNode.js +21 -7
  100. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +1 -1
  101. package/examples/jsm/nodes/display/ViewportTextureNode.js +1 -1
  102. package/examples/jsm/nodes/fog/FogExp2Node.js +2 -2
  103. package/examples/jsm/nodes/fog/FogNode.js +2 -2
  104. package/examples/jsm/nodes/fog/FogRangeNode.js +2 -2
  105. package/examples/jsm/nodes/geometry/RangeNode.js +2 -2
  106. package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
  107. package/examples/jsm/nodes/lighting/AONode.js +2 -2
  108. package/examples/jsm/nodes/lighting/AmbientLightNode.js +3 -3
  109. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +4 -4
  110. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +4 -4
  111. package/examples/jsm/nodes/lighting/EnvironmentNode.js +2 -2
  112. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +3 -3
  113. package/examples/jsm/nodes/lighting/IESSpotLightNode.js +2 -2
  114. package/examples/jsm/nodes/lighting/LightNode.js +2 -2
  115. package/examples/jsm/nodes/lighting/LightingContextNode.js +3 -3
  116. package/examples/jsm/nodes/lighting/LightingNode.js +1 -1
  117. package/examples/jsm/nodes/lighting/LightsNode.js +4 -4
  118. package/examples/jsm/nodes/lighting/PointLightNode.js +3 -3
  119. package/examples/jsm/nodes/lighting/SpotLightNode.js +4 -4
  120. package/examples/jsm/nodes/materials/Line2NodeMaterial.js +449 -0
  121. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +1 -1
  122. package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +54 -0
  123. package/examples/jsm/nodes/materials/Materials.js +2 -0
  124. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -1
  125. package/examples/jsm/nodes/materials/MeshLambertNodeMaterial.js +2 -2
  126. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +2 -2
  127. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
  128. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
  129. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +3 -3
  130. package/examples/jsm/nodes/materials/NodeMaterial.js +39 -29
  131. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +1 -1
  132. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +2 -2
  133. package/examples/jsm/nodes/math/CondNode.js +1 -1
  134. package/examples/jsm/nodes/math/HashNode.js +34 -0
  135. package/examples/jsm/nodes/math/MathNode.js +2 -2
  136. package/examples/jsm/nodes/math/OperatorNode.js +1 -1
  137. package/examples/jsm/nodes/procedural/CheckerNode.js +3 -3
  138. package/examples/jsm/nodes/shadernode/ShaderNode.js +85 -28
  139. package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
  140. package/examples/jsm/nodes/utils/ConvertNode.js +1 -1
  141. package/examples/jsm/nodes/utils/DiscardNode.js +1 -1
  142. package/examples/jsm/nodes/utils/EquirectUVNode.js +2 -2
  143. package/examples/jsm/nodes/utils/JoinNode.js +1 -1
  144. package/examples/jsm/nodes/utils/LoopNode.js +11 -11
  145. package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -2
  146. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
  147. package/examples/jsm/nodes/utils/OscNode.js +2 -2
  148. package/examples/jsm/nodes/utils/PackingNode.js +2 -2
  149. package/examples/jsm/nodes/utils/RemapNode.js +2 -2
  150. package/examples/jsm/nodes/utils/RotateUVNode.js +2 -2
  151. package/examples/jsm/nodes/utils/SetNode.js +62 -0
  152. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +2 -2
  153. package/examples/jsm/nodes/utils/SplitNode.js +2 -2
  154. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +2 -2
  155. package/examples/jsm/nodes/utils/TimerNode.js +2 -2
  156. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +2 -2
  157. package/examples/jsm/objects/Sky.js +1 -3
  158. package/examples/jsm/postprocessing/FilmPass.js +3 -5
  159. package/examples/jsm/postprocessing/OutputPass.js +3 -2
  160. package/examples/jsm/postprocessing/RenderPass.js +30 -12
  161. package/examples/jsm/postprocessing/SAOPass.js +23 -98
  162. package/examples/jsm/postprocessing/SSAOPass.js +10 -30
  163. package/examples/jsm/renderers/common/Backend.js +11 -8
  164. package/examples/jsm/renderers/common/Background.js +2 -2
  165. package/examples/jsm/renderers/common/Binding.js +6 -0
  166. package/examples/jsm/renderers/common/Bindings.js +4 -5
  167. package/examples/jsm/renderers/common/Pipelines.js +9 -9
  168. package/examples/jsm/renderers/common/RenderContext.js +3 -0
  169. package/examples/jsm/renderers/common/RenderContexts.js +26 -1
  170. package/examples/jsm/renderers/common/RenderList.js +12 -4
  171. package/examples/jsm/renderers/common/RenderObject.js +43 -15
  172. package/examples/jsm/renderers/common/RenderObjects.js +8 -14
  173. package/examples/jsm/renderers/common/Renderer.js +52 -16
  174. package/examples/jsm/renderers/common/SampledTexture.js +6 -3
  175. package/examples/jsm/renderers/common/Sampler.js +1 -1
  176. package/examples/jsm/renderers/common/StorageBuffer.js +1 -1
  177. package/examples/jsm/renderers/common/StorageTexture.js +19 -0
  178. package/examples/jsm/renderers/common/Textures.js +166 -21
  179. package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +35 -0
  180. package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +21 -11
  181. package/examples/jsm/renderers/common/nodes/NodeSampler.js +1 -7
  182. package/examples/jsm/renderers/common/nodes/Nodes.js +79 -18
  183. package/examples/jsm/renderers/webgl/WebGLBackend.js +702 -0
  184. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +207 -20
  185. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +84 -0
  186. package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +26 -0
  187. package/examples/jsm/renderers/webgl/utils/WebGLState.js +529 -0
  188. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +212 -0
  189. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +242 -0
  190. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +340 -0
  191. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodeBuilder.js +4 -4
  192. package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/WebGLNodes.js +14 -2
  193. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +282 -43
  194. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +18 -2
  195. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +93 -60
  196. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeFunction.js +2 -2
  197. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +15 -2
  198. package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +39 -14
  199. package/examples/jsm/renderers/webgpu/utils/WebGPUTexturePassUtils.js +285 -0
  200. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +205 -284
  201. package/examples/jsm/renderers/webgpu/utils/WebGPUUtils.js +6 -5
  202. package/examples/jsm/shaders/FilmShader.js +11 -54
  203. package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
  204. package/examples/jsm/shaders/MMDToonShader.js +4 -4
  205. package/examples/jsm/shaders/OutputShader.js +2 -2
  206. package/examples/jsm/shaders/SAOShader.js +0 -13
  207. package/examples/jsm/shaders/SSAOShader.js +33 -26
  208. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +6 -6
  209. package/examples/jsm/utils/BufferGeometryUtils.js +6 -4
  210. package/package.json +1 -1
  211. package/src/Three.js +1 -2
  212. package/src/animation/AnimationUtils.js +3 -20
  213. package/src/animation/KeyframeTrack.js +8 -8
  214. package/src/audio/Audio.js +6 -0
  215. package/src/cameras/Camera.js +1 -5
  216. package/src/cameras/CubeCamera.js +14 -8
  217. package/src/constants.js +10 -1
  218. package/src/core/Object3D.js +1 -14
  219. package/src/core/RenderTarget.js +16 -7
  220. package/src/core/UniformsGroup.js +2 -2
  221. package/src/extras/core/CurvePath.js +4 -1
  222. package/src/loaders/DataTextureLoader.js +0 -2
  223. package/src/loaders/MaterialLoader.js +1 -1
  224. package/src/loaders/ObjectLoader.js +6 -0
  225. package/src/materials/Material.js +10 -10
  226. package/src/math/Color.js +1 -5
  227. package/src/math/ColorManagement.js +82 -60
  228. package/src/math/Vector2.js +2 -2
  229. package/src/math/Vector3.js +3 -3
  230. package/src/math/Vector4.js +4 -4
  231. package/src/objects/Line.js +1 -1
  232. package/src/objects/Mesh.js +1 -1
  233. package/src/objects/Points.js +1 -1
  234. package/src/objects/Sprite.js +2 -2
  235. package/src/renderers/WebGLRenderer.js +42 -51
  236. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
  237. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +1 -1
  238. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +35 -2
  239. package/src/renderers/shaders/ShaderChunk/common.glsl.js +0 -9
  240. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +19 -15
  241. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +2 -2
  242. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +4 -4
  243. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +3 -3
  244. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -6
  245. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +4 -4
  246. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +1 -1
  247. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +16 -16
  248. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +3 -3
  249. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +11 -1
  250. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +1 -1
  251. package/src/renderers/shaders/ShaderLib/background.glsl.js +8 -0
  252. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -1
  253. package/src/renderers/shaders/UniformsUtils.js +2 -2
  254. package/src/renderers/webgl/WebGLBackground.js +9 -17
  255. package/src/renderers/webgl/WebGLLights.js +14 -3
  256. package/src/renderers/webgl/WebGLProgram.js +36 -5
  257. package/src/renderers/webgl/WebGLPrograms.js +9 -1
  258. package/src/renderers/webgl/WebGLTextures.js +19 -8
  259. package/src/renderers/webgl/WebGLUtils.js +25 -20
  260. package/src/scenes/Fog.js +1 -0
  261. package/src/scenes/FogExp2.js +1 -0
  262. package/src/textures/Source.js +2 -2
  263. package/src/textures/Texture.js +2 -2
  264. package/src/utils.js +9 -1
  265. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureMipmapUtils.js +0 -163
  266. package/src/lights/AmbientLightProbe.js +0 -21
  267. package/src/lights/HemisphereLightProbe.js +0 -30
  268. /package/examples/jsm/renderers/{webgl → webgl-legacy}/nodes/SlotNode.js +0 -0
@@ -37,20 +37,29 @@ class RenderTarget extends EventDispatcher {
37
37
 
38
38
  }
39
39
 
40
+ options = Object.assign( {
41
+ generateMipmaps: false,
42
+ internalFormat: null,
43
+ minFilter: LinearFilter,
44
+ depthBuffer: true,
45
+ stencilBuffer: false,
46
+ depthTexture: null,
47
+ samples: 0
48
+ }, options );
49
+
40
50
  this.texture = new Texture( image, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.colorSpace );
41
51
  this.texture.isRenderTargetTexture = true;
42
52
 
43
53
  this.texture.flipY = false;
44
- this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
45
- this.texture.internalFormat = options.internalFormat !== undefined ? options.internalFormat : null;
46
- this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
54
+ this.texture.generateMipmaps = options.generateMipmaps;
55
+ this.texture.internalFormat = options.internalFormat;
47
56
 
48
- this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
49
- this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;
57
+ this.depthBuffer = options.depthBuffer;
58
+ this.stencilBuffer = options.stencilBuffer;
50
59
 
51
- this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
60
+ this.depthTexture = options.depthTexture;
52
61
 
53
- this.samples = options.samples !== undefined ? options.samples : 0;
62
+ this.samples = options.samples;
54
63
 
55
64
  }
56
65
 
@@ -1,7 +1,7 @@
1
1
  import { EventDispatcher } from './EventDispatcher.js';
2
2
  import { StaticDrawUsage } from '../constants.js';
3
3
 
4
- let id = 0;
4
+ let _id = 0;
5
5
 
6
6
  class UniformsGroup extends EventDispatcher {
7
7
 
@@ -11,7 +11,7 @@ class UniformsGroup extends EventDispatcher {
11
11
 
12
12
  this.isUniformsGroup = true;
13
13
 
14
- Object.defineProperty( this, 'id', { value: id ++ } );
14
+ Object.defineProperty( this, 'id', { value: _id ++ } );
15
15
 
16
16
  this.name = '';
17
17
 
@@ -33,10 +33,13 @@ class CurvePath extends Curve {
33
33
 
34
34
  if ( ! startPoint.equals( endPoint ) ) {
35
35
 
36
- this.curves.push( new Curves[ 'LineCurve' ]( endPoint, startPoint ) );
36
+ const lineType = ( startPoint.isVector2 === true ) ? 'LineCurve' : 'LineCurve3';
37
+ this.curves.push( new Curves[ lineType ]( endPoint, startPoint ) );
37
38
 
38
39
  }
39
40
 
41
+ return this;
42
+
40
43
  }
41
44
 
42
45
  // To get accurate point with reference to
@@ -51,8 +51,6 @@ class DataTextureLoader extends Loader {
51
51
 
52
52
  }
53
53
 
54
- if ( ! texData ) return onError(); // TODO: Remove this when all loaders properly throw errors
55
-
56
54
  if ( texData.image !== undefined ) {
57
55
 
58
56
  texture.image = texData.image;
@@ -142,7 +142,7 @@ class MaterialLoader extends Loader {
142
142
 
143
143
  if ( json.rotation !== undefined ) material.rotation = json.rotation;
144
144
 
145
- if ( json.linewidth !== 1 ) material.linewidth = json.linewidth;
145
+ if ( json.linewidth !== undefined ) material.linewidth = json.linewidth;
146
146
  if ( json.dashSize !== undefined ) material.dashSize = json.dashSize;
147
147
  if ( json.gapSize !== undefined ) material.gapSize = json.gapSize;
148
148
  if ( json.scale !== undefined ) material.scale = json.scale;
@@ -800,6 +800,12 @@ class ObjectLoader extends Loader {
800
800
 
801
801
  }
802
802
 
803
+ if ( data.fog.name !== '' ) {
804
+
805
+ object.fog.name = data.fog.name;
806
+
807
+ }
808
+
803
809
  }
804
810
 
805
811
  if ( data.backgroundBlurriness !== undefined ) object.backgroundBlurriness = data.backgroundBlurriness;
@@ -2,7 +2,7 @@ import { EventDispatcher } from '../core/EventDispatcher.js';
2
2
  import { FrontSide, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js';
3
3
  import * as MathUtils from '../math/MathUtils.js';
4
4
 
5
- let materialId = 0;
5
+ let _materialId = 0;
6
6
 
7
7
  class Material extends EventDispatcher {
8
8
 
@@ -12,7 +12,7 @@ class Material extends EventDispatcher {
12
12
 
13
13
  this.isMaterial = true;
14
14
 
15
- Object.defineProperty( this, 'id', { value: materialId ++ } );
15
+ Object.defineProperty( this, 'id', { value: _materialId ++ } );
16
16
 
17
17
  this.uuid = MathUtils.generateUUID();
18
18
 
@@ -320,10 +320,10 @@ class Material extends EventDispatcher {
320
320
 
321
321
  if ( this.blending !== NormalBlending ) data.blending = this.blending;
322
322
  if ( this.side !== FrontSide ) data.side = this.side;
323
- if ( this.vertexColors ) data.vertexColors = true;
323
+ if ( this.vertexColors === true ) data.vertexColors = true;
324
324
 
325
325
  if ( this.opacity < 1 ) data.opacity = this.opacity;
326
- if ( this.transparent === true ) data.transparent = this.transparent;
326
+ if ( this.transparent === true ) data.transparent = true;
327
327
 
328
328
  data.depthFunc = this.depthFunc;
329
329
  data.depthTest = this.depthTest;
@@ -354,17 +354,17 @@ class Material extends EventDispatcher {
354
354
  if ( this.dithering === true ) data.dithering = true;
355
355
 
356
356
  if ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;
357
- if ( this.alphaHash === true ) data.alphaHash = this.alphaHash;
358
- if ( this.alphaToCoverage === true ) data.alphaToCoverage = this.alphaToCoverage;
359
- if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;
360
- if ( this.forceSinglePass === true ) data.forceSinglePass = this.forceSinglePass;
357
+ if ( this.alphaHash === true ) data.alphaHash = true;
358
+ if ( this.alphaToCoverage === true ) data.alphaToCoverage = true;
359
+ if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = true;
360
+ if ( this.forceSinglePass === true ) data.forceSinglePass = true;
361
361
 
362
- if ( this.wireframe === true ) data.wireframe = this.wireframe;
362
+ if ( this.wireframe === true ) data.wireframe = true;
363
363
  if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
364
364
  if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;
365
365
  if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;
366
366
 
367
- if ( this.flatShading === true ) data.flatShading = this.flatShading;
367
+ if ( this.flatShading === true ) data.flatShading = true;
368
368
 
369
369
  if ( this.visible === false ) data.visible = false;
370
370
 
package/src/math/Color.js CHANGED
@@ -442,11 +442,7 @@ class Color {
442
442
 
443
443
  this.getHSL( _hslA );
444
444
 
445
- _hslA.h += h; _hslA.s += s; _hslA.l += l;
446
-
447
- this.setHSL( _hslA.h, _hslA.s, _hslA.l );
448
-
449
- return this;
445
+ return this.setHSL( _hslA.h + h, _hslA.s + s, _hslA.l + l );
450
446
 
451
447
  }
452
448
 
@@ -1,18 +1,6 @@
1
- import { SRGBColorSpace, LinearSRGBColorSpace, DisplayP3ColorSpace, } from '../constants.js';
1
+ import { SRGBColorSpace, LinearSRGBColorSpace, DisplayP3ColorSpace, LinearDisplayP3ColorSpace, Rec709Primaries, P3Primaries, SRGBTransfer, LinearTransfer, NoColorSpace, } from '../constants.js';
2
2
  import { Matrix3 } from './Matrix3.js';
3
3
 
4
- export function SRGBToLinear( c ) {
5
-
6
- return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
7
-
8
- }
9
-
10
- export function LinearToSRGB( c ) {
11
-
12
- return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
13
-
14
- }
15
-
16
4
  /**
17
5
  * Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
18
6
  * or clipping. Based on W3C specifications for sRGB and Display P3,
@@ -25,50 +13,57 @@ export function LinearToSRGB( c ) {
25
13
  * - http://www.russellcottrell.com/photo/matrixCalculator.htm
26
14
  */
27
15
 
28
- const LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = /*@__PURE__*/ new Matrix3().fromArray( [
29
- 0.8224621, 0.0331941, 0.0170827,
30
- 0.1775380, 0.9668058, 0.0723974,
31
- - 0.0000001, 0.0000001, 0.9105199
32
- ] );
33
-
34
- const LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = /*@__PURE__*/ new Matrix3().fromArray( [
35
- 1.2249401, - 0.0420569, - 0.0196376,
36
- - 0.2249404, 1.0420571, - 0.0786361,
37
- 0.0000001, 0.0000000, 1.0982735
38
- ] );
39
-
40
- function DisplayP3ToLinearSRGB( color ) {
16
+ const LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = /*@__PURE__*/ new Matrix3().set(
17
+ 0.8224621, 0.177538, 0.0,
18
+ 0.0331941, 0.9668058, 0.0,
19
+ 0.0170827, 0.0723974, 0.9105199,
20
+ );
41
21
 
42
- // Display P3 uses the sRGB transfer functions
43
- return color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB );
22
+ const LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = /*@__PURE__*/ new Matrix3().set(
23
+ 1.2249401, - 0.2249404, 0.0,
24
+ - 0.0420569, 1.0420571, 0.0,
25
+ - 0.0196376, - 0.0786361, 1.0982735
26
+ );
44
27
 
45
- }
46
-
47
- function LinearSRGBToDisplayP3( color ) {
48
-
49
- // Display P3 uses the sRGB transfer functions
50
- return color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB();
51
-
52
- }
53
-
54
- // Conversions from <source> to Linear-sRGB reference space.
55
- const TO_LINEAR = {
56
- [ LinearSRGBColorSpace ]: ( color ) => color,
57
- [ SRGBColorSpace ]: ( color ) => color.convertSRGBToLinear(),
58
- [ DisplayP3ColorSpace ]: DisplayP3ToLinearSRGB,
28
+ /**
29
+ * Defines supported color spaces by transfer function and primaries,
30
+ * and provides conversions to/from the Linear-sRGB reference space.
31
+ */
32
+ const COLOR_SPACES = {
33
+ [ LinearSRGBColorSpace ]: {
34
+ transfer: LinearTransfer,
35
+ primaries: Rec709Primaries,
36
+ toReference: ( color ) => color,
37
+ fromReference: ( color ) => color,
38
+ },
39
+ [ SRGBColorSpace ]: {
40
+ transfer: SRGBTransfer,
41
+ primaries: Rec709Primaries,
42
+ toReference: ( color ) => color.convertSRGBToLinear(),
43
+ fromReference: ( color ) => color.convertLinearToSRGB(),
44
+ },
45
+ [ LinearDisplayP3ColorSpace ]: {
46
+ transfer: LinearTransfer,
47
+ primaries: P3Primaries,
48
+ toReference: ( color ) => color.applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
49
+ fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ),
50
+ },
51
+ [ DisplayP3ColorSpace ]: {
52
+ transfer: SRGBTransfer,
53
+ primaries: P3Primaries,
54
+ toReference: ( color ) => color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
55
+ fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB(),
56
+ },
59
57
  };
60
58
 
61
- // Conversions to <target> from Linear-sRGB reference space.
62
- const FROM_LINEAR = {
63
- [ LinearSRGBColorSpace ]: ( color ) => color,
64
- [ SRGBColorSpace ]: ( color ) => color.convertLinearToSRGB(),
65
- [ DisplayP3ColorSpace ]: LinearSRGBToDisplayP3,
66
- };
59
+ const SUPPORTED_WORKING_COLOR_SPACES = new Set( [ LinearSRGBColorSpace, LinearDisplayP3ColorSpace ] );
67
60
 
68
61
  export const ColorManagement = {
69
62
 
70
63
  enabled: true,
71
64
 
65
+ _workingColorSpace: LinearSRGBColorSpace,
66
+
72
67
  get legacyMode() {
73
68
 
74
69
  console.warn( 'THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.' );
@@ -87,13 +82,19 @@ export const ColorManagement = {
87
82
 
88
83
  get workingColorSpace() {
89
84
 
90
- return LinearSRGBColorSpace;
85
+ return this._workingColorSpace;
91
86
 
92
87
  },
93
88
 
94
89
  set workingColorSpace( colorSpace ) {
95
90
 
96
- console.warn( 'THREE.ColorManagement: .workingColorSpace is readonly.' );
91
+ if ( ! SUPPORTED_WORKING_COLOR_SPACES.has( colorSpace ) ) {
92
+
93
+ throw new Error( `Unsupported working color space, "${ colorSpace }".` );
94
+
95
+ }
96
+
97
+ this._workingColorSpace = colorSpace;
97
98
 
98
99
  },
99
100
 
@@ -105,29 +106,50 @@ export const ColorManagement = {
105
106
 
106
107
  }
107
108
 
108
- const sourceToLinear = TO_LINEAR[ sourceColorSpace ];
109
- const targetFromLinear = FROM_LINEAR[ targetColorSpace ];
109
+ const sourceToReference = COLOR_SPACES[ sourceColorSpace ].toReference;
110
+ const targetFromReference = COLOR_SPACES[ targetColorSpace ].fromReference;
110
111
 
111
- if ( sourceToLinear === undefined || targetFromLinear === undefined ) {
112
+ return targetFromReference( sourceToReference( color ) );
112
113
 
113
- throw new Error( `Unsupported color space conversion, "${ sourceColorSpace }" to "${ targetColorSpace }".` );
114
+ },
114
115
 
115
- }
116
+ fromWorkingColorSpace: function ( color, targetColorSpace ) {
116
117
 
117
- return targetFromLinear( sourceToLinear( color ) );
118
+ return this.convert( color, this._workingColorSpace, targetColorSpace );
118
119
 
119
120
  },
120
121
 
121
- fromWorkingColorSpace: function ( color, targetColorSpace ) {
122
+ toWorkingColorSpace: function ( color, sourceColorSpace ) {
122
123
 
123
- return this.convert( color, this.workingColorSpace, targetColorSpace );
124
+ return this.convert( color, sourceColorSpace, this._workingColorSpace );
124
125
 
125
126
  },
126
127
 
127
- toWorkingColorSpace: function ( color, sourceColorSpace ) {
128
+ getPrimaries: function ( colorSpace ) {
129
+
130
+ return COLOR_SPACES[ colorSpace ].primaries;
131
+
132
+ },
133
+
134
+ getTransfer: function ( colorSpace ) {
128
135
 
129
- return this.convert( color, sourceColorSpace, this.workingColorSpace );
136
+ if ( colorSpace === NoColorSpace ) return LinearTransfer;
137
+
138
+ return COLOR_SPACES[ colorSpace ].transfer;
130
139
 
131
140
  },
132
141
 
133
142
  };
143
+
144
+
145
+ export function SRGBToLinear( c ) {
146
+
147
+ return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
148
+
149
+ }
150
+
151
+ export function LinearToSRGB( c ) {
152
+
153
+ return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
154
+
155
+ }
@@ -293,8 +293,8 @@ class Vector2 {
293
293
 
294
294
  roundToZero() {
295
295
 
296
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
297
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
296
+ this.x = Math.trunc( this.x );
297
+ this.y = Math.trunc( this.y );
298
298
 
299
299
  return this;
300
300
 
@@ -397,9 +397,9 @@ class Vector3 {
397
397
 
398
398
  roundToZero() {
399
399
 
400
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
401
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
402
- this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
400
+ this.x = Math.trunc( this.x );
401
+ this.y = Math.trunc( this.y );
402
+ this.z = Math.trunc( this.z );
403
403
 
404
404
  return this;
405
405
 
@@ -502,10 +502,10 @@ class Vector4 {
502
502
 
503
503
  roundToZero() {
504
504
 
505
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
506
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
507
- this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
508
- this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );
505
+ this.x = Math.trunc( this.x );
506
+ this.y = Math.trunc( this.y );
507
+ this.z = Math.trunc( this.z );
508
+ this.w = Math.trunc( this.w );
509
509
 
510
510
  return this;
511
511
 
@@ -34,7 +34,7 @@ class Line extends Object3D {
34
34
 
35
35
  super.copy( source, recursive );
36
36
 
37
- this.material = source.material;
37
+ this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
38
38
  this.geometry = source.geometry;
39
39
 
40
40
  return this;
@@ -65,7 +65,7 @@ class Mesh extends Object3D {
65
65
 
66
66
  }
67
67
 
68
- this.material = source.material;
68
+ this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
69
69
  this.geometry = source.geometry;
70
70
 
71
71
  return this;
@@ -32,7 +32,7 @@ class Points extends Object3D {
32
32
 
33
33
  super.copy( source, recursive );
34
34
 
35
- this.material = source.material;
35
+ this.material = Array.isArray( source.material ) ? source.material.slice() : source.material;
36
36
  this.geometry = source.geometry;
37
37
 
38
38
  return this;
@@ -28,7 +28,7 @@ const _uvC = /*@__PURE__*/ new Vector2();
28
28
 
29
29
  class Sprite extends Object3D {
30
30
 
31
- constructor( material ) {
31
+ constructor( material = new SpriteMaterial() ) {
32
32
 
33
33
  super();
34
34
 
@@ -56,7 +56,7 @@ class Sprite extends Object3D {
56
56
  }
57
57
 
58
58
  this.geometry = _geometry;
59
- this.material = ( material !== undefined ) ? material : new SpriteMaterial();
59
+ this.material = material;
60
60
 
61
61
  this.center = new Vector2( 0.5, 0.5 );
62
62
 
@@ -21,7 +21,9 @@ import {
21
21
  UnsignedInt248Type,
22
22
  UnsignedShort4444Type,
23
23
  UnsignedShort5551Type,
24
- WebGLCoordinateSystem
24
+ WebGLCoordinateSystem,
25
+ DisplayP3ColorSpace,
26
+ LinearDisplayP3ColorSpace
25
27
  } from '../constants.js';
26
28
  import { Color } from '../math/Color.js';
27
29
  import { Frustum } from '../math/Frustum.js';
@@ -59,15 +61,8 @@ import { WebVRManager } from './webvr/WebVRManager.js';
59
61
  import { WebXRManager } from './webxr/WebXRManager.js';
60
62
  import { WebGLMaterials } from './webgl/WebGLMaterials.js';
61
63
  import { WebGLUniformsGroups } from './webgl/WebGLUniformsGroups.js';
62
- import { createElementNS } from '../utils.js';
63
-
64
- function createCanvasElement() {
65
-
66
- const canvas = createElementNS( 'canvas' );
67
- canvas.style.display = 'block';
68
- return canvas;
69
-
70
- }
64
+ import { createCanvasElement } from '../utils.js';
65
+ import { ColorManagement } from '../math/ColorManagement.js';
71
66
 
72
67
  class WebGLRenderer {
73
68
 
@@ -149,7 +144,7 @@ class WebGLRenderer {
149
144
 
150
145
  // physically based shading
151
146
 
152
- this.outputColorSpace = SRGBColorSpace;
147
+ this._outputColorSpace = SRGBColorSpace;
153
148
 
154
149
  // physical lights
155
150
 
@@ -1799,48 +1794,28 @@ class WebGLRenderer {
1799
1794
 
1800
1795
  if ( refreshProgram || _currentCamera !== camera ) {
1801
1796
 
1802
- p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
1803
-
1804
- if ( capabilities.logarithmicDepthBuffer ) {
1797
+ // common camera uniforms
1805
1798
 
1806
- p_uniforms.setValue( _gl, 'logDepthBufFC',
1807
- 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
1799
+ p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
1800
+ p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
1808
1801
 
1809
- }
1802
+ const uCamPos = p_uniforms.map.cameraPosition;
1810
1803
 
1811
- if ( _currentCamera !== camera ) {
1804
+ if ( uCamPos !== undefined ) {
1812
1805
 
1813
- _currentCamera = camera;
1814
-
1815
- // lighting uniforms depend on the camera so enforce an update
1816
- // now, in case this material supports lights - or later, when
1817
- // the next material that does gets activated:
1818
-
1819
- refreshMaterial = true; // set to true on material change
1820
- refreshLights = true; // remains set until update done
1806
+ uCamPos.setValue( _gl, _vector3.setFromMatrixPosition( camera.matrixWorld ) );
1821
1807
 
1822
1808
  }
1823
1809
 
1824
- // load material specific uniforms
1825
- // (shader material also gets them for the sake of genericity)
1826
-
1827
- if ( material.isShaderMaterial ||
1828
- material.isMeshPhongMaterial ||
1829
- material.isMeshToonMaterial ||
1830
- material.isMeshStandardMaterial ||
1831
- material.envMap ) {
1832
-
1833
- const uCamPos = p_uniforms.map.cameraPosition;
1834
-
1835
- if ( uCamPos !== undefined ) {
1836
-
1837
- uCamPos.setValue( _gl,
1838
- _vector3.setFromMatrixPosition( camera.matrixWorld ) );
1810
+ if ( capabilities.logarithmicDepthBuffer ) {
1839
1811
 
1840
- }
1812
+ p_uniforms.setValue( _gl, 'logDepthBufFC',
1813
+ 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
1841
1814
 
1842
1815
  }
1843
1816
 
1817
+ // consider moving isOrthographic to UniformLib and WebGLMaterials, see https://github.com/mrdoob/three.js/pull/26467#issuecomment-1645185067
1818
+
1844
1819
  if ( material.isMeshPhongMaterial ||
1845
1820
  material.isMeshToonMaterial ||
1846
1821
  material.isMeshLambertMaterial ||
@@ -1852,16 +1827,16 @@ class WebGLRenderer {
1852
1827
 
1853
1828
  }
1854
1829
 
1855
- if ( material.isMeshPhongMaterial ||
1856
- material.isMeshToonMaterial ||
1857
- material.isMeshLambertMaterial ||
1858
- material.isMeshBasicMaterial ||
1859
- material.isMeshStandardMaterial ||
1860
- material.isShaderMaterial ||
1861
- material.isShadowMaterial ||
1862
- object.isSkinnedMesh ) {
1830
+ if ( _currentCamera !== camera ) {
1863
1831
 
1864
- p_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );
1832
+ _currentCamera = camera;
1833
+
1834
+ // lighting uniforms depend on the camera so enforce an update
1835
+ // now, in case this material supports lights - or later, when
1836
+ // the next material that does gets activated:
1837
+
1838
+ refreshMaterial = true; // set to true on material change
1839
+ refreshLights = true; // remains set until update done
1865
1840
 
1866
1841
  }
1867
1842
 
@@ -2477,6 +2452,22 @@ class WebGLRenderer {
2477
2452
 
2478
2453
  }
2479
2454
 
2455
+ get outputColorSpace() {
2456
+
2457
+ return this._outputColorSpace;
2458
+
2459
+ }
2460
+
2461
+ set outputColorSpace( colorSpace ) {
2462
+
2463
+ this._outputColorSpace = colorSpace;
2464
+
2465
+ const gl = this.getContext();
2466
+ gl.drawingBufferColorSpace = colorSpace === DisplayP3ColorSpace ? 'display-p3' : 'srgb';
2467
+ gl.unpackColorSpace = ColorManagement.workingColorSpace === LinearDisplayP3ColorSpace ? 'display-p3' : 'srgb';
2468
+
2469
+ }
2470
+
2480
2471
  get physicallyCorrectLights() { // @deprecated, r150
2481
2472
 
2482
2473
  console.warn( 'THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.' );
@@ -8,7 +8,7 @@ export default /* glsl */`
8
8
 
9
9
  #if defined( USE_ENVMAP ) && defined( STANDARD )
10
10
 
11
- float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
11
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
12
12
 
13
13
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
14
14
 
@@ -1,7 +1,7 @@
1
1
  export default /* glsl */`
2
2
  #ifdef USE_CLEARCOAT
3
3
 
4
- vec3 clearcoatNormal = geometryNormal;
4
+ vec3 clearcoatNormal = nonPerturbedNormal;
5
5
 
6
6
  #endif
7
7
  `;