getUniformSize method

Map<String, int> getUniformSize(
  1. dynamic value
)

Implementation

Map<String,int> getUniformSize( value ) {
	final Map<String,int> info = {
		'boundary': 0, // bytes
		'storage': 0 // bytes
	};

	// determine sizes according to STD140

	if (value is double || value is int || value is num || value is bool ) {
		info['boundary'] = 4;
		info['storage'] = 4;
	} else if ( value is Vector2 ) {
		info['boundary'] = 8;
		info['storage'] = 8;
	} else if ( value is Vector3 || value is Color ) {
		info['boundary'] = 16;
		info['storage'] = 12; // evil: vec3 must start on a 16-byte boundary but it only consumes 12 bytes
	} else if ( value is Vector4 ) {
		info['boundary'] = 16;
		info['storage'] = 16;
	} else if ( value is Matrix3 ) {
		info['boundary'] = 48;
		info['storage'] = 48;
	} else if ( value is Matrix4 ) {
		info['boundary'] = 64;
		info['storage'] = 64;
	} else if ( value is Texture ) {
		console.warning( 'THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.' );
	} else {
		console.warning( 'THREE.WebGLRenderer: Unsupported uniform value type. $value');
	}

	return info;
}