@@ -193,12 +193,6 @@ let stepProfilerId = -1;
193193 */
194194let stepThreadsProfilerId = - 1 ;
195195
196- /**
197- * Numeric ID for RenderWebGL.draw in Profiler instances.
198- * @type {number }
199- */
200- let rendererDrawProfilerId = - 1 ;
201-
202196/**
203197 * Manages targets, scripts, and the sequencer.
204198 * @constructor
@@ -445,6 +439,14 @@ class Runtime extends EventEmitter {
445439 */
446440 this . platform = Object . assign ( { } , platform ) ;
447441
442+ /**
443+ * Screen refresh time speculated from screen refresh rate, in milliseconds.
444+ * Indicates time passed between two screen refreshments.
445+ * Based on site isolation status, the resolution could be ~0.1ms or lower.
446+ * @type {!number }
447+ */
448+ this . screenRefreshTime = 0 ;
449+
448450 this . _initScratchLink ( ) ;
449451
450452 this . resetRunId ( ) ;
@@ -471,7 +473,6 @@ class Runtime extends EventEmitter {
471473
472474 this . debug = false ;
473475
474- this . _lastStepTime = Date . now ( ) ;
475476 this . interpolationEnabled = false ;
476477
477478 this . _defaultStoredSettings = this . _generateAllProjectOptions ( ) ;
@@ -2495,8 +2496,8 @@ class Runtime extends EventEmitter {
24952496 }
24962497
24972498 _renderInterpolatedPositions ( ) {
2498- const frameStarted = this . _lastStepTime ;
2499- const now = Date . now ( ) ;
2499+ const frameStarted = this . frameLoop . _lastStepTime ;
2500+ const now = this . frameLoop . now ( ) ;
25002501 const timeSinceStart = now - frameStarted ;
25012502 const progressInFrame = Math . min ( 1 , Math . max ( 0 , timeSinceStart / this . currentStepTime ) ) ;
25022503
@@ -2567,24 +2568,6 @@ class Runtime extends EventEmitter {
25672568 // Store threads that completed this iteration for testing and other
25682569 // internal purposes.
25692570 this . _lastStepDoneThreads = doneThreads ;
2570- if ( this . renderer ) {
2571- // @todo : Only render when this.redrawRequested or clones rendered.
2572- if ( this . profiler !== null ) {
2573- if ( rendererDrawProfilerId === - 1 ) {
2574- rendererDrawProfilerId = this . profiler . idByName ( 'RenderWebGL.draw' ) ;
2575- }
2576- this . profiler . start ( rendererDrawProfilerId ) ;
2577- }
2578- // tw: do not draw if document is hidden or a rAF loop is running
2579- // Checking for the animation frame loop is more reliable than using
2580- // interpolationEnabled in some edge cases
2581- if ( ! document . hidden && ! this . frameLoop . _interpolationAnimation ) {
2582- this . renderer . draw ( ) ;
2583- }
2584- if ( this . profiler !== null ) {
2585- this . profiler . stop ( ) ;
2586- }
2587- }
25882571
25892572 if ( this . _refreshTargets ) {
25902573 this . emit ( Runtime . TARGETS_UPDATE , false /* Don't emit project changed */ ) ;
@@ -2600,10 +2583,6 @@ class Runtime extends EventEmitter {
26002583 this . profiler . stop ( ) ;
26012584 this . profiler . reportFrames ( ) ;
26022585 }
2603-
2604- if ( this . interpolationEnabled ) {
2605- this . _lastStepTime = Date . now ( ) ;
2606- }
26072586 }
26082587
26092588 /**
@@ -2662,9 +2641,6 @@ class Runtime extends EventEmitter {
26622641 * @param {number } framerate Target frames per second
26632642 */
26642643 setFramerate ( framerate ) {
2665- // Setting framerate to anything greater than this is unnecessary and can break the sequencer
2666- // Additionally, the JS spec says intervals can't run more than once every 4ms (250/s) anyways
2667- if ( framerate > 250 ) framerate = 250 ;
26682644 // Convert negative framerates to 1FPS
26692645 // Note that 0 is a special value which means "matching device screen refresh rate"
26702646 if ( framerate < 0 ) framerate = 1 ;
0 commit comments