Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
5e250228
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,发现更多精彩内容 >>
提交
5e250228
编写于
6月 22, 2015
作者:
W
WestLangley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added support for tangents and uvs2 to BufferGeometry and DirectGeometry
上级
de1e2336
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
99 addition
and
4 deletion
+99
-4
src/core/BufferGeometry.js
src/core/BufferGeometry.js
+31
-0
src/core/DirectGeometry.js
src/core/DirectGeometry.js
+33
-2
src/core/Geometry.js
src/core/Geometry.js
+35
-2
未找到文件。
src/core/BufferGeometry.js
浏览文件 @
5e250228
...
...
@@ -194,11 +194,13 @@ THREE.BufferGeometry.prototype = {
direct
.
normalsNeedUpdate
=
geometry
.
normalsNeedUpdate
;
direct
.
colorsNeedUpdate
=
geometry
.
colorsNeedUpdate
;
direct
.
uvsNeedUpdate
=
geometry
.
uvsNeedUpdate
;
direct
.
tangentsNeedUpdate
=
geometry
.
tangentsNeedUpdate
;
geometry
.
verticesNeedUpdate
=
false
;
geometry
.
normalsNeedUpdate
=
false
;
geometry
.
colorsNeedUpdate
=
false
;
geometry
.
uvsNeedUpdate
=
false
;
geometry
.
tangentsNeedUpdate
=
false
;
geometry
=
direct
;
...
...
@@ -249,6 +251,21 @@ THREE.BufferGeometry.prototype = {
}
if
(
geometry
.
tangentsNeedUpdate
===
true
)
{
var
attribute
=
this
.
attributes
.
tangent
;
if
(
attribute
!==
undefined
)
{
attribute
.
copyVector4sArray
(
geometry
.
tangents
);
attribute
.
needsUpdate
=
true
;
}
geometry
.
tangentsNeedUpdate
=
false
;
}
return
this
;
},
...
...
@@ -298,6 +315,20 @@ THREE.BufferGeometry.prototype = {
}
if
(
geometry
.
uvs2
.
length
>
0
)
{
var
uvs2
=
new
Float32Array
(
geometry
.
uvs2
.
length
*
2
);
this
.
addAttribute
(
'
uv2
'
,
new
THREE
.
BufferAttribute
(
uvs2
,
2
).
copyVector2sArray
(
geometry
.
uvs2
)
);
}
if
(
geometry
.
tangents
.
length
>
0
)
{
var
tangents
=
new
Float32Array
(
geometry
.
tangents
.
length
*
4
);
this
.
addAttribute
(
'
tangent
'
,
new
THREE
.
BufferAttribute
(
tangents
,
4
).
copyVector4sArray
(
geometry
.
tangents
)
);
}
// morphs
if
(
geometry
.
morphTargets
.
length
>
0
)
{
...
...
src/core/DirectGeometry.js
浏览文件 @
5e250228
...
...
@@ -18,6 +18,7 @@ THREE.DirectGeometry = function () {
this
.
colors
=
[];
this
.
uvs
=
[];
this
.
uvs2
=
[];
this
.
tangents
=
[];
this
.
morphTargets
=
[];
this
.
morphColors
=
[];
...
...
@@ -37,6 +38,7 @@ THREE.DirectGeometry = function () {
this
.
normalsNeedUpdate
=
false
;
this
.
colorsNeedUpdate
=
false
;
this
.
uvsNeedUpdate
=
false
;
this
.
tangentsNeedUpdate
=
false
;
};
...
...
@@ -61,6 +63,14 @@ THREE.DirectGeometry.prototype = {
},
computeTangents
:
function
()
{
console
.
warn
(
'
THREE.DirectGeometry: computeTangents() is not a method of this type of geometry.
'
);
return
this
;
},
fromGeometry
:
function
(
geometry
)
{
var
faces
=
geometry
.
faces
;
...
...
@@ -70,6 +80,8 @@ THREE.DirectGeometry.prototype = {
var
hasFaceVertexUv
=
faceVertexUvs
[
0
]
&&
faceVertexUvs
[
0
].
length
>
0
;
var
hasFaceVertexUv2
=
faceVertexUvs
[
1
]
&&
faceVertexUvs
[
1
].
length
>
0
;
var
hasTangents
=
geometry
.
hasTangents
;
// morphs
var
morphTargets
=
geometry
.
morphTargets
;
...
...
@@ -153,7 +165,7 @@ THREE.DirectGeometry.prototype = {
}
else
{
console
.
warn
(
'
THREE.
BufferGeometry.fromGeometry(): Undefined vertexUv
'
,
i
);
console
.
warn
(
'
THREE.
DirectGeometry.fromGeometry(): Undefined vertexUv
'
,
i
);
this
.
uvs
.
push
(
new
THREE
.
Vector2
(),
new
THREE
.
Vector2
(),
new
THREE
.
Vector2
()
);
...
...
@@ -171,7 +183,7 @@ THREE.DirectGeometry.prototype = {
}
else
{
console
.
warn
(
'
THREE.
BufferGeometry.fromGeometry(): Undefined vertexUv2
'
,
i
);
console
.
warn
(
'
THREE.
DirectGeometry.fromGeometry(): Undefined vertexUv2
'
,
i
);
this
.
uvs2
.
push
(
new
THREE
.
Vector2
(),
new
THREE
.
Vector2
(),
new
THREE
.
Vector2
()
);
...
...
@@ -179,6 +191,24 @@ THREE.DirectGeometry.prototype = {
}
if
(
hasTangents
===
true
)
{
var
vertexTangents
=
face
.
vertexTangents
;
if
(
vertexTangents
.
length
===
3
)
{
this
.
tangents
.
push
(
vertexTangents
[
0
],
vertexTangents
[
1
],
vertexTangents
[
2
]
);
}
else
{
console
.
warn
(
'
THREE.DirectGeometry.fromGeometry(): Undefined tangents
'
,
i
);
this
.
tangents
.
push
(
new
THREE
.
Vector4
(),
new
THREE
.
Vector4
(),
new
THREE
.
Vector4
()
);
}
}
// morphs
for
(
var
j
=
0
;
j
<
morphTargetsLength
;
j
++
)
{
...
...
@@ -226,6 +256,7 @@ THREE.DirectGeometry.prototype = {
this
.
normalsNeedUpdate
=
geometry
.
normalsNeedUpdate
;
this
.
colorsNeedUpdate
=
geometry
.
colorsNeedUpdate
;
this
.
uvsNeedUpdate
=
geometry
.
uvsNeedUpdate
;
this
.
tangentsNeedUpdate
=
geometry
.
tangentsNeedUpdate
;
return
this
;
...
...
src/core/Geometry.js
浏览文件 @
5e250228
...
...
@@ -103,11 +103,18 @@ THREE.Geometry.prototype = {
var
normals
=
attributes
.
normal
!==
undefined
?
attributes
.
normal
.
array
:
undefined
;
var
colors
=
attributes
.
color
!==
undefined
?
attributes
.
color
.
array
:
undefined
;
var
uvs
=
attributes
.
uv
!==
undefined
?
attributes
.
uv
.
array
:
undefined
;
var
uvs2
=
attributes
.
uv2
!==
undefined
?
attributes
.
uv2
.
array
:
undefined
;
var
tangents
=
attributes
.
tangent
!==
undefined
?
attributes
.
tangent
.
array
:
undefined
;
if
(
uvs2
!==
undefined
)
this
.
faceVertexUvs
[
1
]
=
[];
if
(
tangents
!==
undefined
)
this
.
hasTangents
=
true
;
var
tempNormals
=
[];
var
tempUVs
=
[];
var
tempUVs2
=
[];
var
tempTangents
=
[];
for
(
var
i
=
0
,
j
=
0
;
i
<
vertices
.
length
;
i
+=
3
,
j
+=
2
)
{
for
(
var
i
=
0
,
j
=
0
,
k
=
0
;
i
<
vertices
.
length
;
i
+=
3
,
j
+=
2
,
k
+=
4
)
{
scope
.
vertices
.
push
(
new
THREE
.
Vector3
(
vertices
[
i
],
vertices
[
i
+
1
],
vertices
[
i
+
2
]
)
);
...
...
@@ -129,6 +136,18 @@ THREE.Geometry.prototype = {
}
if
(
uvs2
!==
undefined
)
{
tempUVs2
.
push
(
new
THREE
.
Vector2
(
uvs2
[
j
],
uvs2
[
j
+
1
]
)
);
}
if
(
tangents
!==
undefined
)
{
tempTangents
.
push
(
new
THREE
.
Vector4
(
tangents
[
k
],
tangents
[
k
+
1
],
tangents
[
k
+
2
],
tangents
[
k
+
3
]
)
);
}
}
var
addFace
=
function
(
a
,
b
,
c
)
{
...
...
@@ -136,7 +155,9 @@ THREE.Geometry.prototype = {
var
vertexNormals
=
normals
!==
undefined
?
[
tempNormals
[
a
].
clone
(),
tempNormals
[
b
].
clone
(),
tempNormals
[
c
].
clone
()
]
:
[];
var
vertexColors
=
colors
!==
undefined
?
[
scope
.
colors
[
a
].
clone
(),
scope
.
colors
[
b
].
clone
(),
scope
.
colors
[
c
].
clone
()
]
:
[];
scope
.
faces
.
push
(
new
THREE
.
Face3
(
a
,
b
,
c
,
vertexNormals
,
vertexColors
)
);
var
face
=
new
THREE
.
Face3
(
a
,
b
,
c
,
vertexNormals
,
vertexColors
);
scope
.
faces
.
push
(
face
);
if
(
uvs
!==
undefined
)
{
...
...
@@ -144,6 +165,18 @@ THREE.Geometry.prototype = {
}
if
(
uvs2
!==
undefined
)
{
scope
.
faceVertexUvs
[
1
].
push
(
[
tempUVs2
[
a
].
clone
(),
tempUVs2
[
b
].
clone
(),
tempUVs2
[
c
].
clone
()
]
);
}
if
(
tangents
!==
undefined
)
{
face
.
vertexTangents
.
push
(
tempTangents
[
a
].
clone
(),
tempTangents
[
b
].
clone
(),
tempTangents
[
c
].
clone
()
);
}
};
if
(
indices
!==
undefined
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录