o3d.Counter Class Reference
Inherits
o3d.ParamObject
List of all members.
Detailed Description
A Counter counts seconds, ticks or render frames depending on the type of
counter. You can set where it starts counting from and where it stops counting
at, whether or not it is running or paused and how it loops or does not loop.
You can also give it callbacks to call at specific count values.
Public Types
Public Member Functions
Public Properties
Parameters
Public Types Documentation
| enum o3d.Counter.CountMode |
CountMode
CONTINUOUS, Keep running the counter forever.
ONCE, Stop at start or end depending on the direction.
CYCLE, When at end, jump back to start or visa versa.
OSCILLATE, Go from start to end back to start.
};
Member Function Documentation
| Counter.addCallback |
( |
number |
count |
|
|
|
|
function(): void |
counterCallback |
) |
|
Adds a callback for a given count value. Only one callback can be
added to a specific count value. If another callback is added with the
same count value the previous callback for that value will be replaced.
Note: A callback at start will only get called when counting backward, a
callback at end will only get called counting forward.
- Parameters:
-
| count |
Count at which to call callback. |
| counterCallback |
Callback to call at given count. |
| Counter.advance |
( |
number |
advanceAmount |
) |
|
Advances the counter the given amount. The actual amount advanced depends
on the forward and multiplier settings. The formula is
new_count = count + advance_amount * multiplier * (forward ? 1.0 : -1.0);
Any callbacks that fall in the range between the counter's current count and
the amount advanced will be called.
This function is normally called automatically by the client if the counter
is set to running = true. but you can call it manually.
- Parameters:
-
| advanceAmount |
Amount to advance count. |
Copies all the params from a the given source_param_object to this param
object. Does not replace any currently existing params with the same name.
- Parameters:
-
| sourceParamObject |
param object to copy params from. |
Creates a Param with the given name and type on the ParamObject.
Will fail if a param with the same name already exists.
- Parameters:
-
| paramName |
The name of the Param to be created. |
| paramTypeName |
The type of Param to create. Valid types are
- 'o3d.ParamBoolean'
- 'o3d.ParamBoundingBox'
- 'o3d.ParamDrawContext'
- 'o3d.ParamDrawList'
- 'o3d.ParamEffect'
- 'o3d.ParamFloat'
- 'o3d.ParamFloat2'
- 'o3d.ParamFloat3'
- 'o3d.ParamFloat4'
- 'o3d.ParamFunction'
- 'o3d.ParamInteger'
- 'o3d.ParamMaterial'
- 'o3d.ParamMatrix4'
- 'o3d.ParamParamArray'
- 'o3d.ParamRenderSurface'
- 'o3d.ParamRenderDepthStencilSurface'
- 'o3d.ParamSampler'
- 'o3d.ParamSkin'
- 'o3d.ParamSteamBank'
- 'o3d.ParamState'
- 'o3d.ParamString'
- 'o3d.ParamTexture'
- 'o3d.ParamTransform'
- 'o3d.ProjectionParamMatrix4'
- 'o3d.ProjectionInverseParamMatrix4'
- 'o3d.ProjectionTransposeParamMatrix4'
- 'o3d.ProjectionInverseTransposeParamMatrix4'
- 'o3d.ViewParamMatrix4'
- 'o3d.ViewInverseParamMatrix4'
- 'o3d.ViewTransposeParamMatrix4'
- 'o3d.ViewInverseTransposeParamMatrix4'
- 'o3d.ViewProjectionParamMatrix4'
- 'o3d.ViewProjectionInverseParamMatrix4'
- 'o3d.ViewProjectionTransposeParamMatrix4'
- 'o3d.ViewProjectionInverseTransposeParamMatrix4'
- 'o3d.WorldParamMatrix4'
- 'o3d.WorldInverseParamMatrix4'
- 'o3d.WorldTransposeParamMatrix4'
- 'o3d.WorldInverseTransposeParamMatrix4'
- 'o3d.WorldViewParamMatrix4'
- 'o3d.WorldViewInverseParamMatrix4'
- 'o3d.WorldViewTransposeParamMatrix4'
- 'o3d.WorldViewInverseTransposeParamMatrix4'
- 'o3d.WorldViewProjectionParamMatrix4'
- 'o3d.WorldViewProjectionInverseParamMatrix4'
- 'o3d.WorldViewProjectionTransposeParamMatrix4'
- 'o3d.WorldViewProjectionInverseTransposeParamMatrix4'
|
- Returns:
-
o3d.Param.The newly created Param or null on failure.
| Counter.getCallbackCounts |
( |
|
|
) |
|
Returns all the counts for which all callback has been added.
- Returns:
-
!Array.<number>.Array of counts.
Searches by name for a Param defined in the object.
- Parameters:
-
| paramName |
Name to search for. |
- Returns:
-
o3d.Param.The Param with the given name, or null otherwise.
| boolean Counter.isAClassName |
( |
string |
className |
) |
[inherited from o3d.ObjectBase] |
Takes the name of a class as an argument, and returns true if this object is
either an instance of that class or derives from that class.
var t = pack.createObject('o3d.Transform');
t.isAClassName('o3d.Transform'); // true
t.isAClassName('o3d.ParamObject'); // true
t.isAClassName('o3d.Shape'); // false
- Parameters:
-
| className |
Name of class to check for. |
- Returns:
-
boolean.true if this object is a or is derived from the given class name.
| Counter.removeAllCallbacks |
( |
|
|
) |
|
Removes all the callbacks on this counter.
| boolean Counter.removeCallback |
( |
number |
count |
) |
|
Removes a callback for a given count value.
- Parameters:
-
| count |
Count to remove callback for, |
- Returns:
-
boolean.true if there was a callback for that count, false if there was not
a callback for that count.
Removes a Param from a ParamObject.
This function will fail if the param does not exist on this ParamObject
or if the param is unremovable.
- Parameters:
-
- Returns:
-
boolean.True if the param was removed.
Resets the counter back to the start or end time depending on the forward
setting and also resets the Callback state.
Note: Reset does not change the running state of the counter.
| Counter.setCount |
( |
number |
count |
) |
|
Sets the current count value for this counter as well as the resetting
the state of the callbacks.
In other words. Assume start = 1, end = 5, count = 1, and you have a
callback at 3.
myCounter.start = 1;
myCounter.end = 5;
myCounter.addCallback(3, myCallback);
myCounter.reset();
myCounter.advance(2); // count is now 3, myCallback is called.
myCounter.advance(2); // count is now 5
vs.
myCounter.start = 1;
myCounter.end = 5;
myCounter.addCallback(3, myCallback);
myCounter.reset();
myCounter.advance(2); // count is now 3, myCallback is called.
myCounter.setCount(3); // count is now 3, callback state has been reset.
myCounter.advance(2); // count is now 5, myCallback is called.
In the second case myCallback was called twice.
- Parameters:
-
| count |
Value to set the count to. |
Member Property Documentation
The concrete class name for an object derived from ObjectBase.
If you want to know if an object is of a certain type you should use
objectBase.isAClassName
var t = pack.createObject('o3d.Transform');
t.className == 'o3d.Transform'; // true
This property is read-only.
Unique id of the object.
This id will be unique, even across multiple O3D clients in the same
page.
This property is read-only.
The current count value for this counter.
Default = 0.
This property is read-only.
The current count mode for this counter.
Default = CONTINUOUS.
The end count for this counter.
Default = 0.
Which direction this counter is counting.
Default = true.
| number Counter.multiplier
|
A multiplier used when advancing the count. The default value is 1.0.
For example you could set this to 0.5 to run the counter at half speed
or 2.0 to run it at double speed.
Default = 1.
The object's name.
Setting this has no meaning to O3D, but is useful for debugging and for
the functions Client.getObjects, Pack.getObject,
RenderNode.getRenderNodesByNameInTree and
RenderNode.getTransformsByNameInTree
which search for objects by name.
Gets all the param on this param object.
Each access to this field gets the entire list, so it is best to get it
just once. For example:
var params = paramObject.params;
for (var i = 0; i < params.length; i++) {
var param = params[i];
}
Note that modifications to this array [e.g. push()] will not affect
the underlying ParamObject, while modifications to the array's members
will affect them.
This property is read-only.
Whether or not this counter is running.
Default = true.
The start count for this counter.
Default = 0.
Parameter Documentation
Whether or not this counter is running.
The direction this counter is counting.
The start value for this counter.
The end value for this counter
The counting mode for this counter.
The current count for this counter.
The time multiplier for this counter.