@plastic-software/three 0.178.0 → 0.179.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/README.md +1 -1
- package/build/three.cjs +856 -196
- package/build/three.core.js +647 -123
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +211 -76
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +70 -21
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +1796 -557
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +1754 -557
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -2
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/USDZExporter.js +676 -299
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/interactive/HTMLMesh.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +1 -1
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +14 -5
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/tsl/display/BloomNode.js +8 -7
- package/examples/jsm/tsl/display/GaussianBlurNode.js +6 -8
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +69 -20
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +1 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/loaders/FileLoader.js +25 -2
- package/src/loaders/ImageBitmapLoader.js +23 -0
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/NodeMaterial.js +1 -1
- package/src/materials/nodes/PointsNodeMaterial.js +5 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/Frustum.js +19 -8
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +1 -0
- package/src/nodes/TSL.js +1 -0
- package/src/nodes/accessors/Camera.js +12 -12
- package/src/nodes/accessors/Normal.js +11 -11
- package/src/nodes/accessors/ReferenceNode.js +18 -3
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +12 -0
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +3 -0
- package/src/nodes/core/ContextNode.js +20 -1
- package/src/nodes/core/Node.js +14 -2
- package/src/nodes/core/NodeBuilder.js +25 -20
- package/src/nodes/core/NodeUtils.js +4 -1
- package/src/nodes/core/StackNode.js +42 -0
- package/src/nodes/core/UniformNode.js +63 -5
- package/src/nodes/core/VarNode.js +91 -2
- package/src/nodes/display/PassNode.js +148 -2
- package/src/nodes/display/ViewportTextureNode.js +67 -7
- package/src/nodes/functions/PhysicalLightingModel.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/ConditionalNode.js +1 -1
- package/src/nodes/math/MathNode.js +78 -54
- package/src/nodes/math/OperatorNode.js +22 -22
- package/src/nodes/tsl/TSLCore.js +64 -9
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/RTTNode.js +9 -0
- package/src/objects/BatchedMesh.js +4 -2
- package/src/renderers/WebGLRenderer.js +21 -22
- package/src/renderers/common/Bindings.js +19 -18
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/Renderer.js +18 -15
- package/src/renderers/common/SampledTexture.js +3 -71
- package/src/renderers/common/Sampler.js +79 -0
- package/src/renderers/common/Storage3DTexture.js +21 -0
- package/src/renderers/common/StorageArrayTexture.js +21 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +19 -3
- package/src/renderers/common/XRManager.js +26 -8
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLMaterials.js +6 -6
- package/src/renderers/webgl/WebGLProgram.js +22 -16
- package/src/renderers/webgl/WebGLPrograms.js +4 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLTextures.js +19 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +22 -12
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +2 -2
- package/src/renderers/webgpu/WebGPUBackend.js +54 -15
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +53 -73
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +35 -31
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +11 -64
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +68 -8
- package/src/textures/ExternalTexture.js +45 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +11 -1
- package/src/textures/VideoTexture.js +30 -2
package/src/math/Matrix4.js
CHANGED
|
@@ -1103,11 +1103,13 @@ class Matrix4 {
|
|
|
1103
1103
|
* @param {number} near - The distance from the camera to the near plane.
|
|
1104
1104
|
* @param {number} far - The distance from the camera to the far plane.
|
|
1105
1105
|
* @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
|
|
1106
|
+
* @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
|
|
1106
1107
|
* @return {Matrix4} A reference to this matrix.
|
|
1107
1108
|
*/
|
|
1108
|
-
makePerspective( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem ) {
|
|
1109
|
+
makePerspective( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false ) {
|
|
1109
1110
|
|
|
1110
1111
|
const te = this.elements;
|
|
1112
|
+
|
|
1111
1113
|
const x = 2 * near / ( right - left );
|
|
1112
1114
|
const y = 2 * near / ( top - bottom );
|
|
1113
1115
|
|
|
@@ -1116,19 +1118,28 @@ class Matrix4 {
|
|
|
1116
1118
|
|
|
1117
1119
|
let c, d;
|
|
1118
1120
|
|
|
1119
|
-
if (
|
|
1121
|
+
if ( reversedDepth ) {
|
|
1120
1122
|
|
|
1121
|
-
c =
|
|
1122
|
-
d = (
|
|
1123
|
+
c = near / ( far - near );
|
|
1124
|
+
d = ( far * near ) / ( far - near );
|
|
1123
1125
|
|
|
1124
|
-
} else
|
|
1126
|
+
} else {
|
|
1125
1127
|
|
|
1126
|
-
|
|
1127
|
-
d = ( - far * near ) / ( far - near );
|
|
1128
|
+
if ( coordinateSystem === WebGLCoordinateSystem ) {
|
|
1128
1129
|
|
|
1129
|
-
|
|
1130
|
+
c = - ( far + near ) / ( far - near );
|
|
1131
|
+
d = ( - 2 * far * near ) / ( far - near );
|
|
1132
|
+
|
|
1133
|
+
} else if ( coordinateSystem === WebGPUCoordinateSystem ) {
|
|
1134
|
+
|
|
1135
|
+
c = - far / ( far - near );
|
|
1136
|
+
d = ( - far * near ) / ( far - near );
|
|
1130
1137
|
|
|
1131
|
-
|
|
1138
|
+
} else {
|
|
1139
|
+
|
|
1140
|
+
throw new Error( 'THREE.Matrix4.makePerspective(): Invalid coordinate system: ' + coordinateSystem );
|
|
1141
|
+
|
|
1142
|
+
}
|
|
1132
1143
|
|
|
1133
1144
|
}
|
|
1134
1145
|
|
|
@@ -1152,39 +1163,49 @@ class Matrix4 {
|
|
|
1152
1163
|
* @param {number} near - The distance from the camera to the near plane.
|
|
1153
1164
|
* @param {number} far - The distance from the camera to the far plane.
|
|
1154
1165
|
* @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
|
|
1166
|
+
* @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
|
|
1155
1167
|
* @return {Matrix4} A reference to this matrix.
|
|
1156
1168
|
*/
|
|
1157
|
-
makeOrthographic( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem ) {
|
|
1169
|
+
makeOrthographic( left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false ) {
|
|
1158
1170
|
|
|
1159
1171
|
const te = this.elements;
|
|
1160
|
-
const w = 1.0 / ( right - left );
|
|
1161
|
-
const h = 1.0 / ( top - bottom );
|
|
1162
|
-
const p = 1.0 / ( far - near );
|
|
1163
|
-
|
|
1164
|
-
const x = ( right + left ) * w;
|
|
1165
|
-
const y = ( top + bottom ) * h;
|
|
1166
1172
|
|
|
1167
|
-
|
|
1173
|
+
const x = 2 / ( right - left );
|
|
1174
|
+
const y = 2 / ( top - bottom );
|
|
1168
1175
|
|
|
1169
|
-
|
|
1176
|
+
const a = - ( right + left ) / ( right - left );
|
|
1177
|
+
const b = - ( top + bottom ) / ( top - bottom );
|
|
1170
1178
|
|
|
1171
|
-
|
|
1172
|
-
zInv = - 2 * p;
|
|
1179
|
+
let c, d;
|
|
1173
1180
|
|
|
1174
|
-
|
|
1181
|
+
if ( reversedDepth ) {
|
|
1175
1182
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1183
|
+
c = 1 / ( far - near );
|
|
1184
|
+
d = far / ( far - near );
|
|
1178
1185
|
|
|
1179
1186
|
} else {
|
|
1180
1187
|
|
|
1181
|
-
|
|
1188
|
+
if ( coordinateSystem === WebGLCoordinateSystem ) {
|
|
1189
|
+
|
|
1190
|
+
c = - 2 / ( far - near );
|
|
1191
|
+
d = - ( far + near ) / ( far - near );
|
|
1192
|
+
|
|
1193
|
+
} else if ( coordinateSystem === WebGPUCoordinateSystem ) {
|
|
1194
|
+
|
|
1195
|
+
c = - 1 / ( far - near );
|
|
1196
|
+
d = - near / ( far - near );
|
|
1197
|
+
|
|
1198
|
+
} else {
|
|
1199
|
+
|
|
1200
|
+
throw new Error( 'THREE.Matrix4.makeOrthographic(): Invalid coordinate system: ' + coordinateSystem );
|
|
1201
|
+
|
|
1202
|
+
}
|
|
1182
1203
|
|
|
1183
1204
|
}
|
|
1184
1205
|
|
|
1185
|
-
te[ 0 ] =
|
|
1186
|
-
te[ 1 ] = 0; te[ 5 ] =
|
|
1187
|
-
te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] =
|
|
1206
|
+
te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = a;
|
|
1207
|
+
te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = 0; te[ 13 ] = b;
|
|
1208
|
+
te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d;
|
|
1188
1209
|
te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1;
|
|
1189
1210
|
|
|
1190
1211
|
return this;
|
package/src/math/Spherical.js
CHANGED
|
@@ -107,8 +107,8 @@ class Spherical {
|
|
|
107
107
|
* Sets the spherical components from the given Cartesian coordinates.
|
|
108
108
|
*
|
|
109
109
|
* @param {number} x - The x value.
|
|
110
|
-
* @param {number} y - The
|
|
111
|
-
* @param {number} z - The
|
|
110
|
+
* @param {number} y - The y value.
|
|
111
|
+
* @param {number} z - The z value.
|
|
112
112
|
* @return {Spherical} A reference to this spherical.
|
|
113
113
|
*/
|
|
114
114
|
setFromCartesianCoords( x, y, z ) {
|
package/src/nodes/Nodes.js
CHANGED
|
@@ -55,6 +55,7 @@ export { default as ReflectorNode } from './utils/ReflectorNode.js';
|
|
|
55
55
|
export { default as RTTNode } from './utils/RTTNode.js';
|
|
56
56
|
export { default as MemberNode } from './utils/MemberNode.js';
|
|
57
57
|
export { default as DebugNode } from './utils/DebugNode.js';
|
|
58
|
+
export { default as EventNode } from './utils/EventNode.js';
|
|
58
59
|
|
|
59
60
|
// accessors
|
|
60
61
|
export { default as UniformArrayNode } from './accessors/UniformArrayNode.js';
|
package/src/nodes/TSL.js
CHANGED
|
@@ -43,6 +43,7 @@ export * from './utils/ReflectorNode.js';
|
|
|
43
43
|
export * from './utils/RTTNode.js';
|
|
44
44
|
export * from './utils/PostProcessingUtils.js';
|
|
45
45
|
export * from './utils/SampleNode.js';
|
|
46
|
+
export * from './utils/EventNode.js';
|
|
46
47
|
|
|
47
48
|
// three.js shading language
|
|
48
49
|
export * from './tsl/TSLBase.js';
|
|
@@ -11,7 +11,7 @@ import { builtin } from './BuiltinNode.js';
|
|
|
11
11
|
* @tsl
|
|
12
12
|
* @type {UniformNode<uint>}
|
|
13
13
|
*/
|
|
14
|
-
export const cameraIndex = /*@__PURE__*/ uniform( 0, 'uint' ).
|
|
14
|
+
export const cameraIndex = /*@__PURE__*/ uniform( 0, 'uint' ).setName( 'u_cameraIndex' ).setGroup( sharedUniformGroup( 'cameraIndex' ) ).toVarying( 'v_cameraIndex' );
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* TSL object that represents the `near` value of the camera used for the current render.
|
|
@@ -19,7 +19,7 @@ export const cameraIndex = /*@__PURE__*/ uniform( 0, 'uint' ).label( 'u_cameraIn
|
|
|
19
19
|
* @tsl
|
|
20
20
|
* @type {UniformNode<float>}
|
|
21
21
|
*/
|
|
22
|
-
export const cameraNear = /*@__PURE__*/ uniform( 'float' ).
|
|
22
|
+
export const cameraNear = /*@__PURE__*/ uniform( 'float' ).setName( 'cameraNear' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.near );
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* TSL object that represents the `far` value of the camera used for the current render.
|
|
@@ -27,7 +27,7 @@ export const cameraNear = /*@__PURE__*/ uniform( 'float' ).label( 'cameraNear' )
|
|
|
27
27
|
* @tsl
|
|
28
28
|
* @type {UniformNode<float>}
|
|
29
29
|
*/
|
|
30
|
-
export const cameraFar = /*@__PURE__*/ uniform( 'float' ).
|
|
30
|
+
export const cameraFar = /*@__PURE__*/ uniform( 'float' ).setName( 'cameraFar' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.far );
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* TSL object that represents the projection matrix of the camera used for the current render.
|
|
@@ -49,13 +49,13 @@ export const cameraProjectionMatrix = /*@__PURE__*/ ( Fn( ( { camera } ) => {
|
|
|
49
49
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const cameraProjectionMatrices = uniformArray( matrices ).setGroup( renderGroup ).
|
|
52
|
+
const cameraProjectionMatrices = uniformArray( matrices ).setGroup( renderGroup ).setName( 'cameraProjectionMatrices' );
|
|
53
53
|
|
|
54
54
|
cameraProjectionMatrix = cameraProjectionMatrices.element( camera.isMultiViewCamera ? builtin( 'gl_ViewID_OVR' ) : cameraIndex ).toVar( 'cameraProjectionMatrix' );
|
|
55
55
|
|
|
56
56
|
} else {
|
|
57
57
|
|
|
58
|
-
cameraProjectionMatrix = uniform( 'mat4' ).
|
|
58
|
+
cameraProjectionMatrix = uniform( 'mat4' ).setName( 'cameraProjectionMatrix' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrix );
|
|
59
59
|
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -83,13 +83,13 @@ export const cameraProjectionMatrixInverse = /*@__PURE__*/ ( Fn( ( { camera } )
|
|
|
83
83
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
const cameraProjectionMatricesInverse = uniformArray( matrices ).setGroup( renderGroup ).
|
|
86
|
+
const cameraProjectionMatricesInverse = uniformArray( matrices ).setGroup( renderGroup ).setName( 'cameraProjectionMatricesInverse' );
|
|
87
87
|
|
|
88
88
|
cameraProjectionMatrixInverse = cameraProjectionMatricesInverse.element( camera.isMultiViewCamera ? builtin( 'gl_ViewID_OVR' ) : cameraIndex ).toVar( 'cameraProjectionMatrixInverse' );
|
|
89
89
|
|
|
90
90
|
} else {
|
|
91
91
|
|
|
92
|
-
cameraProjectionMatrixInverse = uniform( 'mat4' ).
|
|
92
|
+
cameraProjectionMatrixInverse = uniform( 'mat4' ).setName( 'cameraProjectionMatrixInverse' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrixInverse );
|
|
93
93
|
|
|
94
94
|
}
|
|
95
95
|
|
|
@@ -117,13 +117,13 @@ export const cameraViewMatrix = /*@__PURE__*/ ( Fn( ( { camera } ) => {
|
|
|
117
117
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
const cameraViewMatrices = uniformArray( matrices ).setGroup( renderGroup ).
|
|
120
|
+
const cameraViewMatrices = uniformArray( matrices ).setGroup( renderGroup ).setName( 'cameraViewMatrices' );
|
|
121
121
|
|
|
122
122
|
cameraViewMatrix = cameraViewMatrices.element( camera.isMultiViewCamera ? builtin( 'gl_ViewID_OVR' ) : cameraIndex ).toVar( 'cameraViewMatrix' );
|
|
123
123
|
|
|
124
124
|
} else {
|
|
125
125
|
|
|
126
|
-
cameraViewMatrix = uniform( 'mat4' ).
|
|
126
|
+
cameraViewMatrix = uniform( 'mat4' ).setName( 'cameraViewMatrix' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorldInverse );
|
|
127
127
|
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -137,7 +137,7 @@ export const cameraViewMatrix = /*@__PURE__*/ ( Fn( ( { camera } ) => {
|
|
|
137
137
|
* @tsl
|
|
138
138
|
* @type {UniformNode<mat4>}
|
|
139
139
|
*/
|
|
140
|
-
export const cameraWorldMatrix = /*@__PURE__*/ uniform( 'mat4' ).
|
|
140
|
+
export const cameraWorldMatrix = /*@__PURE__*/ uniform( 'mat4' ).setName( 'cameraWorldMatrix' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorld );
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* TSL object that represents the normal matrix of the camera used for the current render.
|
|
@@ -145,7 +145,7 @@ export const cameraWorldMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraW
|
|
|
145
145
|
* @tsl
|
|
146
146
|
* @type {UniformNode<mat3>}
|
|
147
147
|
*/
|
|
148
|
-
export const cameraNormalMatrix = /*@__PURE__*/ uniform( 'mat3' ).
|
|
148
|
+
export const cameraNormalMatrix = /*@__PURE__*/ uniform( 'mat3' ).setName( 'cameraNormalMatrix' ).setGroup( renderGroup ).onRenderUpdate( ( { camera } ) => camera.normalMatrix );
|
|
149
149
|
|
|
150
150
|
/**
|
|
151
151
|
* TSL object that represents the position in world space of the camera used for the current render.
|
|
@@ -153,4 +153,4 @@ export const cameraNormalMatrix = /*@__PURE__*/ uniform( 'mat3' ).label( 'camera
|
|
|
153
153
|
* @tsl
|
|
154
154
|
* @type {UniformNode<vec3>}
|
|
155
155
|
*/
|
|
156
|
-
export const cameraPosition = /*@__PURE__*/ uniform( new Vector3() ).
|
|
156
|
+
export const cameraPosition = /*@__PURE__*/ uniform( new Vector3() ).setName( 'cameraPosition' ).setGroup( renderGroup ).onRenderUpdate( ( { camera }, self ) => self.value.setFromMatrixPosition( camera.matrixWorld ) );
|
|
@@ -6,7 +6,7 @@ import { positionView } from './Position.js';
|
|
|
6
6
|
import { directionToFaceDirection } from '../display/FrontFacingNode.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* TSL object that represents the normal attribute of the current rendered object.
|
|
9
|
+
* TSL object that represents the normal attribute of the current rendered object in local space.
|
|
10
10
|
*
|
|
11
11
|
* @tsl
|
|
12
12
|
* @type {Node<vec3>}
|
|
@@ -14,7 +14,7 @@ import { directionToFaceDirection } from '../display/FrontFacingNode.js';
|
|
|
14
14
|
export const normalGeometry = /*@__PURE__*/ attribute( 'normal', 'vec3' );
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* TSL object that represents the vertex normal
|
|
17
|
+
* TSL object that represents the vertex normal of the current rendered object in local space.
|
|
18
18
|
*
|
|
19
19
|
* @tsl
|
|
20
20
|
* @type {Node<vec3>}
|
|
@@ -34,7 +34,7 @@ export const normalLocal = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
34
34
|
}, 'vec3' ).once() )().toVar( 'normalLocal' );
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* TSL object that represents the flat vertex normal
|
|
37
|
+
* TSL object that represents the flat vertex normal of the current rendered object in view space.
|
|
38
38
|
*
|
|
39
39
|
* @tsl
|
|
40
40
|
* @type {Node<vec3>}
|
|
@@ -42,7 +42,7 @@ export const normalLocal = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
42
42
|
export const normalFlat = /*@__PURE__*/ positionView.dFdx().cross( positionView.dFdy() ).normalize().toVar( 'normalFlat' );
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* TSL object that represents the vertex normal
|
|
45
|
+
* TSL object that represents the vertex normal of the current rendered object in view space.
|
|
46
46
|
*
|
|
47
47
|
* @tsl
|
|
48
48
|
* @type {Node<vec3>}
|
|
@@ -66,7 +66,7 @@ export const normalViewGeometry = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
66
66
|
}, 'vec3' ).once() )().toVar( 'normalViewGeometry' );
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
* TSL object that represents the vertex normal
|
|
69
|
+
* TSL object that represents the vertex normal of the current rendered object in world space.
|
|
70
70
|
*
|
|
71
71
|
* @tsl
|
|
72
72
|
* @type {Node<vec3>}
|
|
@@ -86,7 +86,7 @@ export const normalWorldGeometry = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
86
86
|
}, 'vec3' ).once() )();
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* TSL object that represents the
|
|
89
|
+
* TSL object that represents the vertex normal of the current rendered object in view space.
|
|
90
90
|
*
|
|
91
91
|
* @tsl
|
|
92
92
|
* @type {Node<vec3>}
|
|
@@ -118,7 +118,7 @@ export const normalView = /*@__PURE__*/ ( Fn( ( { subBuildFn, material, context
|
|
|
118
118
|
}, 'vec3' ).once( [ 'NORMAL', 'VERTEX' ] ) )().toVar( 'normalView' );
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
|
-
* TSL object that represents the
|
|
121
|
+
* TSL object that represents the vertex normal of the current rendered object in world space.
|
|
122
122
|
*
|
|
123
123
|
* @tsl
|
|
124
124
|
* @type {Node<vec3>}
|
|
@@ -126,7 +126,7 @@ export const normalView = /*@__PURE__*/ ( Fn( ( { subBuildFn, material, context
|
|
|
126
126
|
export const normalWorld = /*@__PURE__*/ normalView.transformDirection( cameraViewMatrix ).toVar( 'normalWorld' );
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
|
-
* TSL object that represents the
|
|
129
|
+
* TSL object that represents the clearcoat vertex normal of the current rendered object in view space.
|
|
130
130
|
*
|
|
131
131
|
* @tsl
|
|
132
132
|
* @type {Node<vec3>}
|
|
@@ -200,7 +200,7 @@ export const transformNormalToView = /*@__PURE__*/ Fn( ( [ normal ], builder ) =
|
|
|
200
200
|
// Deprecated
|
|
201
201
|
|
|
202
202
|
/**
|
|
203
|
-
* TSL object that represents the transformed vertex normal
|
|
203
|
+
* TSL object that represents the transformed vertex normal of the current rendered object in view space.
|
|
204
204
|
*
|
|
205
205
|
* @tsl
|
|
206
206
|
* @type {Node<vec3>}
|
|
@@ -214,7 +214,7 @@ export const transformedNormalView = ( Fn( () => { // @deprecated, r177
|
|
|
214
214
|
} ).once( [ 'NORMAL', 'VERTEX' ] ) )();
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
|
-
* TSL object that represents the transformed vertex normal
|
|
217
|
+
* TSL object that represents the transformed vertex normal of the current rendered object in world space.
|
|
218
218
|
*
|
|
219
219
|
* @tsl
|
|
220
220
|
* @type {Node<vec3>}
|
|
@@ -228,7 +228,7 @@ export const transformedNormalWorld = ( Fn( () => { // @deprecated, r177
|
|
|
228
228
|
} ).once( [ 'NORMAL', 'VERTEX' ] ) )();
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
|
-
* TSL object that represents the transformed clearcoat vertex normal
|
|
231
|
+
* TSL object that represents the transformed clearcoat vertex normal of the current rendered object in view space.
|
|
232
232
|
*
|
|
233
233
|
* @tsl
|
|
234
234
|
* @type {Node<vec3>}
|
|
@@ -216,12 +216,12 @@ class ReferenceNode extends Node {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
/**
|
|
219
|
-
* Sets the
|
|
219
|
+
* Sets the name for the internal uniform.
|
|
220
220
|
*
|
|
221
221
|
* @param {string} name - The label to set.
|
|
222
222
|
* @return {ReferenceNode} A reference to this node.
|
|
223
223
|
*/
|
|
224
|
-
|
|
224
|
+
setName( name ) {
|
|
225
225
|
|
|
226
226
|
this.name = name;
|
|
227
227
|
|
|
@@ -229,6 +229,21 @@ class ReferenceNode extends Node {
|
|
|
229
229
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Sets the label for the internal uniform.
|
|
234
|
+
*
|
|
235
|
+
* @deprecated
|
|
236
|
+
* @param {string} name - The label to set.
|
|
237
|
+
* @return {ReferenceNode} A reference to this node.
|
|
238
|
+
*/
|
|
239
|
+
label( name ) {
|
|
240
|
+
|
|
241
|
+
console.warn( 'THREE.TSL: "label()" has been deprecated. Use "setName()" instead.' ); // @deprecated r179
|
|
242
|
+
|
|
243
|
+
return this.setName( name );
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
232
247
|
/**
|
|
233
248
|
* Sets the node type which automatically defines the internal
|
|
234
249
|
* uniform type.
|
|
@@ -267,7 +282,7 @@ class ReferenceNode extends Node {
|
|
|
267
282
|
|
|
268
283
|
}
|
|
269
284
|
|
|
270
|
-
if ( this.name !== null ) node.
|
|
285
|
+
if ( this.name !== null ) node.setName( this.name );
|
|
271
286
|
|
|
272
287
|
this.node = node.getSelf();
|
|
273
288
|
|
|
@@ -78,7 +78,7 @@ class SceneNode extends Node {
|
|
|
78
78
|
|
|
79
79
|
} else if ( scope === SceneNode.BACKGROUND_ROTATION ) {
|
|
80
80
|
|
|
81
|
-
output = uniform( 'mat4' ).
|
|
81
|
+
output = uniform( 'mat4' ).setName( 'backgroundRotation' ).setGroup( renderGroup ).onRenderUpdate( () => {
|
|
82
82
|
|
|
83
83
|
const background = scene.background;
|
|
84
84
|
|
|
@@ -186,7 +186,7 @@ class StorageTextureNode extends TextureNode {
|
|
|
186
186
|
const { uvNode, storeNode, depthNode } = properties;
|
|
187
187
|
|
|
188
188
|
const textureProperty = super.generate( builder, 'property' );
|
|
189
|
-
const uvSnippet = uvNode.build( builder, 'uvec2' );
|
|
189
|
+
const uvSnippet = uvNode.build( builder, this.value.is3DTexture === true ? 'uvec3' : 'uvec2' );
|
|
190
190
|
const storeSnippet = storeNode.build( builder, 'vec4' );
|
|
191
191
|
const depthSnippet = depthNode ? depthNode.build( builder, 'int' ) : null;
|
|
192
192
|
|
|
@@ -554,6 +554,18 @@ class TextureNode extends UniformNode {
|
|
|
554
554
|
|
|
555
555
|
}
|
|
556
556
|
|
|
557
|
+
/**
|
|
558
|
+
* TSL function for creating a texture node that fetches/loads texels without interpolation.
|
|
559
|
+
*
|
|
560
|
+
* @param {Node<uvec2>} uvNode - The uv node.
|
|
561
|
+
* @returns {TextureNode} A texture node representing the texture load.
|
|
562
|
+
*/
|
|
563
|
+
load( uvNode ) {
|
|
564
|
+
|
|
565
|
+
return this.sample( uvNode ).setSampler( false );
|
|
566
|
+
|
|
567
|
+
}
|
|
568
|
+
|
|
557
569
|
/**
|
|
558
570
|
* Samples a blurred version of the texture by defining an internal bias.
|
|
559
571
|
*
|
|
@@ -58,6 +58,18 @@ class ArrayNode extends TempNode {
|
|
|
58
58
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Returns the number of elements in the node array.
|
|
63
|
+
*
|
|
64
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
65
|
+
* @return {number} The number of elements in the node array.
|
|
66
|
+
*/
|
|
67
|
+
getArrayCount( /*builder*/ ) {
|
|
68
|
+
|
|
69
|
+
return this.count;
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
61
73
|
/**
|
|
62
74
|
* Returns the node's type.
|
|
63
75
|
*
|
|
@@ -97,6 +97,9 @@ class AssignNode extends TempNode {
|
|
|
97
97
|
|
|
98
98
|
const { targetNode, sourceNode } = this;
|
|
99
99
|
|
|
100
|
+
const targetProperties = builder.getNodeProperties( targetNode );
|
|
101
|
+
targetProperties.assign = true;
|
|
102
|
+
|
|
100
103
|
const properties = builder.getNodeProperties( this );
|
|
101
104
|
properties.sourceNode = sourceNode;
|
|
102
105
|
properties.targetNode = targetNode.context( { assign: true } );
|
|
@@ -131,16 +131,35 @@ export default ContextNode;
|
|
|
131
131
|
*/
|
|
132
132
|
export const context = /*@__PURE__*/ nodeProxy( ContextNode ).setParameterLength( 1, 2 );
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* TSL function for defining a name for the context value for a given node.
|
|
136
|
+
*
|
|
137
|
+
* @tsl
|
|
138
|
+
* @function
|
|
139
|
+
* @param {Node} node - The node whose context should be modified.
|
|
140
|
+
* @param {string} name - The name to set.
|
|
141
|
+
* @returns {ContextNode}
|
|
142
|
+
*/
|
|
143
|
+
export const setName = ( node, name ) => context( node, { nodeName: name } );
|
|
144
|
+
|
|
134
145
|
/**
|
|
135
146
|
* TSL function for defining a label context value for a given node.
|
|
136
147
|
*
|
|
137
148
|
* @tsl
|
|
138
149
|
* @function
|
|
150
|
+
* @deprecated
|
|
139
151
|
* @param {Node} node - The node whose context should be modified.
|
|
140
152
|
* @param {string} name - The name/label to set.
|
|
141
153
|
* @returns {ContextNode}
|
|
142
154
|
*/
|
|
143
|
-
export
|
|
155
|
+
export function label( node, name ) {
|
|
156
|
+
|
|
157
|
+
console.warn( 'THREE.TSL: "label()" has been deprecated. Use "setName()" instead.' ); // @deprecated r179
|
|
158
|
+
|
|
159
|
+
return setName( node, name );
|
|
160
|
+
|
|
161
|
+
}
|
|
144
162
|
|
|
145
163
|
addMethodChaining( 'context', context );
|
|
146
164
|
addMethodChaining( 'label', label );
|
|
165
|
+
addMethodChaining( 'setName', setName );
|
package/src/nodes/core/Node.js
CHANGED
|
@@ -480,10 +480,22 @@ class Node extends EventDispatcher {
|
|
|
480
480
|
|
|
481
481
|
}
|
|
482
482
|
|
|
483
|
+
/**
|
|
484
|
+
* Returns the number of elements in the node array.
|
|
485
|
+
*
|
|
486
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
487
|
+
* @return {?number} The number of elements in the node array.
|
|
488
|
+
*/
|
|
489
|
+
getArrayCount( /*builder*/ ) {
|
|
490
|
+
|
|
491
|
+
return null;
|
|
492
|
+
|
|
493
|
+
}
|
|
494
|
+
|
|
483
495
|
/**
|
|
484
496
|
* Represents the setup stage which is the first step of the build process, see {@link Node#build} method.
|
|
485
|
-
* This method is often overwritten in derived modules to prepare the node which is used as
|
|
486
|
-
*
|
|
497
|
+
* This method is often overwritten in derived modules to prepare the node which is used as a node's output/result.
|
|
498
|
+
* If an output node is prepared, then it must be returned in the `return` statement of the derived module's setup function.
|
|
487
499
|
*
|
|
488
500
|
* @param {NodeBuilder} builder - The current node builder.
|
|
489
501
|
* @return {?Node} The output node.
|
|
@@ -196,7 +196,7 @@ class NodeBuilder {
|
|
|
196
196
|
/**
|
|
197
197
|
* A reference to the current fog node.
|
|
198
198
|
*
|
|
199
|
-
* @type {?
|
|
199
|
+
* @type {?Node}
|
|
200
200
|
* @default null
|
|
201
201
|
*/
|
|
202
202
|
this.fogNode = null;
|
|
@@ -1747,23 +1747,6 @@ class NodeBuilder {
|
|
|
1747
1747
|
|
|
1748
1748
|
}
|
|
1749
1749
|
|
|
1750
|
-
/**
|
|
1751
|
-
* Returns the array length.
|
|
1752
|
-
*
|
|
1753
|
-
* @param {Node} node - The node.
|
|
1754
|
-
* @return {?number} The array length.
|
|
1755
|
-
*/
|
|
1756
|
-
getArrayCount( node ) {
|
|
1757
|
-
|
|
1758
|
-
let count = null;
|
|
1759
|
-
|
|
1760
|
-
if ( node.isArrayNode ) count = node.count;
|
|
1761
|
-
else if ( node.isVarNode && node.node.isArrayNode ) count = node.node.count;
|
|
1762
|
-
|
|
1763
|
-
return count;
|
|
1764
|
-
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
1750
|
/**
|
|
1768
1751
|
* Returns an instance of {@link NodeVar} for the given variable node.
|
|
1769
1752
|
*
|
|
@@ -1807,7 +1790,7 @@ class NodeBuilder {
|
|
|
1807
1790
|
|
|
1808
1791
|
//
|
|
1809
1792
|
|
|
1810
|
-
const count =
|
|
1793
|
+
const count = node.getArrayCount( this );
|
|
1811
1794
|
|
|
1812
1795
|
nodeVar = new NodeVar( name, type, readOnly, count );
|
|
1813
1796
|
|
|
@@ -2233,6 +2216,28 @@ class NodeBuilder {
|
|
|
2233
2216
|
|
|
2234
2217
|
}
|
|
2235
2218
|
|
|
2219
|
+
/**
|
|
2220
|
+
* Executes the node in a specific build stage.
|
|
2221
|
+
*
|
|
2222
|
+
* @param {Node} node - The node to execute.
|
|
2223
|
+
* @param {string} buildStage - The build stage to execute the node in.
|
|
2224
|
+
* @param {Node|string|null} output - Expected output type. For example 'vec3'.
|
|
2225
|
+
* @return {Node|string|null} The result of the node build.
|
|
2226
|
+
*/
|
|
2227
|
+
flowBuildStage( node, buildStage, output = null ) {
|
|
2228
|
+
|
|
2229
|
+
const previousBuildStage = this.getBuildStage();
|
|
2230
|
+
|
|
2231
|
+
this.setBuildStage( buildStage );
|
|
2232
|
+
|
|
2233
|
+
const result = node.build( this, output );
|
|
2234
|
+
|
|
2235
|
+
this.setBuildStage( previousBuildStage );
|
|
2236
|
+
|
|
2237
|
+
return result;
|
|
2238
|
+
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2236
2241
|
/**
|
|
2237
2242
|
* Runs the node flow through all the steps of creation, 'setup', 'analyze', 'generate'.
|
|
2238
2243
|
*
|
|
@@ -2743,7 +2748,7 @@ class NodeBuilder {
|
|
|
2743
2748
|
|
|
2744
2749
|
}
|
|
2745
2750
|
|
|
2746
|
-
// setup() -> stage 1: create possible new nodes and
|
|
2751
|
+
// setup() -> stage 1: create possible new nodes and/or return an output reference node
|
|
2747
2752
|
// analyze() -> stage 2: analyze nodes to possible optimization and validation
|
|
2748
2753
|
// generate() -> stage 3: generate shader
|
|
2749
2754
|
|
|
@@ -138,10 +138,13 @@ export function* getNodeChildren( node, toJSON = false ) {
|
|
|
138
138
|
|
|
139
139
|
yield { property, childNode: object };
|
|
140
140
|
|
|
141
|
-
} else if (
|
|
141
|
+
} else if ( object && Object.getPrototypeOf( object ) === Object.prototype ) {
|
|
142
142
|
|
|
143
143
|
for ( const subProperty in object ) {
|
|
144
144
|
|
|
145
|
+
// Ignore private properties.
|
|
146
|
+
if ( subProperty.startsWith( '_' ) === true ) continue;
|
|
147
|
+
|
|
145
148
|
const child = object[ subProperty ];
|
|
146
149
|
|
|
147
150
|
if ( child && ( child.isNode === true || toJSON && typeof child.toJSON === 'function' ) ) {
|