Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _menu_load_objects() (line 579 of /home/drbiz/public/tools.realism.com/includes/menu.inc).

Revision of Data Types from Thu, 08/10/2017 - 11:35

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:

  • V0.5+
    • string - this is the default and allows any set of characters in the HTML encoding
    • integer - must pass the JavaScript number check and have no fractional part
    • float - must pass the JavaScript number check
    • vec2 - a two-element vector of floats. The elements are space separated.
    • vec3 - a three-element vector of floats. The elements are space separated.
    • vec4 - a four-element vector of floats. The elements are space separated.
    • color - A color specified as one of the following
      • <name> - A valid HTML color name
      • #<24-bit hex> - A color specified as three douples of hex digits
      • #<base-10> - A color specified as an integer that converts to a 24-bit color
      • "r g b" - Where r, g, and b are either three floats from [0,1] or three integers from [0-255]. The elements are space separated.
XSeen DataType JavaScript DataType
string String
integer Number (integer)
float Number
vec2 Array with 2 numeric elements
vec3 Array with 3 numeric elements
vec4 Array with 4 numeric elements
color Number [0-2^24-1]

 

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);
        },
    
};