Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
868fc746
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,发现更多精彩内容 >>
提交
868fc746
编写于
1月 24, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CardboardEffect: Simplified using .toNonIndexed()
上级
e8b034d0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
23 addition
and
50 deletion
+23
-50
examples/js/effects/CardboardEffect.js
examples/js/effects/CardboardEffect.js
+23
-50
未找到文件。
examples/js/effects/CardboardEffect.js
浏览文件 @
868fc746
...
...
@@ -21,76 +21,49 @@ THREE.CardboardEffect = function ( renderer ) {
var
distortion
=
new
THREE
.
Vector2
(
0.441
,
0.156
);
var
geometry
=
new
THREE
.
PlaneBufferGeometry
(
1
,
1
,
10
,
20
);
var
geometry
=
new
THREE
.
PlaneBufferGeometry
(
1
,
1
,
10
,
20
)
.
removeAttribute
(
'
normal
'
).
toNonIndexed
()
;
var
indices
=
geometry
.
index
.
array
;
var
positions
=
geometry
.
attributes
.
position
.
array
;
var
uvs
=
geometry
.
attributes
.
uv
.
array
;
var
vector
=
new
THREE
.
Vector2
();
function
poly
(
val
)
{
return
1.5
+
(
distortion
.
x
+
distortion
.
y
*
val
)
*
val
;
}
for
(
var
i
=
0
;
i
<
indices
.
length
;
i
++
)
{
// duplicate
vector
.
x
=
positions
[
i
*
3
+
0
];
vector
.
y
=
positions
[
i
*
3
+
1
];
var
scalar
=
poly
(
vector
.
dot
(
vector
)
);
positions
[
i
*
3
+
0
]
=
(
vector
.
x
/
scalar
)
*
1.5
-
0.5
;
positions
[
i
*
3
+
1
]
=
(
vector
.
y
/
scalar
)
*
3.0
;
uvs
[
i
*
2
]
*=
0.5
;
}
// clone geometry
function
copyArray
(
array1
,
array2
,
offset
)
{
for
(
var
i
=
0
,
l
=
array2
.
length
;
i
<
l
;
i
++
)
{
var
positions2
=
new
Float32Array
(
positions
.
length
*
2
);
positions2
.
set
(
positions
);
positions2
.
set
(
positions
,
positions
.
length
);
array1
[
i
+
offset
]
=
array2
[
i
];
var
uvs2
=
new
Float32Array
(
uvs
.
length
*
2
);
uvs2
.
set
(
uvs
);
uvs2
.
set
(
uvs
,
uvs
.
length
);
}
var
vector
=
new
THREE
.
Vector2
();
var
length
=
positions
.
length
/
3
;
}
for
(
var
i
=
0
,
l
=
positions2
.
length
/
3
;
i
<
l
;
i
++
)
{
var
indices2
=
new
Uint16Array
(
indices
.
length
*
2
);
var
positions2
=
new
Float32Array
(
positions
.
length
*
2
);
var
uvs2
=
new
Float32Array
(
uvs
.
length
*
2
);
vector
.
x
=
positions2
[
i
*
3
+
0
];
vector
.
y
=
positions2
[
i
*
3
+
1
];
copyArray
(
indices2
,
indices
,
0
);
copyArray
(
positions2
,
positions
,
0
);
copyArray
(
uvs2
,
uvs
,
0
);
var
dot
=
vector
.
dot
(
vector
);
var
scalar
=
1.5
+
(
distortion
.
x
+
distortion
.
y
*
dot
)
*
dot
;
var
offset
=
positions
.
length
/
3
;
var
offset
=
i
<
length
?
0
:
1
;
for
(
i
=
0
;
i
<
indices
.
length
;
i
++
)
{
positions2
[
i
*
3
+
0
]
=
(
vector
.
x
/
scalar
)
*
1.5
-
0.5
+
offset
;
positions2
[
i
*
3
+
1
]
=
(
vector
.
y
/
scalar
)
*
3.0
;
indices
[
i
]
+=
offset
;
positions
[
i
*
3
]
+=
1.0
;
uvs
[
i
*
2
]
+=
0.5
;
uvs2
[
i
*
2
]
=
(
uvs2
[
i
*
2
]
+
offset
)
*
0.5
;
}
copyArray
(
indices2
,
indices
,
indices
.
length
);
copyArray
(
positions2
,
positions
,
positions
.
length
);
copyArray
(
uvs2
,
uvs
,
uvs
.
length
);
geometry
.
attributes
.
position
.
array
=
positions2
;
geometry
.
attributes
.
uv
.
array
=
uvs2
;
var
geometry2
=
new
THREE
.
BufferGeometry
();
geometry2
.
setIndex
(
new
THREE
.
BufferAttribute
(
indices2
,
1
)
);
geometry2
.
addAttribute
(
'
position
'
,
new
THREE
.
BufferAttribute
(
positions2
,
3
)
);
geometry2
.
addAttribute
(
'
uv
'
,
new
THREE
.
BufferAttribute
(
uvs2
,
2
)
);
//
// var material = new THREE.MeshBasicMaterial( { wireframe: true } );
var
material
=
new
THREE
.
MeshBasicMaterial
(
{
map
:
_renderTarget
}
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
2
,
material
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
_scene
.
add
(
mesh
);
//
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录