State

new State(object3D, timestamp)

Store state of context at a given time

Parameters:
NameTypeDescription
object3DObject3D

context root object3D

timestampnumber

time

Members

_consumed :boolean

flag to determine if state has been consumed/treated

Type:
  • boolean

object3D :Object3D

context root object3D

timestamp :number

time when the state has been created in ms

Type:
  • number

Methods

add(diff) → {State}

Compute next state based on a Diff

Parameters:
NameTypeDescription
diffDiff

diff between two State

Returns:
  • next state
Type: 
State

clone() → {State}

Returns:
  • clone of state
Type: 
State

equals(state) → {boolean}

Parameters:
NameTypeDescription
stateState

state to compare to

Returns:
  • true if states are equal
Type: 
boolean

getObject3D() → {Object3D}

Returns:
  • state object3D
Type: 
Object3D

getTimestamp() → {number}

Returns:
  • state timestamp
Type: 
number

hasBeenConsumed() → {boolean}

Returns:
  • return true if state has been consumed/treated
Type: 
boolean

includes(uuid) → {boolean}

Check if there is an object3D with a given uuid

Parameters:
NameTypeDescription
uuidstring

uuid to be check

Returns:
  • true if there is an object3D with this uuid, false otherwise
Type: 
boolean

setConsumed(value)

Parameters:
NameTypeDescription
valueboolean

new consumed value

sub(previousState) → {Diff}

Compute the diff between this and previous state

Parameters:
NameTypeDescription
previousStateState

state passed to compute the diff with this

Returns:

diff between this and previousState

Type: 
Diff

toJSON() → {object}

export state to serializable json object

Returns:
  • serializable json object
Type: 
object

(static) interpolate(s1, s2, ratio) → {State}

Compute a state interpolated between s1 and s2 with a given ratio

Parameters:
NameTypeDescription
s1State

first state if ratio = 0, result = s1

s2State

second state if ratio = 1, result = s2

rationumber

a number between 0 => 1

Returns:
  • interpolated state
Type: 
State