|
|
@@ -202,6 +202,36 @@ export const uniformFlow = ( node ) => context( node, { uniformFlow: true } );
|
|
|
*/
|
|
|
export const setName = ( node, name ) => context( node, { nodeName: name } );
|
|
|
|
|
|
+/**
|
|
|
+ * TSL function for defining a built-in shadow context for a given node.
|
|
|
+ *
|
|
|
+ * @tsl
|
|
|
+ * @function
|
|
|
+ * @param {ShadowNode} shadowNode - The shadow node representing the light's shadow.
|
|
|
+ * @param {Light} light - The light associated with the shadow.
|
|
|
+ * @param {Node} [node=null] - The node whose context should be modified.
|
|
|
+ * @returns {ContextNode}
|
|
|
+ */
|
|
|
+export function builtinShadowContext( shadowNode, light, node = null ) {
|
|
|
+
|
|
|
+ return context( node, {
|
|
|
+
|
|
|
+ getShadow: ( { light: shadowLight, shadowColorNode } ) => {
|
|
|
+
|
|
|
+ if ( light === shadowLight ) {
|
|
|
+
|
|
|
+ return shadowColorNode.mul( shadowNode );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return shadowColorNode;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } );
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* TSL function for defining a label context value for a given node.
|
|
|
*
|
|
|
@@ -224,3 +254,4 @@ addMethodChaining( 'context', context );
|
|
|
addMethodChaining( 'label', label );
|
|
|
addMethodChaining( 'uniformFlow', uniformFlow );
|
|
|
addMethodChaining( 'setName', setName );
|
|
|
+addMethodChaining( 'builtinShadowContext', ( node, shadowNode, light ) => builtinShadowContext( shadowNode, light, node ) );
|