|
|
@@ -304,6 +304,8 @@ class ShaderCallNodeInternal extends Node {
|
|
|
this.shaderNode = shaderNode;
|
|
|
this.inputNodes = inputNodes;
|
|
|
|
|
|
+ this.isShaderCallNodeInternal = true;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
getNodeType( builder ) {
|
|
|
@@ -608,7 +610,11 @@ export const Fn = ( jsFunc, layout = null ) => {
|
|
|
|
|
|
}
|
|
|
|
|
|
- return shaderNode.call( inputs );
|
|
|
+ const fnCall = shaderNode.call( inputs );
|
|
|
+
|
|
|
+ if ( nodeType === 'void' ) fnCall.toStack();
|
|
|
+
|
|
|
+ return fnCall;
|
|
|
|
|
|
};
|
|
|
|
|
|
@@ -663,21 +669,6 @@ export const Fn = ( jsFunc, layout = null ) => {
|
|
|
|
|
|
};
|
|
|
|
|
|
-/**
|
|
|
- * @tsl
|
|
|
- * @function
|
|
|
- * @deprecated since r168. Use {@link Fn} instead.
|
|
|
- *
|
|
|
- * @param {...any} params
|
|
|
- * @returns {Function}
|
|
|
- */
|
|
|
-export const tslFn = ( ...params ) => { // @deprecated, r168
|
|
|
-
|
|
|
- console.warn( 'THREE.TSL: tslFn() has been renamed to Fn().' );
|
|
|
- return Fn( ...params );
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
//
|
|
|
|
|
|
addMethodChaining( 'toGlobal', ( node ) => {
|
|
|
@@ -704,10 +695,44 @@ export const setCurrentStack = ( stack ) => {
|
|
|
|
|
|
export const getCurrentStack = () => currentStack;
|
|
|
|
|
|
+/**
|
|
|
+ * Represent a conditional node using if/else statements.
|
|
|
+ *
|
|
|
+ * ```js
|
|
|
+ * If( condition, function )
|
|
|
+ * .ElseIf( condition, function )
|
|
|
+ * .Else( function )
|
|
|
+ * ```
|
|
|
+ * @tsl
|
|
|
+ * @function
|
|
|
+ * @param {...any} params - The parameters for the conditional node.
|
|
|
+ * @returns {StackNode} The conditional node.
|
|
|
+ */
|
|
|
export const If = ( ...params ) => currentStack.If( ...params );
|
|
|
+
|
|
|
+/**
|
|
|
+ * Represent a conditional node using switch/case statements.
|
|
|
+ *
|
|
|
+ * ```js
|
|
|
+ * Switch( value )
|
|
|
+ * .Case( 1, function )
|
|
|
+ * .Case( 2, 3, 4, function )
|
|
|
+ * .Default( function )
|
|
|
+ * ```
|
|
|
+ * @tsl
|
|
|
+ * @function
|
|
|
+ * @param {...any} params - The parameters for the conditional node.
|
|
|
+ * @returns {StackNode} The conditional node.
|
|
|
+ */
|
|
|
export const Switch = ( ...params ) => currentStack.Switch( ...params );
|
|
|
|
|
|
-export function append( node ) {
|
|
|
+/**
|
|
|
+ * Add the given node to the current stack.
|
|
|
+ *
|
|
|
+ * @param {Node} node - The node to add.
|
|
|
+ * @returns {Node} The node that was added to the stack.
|
|
|
+ */
|
|
|
+export function Stack( node ) {
|
|
|
|
|
|
if ( currentStack ) currentStack.add( node );
|
|
|
|
|
|
@@ -715,7 +740,7 @@ export function append( node ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
-addMethodChaining( 'append', append );
|
|
|
+addMethodChaining( 'toStack', Stack );
|
|
|
|
|
|
// types
|
|
|
|
|
|
@@ -777,3 +802,42 @@ export const split = ( node, channels ) => nodeObject( new SplitNode( nodeObject
|
|
|
|
|
|
addMethodChaining( 'element', element );
|
|
|
addMethodChaining( 'convert', convert );
|
|
|
+
|
|
|
+// deprecated
|
|
|
+
|
|
|
+/**
|
|
|
+ * @tsl
|
|
|
+ * @function
|
|
|
+ * @deprecated since r176. Use {@link Stack} instead.
|
|
|
+ *
|
|
|
+ * @param {Node} node - The node to add.
|
|
|
+ * @returns {Function}
|
|
|
+ */
|
|
|
+export const append = ( node ) => { // @deprecated, r176
|
|
|
+
|
|
|
+ console.warn( 'THREE.TSL: append() has been renamed to Stack().' );
|
|
|
+ return Stack( node );
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+addMethodChaining( 'append', ( node ) => { // @deprecated, r176
|
|
|
+
|
|
|
+ console.warn( 'THREE.TSL: .append() has been renamed to .toStack().' );
|
|
|
+ return Stack( node );
|
|
|
+
|
|
|
+} );
|
|
|
+
|
|
|
+/**
|
|
|
+ * @tsl
|
|
|
+ * @function
|
|
|
+ * @deprecated since r168. Use {@link Fn} instead.
|
|
|
+ *
|
|
|
+ * @param {...any} params
|
|
|
+ * @returns {Function}
|
|
|
+ */
|
|
|
+export const tslFn = ( ...params ) => { // @deprecated, r168
|
|
|
+
|
|
|
+ console.warn( 'THREE.TSL: tslFn() has been renamed to Fn().' );
|
|
|
+ return Fn( ...params );
|
|
|
+
|
|
|
+};
|