diff --git a/docs/examples/en/misc/Timer.html b/docs/examples/en/misc/Timer.html new file mode 100644 index 00000000000000..2664d4936f71a8 --- /dev/null +++ b/docs/examples/en/misc/Timer.html @@ -0,0 +1,124 @@ + + +
+ ++ This class is an alternative to [page:Clock] with a different API design and behavior + The goal is to avoid the conceptual flaws that became apparent in [page:Clock] over time. + +
+ [name] is an add-on, and must be imported explicitly. + See [link:#manual/introduction/Installation Installation / Addons]. +
+ +
+ import { Timer } from 'three/addons/misc/Timer.js';
+
+
+
+ const timer = new Timer();
+
+ function animate() {
+
+ requestAnimationFrame( animate );
+
+ timer.update();
+
+ const delta = timer.getDelta();
+
+ // do something with delta
+
+ renderer.render( scene, camera );
+
+ }
+
+
+ + [example:webgl_morphtargets_sphere WebGL / morphtargets / sphere] +
+ ++ Disables the usage of a fixed delta time. +
+ ++ Can be used to free all internal resources. Usually called when the timer instance isn't required anymore. +
+ ++ Enables the usage of a fixed delta time. +
+ ++ Returns the time delta in seconds. +
+ ++ Returns the elapsed time in seconds. +
+ ++ Returns the fixed time delta that has been previously configured via [page:.setFixedDelta](). +
+ ++ Resets the time computation for the current simulation step. +
+ ++ Defines a fixed time delta value which is used to update the timer per simulation step. +
+ ++ Sets a time scale that scales the time delta in [page:.update](). +
+ ++ Updates the internal state of the timer. This method should be called once per simulation step + and before you perform queries against the timer (e.g. via [page:.getDelta]()). +
+ ++ [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/misc/Timer.js examples/jsm/misc/Timer.js] +
+ + diff --git a/docs/list.json b/docs/list.json index ea01871a0d303a..2794aa035841c9 100644 --- a/docs/list.json +++ b/docs/list.json @@ -400,6 +400,10 @@ "OBB": "examples/en/math/OBB" }, + "Misc": { + "Timer": "examples/en/misc/Timer" + }, + "ConvexHull": { "Face": "examples/en/math/convexhull/Face", "HalfEdge": "examples/en/math/convexhull/HalfEdge", diff --git a/examples/jsm/misc/Timer.js b/examples/jsm/misc/Timer.js index 92d13edc5c204a..32004a7b388573 100644 --- a/examples/jsm/misc/Timer.js +++ b/examples/jsm/misc/Timer.js @@ -1,12 +1,3 @@ -/** - * This class is a new alternative to THREE.Clock with a different API design and behavior. - * The goal is to avoid the conceptual flaws that became apparent in THREE.Clock over time. - * - * - THREE.Timer has an update() method that updates its internal state. That makes it possible to call .getDeltaTime() and - * .getElapsedTime() multiple times per simulation step without getting different values. - * - The class uses the Page Visibility API to avoid large time delta values when the app is inactive (e.g. tab switched or browser hidden). - * - It's possible to configure a fixed time delta and a time scale value (similar to Unity's Time interface). - */ class Timer { constructor() {