super-three 0.169.0 → 0.170.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 (195) hide show
  1. package/build/three.cjs +989 -1131
  2. package/build/three.module.js +990 -1128
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +8398 -9842
  5. package/build/three.webgpu.min.js +1 -1
  6. package/build/three.webgpu.nodes.js +8398 -9842
  7. package/build/three.webgpu.nodes.min.js +1 -1
  8. package/examples/jsm/Addons.js +3 -3
  9. package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
  10. package/examples/jsm/animation/MMDPhysics.js +2 -0
  11. package/examples/jsm/controls/TransformControls.js +22 -6
  12. package/examples/jsm/csm/CSM.js +2 -2
  13. package/examples/jsm/csm/CSMFrustum.js +7 -4
  14. package/examples/jsm/csm/CSMHelper.js +2 -0
  15. package/examples/jsm/csm/CSMShadowNode.js +435 -0
  16. package/examples/jsm/curves/NURBSCurve.js +34 -3
  17. package/examples/jsm/exporters/GLTFExporter.js +138 -71
  18. package/examples/jsm/exporters/KTX2Exporter.js +35 -12
  19. package/examples/jsm/exporters/MMDExporter.js +6 -0
  20. package/examples/jsm/exporters/USDZExporter.js +21 -3
  21. package/examples/jsm/geometries/DecalGeometry.js +65 -20
  22. package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
  23. package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
  24. package/examples/jsm/interactive/HTMLMesh.js +1 -0
  25. package/examples/jsm/lighting/TiledLighting.js +18 -0
  26. package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
  27. package/examples/jsm/lines/LineMaterial.js +7 -2
  28. package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
  29. package/examples/jsm/lines/webgpu/LineSegments2.js +0 -15
  30. package/examples/jsm/lines/webgpu/Wireframe.js +56 -0
  31. package/examples/jsm/loaders/3DMLoader.js +1 -0
  32. package/examples/jsm/loaders/3MFLoader.js +91 -0
  33. package/examples/jsm/loaders/FBXLoader.js +12 -2
  34. package/examples/jsm/loaders/GLTFLoader.js +2 -0
  35. package/examples/jsm/loaders/KTX2Loader.js +140 -49
  36. package/examples/jsm/loaders/LDrawLoader.js +22 -136
  37. package/examples/jsm/loaders/LottieLoader.js +1 -0
  38. package/examples/jsm/loaders/MMDLoader.js +9 -2
  39. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
  40. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
  41. package/examples/jsm/materials/MeshGouraudMaterial.js +6 -2
  42. package/examples/jsm/math/ColorSpaces.js +76 -0
  43. package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
  44. package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
  45. package/examples/jsm/misc/VolumeSlice.js +1 -0
  46. package/examples/jsm/objects/WaterMesh.js +8 -8
  47. package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
  48. package/examples/jsm/postprocessing/SSRPass.js +6 -0
  49. package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
  50. package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
  51. package/examples/jsm/shaders/FXAAShader.js +225 -224
  52. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  53. package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +17 -20
  54. package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
  55. package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
  56. package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
  57. package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +11 -40
  58. package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +18 -41
  59. package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +2 -8
  60. package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
  61. package/examples/jsm/tsl/display/FXAANode.js +316 -0
  62. package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +2 -6
  63. package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +30 -70
  64. package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +74 -36
  65. package/examples/jsm/tsl/display/LensflareNode.js +161 -0
  66. package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +1 -4
  67. package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
  68. package/examples/jsm/tsl/display/OutlineNode.js +434 -0
  69. package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +1 -5
  70. package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +3 -15
  71. package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +1 -6
  72. package/examples/jsm/tsl/display/SMAANode.js +620 -0
  73. package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
  74. package/examples/jsm/tsl/display/SSRNode.js +343 -0
  75. package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
  76. package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +3 -11
  77. package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
  78. package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
  79. package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
  80. package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +1 -6
  81. package/examples/jsm/tsl/display/hashBlur.js +24 -0
  82. package/examples/jsm/tsl/lighting/TiledLightsNode.js +392 -0
  83. package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
  84. package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
  85. package/examples/jsm/webxr/Text2D.js +6 -6
  86. package/package.json +2 -2
  87. package/src/Three.WebGPU.Nodes.js +4 -0
  88. package/src/Three.WebGPU.js +4 -0
  89. package/src/constants.js +1 -6
  90. package/src/core/BufferGeometry.js +44 -6
  91. package/src/geometries/CylinderGeometry.js +2 -2
  92. package/src/materials/LineBasicMaterial.js +6 -2
  93. package/src/materials/LineDashedMaterial.js +6 -2
  94. package/src/materials/Material.js +14 -1
  95. package/src/materials/MeshBasicMaterial.js +6 -2
  96. package/src/materials/MeshDepthMaterial.js +6 -2
  97. package/src/materials/MeshDistanceMaterial.js +6 -2
  98. package/src/materials/MeshLambertMaterial.js +6 -2
  99. package/src/materials/MeshMatcapMaterial.js +6 -2
  100. package/src/materials/MeshNormalMaterial.js +6 -2
  101. package/src/materials/MeshPhongMaterial.js +6 -2
  102. package/src/materials/MeshPhysicalMaterial.js +6 -2
  103. package/src/materials/MeshStandardMaterial.js +6 -2
  104. package/src/materials/MeshToonMaterial.js +6 -2
  105. package/src/materials/PointsMaterial.js +6 -2
  106. package/src/materials/RawShaderMaterial.js +6 -2
  107. package/src/materials/ShaderMaterial.js +6 -2
  108. package/src/materials/ShadowMaterial.js +6 -2
  109. package/src/materials/SpriteMaterial.js +6 -2
  110. package/src/materials/nodes/NodeMaterial.js +31 -9
  111. package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
  112. package/src/materials/nodes/manager/NodeMaterialObserver.js +111 -2
  113. package/src/math/ColorManagement.js +118 -85
  114. package/src/math/Vector4.js +11 -0
  115. package/src/nodes/Nodes.js +1 -21
  116. package/src/nodes/TSL.js +6 -24
  117. package/src/nodes/accessors/Camera.js +0 -1
  118. package/src/nodes/accessors/SceneNode.js +35 -1
  119. package/src/nodes/accessors/StorageBufferNode.js +32 -10
  120. package/src/nodes/accessors/VelocityNode.js +13 -3
  121. package/src/nodes/code/FunctionCallNode.js +16 -5
  122. package/src/nodes/code/ScriptableNode.js +4 -4
  123. package/src/nodes/core/Node.js +1 -0
  124. package/src/nodes/core/NodeBuilder.js +29 -5
  125. package/src/nodes/core/VarNode.js +15 -3
  126. package/src/nodes/display/ColorAdjustment.js +53 -4
  127. package/src/nodes/display/ColorSpaceFunctions.js +5 -5
  128. package/src/nodes/display/ColorSpaceNode.js +27 -39
  129. package/src/nodes/display/PassNode.js +6 -4
  130. package/src/nodes/display/ToneMappingNode.js +1 -1
  131. package/src/nodes/display/ViewportDepthNode.js +33 -1
  132. package/src/nodes/functions/PhysicalLightingModel.js +21 -15
  133. package/src/nodes/functions/material/getAlphaHashThreshold.js +64 -0
  134. package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
  135. package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
  136. package/src/nodes/gpgpu/ComputeNode.js +9 -1
  137. package/src/nodes/lighting/AnalyticLightNode.js +12 -416
  138. package/src/nodes/lighting/LightsNode.js +24 -12
  139. package/src/nodes/lighting/PointLightNode.js +36 -26
  140. package/src/nodes/lighting/RectAreaLightNode.js +3 -0
  141. package/src/nodes/lighting/ShadowNode.js +484 -0
  142. package/src/nodes/utils/LoopNode.js +2 -2
  143. package/src/nodes/utils/Oscillators.js +6 -0
  144. package/src/nodes/utils/PostProcessingUtils.js +89 -0
  145. package/src/nodes/utils/ReflectorNode.js +101 -15
  146. package/src/nodes/utils/Timer.js +29 -0
  147. package/src/objects/BatchedMesh.js +458 -241
  148. package/src/renderers/WebGLRenderer.js +121 -126
  149. package/src/renderers/common/Attributes.js +4 -0
  150. package/src/renderers/common/Backend.js +2 -0
  151. package/src/renderers/common/Background.js +14 -4
  152. package/src/renderers/common/Bindings.js +3 -2
  153. package/src/renderers/common/Constants.js +2 -1
  154. package/src/renderers/common/Geometries.js +20 -0
  155. package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
  156. package/src/renderers/common/Lighting.js +45 -0
  157. package/src/renderers/common/PostProcessingUtils.js +86 -0
  158. package/src/renderers/common/RenderList.js +39 -11
  159. package/src/renderers/common/RenderLists.js +4 -2
  160. package/src/renderers/common/RenderObject.js +18 -1
  161. package/src/renderers/common/Renderer.js +165 -26
  162. package/src/renderers/common/Textures.js +30 -14
  163. package/src/renderers/common/nodes/NodeLibrary.js +1 -14
  164. package/src/renderers/common/nodes/Nodes.js +2 -2
  165. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
  166. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
  167. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
  168. package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
  169. package/src/renderers/webgl/WebGLCapabilities.js +0 -7
  170. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
  171. package/src/renderers/webgl/WebGLProgram.js +24 -28
  172. package/src/renderers/webgl/WebGLPrograms.js +5 -2
  173. package/src/renderers/webgl/WebGLState.js +37 -1
  174. package/src/renderers/webgl/WebGLTextures.js +29 -12
  175. package/src/renderers/webgl-fallback/WebGLBackend.js +98 -31
  176. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
  177. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +33 -8
  178. package/src/renderers/webgpu/WebGPUBackend.js +105 -25
  179. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
  180. package/src/renderers/webgpu/WebGPURenderer.js +1 -1
  181. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
  182. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -8
  183. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +10 -20
  184. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
  185. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
  186. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +24 -6
  187. package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
  188. package/src/renderers/webxr/WebXRManager.js +4 -4
  189. package/examples/jsm/cameras/CinematicCamera.js +0 -208
  190. package/src/nodes/display/FXAANode.js +0 -332
  191. package/src/nodes/utils/OscNode.js +0 -85
  192. package/src/nodes/utils/TimerNode.js +0 -97
  193. package/src/renderers/webvr/WebVRManager.js +0 -495
  194. package/src/renderers/webvr/WebVRUtils.js +0 -66
  195. /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
@@ -85,8 +85,15 @@ class NodeMaterialObserver {
85
85
 
86
86
  if ( data === undefined ) {
87
87
 
88
+ const { geometry, material } = renderObject;
89
+
88
90
  data = {
89
- material: this.getMaterialData( renderObject.material ),
91
+ material: this.getMaterialData( material ),
92
+ geometry: {
93
+ attributes: this.getAttributesData( geometry.attributes ),
94
+ indexVersion: geometry.index ? geometry.index.version : null,
95
+ drawRange: { start: geometry.drawRange.start, count: geometry.drawRange.count }
96
+ },
90
97
  worldMatrix: renderObject.object.matrixWorld.clone()
91
98
  };
92
99
 
@@ -108,6 +115,15 @@ class NodeMaterialObserver {
108
115
 
109
116
  }
110
117
 
118
+ if ( data.material.transmission > 0 ) {
119
+
120
+ const { width, height } = renderObject.context;
121
+
122
+ data.bufferWidth = width;
123
+ data.bufferHeight = height;
124
+
125
+ }
126
+
111
127
  this.renderObjects.set( renderObject, data );
112
128
 
113
129
  }
@@ -116,6 +132,24 @@ class NodeMaterialObserver {
116
132
 
117
133
  }
118
134
 
135
+ getAttributesData( attributes ) {
136
+
137
+ const attributesData = {};
138
+
139
+ for ( const name in attributes ) {
140
+
141
+ const attribute = attributes[ name ];
142
+
143
+ attributesData[ name ] = {
144
+ version: attribute.version
145
+ };
146
+
147
+ }
148
+
149
+ return attributesData;
150
+
151
+ }
152
+
119
153
  containsNode( builder ) {
120
154
 
121
155
  const material = builder.material;
@@ -170,7 +204,7 @@ class NodeMaterialObserver {
170
204
 
171
205
  equals( renderObject ) {
172
206
 
173
- const { object, material } = renderObject;
207
+ const { object, material, geometry } = renderObject;
174
208
 
175
209
  const renderObjectData = this.getRenderObjectData( renderObject );
176
210
 
@@ -224,6 +258,81 @@ class NodeMaterialObserver {
224
258
 
225
259
  }
226
260
 
261
+ if ( materialData.transmission > 0 ) {
262
+
263
+ const { width, height } = renderObject.context;
264
+
265
+ if ( renderObjectData.bufferWidth !== width || renderObjectData.bufferHeight !== height ) {
266
+
267
+ renderObjectData.bufferWidth = width;
268
+ renderObjectData.bufferHeight = height;
269
+
270
+ return false;
271
+
272
+ }
273
+
274
+ }
275
+
276
+ // geometry
277
+
278
+ const storedGeometryData = renderObjectData.geometry;
279
+ const attributes = geometry.attributes;
280
+ const storedAttributes = storedGeometryData.attributes;
281
+
282
+ const storedAttributeNames = Object.keys( storedAttributes );
283
+ const currentAttributeNames = Object.keys( attributes );
284
+
285
+ if ( storedAttributeNames.length !== currentAttributeNames.length ) {
286
+
287
+ renderObjectData.geometry.attributes = this.getAttributesData( attributes );
288
+ return false;
289
+
290
+ }
291
+
292
+ // Compare each attribute
293
+ for ( const name of storedAttributeNames ) {
294
+
295
+ const storedAttributeData = storedAttributes[ name ];
296
+ const attribute = attributes[ name ];
297
+
298
+ if ( attribute === undefined ) {
299
+
300
+ // Attribute was removed
301
+ delete storedAttributes[ name ];
302
+ return false;
303
+
304
+ }
305
+
306
+ if ( storedAttributeData.version !== attribute.version ) {
307
+
308
+ storedAttributeData.version = attribute.version;
309
+ return false;
310
+
311
+ }
312
+
313
+ }
314
+
315
+ // Check index
316
+ const index = geometry.index;
317
+ const storedIndexVersion = storedGeometryData.indexVersion;
318
+ const currentIndexVersion = index ? index.version : null;
319
+
320
+ if ( storedIndexVersion !== currentIndexVersion ) {
321
+
322
+ storedGeometryData.indexVersion = currentIndexVersion;
323
+ return false;
324
+
325
+ }
326
+
327
+ // Check drawRange
328
+ if ( storedGeometryData.drawRange.start !== geometry.drawRange.start || storedGeometryData.drawRange.count !== geometry.drawRange.count ) {
329
+
330
+ storedGeometryData.drawRange.start = geometry.drawRange.start;
331
+ storedGeometryData.drawRange.count = geometry.drawRange.count;
332
+ return false;
333
+
334
+ }
335
+
227
336
  // morph targets
228
337
 
229
338
  if ( renderObjectData.morphTargetInfluences ) {
@@ -1,121 +1,82 @@
1
- import { SRGBColorSpace, LinearSRGBColorSpace, DisplayP3ColorSpace, LinearDisplayP3ColorSpace, Rec709Primaries, P3Primaries, SRGBTransfer, LinearTransfer, NoColorSpace, } from '../constants.js';
1
+ import { SRGBColorSpace, LinearSRGBColorSpace, SRGBTransfer, LinearTransfer, NoColorSpace } from '../constants.js';
2
2
  import { Matrix3 } from './Matrix3.js';
3
3
 
4
- /**
5
- * Matrices converting P3 <-> Rec. 709 primaries, without gamut mapping
6
- * or clipping. Based on W3C specifications for sRGB and Display P3,
7
- * and ICC specifications for the D50 connection space. Values in/out
8
- * are _linear_ sRGB and _linear_ Display P3.
9
- *
10
- * Note that both sRGB and Display P3 use the sRGB transfer functions.
11
- *
12
- * Reference:
13
- * - http://www.russellcottrell.com/photo/matrixCalculator.htm
14
- */
15
-
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
- );
21
-
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
- );
27
-
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
- luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
37
- toReference: ( color ) => color,
38
- fromReference: ( color ) => color,
39
- },
40
- [ SRGBColorSpace ]: {
41
- transfer: SRGBTransfer,
42
- primaries: Rec709Primaries,
43
- luminanceCoefficients: [ 0.2126, 0.7152, 0.0722 ],
44
- toReference: ( color ) => color.convertSRGBToLinear(),
45
- fromReference: ( color ) => color.convertLinearToSRGB(),
46
- },
47
- [ LinearDisplayP3ColorSpace ]: {
48
- transfer: LinearTransfer,
49
- primaries: P3Primaries,
50
- luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
51
- toReference: ( color ) => color.applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
52
- fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ),
53
- },
54
- [ DisplayP3ColorSpace ]: {
55
- transfer: SRGBTransfer,
56
- primaries: P3Primaries,
57
- luminanceCoefficients: [ 0.2289, 0.6917, 0.0793 ],
58
- toReference: ( color ) => color.convertSRGBToLinear().applyMatrix3( LINEAR_DISPLAY_P3_TO_LINEAR_SRGB ),
59
- fromReference: ( color ) => color.applyMatrix3( LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 ).convertLinearToSRGB(),
60
- },
61
- };
62
-
63
- const SUPPORTED_WORKING_COLOR_SPACES = new Set( [ LinearSRGBColorSpace, LinearDisplayP3ColorSpace ] );
64
-
65
4
  export const ColorManagement = {
66
5
 
67
6
  enabled: true,
68
7
 
69
- _workingColorSpace: LinearSRGBColorSpace,
8
+ workingColorSpace: LinearSRGBColorSpace,
9
+
10
+ /**
11
+ * Implementations of supported color spaces.
12
+ *
13
+ * Required:
14
+ * - primaries: chromaticity coordinates [ rx ry gx gy bx by ]
15
+ * - whitePoint: reference white [ x y ]
16
+ * - transfer: transfer function (pre-defined)
17
+ * - toXYZ: Matrix3 RGB to XYZ transform
18
+ * - fromXYZ: Matrix3 XYZ to RGB transform
19
+ * - luminanceCoefficients: RGB luminance coefficients
20
+ *
21
+ * Optional:
22
+ * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace }
23
+ * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
24
+ *
25
+ * Reference:
26
+ * - https://www.russellcottrell.com/photo/matrixCalculator.htm
27
+ */
28
+ spaces: {},
70
29
 
71
- get workingColorSpace() {
30
+ convert: function ( color, sourceColorSpace, targetColorSpace ) {
72
31
 
73
- return this._workingColorSpace;
32
+ if ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
74
33
 
75
- },
34
+ return color;
76
35
 
77
- set workingColorSpace( colorSpace ) {
36
+ }
78
37
 
79
- if ( ! SUPPORTED_WORKING_COLOR_SPACES.has( colorSpace ) ) {
38
+ if ( this.spaces[ sourceColorSpace ].transfer === SRGBTransfer ) {
80
39
 
81
- throw new Error( `Unsupported working color space, "${ colorSpace }".` );
40
+ color.r = SRGBToLinear( color.r );
41
+ color.g = SRGBToLinear( color.g );
42
+ color.b = SRGBToLinear( color.b );
82
43
 
83
44
  }
84
45
 
85
- this._workingColorSpace = colorSpace;
46
+ if ( this.spaces[ sourceColorSpace ].primaries !== this.spaces[ targetColorSpace ].primaries ) {
86
47
 
87
- },
48
+ color.applyMatrix3( this.spaces[ sourceColorSpace ].toXYZ );
49
+ color.applyMatrix3( this.spaces[ targetColorSpace ].fromXYZ );
88
50
 
89
- convert: function ( color, sourceColorSpace, targetColorSpace ) {
51
+ }
90
52
 
91
- if ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
53
+ if ( this.spaces[ targetColorSpace ].transfer === SRGBTransfer ) {
92
54
 
93
- return color;
55
+ color.r = LinearToSRGB( color.r );
56
+ color.g = LinearToSRGB( color.g );
57
+ color.b = LinearToSRGB( color.b );
94
58
 
95
59
  }
96
60
 
97
- const sourceToReference = COLOR_SPACES[ sourceColorSpace ].toReference;
98
- const targetFromReference = COLOR_SPACES[ targetColorSpace ].fromReference;
99
-
100
- return targetFromReference( sourceToReference( color ) );
61
+ return color;
101
62
 
102
63
  },
103
64
 
104
65
  fromWorkingColorSpace: function ( color, targetColorSpace ) {
105
66
 
106
- return this.convert( color, this._workingColorSpace, targetColorSpace );
67
+ return this.convert( color, this.workingColorSpace, targetColorSpace );
107
68
 
108
69
  },
109
70
 
110
71
  toWorkingColorSpace: function ( color, sourceColorSpace ) {
111
72
 
112
- return this.convert( color, sourceColorSpace, this._workingColorSpace );
73
+ return this.convert( color, sourceColorSpace, this.workingColorSpace );
113
74
 
114
75
  },
115
76
 
116
77
  getPrimaries: function ( colorSpace ) {
117
78
 
118
- return COLOR_SPACES[ colorSpace ].primaries;
79
+ return this.spaces[ colorSpace ].primaries;
119
80
 
120
81
  },
121
82
 
@@ -123,18 +84,45 @@ export const ColorManagement = {
123
84
 
124
85
  if ( colorSpace === NoColorSpace ) return LinearTransfer;
125
86
 
126
- return COLOR_SPACES[ colorSpace ].transfer;
87
+ return this.spaces[ colorSpace ].transfer;
127
88
 
128
89
  },
129
90
 
130
- getLuminanceCoefficients: function ( target, colorSpace = this._workingColorSpace ) {
91
+ getLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {
131
92
 
132
- return target.fromArray( COLOR_SPACES[ colorSpace ].luminanceCoefficients );
93
+ return target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );
133
94
 
134
95
  },
135
96
 
136
- };
97
+ define: function ( colorSpaces ) {
137
98
 
99
+ Object.assign( this.spaces, colorSpaces );
100
+
101
+ },
102
+
103
+ // Internal APIs
104
+
105
+ _getMatrix: function ( targetMatrix, sourceColorSpace, targetColorSpace ) {
106
+
107
+ return targetMatrix
108
+ .copy( this.spaces[ sourceColorSpace ].toXYZ )
109
+ .multiply( this.spaces[ targetColorSpace ].fromXYZ );
110
+
111
+ },
112
+
113
+ _getDrawingBufferColorSpace: function ( colorSpace ) {
114
+
115
+ return this.spaces[ colorSpace ].outputColorSpaceConfig.drawingBufferColorSpace;
116
+
117
+ },
118
+
119
+ _getUnpackColorSpace: function ( colorSpace = this.workingColorSpace ) {
120
+
121
+ return this.spaces[ colorSpace ].workingColorSpaceConfig.unpackColorSpace;
122
+
123
+ }
124
+
125
+ };
138
126
 
139
127
  export function SRGBToLinear( c ) {
140
128
 
@@ -147,3 +135,48 @@ export function LinearToSRGB( c ) {
147
135
  return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
148
136
 
149
137
  }
138
+
139
+ /******************************************************************************
140
+ * sRGB definitions
141
+ */
142
+
143
+ const REC709_PRIMARIES = [ 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 ];
144
+ const REC709_LUMINANCE_COEFFICIENTS = [ 0.2126, 0.7152, 0.0722 ];
145
+ const D65 = [ 0.3127, 0.3290 ];
146
+
147
+ const LINEAR_REC709_TO_XYZ = /*@__PURE__*/ new Matrix3().set(
148
+ 0.4123908, 0.3575843, 0.1804808,
149
+ 0.2126390, 0.7151687, 0.0721923,
150
+ 0.0193308, 0.1191948, 0.9505322
151
+ );
152
+
153
+ const XYZ_TO_LINEAR_REC709 = /*@__PURE__*/ new Matrix3().set(
154
+ 3.2409699, - 1.5373832, - 0.4986108,
155
+ - 0.9692436, 1.8759675, 0.0415551,
156
+ 0.0556301, - 0.2039770, 1.0569715
157
+ );
158
+
159
+ ColorManagement.define( {
160
+
161
+ [ LinearSRGBColorSpace ]: {
162
+ primaries: REC709_PRIMARIES,
163
+ whitePoint: D65,
164
+ transfer: LinearTransfer,
165
+ toXYZ: LINEAR_REC709_TO_XYZ,
166
+ fromXYZ: XYZ_TO_LINEAR_REC709,
167
+ luminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,
168
+ workingColorSpaceConfig: { unpackColorSpace: SRGBColorSpace },
169
+ outputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }
170
+ },
171
+
172
+ [ SRGBColorSpace ]: {
173
+ primaries: REC709_PRIMARIES,
174
+ whitePoint: D65,
175
+ transfer: SRGBTransfer,
176
+ toXYZ: LINEAR_REC709_TO_XYZ,
177
+ fromXYZ: XYZ_TO_LINEAR_REC709,
178
+ luminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,
179
+ outputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }
180
+ },
181
+
182
+ } );
@@ -249,6 +249,17 @@ class Vector4 {
249
249
 
250
250
  }
251
251
 
252
+ divide( v ) {
253
+
254
+ this.x /= v.x;
255
+ this.y /= v.y;
256
+ this.z /= v.z;
257
+ this.w /= v.w;
258
+
259
+ return this;
260
+
261
+ }
262
+
252
263
  divideScalar( scalar ) {
253
264
 
254
265
  return this.multiplyScalar( 1 / scalar );
@@ -43,14 +43,12 @@ export { default as JoinNode } from './utils/JoinNode.js';
43
43
  export { default as LoopNode } from './utils/LoopNode.js';
44
44
  export { default as MatcapUVNode } from './utils/MatcapUVNode.js';
45
45
  export { default as MaxMipLevelNode } from './utils/MaxMipLevelNode.js';
46
- export { default as OscNode } from './utils/OscNode.js';
47
46
  export { default as RemapNode } from './utils/RemapNode.js';
48
47
  export { default as RotateNode } from './utils/RotateNode.js';
49
48
  export { default as SetNode } from './utils/SetNode.js';
50
49
  export { default as SplitNode } from './utils/SplitNode.js';
51
50
  export { default as SpriteSheetUVNode } from './utils/SpriteSheetUVNode.js';
52
51
  export { default as StorageArrayElementNode } from './utils/StorageArrayElementNode.js';
53
- export { default as TimerNode } from './utils/TimerNode.js';
54
52
  export { default as TriplanarTexturesNode } from './utils/TriplanarTexturesNode.js';
55
53
  export { default as ReflectorNode } from './utils/ReflectorNode.js';
56
54
  export { default as RTTNode } from './utils/RTTNode.js';
@@ -93,26 +91,7 @@ export { default as ViewportTextureNode } from './display/ViewportTextureNode.js
93
91
  export { default as ViewportSharedTextureNode } from './display/ViewportSharedTextureNode.js';
94
92
  export { default as ViewportDepthTextureNode } from './display/ViewportDepthTextureNode.js';
95
93
  export { default as ViewportDepthNode } from './display/ViewportDepthNode.js';
96
- export { default as GaussianBlurNode } from './display/GaussianBlurNode.js';
97
- export { default as AfterImageNode } from './display/AfterImageNode.js';
98
- export { default as AnamorphicNode } from './display/AnamorphicNode.js';
99
- export { default as SobelOperatorNode } from './display/SobelOperatorNode.js';
100
- export { default as DepthOfFieldNode } from './display/DepthOfFieldNode.js';
101
- export { default as DotScreenNode } from './display/DotScreenNode.js';
102
- export { default as RGBShiftNode } from './display/RGBShiftNode.js';
103
- export { default as FilmNode } from './display/FilmNode.js';
104
- export { default as Lut3DNode } from './display/Lut3DNode.js';
105
- export { default as GTAONode } from './display/GTAONode.js';
106
- export { default as DenoiseNode } from './display/DenoiseNode.js';
107
- export { default as FXAANode } from './display/FXAANode.js';
108
- export { default as BloomNode } from './display/BloomNode.js';
109
- export { default as TransitionNode } from './display/TransitionNode.js';
110
94
  export { default as RenderOutputNode } from './display/RenderOutputNode.js';
111
- export { default as PixelationPassNode } from './display/PixelationPassNode.js';
112
- export { default as SSAAPassNode } from './display/SSAAPassNode.js';
113
- export { default as StereoPassNode } from './display/StereoPassNode.js';
114
- export { default as AnaglyphPassNode } from './display/AnaglyphPassNode.js';
115
- export { default as ParallaxBarrierPassNode } from './display/ParallaxBarrierPassNode.js';
116
95
  export { default as PassNode } from './display/PassNode.js';
117
96
  export { default as ToonOutlinePassNode } from './display/ToonOutlinePassNode.js';
118
97
 
@@ -152,6 +131,7 @@ export { default as BasicEnvironmentNode } from './lighting/BasicEnvironmentNode
152
131
  export { default as IrradianceNode } from './lighting/IrradianceNode.js';
153
132
  export { default as AONode } from './lighting/AONode.js';
154
133
  export { default as AnalyticLightNode } from './lighting/AnalyticLightNode.js';
134
+ export { default as ShadowNode } from './lighting/ShadowNode.js';
155
135
 
156
136
  // pmrem
157
137
  export { default as PMREMNode } from './pmrem/PMREMNode.js';
package/src/nodes/TSL.js CHANGED
@@ -28,7 +28,7 @@ export * from './utils/FunctionOverloadingNode.js';
28
28
  export * from './utils/LoopNode.js';
29
29
  export * from './utils/MatcapUVNode.js';
30
30
  export * from './utils/MaxMipLevelNode.js';
31
- export * from './utils/OscNode.js';
31
+ export * from './utils/Oscillators.js';
32
32
  export * from './utils/Packing.js';
33
33
  export * from './utils/RemapNode.js';
34
34
  export * from './utils/UVUtils.js';
@@ -36,10 +36,11 @@ export * from './utils/SpriteUtils.js';
36
36
  export * from './utils/ViewportUtils.js';
37
37
  export * from './utils/RotateNode.js';
38
38
  export * from './utils/SpriteSheetUVNode.js';
39
- export * from './utils/TimerNode.js';
39
+ export * from './utils/Timer.js';
40
40
  export * from './utils/TriplanarTexturesNode.js';
41
41
  export * from './utils/ReflectorNode.js';
42
42
  export * from './utils/RTTNode.js';
43
+ export * from './utils/PostProcessingUtils.js';
43
44
 
44
45
  // three.js shading language
45
46
  export * from './tsl/TSLBase.js';
@@ -95,29 +96,7 @@ export * from './display/ViewportTextureNode.js';
95
96
  export * from './display/ViewportSharedTextureNode.js';
96
97
  export * from './display/ViewportDepthTextureNode.js';
97
98
  export * from './display/ViewportDepthNode.js';
98
- export * from './display/GaussianBlurNode.js';
99
- export * from './display/AfterImageNode.js';
100
- export * from './display/AnamorphicNode.js';
101
- export * from './display/SobelOperatorNode.js';
102
- export * from './display/DepthOfFieldNode.js';
103
- export * from './display/DotScreenNode.js';
104
- export * from './display/RGBShiftNode.js';
105
- export * from './display/FilmNode.js';
106
- export * from './display/Lut3DNode.js';
107
- export * from './display/MotionBlur.js';
108
- export * from './display/GTAONode.js';
109
- export * from './display/DenoiseNode.js';
110
- export * from './display/FXAANode.js';
111
- export * from './display/BloomNode.js';
112
- export * from './display/TransitionNode.js';
113
99
  export * from './display/RenderOutputNode.js';
114
- export * from './display/PixelationPassNode.js';
115
- export * from './display/SSAAPassNode.js';
116
- export * from './display/StereoPassNode.js';
117
- export * from './display/AnaglyphPassNode.js';
118
- export * from './display/ParallaxBarrierPassNode.js';
119
- export * from './display/BleachBypass.js';
120
- export * from './display/Sepia.js';
121
100
  export * from './display/ToonOutlinePassNode.js';
122
101
 
123
102
  export * from './display/PassNode.js';
@@ -152,6 +131,8 @@ export * from './gpgpu/AtomicFunctionNode.js';
152
131
  export * from './accessors/Lights.js';
153
132
  export * from './lighting/LightsNode.js';
154
133
  export * from './lighting/LightingContextNode.js';
134
+ export * from './lighting/ShadowNode.js';
135
+ export * from './lighting/PointLightNode.js';
155
136
 
156
137
  // pmrem
157
138
  export * from './pmrem/PMREMNode.js';
@@ -175,5 +156,6 @@ export { default as V_GGX_SmithCorrelated } from './functions/BSDF/V_GGX_SmithCo
175
156
  export * from './lighting/LightUtils.js';
176
157
 
177
158
  export { default as getGeometryRoughness } from './functions/material/getGeometryRoughness.js';
159
+ export { default as getParallaxCorrectNormal } from './functions/material/getParallaxCorrectNormal.js';
178
160
  export { default as getRoughness } from './functions/material/getRoughness.js';
179
161
  export { default as getShIrradianceAt } from './functions/material/getShIrradianceAt.js';
@@ -4,7 +4,6 @@ import { Vector3 } from '../../math/Vector3.js';
4
4
 
5
5
  export const cameraNear = /*@__PURE__*/ uniform( 'float' ).label( 'cameraNear' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.near );
6
6
  export const cameraFar = /*@__PURE__*/ uniform( 'float' ).label( 'cameraFar' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.far );
7
- export const cameraLogDepth = /*@__PURE__*/ uniform( 'float' ).label( 'cameraLogDepth' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
8
7
  export const cameraProjectionMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrix' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrix );
9
8
  export const cameraProjectionMatrixInverse = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrixInverse' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrixInverse );
10
9
  export const cameraViewMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraViewMatrix' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorldInverse );
@@ -1,7 +1,14 @@
1
+ import { UVMapping } from '../../constants.js';
2
+ import { Euler } from '../../math/Euler.js';
3
+ import { Matrix4 } from '../../math/Matrix4.js';
1
4
  import Node from '../core/Node.js';
2
- import { nodeImmutable } from '../tsl/TSLBase.js';
5
+ import { renderGroup } from '../core/UniformGroupNode.js';
6
+ import { nodeImmutable, uniform } from '../tsl/TSLBase.js';
3
7
  import { reference } from './ReferenceNode.js';
4
8
 
9
+ const _e1 = /*@__PURE__*/ new Euler();
10
+ const _m1 = /*@__PURE__*/ new Matrix4();
11
+
5
12
  class SceneNode extends Node {
6
13
 
7
14
  static get type() {
@@ -34,6 +41,31 @@ class SceneNode extends Node {
34
41
 
35
42
  output = reference( 'backgroundIntensity', 'float', scene );
36
43
 
44
+ } else if ( scope === SceneNode.BACKGROUND_ROTATION ) {
45
+
46
+ output = uniform( 'mat4' ).label( 'backgroundRotation' ).setGroup( renderGroup ).onRenderUpdate( () => {
47
+
48
+ const background = scene.background;
49
+
50
+ if ( background !== null && background.isTexture && background.mapping !== UVMapping ) {
51
+
52
+ _e1.copy( scene.backgroundRotation );
53
+
54
+ // accommodate left-handed frame
55
+ _e1.x *= - 1; _e1.y *= - 1; _e1.z *= - 1;
56
+
57
+ _m1.makeRotationFromEuler( _e1 );
58
+
59
+ } else {
60
+
61
+ _m1.identity();
62
+
63
+ }
64
+
65
+ return _m1;
66
+
67
+ } );
68
+
37
69
  } else {
38
70
 
39
71
  console.error( 'THREE.SceneNode: Unknown scope:', scope );
@@ -48,8 +80,10 @@ class SceneNode extends Node {
48
80
 
49
81
  SceneNode.BACKGROUND_BLURRINESS = 'backgroundBlurriness';
50
82
  SceneNode.BACKGROUND_INTENSITY = 'backgroundIntensity';
83
+ SceneNode.BACKGROUND_ROTATION = 'backgroundRotation';
51
84
 
52
85
  export default SceneNode;
53
86
 
54
87
  export const backgroundBlurriness = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_BLURRINESS );
55
88
  export const backgroundIntensity = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_INTENSITY );
89
+ export const backgroundRotation = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_ROTATION );
@@ -66,7 +66,7 @@ class StorageBufferNode extends BufferNode {
66
66
 
67
67
  getInputType( /*builder*/ ) {
68
68
 
69
- return 'storageBuffer';
69
+ return this.value.isIndirectStorageBufferAttribute ? 'indirectStorageBuffer' : 'storageBuffer';
70
70
 
71
71
  }
72
72
 
@@ -112,27 +112,49 @@ class StorageBufferNode extends BufferNode {
112
112
 
113
113
  }
114
114
 
115
- generate( builder ) {
115
+ getAttributeData() {
116
116
 
117
- if ( builder.isAvailable( 'storageBuffer' ) ) {
117
+ if ( this._attribute === null ) {
118
118
 
119
- return super.generate( builder );
119
+ this._attribute = bufferAttribute( this.value );
120
+ this._varying = varying( this._attribute );
120
121
 
121
122
  }
122
123
 
123
- const nodeType = this.getNodeType( builder );
124
+ return {
125
+ attribute: this._attribute,
126
+ varying: this._varying
127
+ };
124
128
 
125
- if ( this._attribute === null ) {
129
+ }
126
130
 
127
- this._attribute = bufferAttribute( this.value );
128
- this._varying = varying( this._attribute );
131
+ getNodeType( builder ) {
132
+
133
+ if ( builder.isAvailable( 'storageBuffer' ) || builder.isAvailable( 'indirectStorageBuffer' ) ) {
134
+
135
+ return super.getNodeType( builder );
136
+
137
+ }
138
+
139
+ const { attribute } = this.getAttributeData();
140
+
141
+ return attribute.getNodeType( builder );
142
+
143
+ }
144
+
145
+ generate( builder ) {
146
+
147
+ if ( builder.isAvailable( 'storageBuffer' ) || builder.isAvailable( 'indirectStorageBuffer' ) ) {
148
+
149
+ return super.generate( builder );
129
150
 
130
151
  }
131
152
 
153
+ const { attribute, varying } = this.getAttributeData();
132
154
 
133
- const output = this._varying.build( builder, nodeType );
155
+ const output = varying.build( builder );
134
156
 
135
- builder.registerTransform( output, this._attribute );
157
+ builder.registerTransform( output, attribute );
136
158
 
137
159
  return output;
138
160