Skip to content

Commit

Permalink
Adds "proper" support for node.js
Browse files Browse the repository at this point in the history
Merge branch 'nodejs-support-squashed' into dev

Conflicts:
	src/Tween.js
  • Loading branch information
sole committed Jun 3, 2013
2 parents 18388db + db5cd9c commit b52334d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
nodejs/index.js
nodejs/README.md
9 changes: 5 additions & 4 deletions build/tween.min.js

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

22 changes: 22 additions & 0 deletions nodejs/package.json
@@ -0,0 +1,22 @@
{
"name": "tween",
"description": "Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.",
"version": "0.10.0",
"homepage": "https://github.com/sole/tween.js",
"repository": {
"type": "git",
"url": "git://github.com/sole/tween.js.git"
},
"bugs": {
"url": "https://github.com/sole/tween.js/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/sole/tween.js/blob/master/LICENSE"
}
],
"keywords": [
"tween"
]
}
7 changes: 3 additions & 4 deletions src/Tween.js
Expand Up @@ -22,7 +22,6 @@ if ( Date.now === undefined ) {

}


var TWEEN = TWEEN || ( function () {

var _tweens = [];
Expand Down Expand Up @@ -67,7 +66,7 @@ var TWEEN = TWEEN || ( function () {

var i = 0, numTweens = _tweens.length;

time = time !== undefined ? time : ( window.performance !== undefined && window.performance.now !== undefined ? window.performance.now() : Date.now() );
time = time !== undefined ? time : ( typeof window !== 'undefined' && window.performance !== undefined && window.performance.now !== undefined ? window.performance.now() : Date.now() );

while ( i < numTweens ) {

Expand Down Expand Up @@ -137,7 +136,7 @@ TWEEN.Tween = function ( object ) {

_onStartCallbackFired = false;

_startTime = time !== undefined ? time : (window.performance !== undefined && window.performance.now !== undefined ? window.performance.now() : Date.now() );
_startTime = time !== undefined ? time : ( typeof window !== 'undefined' && window.performance !== undefined && window.performance.now !== undefined ? window.performance.now() : Date.now() );
_startTime += _delayTime;

for ( var property in _valuesEnd ) {
Expand Down Expand Up @@ -334,6 +333,7 @@ TWEEN.Tween = function ( object ) {

};


TWEEN.Easing = {

Linear: {
Expand Down Expand Up @@ -699,4 +699,3 @@ TWEEN.Interpolation = {
}

};

10 changes: 10 additions & 0 deletions utils/builder.py
@@ -1,11 +1,21 @@
import os
import shutil

source = '../src/Tween.js'
output = '../build/tween.min.js'
nodeOutput = '../nodejs/index.js'
readme = '../README.md'
nodeReadme = '../nodejs/README.md'

os.system( 'java -jar compiler/compiler.jar --language_in=ECMASCRIPT5_STRICT --js ' + source + ' --js_output_file ' + output )

# header

with open(output,'r') as f: text = f.read()
with open(output,'w') as f: f.write('// tween.js - http://github.com/sole/tween.js\n' + text)

shutil.copyfile(source, nodeOutput)
shutil.copyfile(readme, nodeReadme)

with open(nodeOutput,'r') as f: text = f.read()
with open(nodeOutput,'w') as f: f.write('// tween.js - http://github.com/sole/tween.js\n' + text + '\nmodule.exports=TWEEN;')

0 comments on commit b52334d

Please sign in to comment.