提交 71ddb808 编写于 作者: M Mr.doob

Removed requestAnimationFrame and performance shims. See #7787.

上级 f5efb5e4
......@@ -16,80 +16,6 @@ if ( typeof define === 'function' && define.amd ) {
}
// polyfills
if ( self.requestAnimationFrame === undefined || self.cancelAnimationFrame === undefined ) {
// Missing in Android stock browser.
( function () {
var lastTime = 0;
var vendors = [ 'ms', 'moz', 'webkit', 'o' ];
for ( var x = 0; x < vendors.length && ! self.requestAnimationFrame; ++ x ) {
self.requestAnimationFrame = self[ vendors[ x ] + 'RequestAnimationFrame' ];
self.cancelAnimationFrame = self[ vendors[ x ] + 'CancelAnimationFrame' ] || self[ vendors[ x ] + 'CancelRequestAnimationFrame' ];
}
if ( self.requestAnimationFrame === undefined && self.setTimeout !== undefined ) {
self.requestAnimationFrame = function ( callback ) {
var currTime = Date.now(), timeToCall = Math.max( 0, 16 - ( currTime - lastTime ) );
var id = self.setTimeout( function () {
callback( currTime + timeToCall );
}, timeToCall );
lastTime = currTime + timeToCall;
return id;
};
}
if ( self.cancelAnimationFrame === undefined && self.clearTimeout !== undefined ) {
self.cancelAnimationFrame = function ( id ) {
self.clearTimeout( id );
};
}
} )();
}
//
if ( self.performance === undefined ) {
self.performance = {};
}
if ( self.performance.now === undefined ) {
( function () {
var start = Date.now();
self.performance.now = function () {
return Date.now() - start;
}
} )();
}
//
if ( Number.EPSILON === undefined ) {
......
......@@ -20,7 +20,7 @@ THREE.Clock.prototype = {
start: function () {
this.startTime = self.performance.now();
this.startTime = performance.now();
this.oldTime = this.startTime;
this.running = true;
......@@ -53,7 +53,7 @@ THREE.Clock.prototype = {
if ( this.running ) {
var newTime = self.performance.now();
var newTime = performance.now();
diff = 0.001 * ( newTime - this.oldTime );
this.oldTime = newTime;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册