super-three 0.170.0 → 0.171.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.
- package/build/three.cjs +24410 -24422
- package/build/three.core.js +37002 -0
- package/build/three.core.min.js +6 -0
- package/build/three.module.js +10573 -47578
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +533 -0
- package/build/three.tsl.min.js +6 -0
- package/build/three.webgpu.js +2907 -37975
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +2914 -37959
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/capabilities/WebGPU.js +1 -10
- package/examples/jsm/controls/ArcballControls.js +25 -21
- package/examples/jsm/controls/OrbitControls.js +41 -9
- package/examples/jsm/controls/PointerLockControls.js +2 -5
- package/examples/jsm/csm/CSMShadowNode.js +7 -5
- package/examples/jsm/geometries/DecalGeometry.js +5 -1
- package/examples/jsm/lighting/TiledLighting.js +1 -1
- package/examples/jsm/lines/LineGeometry.js +25 -0
- package/examples/jsm/lines/LineMaterial.js +1 -7
- package/examples/jsm/lines/webgpu/Line2.js +2 -1
- package/examples/jsm/lines/webgpu/LineSegments2.js +2 -1
- package/examples/jsm/lines/webgpu/Wireframe.js +2 -1
- package/examples/jsm/loaders/KTX2Loader.js +3 -0
- package/examples/jsm/loaders/MMDLoader.js +2 -6
- package/examples/jsm/loaders/MaterialXLoader.js +2 -2
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -6
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +2 -2
- package/examples/jsm/objects/InstancedPoints.js +2 -4
- package/examples/jsm/objects/LensflareMesh.js +4 -2
- package/examples/jsm/objects/SkyMesh.js +5 -3
- package/examples/jsm/objects/Water2Mesh.js +7 -3
- package/examples/jsm/objects/WaterMesh.js +5 -3
- package/examples/jsm/transpiler/AST.js +2 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +57 -25
- package/examples/jsm/transpiler/TSLEncoder.js +11 -6
- package/examples/jsm/tsl/display/AfterImageNode.js +3 -3
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -2
- package/examples/jsm/tsl/display/AnamorphicNode.js +2 -2
- package/examples/jsm/tsl/display/BloomNode.js +3 -3
- package/examples/jsm/tsl/display/DenoiseNode.js +48 -12
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +3 -2
- package/examples/jsm/tsl/display/DotScreenNode.js +2 -2
- package/examples/jsm/tsl/display/FXAANode.js +3 -3
- package/examples/jsm/tsl/display/FilmNode.js +3 -2
- package/examples/jsm/tsl/display/GTAONode.js +62 -27
- package/examples/jsm/tsl/display/GaussianBlurNode.js +6 -8
- package/examples/jsm/tsl/display/LensflareNode.js +3 -3
- package/examples/jsm/tsl/display/Lut3DNode.js +3 -2
- package/examples/jsm/tsl/display/OutlineNode.js +2 -2
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -1
- package/examples/jsm/tsl/display/PixelationPassNode.js +4 -4
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -1
- package/examples/jsm/tsl/display/SMAANode.js +3 -3
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +31 -8
- package/examples/jsm/tsl/display/SobelOperatorNode.js +3 -3
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +4 -4
- package/examples/jsm/tsl/display/StereoPassNode.js +2 -2
- package/examples/jsm/tsl/display/TRAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/TransitionNode.js +3 -2
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +6 -9
- package/examples/jsm/utils/SceneOptimizer.js +410 -0
- package/examples/jsm/utils/UVsDebug.js +1 -1
- package/package.json +3 -3
- package/src/Three.Core.js +178 -0
- package/src/Three.TSL.js +526 -0
- package/src/Three.WebGPU.Nodes.js +5 -186
- package/src/Three.WebGPU.js +4 -186
- package/src/Three.js +1 -177
- package/src/animation/AnimationClip.js +2 -2
- package/src/animation/AnimationObjectGroup.js +2 -2
- package/src/audio/Audio.js +38 -0
- package/src/cameras/PerspectiveCamera.js +6 -6
- package/src/cameras/StereoCamera.js +2 -2
- package/src/constants.js +1 -1
- package/src/core/BufferGeometry.js +5 -3
- package/src/core/InterleavedBuffer.js +4 -4
- package/src/core/Object3D.js +2 -2
- package/src/extras/core/Curve.js +3 -3
- package/src/extras/core/Shape.js +2 -2
- package/src/geometries/EdgesGeometry.js +2 -2
- package/src/geometries/LatheGeometry.js +2 -2
- package/src/lights/SpotLightShadow.js +2 -2
- package/src/materials/LineBasicMaterial.js +2 -6
- package/src/materials/LineDashedMaterial.js +1 -6
- package/src/materials/Material.js +3 -16
- package/src/materials/MeshBasicMaterial.js +2 -6
- package/src/materials/MeshDepthMaterial.js +2 -6
- package/src/materials/MeshDistanceMaterial.js +2 -6
- package/src/materials/MeshLambertMaterial.js +2 -6
- package/src/materials/MeshMatcapMaterial.js +2 -6
- package/src/materials/MeshNormalMaterial.js +2 -6
- package/src/materials/MeshPhongMaterial.js +3 -7
- package/src/materials/MeshPhysicalMaterial.js +4 -8
- package/src/materials/MeshStandardMaterial.js +2 -6
- package/src/materials/MeshToonMaterial.js +2 -6
- package/src/materials/PointsMaterial.js +2 -6
- package/src/materials/RawShaderMaterial.js +2 -6
- package/src/materials/ShaderMaterial.js +2 -6
- package/src/materials/ShadowMaterial.js +2 -6
- package/src/materials/SpriteMaterial.js +2 -6
- package/src/materials/nodes/Line2NodeMaterial.js +32 -13
- package/src/materials/nodes/LineDashedNodeMaterial.js +4 -2
- package/src/materials/nodes/NodeMaterial.js +64 -16
- package/src/materials/nodes/manager/NodeMaterialObserver.js +13 -10
- package/src/math/ColorManagement.js +130 -122
- package/src/math/Line3.js +2 -2
- package/src/math/Quaternion.js +2 -2
- package/src/math/Spherical.js +3 -3
- package/src/math/Vector2.js +7 -7
- package/src/math/Vector3.js +9 -9
- package/src/math/Vector4.js +11 -9
- package/src/nodes/Nodes.js +1 -0
- package/src/nodes/TSL.js +3 -1
- package/src/nodes/accessors/Arrays.js +27 -0
- package/src/nodes/accessors/BuiltinNode.js +26 -0
- package/src/nodes/accessors/ClippingNode.js +76 -42
- package/src/nodes/accessors/InstanceNode.js +17 -20
- package/src/nodes/accessors/InstancedMeshNode.js +26 -0
- package/src/nodes/accessors/Lights.js +32 -0
- package/src/nodes/accessors/StorageBufferNode.js +29 -9
- package/src/nodes/accessors/StorageTextureNode.js +10 -4
- package/src/nodes/accessors/TextureNode.js +1 -1
- package/src/nodes/core/NodeBuilder.js +2 -9
- package/src/nodes/core/NodeUtils.js +28 -0
- package/src/nodes/core/constants.js +6 -0
- package/src/nodes/display/BlendModes.js +99 -0
- package/src/nodes/display/ToonOutlinePassNode.js +3 -3
- package/src/nodes/display/ViewportDepthNode.js +21 -6
- package/src/nodes/functions/material/getAlphaHashThreshold.js +13 -7
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +1 -1
- package/src/nodes/lighting/AnalyticLightNode.js +12 -4
- package/src/nodes/lighting/PointLightNode.js +10 -1
- package/src/nodes/lighting/PointShadowNode.js +254 -0
- package/src/nodes/lighting/ShadowNode.js +176 -67
- package/src/nodes/lighting/SpotLightNode.js +14 -2
- package/src/nodes/utils/RTTNode.js +9 -1
- package/src/nodes/utils/StorageArrayElementNode.js +2 -2
- package/src/objects/BatchedMesh.js +54 -95
- package/src/objects/ClippingGroup.js +19 -0
- package/src/objects/Skeleton.js +2 -2
- package/src/renderers/WebGLRenderer.js +94 -23
- package/src/renderers/common/Animation.js +23 -11
- package/src/renderers/common/Background.js +1 -1
- package/src/renderers/common/Bindings.js +20 -4
- package/src/renderers/common/ClippingContext.js +77 -85
- package/src/renderers/common/RenderList.js +9 -6
- package/src/renderers/common/RenderObject.js +27 -27
- package/src/renderers/common/RenderObjects.js +12 -6
- package/src/renderers/common/Renderer.js +63 -57
- package/src/renderers/common/Textures.js +11 -3
- package/src/renderers/common/UniformsGroup.js +16 -4
- package/src/renderers/common/extras/PMREMGenerator.js +89 -13
- package/src/renderers/common/nodes/NodeLibrary.js +2 -2
- package/src/renderers/common/nodes/NodeStorageBuffer.js +2 -3
- package/src/renderers/common/nodes/NodeUniform.js +42 -0
- package/src/renderers/webgl/WebGLBackground.js +20 -1
- package/src/renderers/webgl/WebGLGeometries.js +0 -28
- package/src/renderers/webgl-fallback/WebGLBackend.js +13 -6
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +43 -12
- package/src/renderers/webgl-fallback/utils/WebGLState.js +26 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +4 -1
- package/src/renderers/webgpu/WebGPUBackend.js +47 -31
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +13 -26
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +184 -74
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -2
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -7
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -1
- package/src/textures/Source.js +2 -2
- package/src/textures/Texture.js +2 -2
- 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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
16
|
+
function createColorManagement() {
|
|
33
17
|
|
|
34
|
-
|
|
18
|
+
const ColorManagement = {
|
|
35
19
|
|
|
36
|
-
|
|
20
|
+
enabled: true,
|
|
37
21
|
|
|
38
|
-
|
|
22
|
+
workingColorSpace: LinearSRGBColorSpace,
|
|
39
23
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
46
|
+
if ( this.enabled === false || sourceColorSpace === targetColorSpace || ! sourceColorSpace || ! targetColorSpace ) {
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
color.applyMatrix3( this.spaces[ targetColorSpace ].fromXYZ );
|
|
48
|
+
return color;
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
}
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
if ( this.spaces[ sourceColorSpace ].transfer === SRGBTransfer ) {
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
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
|
-
|
|
65
|
+
}
|
|
66
66
|
|
|
67
|
-
|
|
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
|
-
|
|
73
|
+
}
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
return color;
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
},
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
fromWorkingColorSpace: function ( color, targetColorSpace ) {
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
return this.convert( color, this.workingColorSpace, targetColorSpace );
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
},
|
|
82
84
|
|
|
83
|
-
|
|
85
|
+
toWorkingColorSpace: function ( color, sourceColorSpace ) {
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
return this.convert( color, sourceColorSpace, this.workingColorSpace );
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
},
|
|
88
90
|
|
|
89
|
-
|
|
91
|
+
getPrimaries: function ( colorSpace ) {
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
return this.spaces[ colorSpace ].primaries;
|
|
92
94
|
|
|
93
|
-
|
|
95
|
+
},
|
|
94
96
|
|
|
95
|
-
|
|
97
|
+
getTransfer: function ( colorSpace ) {
|
|
96
98
|
|
|
97
|
-
|
|
99
|
+
if ( colorSpace === NoColorSpace ) return LinearTransfer;
|
|
98
100
|
|
|
99
|
-
|
|
101
|
+
return this.spaces[ colorSpace ].transfer;
|
|
100
102
|
|
|
101
|
-
|
|
103
|
+
},
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
getLuminanceCoefficients: function ( target, colorSpace = this.workingColorSpace ) {
|
|
104
106
|
|
|
105
|
-
|
|
107
|
+
return target.fromArray( this.spaces[ colorSpace ].luminanceCoefficients );
|
|
106
108
|
|
|
107
|
-
|
|
108
|
-
.copy( this.spaces[ sourceColorSpace ].toXYZ )
|
|
109
|
-
.multiply( this.spaces[ targetColorSpace ].fromXYZ );
|
|
109
|
+
},
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
define: function ( colorSpaces ) {
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
Object.assign( this.spaces, colorSpaces );
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
},
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
// Internal APIs
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
_getMatrix: function ( targetMatrix, sourceColorSpace, targetColorSpace ) {
|
|
120
120
|
|
|
121
|
-
|
|
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
|
-
|
|
129
|
+
return this.spaces[ colorSpace ].outputColorSpaceConfig.drawingBufferColorSpace;
|
|
128
130
|
|
|
129
|
-
|
|
131
|
+
},
|
|
130
132
|
|
|
131
|
-
|
|
133
|
+
_getUnpackColorSpace: function ( colorSpace = this.workingColorSpace ) {
|
|
132
134
|
|
|
133
|
-
|
|
135
|
+
return this.spaces[ colorSpace ].workingColorSpaceConfig.unpackColorSpace;
|
|
134
136
|
|
|
135
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
|
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 =
|
|
76
|
+
t = clamp( t, 0, 1 );
|
|
77
77
|
|
|
78
78
|
}
|
|
79
79
|
|
package/src/math/Quaternion.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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(
|
|
397
|
+
return 2 * Math.acos( Math.abs( clamp( this.dot( q ), - 1, 1 ) ) );
|
|
398
398
|
|
|
399
399
|
}
|
|
400
400
|
|
package/src/math/Spherical.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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 =
|
|
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(
|
|
69
|
+
this.phi = Math.acos( clamp( y / this.radius, - 1, 1 ) );
|
|
70
70
|
|
|
71
71
|
}
|
|
72
72
|
|
package/src/math/Vector2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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 =
|
|
244
|
-
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 =
|
|
253
|
-
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(
|
|
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(
|
|
368
|
+
return Math.acos( clamp( theta, - 1, 1 ) );
|
|
369
369
|
|
|
370
370
|
}
|
|
371
371
|
|
package/src/math/Vector3.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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 =
|
|
342
|
-
this.y =
|
|
343
|
-
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 =
|
|
352
|
-
this.y =
|
|
353
|
-
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(
|
|
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(
|
|
533
|
+
return Math.acos( clamp( theta, - 1, 1 ) );
|
|
534
534
|
|
|
535
535
|
}
|
|
536
536
|
|
package/src/math/Vector4.js
CHANGED
|
@@ -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 =
|
|
467
|
-
this.y =
|
|
468
|
-
this.z =
|
|
469
|
-
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 =
|
|
478
|
-
this.y =
|
|
479
|
-
this.z =
|
|
480
|
-
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(
|
|
492
|
+
return this.divideScalar( length || 1 ).multiplyScalar( clamp( length, min, max ) );
|
|
491
493
|
|
|
492
494
|
}
|
|
493
495
|
|
package/src/nodes/Nodes.js
CHANGED
|
@@ -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/
|
|
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 );
|