forked from mrdoob/stats.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom.html
65 lines (47 loc) · 1.36 KB
/
custom.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
<title>stats.js - custom panel example</title>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
margin: 0px;
overflow: hidden;
}
</style>
</head>
<body>
<script src="../build/stats.min.js"></script>
<script>
var stats = new Stats();
var xPanel = stats.addPanel( new Stats.Panel( 'x', '#ff8', '#221' ) );
var yPanel = stats.addPanel( new Stats.Panel( 'y', '#f8f', '#212' ) );
stats.showPanel( 3 );
document.body.appendChild( stats.dom );
var canvas = document.createElement( 'canvas' );
canvas.width = 512;
canvas.height = 512;
document.body.appendChild( canvas );
var context = canvas.getContext( '2d' );
context.fillStyle = 'rgba(127,0,255,0.05)';
var test = [];
function animate() {
var time = performance.now() / 1000;
context.clearRect( 0, 0, 512, 512 );
stats.begin();
for ( var i = 0; i < 2000; i ++ ) {
var x = Math.cos( time + i * 0.01 ) * 196 + 256;
var y = Math.sin( time + i * 0.01234 ) * 196 + 256;
context.beginPath();
context.arc( x, y, 10, 0, Math.PI * 2, true );
context.fill();
}
stats.end();
xPanel.update( x, 460 );
yPanel.update( y, 460 );
requestAnimationFrame( animate );
}
animate();
</script>
</body>
</html>