super-three 0.170.0 → 0.170.1

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 (172) hide show
  1. package/build/three.cjs +24410 -24422
  2. package/build/three.core.js +37002 -0
  3. package/build/three.core.min.js +6 -0
  4. package/build/three.module.js +10573 -47578
  5. package/build/three.module.min.js +1 -1
  6. package/build/three.tsl.js +533 -0
  7. package/build/three.tsl.min.js +6 -0
  8. package/build/three.webgpu.js +2907 -37975
  9. package/build/three.webgpu.min.js +1 -1
  10. package/build/three.webgpu.nodes.js +2914 -37959
  11. package/build/three.webgpu.nodes.min.js +1 -1
  12. package/examples/jsm/capabilities/WebGPU.js +1 -10
  13. package/examples/jsm/controls/ArcballControls.js +25 -21
  14. package/examples/jsm/controls/OrbitControls.js +41 -9
  15. package/examples/jsm/controls/PointerLockControls.js +2 -5
  16. package/examples/jsm/csm/CSMShadowNode.js +7 -5
  17. package/examples/jsm/geometries/DecalGeometry.js +5 -1
  18. package/examples/jsm/lighting/TiledLighting.js +1 -1
  19. package/examples/jsm/lines/LineGeometry.js +25 -0
  20. package/examples/jsm/lines/LineMaterial.js +1 -7
  21. package/examples/jsm/lines/webgpu/Line2.js +2 -1
  22. package/examples/jsm/lines/webgpu/LineSegments2.js +2 -1
  23. package/examples/jsm/lines/webgpu/Wireframe.js +2 -1
  24. package/examples/jsm/loaders/KTX2Loader.js +3 -0
  25. package/examples/jsm/loaders/MMDLoader.js +2 -6
  26. package/examples/jsm/loaders/MaterialXLoader.js +2 -2
  27. package/examples/jsm/materials/MeshGouraudMaterial.js +2 -6
  28. package/examples/jsm/misc/ProgressiveLightMapGPU.js +2 -2
  29. package/examples/jsm/objects/InstancedPoints.js +2 -4
  30. package/examples/jsm/objects/LensflareMesh.js +4 -2
  31. package/examples/jsm/objects/SkyMesh.js +5 -3
  32. package/examples/jsm/objects/Water2Mesh.js +7 -3
  33. package/examples/jsm/objects/WaterMesh.js +5 -3
  34. package/examples/jsm/transpiler/AST.js +2 -2
  35. package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
  36. package/examples/jsm/transpiler/TSLEncoder.js +11 -6
  37. package/examples/jsm/tsl/display/AfterImageNode.js +3 -3
  38. package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -2
  39. package/examples/jsm/tsl/display/AnamorphicNode.js +2 -2
  40. package/examples/jsm/tsl/display/BloomNode.js +3 -3
  41. package/examples/jsm/tsl/display/DenoiseNode.js +48 -12
  42. package/examples/jsm/tsl/display/DepthOfFieldNode.js +3 -2
  43. package/examples/jsm/tsl/display/DotScreenNode.js +2 -2
  44. package/examples/jsm/tsl/display/FXAANode.js +3 -3
  45. package/examples/jsm/tsl/display/FilmNode.js +3 -2
  46. package/examples/jsm/tsl/display/GTAONode.js +62 -27
  47. package/examples/jsm/tsl/display/GaussianBlurNode.js +6 -8
  48. package/examples/jsm/tsl/display/LensflareNode.js +3 -3
  49. package/examples/jsm/tsl/display/Lut3DNode.js +3 -2
  50. package/examples/jsm/tsl/display/OutlineNode.js +2 -2
  51. package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -1
  52. package/examples/jsm/tsl/display/PixelationPassNode.js +4 -4
  53. package/examples/jsm/tsl/display/RGBShiftNode.js +2 -1
  54. package/examples/jsm/tsl/display/SMAANode.js +3 -3
  55. package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
  56. package/examples/jsm/tsl/display/SSRNode.js +31 -8
  57. package/examples/jsm/tsl/display/SobelOperatorNode.js +3 -3
  58. package/examples/jsm/tsl/display/StereoCompositePassNode.js +4 -4
  59. package/examples/jsm/tsl/display/StereoPassNode.js +2 -2
  60. package/examples/jsm/tsl/display/TRAAPassNode.js +2 -2
  61. package/examples/jsm/tsl/display/TransitionNode.js +3 -2
  62. package/examples/jsm/tsl/lighting/TiledLightsNode.js +6 -9
  63. package/examples/jsm/utils/SceneOptimizer.js +410 -0
  64. package/examples/jsm/utils/UVsDebug.js +1 -1
  65. package/package.json +3 -3
  66. package/src/Three.Core.js +178 -0
  67. package/src/Three.TSL.js +526 -0
  68. package/src/Three.WebGPU.Nodes.js +5 -186
  69. package/src/Three.WebGPU.js +4 -186
  70. package/src/Three.js +1 -177
  71. package/src/animation/AnimationClip.js +2 -2
  72. package/src/animation/AnimationObjectGroup.js +2 -2
  73. package/src/audio/Audio.js +38 -0
  74. package/src/cameras/PerspectiveCamera.js +6 -6
  75. package/src/cameras/StereoCamera.js +2 -2
  76. package/src/constants.js +1 -1
  77. package/src/core/BufferGeometry.js +5 -3
  78. package/src/core/InterleavedBuffer.js +4 -4
  79. package/src/core/Object3D.js +2 -2
  80. package/src/extras/core/Curve.js +3 -3
  81. package/src/extras/core/Shape.js +2 -2
  82. package/src/geometries/EdgesGeometry.js +2 -2
  83. package/src/geometries/LatheGeometry.js +2 -2
  84. package/src/lights/SpotLightShadow.js +2 -2
  85. package/src/materials/LineBasicMaterial.js +2 -6
  86. package/src/materials/LineDashedMaterial.js +1 -6
  87. package/src/materials/Material.js +3 -16
  88. package/src/materials/MeshBasicMaterial.js +2 -6
  89. package/src/materials/MeshDepthMaterial.js +2 -6
  90. package/src/materials/MeshDistanceMaterial.js +2 -6
  91. package/src/materials/MeshLambertMaterial.js +2 -6
  92. package/src/materials/MeshMatcapMaterial.js +2 -6
  93. package/src/materials/MeshNormalMaterial.js +2 -6
  94. package/src/materials/MeshPhongMaterial.js +3 -7
  95. package/src/materials/MeshPhysicalMaterial.js +4 -8
  96. package/src/materials/MeshStandardMaterial.js +2 -6
  97. package/src/materials/MeshToonMaterial.js +2 -6
  98. package/src/materials/PointsMaterial.js +2 -6
  99. package/src/materials/RawShaderMaterial.js +2 -6
  100. package/src/materials/ShaderMaterial.js +2 -6
  101. package/src/materials/ShadowMaterial.js +2 -6
  102. package/src/materials/SpriteMaterial.js +2 -6
  103. package/src/materials/nodes/Line2NodeMaterial.js +32 -13
  104. package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
  105. package/src/materials/nodes/NodeMaterial.js +64 -16
  106. package/src/materials/nodes/manager/NodeMaterialObserver.js +13 -10
  107. package/src/math/ColorManagement.js +130 -122
  108. package/src/math/Line3.js +2 -2
  109. package/src/math/Quaternion.js +2 -2
  110. package/src/math/Spherical.js +3 -3
  111. package/src/math/Vector2.js +7 -7
  112. package/src/math/Vector3.js +9 -9
  113. package/src/math/Vector4.js +11 -9
  114. package/src/nodes/Nodes.js +1 -0
  115. package/src/nodes/TSL.js +3 -1
  116. package/src/nodes/accessors/Arrays.js +27 -0
  117. package/src/nodes/accessors/BuiltinNode.js +26 -0
  118. package/src/nodes/accessors/ClippingNode.js +76 -42
  119. package/src/nodes/accessors/InstanceNode.js +17 -20
  120. package/src/nodes/accessors/InstancedMeshNode.js +26 -0
  121. package/src/nodes/accessors/Lights.js +32 -0
  122. package/src/nodes/accessors/StorageBufferNode.js +29 -9
  123. package/src/nodes/accessors/StorageTextureNode.js +10 -4
  124. package/src/nodes/accessors/TextureNode.js +1 -1
  125. package/src/nodes/core/NodeBuilder.js +2 -9
  126. package/src/nodes/core/NodeUtils.js +28 -0
  127. package/src/nodes/core/constants.js +6 -0
  128. package/src/nodes/display/BlendModes.js +99 -0
  129. package/src/nodes/display/ToonOutlinePassNode.js +3 -3
  130. package/src/nodes/display/ViewportDepthNode.js +21 -6
  131. package/src/nodes/functions/material/getAlphaHashThreshold.js +13 -7
  132. package/src/nodes/functions/material/getParallaxCorrectNormal.js +1 -1
  133. package/src/nodes/lighting/AnalyticLightNode.js +12 -4
  134. package/src/nodes/lighting/PointLightNode.js +10 -1
  135. package/src/nodes/lighting/PointShadowNode.js +254 -0
  136. package/src/nodes/lighting/ShadowNode.js +176 -67
  137. package/src/nodes/lighting/SpotLightNode.js +14 -2
  138. package/src/nodes/utils/RTTNode.js +9 -1
  139. package/src/nodes/utils/StorageArrayElementNode.js +2 -2
  140. package/src/objects/BatchedMesh.js +54 -95
  141. package/src/objects/ClippingGroup.js +19 -0
  142. package/src/objects/Skeleton.js +2 -2
  143. package/src/renderers/WebGLRenderer.js +94 -23
  144. package/src/renderers/common/Animation.js +23 -11
  145. package/src/renderers/common/Background.js +1 -1
  146. package/src/renderers/common/Bindings.js +20 -4
  147. package/src/renderers/common/ClippingContext.js +77 -85
  148. package/src/renderers/common/RenderList.js +9 -6
  149. package/src/renderers/common/RenderObject.js +27 -27
  150. package/src/renderers/common/RenderObjects.js +12 -6
  151. package/src/renderers/common/Renderer.js +63 -57
  152. package/src/renderers/common/Textures.js +11 -3
  153. package/src/renderers/common/UniformsGroup.js +16 -4
  154. package/src/renderers/common/extras/PMREMGenerator.js +89 -13
  155. package/src/renderers/common/nodes/NodeLibrary.js +2 -2
  156. package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
  157. package/src/renderers/common/nodes/NodeUniform.js +42 -0
  158. package/src/renderers/webgl/WebGLBackground.js +20 -1
  159. package/src/renderers/webgl/WebGLGeometries.js +0 -28
  160. package/src/renderers/webgl-fallback/WebGLBackend.js +13 -6
  161. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
  162. package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
  163. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +4 -1
  164. package/src/renderers/webgpu/WebGPUBackend.js +47 -31
  165. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -26
  166. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +184 -74
  167. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
  168. package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
  169. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -1
  170. package/src/textures/Source.js +2 -2
  171. package/src/textures/Texture.js +2 -2
  172. package/src/nodes/display/BlendMode.js +0 -54
@@ -1,182 +1,190 @@
1
1
  import { SRGBColorSpace, LinearSRGBColorSpace, SRGBTransfer, LinearTransfer, NoColorSpace } from '../constants.js';
2
2
  import { Matrix3 } from './Matrix3.js';
3
3
 
4
- export const ColorManagement = {
5
-
6
- enabled: true,
7
-
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: {},
4
+ const LINEAR_REC709_TO_XYZ = /*@__PURE__*/ new Matrix3().set(
5
+ 0.4123908, 0.3575843, 0.1804808,
6
+ 0.2126390, 0.7151687, 0.0721923,
7
+ 0.0193308, 0.1191948, 0.9505322
8
+ );
29
9
 
30
- convert: function ( color, sourceColorSpace, targetColorSpace ) {
10
+ const XYZ_TO_LINEAR_REC709 = /*@__PURE__*/ new Matrix3().set(
11
+ 3.2409699, - 1.5373832, - 0.4986108,
12
+ - 0.9692436, 1.8759675, 0.0415551,
13
+ 0.0556301, - 0.2039770, 1.0569715
14
+ );
31
15
 
32
- if ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
16
+ function createColorManagement() {
33
17
 
34
- return color;
18
+ const ColorManagement = {
35
19
 
36
- }
20
+ enabled: true,
37
21
 
38
- if ( this.spaces[ sourceColorSpace ].transfer === SRGBTransfer ) {
22
+ workingColorSpace: LinearSRGBColorSpace,
39
23
 
40
- color.r = SRGBToLinear( color.r );
41
- color.g = SRGBToLinear( color.g );
42
- color.b = SRGBToLinear( color.b );
24
+ /**
25
+ * Implementations of supported color spaces.
26
+ *
27
+ * Required:
28
+ * - primaries: chromaticity coordinates [ rx ry gx gy bx by ]
29
+ * - whitePoint: reference white [ x y ]
30
+ * - transfer: transfer function (pre-defined)
31
+ * - toXYZ: Matrix3 RGB to XYZ transform
32
+ * - fromXYZ: Matrix3 XYZ to RGB transform
33
+ * - luminanceCoefficients: RGB luminance coefficients
34
+ *
35
+ * Optional:
36
+ * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace }
37
+ * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
38
+ *
39
+ * Reference:
40
+ * - https://www.russellcottrell.com/photo/matrixCalculator.htm
41
+ */
42
+ spaces: {},
43
43
 
44
- }
44
+ convert: function ( color, sourceColorSpace, targetColorSpace ) {
45
45
 
46
- if ( this.spaces[ sourceColorSpace ].primaries !== this.spaces[ targetColorSpace ].primaries ) {
46
+ if ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
47
47
 
48
- color.applyMatrix3( this.spaces[ sourceColorSpace ].toXYZ );
49
- color.applyMatrix3( this.spaces[ targetColorSpace ].fromXYZ );
48
+ return color;
50
49
 
51
- }
50
+ }
52
51
 
53
- if ( this.spaces[ targetColorSpace ].transfer === SRGBTransfer ) {
52
+ if ( this.spaces[ sourceColorSpace ].transfer === SRGBTransfer ) {
54
53
 
55
- color.r = LinearToSRGB( color.r );
56
- color.g = LinearToSRGB( color.g );
57
- color.b = LinearToSRGB( color.b );
54
+ color.r = SRGBToLinear( color.r );
55
+ color.g = SRGBToLinear( color.g );
56
+ color.b = SRGBToLinear( color.b );
58
57
 
59
- }
58
+ }
60
59
 
61
- return color;
60
+ if ( this.spaces[ sourceColorSpace ].primaries !== this.spaces[ targetColorSpace ].primaries ) {
62
61
 
63
- },
62
+ color.applyMatrix3( this.spaces[ sourceColorSpace ].toXYZ );
63
+ color.applyMatrix3( this.spaces[ targetColorSpace ].fromXYZ );
64
64
 
65
- fromWorkingColorSpace: function ( color, targetColorSpace ) {
65
+ }
66
66
 
67
- return this.convert( color, this.workingColorSpace, targetColorSpace );
67
+ if ( this.spaces[ targetColorSpace ].transfer === SRGBTransfer ) {
68
68
 
69
- },
69
+ color.r = LinearToSRGB( color.r );
70
+ color.g = LinearToSRGB( color.g );
71
+ color.b = LinearToSRGB( color.b );
70
72
 
71
- toWorkingColorSpace: function ( color, sourceColorSpace ) {
73
+ }
72
74
 
73
- return this.convert( color, sourceColorSpace, this.workingColorSpace );
75
+ return color;
74
76
 
75
- },
77
+ },
76
78
 
77
- getPrimaries: function ( colorSpace ) {
79
+ fromWorkingColorSpace: function ( color, targetColorSpace ) {
78
80
 
79
- return this.spaces[ colorSpace ].primaries;
81
+ return this.convert( color, this.workingColorSpace, targetColorSpace );
80
82
 
81
- },
83
+ },
82
84
 
83
- getTransfer: function ( colorSpace ) {
85
+ toWorkingColorSpace: function ( color, sourceColorSpace ) {
84
86
 
85
- if ( colorSpace === NoColorSpace ) return LinearTransfer;
87
+ return this.convert( color, sourceColorSpace, this.workingColorSpace );
86
88
 
87
- return this.spaces[ colorSpace ].transfer;
89
+ },
88
90
 
89
- },
91
+ getPrimaries: function ( colorSpace ) {
90
92
 
91
- getLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {
93
+ return this.spaces[ colorSpace ].primaries;
92
94
 
93
- return target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );
95
+ },
94
96
 
95
- },
97
+ getTransfer: function ( colorSpace ) {
96
98
 
97
- define: function ( colorSpaces ) {
99
+ if ( colorSpace === NoColorSpace ) return LinearTransfer;
98
100
 
99
- Object.assign( this.spaces, colorSpaces );
101
+ return this.spaces[ colorSpace ].transfer;
100
102
 
101
- },
103
+ },
102
104
 
103
- // Internal APIs
105
+ getLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {
104
106
 
105
- _getMatrix: function ( targetMatrix, sourceColorSpace, targetColorSpace ) {
107
+ return target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );
106
108
 
107
- return targetMatrix
108
- .copy( this.spaces[ sourceColorSpace ].toXYZ )
109
- .multiply( this.spaces[ targetColorSpace ].fromXYZ );
109
+ },
110
110
 
111
- },
111
+ define: function ( colorSpaces ) {
112
112
 
113
- _getDrawingBufferColorSpace: function ( colorSpace ) {
113
+ Object.assign( this.spaces, colorSpaces );
114
114
 
115
- return this.spaces[ colorSpace ].outputColorSpaceConfig.drawingBufferColorSpace;
115
+ },
116
116
 
117
- },
117
+ // Internal APIs
118
118
 
119
- _getUnpackColorSpace: function ( colorSpace = this.workingColorSpace ) {
119
+ _getMatrix: function ( targetMatrix, sourceColorSpace, targetColorSpace ) {
120
120
 
121
- return this.spaces[ colorSpace ].workingColorSpaceConfig.unpackColorSpace;
121
+ return targetMatrix
122
+ .copy( this.spaces[ sourceColorSpace ].toXYZ )
123
+ .multiply( this.spaces[ targetColorSpace ].fromXYZ );
122
124
 
123
- }
125
+ },
124
126
 
125
- };
127
+ _getDrawingBufferColorSpace: function ( colorSpace ) {
126
128
 
127
- export function SRGBToLinear( c ) {
129
+ return this.spaces[ colorSpace ].outputColorSpaceConfig.drawingBufferColorSpace;
128
130
 
129
- return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
131
+ },
130
132
 
131
- }
133
+ _getUnpackColorSpace: function ( colorSpace = this.workingColorSpace ) {
132
134
 
133
- export function LinearToSRGB( c ) {
135
+ return this.spaces[ colorSpace ].workingColorSpaceConfig.unpackColorSpace;
134
136
 
135
- return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
137
+ }
138
+
139
+ };
140
+
141
+ /******************************************************************************
142
+ * sRGB definitions
143
+ */
144
+
145
+ const REC709_PRIMARIES = [ 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 ];
146
+ const REC709_LUMINANCE_COEFFICIENTS = [ 0.2126, 0.7152, 0.0722 ];
147
+ const D65 = [ 0.3127, 0.3290 ];
148
+
149
+ ColorManagement.define( {
150
+
151
+ [ LinearSRGBColorSpace ]: {
152
+ primaries: REC709_PRIMARIES,
153
+ whitePoint: D65,
154
+ transfer: LinearTransfer,
155
+ toXYZ: LINEAR_REC709_TO_XYZ,
156
+ fromXYZ: XYZ_TO_LINEAR_REC709,
157
+ luminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,
158
+ workingColorSpaceConfig: { unpackColorSpace: SRGBColorSpace },
159
+ outputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }
160
+ },
161
+
162
+ [ SRGBColorSpace ]: {
163
+ primaries: REC709_PRIMARIES,
164
+ whitePoint: D65,
165
+ transfer: SRGBTransfer,
166
+ toXYZ: LINEAR_REC709_TO_XYZ,
167
+ fromXYZ: XYZ_TO_LINEAR_REC709,
168
+ luminanceCoefficients: REC709_LUMINANCE_COEFFICIENTS,
169
+ outputColorSpaceConfig: { drawingBufferColorSpace: SRGBColorSpace }
170
+ },
171
+
172
+ } );
173
+
174
+ return ColorManagement;
136
175
 
137
176
  }
138
177
 
139
- /******************************************************************************
140
- * sRGB definitions
141
- */
178
+ export const ColorManagement = /*@__PURE__*/ createColorManagement();
142
179
 
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 ];
180
+ export function SRGBToLinear( c ) {
146
181
 
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
- );
182
+ return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
152
183
 
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
- );
184
+ }
158
185
 
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
- } );
186
+ export function LinearToSRGB( c ) {
187
+
188
+ return ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;
189
+
190
+ }
package/src/math/Line3.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Vector3 } from './Vector3.js';
2
- import * as MathUtils from './MathUtils.js';
2
+ import { clamp } from './MathUtils.js';
3
3
 
4
4
  const _startP = /*@__PURE__*/ new Vector3();
5
5
  const _startEnd = /*@__PURE__*/ new Vector3();
@@ -73,7 +73,7 @@ class Line3 {
73
73
 
74
74
  if ( clampToLine ) {
75
75
 
76
- t = MathUtils.clamp( t, 0, 1 );
76
+ t = clamp( t, 0, 1 );
77
77
 
78
78
  }
79
79
 
@@ -1,4 +1,4 @@
1
- import * as MathUtils from './MathUtils.js';
1
+ import { clamp } from './MathUtils.js';
2
2
 
3
3
  class Quaternion {
4
4
 
@@ -394,7 +394,7 @@ class Quaternion {
394
394
 
395
395
  angleTo( q ) {
396
396
 
397
- return 2 * Math.acos( Math.abs( MathUtils.clamp( this.dot( q ), - 1, 1 ) ) );
397
+ return 2 * Math.acos( Math.abs( clamp( this.dot( q ), - 1, 1 ) ) );
398
398
 
399
399
  }
400
400
 
@@ -1,4 +1,4 @@
1
- import * as MathUtils from './MathUtils.js';
1
+ import { clamp } from './MathUtils.js';
2
2
 
3
3
  /**
4
4
  * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system
@@ -42,7 +42,7 @@ class Spherical {
42
42
  makeSafe() {
43
43
 
44
44
  const EPS = 0.000001;
45
- this.phi = Math.max( EPS, Math.min( Math.PI - EPS, this.phi ) );
45
+ this.phi = clamp( this.phi, EPS, Math.PI - EPS );
46
46
 
47
47
  return this;
48
48
 
@@ -66,7 +66,7 @@ class Spherical {
66
66
  } else {
67
67
 
68
68
  this.theta = Math.atan2( x, z );
69
- this.phi = Math.acos( MathUtils.clamp( y / this.radius, - 1, 1 ) );
69
+ this.phi = Math.acos( clamp( y / this.radius, - 1, 1 ) );
70
70
 
71
71
  }
72
72
 
@@ -1,4 +1,4 @@
1
- import * as MathUtils from './MathUtils.js';
1
+ import { clamp } from './MathUtils.js';
2
2
 
3
3
  class Vector2 {
4
4
 
@@ -240,8 +240,8 @@ class Vector2 {
240
240
 
241
241
  // assumes min < max, componentwise
242
242
 
243
- this.x = Math.max( min.x, Math.min( max.x, this.x ) );
244
- this.y = Math.max( min.y, Math.min( max.y, this.y ) );
243
+ this.x = clamp( this.x, min.x, max.x );
244
+ this.y = clamp( this.y, min.y, max.y );
245
245
 
246
246
  return this;
247
247
 
@@ -249,8 +249,8 @@ class Vector2 {
249
249
 
250
250
  clampScalar( minVal, maxVal ) {
251
251
 
252
- this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
253
- this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
252
+ this.x = clamp( this.x, minVal, maxVal );
253
+ this.y = clamp( this.y, minVal, maxVal );
254
254
 
255
255
  return this;
256
256
 
@@ -260,7 +260,7 @@ class Vector2 {
260
260
 
261
261
  const length = this.length();
262
262
 
263
- return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
263
+ return this.divideScalar( length || 1 ).multiplyScalar( clamp( length, min, max ) );
264
264
 
265
265
  }
266
266
 
@@ -365,7 +365,7 @@ class Vector2 {
365
365
 
366
366
  // clamp, to handle numerical problems
367
367
 
368
- return Math.acos( MathUtils.clamp( theta, - 1, 1 ) );
368
+ return Math.acos( clamp( theta, - 1, 1 ) );
369
369
 
370
370
  }
371
371
 
@@ -1,4 +1,4 @@
1
- import * as MathUtils from './MathUtils.js';
1
+ import { clamp } from './MathUtils.js';
2
2
  import { Quaternion } from './Quaternion.js';
3
3
 
4
4
  class Vector3 {
@@ -338,9 +338,9 @@ class Vector3 {
338
338
 
339
339
  // assumes min < max, componentwise
340
340
 
341
- this.x = Math.max( min.x, Math.min( max.x, this.x ) );
342
- this.y = Math.max( min.y, Math.min( max.y, this.y ) );
343
- this.z = Math.max( min.z, Math.min( max.z, this.z ) );
341
+ this.x = clamp( this.x, min.x, max.x );
342
+ this.y = clamp( this.y, min.y, max.y );
343
+ this.z = clamp( this.z, min.z, max.z );
344
344
 
345
345
  return this;
346
346
 
@@ -348,9 +348,9 @@ class Vector3 {
348
348
 
349
349
  clampScalar( minVal, maxVal ) {
350
350
 
351
- this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
352
- this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
353
- this.z = Math.max( minVal, Math.min( maxVal, this.z ) );
351
+ this.x = clamp( this.x, minVal, maxVal );
352
+ this.y = clamp( this.y, minVal, maxVal );
353
+ this.z = clamp( this.z, minVal, maxVal );
354
354
 
355
355
  return this;
356
356
 
@@ -360,7 +360,7 @@ class Vector3 {
360
360
 
361
361
  const length = this.length();
362
362
 
363
- return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
363
+ return this.divideScalar( length || 1 ).multiplyScalar( clamp( length, min, max ) );
364
364
 
365
365
  }
366
366
 
@@ -530,7 +530,7 @@ class Vector3 {
530
530
 
531
531
  // clamp, to handle numerical problems
532
532
 
533
- return Math.acos( MathUtils.clamp( theta, - 1, 1 ) );
533
+ return Math.acos( clamp( theta, - 1, 1 ) );
534
534
 
535
535
  }
536
536
 
@@ -1,3 +1,5 @@
1
+ import { clamp } from './MathUtils.js';
2
+
1
3
  class Vector4 {
2
4
 
3
5
  constructor( x = 0, y = 0, z = 0, w = 1 ) {
@@ -463,10 +465,10 @@ class Vector4 {
463
465
 
464
466
  // assumes min < max, componentwise
465
467
 
466
- this.x = Math.max( min.x, Math.min( max.x, this.x ) );
467
- this.y = Math.max( min.y, Math.min( max.y, this.y ) );
468
- this.z = Math.max( min.z, Math.min( max.z, this.z ) );
469
- this.w = Math.max( min.w, Math.min( max.w, this.w ) );
468
+ this.x = clamp( this.x, min.x, max.x );
469
+ this.y = clamp( this.y, min.y, max.y );
470
+ this.z = clamp( this.z, min.z, max.z );
471
+ this.w = clamp( this.w, min.w, max.w );
470
472
 
471
473
  return this;
472
474
 
@@ -474,10 +476,10 @@ class Vector4 {
474
476
 
475
477
  clampScalar( minVal, maxVal ) {
476
478
 
477
- this.x = Math.max( minVal, Math.min( maxVal, this.x ) );
478
- this.y = Math.max( minVal, Math.min( maxVal, this.y ) );
479
- this.z = Math.max( minVal, Math.min( maxVal, this.z ) );
480
- this.w = Math.max( minVal, Math.min( maxVal, this.w ) );
479
+ this.x = clamp( this.x, minVal, maxVal );
480
+ this.y = clamp( this.y, minVal, maxVal );
481
+ this.z = clamp( this.z, minVal, maxVal );
482
+ this.w = clamp( this.w, minVal, maxVal );
481
483
 
482
484
  return this;
483
485
 
@@ -487,7 +489,7 @@ class Vector4 {
487
489
 
488
490
  const length = this.length();
489
491
 
490
- return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
492
+ return this.divideScalar( length || 1 ).multiplyScalar( clamp( length, min, max ) );
491
493
 
492
494
  }
493
495
 
@@ -60,6 +60,7 @@ export { default as BufferNode } from './accessors/BufferNode.js';
60
60
  export { default as VertexColorNode } from './accessors/VertexColorNode.js';
61
61
  export { default as CubeTextureNode } from './accessors/CubeTextureNode.js';
62
62
  export { default as InstanceNode } from './accessors/InstanceNode.js';
63
+ export { default as InstancedMeshNode } from './accessors/InstancedMeshNode.js';
63
64
  export { default as BatchNode } from './accessors/BatchNode.js';
64
65
  export { default as MaterialNode } from './accessors/MaterialNode.js';
65
66
  export { default as MaterialReferenceNode } from './accessors/MaterialReferenceNode.js';
package/src/nodes/TSL.js CHANGED
@@ -47,6 +47,7 @@ export * from './tsl/TSLBase.js';
47
47
 
48
48
  // accessors
49
49
  export * from './accessors/AccessorsUtils.js';
50
+ export * from './accessors/Arrays.js';
50
51
  export * from './accessors/UniformArrayNode.js';
51
52
  export * from './accessors/Bitangent.js';
52
53
  export * from './accessors/BufferAttributeNode.js';
@@ -55,6 +56,7 @@ export * from './accessors/Camera.js';
55
56
  export * from './accessors/VertexColorNode.js';
56
57
  export * from './accessors/CubeTextureNode.js';
57
58
  export * from './accessors/InstanceNode.js';
59
+ export * from './accessors/InstancedMeshNode.js';
58
60
  export * from './accessors/BatchNode.js';
59
61
  export * from './accessors/MaterialNode.js';
60
62
  export * from './accessors/MaterialProperties.js';
@@ -83,7 +85,7 @@ export * from './accessors/UserDataNode.js';
83
85
  export * from './accessors/VelocityNode.js';
84
86
 
85
87
  // display
86
- export * from './display/BlendMode.js';
88
+ export * from './display/BlendModes.js';
87
89
  export * from './display/BumpMapNode.js';
88
90
  export * from './display/ColorAdjustment.js';
89
91
  export * from './display/ColorSpaceNode.js';
@@ -0,0 +1,27 @@
1
+ import StorageInstancedBufferAttribute from '../../renderers/common/StorageInstancedBufferAttribute.js';
2
+ import StorageBufferAttribute from '../../renderers/common/StorageBufferAttribute.js';
3
+ import { storage } from './StorageBufferNode.js';
4
+ import { getLengthFromType } from '../core/NodeUtils.js';
5
+
6
+ export const attributeArray = ( count, type = 'float' ) => {
7
+
8
+ const itemSize = getLengthFromType( type );
9
+
10
+ const buffer = new StorageBufferAttribute( count, itemSize );
11
+ const node = storage( buffer, type, count );
12
+
13
+ return node;
14
+
15
+ };
16
+
17
+
18
+ export const instancedArray = ( count, type = 'float' ) => {
19
+
20
+ const itemSize = getLengthFromType( type );
21
+
22
+ const buffer = new StorageInstancedBufferAttribute( count, itemSize );
23
+ const node = storage( buffer, type, count );
24
+
25
+ return node;
26
+
27
+ };
@@ -0,0 +1,26 @@
1
+ import Node from '../core/Node.js';
2
+ import { nodeProxy } from '../tsl/TSLBase.js';
3
+
4
+ class BuiltinNode extends Node {
5
+
6
+ constructor( name ) {
7
+
8
+ super( 'float' );
9
+
10
+ this.name = name;
11
+
12
+ this.isBuiltinNode = true;
13
+
14
+ }
15
+
16
+ generate( /* builder */ ) {
17
+
18
+ return this.name;
19
+
20
+ }
21
+
22
+ }
23
+
24
+ export default BuiltinNode;
25
+
26
+ export const builtin = nodeProxy( BuiltinNode );