@tweenjs/tween.js 17.3.5 → 17.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +6 -0
- package/package-lock.json +11765 -0
- package/package.json +1 -1
- package/src/Tween.js +13 -1
- package/benchmarks/additionWithStart.js +0 -9
- package/benchmarks/additionWithUpdate.js +0 -11
- package/benchmarks/additionWithoutStart.js +0 -8
- package/benchmarks/benchmarks.html +0 -55
- package/benchmarks/updateBug.html +0 -37
- package/benchmarks/updateMany.js +0 -13
- package/src/TweenThree.js +0 -24
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tweenjs/tween.js",
|
|
3
3
|
"description": "Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.",
|
|
4
|
-
"version": "17.
|
|
4
|
+
"version": "17.4.0",
|
|
5
5
|
"main": "src/Tween.js",
|
|
6
6
|
"homepage": "https://github.com/tweenjs/tween.js",
|
|
7
7
|
"repository": {
|
package/src/Tween.js
CHANGED
|
@@ -138,6 +138,7 @@ TWEEN.Tween = function (object, group) {
|
|
|
138
138
|
this._onStartCallback = null;
|
|
139
139
|
this._onStartCallbackFired = false;
|
|
140
140
|
this._onUpdateCallback = null;
|
|
141
|
+
this._onRepeatCallback = null;
|
|
141
142
|
this._onCompleteCallback = null;
|
|
142
143
|
this._onStopCallback = null;
|
|
143
144
|
this._group = group || TWEEN;
|
|
@@ -318,6 +319,13 @@ TWEEN.Tween.prototype = {
|
|
|
318
319
|
|
|
319
320
|
},
|
|
320
321
|
|
|
322
|
+
onRepeat: function onRepeat(callback) {
|
|
323
|
+
|
|
324
|
+
this._onRepeatCallback = callback;
|
|
325
|
+
return this;
|
|
326
|
+
|
|
327
|
+
},
|
|
328
|
+
|
|
321
329
|
onComplete: function (callback) {
|
|
322
330
|
|
|
323
331
|
this._onCompleteCallback = callback;
|
|
@@ -392,7 +400,7 @@ TWEEN.Tween.prototype = {
|
|
|
392
400
|
}
|
|
393
401
|
|
|
394
402
|
if (this._onUpdateCallback !== null) {
|
|
395
|
-
this._onUpdateCallback(this._object);
|
|
403
|
+
this._onUpdateCallback(this._object, elapsed);
|
|
396
404
|
}
|
|
397
405
|
|
|
398
406
|
if (elapsed === 1) {
|
|
@@ -431,6 +439,10 @@ TWEEN.Tween.prototype = {
|
|
|
431
439
|
this._startTime = time + this._delayTime;
|
|
432
440
|
}
|
|
433
441
|
|
|
442
|
+
if (this._onRepeatCallback !== null) {
|
|
443
|
+
this._onRepeatCallback(this._object);
|
|
444
|
+
}
|
|
445
|
+
|
|
434
446
|
return true;
|
|
435
447
|
|
|
436
448
|
} else {
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<title>Tween.js / hello world!</title>
|
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
6
|
-
<link href="css/style.css" media="screen" rel="stylesheet" type="text/css" />
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="info">
|
|
10
|
-
<h1><a href="http://github.com/tweenjs/tween.js">tween.js</a></h1>
|
|
11
|
-
<h2>00 _ hello world</h2>
|
|
12
|
-
<p>Simple example for illustrating the creation and chaining of tweens.</p>
|
|
13
|
-
</div>
|
|
14
|
-
<div id="target" style="position:absolute; top: 100px; left: 100px; width: 100px; height: 100px; background: #a0dde9; padding: 1em;">
|
|
15
|
-
hello world!
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<script src="../src/Tween.js"></script>
|
|
19
|
-
<script src="js/RequestAnimationFrame.js"></script>
|
|
20
|
-
|
|
21
|
-
<script src="additionWithStart.js"></script>
|
|
22
|
-
<script src="additionWithoutStart.js"></script>
|
|
23
|
-
<script src="additionWithUpdate.js"></script>
|
|
24
|
-
<script src="updateMany.js"></script>
|
|
25
|
-
|
|
26
|
-
<script>
|
|
27
|
-
|
|
28
|
-
function timeFunction(func) {
|
|
29
|
-
var startTime = new Date().getTime();
|
|
30
|
-
func();
|
|
31
|
-
var endTime = new Date().getTime();
|
|
32
|
-
|
|
33
|
-
return (endTime - startTime) / 1000.0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var additionWithStartTime = timeFunction(additionWithStart);
|
|
37
|
-
TWEEN.removeAll();
|
|
38
|
-
console.log("Addition with start(): " + additionWithStartTime);
|
|
39
|
-
|
|
40
|
-
var additionWithoutStartTime = timeFunction(additionWithoutStart);
|
|
41
|
-
TWEEN.removeAll();
|
|
42
|
-
console.log("Addition without start(): " + additionWithoutStartTime);
|
|
43
|
-
|
|
44
|
-
var additionWithUpdateTime = timeFunction(additionWithUpdate);
|
|
45
|
-
TWEEN.removeAll();
|
|
46
|
-
console.log("Addition with TWEEN.update(): " + additionWithUpdateTime);
|
|
47
|
-
|
|
48
|
-
updateManySetup();
|
|
49
|
-
var updateManyTime = timeFunction(updateMany);
|
|
50
|
-
TWEEN.removeAll();
|
|
51
|
-
console.log("Update many tweens: " + updateManyTime);
|
|
52
|
-
|
|
53
|
-
</script>
|
|
54
|
-
</body>
|
|
55
|
-
</html>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<title>update bug</title>
|
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
|
|
9
|
-
<script src="../src/Tween.js"></script>
|
|
10
|
-
|
|
11
|
-
<script>
|
|
12
|
-
|
|
13
|
-
var numAdditions = 1E5;
|
|
14
|
-
|
|
15
|
-
for (var i = 0; i < numAdditions; ++i) {
|
|
16
|
-
var currentTween = new TWEEN.Tween({a: 0.0});
|
|
17
|
-
currentTween.to({a: 1.0}, 1.0);
|
|
18
|
-
currentTween.start(0.0);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
TWEEN.update(0.5);
|
|
22
|
-
|
|
23
|
-
console.log("A");
|
|
24
|
-
|
|
25
|
-
for (var i = 0; i < numAdditions; ++i) {
|
|
26
|
-
var currentTween = new TWEEN.Tween({a: 0.0});
|
|
27
|
-
currentTween.to({a: 1.0}, 1.0);
|
|
28
|
-
currentTween.start(0.0);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
TWEEN.update(0.5);
|
|
32
|
-
|
|
33
|
-
console.log("B");
|
|
34
|
-
|
|
35
|
-
</script>
|
|
36
|
-
</body>
|
|
37
|
-
</html>
|
package/benchmarks/updateMany.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
function updateManySetup() {
|
|
2
|
-
var numAdditions = 1e4;
|
|
3
|
-
|
|
4
|
-
for (var i = 0; i < numAdditions; ++i) {
|
|
5
|
-
var currentTween = new TWEEN.Tween({a: 0.0});
|
|
6
|
-
currentTween.to({a: 1.0}, 1.0);
|
|
7
|
-
currentTween.start(0.0);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function updateMany() {
|
|
12
|
-
TWEEN.update(0.5);
|
|
13
|
-
}
|
package/src/TweenThree.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
TWEEN.THREE = {};
|
|
2
|
-
|
|
3
|
-
TWEEN.THREE.DirectRotation = function(object3d) {
|
|
4
|
-
this._object3d = object3d;
|
|
5
|
-
|
|
6
|
-
this._originalRotation = object3d.
|
|
7
|
-
|
|
8
|
-
this._object = {progress: 0};
|
|
9
|
-
this._object.position;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
TWEEN.THREE.DirectRotation.prototype = new TWEEN.Tween();
|
|
13
|
-
|
|
14
|
-
TWEEN.THREE.DirectRotation.prototype._onUpdateCallback = function(object) {
|
|
15
|
-
this._object3d // TODO
|
|
16
|
-
|
|
17
|
-
this._other_onUpdateCallback(object);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
TWEEN.THREE.DirectRotation.prototype.onUpdate = function(onUpdateCallback) {
|
|
21
|
-
this._other_onUpdateCallback = onUpdateCallback;
|
|
22
|
-
|
|
23
|
-
return this;
|
|
24
|
-
};
|