[+] Time tracker
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as THREE from 'three'
|
||||
import * as helper from "@/animation/Helpers";
|
||||
import {initMouseTracker, moused} from "@/animation/Trackers";
|
||||
import {initMouseTracker, moused, timed, updateTimeTracker} from "@/animation/Trackers";
|
||||
import {circle} from "@/animation/Helpers";
|
||||
|
||||
let renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.PerspectiveCamera
|
||||
@@ -96,6 +96,7 @@ function onWindowResize()
|
||||
function animate(): void
|
||||
{
|
||||
requestAnimationFrame(animate)
|
||||
updateTimeTracker()
|
||||
update()
|
||||
renderer.render(scene, camera)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// import * as THREE from 'three'
|
||||
|
||||
export let mouse: MouseEvent
|
||||
export const moused: {x: number, y: number} = {x: 0, y: 0}
|
||||
export const moused = {x: 0, y: 0}
|
||||
export const timed = {dt: 0, dts: 0, elapsed: 0, start: Date.now(), last: Date.now(),
|
||||
update: updateTimeTracker}
|
||||
|
||||
/**
|
||||
* Initialize mouse tracker
|
||||
@@ -15,3 +17,12 @@ export function initMouseTracker(): void
|
||||
moused.y = -(e.clientY / window.innerHeight * 2 - 1)
|
||||
}
|
||||
}
|
||||
|
||||
export function updateTimeTracker(): void
|
||||
{
|
||||
const now = Date.now()
|
||||
timed.elapsed = timed.start - now
|
||||
timed.dt = timed.last - now
|
||||
timed.dts = timed.dt / 1000.0
|
||||
timed.last = now
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user