How to use animation method in wpt

Best JavaScript code snippet using wpt

transition.js

Source:transition.js Github

copy

Full Screen

...284 // determine exact animation285 animation = animation || settings.animation;286 animationClass = module.get.animationClass(animation);287 // save animation class in cache to restore class names288 module.save.animation(animationClass);289 // override display if necessary so animation appears visibly290 module.force.visible();291 module.remove.hidden();292 module.remove.direction();293 module.start.animation(animationClass);294 },295 duration: function(animationName, duration) {296 duration = duration || settings.duration;297 duration = (typeof duration == 'number')298 ? duration + 'ms'299 : duration300 ;301 if(duration || duration === 0) {302 module.verbose('Setting animation duration', duration);303 $module304 .css({305 'animation-duration': duration306 })307 ;...

Full Screen

Full Screen

ModelAnimationCollection.js

Source:ModelAnimationCollection.js Github

copy

Full Screen

1define([2 '../Core/clone',3 '../Core/defaultValue',4 '../Core/defined',5 '../Core/defineProperties',6 '../Core/DeveloperError',7 '../Core/Event',8 '../Core/JulianDate',9 '../Core/Math',10 './ModelAnimation',11 './ModelAnimationLoop',12 './ModelAnimationState'13 ], function(14 clone,15 defaultValue,16 defined,17 defineProperties,18 DeveloperError,19 Event,20 JulianDate,21 CesiumMath,22 ModelAnimation,23 ModelAnimationLoop,24 ModelAnimationState) {25 'use strict';2627 /**28 * A collection of active model animations. Access this using {@link Model#activeAnimations}.29 *30 * @alias ModelAnimationCollection31 * @internalConstructor32 *33 * @see Model#activeAnimations34 */35 function ModelAnimationCollection(model) {36 /**37 * The event fired when an animation is added to the collection. This can be used, for38 * example, to keep a UI in sync.39 *40 * @type {Event}41 * @default new Event()42 *43 * @example44 * model.activeAnimations.animationAdded.addEventListener(function(model, animation) {45 * console.log('Animation added: ' + animation.name);46 * });47 */48 this.animationAdded = new Event();4950 /**51 * The event fired when an animation is removed from the collection. This can be used, for52 * example, to keep a UI in sync.53 *54 * @type {Event}55 * @default new Event()56 *57 * @example58 * model.activeAnimations.animationRemoved.addEventListener(function(model, animation) {59 * console.log('Animation removed: ' + animation.name);60 * });61 */62 this.animationRemoved = new Event();6364 this._model = model;65 this._scheduledAnimations = [];66 this._previousTime = undefined;67 }6869 defineProperties(ModelAnimationCollection.prototype, {70 /**71 * The number of animations in the collection.72 *73 * @memberof ModelAnimationCollection.prototype74 *75 * @type {Number}76 * @readonly77 */78 length : {79 get : function() {80 return this._scheduledAnimations.length;81 }82 }83 });8485 function add(collection, index, options) {86 var model = collection._model;87 var animations = model._runtime.animations;88 var animation = animations[index];89 var scheduledAnimation = new ModelAnimation(options, model, animation);90 collection._scheduledAnimations.push(scheduledAnimation);91 collection.animationAdded.raiseEvent(model, scheduledAnimation);92 return scheduledAnimation;93 }9495 /**96 * Creates and adds an animation with the specified initial properties to the collection.97 * <p>98 * This raises the {@link ModelAnimationCollection#animationAdded} event so, for example, a UI can stay in sync.99 * </p>100 *101 * @param {Object} options Object with the following properties:102 * @param {String} [options.name] The glTF animation name that identifies the animation. Must be defined if <code>options.id</code> is <code>undefined</code>.103 * @param {Number} [options.index] The glTF animation index that identifies the animation. Must be defined if <code>options.name</code> is <code>undefined</code>.104 * @param {JulianDate} [options.startTime] The scene time to start playing the animation. When this is <code>undefined</code>, the animation starts at the next frame.105 * @param {Number} [options.delay=0.0] The delay, in seconds, from <code>startTime</code> to start playing.106 * @param {JulianDate} [options.stopTime] The scene time to stop playing the animation. When this is <code>undefined</code>, the animation is played for its full duration.107 * @param {Boolean} [options.removeOnStop=false] When <code>true</code>, the animation is removed after it stops playing.108 * @param {Number} [options.speedup=1.0] Values greater than <code>1.0</code> increase the speed that the animation is played relative to the scene clock speed; values less than <code>1.0</code> decrease the speed.109 * @param {Boolean} [options.reverse=false] When <code>true</code>, the animation is played in reverse.110 * @param {ModelAnimationLoop} [options.loop=ModelAnimationLoop.NONE] Determines if and how the animation is looped.111 * @returns {ModelAnimation} The animation that was added to the collection.112 *113 * @exception {DeveloperError} Animations are not loaded. Wait for the {@link Model#readyPromise} to resolve.114 * @exception {DeveloperError} options.name must be a valid animation name.115 * @exception {DeveloperError} options.index must be a valid animation index.116 * @exception {DeveloperError} Either options.name or options.index must be defined.117 * @exception {DeveloperError} options.speedup must be greater than zero.118 *119 * @example120 * // Example 1. Add an animation by name121 * model.activeAnimations.add({122 * name : 'animation name'123 * });124 *125 * // Example 2. Add an animation by index126 * model.activeAnimations.add({127 * index : 0128 * });129 *130 * @example131 * // Example 3. Add an animation and provide all properties and events132 * var startTime = Cesium.JulianDate.now();133 *134 * var animation = model.activeAnimations.add({135 * name : 'another animation name',136 * startTime : startTime,137 * delay : 0.0, // Play at startTime (default)138 * stopTime : Cesium.JulianDate.addSeconds(startTime, 4.0, new Cesium.JulianDate()),139 * removeOnStop : false, // Do not remove when animation stops (default)140 * speedup : 2.0, // Play at double speed141 * reverse : true, // Play in reverse142 * loop : Cesium.ModelAnimationLoop.REPEAT // Loop the animation143 * });144 *145 * animation.start.addEventListener(function(model, animation) {146 * console.log('Animation started: ' + animation.name);147 * });148 * animation.update.addEventListener(function(model, animation, time) {149 * console.log('Animation updated: ' + animation.name + '. glTF animation time: ' + time);150 * });151 * animation.stop.addEventListener(function(model, animation) {152 * console.log('Animation stopped: ' + animation.name);153 * });154 */155 ModelAnimationCollection.prototype.add = function(options) {156 options = defaultValue(options, defaultValue.EMPTY_OBJECT);157158 var model = this._model;159 var animations = model._runtime.animations;160161 //>>includeStart('debug', pragmas.debug);162 if (!defined(animations)) {163 throw new DeveloperError('Animations are not loaded. Wait for Model.readyPromise to resolve.');164 }165 if (!defined(options.name) && !defined(options.index)) {166 throw new DeveloperError('Either options.name or options.index must be defined.');167 }168 if (defined(options.speedup) && (options.speedup <= 0.0)) {169 throw new DeveloperError('options.speedup must be greater than zero.');170 }171 if (defined(options.index) && (options.index >= animations.length || options.index < 0)) {172 throw new DeveloperError('options.index must be a valid animation index.');173 }174 //>>includeEnd('debug');175176 if (defined(options.index)) {177 return add(this, options.index, options);178 }179180 // Find the index of the animation with the given name181 var index;182 var length = animations.length;183 for (var i = 0; i < length; ++i) {184 if (animations[i].name === options.name) {185 index = i;186 break;187 }188 }189190 //>>includeStart('debug', pragmas.debug);191 if (!defined(index)) {192 throw new DeveloperError('options.name must be a valid animation name.');193 }194 //>>includeEnd('debug');195196 return add(this, index, options);197 };198199 /**200 * Creates and adds an animation with the specified initial properties to the collection201 * for each animation in the model.202 * <p>203 * This raises the {@link ModelAnimationCollection#animationAdded} event for each model so, for example, a UI can stay in sync.204 * </p>205 *206 * @param {Object} [options] Object with the following properties:207 * @param {JulianDate} [options.startTime] The scene time to start playing the animations. When this is <code>undefined</code>, the animations starts at the next frame.208 * @param {Number} [options.delay=0.0] The delay, in seconds, from <code>startTime</code> to start playing.209 * @param {JulianDate} [options.stopTime] The scene time to stop playing the animations. When this is <code>undefined</code>, the animations are played for its full duration.210 * @param {Boolean} [options.removeOnStop=false] When <code>true</code>, the animations are removed after they stop playing.211 * @param {Number} [options.speedup=1.0] Values greater than <code>1.0</code> increase the speed that the animations play relative to the scene clock speed; values less than <code>1.0</code> decrease the speed.212 * @param {Boolean} [options.reverse=false] When <code>true</code>, the animations are played in reverse.213 * @param {ModelAnimationLoop} [options.loop=ModelAnimationLoop.NONE] Determines if and how the animations are looped.214 * @returns {ModelAnimation[]} An array of {@link ModelAnimation} objects, one for each animation added to the collection. If there are no glTF animations, the array is empty.215 *216 * @exception {DeveloperError} Animations are not loaded. Wait for the {@link Model#readyPromise} to resolve.217 * @exception {DeveloperError} options.speedup must be greater than zero.218 *219 * @example220 * model.activeAnimations.addAll({221 * speedup : 0.5, // Play at half-speed222 * loop : Cesium.ModelAnimationLoop.REPEAT // Loop the animations223 * });224 */225 ModelAnimationCollection.prototype.addAll = function(options) {226 options = defaultValue(options, defaultValue.EMPTY_OBJECT);227228 //>>includeStart('debug', pragmas.debug);229 if (!defined(this._model._runtime.animations)) {230 throw new DeveloperError('Animations are not loaded. Wait for Model.readyPromise to resolve.');231 }232233 if (defined(options.speedup) && (options.speedup <= 0.0)) {234 throw new DeveloperError('options.speedup must be greater than zero.');235 }236 //>>includeEnd('debug');237238 var scheduledAnimations = [];239 var model = this._model;240 var animations = model._runtime.animations;241 var length = animations.length;242 for (var i = 0; i < length; ++i) {243 scheduledAnimations.push(add(this, i, options));244 }245 return scheduledAnimations;246 };247248 /**249 * Removes an animation from the collection.250 * <p>251 * This raises the {@link ModelAnimationCollection#animationRemoved} event so, for example, a UI can stay in sync.252 * </p>253 * <p>254 * An animation can also be implicitly removed from the collection by setting {@link ModelAnimation#removeOnStop} to255 * <code>true</code>. The {@link ModelAnimationCollection#animationRemoved} event is still fired when the animation is removed.256 * </p>257 *258 * @param {ModelAnimation} animation The animation to remove.259 * @returns {Boolean} <code>true</code> if the animation was removed; <code>false</code> if the animation was not found in the collection.260 *261 * @example262 * var a = model.activeAnimations.add({263 * name : 'animation name'264 * });265 * model.activeAnimations.remove(a); // Returns true266 */267 ModelAnimationCollection.prototype.remove = function(animation) {268 if (defined(animation)) {269 var animations = this._scheduledAnimations;270 var i = animations.indexOf(animation);271 if (i !== -1) {272 animations.splice(i, 1);273 this.animationRemoved.raiseEvent(this._model, animation);274 return true;275 }276 }277278 return false;279 };280281 /**282 * Removes all animations from the collection.283 * <p>284 * This raises the {@link ModelAnimationCollection#animationRemoved} event for each285 * animation so, for example, a UI can stay in sync.286 * </p>287 */288 ModelAnimationCollection.prototype.removeAll = function() {289 var model = this._model;290 var animations = this._scheduledAnimations;291 var length = animations.length;292293 this._scheduledAnimations = [];294295 for (var i = 0; i < length; ++i) {296 this.animationRemoved.raiseEvent(model, animations[i]);297 }298 };299300 /**301 * Determines whether this collection contains a given animation.302 *303 * @param {ModelAnimation} animation The animation to check for.304 * @returns {Boolean} <code>true</code> if this collection contains the animation, <code>false</code> otherwise.305 */306 ModelAnimationCollection.prototype.contains = function(animation) {307 if (defined(animation)) {308 return (this._scheduledAnimations.indexOf(animation) !== -1);309 }310311 return false;312 };313314 /**315 * Returns the animation in the collection at the specified index. Indices are zero-based316 * and increase as animations are added. Removing an animation shifts all animations after317 * it to the left, changing their indices. This function is commonly used to iterate over318 * all the animations in the collection.319 *320 * @param {Number} index The zero-based index of the animation.321 * @returns {ModelAnimation} The animation at the specified index.322 *323 * @example324 * // Output the names of all the animations in the collection.325 * var animations = model.activeAnimations;326 * var length = animations.length;327 * for (var i = 0; i < length; ++i) {328 * console.log(animations.get(i).name);329 * }330 */331 ModelAnimationCollection.prototype.get = function(index) {332 //>>includeStart('debug', pragmas.debug);333 if (!defined(index)) {334 throw new DeveloperError('index is required.');335 }336 //>>includeEnd('debug');337338 return this._scheduledAnimations[index];339 };340341 function animateChannels(runtimeAnimation, localAnimationTime) {342 var channelEvaluators = runtimeAnimation.channelEvaluators;343 var length = channelEvaluators.length;344 for (var i = 0; i < length; ++i) {345 channelEvaluators[i](localAnimationTime);346 }347 }348349 var animationsToRemove = [];350351 function createAnimationRemovedFunction(modelAnimationCollection, model, animation) {352 return function() {353 modelAnimationCollection.animationRemoved.raiseEvent(model, animation);354 };355 }356357 /**358 * @private359 */360 ModelAnimationCollection.prototype.update = function(frameState) {361 var scheduledAnimations = this._scheduledAnimations;362 var length = scheduledAnimations.length;363364 if (length === 0) {365 // No animations - quick return for performance366 this._previousTime = undefined;367 return false;368 }369370 if (JulianDate.equals(frameState.time, this._previousTime)) {371 // Animations are currently only time-dependent so do not animate when paused or picking372 return false;373 }374 this._previousTime = JulianDate.clone(frameState.time, this._previousTime);375376 var animationOccured = false;377 var sceneTime = frameState.time;378 var model = this._model;379380 for (var i = 0; i < length; ++i) {381 var scheduledAnimation = scheduledAnimations[i];382 var runtimeAnimation = scheduledAnimation._runtimeAnimation;383384 if (!defined(scheduledAnimation._computedStartTime)) {385 scheduledAnimation._computedStartTime = JulianDate.addSeconds(defaultValue(scheduledAnimation.startTime, sceneTime), scheduledAnimation.delay, new JulianDate());386 }387388 if (!defined(scheduledAnimation._duration)) {389 scheduledAnimation._duration = runtimeAnimation.stopTime * (1.0 / scheduledAnimation.speedup);390 }391392 var startTime = scheduledAnimation._computedStartTime;393 var duration = scheduledAnimation._duration;394 var stopTime = scheduledAnimation.stopTime;395396 // [0.0, 1.0] normalized local animation time397 var delta = (duration !== 0.0) ? (JulianDate.secondsDifference(sceneTime, startTime) / duration) : 0.0;398 var pastStartTime = (delta >= 0.0);399400 // Play animation if401 // * we are after the start time or the animation is being repeated, and402 // * before the end of the animation's duration or the animation is being repeated, and403 // * we did not reach a user-provided stop time.404405 var repeat = ((scheduledAnimation.loop === ModelAnimationLoop.REPEAT) ||406 (scheduledAnimation.loop === ModelAnimationLoop.MIRRORED_REPEAT));407408 var play = (pastStartTime || (repeat && !defined(scheduledAnimation.startTime))) &&409 ((delta <= 1.0) || repeat) &&410 (!defined(stopTime) || JulianDate.lessThanOrEquals(sceneTime, stopTime));411412 if (play) {413 // STOPPED -> ANIMATING state transition?414 if (scheduledAnimation._state === ModelAnimationState.STOPPED) {415 scheduledAnimation._state = ModelAnimationState.ANIMATING;416 if (scheduledAnimation.start.numberOfListeners > 0) {417 frameState.afterRender.push(scheduledAnimation._raiseStartEvent);418 }419 }420421 // Truncate to [0.0, 1.0] for repeating animations422 if (scheduledAnimation.loop === ModelAnimationLoop.REPEAT) {423 delta = delta - Math.floor(delta);424 } else if (scheduledAnimation.loop === ModelAnimationLoop.MIRRORED_REPEAT) {425 var floor = Math.floor(delta);426 var fract = delta - floor;427 // When even use (1.0 - fract) to mirror repeat428 delta = (floor % 2 === 1.0) ? (1.0 - fract) : fract;429 }430431 if (scheduledAnimation.reverse) {432 delta = 1.0 - delta;433 }434435 var localAnimationTime = delta * duration * scheduledAnimation.speedup;436 // Clamp in case floating-point roundoff goes outside the animation's first or last keyframe437 localAnimationTime = CesiumMath.clamp(localAnimationTime, runtimeAnimation.startTime, runtimeAnimation.stopTime);438439 animateChannels(runtimeAnimation, localAnimationTime);440441 if (scheduledAnimation.update.numberOfListeners > 0) {442 scheduledAnimation._updateEventTime = localAnimationTime;443 frameState.afterRender.push(scheduledAnimation._raiseUpdateEvent);444 }445 animationOccured = true;446 } else if (pastStartTime && (scheduledAnimation._state === ModelAnimationState.ANIMATING)) {447 // ANIMATING -> STOPPED state transition?448 scheduledAnimation._state = ModelAnimationState.STOPPED;449 if (scheduledAnimation.stop.numberOfListeners > 0) {450 frameState.afterRender.push(scheduledAnimation._raiseStopEvent);451 }452453 if (scheduledAnimation.removeOnStop) {454 animationsToRemove.push(scheduledAnimation);455 }456 }457 }458459 // Remove animations that stopped460 length = animationsToRemove.length;461 for (var j = 0; j < length; ++j) {462 var animationToRemove = animationsToRemove[j];463 scheduledAnimations.splice(scheduledAnimations.indexOf(animationToRemove), 1);464 frameState.afterRender.push(createAnimationRemovedFunction(this, model, animationToRemove));465 }466 animationsToRemove.length = 0;467468 return animationOccured;469 };470471 return ModelAnimationCollection; ...

Full Screen

Full Screen

AnimationAction.tests.js

Source:AnimationAction.tests.js Github

copy

Full Screen

1/**2 * @author TristanVALCKE / https://github.com/Itee3 */4/* global QUnit */5import { AnimationAction } from '../../../../src/animation/AnimationAction';6import { AnimationMixer } from '../../../../src/animation/AnimationMixer';7import { AnimationClip } from '../../../../src/animation/AnimationClip';8import { NumberKeyframeTrack } from '../../../../src/animation/tracks/NumberKeyframeTrack';9import { Object3D } from '../../../../src/core/Object3D';10import { LoopOnce, LoopRepeat, LoopPingPong } from '../../../../src/constants';11function createAnimation() {12 var root = new Object3D();13 var mixer = new AnimationMixer( root );14 var track = new NumberKeyframeTrack( ".rotation[x]", [ 0, 1000 ], [ 0, 360 ] );15 var clip = new AnimationClip( "clip1", 1000, [ track ] );16 var animationAction = mixer.clipAction( clip );17 return {18 root: root,19 mixer: mixer,20 track: track,21 clip: clip,22 animationAction: animationAction23 };24}25function createTwoAnimations() {26 var root = new Object3D();27 var mixer = new AnimationMixer( root );28 var track = new NumberKeyframeTrack( ".rotation[x]", [ 0, 1000 ], [ 0, 360 ] );29 var clip = new AnimationClip( "clip1", 1000, [ track ] );30 var animationAction = mixer.clipAction( clip );31 var track2 = new NumberKeyframeTrack( ".rotation[y]", [ 0, 1000 ], [ 0, 360 ] );32 var clip2 = new AnimationClip( "clip2", 1000, [ track ] );33 var animationAction2 = mixer.clipAction( clip2 );34 return {35 root: root,36 mixer: mixer,37 track: track,38 clip: clip,39 animationAction: animationAction,40 track2: track2,41 clip2: clip2,42 animationAction2: animationAction243 };44}45export default QUnit.module( 'Animation', () => {46 QUnit.module( 'AnimationAction', () => {47 // INSTANCING48 QUnit.test( "Instancing", ( assert ) => {49 var mixer = new AnimationMixer();50 var clip = new AnimationClip( "nonname", - 1, [] );51 var animationAction = new AnimationAction( mixer, clip );52 assert.ok( animationAction, "animationAction instanciated" );53 } );54 // PUBLIC STUFF55 QUnit.test( "play", ( assert ) => {56 var { mixer, animationAction } = createAnimation();57 var animationAction2 = animationAction.play();58 assert.equal( animationAction, animationAction2, "AnimationAction.play can be chained." );59 var UserException = function () {60 this.message = "AnimationMixer must activate AnimationAction on play.";61 };62 mixer._activateAction = function ( action ) {63 if ( action === animationAction ) {64 throw new UserException();65 }66 };67 assert.throws( () => {68 animationAction.play();69 }, new UserException() );70 } );71 QUnit.test( "stop", ( assert ) => {72 var { mixer, animationAction } = createAnimation();73 var animationAction2 = animationAction.stop();74 assert.equal( animationAction, animationAction2, "AnimationAction.stop can be chained." );75 var UserException = function () {76 this.message = "AnimationMixer must deactivate AnimationAction on stop.";77 };78 mixer._deactivateAction = function ( action ) {79 if ( action === animationAction ) {80 throw new UserException();81 }82 };83 assert.throws( () => {84 animationAction.stop();85 }, new UserException() );86 } );87 QUnit.test( "reset", ( assert ) => {88 var { mixer, animationAction } = createAnimation();89 var animationAction2 = animationAction.stop();90 assert.equal( animationAction, animationAction2, "AnimationAction.reset can be chained." );91 assert.equal( animationAction2.paused, false, "AnimationAction.reset() sets paused false" );92 assert.equal( animationAction2.enabled, true, "AnimationAction.reset() sets enabled true" );93 assert.equal( animationAction2.time, 0, "AnimationAction.reset() resets time." );94 assert.equal( animationAction2._loopCount, - 1, "AnimationAction.reset() resets loopcount." );95 assert.equal( animationAction2._startTime, null, "AnimationAction.reset() removes starttime." );96 } );97 QUnit.test( "isRunning", ( assert ) => {98 var { mixer, animationAction } = createAnimation();99 assert.notOk( animationAction.isRunning(), "When an animation is just made, it is not running." );100 animationAction.play();101 assert.ok( animationAction.isRunning(), "When an animation is started, it is running." );102 animationAction.stop();103 assert.notOk( animationAction.isRunning(), "When an animation is stopped, it is not running." );104 animationAction.play();105 animationAction.paused = true;106 assert.notOk( animationAction.isRunning(), "When an animation is paused, it is not running." );107 animationAction.paused = false;108 animationAction.enabled = false;109 assert.notOk( animationAction.isRunning(), "When an animation is not enabled, it is not running." );110 animationAction.enabled = true;111 assert.ok( animationAction.isRunning(), "When an animation is enabled, it is running." );112 } );113 QUnit.test( "isScheduled", ( assert ) => {114 var { mixer, animationAction } = createAnimation();115 assert.notOk( animationAction.isScheduled(), "When an animation is just made, it is not scheduled." );116 animationAction.play();117 assert.ok( animationAction.isScheduled(), "When an animation is started, it is scheduled." );118 mixer.update( 1 );119 assert.ok( animationAction.isScheduled(), "When an animation is updated, it is scheduled." );120 animationAction.stop();121 assert.notOk( animationAction.isScheduled(), "When an animation is stopped, it isn't scheduled anymore." );122 } );123 QUnit.test( "startAt", ( assert ) => {124 var { mixer, animationAction } = createAnimation();125 animationAction.startAt( 2 );126 animationAction.play();127 assert.notOk( animationAction.isRunning(), "When an animation is started at a specific time, it is not running." );128 assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time, it is scheduled." );129 mixer.update( 1 );130 assert.notOk( animationAction.isRunning(), "When an animation is started at a specific time and the interval is not passed, it is not running." );131 assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time and the interval is not passed, it is scheduled." );132 mixer.update( 1 );133 assert.ok( animationAction.isRunning(), "When an animation is started at a specific time and the interval is passed, it is running." );134 assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time and the interval is passed, it is scheduled." );135 animationAction.stop();136 assert.notOk( animationAction.isRunning(), "When an animation is stopped, it is not running." );137 assert.notOk( animationAction.isScheduled(), "When an animation is stopped, it is not scheduled." );138 } );139 QUnit.test( "setLoop LoopOnce", ( assert ) => {140 var { mixer, animationAction } = createAnimation();141 animationAction.setLoop( LoopOnce );142 animationAction.play();143 assert.ok( animationAction.isRunning(), "When an animation is started, it is running." );144 mixer.update( 500 );145 assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." );146 mixer.update( 500 );147 assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." );148 mixer.update( 500 );149 assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." );150 } );151 QUnit.test( "setLoop LoopRepeat", ( assert ) => {152 var { root, mixer, animationAction } = createAnimation();153 animationAction.setLoop( LoopRepeat, 3 );154 animationAction.play();155 assert.ok( animationAction.isRunning(), "When an animation is started, it is running." );156 mixer.update( 750 );157 assert.equal( root.rotation.x, 270, "When an animation is 3/4 in the first loop, it has changed to 3/4 when LoopRepeat." );158 assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." );159 mixer.update( 1000 );160 assert.equal( root.rotation.x, 270, "When an animation is 3/4 in the second loop, it has changed to 3/4 when LoopRepeat." );161 assert.ok( animationAction.isRunning(), "When an animation is in second loop when in looprepeat 3 times, it is running." );162 mixer.update( 1000 );163 assert.equal( root.rotation.x, 270, "When an animation is 3/4 in the third loop, it has changed to 3/4 when LoopRepeat." );164 assert.ok( animationAction.isRunning(), "When an animation is in third loop when in looprepeat 3 times, it is running." );165 mixer.update( 1000 );166 assert.equal( root.rotation.x, 0, "When an animation ended his third loop when in looprepeat 3 times, it stays on the end result." );167 assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it stays not running anymore." );168 } );169 QUnit.test( "setLoop LoopPingPong", ( assert ) => {170 var { root, mixer, animationAction } = createAnimation();171 animationAction.setLoop( LoopPingPong, 3 );172 animationAction.play();173 assert.ok( animationAction.isRunning(), "When an animation is started, it is running." );174 mixer.update( 750 );175 assert.equal( root.rotation.x, 270, "When an animation is 3/4 in the first loop, it has changed to 3/4 when LoopPingPong." );176 assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." );177 mixer.update( 1000 );178 assert.equal( root.rotation.x, 90, "When an animation is 3/4 in the second loop, it has changed to 1/4 when LoopPingPong." );179 assert.ok( animationAction.isRunning(), "When an animation is in second loop when in looprepeat 3 times, it is running." );180 mixer.update( 1000 );181 assert.equal( root.rotation.x, 270, "When an animation is 3/4 in the third loop, it has changed to 3/4 when LoopPingPong." );182 assert.ok( animationAction.isRunning(), "When an animation is in third loop when in looprepeat 3 times, it is running." );183 mixer.update( 1000 );184 assert.equal( root.rotation.x, 0, "When an animation ended his fourth loop when in looprepeat 3 times, it stays on the end result." );185 assert.notOk( animationAction.isRunning(), "When an animation ended his fourth loop when in looprepeat 3 times, it stays not running anymore." );186 } );187 QUnit.test( "setEffectiveWeight", ( assert ) => {188 var { animationAction } = createAnimation();189 assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation is created, EffectiveWeight is 1." );190 animationAction.setEffectiveWeight( 0.3 );191 assert.equal( animationAction.getEffectiveWeight(), 0.3, "When EffectiveWeight is set to 0.3 , EffectiveWeight is 0.3." );192 var { animationAction } = createAnimation();193 assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation is created, EffectiveWeight is 1." );194 animationAction.enabled = false;195 animationAction.setEffectiveWeight( 0.3 );196 assert.equal( animationAction.getEffectiveWeight(), 0, "When EffectiveWeight is set to 0.3 when disabled , EffectiveWeight is 0." );197 var { root, mixer, animationAction } = createAnimation();198 animationAction.setEffectiveWeight( 0.5 );199 animationAction.play();200 mixer.update( 500 );201 assert.equal( root.rotation.x, 90, "When an animation has weight 0.5 and runs half through the animation, it has changed to 1/4." );202 mixer.update( 1000 );203 assert.equal( root.rotation.x, 90, "When an animation has weight 0.5 and runs one and half through the animation, it has changed to 1/4." );204 } );205 QUnit.test( "getEffectiveWeight", ( assert ) => {206 var { animationAction } = createAnimation();207 assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation is created, EffectiveWeight is 1." );208 animationAction.setEffectiveWeight( 0.3 );209 assert.equal( animationAction.getEffectiveWeight(), 0.3, "When EffectiveWeight is set to 0.3 , EffectiveWeight is 0.3." );210 var { animationAction } = createAnimation();211 assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation is created, EffectiveWeight is 1." );212 animationAction.enabled = false;213 animationAction.setEffectiveWeight( 0.3 );214 assert.equal( animationAction.getEffectiveWeight(), 0, "When EffectiveWeight is set to 0.3 when disabled , EffectiveWeight is 0." );215 } );216 QUnit.test( "fadeIn", ( assert ) => {217 var { mixer, animationAction } = createAnimation();218 animationAction.fadeIn( 1000 );219 animationAction.play();220 assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation fadeIn is started, EffectiveWeight is 1." );221 mixer.update( 250 );222 assert.equal( animationAction.getEffectiveWeight(), 0.25, "When an animation fadeIn happened 1/4, EffectiveWeight is 0.25." );223 mixer.update( 250 );224 assert.equal( animationAction.getEffectiveWeight(), 0.5, "When an animation fadeIn is halfway , EffectiveWeight is 0.5." );225 mixer.update( 250 );226 assert.equal( animationAction.getEffectiveWeight(), 0.75, "When an animation fadeIn is halfway , EffectiveWeight is 0.75." );227 mixer.update( 500 );228 assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation fadeIn is ended , EffectiveWeight is 1." );229 } );230 QUnit.test( "fadeOut", ( assert ) => {231 var { mixer, animationAction } = createAnimation();232 animationAction.fadeOut( 1000 );233 animationAction.play();234 assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation fadeOut is started, EffectiveWeight is 1." );235 mixer.update( 250 );236 assert.equal( animationAction.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );237 mixer.update( 250 );238 assert.equal( animationAction.getEffectiveWeight(), 0.5, "When an animation fadeOut is halfway , EffectiveWeight is 0.5." );239 mixer.update( 250 );240 assert.equal( animationAction.getEffectiveWeight(), 0.25, "When an animation fadeOut is happened 3/4 , EffectiveWeight is 0.25." );241 mixer.update( 500 );242 assert.equal( animationAction.getEffectiveWeight(), 0, "When an animation fadeOut is ended , EffectiveWeight is 0." );243 } );244 QUnit.test( "crossFadeFrom", ( assert ) => {245 var { mixer, animationAction, animationAction2 } = createTwoAnimations();246 animationAction.crossFadeFrom( animationAction2, 1000, false );247 animationAction.play();248 animationAction2.play();249 assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation crossFadeFrom is started, EffectiveWeight is 1." );250 assert.equal( animationAction2.getEffectiveWeight(), 1, "When an animation crossFadeFrom is started, EffectiveWeight is 1." );251 mixer.update( 250 );252 assert.equal( animationAction.getEffectiveWeight(), 0.25, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );253 assert.equal( animationAction2.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );254 mixer.update( 250 );255 assert.equal( animationAction.getEffectiveWeight(), 0.5, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );256 assert.equal( animationAction2.getEffectiveWeight(), 0.5, "When an animation fadeOut is halfway , EffectiveWeight is 0.5." );257 mixer.update( 250 );258 assert.equal( animationAction.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );259 assert.equal( animationAction2.getEffectiveWeight(), 0.25, "When an animation fadeOut is happened 3/4 , EffectiveWeight is 0.25." );260 mixer.update( 500 );261 assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );262 assert.equal( animationAction2.getEffectiveWeight(), 0, "When an animation fadeOut is ended , EffectiveWeight is 0." );263 } );264 QUnit.test( "crossFadeTo", ( assert ) => {265 var { mixer, animationAction, animationAction2 } = createTwoAnimations();266 animationAction2.crossFadeTo( animationAction, 1000, false );267 animationAction.play();268 animationAction2.play();269 assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation crossFadeFrom is started, EffectiveWeight is 1." );270 assert.equal( animationAction2.getEffectiveWeight(), 1, "When an animation crossFadeFrom is started, EffectiveWeight is 1." );271 mixer.update( 250 );272 assert.equal( animationAction.getEffectiveWeight(), 0.25, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );273 assert.equal( animationAction2.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );274 mixer.update( 250 );275 assert.equal( animationAction.getEffectiveWeight(), 0.5, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );276 assert.equal( animationAction2.getEffectiveWeight(), 0.5, "When an animation fadeOut is halfway , EffectiveWeight is 0.5." );277 mixer.update( 250 );278 assert.equal( animationAction.getEffectiveWeight(), 0.75, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );279 assert.equal( animationAction2.getEffectiveWeight(), 0.25, "When an animation fadeOut is happened 3/4 , EffectiveWeight is 0.25." );280 mixer.update( 500 );281 assert.equal( animationAction.getEffectiveWeight(), 1, "When an animation fadeOut happened 1/4, EffectiveWeight is 0.75." );282 assert.equal( animationAction2.getEffectiveWeight(), 0, "When an animation fadeOut is ended , EffectiveWeight is 0." );283 } );284 QUnit.todo( "stopFading", ( assert ) => {285 assert.ok( false, "everything's gonna be alright" );286 } );287 QUnit.todo( "setEffectiveTimeScale", ( assert ) => {288 assert.ok( false, "everything's gonna be alright" );289 } );290 QUnit.todo( "getEffectiveTimeScale", ( assert ) => {291 assert.ok( false, "everything's gonna be alright" );292 } );293 QUnit.todo( "setDuration", ( assert ) => {294 assert.ok( false, "everything's gonna be alright" );295 } );296 QUnit.todo( "syncWith", ( assert ) => {297 assert.ok( false, "everything's gonna be alright" );298 } );299 QUnit.todo( "halt", ( assert ) => {300 assert.ok( false, "everything's gonna be alright" );301 } );302 QUnit.todo( "warp", ( assert ) => {303 assert.ok( false, "everything's gonna be alright" );304 } );305 QUnit.todo( "stopWarping", ( assert ) => {306 assert.ok( false, "everything's gonna be alright" );307 } );308 QUnit.test( "getMixer", ( assert ) => {309 var { mixer, animationAction } = createAnimation();310 var mixer2 = animationAction.getMixer();311 assert.equal( mixer, mixer2, "mixer should be returned by getMixer." );312 } );313 QUnit.test( "getClip", ( assert ) => {314 var { clip, animationAction } = createAnimation();315 var clip2 = animationAction.getClip();316 assert.equal( clip, clip2, "clip should be returned by getClip." );317 } );318 QUnit.test( "getRoot", ( assert ) => {319 var { root, animationAction } = createAnimation();320 var root2 = animationAction.getRoot();321 assert.equal( root, root2, "root should be returned by getRoot." );322 } );323 } );...

Full Screen

Full Screen

animation-active.js

Source:animation-active.js Github

copy

Full Screen

1(function ($) {2 "use strict";3 4 /*----------------------5 Animation active js6 -----------------------*/7 $("button.btn.ant-nk-st.bounce-ac").on('click', function(){8 $(".animation-img .animate-one").addClass("animated bounce").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){9 $(this).removeClass("animated bounce");10 });11 });12 $("button.btn.ant-nk-st.flash-ac").on('click', function(){13 $(".animation-img .animate-one").addClass("animated flash").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){14 $(this).removeClass("animated flash");15 });16 });17 $("button.btn.ant-nk-st.pulse-ac").on('click', function(){18 $(".animation-img .animate-one").addClass("animated pulse").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){19 $(this).removeClass("animated pulse");20 });21 });22 $("button.btn.ant-nk-st.rubberBand-ac").on('click', function(){23 $(".animation-img .animate-one").addClass("animated rubberBand").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){24 $(this).removeClass("animated rubberBand");25 });26 });27 $("button.btn.ant-nk-st.bounceIn-ac").on('click', function(){28 $(".animation-img .animate-two").addClass("animated bounceIn").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){29 $(this).removeClass("animated bounceIn");30 });31 });32 $("button.btn.ant-nk-st.bounceInDown-ac").on('click', function(){33 $(".animation-img .animate-two").addClass("animated bounceInDown").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){34 $(this).removeClass("animated bounceInDown");35 });36 });37 $("button.btn.ant-nk-st.bounceInLeft-ac").on('click', function(){38 $(".animation-img .animate-two").addClass("animated bounceInLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){39 $(this).removeClass("animated bounceInLeft");40 });41 });42 $("button.btn.ant-nk-st.bounceInUp-ac").on('click', function(){43 $(".animation-img .animate-two").addClass("animated bounceInUp").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){44 $(this).removeClass("animated bounceInUp");45 });46 });47 $("button.btn.ant-nk-st.bounceOut-ac").on('click', function(){48 $(".animation-img .animate-three").addClass("animated bounceOut").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){49 $(this).removeClass("animated bounceOut");50 });51 });52 $("button.btn.ant-nk-st.bounceOutDown-ac").on('click', function(){53 $(".animation-img .animate-three").addClass("animated bounceOutDown").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){54 $(this).removeClass("animated bounceOutDown");55 });56 });57 $("button.btn.ant-nk-st.bounceOutLeft-ac").on('click', function(){58 $(".animation-img .animate-three").addClass("animated bounceOutLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){59 $(this).removeClass("animated bounceOutLeft");60 });61 });62 $("button.btn.ant-nk-st.bounceOutRight-ac").on('click', function(){63 $(".animation-img .animate-three").addClass("animated bounceOutRight").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){64 $(this).removeClass("animated bounceOutRight");65 });66 });67 $("button.btn.ant-nk-st.fadeIn-ac").on('click', function(){68 $(".animation-img .animate-four").addClass("animated fadeIn").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){69 $(this).removeClass("animated fadeIn");70 });71 });72 $("button.btn.ant-nk-st.fadeInDown-ac").on('click', function(){73 $(".animation-img .animate-four").addClass("animated fadeInDown").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){74 $(this).removeClass("animated fadeInDown");75 });76 });77 $("button.btn.ant-nk-st.fadeInDownBig-ac").on('click', function(){78 $(".animation-img .animate-four").addClass("animated fadeInDownBig").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){79 $(this).removeClass("animated fadeInDownBig");80 });81 });82 $("button.btn.ant-nk-st.fadeInLeft-ac").on('click', function(){83 $(".animation-img .animate-four").addClass("animated fadeInLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){84 $(this).removeClass("animated fadeInLeft");85 });86 });87 $("button.btn.ant-nk-st.fadeOut-ac").on('click', function(){88 $(".animation-img .animate-five").addClass("animated fadeOut").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){89 $(this).removeClass("animated fadeOut");90 });91 });92 $("button.btn.ant-nk-st.fadeOutDown-ac").on('click', function(){93 $(".animation-img .animate-five").addClass("animated fadeOutDown").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){94 $(this).removeClass("animated fadeOutDown");95 });96 });97 $("button.btn.ant-nk-st.fadeOutDownBig-ac").on('click', function(){98 $(".animation-img .animate-five").addClass("animated fadeOutDownBig").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){99 $(this).removeClass("animated fadeOutDownBig");100 });101 });102 $("button.btn.ant-nk-st.fadeOutLeft-ac").on('click', function(){103 $(".animation-img .animate-five").addClass("animated fadeOutLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){104 $(this).removeClass("animated fadeOutLeft");105 });106 });107 $("button.btn.ant-nk-st.flip-ac").on('click', function(){108 $(".animation-img .animate-six").addClass("animated flip").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){109 $(this).removeClass("animated flip");110 });111 });112 $("button.btn.ant-nk-st.flipInX-ac").on('click', function(){113 $(".animation-img .animate-six").addClass("animated flipInX").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){114 $(this).removeClass("animated flipInX");115 });116 });117 $("button.btn.ant-nk-st.flipInY-ac").on('click', function(){118 $(".animation-img .animate-six").addClass("animated flipInY").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){119 $(this).removeClass("animated flipInY");120 });121 });122 $("button.btn.ant-nk-st.flipOutX-ac").on('click', function(){123 $(".animation-img .animate-six").addClass("animated flipOutX").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){124 $(this).removeClass("animated flipOutX");125 });126 });127 $("button.btn.ant-nk-st.slideInUp-ac").on('click', function(){128 $(".animation-img .animate-seven").addClass("animated slideInUp").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){129 $(this).removeClass("animated slideInUp");130 });131 });132 $("button.btn.ant-nk-st.slideInDown-ac").on('click', function(){133 $(".animation-img .animate-seven").addClass("animated slideInDown").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){134 $(this).removeClass("animated slideInDown");135 });136 });137 $("button.btn.ant-nk-st.slideInLeft-ac").on('click', function(){138 $(".animation-img .animate-seven").addClass("animated slideInLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){139 $(this).removeClass("animated slideInLeft");140 });141 });142 $("button.btn.ant-nk-st.slideInRight-ac").on('click', function(){143 $(".animation-img .animate-seven").addClass("animated slideInRight").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){144 $(this).removeClass("animated slideInRight");145 });146 });147 $("button.btn.ant-nk-st.rotateIn-ac").on('click', function(){148 $(".animation-img .animate-eight").addClass("animated rotateIn").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){149 $(this).removeClass("animated rotateIn");150 });151 });152 $("button.btn.ant-nk-st.rotateInDownLeft-ac").on('click', function(){153 $(".animation-img .animate-eight").addClass("animated rotateInDownLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){154 $(this).removeClass("animated rotateInDownLeft");155 });156 });157 $("button.btn.ant-nk-st.rotateInDownRight-ac").on('click', function(){158 $(".animation-img .animate-eight").addClass("animated rotateInDownRight").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){159 $(this).removeClass("animated rotateInDownRight");160 });161 });162 $("button.btn.ant-nk-st.rotateInUpLeft-ac").on('click', function(){163 $(".animation-img .animate-eight").addClass("animated rotateInUpLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){164 $(this).removeClass("animated rotateInUpLeft");165 });166 });167 $("button.btn.ant-nk-st.rotateOut-ac").on('click', function(){168 $(".animation-img .animate-nine").addClass("animated rotateOut").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){169 $(this).removeClass("animated rotateOut");170 });171 });172 $("button.btn.ant-nk-st.rotateOutDownLeft-ac").on('click', function(){173 $(".animation-img .animate-nine").addClass("animated rotateOutDownLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){174 $(this).removeClass("animated rotateOutDownLeft");175 });176 });177 $("button.btn.ant-nk-st.rotateOutDownRight-ac").on('click', function(){178 $(".animation-img .animate-nine").addClass("animated rotateOutDownRight").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){179 $(this).removeClass("animated rotateOutDownRight");180 });181 });182 $("button.btn.ant-nk-st.rotateOutUpLeft-ac").on('click', function(){183 $(".animation-img .animate-nine").addClass("animated rotateOutUpLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){184 $(this).removeClass("animated rotateOutUpLeft");185 });186 });187 $("button.btn.ant-nk-st.slideOutUp-ac").on('click', function(){188 $(".animation-img .animate-ten").addClass("animated slideOutUp").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){189 $(this).removeClass("animated slideOutUp");190 });191 });192 $("button.btn.ant-nk-st.slideOutDown-ac").on('click', function(){193 $(".animation-img .animate-ten").addClass("animated slideOutDown").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){194 $(this).removeClass("animated slideOutDown");195 });196 });197 $("button.btn.ant-nk-st.slideOutLeft-ac").on('click', function(){198 $(".animation-img .animate-ten").addClass("animated slideOutLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){199 $(this).removeClass("animated slideOutLeft");200 });201 });202 $("button.btn.ant-nk-st.slideOutRight-ac").on('click', function(){203 $(".animation-img .animate-ten").addClass("animated slideOutRight").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){204 $(this).removeClass("animated slideOutRight");205 });206 });207 $("button.btn.ant-nk-st.zoomIn-ac").on('click', function(){208 $(".animation-img .animate-eleven").addClass("animated zoomIn").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){209 $(this).removeClass("animated zoomIn");210 });211 });212 $("button.btn.ant-nk-st.zoomInDown-ac").on('click', function(){213 $(".animation-img .animate-eleven").addClass("animated zoomInDown").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){214 $(this).removeClass("animated zoomInDown");215 });216 });217 $("button.btn.ant-nk-st.zoomInLeft-ac").on('click', function(){218 $(".animation-img .animate-eleven").addClass("animated zoomInLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){219 $(this).removeClass("animated zoomInLeft");220 });221 });222 $("button.btn.ant-nk-st.zoomInRight-ac").on('click', function(){223 $(".animation-img .animate-eleven").addClass("animated zoomInRight").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){224 $(this).removeClass("animated zoomInRight");225 });226 });227 $("button.btn.ant-nk-st.zoomOut-ac").on('click', function(){228 $(".animation-img .animate-twelve").addClass("animated zoomOut").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){229 $(this).removeClass("animated zoomOut");230 });231 });232 $("button.btn.ant-nk-st.zoomOutDown-ac").on('click', function(){233 $(".animation-img .animate-twelve").addClass("animated zoomOutDown").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){234 $(this).removeClass("animated zoomOutDown");235 });236 });237 $("button.btn.ant-nk-st.zoomOutLeft-ac").on('click', function(){238 $(".animation-img .animate-twelve").addClass("animated zoomOutLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){239 $(this).removeClass("animated zoomOutLeft");240 });241 });242 $("button.btn.ant-nk-st.zoomOutRight-ac").on('click', function(){243 $(".animation-img .animate-twelve").addClass("animated zoomOutRight").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){244 $(this).removeClass("animated zoomOutRight");245 });246 });247 /*----------------------248 Animation dropdown active js249 -----------------------*/250 $("button.triger-fadeIn").on('click', function(){251 $(".triger-fadeIn-dp").addClass("animated fadeIn").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){252 $(this).removeClass("animated fadeIn");253 });254 });255 $("button.triger-fadeInUp").on('click', function(){256 $(".triger-fadeInUp-dp").addClass("animated fadeInUp").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){257 $(this).removeClass("animated fadeInUp");258 });259 });260 $("button.triger-fadeInLeft").on('click', function(){261 $(".triger-fadeInLeft-dp").addClass("animated fadeInLeft").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){262 $(this).removeClass("animated fadeInLeft");263 });264 });265 $("button.triger-shake").on('click', function(){266 $(".triger-shake-dp").addClass("animated shake").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){267 $(this).removeClass("animated shake");268 });269 });270 $("button.triger-swing").on('click', function(){271 $(".triger-swing-dp").addClass("animated swing").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){272 $(this).removeClass("animated swing");273 });274 });275 $("button.triger-jello").on('click', function(){276 $(".triger-jello-dp").addClass("animated jello").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){277 $(this).removeClass("animated jello");278 });279 });280 $("button.triger-bounceIn").on('click', function(){281 $(".triger-bounceIn-dp").addClass("animated bounceIn").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){282 $(this).removeClass("animated bounceIn");283 });284 });285 $("button.triger-bounceInUp").on('click', function(){286 $(".triger-bounceInUp-dp").addClass("animated bounceInUp").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){287 $(this).removeClass("animated bounceInUp");288 });289 });290 $("button.triger-flip").on('click', function(){291 $(".triger-flip-dp").addClass("animated flip").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){292 $(this).removeClass("animated flip");293 });294 });295 $("button.triger-flipInX").on('click', function(){296 $(".triger-flipInX-dp").addClass("animated flipInX").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){297 $(this).removeClass("animated flipInX");298 });299 });300 $("button.triger-flipInY").on('click', function(){301 $(".triger-flipInY-dp").addClass("animated flipInY").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){302 $(this).removeClass("animated flipInY");303 });304 });305 $("button.triger-rotateIn").on('click', function(){306 $(".triger-rotateIn-dp").addClass("animated rotateIn").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){307 $(this).removeClass("animated rotateIn");308 });309 });310 $("button.triger-zoomIn").on('click', function(){311 $(".triger-zoomIn-dp").addClass("animated zoomIn").one("webkitAnimationEnd mozAnimationEnd oAnimationEnd animationend", function(){312 $(this).removeClass("animated zoomIn");313 });314 });315 ...

Full Screen

Full Screen

transitions-sliders.js

Source:transitions-sliders.js Github

copy

Full Screen

1'use strict';2$(document).ready(function(){3 function testAnim(x, str) {4 $('#animationSandbox' + str).removeClass().addClass(x + ' animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {5 $(this).removeClass();6 });7 }8 function testAnim1(str) {9 var x = document.getElementById('s' + str).value;10 $('#animationSandbox' + str).removeClass().addClass(x + ' animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {11 $(this).removeClass();12 });13 }14 $(".knob").knob({15 change: function(value) {16 //console.log("change : " + value);17 },18 release: function(value) {19 //console.log(this.$.attr('value'));20 console.log("release : " + value);21 },22 cancel: function() {23 console.log("cancel : ", this);24 },25 /*format : function (value) {26 return value + '%';27 },*/28 draw: function() {29 // "tron" case30 if (this.$.data('skin') == 'tron') {31 this.cursorExt = 0.3;32 var a = this.arc(this.cv) // Arc33 ,34 pa // Previous arc35 , r = 1;36 this.g.lineWidth = this.lineWidth;37 if (this.o.displayPrevious) {38 pa = this.arc(this.v);39 this.g.beginPath();40 this.g.strokeStyle = this.pColor;41 this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, pa.s, pa.e, pa.d);42 this.g.stroke();43 }44 this.g.beginPath();45 this.g.strokeStyle = r ? this.o.fgColor : this.fgColor;46 this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, a.s, a.e, a.d);47 this.g.stroke();48 this.g.lineWidth = 2;49 this.g.beginPath();50 this.g.strokeStyle = this.o.fgColor;51 this.g.arc(this.xy, this.xy, this.radius - this.lineWidth + 1 + this.lineWidth * 2 / 3, 0, 2 * Math.PI, false);52 this.g.stroke();53 return false;54 }55 }56 });57 // Example of infinite knob, iPod click wheel58 var v, up = 0,59 down = 0,60 i = 0,61 $idir = $("div.idir"),62 $ival = $("div.ival"),63 incr = function() {64 i++;65 $idir.show().html("+").fadeOut();66 $ival.html(i);67 },68 decr = function() {69 i--;70 $idir.show().html("-").fadeOut();71 $ival.html(i);72 };73 $("input.infinite").knob({74 min: 0,75 max: 20,76 stopper: false,77 change: function() {78 if (v > this.cv) {79 if (up) {80 decr();81 up = 0;82 } else {83 up = 1;84 down = 0;85 }86 } else {87 if (v < this.cv) {88 if (down) {89 incr();90 down = 0;91 } else {92 down = 1;93 up = 0;94 }95 }96 }97 v = this.cv;98 }99 });100// ======================transitions========================101// bounce in102 $("#bi").on("click", function() {103 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';104 $('#bi').addClass('animated bounceIn').one(animationEnd, function() {105 $(this).removeClass('animated bounceIn');106 });107 return false;108 });109// bounceinleft110 $("#bil").on("click", function() {111 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';112 $('#bil').addClass('animated bounceInLeft').one(animationEnd, function() {113 $(this).removeClass('animated bounceInLeft');114 });115 return false;116 });117// bounceinright118 $("#bir").on("click", function() {119 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';120 $('#bir').addClass('animated bounceInRight').one(animationEnd, function() {121 $(this).removeClass('animated bounceInRight');122 });123 return false;124 });125// bounce out126 $("#bo").on("click", function() {127 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';128 $('#bo').addClass('animated bounceOut').one(animationEnd, function() {129 $(this).removeClass('animated bounceOut');130 });131 return false;132 });133// pulse134 $("#pul").on("click", function() {135 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';136 $('#pul').addClass('animated pulse').one(animationEnd, function() {137 $(this).removeClass('animated pulse');138 });139 return false;140 });141// tada142 $("#tad").on("click", function() {143 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';144 $('#tad').addClass('animated tada').one(animationEnd, function() {145 $(this).removeClass('animated tada');146 });147 return false;148 });149 // Rubber band150 $("#rubber").on("click", function() {151 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';152 $('#rubber').addClass('animated rubberBand').one(animationEnd, function() {153 $(this).removeClass('animated rubberBand');154 });155 return false;156 });157//swing158 $("#swing").on("click", function() {159 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';160 $('#swing').addClass('animated swing').one(animationEnd, function() {161 $(this).removeClass('animated swing');162 });163 return false;164 });165// wobble166 $("#wobble").on("click", function() {167 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';168 $('#wobble').addClass('animated wobble').one(animationEnd, function() {169 $(this).removeClass('animated wobble');170 });171 return false;172 });173//fade effects174 $("#fadein").on("click", function() {175 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';176 $('#fadein').addClass('animated fadeIn').one(animationEnd, function() {177 $(this).removeClass('animated fadeIn');178 });179 return false;180 });181 $("#fadeleft").on("click", function() {182 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';183 $('#fadeleft').addClass('animated fadeInLeft').one(animationEnd, function() {184 $(this).removeClass('animated fadeInLeft');185 });186 return false;187 });188 $("#faderight").on("click", function() {189 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';190 $('#faderight').addClass('animated fadeInRight').one(animationEnd, function() {191 $(this).removeClass('animated fadeInRight');192 });193 return false;194 });195 $("#fadeout").on("click", function() {196 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';197 $('#fadeout').addClass('animated fadeOut').one(animationEnd, function() {198 $(this).removeClass('animated fadeOut');199 });200 return false;201 });202//flip effect203 $("#flip").on("click", function() {204 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';205 $('#flip').addClass('animated flip').one(animationEnd, function() {206 $(this).removeClass('animated flip');207 });208 return false;209 });210 $("#flipy").on("click", function() {211 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';212 $('#flipy').addClass('animated flipInY').one(animationEnd, function() {213 $(this).removeClass('animated flipInY');214 });215 return false;216 });217 $("#flipoutx").on("click", function() {218 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';219 $('#flipoutx').addClass('animated flipOutX').one(animationEnd, function() {220 $(this).removeClass('animated flipOutX');221 });222 return false;223 });224 $("#flipouty").on("click", function() {225 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';226 $('#flipouty').addClass('animated flipOutY').one(animationEnd, function() {227 $(this).removeClass('animated flipOutY');228 });229 return false;230 });231//rotate232 $("#rotatein").on("click", function() {233 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';234 $('#rotatein').addClass('animated rotateIn').one(animationEnd, function() {235 $(this).removeClass('animated rotateIn');236 });237 return false;238 });239 $("#rotatedownright").on("click", function() {240 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';241 $('#rotatedownright').addClass('animated rotateInDownRight').one(animationEnd, function() {242 $(this).removeClass('animated rotateInDownRight');243 });244 return false;245 });246 $("#rotateout").on("click", function() {247 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';248 $('#rotateout').addClass('animated rotateOut').one(animationEnd, function() {249 $(this).removeClass('animated rotateOut');250 });251 return false;252 });253 $("#rotateoutleft").on("click", function() {254 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';255 $('#rotateoutleft').addClass('animated rotateOutUpLeft').one(animationEnd, function() {256 $(this).removeClass('animated rotateOutUpLeft');257 });258 return false;259 });260// zoom effect261 $("#zoomin").on("click", function() {262 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';263 $('#zoomin').addClass('animated zoomIn').one(animationEnd, function() {264 $(this).removeClass('animated zoomIn');265 });266 return false;267 });268 $("#zoominleft").on("click", function() {269 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';270 $('#zoominleft').addClass('animated zoomInLeft').one(animationEnd, function() {271 $(this).removeClass('animated zoomInLeft');272 });273 return false;274 });275 $("#zoomoutdown").on("click", function() {276 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';277 $('#zoomoutdown').addClass('animated zoomOutDown').one(animationEnd, function() {278 $(this).removeClass('animated zoomOutDown');279 });280 return false;281 });282 $("#zoomoutright").on("click", function() {283 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';284 $('#zoomoutright').addClass('animated zoomOutRight').one(animationEnd, function() {285 $(this).removeClass('animated zoomOutRight');286 });287 return false;288 });289//special effects290 $("#hinge").on("click", function() {291 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';292 $('#hinge').addClass('animated hinge').one(animationEnd, function() {293 $(this).removeClass('animated hinge');294 });295 return false;296 });297 $("#rollin").on("click", function() {298 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';299 $('#rollin').addClass('animated rollIn').one(animationEnd, function() {300 $(this).removeClass('animated rollIn');301 });302 return false;303 });304 $("#rollout").on("click", function() {305 var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';306 $('#rollout').addClass('animated rollOut').one(animationEnd, function() {307 $(this).removeClass('animated rollOut');308 });309 return false;310 });...

Full Screen

Full Screen

walkAssets.js

Source:walkAssets.js Github

copy

Full Screen

1//2// walkAssets.js3// version 1.24//5// Created by David Wooldridge, June 20156// Copyright © 2014 - 2015 High Fidelity, Inc.7//8// Organises, loads up and makes available the assets for use by the walk.js script9//10// Distributed under the Apache License, Version 2.0.11// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html12//1314walkAssets = (function () {1516 var _animationSets = {17 //"Female": {18 // path: 'animation-sets/standard-female/'19 //},20 "Male": {21 path: 'animation-sets/standard-male/'22 },23 "Original": {24 path: 'animation-sets/original-male/'25 }26 };27 var _currentAnimationSet = 'Male';28 var _character = null;2930 // load json datafiles31 function loadFile(path, name) {32 var _XMLHttpRequest = new XMLHttpRequest();33 _XMLHttpRequest.open("GET", path, false);34 _XMLHttpRequest.send();35 if (_XMLHttpRequest.status == 200) {36 try {37 var file = JSON.parse(_XMLHttpRequest.responseText);38 if (name === undefined) {39 name = file.name;40 }41 file.name = name;42 return file;43 } catch (e) {44 print('walk.js: Error parsing JSON data for '+path+': '+e.toString());45 print('walk.js: Response text was '+_XMLHttpRequest.responseText);46 return null;47 }48 } else {49 print("walk.js: Error "+_XMLHttpRequest.status+" encountered whilst loading JSON file from "+path);50 return null;51 }52 }5354 // load json animation datafiles55 function loadAnimation(path) {56 var _XMLHttpRequest = new XMLHttpRequest();57 _XMLHttpRequest.open("GET", path, false);58 _XMLHttpRequest.send();59 if (_XMLHttpRequest.status == 200) {60 try {61 var animation = JSON.parse(_XMLHttpRequest.responseText);62 // instantiate harmonics filters63 for (joint in animation.harmonics) {64 for (jointHarmonics in animation.harmonics[joint]) {65 var name = joint+'.'+jointHarmonics;66 var magnitudes = animation.harmonics[joint][jointHarmonics].magnitudes;67 var phaseAngles = animation.harmonics[joint][jointHarmonics].phaseAngles;68 var numHarmonics = animation.harmonics[joint][jointHarmonics].numHarmonics;69 animation.harmonics[joint][jointHarmonics] =70 filter.createHarmonicsFilter(numHarmonics, magnitudes, phaseAngles);71 }72 }73 return animation;74 } catch (e) {75 print('walk.js: Error parsing JSON data for '+path+': '+e.toString());76 print('walk.js: Response text was '+_XMLHttpRequest.responseText);77 return null;78 }79 } else {80 print("walk.js: Error "+_XMLHttpRequest.status+" encountered whilst loading JSON file from "+path);81 return null;82 }83 }8485 function loadAnimationSet() {8687 // load the character animation definition file88 print('walk.js: Loading animation set "'+_currentAnimationSet+'" from '+ pathToAssets + _animationSets[_currentAnimationSet].path);89 _character = loadFile(pathToAssets + _animationSets[_currentAnimationSet].path + "character.json");9091 // load animations data92 for (animation in _character.animations) {93 _character.animations[animation] = loadAnimation(pathToAssets + _character.animations[animation].path);94 print('walk.js: Loaded ' + _character.animations[animation].name+' animation');95 }9697 // load reach poses data98 for (pose in _character.reachPoses) {99 _character.reachPoses[pose].animation = loadAnimation(pathToAssets + _character.reachPoses[pose].path);100 print('walk.js: Loaded ' + _character.reachPoses[pose].animation.name+ ' reach pose');101 }102103 // load sounds104 for (sound in _character.sounds) {105 _character.sounds[sound].audioData = SoundCache.getSound(pathToAssets + _character.sounds[sound].path);106 }107 print('walk.js: Loaded audio files');108109 // create walk and fly animation blending buffers110 var flyBlend = loadFile(pathToAssets + "miscellaneous/animation-buffer.json", "FlyBlend");111 var walkBlend = loadFile(pathToAssets + "miscellaneous/animation-buffer.json", "WalkBlend");112 _character.animations["FlyBlend"] = flyBlend;113 _character.animations["WalkBlend"] = walkBlend;114 print('walk.js: Buffers created');115 116 // add a t-pose 117 _character.animations["T-Pose"] = loadAnimation(pathToAssets + "miscellaneous/t-pose.json");118119 if (avatar) {120 avatar.loadAnimations();121 }122 print('walk.js: '+_currentAnimationSet + ' animation set loaded');123 }124125 // initialise126 var _animationReference = loadFile(pathToAssets + "miscellaneous/animation-reference.json");127 var _preRotations = loadFile(pathToAssets + "miscellaneous/pre-rotations.json");128 loadAnimationSet();129130 return {131132 // expose the reference files133 animationReference: _animationReference,134 preRotations: _preRotations,135 136 // fetch animation data file by name137 getAnimation: function(animationName) {138 var animation = null;139 try {140 animation = _character.animations[animationName];141 } catch(e) {142 print('walk.js: Animation '+animationName+' not found');143 }144 return animation; 145 }, 146147 // fetch reach pose data file by name148 getReachPose: function(reachPoseName) {149 var reachPose = null;150 try {151 reachPose = _character.reachPoses[reachPoseName].animation;152 } catch(e) {153 print('walk.js: Reach pose '+reachPoseName+' not found');154 }155 return reachPose;156 }, 157158 // fetch transition parameters159 getTransitionParameters: function(lastAnimationName, nextAnimationName) {160 // defaults for when no parameters are defined for this character161 var transitionParameters = {162 duration: 0.5,163 easingLower: {x:0.5, y:0.0},164 easingUpper: {x:0.5, y:1.0}165 }166 try {167 if (_character.transitions[lastAnimationName]) {168 if (_character.transitions[lastAnimationName][nextAnimationName]) {169 transitionParameters = _character.transitions[lastAnimationName][nextAnimationName];170 }171 }172 } catch (e) {173 print('walk.js: Transition parameters for '+lastAnimationName+' to '+nextAnimationName+' not found - using default values');174 }175 return transitionParameters;176 }, 177178 // fetch reach pose parameters by name179 getReachPoseParameters: function(reachPoseName) {180 var reachPoseParameters = undefined;181 try {182 reachPoseParameters = _character.reachPoses[reachPoseName];183 } catch (e) {184 print('walk.js: Reach pose parameters for '+reachPoseName+' not found');185 }186 return reachPoseParameters;187 },188189 getSound: function(soundName) {190 return _character.sounds[soundName];191 },192193 // return array containing names of all animations and reach poses194 getAnimationNamesAsArray: function() {195 var allAnimations = [];196 for (animation in _character.animations) {197 if (_character.animations[animation].name !== "WalkBlend" &&198 _character.animations[animation].name !== "FlyBlend") { 199 allAnimations.push(_character.animations[animation].name);200 }201 }202 for (pose in _character.reachPoses) {203 allAnimations.push(_character.reachPoses[pose].animation.name);204 }205 return allAnimations;206 },207208 // animation set stuff209 getAnimationSets: function() {210 var animationSetNames = [];211 for (set in _animationSets) {212 animationSetNames.push(set);213 }214 return animationSetNames;215 },216217 setAnimationSet: function(animationSetName) {218 print('setting animation set to '+animationSetName);219 for (set in _animationSets) {220 if (set === animationSetName) {221 _currentAnimationSet = set;222 loadAnimationSet();223 print('walk.js: Loaded '+_currentAnimationSet+' animation set');224 }225 }226 },227228 getCurrentAnimationSet: function() {229 return _currentAnimationSet;230 },231232 createAnimationBuffer: function(bufferName) {233 var newBuffer = loadFile(pathToAssets + "miscellaneous/animation-buffer.json", bufferName);234 return newBuffer;235 },236 237 setPathToAssets: function(newPath) {238 pathToAssets = newPath;239 loadAnimationSet();240 }241 } ...

Full Screen

Full Screen

MorphBlendMesh.js

Source:MorphBlendMesh.js Github

copy

Full Screen

1/**2 * @author alteredq / http://alteredqualia.com/3 */45THREE.MorphBlendMesh = function( geometry, material ) {67 THREE.Mesh.call( this, geometry, material );89 this.animationsMap = {};10 this.animationsList = [];1112 // prepare default animation13 // (all frames played together in 1 second)1415 var numFrames = this.geometry.morphTargets.length;1617 var name = "__default";1819 var startFrame = 0;20 var endFrame = numFrames - 1;2122 var fps = numFrames / 1;2324 this.createAnimation( name, startFrame, endFrame, fps );25 this.setAnimationWeight( name, 1 );2627};2829THREE.MorphBlendMesh.prototype = Object.create( THREE.Mesh.prototype );30THREE.MorphBlendMesh.prototype.constructor = THREE.MorphBlendMesh;3132THREE.MorphBlendMesh.prototype.createAnimation = function ( name, start, end, fps ) {3334 var animation = {3536 startFrame: start,37 endFrame: end,3839 length: end - start + 1,4041 fps: fps,42 duration: ( end - start ) / fps,4344 lastFrame: 0,45 currentFrame: 0,4647 active: false,4849 time: 0,50 direction: 1,51 weight: 1,5253 directionBackwards: false,54 mirroredLoop: false5556 };5758 this.animationsMap[ name ] = animation;59 this.animationsList.push( animation );6061};6263THREE.MorphBlendMesh.prototype.autoCreateAnimations = function ( fps ) {6465 var pattern = /([a-z]+)_?(\d+)/;6667 var firstAnimation, frameRanges = {};6869 var geometry = this.geometry;7071 for ( var i = 0, il = geometry.morphTargets.length; i < il; i ++ ) {7273 var morph = geometry.morphTargets[ i ];74 var chunks = morph.name.match( pattern );7576 if ( chunks && chunks.length > 1 ) {7778 var name = chunks[ 1 ];7980 if ( ! frameRanges[ name ] ) frameRanges[ name ] = { start: Infinity, end: - Infinity };8182 var range = frameRanges[ name ];8384 if ( i < range.start ) range.start = i;85 if ( i > range.end ) range.end = i;8687 if ( ! firstAnimation ) firstAnimation = name;8889 }9091 }9293 for ( var name in frameRanges ) {9495 var range = frameRanges[ name ];96 this.createAnimation( name, range.start, range.end, fps );9798 }99100 this.firstAnimation = firstAnimation;101102};103104THREE.MorphBlendMesh.prototype.setAnimationDirectionForward = function ( name ) {105106 var animation = this.animationsMap[ name ];107108 if ( animation ) {109110 animation.direction = 1;111 animation.directionBackwards = false;112113 }114115};116117THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward = function ( name ) {118119 var animation = this.animationsMap[ name ];120121 if ( animation ) {122123 animation.direction = - 1;124 animation.directionBackwards = true;125126 }127128};129130THREE.MorphBlendMesh.prototype.setAnimationFPS = function ( name, fps ) {131132 var animation = this.animationsMap[ name ];133134 if ( animation ) {135136 animation.fps = fps;137 animation.duration = ( animation.end - animation.start ) / animation.fps;138139 }140141};142143THREE.MorphBlendMesh.prototype.setAnimationDuration = function ( name, duration ) {144145 var animation = this.animationsMap[ name ];146147 if ( animation ) {148149 animation.duration = duration;150 animation.fps = ( animation.end - animation.start ) / animation.duration;151152 }153154};155156THREE.MorphBlendMesh.prototype.setAnimationWeight = function ( name, weight ) {157158 var animation = this.animationsMap[ name ];159160 if ( animation ) {161162 animation.weight = weight;163164 }165166};167168THREE.MorphBlendMesh.prototype.setAnimationTime = function ( name, time ) {169170 var animation = this.animationsMap[ name ];171172 if ( animation ) {173174 animation.time = time;175176 }177178};179180THREE.MorphBlendMesh.prototype.getAnimationTime = function ( name ) {181182 var time = 0;183184 var animation = this.animationsMap[ name ];185186 if ( animation ) {187188 time = animation.time;189190 }191192 return time;193194};195196THREE.MorphBlendMesh.prototype.getAnimationDuration = function ( name ) {197198 var duration = - 1;199200 var animation = this.animationsMap[ name ];201202 if ( animation ) {203204 duration = animation.duration;205206 }207208 return duration;209210};211212THREE.MorphBlendMesh.prototype.playAnimation = function ( name ) {213214 var animation = this.animationsMap[ name ];215216 if ( animation ) {217218 animation.time = 0;219 animation.active = true;220221 } else {222223 THREE.warn( "THREE.MorphBlendMesh: animation[" + name + "] undefined in .playAnimation()" );224225 }226227};228229THREE.MorphBlendMesh.prototype.stopAnimation = function ( name ) {230231 var animation = this.animationsMap[ name ];232233 if ( animation ) {234235 animation.active = false;236237 }238239};240241THREE.MorphBlendMesh.prototype.update = function ( delta ) {242243 for ( var i = 0, il = this.animationsList.length; i < il; i ++ ) {244245 var animation = this.animationsList[ i ];246247 if ( ! animation.active ) continue;248249 var frameTime = animation.duration / animation.length;250251 animation.time += animation.direction * delta;252253 if ( animation.mirroredLoop ) {254255 if ( animation.time > animation.duration || animation.time < 0 ) {256257 animation.direction *= - 1;258259 if ( animation.time > animation.duration ) {260261 animation.time = animation.duration;262 animation.directionBackwards = true;263264 }265266 if ( animation.time < 0 ) {267268 animation.time = 0;269 animation.directionBackwards = false;270271 }272273 }274275 } else {276277 animation.time = animation.time % animation.duration;278279 if ( animation.time < 0 ) animation.time += animation.duration;280281 }282283 var keyframe = animation.startFrame + THREE.Math.clamp( Math.floor( animation.time / frameTime ), 0, animation.length - 1 );284 var weight = animation.weight;285286 if ( keyframe !== animation.currentFrame ) {287288 this.morphTargetInfluences[ animation.lastFrame ] = 0;289 this.morphTargetInfluences[ animation.currentFrame ] = 1 * weight;290291 this.morphTargetInfluences[ keyframe ] = 0;292293 animation.lastFrame = animation.currentFrame;294 animation.currentFrame = keyframe;295296 }297298 var mix = ( animation.time % frameTime ) / frameTime;299300 if ( animation.directionBackwards ) mix = 1 - mix;301302 this.morphTargetInfluences[ animation.currentFrame ] = mix * weight;303 this.morphTargetInfluences[ animation.lastFrame ] = ( 1 - mix ) * weight;304305 }306 ...

Full Screen

Full Screen

animateOptionSpec.js

Source:animateOptionSpec.js Github

copy

Full Screen

1describe('animate option', function () {2 /////////////////////////////3 // SETUP FOR EACH TEST4 /////////////////////////////5 var div, map, group;6 beforeEach(function () {7 div = document.createElement('div');8 div.style.width = '200px';9 div.style.height = '200px';10 document.body.appendChild(div);11 12 map = L.map(div, { maxZoom: 18, trackResize: false });13 14 // Corresponds to zoom level 8 for the above div dimensions.15 map.fitBounds(new L.LatLngBounds([16 [1, 1],17 [2, 2]18 ]));19 });20 afterEach(function () {21 if (group instanceof L.MarkerClusterGroup) {22 group.removeLayers(group.getLayers());23 map.removeLayer(group);24 }25 map.remove();26 div.remove();27 div = map = group = null;28 });29 /////////////////////////////30 // TESTS31 /////////////////////////////32 it('hooks animated methods version by default', function () {33 // Need to add to map so that we have the top cluster level created.34 group = L.markerClusterGroup().addTo(map);35 var withAnimation = L.MarkerClusterGroup.prototype._withAnimation;36 // MCG animated methods.37 expect(group._animationStart).to.be(withAnimation._animationStart);38 expect(group._animationZoomIn).to.be(withAnimation._animationZoomIn);39 expect(group._animationZoomOut).to.be(withAnimation._animationZoomOut);40 expect(group._animationAddLayer).to.be(withAnimation._animationAddLayer);41 // MarkerCluster spiderfy animated methods42 var cluster = group._topClusterLevel;43 withAnimation = L.MarkerCluster.prototype;44 expect(cluster._animationSpiderfy).to.be(withAnimation._animationSpiderfy);45 expect(cluster._animationUnspiderfy).to.be(withAnimation._animationUnspiderfy);46 });47 it('hooks non-animated methods version when set to false', function () {48 // Need to add to map so that we have the top cluster level created.49 group = L.markerClusterGroup({animate: false}).addTo(map);50 var noAnimation = L.MarkerClusterGroup.prototype._noAnimation;51 // MCG non-animated methods.52 expect(group._animationStart).to.be(noAnimation._animationStart);53 expect(group._animationZoomIn).to.be(noAnimation._animationZoomIn);54 expect(group._animationZoomOut).to.be(noAnimation._animationZoomOut);55 expect(group._animationAddLayer).to.be(noAnimation._animationAddLayer);56 // MarkerCluster spiderfy non-animated methods57 var cluster = group._topClusterLevel;58 noAnimation = L.MarkerClusterNonAnimated.prototype;59 expect(cluster._animationSpiderfy).to.be(noAnimation._animationSpiderfy);60 expect(cluster._animationUnspiderfy).to.be(noAnimation._animationUnspiderfy);61 });62 it('always hooks non-animated methods version when L.DomUtil.TRANSITION is false', function () {63 // Fool Leaflet, make it think the browser does not support transitions.64 var realDomUtil = L.DomUtil;65 var fakeDomUtil = {};66 for (k in realDomUtil) {67 fakeDomUtil[k] = realDomUtil[k];68 }69 fakeDomUtil.TRANSITION = false;70 L.DomUtil = fakeDomUtil;71 try {72 // Need to add to map so that we have the top cluster level created.73 group = L.markerClusterGroup({animate: true}).addTo(map);74 var noAnimation = L.MarkerClusterGroup.prototype._noAnimation;75 // MCG non-animated methods.76 expect(group._animationStart).to.be(noAnimation._animationStart);77 expect(group._animationZoomIn).to.be(noAnimation._animationZoomIn);78 expect(group._animationZoomOut).to.be(noAnimation._animationZoomOut);79 expect(group._animationAddLayer).to.be(noAnimation._animationAddLayer);80 // MarkerCluster spiderfy non-animated methods81 var cluster = group._topClusterLevel;82 noAnimation = L.MarkerClusterNonAnimated.prototype;83 expect(cluster._animationSpiderfy).to.be(noAnimation._animationSpiderfy);84 expect(cluster._animationUnspiderfy).to.be(noAnimation._animationUnspiderfy);85 } finally {86 //Undo the DomUtil replacement hack87 L.DomUtil = realDomUtil;88 }89 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const fs = require('fs');3const path = require('path');4const request = require('request');5const _ = require('lodash');6const wiki = wptools.page('Donald_Trump').getParse();7const wiki2 = wptools.page('Barack_Obama').getParse();8const wiki3 = wptools.page('George_W._Bush').getParse();9const wiki4 = wptools.page('Bill_Clinton').getParse();10const wiki5 = wptools.page('George_H._W._Bush').getParse();11const wiki6 = wptools.page('Ronald_Reagan').getParse();12const wiki7 = wptools.page('Jimmy_Carter').getParse();13const wiki8 = wptools.page('Gerald_Ford').getParse();14const wiki9 = wptools.page('Richard_Nixon').getParse();15const wiki10 = wptools.page('Lyndon_Johnson').getParse();16const wiki11 = wptools.page('John_F._Kennedy').getParse();17const wiki12 = wptools.page('Dwight_D._Eisenhower').getParse();18const wiki13 = wptools.page('Harry_S._Truman').getParse();19const wiki14 = wptools.page('Franklin_D._Roosevelt').getParse();20const wiki15 = wptools.page('Herbert_Hoover').getParse();21const wiki16 = wptools.page('Calvin_Coolidge').getParse();22const wiki17 = wptools.page('Warren_G._Harding').getParse();23const wiki18 = wptools.page('Woodrow_Wilson').getParse();24const wiki19 = wptools.page('William_Howard_Taft').getParse();25const wiki20 = wptools.page('Theodore_Roosevelt').getParse();26const wiki21 = wptools.page('William_McKinley').getParse();27const wiki22 = wptools.page('Grover_Cleveland').getParse();28const wiki23 = wptools.page('Benjamin_Harrison').getParse();29const wiki24 = wptools.page('Grover_Cleveland').getParse();30const wiki25 = wptools.page('William_McKinley').getParse();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wp = require('wptoolkit');2wp.animation('left');3var wp = require('wptoolkit');4wp.animation('left');5var wp = require('wptoolkit');6wp.animation('left');7var wp = require('wptoolkit');8wp.animation('left');9var wp = require('wptoolkit');10wp.animation('left');11var wp = require('wptoolkit');12wp.animation('left');13var wp = require('wptoolkit');14wp.animation('left');15var wp = require('wptoolkit');16wp.animation('left');17var wp = require('wptoolkit');18wp.animation('left');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wp = require('wptoolkit');2wp.init({3 'viewport': {4 }5});6wp.open();7wp.animate('test.js', function() {8 wp.screenshot('test.png');9 wp.close();10});11var wp = require('wptoolkit');12wp.init({13 'viewport': {14 }15});16wp.open();17wp.animate('test.js', function() {18 wp.screenshot('test.png');19 wp.close();20});21### wp.animateFile(filename, callback)22var wp = require('wptoolkit');23wp.init({24 'viewport': {25 }26});27wp.open();28wp.animateFile('test.js', function(error) {29 if (error) {30 throw error;31 }32 wp.screenshot('test.png');33 wp.close();34});35var wp = require('w

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful