Members
# _translation :Vector3
The [x, y, z] translation of the card.
Type:
- Vector3
# _rotation :Quaternion
The rotation of the card in quaternion.
Type:
- Quaternion
# _scale :Vector3
The scale of the card in three axes.
Type:
- Vector3
# _layers :Array
The layers property specifies how the card is treated when a special action is taken. Typical value are as follows:
- "walk": The avatar stays on the geometry of the card.
- "pointer": The pointer action is enabled.
- "portal": the avatar tests if the card it is going through needs to take the avatar to a connected world.
Type:
- Array
# _parent :CardActor
The cards in the world are organized in a hierarchical parent-children structure. The _parent
specifies its parent. Note that this is a "logical" structure. All cards are held as a direct child of the Three.JS scene, with automatic matrix composition for nested cards.
Type:
# _behaviorModules :Array
The list of behavior modules installed to the card.
Type:
- Array
# _name :string
An informative string for the card.
Type:
- string
# _hidden :boolean
The visibility of the card, and whether it responds to pointer events or not.
Type:
- boolean
# _cardData :Object
Any other values that the CardActor holds are stored in an object stored in the _cardData
property. This is needed to mark the values to be stored in the persistent data.
Type:
- Object
Methods
# createCard(data) → {CardActor}
This method creates a new card (a CardActor on the model side and a CardPawn on the view side), based on the cardSpec
.
Name | Type | Description |
---|---|---|
data |
object | the spec for a card to be created. |
the CardActor created.
- Type
- CardActor
# destroy()
This method removes the card from the world. All teardown()
method of installed pawn behaviors and actor behaviors are called before the CardActor is removed from the system.
# call(behaviorName, methodName) → {any}
This method invokes a method of another behavior. The behaviorName
has to be in one of the form of:
- "ModuleName$BehaviorName"
- "BehaviorName"
When the first form is used, it specifies the globally known module name and the behavior with the name on the actor side of the module. When the second form is used, it specified the behavior in the same module as the calling behavior.
The methodName
is the name of the method, and values
are variable-length arguments for the method.
Name | Type | Description |
---|---|---|
behaviorName |
string | name of the behavior |
methodName |
string | name of the method |
...arguments |
any | arguments for the method |
the return value from the method
- Type
- any
# future(time)
This method schedules a future call in the specified logical time in milliseconds. If it is used in this form:
this.future(20).mth();
mth
of the same behavior will be invoked 20 milliseconds from logical now
. If you would like to call a method of another module or behavior, you can use call()
:
this.future(20).call("Module$Behavior", "mth");
Name | Type | Description |
---|---|---|
time |
number | the delay in logical millisecond |
A proxy to invoke a method on
# setCardData(options)
This method updates some elements in the _cardData
object. The current value and the new values are merged to create the new _cardData
object. As a side effect, it publishes cardDataSet
Croquet event that can be handled by the pawn or any other subscribers.
Name | Type | Description |
---|---|---|
options |
object | keys and values to specify new values |
# addEventListener(eventType, listener)
This method adds a "listener" to be invoked when an event occurs on the card. When listener
is a function, it has to have a form of this.mthName
where mthName
is an existing method name of CardActor or the behavior itself. When listener is a string, it has to be the name of a method at CardActor or the behavior itself. The listener added by this Actor-side addEventListener()
is invoked when any user in the world causes the corresponding user pointer or key event.
Calling this method with the same arguments removes the previous listener before adding the new one. This semantics ensures that dynamically-modified method will be used.
Name | Type | Description |
---|---|---|
eventType |
EventName | the event type |
listener |
string | function | the name of the handler in the calling behavior, or a function specified in the form of |
# removeEventListener(eventName, listener)
This method removes the event listener that was added. You can call it when there is no matching event listener.
Name | Type | Description |
---|---|---|
eventName |
EventType | the event type |
listener |
string | function |
# subscribe(scope, eventName, listener)
This method adds a Croquet event subscription. Unlike the version in the Croquet Library, this version removes the subscription with the same scope
and eventName
if it exists before adding the new one. This semantics ensures that it is safe to call this from the setup()
of a behavior.
Name | Type | Description |
---|---|---|
scope |
string | the scope of Croquet event |
eventName |
string | the event name of Croquet event |
listener |
string | function | the name of the handler in the calling behavior, or a function specified in the form of |
# publish(scope, eventName, data)
This method publishes a Croquet event.
Name | Type | Description |
---|---|---|
scope |
string | the scope of Croquet event |
eventName |
string | the event name of Croquet event |
data |
any | serializable data to be published |
# listen(eventName, listener)
This method adds a Croquet event subscription by calling the subscribe()
method with this.id
as the scope
.
Name | Type | Description |
---|---|---|
eventName |
string | the event name of Croquet event |
listener |
string | function | the name of the handler in the calling behavior, or a function specified in the form of |
# say(eventName, data)
This method publishes a Croquet event with this.id
as the scope
. It is usually used to publish an event whose expect recipient is the corresponding CardPawn.
Name | Type | Description |
---|---|---|
eventName |
string | the event name of Croquet event |
data |
any | serializable data to be published |
# addLayer(newLayerName)
This method adds a new element to the layers
array. If newLayerName
is already in the layers
array, the call does not have any effects.
Name | Type | Description |
---|---|---|
newLayerName |
string | the name of a later to be added |
# removeLayer(layerName)
This method removes an element from the layers
array. If layerName
is not in the layers
array, the call does not have any effects.
Name | Type | Description |
---|---|---|
layerName |
string | the name of a later to be removed |
# translateTo(v)
This method moves the translation of the card to the specified [x, y, z]
coordinates.
Name | Type | Description |
---|---|---|
v |
Vector3 | the translation for the card |
# rotateTo(rot)
When rot is a 4 element array, it is interpreted as a quaternion. When rot is a 3 element array, it is interpreted as an Euler angle. When rot is a number, it is interpreted as [0, rot, 0].
This method sets the rotation of the card to the specified by the argument.
Name | Type | Description |
---|---|---|
rot |
Rotation | number | the rotation for the card |
# scaleTo(s)
When s is a number, it is interpreted as [s, s, s]
.
This method sets the scale of the card to the specified by scale factors in [x, y, z] axis.
Name | Type | Description |
---|---|---|
s |
Vector3 | number | the scale for the card |
# positionTo(v, q)
This method sets the translation and rotation of the card, making sure that those two values are used in the same logical time and used for the rendering.
Name | Type | Description |
---|---|---|
v |
Vector3 | the translation for the card |
q |
Quaternion | the rotation for the card |
# translateBy(v)
This method moves the translation of the card by the specified [x, y, z]
vector.
Name | Type | Description |
---|---|---|
v |
Vector3 | the translation offset |
# rotateBy(rot)
When rot is a 4 element array, it is interpreted as a quaternion. When rot is a 3 element array, it is interpreted as an Euler angle. When rot is a number, it is interpreted as [0, rot, 0].
This method combines the rotation of the card by the specified rotation.
Name | Type | Description |
---|---|---|
rot |
Rotation | number | the additional rotation for the card |
# scaleBy(s)
When s is a number, it is interpreted as [s, s, s]. This method multiplies the scale of the card by the specified by scale factors in [x, y, z] axis.
Name | Type | Description |
---|---|---|
s |
Vector3 | the scale offset |
# forwardBy(v)
When v is a number, it is interpreted as [0, 0, v].
This method translates the object by `the specified offset, in the reference frame of the object.
Name | Type | Description |
---|---|---|
v |
Vector3 | number | the offset |
# setAnimationClipIndex(animationClipIndex)
A Three.js keyframe based animation is supported. The animation clip can contain multiple tracks. The index specified here dictates which track to play. A cardData called animationStartTime specifiy the base for time offset.
Name | Type | Description |
---|---|---|
animationClipIndex |
number | the index into animation tracks array |
# nop()
This method is empty. It is used to have a way to get the tap to focus keyboard events but you don't need to take any particular action on tap.