File tree Expand file tree Collapse file tree 5 files changed +24
-52
lines changed
Expand file tree Collapse file tree 5 files changed +24
-52
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { materialReference } from '../../nodes/accessors/MaterialReferenceNode.j
33import { diffuseColor } from '../../nodes/core/PropertyNode.js' ;
44import { vec3 } from '../../nodes/tsl/TSLBase.js' ;
55import { mix } from '../../nodes/math/MathNode.js' ;
6- import { matcapUV } from '../../nodes/utils/MatcapUVNode .js' ;
6+ import { matcapUV } from '../../nodes/utils/MatcapUV .js' ;
77
88import { MeshMatcapMaterial } from '../MeshMatcapMaterial.js' ;
99
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ export { default as EquirectUVNode } from './utils/EquirectUVNode.js';
4545export { default as FunctionOverloadingNode } from './utils/FunctionOverloadingNode.js' ;
4646export { default as JoinNode } from './utils/JoinNode.js' ;
4747export { default as LoopNode } from './utils/LoopNode.js' ;
48- export { default as MatcapUVNode } from './utils/MatcapUVNode.js' ;
4948export { default as MaxMipLevelNode } from './utils/MaxMipLevelNode.js' ;
5049export { default as RemapNode } from './utils/RemapNode.js' ;
5150export { default as RotateNode } from './utils/RotateNode.js' ;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export * from './math/TriNoise3D.js';
2727export * from './utils/EquirectUVNode.js' ;
2828export * from './utils/FunctionOverloadingNode.js' ;
2929export * from './utils/LoopNode.js' ;
30- export * from './utils/MatcapUVNode .js' ;
30+ export * from './utils/MatcapUV .js' ;
3131export * from './utils/MaxMipLevelNode.js' ;
3232export * from './utils/Oscillators.js' ;
3333export * from './utils/Packing.js' ;
Original file line number Diff line number Diff line change 1+ import { normalView } from '../accessors/Normal.js' ;
2+ import { positionViewDirection } from '../accessors/Position.js' ;
3+ import { Fn , vec2 , vec3 } from '../tsl/TSLBase.js' ;
4+
5+ /**
6+ * TSL function for creating a matcap uv node.
7+ *
8+ * Can be used to compute texture coordinates for projecting a
9+ * matcap onto a mesh. Used by {@link MeshMatcapNodeMaterial}.
10+ *
11+ * @tsl
12+ * @function
13+ * @returns {Node<vec2> } The matcap UV coordinates.
14+ */
15+ export const matcapUV = /*@__PURE__ */ Fn ( ( ) => {
16+
17+ const x = vec3 ( positionViewDirection . z , 0 , positionViewDirection . x . negate ( ) ) . normalize ( ) ;
18+ const y = positionViewDirection . cross ( x ) ;
19+
20+ return vec2 ( x . dot ( normalView ) , y . dot ( normalView ) ) . mul ( 0.495 ) . add ( 0.5 ) ; // 0.495 to remove artifacts caused by undersized matcap disks
21+
22+ } ) . once ( [ 'NORMAL' , 'VERTEX' ] ) ( ) . toVar ( 'matcapUV' ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments