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
4 changes: 2 additions & 2 deletions examples/webgpu_tsl_angular_slicing.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<script type="module">

import * as THREE from 'three/webgpu';
import { If, PI2, atan, color, frontFacing, output, positionLocal, Fn, uniform, vec4 } from 'three/tsl';
import { If, TWO_PI, atan, color, frontFacing, output, positionLocal, Fn, uniform, vec4 } from 'three/tsl';

import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
Expand Down Expand Up @@ -80,7 +80,7 @@

const inAngle = Fn( ( [ position, angleStart, angleArc ] ) => {

const angle = atan( position.y, position.x ).sub( angleStart ).mod( PI2 ).toVar();
const angle = atan( position.y, position.x ).sub( angleStart ).mod( TWO_PI ).toVar();
return angle.greaterThan( 0 ).and( angle.lessThan( angleArc ) );

} );
Expand Down
4 changes: 2 additions & 2 deletions examples/webgpu_tsl_galaxy.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<script type="module">

import * as THREE from 'three/webgpu';
import { color, cos, float, mix, range, sin, time, uniform, uv, vec3, vec4, PI2 } from 'three/tsl';
import { color, cos, float, mix, range, sin, time, uniform, uv, vec3, vec4, TWO_PI } from 'three/tsl';

import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
Expand Down Expand Up @@ -59,7 +59,7 @@
const radius = radiusRatio.pow( 1.5 ).mul( 5 ).toVar();

const branches = 3;
const branchAngle = range( 0, branches ).floor().mul( PI2.div( branches ) );
const branchAngle = range( 0, branches ).floor().mul( TWO_PI.div( branches ) );
const angle = branchAngle.add( time.mul( radiusRatio.oneMinus() ) );

const position = vec3(
Expand Down
6 changes: 3 additions & 3 deletions examples/webgpu_tsl_vfx_flames.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<script type="module">

import * as THREE from 'three/webgpu';
import { PI2, oneMinus, spherizeUV, sin, step, texture, time, Fn, uv, vec2, vec3, vec4, mix, billboarding } from 'three/tsl';
import { TWO_PI, oneMinus, spherizeUV, sin, step, texture, time, Fn, uv, vec2, vec3, vec4, mix, billboarding } from 'three/tsl';

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';

Expand Down Expand Up @@ -104,7 +104,7 @@
mainUv.assign( mainUv.mul( 2, 1 ).sub( vec2( 0.5, 0 ) ) ); // scale

// gradients
const gradient1 = sin( time.mul( 10 ).sub( mainUv.y.mul( PI2 ).mul( 2 ) ) ).toVar();
const gradient1 = sin( time.mul( 10 ).sub( mainUv.y.mul( TWO_PI ).mul( 2 ) ) ).toVar();
const gradient2 = mainUv.y.smoothstep( 0, 1 ).toVar();
mainUv.x.addAssign( gradient1.mul( gradient2 ).mul( 0.2 ) );

Expand Down Expand Up @@ -145,7 +145,7 @@
mainUv.x.addAssign( perlinNoise.x.mul( 0.5 ) );

// gradients
const gradient1 = sin( time.mul( 10 ).sub( mainUv.y.mul( PI2 ).mul( 2 ) ) );
const gradient1 = sin( time.mul( 10 ).sub( mainUv.y.mul( TWO_PI ).mul( 2 ) ) );
const gradient2 = mainUv.y.smoothstep( 0, 1 );
const gradient3 = oneMinus( mainUv.y ).smoothstep( 0, 0.3 );
mainUv.x.addAssign( gradient1.mul( gradient2 ).mul( 0.2 ) );
Expand Down
6 changes: 3 additions & 3 deletions examples/webgpu_tsl_vfx_linkedparticles.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<script type="module">

import * as THREE from 'three/webgpu';
import { atan, cos, float, max, min, mix, PI, PI2, sin, vec2, vec3, color, Fn, hash, hue, If, instanceIndex, Loop, mx_fractal_noise_float, mx_fractal_noise_vec3, pass, pcurve, storage, deltaTime, time, uv, uniform, step } from 'three/tsl';
import { atan, cos, float, max, min, mix, PI, TWO_PI, sin, vec2, vec3, color, Fn, hash, hue, If, instanceIndex, Loop, mx_fractal_noise_float, mx_fractal_noise_vec3, pass, pcurve, storage, deltaTime, time, uv, uniform, step } from 'three/tsl';
import { bloom } from 'three/addons/tsl/display/BloomNode.js';

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
Expand Down Expand Up @@ -142,7 +142,7 @@
const life = particlePositions.toAttribute().w;
const modLife = pcurve( life.oneMinus(), 8.0, 1.0 );
const pulse = pcurve(
sin( hash( instanceIndex ).mul( PI2 ).add( time.mul( 0.5 ).mul( PI2 ) ) ).mul( 0.5 ).add( 0.5 ),
sin( hash( instanceIndex ).mul( TWO_PI ).add( time.mul( 0.5 ).mul( TWO_PI ) ) ).mul( 0.5 ).add( 0.5 ),
0.25,
0.25
).mul( 10.0 ).add( 1.0 );
Expand Down Expand Up @@ -318,7 +318,7 @@

// random spherical direction
const rRange = float( 0.01 );
const rTheta = hash( particleIndex ).mul( PI2 );
const rTheta = hash( particleIndex ).mul( TWO_PI );
const rPhi = hash( particleIndex.add( 1 ) ).mul( PI );
const rx = sin( rTheta ).mul( cos( rPhi ) );
const ry = sin( rTheta ).mul( sin( rPhi ) );
Expand Down
4 changes: 2 additions & 2 deletions examples/webgpu_tsl_vfx_tornado.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<script type="module">

import * as THREE from 'three/webgpu';
import { luminance, cos, min, time, atan, uniform, pass, PI, PI2, color, positionLocal, sin, texture, Fn, uv, vec2, vec3, vec4 } from 'three/tsl';
import { luminance, cos, min, time, atan, uniform, pass, PI, TWO_PI, color, positionLocal, sin, texture, Fn, uv, vec2, vec3, vec4 } from 'three/tsl';
import { bloom } from 'three/addons/tsl/display/BloomNode.js';

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
Expand Down Expand Up @@ -59,7 +59,7 @@
const centeredUv = uv.sub( 0.5 ).toVar();
const distanceToCenter = centeredUv.length();
const angle = atan( centeredUv.y, centeredUv.x );
const radialUv = vec2( angle.add( PI ).div( PI2 ), distanceToCenter ).toVar();
const radialUv = vec2( angle.add( PI ).div( TWO_PI ), distanceToCenter ).toVar();
radialUv.mulAssign( multiplier );
radialUv.x.addAssign( rotation );
radialUv.y.addAssign( offset );
Expand Down
2 changes: 2 additions & 0 deletions src/Three.TSL.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const PCFShadowFilter = TSL.PCFShadowFilter;
export const PCFSoftShadowFilter = TSL.PCFSoftShadowFilter;
export const PI = TSL.PI;
export const PI2 = TSL.PI2;
export const TWO_PI = TSL.TWO_PI;
export const HALF_PI = TSL.HALF_PI;
export const PointShadowFilter = TSL.PointShadowFilter;
export const Return = TSL.Return;
export const Schlick_to_F0 = TSL.Schlick_to_F0;
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/display/ColorAdjustment.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const hue = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => {
* @function
* @param {Node<vec3>} color - The color value to compute the luminance for.
* @param {?Node<vec3>} luminanceCoefficients - The luminance coefficients. By default predefined values of the current working color space are used.
* @return {Node<vec3>} The luminance.
* @return {Node<float>} The luminance.
*/
export const luminance = (
color,
Expand Down
19 changes: 18 additions & 1 deletion src/nodes/math/MathNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,30 @@ export const INFINITY = /*@__PURE__*/ float( 1e6 );
*/
export const PI = /*@__PURE__*/ float( Math.PI );

/**
* Represents PI * 2. Please use the non-deprecated version `TWO_PI`.
*
* @tsl
* @deprecated
* @type {Node<float>}
*/
export const PI2 = /*@__PURE__*/ float( Math.PI * 2 ); // @deprecated r181

/**
* Represents PI * 2.
*
* @tsl
* @type {Node<float>}
*/
export const PI2 = /*@__PURE__*/ float( Math.PI * 2 );
export const TWO_PI = /*@__PURE__*/ float( Math.PI * 2 );

/**
* Represents PI / 2.
*
* @tsl
* @type {Node<float>}
*/
export const HALF_PI = /*@__PURE__*/ float( Math.PI * 0.5 );

/**
* Returns `true` if all components of `x` are `true`.
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/math/OperatorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ export const bitAnd = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '&' ).setPara
* @param {Node} b - The second input.
* @returns {OperatorNode}
*/
export const bitNot = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '~' ).setParameterLength( 2 ).setName( 'bitNot' );
export const bitNot = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '~' ).setParameterLength( 1 ).setName( 'bitNot' );

/**
* Performs bitwise OR on two nodes.
Expand Down
Loading