new Animation(container, viewModel)
The animation widget provides play, pause, and rewind buttons, as well as the current time and date. A 'shuttle ring' surrounds it to control animation speed. The shuttle ring concept is borrowed from video editing, where a typical jog wheel rotates to move single animation frames very slowly, while the surrounding shuttle ring can be twisted to control the direction and speed of fast playback. SuperMap3D treats time as continuous (not broken into predefined animation frames), so this widget does not provide a jog wheel. Instead, the shuttle ring enables fast and very slow playback. Click and drag the shuttle ring pointer itself (the green part above), or click the rest of the ring area to push the pointer to the next preset speed in that direction. The animation widget also provides a 'real time' button (top left) to synchronize animation time with the end user's system clock, typically displaying 'today' or 'now'. This mode is used in ClockRange.CLAMPED or ClockRange.LOOP_STOP if the current time is outside Clock's startTime and endTime.
| Name | Type | Description |
|---|---|---|
container |
Element | String |
The DOM element or ID that will contain the widget. |
viewModel |
AnimationViewModel |
The view model used by this widget. |
- See:
Throws:
-
The element with ID 'container' does not exist in the document.
- Type
- DeveloperError
Example
// In HTML head, include a link to Animation.css stylesheet,
// and in the body, include:
var clock = new SuperMap3D.Clock();
var clockViewModel = new SuperMap3D.ClockViewModel(clock);
var viewModel = new SuperMap3D.AnimationViewModel(clockViewModel);
var widget = new SuperMap3D.Animation('animationContainer', viewModel);
function tick() {
clock.tick();
SuperMap3D.requestAnimationFrame(tick);
}
SuperMap3D.requestAnimationFrame(tick);
Members
-
static AllowMatricesInterpolation
-
Use matrix interpolation instead of using direct key value when animating matrices
-
static AllowMatrixDecomposeForInterpolation
-
When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
-
static ANIMATIONLOOPMODE_CONSTANT
-
Constant Loop Mode
-
static ANIMATIONLOOPMODE_CYCLE
-
Cycle Loop Mode
-
static ANIMATIONLOOPMODE_RELATIVE
-
Relative Loop Mode
-
static ANIMATIONTYPE_COLOR3
-
Color3 animation type
-
static ANIMATIONTYPE_COLOR4
-
Color3 animation type
-
static ANIMATIONTYPE_FLOAT
-
Float animation type
-
static ANIMATIONTYPE_MATRIX
-
Matrix animation type
-
static ANIMATIONTYPE_QUATERNION
-
Quaternion animation type
-
static ANIMATIONTYPE_SIZE
-
Size animation type
-
static ANIMATIONTYPE_VECTOR2
-
Vector2 animation type
-
static ANIMATIONTYPE_VECTOR3
-
Vector3 animation type
-
static SnippetUrl
-
Define the Url to load snippets
-
readonly containerElement
-
Retrieve the parent container.
-
readonly viewModelAnimationViewModel
-
Obtain the view model.
Methods
-
static AppendSerializedAnimations(source, destination)
-
Appends the serialized animations from the source animations
Name Type Description sourceSource containing the animations
destinationTarget to store the animations
-
static CreateAndStartAnimation(name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd)
-
Create and start an animation on a node
Name Type Description namedefines the name of the global animation that will be run on all nodes
nodedefines the root node where the animation will take place
targetPropertydefines property to animate
framePerSeconddefines the number of frame per second yo use
totalFramedefines the number of frames in total
fromdefines the initial value
todefines the final value
loopModedefines which loop mode you want to use (off by default)
easingFunctiondefines the easing function to use (linear by default)
onAnimationEnddefines the callback to call when animation end
Returns:
the animatable created for this animation -
static CreateAndStartHierarchyAnimation(name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd)
-
Create and start an animation on a node and its descendants
Name Type Description namedefines the name of the global animation that will be run on all nodes
nodedefines the root node where the animation will take place
directDescendantsOnlyif true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
targetPropertydefines property to animate
framePerSeconddefines the number of frame per second to use
totalFramedefines the number of frames in total
fromdefines the initial value
todefines the final value
loopModedefines which loop mode you want to use (off by default)
easingFunctiondefines the easing function to use (linear by default)
onAnimationEnddefines the callback to call when an animation ends (will be called once per node)
Returns:
the list of animatables created for all nodes -
static CreateAnimation(property, animationType, framePerSecond, easingFunction)
-
Sets up an animation
Name Type Description propertyThe property to animate
animationTypeThe animation type to apply
framePerSecondThe frames per second of the animation
easingFunctionThe easing function used in the animation
Returns:
The created animation -
static CreateFromSnippetAsync(snippetId)
-
Creates an animation or an array of animations from a snippet saved by the Inspector
Name Type Description snippetIddefines the snippet to load
Returns:
a promise that will resolve to the new animation or a new array of animations -
static CreateMergeAndStartAnimation(name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd)
-
Creates a new animation, merges it with the existing animations and starts it
Name Type Description nameName of the animation
nodeNode which contains the scene that begins the animations
targetPropertySpecifies which property to animate
framePerSecondThe frames per second of the animation
totalFrameThe total number of frames
fromThe frame at the beginning of the animation
toThe frame at the end of the animation
loopModeSpecifies the loop mode of the animation
easingFunction(Optional) The easing function of the animation, which allow custom mathematical formulas for animations
onAnimationEndCallback to run once the animation is complete
Returns:
Nullable animation -
static MakeAnimationAdditive(sourceAnimation, referenceFrame, range, cloneOriginal, clonedName)
-
Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
Name Type Description sourceAnimationdefines the Animation containing keyframes to convert
referenceFramedefines the frame that keyframes in the range will be relative to
rangedefines the name of the AnimationRange belonging to the Animation to convert
cloneOriginaldefines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
clonedNamedefines the name of the resulting cloned Animation if cloneOriginal is true
Returns:
a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false -
static Parse(parsedAnimation)
-
Parses an animation object and creates an animation
Name Type Description parsedAnimationParsed animation object
Returns:
Animation object -
static ParseFromFileAsync(name, url)
-
Creates a new animation or an array of animations from a snippet saved in a remote file
Name Type Description namedefines the name of the animation to create (can be null or empty to use the one from the json data)
urldefines the url to load from
Returns:
a promise that will resolve to the new animation or an array of animations -
static TransitionTo(property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd)
-
Transition property of an host to the target Value
Name Type Description propertyThe property to transition
targetValueThe target Value of the property
hostThe object where the property to animate belongs
sceneScene used to run the animation
frameRateFramerate (in frame/s) to use
transitionThe transition type we want to use
durationThe duration of the animation, in milliseconds
onAnimationEndCallback trigger at the end of the animation
Returns:
Nullable animation -
addEvent(event)
-
Add an event to this animation
Name Type Description eventEvent to add
-
applyThemeChanges()
-
更新 widget,以反映修改后的 CSS 主题规则。
Example
//Switch to the supermap3d-lighter theme. document.body.className = 'supermap3d-lighter'; animation.applyThemeChanges(); -
clone()
-
Makes a copy of the animation
Returns:
Cloned animation -
color3InterpolateFunction(startValue, endValue, gradient)
-
Interpolates a Color3 linearly
Name Type Description startValueStart value of the animation curve
endValueEnd value of the animation curve
gradientScalar amount to interpolate
Returns:
Interpolated Color3 value -
color4InterpolateFunction(startValue, endValue, gradient)
-
Interpolates a Color4 linearly
Name Type Description startValueStart value of the animation curve
endValueEnd value of the animation curve
gradientScalar amount to interpolate
Returns:
Interpolated Color3 value -
createRange(name, from, to)
-
Creates an animation range
Name Type Description nameName of the animation range
fromStarting frame of the animation range
toEnding frame of the animation
-
deleteRange(name, deleteFrames)
-
Deletes an animation range by name
Name Type Description nameName of the animation range to delete
deleteFramesSpecifies if the key frames for the range should also be deleted (true) or not (false)
-
destroy()
-
销毁动画部件。如果要从布局中永久删除部件,则应调用该函数。
-
floatInterpolateFunction(startValue, endValue, gradient)
-
Interpolates a scalar linearly
Name Type Description startValueStart value of the animation curve
endValueEnd value of the animation curve
gradientScalar amount to interpolate
Returns:
Interpolated scalar value -
floatInterpolateFunctionWithTangents(startValue, outTangent, endValue, inTangent, gradient)
-
Interpolates a scalar cubically
Name Type Description startValueStart value of the animation curve
outTangentEnd tangent of the animation
endValueEnd value of the animation curve
inTangentStart tangent of the animation curve
gradientScalar amount to interpolate
Returns:
Interpolated scalar value -
getEasingFunction()
-
Gets the easing function of the animation
Returns:
Easing function of the animation -
getEvents()
-
Retrieves all the events from the animation
Returns:
Events from the animation -
getHighestFrame()
-
Gets the highest frame rate of the animation
Returns:
Highest frame rate of the animation -
getKeys()
-
Gets the key frames from the animation
Returns:
The key frames of the animation -
getRange(name)
-
Gets the animation range by name, or null if not defined
Name Type Description nameName of the animation range
Returns:
Nullable animation range -
isDestroyed(){Boolean}
-
Returns:
Type Description Boolean If the object has been destroyed, it is true; otherwise, it is false. -
matrixInterpolateFunction(startValue, endValue, gradient, result)
-
Defines the function to use to interpolate matrices
Name Type Description startValuedefines the start matrix
endValuedefines the end matrix
gradientdefines the gradient between both matrices
resultdefines an optional target matrix where to store the interpolation
Returns:
the interpolated matrix -
quaternionInterpolateFunction(startValue, endValue, gradient)
-
Interpolates a quaternion using a spherical linear interpolation
Name Type Description startValueStart value of the animation curve
endValueEnd value of the animation curve
gradientScalar amount to interpolate
Returns:
Interpolated quaternion value -
quaternionInterpolateFunctionWithTangents(startValue, outTangent, endValue, inTangent, gradient)
-
Interpolates a quaternion cubically
Name Type Description startValueStart value of the animation curve
outTangentEnd tangent of the animation curve
endValueEnd value of the animation curve
inTangentStart tangent of the animation curve
gradientScalar amount to interpolate
Returns:
Interpolated quaternion value -
removeEvents(frame)
-
Remove all events found at the given frame
Name Type Description frameThe frame to remove events from
-
resize()
-
调整 widget 的大小以匹配容器大小。每当容器大小发生变化时,都应调用此函数。
-
serialize()
-
Serializes the animation to an object
Returns:
Serialized object -
setEasingFunction(easingFunction)
-
Sets the easing function of the animation
Name Type Description easingFunctionA custom mathematical formula for animation
-
setKeys(values)
-
Sets the key frames of the animation
Name Type Description valuesThe animation key frames to set
-
sizeInterpolateFunction(startValue, endValue, gradient)
-
Interpolates a size linearly
Name Type Description startValueStart value of the animation curve
endValueEnd value of the animation curve
gradientScalar amount to interpolate
Returns:
Interpolated Size value -
toString(fullDetails)
-
Converts the animation to a string
Name Type Description fullDetailssupport for multiple levels of logging within scene loading
Returns:
String form of the animation -
vector2InterpolateFunction(startValue, endValue, gradient)
-
Interpolates a Vector2 linearly
Name Type Description startValueStart value of the animation curve
endValueEnd value of the animation curve
gradientScalar amount to interpolate
Returns:
Interpolated Vector2 value -
vector2InterpolateFunctionWithTangents(startValue, outTangent, endValue, inTangent, gradient)
-
Interpolates a Vector2 cubically
Name Type Description startValueStart value of the animation curve
outTangentEnd tangent of the animation
endValueEnd value of the animation curve
inTangentStart tangent of the animation curve
gradientScalar amount to interpolate
Returns:
Interpolated Vector2 value -
vector3InterpolateFunction(startValue, endValue, gradient)
-
Interpolates a Vector3 linearl
Name Type Description startValueStart value of the animation curve
endValueEnd value of the animation curve
gradientScalar amount to interpolate
Returns:
Interpolated scalar value -
vector3InterpolateFunctionWithTangents(startValue, outTangent, endValue, inTangent, gradient)
-
Interpolates a Vector3 cubically
Name Type Description startValueStart value of the animation curve
outTangentEnd tangent of the animation
endValueEnd value of the animation curve
inTangentStart tangent of the animation curve
gradientScalar amount to interpolate
Returns:
InterpolatedVector3 value