parseNodeSpecialProperty method

dynamic parseNodeSpecialProperty(
  1. dynamic line,
  2. dynamic propName,
  3. dynamic propValue
)

Implementation

parseNodeSpecialProperty( line, propName, propValue ) {

	// split this
	// P: "Lcl Scaling", "Lcl Scaling", "", "A",1,1,1
	// into array like below
	// ["Lcl Scaling", "Lcl Scaling", "", "A", "1,1,1" ]
	var props = propValue.split( '",' ).map( ( prop ) {

		return prop.trim().replace( RegExp(r'^\"'), '' ).replace( RegExp(r'\s'), '_' );

	} ).toList();

	var innerPropName = props[ 0 ];
	var innerPropType1 = props[ 1 ];
	var innerPropType2 = props[ 2 ];
	var innerPropFlag = props[ 3 ];
	var innerPropValue = props[ 4 ];

	// cast values where needed, otherwise leave as strings
	switch ( innerPropType1 ) {

		case 'int':
		case 'enum':
		case 'bool':
		case 'ULongLong':
		case 'double':
		case 'Number':
		case 'FieldOfView':
			innerPropValue = parseFloat( innerPropValue );
			break;

		case 'Color':
		case 'ColorRGB':
		case 'Vector3D':
		case 'Lcl_Translation':
		case 'Lcl_Rotation':
		case 'Lcl_Scaling':
			innerPropValue = parseNumberArray( innerPropValue );
			break;

	}

	// CAUTION: these props must append to parent's parent
	this.getPrevNode()[ innerPropName ] = {

		'type': innerPropType1,
		'type2': innerPropType2,
		'flag': innerPropFlag,
		'value': innerPropValue

	};

	this.setCurrentProp( this.getPrevNode(), innerPropName );

}