Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yma16
threejs
提交
6ab6aa77
T
threejs
项目概览
yma16
/
threejs
通知
7
Star
5
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
T
threejs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6ab6aa77
编写于
10月 12, 2020
作者:
yma16
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
上传新文件
上级
985bc197
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
179 addition
and
0 deletion
+179
-0
loadmodel_views/js/stats.js
loadmodel_views/js/stats.js
+179
-0
未找到文件。
loadmodel_views/js/stats.js
0 → 100644
浏览文件 @
6ab6aa77
(
function
(
global
,
factory
)
{
typeof
exports
===
'
object
'
&&
typeof
module
!==
'
undefined
'
?
module
.
exports
=
factory
()
:
typeof
define
===
'
function
'
&&
define
.
amd
?
define
(
factory
)
:
(
global
.
Stats
=
factory
());
}(
this
,
(
function
()
{
'
use strict
'
;
/**
* @author mrdoob / http://mrdoob.com/
*/
var
Stats
=
function
()
{
var
mode
=
0
;
var
container
=
document
.
createElement
(
'
div
'
);
container
.
style
.
cssText
=
'
position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000
'
;
container
.
addEventListener
(
'
click
'
,
function
(
event
)
{
event
.
preventDefault
();
showPanel
(
++
mode
%
container
.
children
.
length
);
},
false
);
//
function
addPanel
(
panel
)
{
container
.
appendChild
(
panel
.
dom
);
return
panel
;
}
function
showPanel
(
id
)
{
for
(
var
i
=
0
;
i
<
container
.
children
.
length
;
i
++
)
{
container
.
children
[
i
].
style
.
display
=
i
===
id
?
'
block
'
:
'
none
'
;
}
mode
=
id
;
}
//
var
beginTime
=
(
performance
||
Date
).
now
(),
prevTime
=
beginTime
,
frames
=
0
;
var
fpsPanel
=
addPanel
(
new
Stats
.
Panel
(
'
FPS
'
,
'
#0ff
'
,
'
#002
'
)
);
var
msPanel
=
addPanel
(
new
Stats
.
Panel
(
'
MS
'
,
'
#0f0
'
,
'
#020
'
)
);
if
(
self
.
performance
&&
self
.
performance
.
memory
)
{
var
memPanel
=
addPanel
(
new
Stats
.
Panel
(
'
MB
'
,
'
#f08
'
,
'
#201
'
)
);
}
showPanel
(
0
);
return
{
REVISION
:
16
,
dom
:
container
,
addPanel
:
addPanel
,
showPanel
:
showPanel
,
begin
:
function
()
{
beginTime
=
(
performance
||
Date
).
now
();
},
end
:
function
()
{
frames
++
;
var
time
=
(
performance
||
Date
).
now
();
msPanel
.
update
(
time
-
beginTime
,
200
);
if
(
time
>
prevTime
+
1000
)
{
fpsPanel
.
update
(
(
frames
*
1000
)
/
(
time
-
prevTime
),
100
);
prevTime
=
time
;
frames
=
0
;
if
(
memPanel
)
{
var
memory
=
performance
.
memory
;
memPanel
.
update
(
memory
.
usedJSHeapSize
/
1048576
,
memory
.
jsHeapSizeLimit
/
1048576
);
}
}
return
time
;
},
update
:
function
()
{
beginTime
=
this
.
end
();
},
// Backwards Compatibility
domElement
:
container
,
setMode
:
showPanel
};
};
Stats
.
Panel
=
function
(
name
,
fg
,
bg
)
{
var
min
=
Infinity
,
max
=
0
,
round
=
Math
.
round
;
var
PR
=
round
(
window
.
devicePixelRatio
||
1
);
var
WIDTH
=
80
*
PR
,
HEIGHT
=
48
*
PR
,
TEXT_X
=
3
*
PR
,
TEXT_Y
=
2
*
PR
,
GRAPH_X
=
3
*
PR
,
GRAPH_Y
=
15
*
PR
,
GRAPH_WIDTH
=
74
*
PR
,
GRAPH_HEIGHT
=
30
*
PR
;
var
canvas
=
document
.
createElement
(
'
canvas
'
);
canvas
.
width
=
WIDTH
;
canvas
.
height
=
HEIGHT
;
canvas
.
style
.
cssText
=
'
width:80px;height:48px
'
;
var
context
=
canvas
.
getContext
(
'
2d
'
);
context
.
font
=
'
bold
'
+
(
9
*
PR
)
+
'
px Helvetica,Arial,sans-serif
'
;
context
.
textBaseline
=
'
top
'
;
context
.
fillStyle
=
bg
;
context
.
fillRect
(
0
,
0
,
WIDTH
,
HEIGHT
);
context
.
fillStyle
=
fg
;
context
.
fillText
(
name
,
TEXT_X
,
TEXT_Y
);
context
.
fillRect
(
GRAPH_X
,
GRAPH_Y
,
GRAPH_WIDTH
,
GRAPH_HEIGHT
);
context
.
fillStyle
=
bg
;
context
.
globalAlpha
=
0.9
;
context
.
fillRect
(
GRAPH_X
,
GRAPH_Y
,
GRAPH_WIDTH
,
GRAPH_HEIGHT
);
return
{
dom
:
canvas
,
update
:
function
(
value
,
maxValue
)
{
min
=
Math
.
min
(
min
,
value
);
max
=
Math
.
max
(
max
,
value
);
context
.
fillStyle
=
bg
;
context
.
globalAlpha
=
1
;
context
.
fillRect
(
0
,
0
,
WIDTH
,
GRAPH_Y
);
context
.
fillStyle
=
fg
;
context
.
fillText
(
round
(
value
)
+
'
'
+
name
+
'
(
'
+
round
(
min
)
+
'
-
'
+
round
(
max
)
+
'
)
'
,
TEXT_X
,
TEXT_Y
);
context
.
drawImage
(
canvas
,
GRAPH_X
+
PR
,
GRAPH_Y
,
GRAPH_WIDTH
-
PR
,
GRAPH_HEIGHT
,
GRAPH_X
,
GRAPH_Y
,
GRAPH_WIDTH
-
PR
,
GRAPH_HEIGHT
);
context
.
fillRect
(
GRAPH_X
+
GRAPH_WIDTH
-
PR
,
GRAPH_Y
,
PR
,
GRAPH_HEIGHT
);
context
.
fillStyle
=
bg
;
context
.
globalAlpha
=
0.9
;
context
.
fillRect
(
GRAPH_X
+
GRAPH_WIDTH
-
PR
,
GRAPH_Y
,
PR
,
round
(
(
1
-
(
value
/
maxValue
)
)
*
GRAPH_HEIGHT
)
);
}
};
};
return
Stats
;
})));
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录