فهرست منبع

Revert "TSL: add `addMethodsChaining` (#30201)" (#30217)

This reverts commit a7500fdc0c87acb219777e26bba9e1013b9786d5.
sunag 1 سال پیش
والد
کامیت
6462c8a103
3فایلهای تغییر یافته به همراه107 افزوده شده و 119 حذف شده
  1. 59 60
      src/nodes/math/MathNode.js
  2. 25 25
      src/nodes/math/OperatorNode.js
  3. 23 34
      src/nodes/tsl/TSLCore.js

+ 59 - 60
src/nodes/math/MathNode.js

@@ -1,6 +1,6 @@
 import TempNode from '../core/TempNode.js';
 import TempNode from '../core/TempNode.js';
 import { sub, mul, div } from './OperatorNode.js';
 import { sub, mul, div } from './OperatorNode.js';
-import { addMethodsChaining, nodeObject, nodeProxy, float, vec2, vec3, vec4, Fn } from '../tsl/TSLCore.js';
+import { addMethodChaining, nodeObject, nodeProxy, float, vec2, vec3, vec4, Fn } from '../tsl/TSLCore.js';
 import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../../constants.js';
 import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../../constants.js';
 
 
 /** @module MathNode **/
 /** @module MathNode **/
@@ -950,62 +950,61 @@ export const inversesqrt = inverseSqrt;
 
 
 // Method chaining
 // Method chaining
 
 
-addMethodsChaining( {
-	all: all,
-	any: any,
-	equals: equals,
-	radians: radians,
-	degrees: degrees,
-	exp: exp,
-	exp2: exp2,
-	log: log,
-	log2: log2,
-	sqrt: sqrt,
-	inverseSqrt: inverseSqrt,
-	floor: floor,
-	ceil: ceil,
-	normalize: normalize,
-	fract: fract,
-	sin: sin,
-	cos: cos,
-	tan: tan,
-	asin: asin,
-	acos: acos,
-	atan: atan,
-	abs: abs,
-	sign: sign,
-	length: length,
-	lengthSq: lengthSq,
-	negate: negate,
-	oneMinus: oneMinus,
-	dFdx: dFdx,
-	dFdy: dFdy,
-	round: round,
-	reciprocal: reciprocal,
-	trunc: trunc,
-	fwidth: fwidth,
-	atan2: atan2,
-	min: min,
-	max: max,
-	mod: mod,
-	step: step,
-	reflect: reflect,
-	distance: distance,
-	dot: dot,
-	cross: cross,
-	pow: pow,
-	pow2: pow2,
-	pow3: pow3,
-	pow4: pow4,
-	transformDirection: transformDirection,
-	mix: mixElement,
-	clamp: clamp,
-	refract: refract,
-	smoothstep: smoothstepElement,
-	faceForward: faceForward,
-	difference: difference,
-	saturate: saturate,
-	cbrt: cbrt,
-	transpose: transpose,
-	rand: rand
-} );
+addMethodChaining( 'all', all );
+addMethodChaining( 'any', any );
+addMethodChaining( 'equals', equals );
+
+addMethodChaining( 'radians', radians );
+addMethodChaining( 'degrees', degrees );
+addMethodChaining( 'exp', exp );
+addMethodChaining( 'exp2', exp2 );
+addMethodChaining( 'log', log );
+addMethodChaining( 'log2', log2 );
+addMethodChaining( 'sqrt', sqrt );
+addMethodChaining( 'inverseSqrt', inverseSqrt );
+addMethodChaining( 'floor', floor );
+addMethodChaining( 'ceil', ceil );
+addMethodChaining( 'normalize', normalize );
+addMethodChaining( 'fract', fract );
+addMethodChaining( 'sin', sin );
+addMethodChaining( 'cos', cos );
+addMethodChaining( 'tan', tan );
+addMethodChaining( 'asin', asin );
+addMethodChaining( 'acos', acos );
+addMethodChaining( 'atan', atan );
+addMethodChaining( 'abs', abs );
+addMethodChaining( 'sign', sign );
+addMethodChaining( 'length', length );
+addMethodChaining( 'lengthSq', lengthSq );
+addMethodChaining( 'negate', negate );
+addMethodChaining( 'oneMinus', oneMinus );
+addMethodChaining( 'dFdx', dFdx );
+addMethodChaining( 'dFdy', dFdy );
+addMethodChaining( 'round', round );
+addMethodChaining( 'reciprocal', reciprocal );
+addMethodChaining( 'trunc', trunc );
+addMethodChaining( 'fwidth', fwidth );
+addMethodChaining( 'atan2', atan2 );
+addMethodChaining( 'min', min );
+addMethodChaining( 'max', max );
+addMethodChaining( 'mod', mod );
+addMethodChaining( 'step', step );
+addMethodChaining( 'reflect', reflect );
+addMethodChaining( 'distance', distance );
+addMethodChaining( 'dot', dot );
+addMethodChaining( 'cross', cross );
+addMethodChaining( 'pow', pow );
+addMethodChaining( 'pow2', pow2 );
+addMethodChaining( 'pow3', pow3 );
+addMethodChaining( 'pow4', pow4 );
+addMethodChaining( 'transformDirection', transformDirection );
+addMethodChaining( 'mix', mixElement );
+addMethodChaining( 'clamp', clamp );
+addMethodChaining( 'refract', refract );
+addMethodChaining( 'smoothstep', smoothstepElement );
+addMethodChaining( 'faceForward', faceForward );
+addMethodChaining( 'difference', difference );
+addMethodChaining( 'saturate', saturate );
+addMethodChaining( 'cbrt', cbrt );
+addMethodChaining( 'transpose', transpose );
+addMethodChaining( 'rand', rand );

+ 25 - 25
src/nodes/math/OperatorNode.js

@@ -1,5 +1,5 @@
 import TempNode from '../core/TempNode.js';
 import TempNode from '../core/TempNode.js';
-import { addMethodsChaining, nodeProxy } from '../tsl/TSLCore.js';
+import { addMethodChaining, nodeProxy } from '../tsl/TSLCore.js';
 
 
 /** @module OperatorNode **/
 /** @module OperatorNode **/
 
 
@@ -519,6 +519,29 @@ export const shiftLeft = /*@__PURE__*/ nodeProxy( OperatorNode, '<<' );
  */
  */
 export const shiftRight = /*@__PURE__*/ nodeProxy( OperatorNode, '>>' );
 export const shiftRight = /*@__PURE__*/ nodeProxy( OperatorNode, '>>' );
 
 
+addMethodChaining( 'add', add );
+addMethodChaining( 'sub', sub );
+addMethodChaining( 'mul', mul );
+addMethodChaining( 'div', div );
+addMethodChaining( 'modInt', modInt );
+addMethodChaining( 'equal', equal );
+addMethodChaining( 'notEqual', notEqual );
+addMethodChaining( 'lessThan', lessThan );
+addMethodChaining( 'greaterThan', greaterThan );
+addMethodChaining( 'lessThanEqual', lessThanEqual );
+addMethodChaining( 'greaterThanEqual', greaterThanEqual );
+addMethodChaining( 'and', and );
+addMethodChaining( 'or', or );
+addMethodChaining( 'not', not );
+addMethodChaining( 'xor', xor );
+addMethodChaining( 'bitAnd', bitAnd );
+addMethodChaining( 'bitNot', bitNot );
+addMethodChaining( 'bitOr', bitOr );
+addMethodChaining( 'bitXor', bitXor );
+addMethodChaining( 'shiftLeft', shiftLeft );
+addMethodChaining( 'shiftRight', shiftRight );
+
+
 export const remainder = ( ...params ) => { // @deprecated, r168
 export const remainder = ( ...params ) => { // @deprecated, r168
 
 
 	console.warn( 'TSL.OperatorNode: .remainder() has been renamed to .modInt().' );
 	console.warn( 'TSL.OperatorNode: .remainder() has been renamed to .modInt().' );
@@ -526,27 +549,4 @@ export const remainder = ( ...params ) => { // @deprecated, r168
 
 
 };
 };
 
 
-addMethodsChaining( {
-	add: add,
-	sub: sub,
-	mul: mul,
-	div: div,
-	modInt: modInt,
-	equal: equal,
-	notEqual: notEqual,
-	lessThan: lessThan,
-	greaterThan: greaterThan,
-	lessThanEqual: lessThanEqual,
-	greaterThanEqual: greaterThanEqual,
-	and: and,
-	or: or,
-	not: not,
-	xor: xor,
-	bitAnd: bitAnd,
-	bitNot: bitNot,
-	bitOr: bitOr,
-	bitXor: bitXor,
-	shiftLeft: shiftLeft,
-	shiftRight: shiftRight,
-	remainder: remainder
-} );
+addMethodChaining( 'remainder', remainder );

+ 23 - 34
src/nodes/tsl/TSLCore.js

@@ -29,16 +29,6 @@ export function addMethodChaining( name, nodeElement ) {
 
 
 }
 }
 
 
-export function addMethodsChaining( object ) {
-
-	for ( const key in object ) {
-
-		addMethodChaining( key, object[ key ] );
-
-	}
-
-}
-
 const parseSwizzle = ( props ) => props.replace( /r|s/g, 'x' ).replace( /g|t/g, 'y' ).replace( /b|p/g, 'z' ).replace( /a|q/g, 'w' );
 const parseSwizzle = ( props ) => props.replace( /r|s/g, 'x' ).replace( /g|t/g, 'y' ).replace( /b|p/g, 'z' ).replace( /a|q/g, 'w' );
 const parseSwizzleAndSort = ( props ) => parseSwizzle( props ).split( '' ).sort().join( '' );
 const parseSwizzleAndSort = ( props ) => parseSwizzle( props ).split( '' ).sort().join( '' );
 
 
@@ -639,33 +629,32 @@ export const mat4 = new ConvertType( 'mat4' );
 export const string = ( value = '' ) => nodeObject( new ConstNode( value, 'string' ) );
 export const string = ( value = '' ) => nodeObject( new ConstNode( value, 'string' ) );
 export const arrayBuffer = ( value ) => nodeObject( new ConstNode( value, 'ArrayBuffer' ) );
 export const arrayBuffer = ( value ) => nodeObject( new ConstNode( value, 'ArrayBuffer' ) );
 
 
+addMethodChaining( 'toColor', color );
+addMethodChaining( 'toFloat', float );
+addMethodChaining( 'toInt', int );
+addMethodChaining( 'toUint', uint );
+addMethodChaining( 'toBool', bool );
+addMethodChaining( 'toVec2', vec2 );
+addMethodChaining( 'toIVec2', ivec2 );
+addMethodChaining( 'toUVec2', uvec2 );
+addMethodChaining( 'toBVec2', bvec2 );
+addMethodChaining( 'toVec3', vec3 );
+addMethodChaining( 'toIVec3', ivec3 );
+addMethodChaining( 'toUVec3', uvec3 );
+addMethodChaining( 'toBVec3', bvec3 );
+addMethodChaining( 'toVec4', vec4 );
+addMethodChaining( 'toIVec4', ivec4 );
+addMethodChaining( 'toUVec4', uvec4 );
+addMethodChaining( 'toBVec4', bvec4 );
+addMethodChaining( 'toMat2', mat2 );
+addMethodChaining( 'toMat3', mat3 );
+addMethodChaining( 'toMat4', mat4 );
+
 // basic nodes
 // basic nodes
 
 
 export const element = /*@__PURE__*/ nodeProxy( ArrayElementNode );
 export const element = /*@__PURE__*/ nodeProxy( ArrayElementNode );
 export const convert = ( node, types ) => nodeObject( new ConvertNode( nodeObject( node ), types ) );
 export const convert = ( node, types ) => nodeObject( new ConvertNode( nodeObject( node ), types ) );
 export const split = ( node, channels ) => nodeObject( new SplitNode( nodeObject( node ), channels ) );
 export const split = ( node, channels ) => nodeObject( new SplitNode( nodeObject( node ), channels ) );
 
 
-addMethodsChaining( {
-	toColor: color,
-	toFloat: float,
-	toInt: int,
-	toUint: uint,
-	toBool: bool,
-	toVec2: vec2,
-	toIVec2: ivec2,
-	toUVec2: uvec2,
-	toBVec2: bvec2,
-	toVec3: vec3,
-	toIVec3: ivec3,
-	toUVec3: uvec3,
-	toBVec3: bvec3,
-	toVec4: vec4,
-	toIVec4: ivec4,
-	toUVec4: uvec4,
-	toBVec4: bvec4,
-	toMat2: mat2,
-	toMat3: mat3,
-	toMat4: mat4,
-	element: element,
-	convert: convert
-} );
+addMethodChaining( 'element', element );
+addMethodChaining( 'convert', convert );

粤ICP备19079148号