Class SFVec4d
java.lang.Object
org.web3d.vrml.scripting.ecmascript.builtin.FieldScriptableObject
org.web3d.vrml.scripting.ecmascript.builtin.SFVec4d
- All Implemented Interfaces:
org.mozilla.javascript.Scriptable
SFVec4d field object.
- Version:
- $Revision: 1.1 $
- Author:
- Justin Couch
-
Field Summary
Fields inherited from class org.web3d.vrml.scripting.ecmascript.builtin.FieldScriptableObject
BAD_FORMAT_MSG, dataChanged, INVALID_TYPE_MSG, readOnly, READONLY_MSG, scriptField
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
-
Constructor Summary
ConstructorsConstructorDescriptionSFVec4d()
Default public constructor required by Rhino for when created by an Ecmascript call.SFVec4d
(double[] vec) Alternate constructor that takes a double array rather than a double array.SFVec4d
(float[] vec) Construct a field based on the given array of data (sourced from a node). -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares two objects for equality base on the components being the same.get
(int index, org.mozilla.javascript.Scriptable start) Get the variable at the given index.Get the value of the named function.void
getRawData
(double[] value) Fetch the raw data held by this instance and copy it into the provided array.void
getRawData
(float[] value) Fetch the raw data held by this instance and copy it into the provided array as double values.boolean
has
(int index, org.mozilla.javascript.Scriptable start) Check for the indexed property presence.boolean
Check for the named property presence.void
jsConstructor
(double x, double y, double z, double w) Constructor for all three values that rhino calls.jsFunction_add
(org.mozilla.javascript.Scriptable newVector) Add this vector to the given vector and return the value as a new vector.jsFunction_cross
(org.mozilla.javascript.Scriptable newVector) Calculate the cross product of this vector and the given vectorjsFunction_divide
(double n) Divide this vector by the given scalar value and return the result in a new vectordouble
jsFunction_dot
(org.mozilla.javascript.Scriptable newVector) Calculate the dot product of this vector and the passed vector.boolean
jsFunction_equals
(Object val) Comparison of this object to another of the same type.double
Calculate the length of the vector.jsFunction_multiply
(double n) Multiply this vector by the scalar amount and return the result in a new vector.Generate a vector with the negated version of each of the components.Generate the normalised version of this vector and return it.jsFunction_subtract
(org.mozilla.javascript.Scriptable newVector) Subtract the given vector from this vector and return the results in a new object.Creates a string version of this node.void
Sets a property based on the index.void
Sets the named property with a new value.void
setRawData
(double[] values) Convenience method to reset the values used by this instance.void
setRawData
(double x, double y, double z, double w) Convenience method to reset the values used by this instance.void
setRawData
(float[] values) Convenience method to reset the values used by this instance.toString()
Format the internal values of this field as a string.Methods inherited from class org.web3d.vrml.scripting.ecmascript.builtin.FieldScriptableObject
delete, delete, getClassName, getDefaultValue, getIds, getParentScope, getPrototype, hasChanged, hasInstance, locateFunction, registerFunction, setParentScope, setPrototype, setReadOnly, setScriptField
-
Constructor Details
-
SFVec4d
public SFVec4d()Default public constructor required by Rhino for when created by an Ecmascript call. -
SFVec4d
public SFVec4d(float[] vec) Construct a field based on the given array of data (sourced from a node).- Parameters:
vec
-
-
SFVec4d
public SFVec4d(double[] vec) Alternate constructor that takes a double array rather than a double array. Used primarily by the VrmlMatrix code.- Parameters:
vec
-
-
-
Method Details
-
jsConstructor
public void jsConstructor(double x, double y, double z, double w) Constructor for all three values that rhino calls.- Parameters:
x
- The X component of the vectory
- The Y component of the vectorz
- The Z component of the vectorw
- The W component of the vector
-
has
public boolean has(int index, org.mozilla.javascript.Scriptable start) Check for the indexed property presence. Always returns NOT_FOUND as ECMAScript doesn't support indexed objects.- Specified by:
has
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
has
in classFieldScriptableObject
- Returns:
-
has
Check for the named property presence.- Specified by:
has
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
has
in classFieldScriptableObject
- Parameters:
start
-- Returns:
- true if it is a defined eventOut or field
-
get
Get the variable at the given index. Since we don't support integer index values for fields of the script, this always returns NOT_FOUND.- Specified by:
get
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
get
in classFieldScriptableObject
- Returns:
-
get
Get the value of the named function. If no function object is registered for this name, the method will return null.- Specified by:
get
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
get
in classFieldScriptableObject
- Parameters:
name
- The variable namestart
- The object where the lookup began- Returns:
- the corresponding function object or null
-
put
Sets a property based on the index.- Specified by:
put
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
put
in classFieldScriptableObject
- Parameters:
index
- The index of the property to setstart
- The object who's property is being setvalue
- The value being requested
-
put
Sets the named property with a new value. A put usually means changing the entire property. So, if the property has changed using an operation likee = new SFColor(0, 1, 0);
then a whole new object is passed to us.- Specified by:
put
in interfaceorg.mozilla.javascript.Scriptable
- Overrides:
put
in classFieldScriptableObject
- Parameters:
name
- The name of the property to definestart
- The object who's property is being setvalue
- The value being requested
-
jsFunction_add
Add this vector to the given vector and return the value as a new vector.- Parameters:
newVector
- The vector to add to this vector- Returns:
- The addition of the two objects
-
jsFunction_cross
Calculate the cross product of this vector and the given vector- Parameters:
newVector
- The vector to do the cross product with- Returns:
- The product
-
jsFunction_divide
Divide this vector by the given scalar value and return the result in a new vector- Parameters:
n
- The scalar to divide the objects by- Returns:
- The addition of the two objects
-
jsFunction_dot
public double jsFunction_dot(org.mozilla.javascript.Scriptable newVector) Calculate the dot product of this vector and the passed vector.- Parameters:
newVector
- The vector to make the calculation with- Returns:
- The value of the dot product
-
jsFunction_length
public double jsFunction_length()Calculate the length of the vector.- Returns:
- The length of the vector
-
jsFunction_multiply
Multiply this vector by the scalar amount and return the result in a new vector.- Parameters:
n
- The scalar to divide the objects by- Returns:
- The addition of the two objects
-
jsFunction_negate
Generate a vector with the negated version of each of the components.- Returns:
- A negated version of this vector
-
jsFunction_normalize
Generate the normalised version of this vector and return it.- Returns:
- The normalised form of this vector
-
jsFunction_subtract
Subtract the given vector from this vector and return the results in a new object.- Parameters:
newVector
- The vector to subtract from this one- Returns:
- The difference between the two
-
jsFunction_toString
Creates a string version of this node. Just calls the standard toString() method of the object.- Returns:
- A VRML string representation of the field
-
jsFunction_equals
Comparison of this object to another of the same type. Just calls the standard equals() method of the object.- Parameters:
val
- The value to compare to this object- Returns:
- true if the components of the object are the same
-
toString
-
equals
-
getRawData
public void getRawData(float[] value) Fetch the raw data held by this instance and copy it into the provided array as double values.- Parameters:
value
- The array to copy the data into
-
getRawData
public void getRawData(double[] value) Fetch the raw data held by this instance and copy it into the provided array.- Parameters:
value
- The array to copy the data into
-
setRawData
public void setRawData(float[] values) Convenience method to reset the values used by this instance. Typically used by the VrmlMatrix class, but others may use this too. It does not set the data changed flag when called.- Parameters:
values
- The new values to use
-
setRawData
public void setRawData(double[] values) Convenience method to reset the values used by this instance. Typically used by the VrmlMatrix class, but others may use this too. It does not set the data changed flag when called.- Parameters:
values
- The new values to use
-
setRawData
public void setRawData(double x, double y, double z, double w) Convenience method to reset the values used by this instance. Typically used by the VrmlMatrix class, but others may use this too. It does not set the data changed flag when called.- Parameters:
x
- The new x value to usey
- The new y value to usez
- The new z value to usew
-
-