new Animation(container, viewModel)
动画部件提供播放、暂停和倒退按钮,以及当前时间和日期,周围还有一个 "穿梭环",用于控制动画的速度。
“穿梭环”的概念是从视频编辑中借鉴来的,在视频编辑中,典型的“慢跑轮”可以旋转以非常缓慢地移动单个动画帧,而周围的穿梭环可以扭曲以控制快速播放的方向和速度。
SuperMap3D通常将时间视为连续的(不分解为预定义的动画帧),因此这个小部件不提供jog wheel。
相反,穿梭环能够快速和非常慢的回放。
点击并拖动穿梭环指针本身(上面的绿色部分),或者点击圆环区域的其余部分,将指针推到该方向的下一个预设速度。
动画小部件还提供了一个“实时”按钮(在左上角)
动画时间与最终用户的系统时钟同步,通常显示
“今天”或“现在”。此模式在 ClockRange.CLAMPED或ClockRange.LOOP_STOP
如果当前时间在Clock的startTime和endTime之外,则使用LOOP_STOP}模式。
| Name | Type | Description |
|---|---|---|
container |
Element | String |
将包含小部件的DOM元素或ID。 |
viewModel |
AnimationViewModel |
此小部件使用的视图模型。 |
- See:
Throws:
-
id为"container"的元素在文档中不存在。
- 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
-
获取父容器。
-
readonly viewModelAnimationViewModel
-
获取视图模型。
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 如果对象已被销毁,则为 true,否则为 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