Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
e7a44eec
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e7a44eec
编写于
7月 11, 2018
作者:
S
sunag
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
benchmark node material system
上级
231a8a63
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
270 addition
and
0 deletion
+270
-0
examples/files.js
examples/files.js
+1
-0
examples/webgl_performance_nodes.html
examples/webgl_performance_nodes.html
+269
-0
未找到文件。
examples/files.js
浏览文件 @
e7a44eec
...
...
@@ -210,6 +210,7 @@ var files = {
"
webgl_panorama_equirectangular
"
,
"
webgl_performance
"
,
"
webgl_performance_doublesided
"
,
"
webgl_performance_nodes
"
,
"
webgl_performance_static
"
,
"
webgl_physics_cloth
"
,
"
webgl_physics_convex_break
"
,
...
...
examples/webgl_performance_nodes.html
0 → 100644
浏览文件 @
e7a44eec
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
three.js webgl - performance [nodes]
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
>
<style>
body
{
color
:
#fff
;
font-family
:
Monospace
;
font-size
:
13px
;
margin
:
0px
;
text-align
:
center
;
overflow
:
hidden
;
}
#info
{
color
:
#999
;
position
:
absolute
;
top
:
10px
;
width
:
100%
;
text-align
:
center
;
display
:
block
;
}
.white
{
color
:
white
;
}
b
{
color
:
#ccc
;
}
a
{
color
:
white
}
</style>
</head>
<body>
<script
src=
"../build/three.js"
></script>
<script
src=
"js/libs/stats.min.js"
></script>
<div
id=
"info"
>
<a
href=
"http://threejs.org"
target=
"_blank"
>
three.js
</a><span
class=
"white"
>
- NodeMaterial Performance
</span></br>
<br>
<b>
Node Material System
</b>
<br>
<div>
Standard
<b>
Node
</b>
Material |
<span
id=
"node"
class=
"white"
>
None
</span>
</div>
<div>
MeshStandard
<b>
Node
</b>
Material |
<span
id=
"nodeBased"
class=
"white"
>
None
</span>
</div>
<br>
<b>
Current Material System
</b>
<br>
<div>
MeshStandardMaterial |
<span
id=
"default"
class=
"white"
>
None
</span>
</div>
<br>
<a
id=
"bench"
href=
"javascript:void(0);"
>
Click to benchmark
</a>
</div>
<script
type=
"module"
>
import
'
./js/nodes/THREE.Nodes.js
'
;
var
container
,
stats
;
var
camera
,
scene
,
renderer
;
var
mesh
,
zmesh
,
lightMesh
,
geometry
;
var
meshes
=
[];
var
mouseX
=
0
,
mouseY
=
0
;
var
windowHalfX
=
window
.
innerWidth
/
2
;
var
windowHalfY
=
window
.
innerHeight
/
2
;
document
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
init
();
animate
();
function
createScene
(
MaterialClass
,
count
)
{
count
=
count
!==
undefined
?
count
:
70
;
var
i
=
0
;
for
(
i
=
0
;
i
<
meshes
.
length
;
i
++
)
{
meshes
[
i
].
material
.
dispose
();
scene
.
remove
(
meshes
[
i
]
);
}
meshes
=
[];
for
(
i
=
0
;
i
<
70
;
i
++
)
{
var
material
=
new
MaterialClass
(),
color
=
0xFFFFFF
*
Math
.
random
();
if
(
material
.
color
.
isNode
)
material
.
color
.
value
.
setHex
(
color
);
else
material
.
color
.
setHex
(
color
);
// prevent share code
material
.
defines
.
UUID
=
material
.
uuid
;
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
position
.
x
=
Math
.
random
()
*
1000
-
500
;
mesh
.
position
.
y
=
Math
.
random
()
*
1000
-
500
;
mesh
.
position
.
z
=
Math
.
random
()
*
1000
-
500
;
mesh
.
rotation
.
x
=
Math
.
random
()
*
2
*
Math
.
PI
;
mesh
.
rotation
.
y
=
Math
.
random
()
*
2
*
Math
.
PI
;
mesh
.
scale
.
x
=
mesh
.
scale
.
y
=
mesh
.
scale
.
z
=
Math
.
random
()
*
50
+
100
;
mesh
.
matrixAutoUpdate
=
false
;
mesh
.
updateMatrix
();
scene
.
add
(
mesh
);
meshes
.
push
(
mesh
);
}
}
function
benchmark
()
{
var
time
,
benchmarkTime
;
// Stabilizes CPU
createScene
(
THREE
.
MeshStandardMaterial
,
10
);
render
();
// Standard *Node* Material
time
=
performance
.
now
();
createScene
(
THREE
.
StandardNodeMaterial
);
render
();
benchmarkTime
=
(
performance
.
now
()
-
time
)
/
1000
;
document
.
getElementById
(
'
node
'
).
textContent
=
benchmarkTime
.
toFixed
(
3
)
+
"
seconds
"
;
// Mesh Standard *Node* Material
time
=
performance
.
now
();
createScene
(
THREE
.
MeshStandardNodeMaterial
);
render
();
benchmarkTime
=
(
performance
.
now
()
-
time
)
/
1000
;
document
.
getElementById
(
'
nodeBased
'
).
textContent
=
benchmarkTime
.
toFixed
(
3
)
+
"
seconds
"
;
// Mesh Standard Material
time
=
performance
.
now
();
createScene
(
THREE
.
MeshStandardMaterial
);
render
();
benchmarkTime
=
(
performance
.
now
()
-
time
)
/
1000
;
document
.
getElementById
(
'
default
'
).
textContent
=
benchmarkTime
.
toFixed
(
3
)
+
"
seconds
"
;
}
document
.
getElementById
(
'
bench
'
).
addEventListener
(
'
click
'
,
function
()
{
if
(
geometry
)
{
benchmark
();
}
});
function
init
()
{
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
camera
=
new
THREE
.
PerspectiveCamera
(
60
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
10000
);
camera
.
position
.
z
=
3200
;
scene
=
new
THREE
.
Scene
();
scene
.
add
(
new
THREE
.
PointLight
(
0xFFFFFF
)
);
//scene.background = new THREE.Color( 0xffffff );
var
loader
=
new
THREE
.
BufferGeometryLoader
();
loader
.
load
(
'
models/json/suzanne_buffergeometry.json
'
,
function
(
geo
)
{
geo
.
computeVertexNormals
();
geometry
=
geo
;
}
);
renderer
=
new
THREE
.
WebGLRenderer
();
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
//renderer.sortObjects = false;
container
.
appendChild
(
renderer
.
domElement
);
stats
=
new
Stats
();
container
.
appendChild
(
stats
.
dom
);
//
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
}
function
onWindowResize
()
{
windowHalfX
=
window
.
innerWidth
/
2
;
windowHalfY
=
window
.
innerHeight
/
2
;
camera
.
aspect
=
window
.
innerWidth
/
window
.
innerHeight
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
}
function
onDocumentMouseMove
(
event
)
{
mouseX
=
(
event
.
clientX
-
windowHalfX
)
*
10
;
mouseY
=
(
event
.
clientY
-
windowHalfY
)
*
10
;
}
//
function
animate
()
{
requestAnimationFrame
(
animate
);
render
();
stats
.
update
();
}
function
render
()
{
camera
.
position
.
x
+=
(
mouseX
-
camera
.
position
.
x
)
*
.
05
;
camera
.
position
.
y
+=
(
-
mouseY
-
camera
.
position
.
y
)
*
.
05
;
camera
.
lookAt
(
scene
.
position
);
renderer
.
render
(
scene
,
camera
);
}
</script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录