Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
81bea678
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,发现更多精彩内容 >>
提交
81bea678
编写于
8月 12, 2017
作者:
K
Kai Salmen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added n-gon support to OBJLoader2
上级
7c40f1c6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
80 addition
and
112 deletion
+80
-112
examples/js/loaders/OBJLoader2.js
examples/js/loaders/OBJLoader2.js
+79
-111
examples/js/loaders/WWOBJLoader2.js
examples/js/loaders/WWOBJLoader2.js
+1
-1
未找到文件。
examples/js/loaders/OBJLoader2.js
浏览文件 @
81bea678
...
@@ -15,7 +15,7 @@ if ( THREE.OBJLoader2 === undefined ) { THREE.OBJLoader2 = {} }
...
@@ -15,7 +15,7 @@ if ( THREE.OBJLoader2 === undefined ) { THREE.OBJLoader2 = {} }
*/
*/
THREE
.
OBJLoader2
=
(
function
()
{
THREE
.
OBJLoader2
=
(
function
()
{
var
OBJLOADER2_VERSION
=
'
1.
3.1
'
;
var
OBJLOADER2_VERSION
=
'
1.
4.0
'
;
function
OBJLoader2
(
manager
)
{
function
OBJLoader2
(
manager
)
{
console
.
log
(
"
Using THREE.OBJLoader2 version:
"
+
OBJLOADER2_VERSION
);
console
.
log
(
"
Using THREE.OBJLoader2 version:
"
+
OBJLOADER2_VERSION
);
...
@@ -265,9 +265,9 @@ THREE.OBJLoader2 = (function () {
...
@@ -265,9 +265,9 @@ THREE.OBJLoader2 = (function () {
Parser
.
prototype
.
parseArrayBuffer
=
function
(
arrayBuffer
)
{
Parser
.
prototype
.
parseArrayBuffer
=
function
(
arrayBuffer
)
{
var
arrayBufferView
=
new
Uint8Array
(
arrayBuffer
);
var
arrayBufferView
=
new
Uint8Array
(
arrayBuffer
);
var
length
=
arrayBufferView
.
byteLength
;
var
length
=
arrayBufferView
.
byteLength
;
var
buffer
=
new
Array
(
32
);
var
buffer
=
new
Array
(
128
);
var
bufferPointer
=
0
;
var
bufferPointer
=
0
;
var
slashes
=
new
Array
(
32
);
var
slashes
=
new
Array
(
128
);
var
slashesPointer
=
0
;
var
slashesPointer
=
0
;
var
reachedFaces
=
false
;
var
reachedFaces
=
false
;
var
code
;
var
code
;
...
@@ -313,9 +313,9 @@ THREE.OBJLoader2 = (function () {
...
@@ -313,9 +313,9 @@ THREE.OBJLoader2 = (function () {
*/
*/
Parser
.
prototype
.
parseText
=
function
(
text
)
{
Parser
.
prototype
.
parseText
=
function
(
text
)
{
var
length
=
text
.
length
;
var
length
=
text
.
length
;
var
buffer
=
new
Array
(
32
);
var
buffer
=
new
Array
(
128
);
var
bufferPointer
=
0
;
var
bufferPointer
=
0
;
var
slashes
=
new
Array
(
32
);
var
slashes
=
new
Array
(
128
);
var
slashesPointer
=
0
;
var
slashesPointer
=
0
;
var
reachedFaces
=
false
;
var
reachedFaces
=
false
;
var
char
;
var
char
;
...
@@ -399,40 +399,8 @@ THREE.OBJLoader2 = (function () {
...
@@ -399,40 +399,8 @@ THREE.OBJLoader2 = (function () {
* 2: "f vertex//normal ..."
* 2: "f vertex//normal ..."
* 3: "f vertex ..."
* 3: "f vertex ..."
*/
*/
var
haveQuad
=
bufferLength
%
4
===
0
;
var
faceDescType
=
(
slashesPointer
>
1
&&
(
slashes
[
1
]
-
slashes
[
0
]
)
===
1
)
?
2
:
(
bufferLength
===
slashesPointer
*
2
)
?
1
:
(
bufferLength
*
2
===
slashesPointer
*
3
)
?
0
:
3
;
if
(
slashesPointer
>
1
&&
(
slashes
[
1
]
-
slashes
[
0
]
)
===
1
)
{
this
.
rawObject
.
processFaces
(
buffer
,
bufferPointer
,
faceDescType
);
if
(
haveQuad
)
{
this
.
rawObject
.
buildQuadVVn
(
buffer
);
}
else
{
this
.
rawObject
.
buildFaceVVn
(
buffer
);
}
}
else
if
(
bufferLength
===
slashesPointer
*
2
)
{
if
(
haveQuad
)
{
this
.
rawObject
.
buildQuadVVt
(
buffer
);
}
else
{
this
.
rawObject
.
buildFaceVVt
(
buffer
);
}
}
else
if
(
bufferLength
*
2
===
slashesPointer
*
3
)
{
if
(
haveQuad
)
{
this
.
rawObject
.
buildQuadVVtVn
(
buffer
);
}
else
{
this
.
rawObject
.
buildFaceVVtVn
(
buffer
);
}
}
else
{
if
(
haveQuad
)
{
this
.
rawObject
.
buildQuadV
(
buffer
);
}
else
{
this
.
rawObject
.
buildFaceV
(
buffer
);
}
}
break
;
break
;
case
Consts
.
LINE_L
:
case
Consts
.
LINE_L
:
...
@@ -558,6 +526,8 @@ THREE.OBJLoader2 = (function () {
...
@@ -558,6 +526,8 @@ THREE.OBJLoader2 = (function () {
var
index
=
this
.
buildIndex
(
this
.
activeMtlName
,
this
.
activeSmoothingGroup
);
var
index
=
this
.
buildIndex
(
this
.
activeMtlName
,
this
.
activeSmoothingGroup
);
this
.
rawObjectDescriptionInUse
=
new
RawObjectDescription
(
this
.
objectName
,
this
.
groupName
,
this
.
activeMtlName
,
this
.
activeSmoothingGroup
);
this
.
rawObjectDescriptionInUse
=
new
RawObjectDescription
(
this
.
objectName
,
this
.
groupName
,
this
.
activeMtlName
,
this
.
activeSmoothingGroup
);
this
.
rawObjectDescriptions
[
index
]
=
this
.
rawObjectDescriptionInUse
;
this
.
rawObjectDescriptions
[
index
]
=
this
.
rawObjectDescriptionInUse
;
this
.
facesBuffer
=
new
Array
(
128
);
}
}
RawObject
.
prototype
.
buildIndex
=
function
(
materialName
,
smoothingGroup
)
{
RawObject
.
prototype
.
buildIndex
=
function
(
materialName
,
smoothingGroup
)
{
...
@@ -660,98 +630,96 @@ THREE.OBJLoader2 = (function () {
...
@@ -660,98 +630,96 @@ THREE.OBJLoader2 = (function () {
}
}
};
};
RawObject
.
prototype
.
buildQuadVVtVn
=
function
(
indexArray
)
{
RawObject
.
prototype
.
processFaces
=
function
(
buffer
,
bufferPointer
,
faceDescType
)
{
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
var
bufferLength
=
bufferPointer
-
1
;
this
.
attachFaceV_
(
indexArray
[
Consts
.
QUAD_INDICES_3
[
i
]
]
);
var
facesBuffer
=
this
.
facesBuffer
;
this
.
attachFaceVt
(
indexArray
[
Consts
.
QUAD_INDICES_3
[
i
]
+
1
]
);
var
i
;
this
.
attachFaceVn
(
indexArray
[
Consts
.
QUAD_INDICES_3
[
i
]
+
2
]
);
for
(
i
=
1
;
i
<
bufferLength
+
1
;
i
++
)
{
facesBuffer
[
i
]
=
parseInt
(
buffer
[
i
]
);
}
}
};
RawObject
.
prototype
.
buildQuadVVt
=
function
(
indexArray
)
{
/*
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
* 0: "f vertex/uv/normal ..."
this
.
attachFaceV_
(
indexArray
[
Consts
.
QUAD_INDICES_2
[
i
]
]
);
* 1: "f vertex/uv ..."
this
.
attachFaceVt
(
indexArray
[
Consts
.
QUAD_INDICES_2
[
i
]
+
1
]
);
* 2: "f vertex//normal ..."
}
* 3: "f vertex ..."
};
*/
if
(
faceDescType
===
0
)
{
RawObject
.
prototype
.
buildQuadVVn
=
function
(
indexArray
)
{
for
(
i
=
4
;
i
<
bufferLength
-
3
;
i
+=
3
)
{
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
this
.
attachFaceV_
(
indexArray
[
Consts
.
QUAD_INDICES_2
[
i
]
]
);
this
.
attachFaceVn
(
indexArray
[
Consts
.
QUAD_INDICES_2
[
i
]
+
1
]
);
}
};
RawObject
.
prototype
.
buildQuadV
=
function
(
indexArray
)
{
this
.
attachFace
(
facesBuffer
[
1
],
facesBuffer
[
2
],
facesBuffer
[
3
]
);
for
(
var
i
=
0
;
i
<
6
;
i
++
)
{
this
.
attachFace
(
facesBuffer
[
i
],
facesBuffer
[
i
+
1
],
facesBuffer
[
i
+
2
]
);
this
.
attachFaceV_
(
indexArray
[
Consts
.
QUAD_INDICES_1
[
i
]
]
);
this
.
attachFace
(
facesBuffer
[
i
+
3
],
facesBuffer
[
i
+
4
],
facesBuffer
[
i
+
5
]
);
}
};
RawObject
.
prototype
.
buildFaceVVtVn
=
function
(
indexArray
)
{
}
for
(
var
i
=
1
;
i
<
10
;
i
+=
3
)
{
this
.
attachFaceV_
(
indexArray
[
i
]
);
this
.
attachFaceVt
(
indexArray
[
i
+
1
]
);
this
.
attachFaceVn
(
indexArray
[
i
+
2
]
);
}
};
RawObject
.
prototype
.
buildFaceVVt
=
function
(
indexArray
)
{
}
else
if
(
faceDescType
===
1
)
{
for
(
var
i
=
1
;
i
<
7
;
i
+=
2
)
{
this
.
attachFaceV_
(
indexArray
[
i
]
);
this
.
attachFaceVt
(
indexArray
[
i
+
1
]
);
}
};
RawObject
.
prototype
.
buildFaceVVn
=
function
(
indexArray
)
{
for
(
i
=
3
;
i
<
bufferLength
-
2
;
i
+=
2
)
{
for
(
var
i
=
1
;
i
<
7
;
i
+=
2
)
{
this
.
attachFaceV_
(
indexArray
[
i
]
);
this
.
attachFace
(
facesBuffer
[
1
],
facesBuffer
[
2
],
-
1
);
this
.
attachFaceVn
(
indexArray
[
i
+
1
]
);
this
.
attachFace
(
facesBuffer
[
i
],
facesBuffer
[
i
+
1
],
-
1
);
}
this
.
attachFace
(
facesBuffer
[
i
+
2
],
facesBuffer
[
i
+
3
],
-
1
);
};
}
}
else
if
(
faceDescType
===
2
)
{
for
(
i
=
3
;
i
<
bufferLength
-
2
;
i
+=
2
)
{
this
.
attachFace
(
facesBuffer
[
1
],
-
1
,
facesBuffer
[
2
]
);
this
.
attachFace
(
facesBuffer
[
i
],
-
1
,
facesBuffer
[
i
+
1
]
);
this
.
attachFace
(
facesBuffer
[
i
+
2
],
-
1
,
facesBuffer
[
i
+
3
]
);
}
}
else
{
for
(
i
=
2
;
i
<
bufferLength
-
1
;
i
++
)
{
this
.
attachFace
(
facesBuffer
[
1
],
-
1
,
-
1
);
this
.
attachFace
(
facesBuffer
[
i
],
-
1
,
-
1
);
this
.
attachFace
(
facesBuffer
[
i
+
1
],
-
1
,
-
1
);
}
RawObject
.
prototype
.
buildFaceV
=
function
(
indexArray
)
{
for
(
var
i
=
1
;
i
<
4
;
i
++
)
{
this
.
attachFaceV_
(
indexArray
[
i
]
);
}
}
};
};
RawObject
.
prototype
.
attachFaceV_
=
function
(
faceIndex
)
{
RawObject
.
prototype
.
attachFace
=
function
(
faceIndexV
,
faceIndexVt
,
faceIndexVn
)
{
var
faceIndexInt
=
parseInt
(
faceIndex
);
var
indexV
=
(
faceIndexV
-
this
.
globalVertexOffset
)
*
3
;
var
index
=
(
faceIndexInt
-
this
.
globalVertexOffset
)
*
3
;
var
vertices
=
this
.
rawObjectDescriptionInUse
.
vertices
;
vertices
.
push
(
this
.
vertices
[
indexV
++
]
);
var
rodiu
=
this
.
rawObjectDescriptionInUse
;
vertices
.
push
(
this
.
vertices
[
indexV
++
]
);
rodiu
.
vertices
.
push
(
this
.
vertices
[
index
++
]
);
vertices
.
push
(
this
.
vertices
[
indexV
]
);
rodiu
.
vertices
.
push
(
this
.
vertices
[
index
++
]
);
rodiu
.
vertices
.
push
(
this
.
vertices
[
index
]
);
if
(
this
.
colors
.
length
>
0
)
{
if
(
this
.
colors
.
length
>
0
)
{
index
-=
2
;
indexV
-=
2
;
rodiu
.
colors
.
push
(
this
.
colors
[
index
++
]
);
var
colors
=
this
.
rawObjectDescriptionInUse
.
colors
;
rodiu
.
colors
.
push
(
this
.
colors
[
index
++
]
);
colors
.
push
(
this
.
colors
[
indexV
++
]
);
rodiu
.
colors
.
push
(
this
.
colors
[
index
]
);
colors
.
push
(
this
.
colors
[
indexV
++
]
);
colors
.
push
(
this
.
colors
[
indexV
]
);
}
}
};
if
(
faceIndexVt
>
-
1
)
{
RawObject
.
prototype
.
attachFaceVt
=
function
(
faceIndex
)
{
var
indexVt
=
(
faceIndexVt
-
this
.
globalUvOffset
)
*
2
;
var
faceIndexInt
=
parseInt
(
faceIndex
);
var
uvs
=
this
.
rawObjectDescriptionInUse
.
uvs
;
var
index
=
(
faceIndexInt
-
this
.
globalUvOffset
)
*
2
;
uvs
.
push
(
this
.
uvs
[
indexVt
++
]
);
uvs
.
push
(
this
.
uvs
[
indexVt
]
);
var
rodiu
=
this
.
rawObjectDescriptionInUse
;
}
rodiu
.
uvs
.
push
(
this
.
uvs
[
index
++
]
);
if
(
faceIndexVn
>
-
1
)
{
rodiu
.
uvs
.
push
(
this
.
uvs
[
index
]
);
};
RawObject
.
prototype
.
attachFaceVn
=
function
(
faceIndex
)
{
var
indexVn
=
(
faceIndexVn
-
this
.
globalNormalOffset
)
*
3
;
var
faceIndexInt
=
parseInt
(
faceIndex
);
var
normals
=
this
.
rawObjectDescriptionInUse
.
normals
;
var
index
=
(
faceIndexInt
-
this
.
globalNormalOffset
)
*
3
;
normals
.
push
(
this
.
normals
[
indexVn
++
]
);
normals
.
push
(
this
.
normals
[
indexVn
++
]
);
normals
.
push
(
this
.
normals
[
indexVn
]
);
var
rodiu
=
this
.
rawObjectDescriptionInUse
;
}
rodiu
.
normals
.
push
(
this
.
normals
[
index
++
]
);
rodiu
.
normals
.
push
(
this
.
normals
[
index
++
]
);
rodiu
.
normals
.
push
(
this
.
normals
[
index
]
);
};
};
/*
/*
...
...
examples/js/loaders/WWOBJLoader2.js
浏览文件 @
81bea678
...
@@ -15,7 +15,7 @@ if ( THREE.OBJLoader2 === undefined ) { THREE.OBJLoader2 = {} }
...
@@ -15,7 +15,7 @@ if ( THREE.OBJLoader2 === undefined ) { THREE.OBJLoader2 = {} }
*/
*/
THREE
.
OBJLoader2
.
WWOBJLoader2
=
(
function
()
{
THREE
.
OBJLoader2
.
WWOBJLoader2
=
(
function
()
{
var
WWOBJLOADER2_VERSION
=
'
1.
3.1
'
;
var
WWOBJLOADER2_VERSION
=
'
1.
4.0
'
;
var
Validator
=
THREE
.
OBJLoader2
.
prototype
.
_getValidator
();
var
Validator
=
THREE
.
OBJLoader2
.
prototype
.
_getValidator
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录