Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
cd32a0ad
T
three.js
项目概览
Ablesons
/
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,发现更多精彩内容 >>
提交
cd32a0ad
编写于
5月 11, 2018
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added collision handling to Daydream example
上级
9d49330a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
11 deletion
+41
-11
examples/webvr_daydream.html
examples/webvr_daydream.html
+33
-3
examples/webvr_gearvr.html
examples/webvr_gearvr.html
+8
-8
未找到文件。
examples/webvr_daydream.html
浏览文件 @
cd32a0ad
...
@@ -40,6 +40,10 @@
...
@@ -40,6 +40,10 @@
var
room
;
var
room
;
var
radius
=
0.08
;
var
normal
=
new
THREE
.
Vector3
();
var
relativeVelocity
=
new
THREE
.
Vector3
();
init
();
init
();
animate
();
animate
();
...
@@ -74,7 +78,7 @@
...
@@ -74,7 +78,7 @@
light
.
position
.
set
(
1
,
1
,
1
).
normalize
();
light
.
position
.
set
(
1
,
1
,
1
).
normalize
();
scene
.
add
(
light
);
scene
.
add
(
light
);
var
geometry
=
new
THREE
.
IcosahedronBufferGeometry
(
0.08
,
2
);
var
geometry
=
new
THREE
.
IcosahedronBufferGeometry
(
radius
,
2
);
for
(
var
i
=
0
;
i
<
200
;
i
++
)
{
for
(
var
i
=
0
;
i
<
200
;
i
++
)
{
...
@@ -162,7 +166,7 @@
...
@@ -162,7 +166,7 @@
// keep cubes inside room
// keep cubes inside room
var
range
=
3
-
0.08
;
var
range
=
3
-
radius
;
for
(
var
i
=
0
;
i
<
room
.
children
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
room
.
children
.
length
;
i
++
)
{
...
@@ -177,7 +181,7 @@
...
@@ -177,7 +181,7 @@
}
}
if
(
cube
.
position
.
y
<
-
range
)
{
if
(
cube
.
position
.
y
<
-
range
||
cube
.
position
.
y
>
range
)
{
cube
.
position
.
y
=
Math
.
max
(
cube
.
position
.
y
,
-
range
);
cube
.
position
.
y
=
Math
.
max
(
cube
.
position
.
y
,
-
range
);
...
@@ -194,6 +198,32 @@
...
@@ -194,6 +198,32 @@
}
}
for
(
var
j
=
i
+
1
;
j
<
room
.
children
.
length
;
j
++
)
{
var
cube2
=
room
.
children
[
j
];
normal
.
copy
(
cube
.
position
).
sub
(
cube2
.
position
);
if
(
normal
.
length
()
<
2
*
radius
)
{
normal
.
multiplyScalar
(
0.5
*
normal
.
length
()
-
radius
);
cube
.
position
.
sub
(
normal
);
cube2
.
position
.
add
(
normal
);
normal
.
normalize
();
relativeVelocity
.
copy
(
cube
.
userData
.
velocity
).
sub
(
cube2
.
userData
.
velocity
);
var
dot
=
relativeVelocity
.
dot
(
normal
);
normal
=
normal
.
multiplyScalar
(
dot
);
cube
.
userData
.
velocity
.
sub
(
normal
);
cube2
.
userData
.
velocity
.
add
(
normal
);
}
}
cube
.
userData
.
velocity
.
y
-=
0.00098
;
cube
.
userData
.
velocity
.
y
-=
0.00098
;
}
}
...
...
examples/webvr_gearvr.html
浏览文件 @
cd32a0ad
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
var
controller
;
var
controller
;
var
room
;
var
room
;
var
radius
=
0.08
;
var
radius
=
0.08
;
var
normal
=
new
THREE
.
Vector3
();
var
normal
=
new
THREE
.
Vector3
();
var
relativeVelocity
=
new
THREE
.
Vector3
();
var
relativeVelocity
=
new
THREE
.
Vector3
();
...
@@ -183,7 +183,7 @@
...
@@ -183,7 +183,7 @@
cube
.
position
.
copy
(
controller
.
position
).
sub
(
room
.
position
);
cube
.
position
.
copy
(
controller
.
position
).
sub
(
room
.
position
);
cube
.
userData
.
velocity
.
x
=
(
Math
.
random
()
-
0.5
)
*
0.02
;
cube
.
userData
.
velocity
.
x
=
(
Math
.
random
()
-
0.5
)
*
0.02
;
cube
.
userData
.
velocity
.
y
=
(
Math
.
random
()
-
0.5
)
*
0.02
;
cube
.
userData
.
velocity
.
y
=
(
Math
.
random
()
-
0.5
)
*
0.02
;
cube
.
userData
.
velocity
.
z
=
(
Math
.
random
()
*
0.0
1
-
0.1
);
cube
.
userData
.
velocity
.
z
=
(
Math
.
random
()
*
0.0
2
-
0.1
);
cube
.
userData
.
velocity
.
applyQuaternion
(
controller
.
quaternion
);
cube
.
userData
.
velocity
.
applyQuaternion
(
controller
.
quaternion
);
room
.
add
(
cube
);
room
.
add
(
cube
);
...
@@ -222,15 +222,15 @@
...
@@ -222,15 +222,15 @@
cube
.
userData
.
velocity
.
z
=
-
cube
.
userData
.
velocity
.
z
;
cube
.
userData
.
velocity
.
z
=
-
cube
.
userData
.
velocity
.
z
;
}
}
for
(
var
j
=
i
+
1
;
j
<
room
.
children
.
length
;
j
++
)
{
for
(
var
j
=
i
+
1
;
j
<
room
.
children
.
length
;
j
++
)
{
var
cube2
=
room
.
children
[
j
];
var
cube2
=
room
.
children
[
j
];
normal
.
copy
(
cube
.
position
).
sub
(
cube2
.
position
);
normal
.
copy
(
cube
.
position
).
sub
(
cube2
.
position
);
if
(
normal
.
length
()
<
2
*
radius
)
{
if
(
normal
.
length
()
<
2
*
radius
)
{
normal
.
multiplyScalar
(
0.5
*
normal
.
length
()
-
radius
);
normal
.
multiplyScalar
(
0.5
*
normal
.
length
()
-
radius
);
cube
.
position
.
sub
(
normal
);
cube
.
position
.
sub
(
normal
);
cube2
.
position
.
add
(
normal
);
cube2
.
position
.
add
(
normal
);
...
@@ -246,7 +246,7 @@
...
@@ -246,7 +246,7 @@
cube2
.
userData
.
velocity
.
add
(
normal
);
cube2
.
userData
.
velocity
.
add
(
normal
);
}
}
}
}
cube
.
userData
.
velocity
.
y
-=
0.00098
;
cube
.
userData
.
velocity
.
y
-=
0.00098
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录