Skip to content

Commit

Permalink
r6
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Apr 10, 2012
1 parent ebc06ee commit 01f9dc7
Show file tree
Hide file tree
Showing 18 changed files with 566 additions and 75 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2010 sole http://soledadpenades.com, Mr.doob http://mrdoob.com
Copyright (c) 2010-2012 Tween.js authors.

Easing equations Copyright (c) 2001 Robert Penner http://robertpenner.com/easing/

Expand Down
42 changes: 23 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
tween.js
========

### Javascript Tweening Engine ###
#### Javascript Tweening Engine ####

[![Flattr this](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/thing/45014/tween-js)

Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.

We are still developing this so the API might change from commit to commit.
[Contributors](http://github.com/sole/tween.js/contributors)

## Examples ##
### Examples ###

[![Tween autostart](http://sole.github.com/tween.js/assets/examples/07_autostart.png)](http://sole.github.com/tween.js/examples/07_autostart.html)
[![Video and time](http://sole.github.com/tween.js/assets/examples/06_video_and_time.png)](http://sole.github.com/tween.js/examples/06_video_and_time.html)
Expand All @@ -20,7 +20,7 @@ We are still developing this so the API might change from commit to commit.
[![Bars](http://sole.github.com/tween.js/assets/examples/01_bars.png)](http://sole.github.com/tween.js/examples/01_bars.html)
[![hello world](http://sole.github.com/tween.js/assets/examples/00_hello_world.png)](http://sole.github.com/tween.js/examples/00_hello_world.html)

## Projects using tween.js ##
### Projects using tween.js ###

[![Minesweeper 3D](http://sole.github.com/tween.js/assets/projects/06_minesweeper3d.png)](http://egraether.com/mine3d/)
[![ROME](http://sole.github.com/tween.js/assets/projects/05_rome.png)](http://ro.me)
Expand All @@ -30,7 +30,7 @@ We are still developing this so the API might change from commit to commit.
[![The Wilderness Downtown](http://sole.github.com/tween.js/assets/projects/01_wilderness.png)](http://thewildernessdowntown.com/)
[![Linechart](http://sole.github.com/tween.js/assets/projects/00_linechart.png)](http://dejavis.org/linechart)

## Usage ##
### Usage ###

Download the [minified library](http://github.com/sole/tween.js/raw/master/build/Tween.js) and include it in your html.

Expand Down Expand Up @@ -70,24 +70,31 @@ Have a look at that folder to discover more functionalities of the library!

Also, Jerome Etienne has written a [tutorial](http://learningthreejs.com/blog/2011/08/17/tweenjs-for-smooth-animation/) demonstrating how to use tween.js with three.js, and it's also great for understanding how tweens work!

## Frequently Asked Questions (FAQ) ##
### FAQ ###

**Is there a way to control when is update() called? I'd like to use my own interval.**

Yes, simply don't call `TWEEN.start()`, and run `TWEEN.update()` in your own periodically executing function instead.

**How do you set a tween to start after a while?**

Use the `delay()` method: `var t = new Tween({...}).delay(1000);`
Use the `delay()` method: `var t = new TWEEN.Tween({...}).delay(1000);`

**Is there a jQuery plug-in?**

No, we like to keep it simple and free of dependencies. Feel free to make one yourself, though! :-)


## Change log ##
### Change log ###

2012 04 10 - **r6** (4,707 KB, gzip: 1,630 KB)

* Returning instance also in `.chain()`. ([mrdoob](http://github.com/mrdoob))
* Refactoring and code clean up. ([egraether](http://github.com/egraether))
* Simplified easing formulas. ([infusion](http://github.com/infusion))
* Added support to arrays in `.to()` using linear, catmull-rom or bezier `.interpolation()`. ([egraether](http://github.com/egraether))
* Removed autostart/stop. ([mrdoob](http://github.com/mrdoob))
* Renamed `EaseNone`, `EaseIn`, `EaseOut` ane `EaseInOut`, to `None`, `In`, `Out` and `InOut`. ([mrdoob](http://github.com/mrdoob))
* Made `.to()` values dynamic. ([egraether](http://github.com/egraether) and [jeromeetienne](http://github.com/jeromeetienne))

2011 10 15 - **r5**

2011 10 15 - **r5** (4,733 KB, gzip: 1,379 KB)

* Add autostart/stop functionalities ([jocafa](http://github.com/jocafa) and [sole](http://github.com/sole))
* Add 07_autostart example demonstrating the new functionalities ([sole](http://github.com/sole))
Expand All @@ -97,22 +104,19 @@ No, we like to keep it simple and free of dependencies. Feel free to make one yo

* Use ``Date.now()`` instead of ``new Date.getTime()`` as it's faster ([mrdoob](http://github.com/mrdoob))


2011 09 30 - **r3**

* Added new ``time`` parameter to TWEEN.update, in order to allow synchronizing the tweens to an external timeline ([lechecacharro](http://github.com/lechecacharro))
* Added example to demonstrate the new synchronizing feature. ([sole](http://github.com/sole))


2011 06 18 - **r2**

* Added new utility methods getAll and removeAll for getting and removing all tweens ([Paul Lewis](http://github.com/paullewis))


2011 05 18 - **r1**

* Started using revision numbers in the build file
* Consider this kind of an stable revision :-)

## Contributors ##

People who have contributed directly or indirectly to this project :-D

[sole](http://soledadpenades.com), [mrdoob](http://mrdoob.com), [Robert Eisele](http://www.xarg.org/), [Robert Penner](http://www.robertpenner.com/), [Philippe Elsass](http://philippe.elsass.me), [Paul Lewis](http://www.aerotwist.com/), Lechecacharro
1 change: 0 additions & 1 deletion REVISION

This file was deleted.

25 changes: 12 additions & 13 deletions build/Tween.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/00_hello_world.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2>00 _ hello world</h2>
hello world!
</div>

<script src="../src/Tween.js"></script>
<script src="../build/Tween.js"></script>
<script src="js/RequestAnimationFrame.js"></script>
<script>
var position;
Expand Down
2 changes: 1 addition & 1 deletion examples/01_bars.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h2>01 _ Bars</h2>
</div>
<div id="target"></div>

<script src="../src/Tween.js"></script>
<script src="../build/Tween.js"></script>
<script src="js/RequestAnimationFrame.js"></script>
<script src="js/Stats.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion examples/02_black_and_red.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2>02 _ Black and red</h2>
#target { position: absolute; top: 4em; right: 3em; }
</style>

<script src="../src/Tween.js"></script>
<script src="../build/Tween.js"></script>
<script src="js/RequestAnimationFrame.js"></script>
<script src="js/Stats.js"></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion examples/03_graphs.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h2>03 _ graphs</h2>

<div id="target"></div>

<script src="../src/Tween.js"></script>
<script src="../build/Tween.js"></script>
<script src="js/RequestAnimationFrame.js"></script>
<script>

Expand Down
2 changes: 1 addition & 1 deletion examples/04_simplest.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2>04 _ simplest possible example</h2>
<div id="target" style="position: absolute; left: 50px; top: 300px; font-size: 100px; letter-spacing: -7px; ">
</div>

<script src="../src/Tween.js"></script>
<script src="../build/Tween.js"></script>
<script src="js/RequestAnimationFrame.js"></script>
<script>

Expand Down
2 changes: 1 addition & 1 deletion examples/05_video_and_time.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h2>05 _ video and time</h2>
<video id="video" src="video/sintel.webm" width="320" height="138" autoplay></video>
</div>

<script src="../src/Tween.js"></script>
<script src="../build/Tween.js"></script>
<script src="js/RequestAnimationFrame.js"></script>
<script>

Expand Down
2 changes: 1 addition & 1 deletion examples/06_array_interpolation.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h2>06 _ array interpolation</h2>

<div id="target"></div>

<script src="../src/Tween.js"></script>
<script src="../build/Tween.js"></script>
<script src="js/RequestAnimationFrame.js"></script>
<script>

Expand Down
2 changes: 1 addition & 1 deletion examples/07_dynamic_to.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h2>06 _ dynamic to</h2>

<div id="target"></div>

<script src="../src/Tween.js"></script>
<script src="../build/Tween.js"></script>
<script src="js/RequestAnimationFrame.js"></script>
<script>

Expand Down
36 changes: 18 additions & 18 deletions src/Tween.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ var TWEEN = TWEEN || ( function () {

return {

REVISION: '6',

getAll: function () {

return _tweens;
Expand Down Expand Up @@ -75,17 +77,17 @@ var TWEEN = TWEEN || ( function () {

TWEEN.Tween = function ( object ) {

var _object = object,
_valuesStart = {},
_valuesEnd = {},
_duration = 1000,
_delayTime = 0,
_startTime = null,
_easingFunction = TWEEN.Easing.Linear.None,
_interpolationFunction = TWEEN.Interpolation.Linear,
_chainedTween = null,
_onUpdateCallback = null,
_onCompleteCallback = null;
var _object = object;
var _valuesStart = {};
var _valuesEnd = {};
var _duration = 1000;
var _delayTime = 0;
var _startTime = null;
var _easingFunction = TWEEN.Easing.Linear.None;
var _interpolationFunction = TWEEN.Interpolation.Linear;
var _chainedTween = null;
var _onUpdateCallback = null;
var _onCompleteCallback = null;

this.to = function ( properties, duration ) {

Expand Down Expand Up @@ -190,23 +192,21 @@ TWEEN.Tween = function ( object ) {

this.update = function ( time ) {

var property, elapsed, value, start, end;

if ( time < _startTime ) {

return true;

}

elapsed = ( time - _startTime ) / _duration;
var elapsed = ( time - _startTime ) / _duration;
elapsed = elapsed > 1 ? 1 : elapsed;

value = _easingFunction( elapsed );
var value = _easingFunction( elapsed );

for ( property in _valuesStart ) {
for ( var property in _valuesStart ) {

start = _valuesStart[ property ];
end = _valuesEnd[ property ];
var start = _valuesStart[ property ];
var end = _valuesEnd[ property ];

if ( end instanceof Array ) {

Expand Down
25 changes: 10 additions & 15 deletions utils/builder.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import sys
import os

output = '../build/Tween.js';
source = '../src/Tween.js'
build = '../build/Tween.js'
header = '// Tween.js - http://github.com/sole/tween.js\n'

os.system("java -jar compiler.jar --js ../src/Tween.js --js_output_file %s" % (output))
os.system( 'java -jar compiler/compiler.jar --language_in=ECMASCRIPT5 --js ' + source + ' --js_output_file ' + build )

# HEADER
file = open( build, 'r' )
contents = file.read();
file.close()

with open(os.path.join('..', 'REVISION'), 'r') as handle:
revision = handle.read().rstrip()

string = "// tween.js r%s - http://github.com/sole/tween.js\n" % (revision)

src_file = open(output,'r')
string += src_file.read()

dep_file = open(output,'w')
dep_file.write(string)
dep_file.close()
file = open( build, 'w' )
file.write( header + contents )
file.close()
Binary file removed utils/compiler.jar
Binary file not shown.
Loading

0 comments on commit 01f9dc7

Please sign in to comment.