Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
0be228cf
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,发现更多精彩内容 >>
提交
0be228cf
编写于
6月 22, 2015
作者:
W
WestLangley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up
上级
c915fb88
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
36 deletion
+29
-36
examples/webgl_decals.html
examples/webgl_decals.html
+29
-36
未找到文件。
examples/webgl_decals.html
浏览文件 @
0be228cf
...
...
@@ -59,17 +59,10 @@
depthTest
:
true
,
depthWrite
:
false
,
polygonOffset
:
true
,
polygonOffsetFactor
:
-
4
,
polygonOffsetFactor
:
-
4
,
wireframe
:
false
});
/*decalMaterial = new THREE.MeshNormalMaterial( {
transparent: true,
depthTest: true,
depthWrite: false,
polygonOffset: true,
polygonOffsetFactor: -4,
shading: THREE.SmoothShading
});*/
}
);
var
decals
=
[];
var
decalHelper
,
mouseHelper
;
var
p
=
new
THREE
.
Vector3
(
0
,
0
,
0
);
...
...
@@ -84,7 +77,9 @@
maxScale
:
20
,
rotate
:
true
,
clear
:
function
()
{
removeDecals
();
}
};
...
...
@@ -115,7 +110,7 @@
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
(),
new
THREE
.
Vector3
()
);
geometry
.
dynamic
=
true
;
line
=
new
THREE
.
Line
(
geometry
,
new
THREE
.
LineBasicMaterial
(
{
linewidth
:
4
})
);
line
=
new
THREE
.
Line
(
geometry
,
new
THREE
.
LineBasicMaterial
(
{
linewidth
:
4
}
)
);
scene
.
add
(
line
);
loadLeePerrySmith
();
...
...
@@ -145,7 +140,7 @@
window
.
addEventListener
(
'
mouseup
'
,
function
()
{
checkIntersection
();
if
(
!
moved
)
shoot
();
if
(
!
moved
)
shoot
();
}
);
...
...
@@ -154,12 +149,16 @@
function
onTouchMove
(
event
)
{
if
(
event
.
changedTouches
)
{
if
(
event
.
changedTouches
)
{
x
=
event
.
changedTouches
[
0
].
pageX
;
y
=
event
.
changedTouches
[
0
].
pageY
;
}
else
{
x
=
event
.
clientX
;
y
=
event
.
clientY
;
}
mouse
.
x
=
(
x
/
window
.
innerWidth
)
*
2
-
1
;
...
...
@@ -171,7 +170,7 @@
function
checkIntersection
()
{
if
(
!
mesh
)
return
;
if
(
!
mesh
)
return
;
raycaster
.
setFromCamera
(
mouse
,
camera
);
...
...
@@ -214,7 +213,7 @@
gui
.
open
();
onWindowResize
();
render
();
animate
();
}
...
...
@@ -224,14 +223,6 @@
loader
.
load
(
'
obj/leeperrysmith/LeePerrySmith.js
'
,
function
(
geometry
)
{
geometry
.
verticesNeedUpdate
=
true
;
geometry
.
elementsNeedUpdate
=
true
;
geometry
.
morphTargetsNeedUpdate
=
true
;
geometry
.
uvsNeedUpdate
=
true
;
geometry
.
normalsNeedUpdate
=
true
;
geometry
.
colorsNeedUpdate
=
true
;
geometry
.
tangentsNeedUpdate
=
true
;
var
material
=
new
THREE
.
MeshPhongMaterial
(
{
map
:
THREE
.
ImageUtils
.
loadTexture
(
'
obj/leeperrysmith/Map-COL.jpg
'
),
specularMap
:
THREE
.
ImageUtils
.
loadTexture
(
'
obj/leeperrysmith/Map-SPEC.jpg
'
),
...
...
@@ -252,7 +243,7 @@
function
shoot
()
{
if
(
params
.
projection
==
'
camera
'
)
{
if
(
params
.
projection
==
'
camera
'
)
{
var
dir
=
camera
.
target
.
clone
();
dir
.
sub
(
camera
.
position
);
...
...
@@ -281,7 +272,7 @@
var
scale
=
params
.
minScale
+
Math
.
random
()
*
(
params
.
maxScale
-
params
.
minScale
);
s
.
set
(
scale
,
scale
,
scale
);
if
(
params
.
rotate
)
r
.
z
=
Math
.
random
()
*
2
*
Math
.
PI
;
if
(
params
.
rotate
)
r
.
z
=
Math
.
random
()
*
2
*
Math
.
PI
;
var
material
=
decalMaterial
.
clone
();
material
.
color
.
setHex
(
Math
.
random
()
*
0xffffff
);
...
...
@@ -295,8 +286,10 @@
function
removeDecals
()
{
decals
.
forEach
(
function
(
d
)
{
scene
.
remove
(
d
);
d
=
null
;
}
);
decals
=
[];
...
...
@@ -305,24 +298,24 @@
function
mergeDecals
()
{
var
merge
=
{};
decals
.
forEach
(
function
(
decal
)
{
decals
.
forEach
(
function
(
decal
)
{
var
uuid
=
decal
.
material
.
uuid
;
var
d
=
merge
[
uuid
]
=
merge
[
uuid
]
||
{};
var
d
=
merge
[
uuid
]
=
merge
[
uuid
]
||
{};
d
.
material
=
d
.
material
||
decal
.
material
;
d
.
geometry
=
d
.
geometry
||
new
THREE
.
Geometry
();
d
.
geometry
.
merge
(
decal
.
geometry
,
decal
.
matrix
);
d
.
geometry
.
merge
(
decal
.
geometry
,
decal
.
matrix
);
});
}
);
removeDecals
();
for
(
var
key
in
merge
)
{
for
(
var
key
in
merge
)
{
var
d
=
merge
[
key
];
var
mesh
=
new
THREE
.
Mesh
(
d
.
geometry
,
d
.
material
);
scene
.
add
(
mesh
);
decals
.
push
(
mesh
);
var
d
=
merge
[
key
];
var
mesh
=
new
THREE
.
Mesh
(
d
.
geometry
,
d
.
material
);
scene
.
add
(
mesh
);
decals
.
push
(
mesh
);
}
...
...
@@ -337,9 +330,9 @@
}
function
render
()
{
function
animate
()
{
requestAnimationFrame
(
render
);
requestAnimationFrame
(
animate
);
renderer
.
render
(
scene
,
camera
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录