Revision of [Deprecated] Data Types from Thu, 08/10/2017 - 11:36
All field data is defined using data types. The types are a collection based on X3D and A-Frame. X3D data types start either SF or MF indicating a single- or multiple-valued field, respectively. Multiple-valued fields are a collection of zero or more single-valued fields of the same type. All multi-valued fields are stored as arrays.
The data types are:
All of the following are deprecated
- X3D Types
- SFFloat
- SFInt
- SFBool
- SFVec3f
- SFVec2f
- SFRotation
- SFColor
- SFString
// A-Frame data types
// value can be any CSS color (#HHH, #HHHHHH, 24-bit Integer, name)
'Color' : function (value, defaultString)
{
return defaultString;
},
// Conversion methods
'Vector3' : function (value)
{
return new THREE.Vector3(value[0], value[1], value[2]);
},
'Color3toHex' : function (c3)
{
var hr = Math.round(255*c3[0]).toString(16);
var hg = Math.round(255*c3[1]).toString(16);
var hb = Math.round(255*c3[2]).toString(16);
if (hr.length < 2) {hr = "0" + hr;}
if (hg.length < 2) {hg = "0" + hg;}
if (hb.length < 2) {hb = "0" + hb;}
var hex = '0x' + hr + hg + hb;
return hex;
},
'Color3toInt' : function (c3)
{
var hr = Math.round(255*c3[0]) << 16;
var hg = Math.round(255*c3[1]) << 8;
var hb = Math.round(255*c3[2])
return hr + hg + hb;
},
'Rotation2Quat' : function (rot)
{
var quat = new THREE.Quaternion();
if (typeof(rot) === 'object' && Array.isArray(rot.axis_angle)) {
quat.setFromAxisAngle(rot.axis_angle[0], rot.axis_angle[1]);
} else if (typeof(rot) === 'object' && Array.isArray(rot.vector)) {
quat.setFromAxisAngle(new THREE.Vector3(rot.vector[0],rot.vector[1],rot.vector[2]), rot.vector[3]);
} else if (Array.isArray(rot)) {
quat.setFromAxisAngle(new THREE.Vector3(rot[0],rot[1],rot[2]), rot[3]);
} else {
quat.setFromAxisAngle(new THREE.Vector3(0, 1, 0), 0);
}
return quat;
},
// Convienence data types (should deprecate)
'Scalar' : function (value, defaultString)
{
return this.SFFloat(value, defaultString);
},
'Color3' : function (value, defaultString)
{
return this.SFColor(value, defaultString);
},
};