super-three 0.177.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 +959 -231
- package/build/three.core.js +751 -170
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +210 -64
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +78 -29
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3269 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3093 -1545
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -2
- package/examples/jsm/capabilities/WebGL.js +0 -27
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +61 -14
- 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/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- 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 +95 -16
- 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/AST.js +381 -30
- package/examples/jsm/transpiler/GLSLDecoder.js +226 -86
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/TSLEncoder.js +197 -92
- package/examples/jsm/transpiler/Transpiler.js +17 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
- package/examples/jsm/tsl/display/BloomNode.js +8 -7
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +8 -10
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/hashBlur.js +3 -3
- 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 +77 -28
- package/src/Three.WebGPU.js +2 -0
- 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 +3 -3
- package/src/core/BufferAttribute.js +3 -3
- package/src/core/Clock.js +2 -8
- package/src/core/GLBufferAttribute.js +13 -1
- package/src/core/Object3D.js +1 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/core/Path.js +22 -22
- 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 +27 -4
- package/src/loaders/ImageBitmapLoader.js +27 -4
- package/src/loaders/ImageLoader.js +55 -8
- 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/MeshBasicNodeMaterial.js +4 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
- package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
- package/src/materials/nodes/NodeMaterial.js +28 -5
- package/src/materials/nodes/PointsNodeMaterial.js +5 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/Frustum.js +25 -9
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Quaternion.js +1 -1
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +2 -3
- package/src/nodes/TSL.js +5 -3
- package/src/nodes/accessors/AccessorsUtils.js +7 -8
- package/src/nodes/accessors/Bitangent.js +31 -25
- package/src/nodes/accessors/Camera.js +12 -12
- package/src/nodes/accessors/Normal.js +95 -29
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +7 -7
- package/src/nodes/accessors/ReferenceNode.js +18 -3
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Tangent.js +25 -17
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/TextureBicubic.js +21 -3
- package/src/nodes/accessors/TextureNode.js +12 -0
- package/src/nodes/accessors/UniformArrayNode.js +0 -16
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +3 -0
- package/src/nodes/core/CacheNode.js +0 -14
- package/src/nodes/core/ContextNode.js +20 -1
- package/src/nodes/core/Node.js +15 -3
- package/src/nodes/core/NodeBuilder.js +228 -92
- package/src/nodes/core/NodeUtils.js +4 -1
- package/src/nodes/core/StackNode.js +49 -29
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/UniformNode.js +63 -5
- package/src/nodes/core/VarNode.js +91 -2
- package/src/nodes/core/VaryingNode.js +6 -4
- package/src/nodes/display/BlendModes.js +2 -2
- package/src/nodes/display/FrontFacingNode.js +34 -2
- package/src/nodes/display/NormalMapNode.js +19 -50
- package/src/nodes/display/PassNode.js +157 -9
- package/src/nodes/display/ScreenNode.js +0 -26
- package/src/nodes/display/ViewportTextureNode.js +67 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/PhongLightingModel.js +3 -3
- package/src/nodes/functions/PhysicalLightingModel.js +16 -16
- package/src/nodes/functions/material/getGeometryRoughness.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/EnvironmentNode.js +5 -5
- package/src/nodes/lighting/LightsNode.js +4 -4
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/lighting/ShadowNode.js +2 -2
- 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 -20
- package/src/nodes/math/MathNode.js +90 -55
- package/src/nodes/math/OperatorNode.js +22 -39
- package/src/nodes/tsl/TSLBase.js +1 -0
- package/src/nodes/tsl/TSLCore.js +114 -55
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/LoopNode.js +0 -17
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/RTTNode.js +22 -5
- package/src/nodes/utils/ReflectorNode.js +11 -4
- package/src/nodes/utils/SampleNode.js +81 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/objects/BatchedMesh.js +4 -2
- package/src/renderers/WebGLRenderer.js +26 -24
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/Bindings.js +19 -18
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderObject.js +68 -3
- package/src/renderers/common/Renderer.js +19 -16
- package/src/renderers/common/SampledTexture.js +3 -71
- package/src/renderers/common/Sampler.js +79 -0
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +19 -3
- package/src/renderers/common/XRManager.js +31 -12
- package/src/renderers/common/XRRenderTarget.js +21 -4
- package/src/renderers/common/extras/PMREMGenerator.js +1 -1
- 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/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +12 -6
- package/src/renderers/webgl/WebGLPrograms.js +6 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLState.js +4 -4
- package/src/renderers/webgl/WebGLTextures.js +19 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +103 -72
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -5
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +2 -0
- package/src/renderers/webgpu/WebGPUBackend.js +63 -16
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +64 -79
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -0
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +12 -65
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +68 -6
- 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/nodes/utils/EquirectUVNode.js +0 -65
- package/src/nodes/utils/MatcapUVNode.js +0 -49
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
|
@@ -35,9 +35,9 @@ export const positionPrevious = /*@__PURE__*/ positionGeometry.toVarying( 'posit
|
|
|
35
35
|
*/
|
|
36
36
|
export const positionWorld = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
37
37
|
|
|
38
|
-
return modelWorldMatrix.mul( positionLocal ).xyz.toVarying( builder.
|
|
38
|
+
return modelWorldMatrix.mul( positionLocal ).xyz.toVarying( builder.getSubBuildProperty( 'v_positionWorld' ) );
|
|
39
39
|
|
|
40
|
-
}, 'vec3' ).once( 'POSITION' ) )();
|
|
40
|
+
}, 'vec3' ).once( [ 'POSITION' ] ) )();
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* TSL object that represents the position world direction of the current rendered object.
|
|
@@ -45,13 +45,13 @@ export const positionWorld = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
45
45
|
* @tsl
|
|
46
46
|
* @type {Node<vec3>}
|
|
47
47
|
*/
|
|
48
|
-
export const positionWorldDirection = /*@__PURE__*/ ( Fn( (
|
|
48
|
+
export const positionWorldDirection = /*@__PURE__*/ ( Fn( () => {
|
|
49
49
|
|
|
50
|
-
const vertexPWD = positionLocal.transformDirection( modelWorldMatrix ).toVarying(
|
|
50
|
+
const vertexPWD = positionLocal.transformDirection( modelWorldMatrix ).toVarying( 'v_positionWorldDirection' );
|
|
51
51
|
|
|
52
52
|
return vertexPWD.normalize().toVar( 'positionWorldDirection' );
|
|
53
53
|
|
|
54
|
-
}, 'vec3' ).once( 'POSITION' ) )();
|
|
54
|
+
}, 'vec3' ).once( [ 'POSITION' ] ) )();
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* TSL object that represents the vertex position in view space of the current rendered object.
|
|
@@ -61,9 +61,9 @@ export const positionWorldDirection = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
|
61
61
|
*/
|
|
62
62
|
export const positionView = /*@__PURE__*/ ( Fn( ( builder ) => {
|
|
63
63
|
|
|
64
|
-
return builder.context.setupPositionView().toVarying(
|
|
64
|
+
return builder.context.setupPositionView().toVarying( 'v_positionView' );
|
|
65
65
|
|
|
66
|
-
}, 'vec3' ).once( 'POSITION' ) )();
|
|
66
|
+
}, 'vec3' ).once( [ 'POSITION' ] ) )();
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* TSL object that represents the position view direction of the current rendered object.
|
|
@@ -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
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cameraViewMatrix } from './Camera.js';
|
|
2
|
-
import {
|
|
2
|
+
import { normalView } from './Normal.js';
|
|
3
3
|
import { positionViewDirection } from './Position.js';
|
|
4
4
|
import { materialRefractionRatio } from './MaterialProperties.js';
|
|
5
5
|
|
|
@@ -9,7 +9,7 @@ import { materialRefractionRatio } from './MaterialProperties.js';
|
|
|
9
9
|
* @tsl
|
|
10
10
|
* @type {Node<vec3>}
|
|
11
11
|
*/
|
|
12
|
-
export const reflectView = /*@__PURE__*/ positionViewDirection.negate().reflect(
|
|
12
|
+
export const reflectView = /*@__PURE__*/ positionViewDirection.negate().reflect( normalView );
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* The refract vector in view space.
|
|
@@ -17,7 +17,7 @@ export const reflectView = /*@__PURE__*/ positionViewDirection.negate().reflect(
|
|
|
17
17
|
* @tsl
|
|
18
18
|
* @type {Node<vec3>}
|
|
19
19
|
*/
|
|
20
|
-
export const refractView = /*@__PURE__*/ positionViewDirection.negate().refract(
|
|
20
|
+
export const refractView = /*@__PURE__*/ positionViewDirection.negate().refract( normalView, materialRefractionRatio );
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Used for sampling cube maps when using cube reflection mapping.
|
|
@@ -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
|
|
|
@@ -2,6 +2,8 @@ import { attribute } from '../core/AttributeNode.js';
|
|
|
2
2
|
import { cameraViewMatrix } from './Camera.js';
|
|
3
3
|
import { modelViewMatrix } from './ModelNode.js';
|
|
4
4
|
import { Fn, vec4 } from '../tsl/TSLBase.js';
|
|
5
|
+
import { tangentViewFrame } from './TangentUtils.js';
|
|
6
|
+
import { directionToFaceDirection } from '../display/FrontFacingNode.js';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* TSL object that represents the tangent attribute of the current rendered object.
|
|
@@ -35,28 +37,34 @@ export const tangentLocal = /*@__PURE__*/ tangentGeometry.xyz.toVar( 'tangentLoc
|
|
|
35
37
|
* @tsl
|
|
36
38
|
* @type {Node<vec3>}
|
|
37
39
|
*/
|
|
38
|
-
export const tangentView = /*@__PURE__*/
|
|
40
|
+
export const tangentView = /*@__PURE__*/ ( Fn( ( { subBuildFn, geometry, material } ) => {
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
* TSL object that represents the vertex tangent in world space of the current rendered object.
|
|
42
|
-
*
|
|
43
|
-
* @tsl
|
|
44
|
-
* @type {Node<vec3>}
|
|
45
|
-
*/
|
|
46
|
-
export const tangentWorld = /*@__PURE__*/ tangentView.transformDirection( cameraViewMatrix ).toVarying( 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' );
|
|
42
|
+
let node;
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
if ( subBuildFn === 'VERTEX' || geometry.hasAttribute( 'tangent' ) ) {
|
|
45
|
+
|
|
46
|
+
node = modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz.toVarying( 'v_tangentView' ).normalize();
|
|
47
|
+
|
|
48
|
+
} else {
|
|
49
|
+
|
|
50
|
+
node = tangentViewFrame;
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if ( material.flatShading !== true ) {
|
|
55
|
+
|
|
56
|
+
node = directionToFaceDirection( node );
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return node;
|
|
61
|
+
|
|
62
|
+
}, 'vec3' ).once( [ 'NORMAL', 'VERTEX' ] ) )().toVar( 'tangentView' );
|
|
55
63
|
|
|
56
64
|
/**
|
|
57
|
-
* TSL object that represents the
|
|
65
|
+
* TSL object that represents the vertex tangent in world space of the current rendered object.
|
|
58
66
|
*
|
|
59
67
|
* @tsl
|
|
60
68
|
* @type {Node<vec3>}
|
|
61
69
|
*/
|
|
62
|
-
export const
|
|
70
|
+
export const tangentWorld = /*@__PURE__*/ tangentView.transformDirection( cameraViewMatrix ).toVarying( 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' );
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { uv as getUV } from './UV.js';
|
|
2
|
+
import { positionView } from './Position.js';
|
|
3
|
+
import { normalView } from './Normal.js';
|
|
4
|
+
|
|
5
|
+
// Normal Mapping Without Precomputed Tangents
|
|
6
|
+
// http://www.thetenthplanet.de/archives/1180
|
|
7
|
+
|
|
8
|
+
const uv = getUV();
|
|
9
|
+
|
|
10
|
+
const q0 = positionView.dFdx();
|
|
11
|
+
const q1 = positionView.dFdy();
|
|
12
|
+
const st0 = uv.dFdx();
|
|
13
|
+
const st1 = uv.dFdy();
|
|
14
|
+
|
|
15
|
+
const N = normalView;
|
|
16
|
+
|
|
17
|
+
const q1perp = q1.cross( N );
|
|
18
|
+
const q0perp = N.cross( q0 );
|
|
19
|
+
|
|
20
|
+
const T = q1perp.mul( st0.x ).add( q0perp.mul( st1.x ) );
|
|
21
|
+
const B = q1perp.mul( st0.y ).add( q0perp.mul( st1.y ) );
|
|
22
|
+
|
|
23
|
+
const det = T.dot( T ).max( B.dot( B ) );
|
|
24
|
+
const scale = det.equal( 0.0 ).select( 0.0, det.inverseSqrt() );
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Tangent vector in view space, computed dynamically from geometry and UV derivatives.
|
|
28
|
+
* Useful for normal mapping without precomputed tangents.
|
|
29
|
+
*
|
|
30
|
+
* Reference: http://www.thetenthplanet.de/archives/1180
|
|
31
|
+
*
|
|
32
|
+
* @tsl
|
|
33
|
+
* @type {Node<vec3>}
|
|
34
|
+
*/
|
|
35
|
+
export const tangentViewFrame = /*@__PURE__*/ T.mul( scale ).toVar( 'tangentViewFrame' );
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Bitangent vector in view space, computed dynamically from geometry and UV derivatives.
|
|
39
|
+
* Complements the tangentViewFrame for constructing the tangent space basis.
|
|
40
|
+
*
|
|
41
|
+
* Reference: http://www.thetenthplanet.de/archives/1180
|
|
42
|
+
*
|
|
43
|
+
* @tsl
|
|
44
|
+
* @type {Node<vec3>}
|
|
45
|
+
*/
|
|
46
|
+
export const bitangentViewFrame = /*@__PURE__*/ B.mul( scale ).toVar( 'bitangentViewFrame' );
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { add, mul, div } from '../math/OperatorNode.js';
|
|
2
2
|
import { floor, ceil, fract, pow } from '../math/MathNode.js';
|
|
3
|
-
import { Fn,
|
|
3
|
+
import { Fn, vec2, vec4, int } from '../tsl/TSLBase.js';
|
|
4
|
+
import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
|
|
4
5
|
|
|
5
6
|
// Mipped Bicubic Texture Filtering by N8
|
|
6
7
|
// https://www.shadertoy.com/view/Dl2SDW
|
|
@@ -57,10 +58,10 @@ const bicubic = ( textureNode, texelSize, lod ) => {
|
|
|
57
58
|
* @tsl
|
|
58
59
|
* @function
|
|
59
60
|
* @param {TextureNode} textureNode - The texture node that should be filtered.
|
|
60
|
-
* @param {Node<float>}
|
|
61
|
+
* @param {Node<float>} lodNode - Defines the LOD to sample from.
|
|
61
62
|
* @return {Node} The filtered texture sample.
|
|
62
63
|
*/
|
|
63
|
-
export const
|
|
64
|
+
export const textureBicubicLevel = /*@__PURE__*/ Fn( ( [ textureNode, lodNode ] ) => {
|
|
64
65
|
|
|
65
66
|
const fLodSize = vec2( textureNode.size( int( lodNode ) ) );
|
|
66
67
|
const cLodSize = vec2( textureNode.size( int( lodNode.add( 1.0 ) ) ) );
|
|
@@ -72,3 +73,20 @@ export const textureBicubic = /*@__PURE__*/ Fn( ( [ textureNode, lodNode = float
|
|
|
72
73
|
return fract( lodNode ).mix( fSample, cSample );
|
|
73
74
|
|
|
74
75
|
} );
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Applies mipped bicubic texture filtering to the given texture node.
|
|
79
|
+
*
|
|
80
|
+
* @tsl
|
|
81
|
+
* @function
|
|
82
|
+
* @param {TextureNode} textureNode - The texture node that should be filtered.
|
|
83
|
+
* @param {Node<float>} [strength] - Defines the strength of the bicubic filtering.
|
|
84
|
+
* @return {Node} The filtered texture sample.
|
|
85
|
+
*/
|
|
86
|
+
export const textureBicubic = /*@__PURE__*/ Fn( ( [ textureNode, strength ] ) => {
|
|
87
|
+
|
|
88
|
+
const lod = strength.mul( maxMipLevel( textureNode ) );
|
|
89
|
+
|
|
90
|
+
return textureBicubicLevel( textureNode, lod );
|
|
91
|
+
|
|
92
|
+
} );
|
|
@@ -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
|
*
|
|
@@ -346,19 +346,3 @@ export default UniformArrayNode;
|
|
|
346
346
|
* @returns {UniformArrayNode}
|
|
347
347
|
*/
|
|
348
348
|
export const uniformArray = ( values, nodeType ) => nodeObject( new UniformArrayNode( values, nodeType ) );
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* @tsl
|
|
352
|
-
* @function
|
|
353
|
-
* @deprecated since r168. Use {@link uniformArray} instead.
|
|
354
|
-
*
|
|
355
|
-
* @param {Array<any>} values - Array-like data.
|
|
356
|
-
* @param {string} nodeType - The data type of the array elements.
|
|
357
|
-
* @returns {UniformArrayNode}
|
|
358
|
-
*/
|
|
359
|
-
export const uniforms = ( values, nodeType ) => { // @deprecated, r168
|
|
360
|
-
|
|
361
|
-
console.warn( 'THREE.TSL: uniforms() has been renamed to uniformArray().' );
|
|
362
|
-
return nodeObject( new UniformArrayNode( values, nodeType ) );
|
|
363
|
-
|
|
364
|
-
};
|
|
@@ -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 } );
|
|
@@ -97,18 +97,4 @@ export default CacheNode;
|
|
|
97
97
|
*/
|
|
98
98
|
export const cache = ( node, parent ) => nodeObject( new CacheNode( nodeObject( node ), parent ) );
|
|
99
99
|
|
|
100
|
-
/**
|
|
101
|
-
* Assigns a namespace to the given node by updating its context.
|
|
102
|
-
*
|
|
103
|
-
* Important for TSL functions that use `.once( namespace )` to ensure that the namespace will run twice,
|
|
104
|
-
* once when the node is build in the specific namespace and once when the node is built in the others namespace.
|
|
105
|
-
*
|
|
106
|
-
* This is useful for nodes like `positionWorld` that need to be re-updated if used in `material.positionNode` and outside of it in the same material.
|
|
107
|
-
*
|
|
108
|
-
* @param {Object} node - The node to which the namespace will be assigned.
|
|
109
|
-
* @param {string} namespace - The namespace to be assigned to the node.
|
|
110
|
-
* @returns {Object} The updated node with the new namespace in its context.
|
|
111
|
-
*/
|
|
112
|
-
export const namespace = ( node, namespace ) => node.context( { namespace } );
|
|
113
|
-
|
|
114
100
|
addMethodChaining( 'cache', cache );
|
|
@@ -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.
|
|
@@ -735,7 +747,7 @@ class Node extends EventDispatcher {
|
|
|
735
747
|
|
|
736
748
|
console.warn( 'THREE.Node: Recursion detected.', this );
|
|
737
749
|
|
|
738
|
-
result = '';
|
|
750
|
+
result = '/* Recursion detected. */';
|
|
739
751
|
|
|
740
752
|
}
|
|
741
753
|
|