Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
54aef22b
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,发现更多精彩内容 >>
提交
54aef22b
编写于
9月 06, 2018
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improved webvr_ballshooter example performance.
上级
19a0947e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
29 deletion
+29
-29
examples/webvr_ballshooter.html
examples/webvr_ballshooter.html
+29
-29
未找到文件。
examples/webvr_ballshooter.html
浏览文件 @
54aef22b
...
...
@@ -34,6 +34,7 @@
var
room
;
var
count
=
0
;
var
radius
=
0.08
;
var
normal
=
new
THREE
.
Vector3
();
var
relativeVelocity
=
new
THREE
.
Vector3
();
...
...
@@ -66,10 +67,8 @@
room
.
geometry
.
translate
(
0
,
3
,
0
);
scene
.
add
(
room
);
scene
.
add
(
new
THREE
.
HemisphereLight
(
0x606060
,
0x404040
)
);
var
light
=
new
THREE
.
DirectionalLight
(
0xffffff
);
light
.
position
.
set
(
1
,
1
,
1
).
normalize
();
var
light
=
new
THREE
.
HemisphereLight
(
0xffffff
,
0x444444
);
light
.
position
.
set
(
1
,
1
,
1
);
scene
.
add
(
light
);
var
geometry
=
new
THREE
.
IcosahedronBufferGeometry
(
radius
,
2
);
...
...
@@ -157,8 +156,7 @@
if
(
controller
.
userData
.
isSelecting
)
{
var
object
=
room
.
children
[
0
];
room
.
remove
(
object
);
var
object
=
room
.
children
[
count
++
];
object
.
position
.
copy
(
controller
.
position
);
object
.
userData
.
velocity
.
x
=
(
Math
.
random
()
-
0.5
)
*
0.02
;
...
...
@@ -166,7 +164,7 @@
object
.
userData
.
velocity
.
z
=
(
Math
.
random
()
*
0.02
-
0.1
);
object
.
userData
.
velocity
.
applyQuaternion
(
controller
.
quaternion
);
room
.
add
(
object
)
;
if
(
count
===
room
.
children
.
length
)
count
=
0
;
}
...
...
@@ -185,45 +183,47 @@
handleController
(
controller1
);
handleController
(
controller2
);
//
keep cubes inside room
//
var
range
=
3
-
radius
;
for
(
var
i
=
0
;
i
<
room
.
children
.
length
;
i
++
)
{
var
cube
=
room
.
children
[
i
];
var
object
=
room
.
children
[
i
];
object
.
position
.
add
(
object
.
userData
.
velocity
);
cube
.
position
.
add
(
cube
.
userData
.
velocity
);
// keep objects inside room
if
(
cube
.
position
.
x
<
-
range
||
cube
.
position
.
x
>
range
)
{
if
(
object
.
position
.
x
<
-
range
||
object
.
position
.
x
>
range
)
{
cube
.
position
.
x
=
THREE
.
Math
.
clamp
(
cube
.
position
.
x
,
-
range
,
range
);
cube
.
userData
.
velocity
.
x
=
-
cube
.
userData
.
velocity
.
x
;
object
.
position
.
x
=
THREE
.
Math
.
clamp
(
object
.
position
.
x
,
-
range
,
range
);
object
.
userData
.
velocity
.
x
=
-
object
.
userData
.
velocity
.
x
;
}
if
(
cube
.
position
.
y
<
radius
||
cube
.
position
.
y
>
6
)
{
if
(
object
.
position
.
y
<
radius
||
object
.
position
.
y
>
6
)
{
cube
.
position
.
y
=
Math
.
max
(
cube
.
position
.
y
,
radius
);
object
.
position
.
y
=
Math
.
max
(
object
.
position
.
y
,
radius
);
cube
.
userData
.
velocity
.
x
*=
0.98
;
cube
.
userData
.
velocity
.
y
=
-
cube
.
userData
.
velocity
.
y
*
0.8
;
cube
.
userData
.
velocity
.
z
*=
0.98
;
object
.
userData
.
velocity
.
x
*=
0.98
;
object
.
userData
.
velocity
.
y
=
-
object
.
userData
.
velocity
.
y
*
0.8
;
object
.
userData
.
velocity
.
z
*=
0.98
;
}
if
(
cube
.
position
.
z
<
-
range
||
cube
.
position
.
z
>
range
)
{
if
(
object
.
position
.
z
<
-
range
||
object
.
position
.
z
>
range
)
{
cube
.
position
.
z
=
THREE
.
Math
.
clamp
(
cube
.
position
.
z
,
-
range
,
range
);
cube
.
userData
.
velocity
.
z
=
-
cube
.
userData
.
velocity
.
z
;
object
.
position
.
z
=
THREE
.
Math
.
clamp
(
object
.
position
.
z
,
-
range
,
range
);
object
.
userData
.
velocity
.
z
=
-
object
.
userData
.
velocity
.
z
;
}
for
(
var
j
=
i
+
1
;
j
<
room
.
children
.
length
;
j
++
)
{
var
cube
2
=
room
.
children
[
j
];
var
object
2
=
room
.
children
[
j
];
normal
.
copy
(
cube
.
position
).
sub
(
cube
2
.
position
);
normal
.
copy
(
object
.
position
).
sub
(
object
2
.
position
);
var
distance
=
normal
.
length
();
...
...
@@ -231,23 +231,23 @@
normal
.
multiplyScalar
(
0.5
*
distance
-
radius
);
cube
.
position
.
sub
(
normal
);
cube
2
.
position
.
add
(
normal
);
object
.
position
.
sub
(
normal
);
object
2
.
position
.
add
(
normal
);
normal
.
normalize
();
relativeVelocity
.
copy
(
cube
.
userData
.
velocity
).
sub
(
cube
2
.
userData
.
velocity
);
relativeVelocity
.
copy
(
object
.
userData
.
velocity
).
sub
(
object
2
.
userData
.
velocity
);
normal
=
normal
.
multiplyScalar
(
relativeVelocity
.
dot
(
normal
)
);
cube
.
userData
.
velocity
.
sub
(
normal
);
cube
2
.
userData
.
velocity
.
add
(
normal
);
object
.
userData
.
velocity
.
sub
(
normal
);
object
2
.
userData
.
velocity
.
add
(
normal
);
}
}
cube
.
userData
.
velocity
.
y
-=
0.00098
;
object
.
userData
.
velocity
.
y
-=
0.00098
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录