Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
8926c8df
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,发现更多精彩内容 >>
提交
8926c8df
编写于
8月 13, 2017
作者:
K
Kai Salmen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Face and line detection only depends on slash and buffer length.
上级
37cfd7b4
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
38 addition
and
78 deletion
+38
-78
examples/js/loaders/OBJLoader2.js
examples/js/loaders/OBJLoader2.js
+38
-78
未找到文件。
examples/js/loaders/OBJLoader2.js
浏览文件 @
8926c8df
...
...
@@ -251,10 +251,7 @@ THREE.OBJLoader2 = (function () {
var
length
=
arrayBufferView
.
byteLength
;
var
buffer
=
new
Array
(
128
);
var
bufferPointer
=
0
;
var
slashesLast
=
0
;
var
slashesDistance
=
0
;
var
slashesCount
=
0
;
var
faceDescType
=
-
1
;
var
reachedFaces
=
false
;
var
code
;
var
word
=
''
;
...
...
@@ -264,23 +261,11 @@ THREE.OBJLoader2 = (function () {
switch
(
code
)
{
case
Consts
.
CODE_SPACE
:
if
(
word
.
length
>
0
)
buffer
[
bufferPointer
++
]
=
word
;
//Whenever space is reached after first block (f v/vn" ") and no face type has been calculated, it will be performed once
if
(
faceDescType
===
-
1
&&
bufferPointer
>
1
)
{
faceDescType
=
(
slashesCount
===
0
)
?
3
:
(
slashesCount
===
1
)
?
1
:
(
slashesCount
===
2
&&
slashesDistance
===
1
)
?
2
:
0
;
}
word
=
''
;
break
;
case
Consts
.
CODE_SLASH
:
if
(
faceDescType
===
-
1
)
{
slashesCount
++
;
slashesDistance
=
i
-
slashesLast
;
slashesLast
=
i
;
}
if
(
word
.
length
>
0
)
buffer
[
bufferPointer
++
]
=
word
;
word
=
''
;
break
;
...
...
@@ -288,13 +273,9 @@ THREE.OBJLoader2 = (function () {
case
Consts
.
CODE_LF
:
if
(
word
.
length
>
0
)
buffer
[
bufferPointer
++
]
=
word
;
word
=
''
;
reachedFaces
=
this
.
processLine
(
buffer
,
bufferPointer
,
faceDescType
,
reachedFaces
);
reachedFaces
=
this
.
processLine
(
buffer
,
bufferPointer
,
slashesCount
,
reachedFaces
);
bufferPointer
=
0
;
slashesLast
=
0
;
slashesDistance
=
0
;
slashesCount
=
0
;
faceDescType
=
-
1
;
break
;
case
Consts
.
CODE_CR
:
...
...
@@ -317,10 +298,7 @@ THREE.OBJLoader2 = (function () {
var
length
=
text
.
length
;
var
buffer
=
new
Array
(
128
);
var
bufferPointer
=
0
;
var
slashesLast
=
0
;
var
slashesDistance
=
0
;
var
slashesCount
=
0
;
var
faceDescType
=
-
1
;
var
reachedFaces
=
false
;
var
char
;
var
word
=
''
;
...
...
@@ -330,22 +308,11 @@ THREE.OBJLoader2 = (function () {
switch
(
char
)
{
case
Consts
.
STRING_SPACE
:
if
(
word
.
length
>
0
)
buffer
[
bufferPointer
++
]
=
word
;
//Whenever space is reached after first block (f v/vn" ") and no face type has been calculated, it will be performed once
if
(
faceDescType
===
-
1
&&
bufferPointer
>
1
)
{
faceDescType
=
(
slashesCount
===
0
)
?
3
:
(
slashesCount
===
1
)
?
1
:
(
slashesCount
===
2
&&
slashesDistance
===
1
)
?
2
:
0
;
}
word
=
''
;
break
;
case
Consts
.
STRING_SLASH
:
if
(
faceDescType
===
-
1
)
{
slashesCount
++
;
slashesDistance
=
i
-
slashesLast
;
slashesLast
=
i
;
}
if
(
word
.
length
>
0
)
buffer
[
bufferPointer
++
]
=
word
;
word
=
''
;
break
;
...
...
@@ -353,12 +320,9 @@ THREE.OBJLoader2 = (function () {
case
Consts
.
STRING_LF
:
if
(
word
.
length
>
0
)
buffer
[
bufferPointer
++
]
=
word
;
word
=
''
;
reachedFaces
=
this
.
processLine
(
buffer
,
bufferPointer
,
faceDescType
,
reachedFaces
);
reachedFaces
=
this
.
processLine
(
buffer
,
bufferPointer
,
slashesCount
,
reachedFaces
);
bufferPointer
=
0
;
slashesLast
=
0
;
slashesDistance
=
0
;
slashesCount
=
0
;
faceDescType
=
-
1
;
break
;
case
Consts
.
STRING_CR
:
...
...
@@ -370,7 +334,7 @@ THREE.OBJLoader2 = (function () {
}
};
Parser
.
prototype
.
processLine
=
function
(
buffer
,
bufferPointer
,
faceDescType
,
reachedFaces
)
{
Parser
.
prototype
.
processLine
=
function
(
buffer
,
bufferPointer
,
slashesCount
,
reachedFaces
)
{
if
(
bufferPointer
<
1
)
return
reachedFaces
;
var
bufferLength
=
bufferPointer
-
1
;
...
...
@@ -411,11 +375,11 @@ THREE.OBJLoader2 = (function () {
case
Consts
.
LINE_F
:
reachedFaces
=
true
;
this
.
rawObject
.
processFaces
(
buffer
,
bufferPointer
,
faceDescType
);
this
.
rawObject
.
processFaces
(
buffer
,
bufferPointer
,
slashesCount
);
break
;
case
Consts
.
LINE_L
:
if
(
faceDescType
===
1
)
{
if
(
bufferLength
===
slashesCount
*
2
)
{
this
.
rawObject
.
buildLineVvt
(
buffer
);
...
...
@@ -639,24 +603,24 @@ THREE.OBJLoader2 = (function () {
}
};
RawObject
.
prototype
.
processFaces
=
function
(
buffer
,
bufferPointer
,
faceDescType
)
{
RawObject
.
prototype
.
processFaces
=
function
(
buffer
,
bufferPointer
,
slashesCount
)
{
var
bufferLength
=
bufferPointer
-
1
;
var
i
;
switch
(
faceDescType
)
{
// "f vertex/uv/normal ..."
case
0
:
for
(
i
=
4
;
i
<
bufferLength
-
3
;
i
+=
3
)
{
// "f vertex ..."
if
(
slashesCount
===
0
)
{
this
.
attachFace
(
buffer
[
1
],
buffer
[
2
],
buffer
[
3
]
);
this
.
attachFace
(
buffer
[
i
],
buffer
[
i
+
1
],
buffer
[
i
+
2
]
);
this
.
attachFace
(
buffer
[
i
+
3
],
buffer
[
i
+
4
],
buffer
[
i
+
5
]
);
for
(
i
=
2
;
i
<
bufferLength
-
1
;
i
++
)
{
this
.
attachFace
(
buffer
[
1
]
);
this
.
attachFace
(
buffer
[
i
]
);
this
.
attachFace
(
buffer
[
i
+
1
]
);
}
break
;
// "f vertex/uv ..."
case
1
:
}
else
if
(
bufferLength
===
slashesCount
*
2
)
{
for
(
i
=
3
;
i
<
bufferLength
-
2
;
i
+=
2
)
{
this
.
attachFace
(
buffer
[
1
],
buffer
[
2
]
);
...
...
@@ -664,10 +628,21 @@ THREE.OBJLoader2 = (function () {
this
.
attachFace
(
buffer
[
i
+
2
],
buffer
[
i
+
3
]
);
}
break
;
// "f vertex/uv/normal ..."
}
else
if
(
bufferLength
*
2
===
slashesCount
*
3
)
{
for
(
i
=
4
;
i
<
bufferLength
-
3
;
i
+=
3
)
{
this
.
attachFace
(
buffer
[
1
],
buffer
[
2
],
buffer
[
3
]
);
this
.
attachFace
(
buffer
[
i
],
buffer
[
i
+
1
],
buffer
[
i
+
2
]
);
this
.
attachFace
(
buffer
[
i
+
3
],
buffer
[
i
+
4
],
buffer
[
i
+
5
]
);
}
// "f vertex//normal ..."
case
2
:
}
else
{
for
(
i
=
3
;
i
<
bufferLength
-
2
;
i
+=
2
)
{
this
.
attachFace
(
buffer
[
1
],
undefined
,
buffer
[
2
]
);
...
...
@@ -675,21 +650,6 @@ THREE.OBJLoader2 = (function () {
this
.
attachFace
(
buffer
[
i
+
2
],
undefined
,
buffer
[
i
+
3
]
);
}
break
;
// "f vertex ..."
case
3
:
for
(
i
=
2
;
i
<
bufferLength
-
1
;
i
++
)
{
this
.
attachFace
(
buffer
[
1
]
);
this
.
attachFace
(
buffer
[
i
]
);
this
.
attachFace
(
buffer
[
i
+
1
]
);
}
break
;
default
:
break
;
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录