Explorar o código

TSL: Convert common math objects to nodes if used in parameters. (#25728)

sunag %!s(int64=2) %!d(string=hai) anos
pai
achega
5d3ed2296b

+ 5 - 1
examples/jsm/nodes/core/NodeUtils.js

@@ -79,7 +79,11 @@ export function getValueType( value ) {
 
 
 	const typeOf = typeof value;
 	const typeOf = typeof value;
 
 
-	if ( typeOf === 'number' ) {
+	if ( value.isNode === true ) {
+
+		return 'node';
+
+	} else if ( typeOf === 'number' ) {
 
 
 		return 'float';
 		return 'float';
 
 

+ 13 - 13
examples/jsm/nodes/shadernode/ShaderNode.js

@@ -81,29 +81,29 @@ const nodeObjectsCacheMap = new WeakMap();
 
 
 const ShaderNodeObject = function ( obj ) {
 const ShaderNodeObject = function ( obj ) {
 
 
-	const type = typeof obj;
+	const type = getValueType( obj );
 
 
-	if ( ( type === 'number' ) || ( type === 'boolean' ) ) {
+	if ( type === 'node' ) {
 
 
-		return nodeObject( getAutoTypedConstNode( obj ) );
+		let nodeObject = nodeObjectsCacheMap.get( obj );
 
 
-	} else if ( type === 'object' ) {
+		if ( nodeObject === undefined ) {
 
 
-		if ( obj && obj.isNode === true ) {
+			nodeObject = new Proxy( obj, shaderNodeHandler );
+			nodeObjectsCacheMap.set( obj, nodeObject );
+			nodeObjectsCacheMap.set( nodeObject, nodeObject );
 
 
-			let nodeObject = nodeObjectsCacheMap.get( obj );
+		}
 
 
-			if ( nodeObject === undefined ) {
+		return nodeObject;
 
 
-				nodeObject = new Proxy( obj, shaderNodeHandler );
-				nodeObjectsCacheMap.set( obj, nodeObject );
-				nodeObjectsCacheMap.set( nodeObject, nodeObject );
+	} else if ( ( type === 'float' ) || ( type === 'boolean' ) ) {
 
 
-			}
+		return nodeObject( getAutoTypedConstNode( obj ) );
 
 
-			return nodeObject;
+	} else if ( type && type !== 'string' ) {
 
 
-		}
+		return nodeObject( new ConstNode( obj ) );
 
 
 	}
 	}