get method

dynamic get(
  1. dynamic node,
  2. dynamic prop
)

Implementation

get ( node, prop ) {

	if ( prop is String && node[ prop ] == undefined ) {

		if ( RegExp(r"^[xyzwrgbastpq]{1,4}$").hasMatch( prop ) == true ) {

			// accessing properties ( swizzle )

			prop = prop..replaceAll( RegExp(r"r|s"), 'x' )
				.replaceAll( RegExp(r"g|t"), 'y' )
				.replaceAll( RegExp(r"b|p"), 'z' )
				.replaceAll( RegExp(r"a|q"), 'w' );

			return ShaderNodeObject( new SplitNode( node, prop ) );

		} else if ( RegExp(r"^\d+$").hasMatch( prop ) == true ) {

			// accessing array

			return ShaderNodeObject( new ArrayElementNode( node, new FloatNode( num.parse( prop ) ).setConst( true ) ) );

		}

	}

	return node[ prop ];

}