Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export { NodeUtils };
// utils
export { default as ArrayElementNode } from './utils/ArrayElementNode.js';
export { default as ConvertNode } from './utils/ConvertNode.js';
export { default as EquirectUVNode } from './utils/EquirectUVNode.js';
export { default as FunctionOverloadingNode } from './utils/FunctionOverloadingNode.js';
export { default as JoinNode } from './utils/JoinNode.js';
export { default as LoopNode } from './utils/LoopNode.js';
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/TSL.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export * from './math/MathUtils.js';
export * from './math/TriNoise3D.js';

// utils
export * from './utils/EquirectUVNode.js';
export * from './utils/EquirectUV.js';
export * from './utils/FunctionOverloadingNode.js';
export * from './utils/LoopNode.js';
export * from './utils/MatcapUVNode.js';
Expand Down
27 changes: 27 additions & 0 deletions src/nodes/utils/EquirectUV.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { positionWorldDirection } from '../accessors/Position.js';
import { Fn, vec2 } from '../tsl/TSLBase.js';

/**
* TSL function for creating an equirect uv node.
*
* Can be used to compute texture coordinates for projecting an
* equirectangular texture onto a mesh for using it as the scene's
* background.
*
* ```js
* scene.backgroundNode = texture( equirectTexture, equirectUV() );
* ```
*
* @tsl
* @function
* @param {?Node<vec3>} [dirNode=positionWorldDirection] - A direction vector for sampling which is by default `positionWorldDirection`.
* @returns {Node<vec2>}
*/
export const equirectUV = /*@__PURE__*/ Fn( ( [ dir = positionWorldDirection ] ) => {

const u = dir.z.atan( dir.x ).mul( 1 / ( Math.PI * 2 ) ).add( 0.5 );
const v = dir.y.clamp( - 1.0, 1.0 ).asin().mul( 1 / Math.PI ).add( 0.5 );

return vec2( u, v );

} );
65 changes: 0 additions & 65 deletions src/nodes/utils/EquirectUVNode.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/renderers/common/CubeRenderTarget.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { equirectUV } from '../../nodes/utils/EquirectUVNode.js';
import { equirectUV } from '../../nodes/utils/EquirectUV.js';
import { texture as TSL_Texture } from '../../nodes/accessors/TextureNode.js';
import { positionWorldDirection } from '../../nodes/accessors/Position.js';
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/common/extras/PMREMGenerator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import NodeMaterial from '../../../materials/nodes/NodeMaterial.js';
import { getDirection, blur } from '../../../nodes/pmrem/PMREMUtils.js';
import { equirectUV } from '../../../nodes/utils/EquirectUVNode.js';
import { equirectUV } from '../../../nodes/utils/EquirectUV.js';
import { uniform } from '../../../nodes/core/UniformNode.js';
import { uniformArray } from '../../../nodes/accessors/UniformArrayNode.js';
import { texture } from '../../../nodes/accessors/TextureNode.js';
Expand Down