Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
770991cf
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,发现更多精彩内容 >>
提交
770991cf
编写于
12月 17, 2017
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
https://github.com/mrdoob/three.js
into dev
上级
5af8b450
e025c48c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
82 addition
and
127 deletion
+82
-127
examples/js/loaders/LoaderSupport.js
examples/js/loaders/LoaderSupport.js
+11
-3
examples/js/loaders/OBJLoader2.js
examples/js/loaders/OBJLoader2.js
+65
-117
examples/webgl_loader_obj2.html
examples/webgl_loader_obj2.html
+2
-4
examples/webgl_loader_obj2_options.html
examples/webgl_loader_obj2_options.html
+4
-3
未找到文件。
examples/js/loaders/LoaderSupport.js
浏览文件 @
770991cf
...
@@ -277,7 +277,7 @@ THREE.LoaderSupport.ResourceDescriptor = (function () {
...
@@ -277,7 +277,7 @@ THREE.LoaderSupport.ResourceDescriptor = (function () {
if
(
urlParts
.
length
<
2
)
{
if
(
urlParts
.
length
<
2
)
{
this
.
path
=
null
;
this
.
path
=
null
;
this
.
name
=
this
.
name
=
url
;
this
.
name
=
url
;
this
.
url
=
url
;
this
.
url
=
url
;
}
else
{
}
else
{
...
@@ -989,7 +989,7 @@ THREE.LoaderSupport.WorkerRunnerRefImpl = (function () {
...
@@ -989,7 +989,7 @@ THREE.LoaderSupport.WorkerRunnerRefImpl = (function () {
*/
*/
THREE
.
LoaderSupport
.
WorkerSupport
=
(
function
()
{
THREE
.
LoaderSupport
.
WorkerSupport
=
(
function
()
{
var
WORKER_SUPPORT_VERSION
=
'
2.0.
0
'
;
var
WORKER_SUPPORT_VERSION
=
'
2.0.
1
'
;
var
Validator
=
THREE
.
LoaderSupport
.
Validator
;
var
Validator
=
THREE
.
LoaderSupport
.
Validator
;
...
@@ -1110,7 +1110,15 @@ THREE.LoaderSupport.WorkerSupport = (function () {
...
@@ -1110,7 +1110,15 @@ THREE.LoaderSupport.WorkerSupport = (function () {
LoaderWorker
.
prototype
.
_postMessage
=
function
()
{
LoaderWorker
.
prototype
.
_postMessage
=
function
()
{
if
(
Validator
.
isValid
(
this
.
queuedMessage
)
&&
Validator
.
isValid
(
this
.
worker
)
)
{
if
(
Validator
.
isValid
(
this
.
queuedMessage
)
&&
Validator
.
isValid
(
this
.
worker
)
)
{
this
.
worker
.
postMessage
(
this
.
queuedMessage
);
if
(
this
.
queuedMessage
.
data
.
input
instanceof
ArrayBuffer
)
{
this
.
worker
.
postMessage
(
this
.
queuedMessage
,
[
this
.
queuedMessage
.
data
.
input
]
);
}
else
{
this
.
worker
.
postMessage
(
this
.
queuedMessage
);
}
}
}
};
};
...
...
examples/js/loaders/OBJLoader2.js
浏览文件 @
770991cf
...
@@ -18,7 +18,7 @@ if ( THREE.LoaderSupport === undefined ) console.error( '"THREE.LoaderSupport" i
...
@@ -18,7 +18,7 @@ if ( THREE.LoaderSupport === undefined ) console.error( '"THREE.LoaderSupport" i
*/
*/
THREE
.
OBJLoader2
=
(
function
()
{
THREE
.
OBJLoader2
=
(
function
()
{
var
OBJLOADER2_VERSION
=
'
2.2.
0
'
;
var
OBJLOADER2_VERSION
=
'
2.2.
1
'
;
var
LoaderBase
=
THREE
.
LoaderSupport
.
LoaderBase
;
var
LoaderBase
=
THREE
.
LoaderSupport
.
LoaderBase
;
var
Validator
=
THREE
.
LoaderSupport
.
Validator
;
var
Validator
=
THREE
.
LoaderSupport
.
Validator
;
var
ConsoleLogger
=
THREE
.
LoaderSupport
.
ConsoleLogger
;
var
ConsoleLogger
=
THREE
.
LoaderSupport
.
ConsoleLogger
;
...
@@ -297,8 +297,7 @@ THREE.OBJLoader2 = (function () {
...
@@ -297,8 +297,7 @@ THREE.OBJLoader2 = (function () {
input
:
content
,
input
:
content
,
options
:
null
options
:
null
}
}
},
}
[
content
.
buffer
]
);
);
};
};
...
@@ -354,7 +353,6 @@ THREE.OBJLoader2 = (function () {
...
@@ -354,7 +353,6 @@ THREE.OBJLoader2 = (function () {
};
};
this
.
logger
=
new
ConsoleLogger
();
this
.
logger
=
new
ConsoleLogger
();
this
.
totalBytes
=
0
;
this
.
totalBytes
=
0
;
this
.
reachedFaces
=
false
;
};
};
Parser
.
prototype
.
setUseAsync
=
function
(
useAsync
)
{
Parser
.
prototype
.
setUseAsync
=
function
(
useAsync
)
{
...
@@ -560,28 +558,7 @@ THREE.OBJLoader2 = (function () {
...
@@ -560,28 +558,7 @@ THREE.OBJLoader2 = (function () {
switch
(
buffer
[
0
]
)
{
switch
(
buffer
[
0
]
)
{
case
Consts
.
LINE_V
:
case
Consts
.
LINE_V
:
// object complete instance required if reached faces already (= reached next block of v)
this
.
rawMesh
.
pushVertex
(
buffer
,
bufferPointer
>
4
);
if
(
this
.
reachedFaces
)
{
if
(
this
.
rawMesh
.
colors
.
length
>
0
&&
this
.
rawMesh
.
colors
.
length
!==
this
.
rawMesh
.
vertices
.
length
)
{
throw
'
Vertex Colors were detected, but vertex count and color count do not match!
'
;
}
// only when new vertices after faces are detected complete new mesh is prepared (reset offsets, etc)
this
.
processCompletedMesh
(
this
.
rawMesh
.
objectName
,
this
.
rawMesh
.
groupName
,
currentByte
,
true
);
this
.
reachedFaces
=
false
;
}
if
(
bufferPointer
===
4
)
{
this
.
rawMesh
.
pushVertex
(
buffer
)
}
else
{
this
.
rawMesh
.
pushVertexAndVertextColors
(
buffer
);
}
break
;
break
;
case
Consts
.
LINE_VT
:
case
Consts
.
LINE_VT
:
...
@@ -593,7 +570,6 @@ THREE.OBJLoader2 = (function () {
...
@@ -593,7 +570,6 @@ THREE.OBJLoader2 = (function () {
break
;
break
;
case
Consts
.
LINE_F
:
case
Consts
.
LINE_F
:
this
.
reachedFaces
=
true
;
this
.
rawMesh
.
processFaces
(
buffer
,
bufferPointer
,
countSlashes
(
slashSpacePattern
,
slashSpacePatternPointer
)
);
this
.
rawMesh
.
processFaces
(
buffer
,
bufferPointer
,
countSlashes
(
slashSpacePattern
,
slashSpacePatternPointer
)
);
break
;
break
;
...
@@ -607,12 +583,15 @@ THREE.OBJLoader2 = (function () {
...
@@ -607,12 +583,15 @@ THREE.OBJLoader2 = (function () {
break
;
break
;
case
Consts
.
LINE_G
:
case
Consts
.
LINE_G
:
this
.
processCompletedMesh
(
this
.
rawMesh
.
objectName
,
concatStringBuffer
(
buffer
,
bufferPointer
,
slashSpacePattern
),
currentByte
,
false
);
// 'g' leads to creation of mesh if valid data (faces declaration was done before), otherwise only groupName gets set
this
.
processCompletedMesh
(
currentByte
);
this
.
rawMesh
.
pushGroup
(
concatStringBuffer
(
buffer
,
bufferPointer
,
slashSpacePattern
)
);
flushStringBuffer
(
buffer
,
bufferPointer
);
flushStringBuffer
(
buffer
,
bufferPointer
);
break
;
break
;
case
Consts
.
LINE_O
:
case
Consts
.
LINE_O
:
this
.
processCompletedMesh
(
concatStringBuffer
(
buffer
,
bufferPointer
,
slashSpacePattern
),
this
.
rawMesh
.
groupName
,
currentByte
,
false
);
// 'o' is pure meta-information and does not result in creation of new meshes
this
.
rawMesh
.
pushObject
(
concatStringBuffer
(
buffer
,
bufferPointer
,
slashSpacePattern
)
);
flushStringBuffer
(
buffer
,
bufferPointer
);
flushStringBuffer
(
buffer
,
bufferPointer
);
break
;
break
;
...
@@ -645,43 +624,40 @@ THREE.OBJLoader2 = (function () {
...
@@ -645,43 +624,40 @@ THREE.OBJLoader2 = (function () {
'
\n\t
Real RawMeshSubGroup count:
'
+
report
.
subGroups
;
'
\n\t
Real RawMeshSubGroup count:
'
+
report
.
subGroups
;
};
};
Parser
.
prototype
.
processCompletedMesh
=
function
(
objectName
,
groupName
,
currentByte
,
beginNewObject
)
{
Parser
.
prototype
.
processCompletedMesh
=
function
(
currentByte
)
{
var
result
=
this
.
rawMesh
.
finalize
();
var
result
=
this
.
rawMesh
.
finalize
();
if
(
Validator
.
isValid
(
result
)
)
{
if
(
Validator
.
isValid
(
result
)
)
{
this
.
inputObjectCount
++
;
if
(
this
.
rawMesh
.
colors
.
length
>
0
&&
this
.
rawMesh
.
colors
.
length
!==
this
.
rawMesh
.
vertices
.
length
)
{
throw
'
Vertex Colors were detected, but vertex count and color count do not match!
'
;
}
if
(
this
.
logger
.
isDebug
()
)
this
.
logger
.
logDebug
(
this
.
createRawMeshReport
(
this
.
rawMesh
,
this
.
inputObjectCount
)
);
if
(
this
.
logger
.
isDebug
()
)
this
.
logger
.
logDebug
(
this
.
createRawMeshReport
(
this
.
rawMesh
,
this
.
inputObjectCount
)
);
this
.
inputObjectCount
++
;
this
.
buildMesh
(
result
,
currentByte
);
this
.
buildMesh
(
result
,
currentByte
);
var
progressBytesPercent
=
currentByte
/
this
.
totalBytes
;
var
progressBytesPercent
=
currentByte
/
this
.
totalBytes
;
this
.
callbackProgress
(
'
Completed [o:
'
+
this
.
rawMesh
.
objectName
+
'
g:
'
+
this
.
rawMesh
.
groupName
+
'
] Total progress:
'
+
(
progressBytesPercent
*
100
).
toFixed
(
2
)
+
'
%
'
,
progressBytesPercent
);
this
.
callbackProgress
(
'
Completed [o:
'
+
this
.
rawMesh
.
objectName
+
'
g:
'
+
this
.
rawMesh
.
groupName
+
'
] Total progress:
'
+
(
progressBytesPercent
*
100
).
toFixed
(
2
)
+
'
%
'
,
progressBytesPercent
);
this
.
rawMesh
=
beginNewObject
?
this
.
rawMesh
.
newInstanceResetOffsets
()
:
this
.
rawMesh
.
newInstanceKeepOffsets
(
);
this
.
rawMesh
.
reset
(
this
.
rawMesh
.
smoothingGroup
.
splitMaterials
);
return
true
;
}
else
{
return
false
;
}
}
// Always update group an object name in case they have changed and are valid
if
(
this
.
rawMesh
.
objectName
!==
objectName
&&
Validator
.
isValid
(
objectName
)
)
this
.
rawMesh
.
pushObject
(
objectName
);
if
(
this
.
rawMesh
.
groupName
!==
groupName
&&
Validator
.
isValid
(
groupName
)
)
this
.
rawMesh
.
pushGroup
(
groupName
);
};
};
Parser
.
prototype
.
finalize
=
function
(
currentByte
)
{
Parser
.
prototype
.
finalize
=
function
(
currentByte
)
{
this
.
logger
.
logInfo
(
'
Global output object count:
'
+
this
.
outputObjectCount
);
this
.
logger
.
logInfo
(
'
Global output object count:
'
+
this
.
outputObjectCount
);
var
result
=
Validator
.
isValid
(
this
.
rawMesh
)
?
this
.
rawMesh
.
finalize
()
:
null
;
if
(
this
.
processCompletedMesh
(
currentByte
)
&&
this
.
logger
.
isEnabled
()
)
{
if
(
Validator
.
isValid
(
result
)
)
{
this
.
inputObjectCount
++
;
if
(
this
.
logger
.
isDebug
()
)
this
.
logger
.
logDebug
(
this
.
createRawMeshReport
(
this
.
rawMesh
,
this
.
inputObjectCount
)
);
this
.
buildMesh
(
result
,
currentByte
);
if
(
this
.
logger
.
isEnabled
()
)
{
var
parserFinalReport
=
'
Overall counts:
'
+
'
\n\t
Vertices:
'
+
this
.
counts
.
vertices
+
'
\n\t
Faces:
'
+
this
.
counts
.
faces
+
'
\n\t
Multiple definitions:
'
+
this
.
counts
.
doubleIndicesCount
;
this
.
logger
.
logInfo
(
parserFinalReport
);
}
var
parserFinalReport
=
'
Overall counts:
'
+
var
progressBytesPercent
=
currentByte
/
this
.
totalBytes
;
'
\n\t
Vertices:
'
+
this
.
counts
.
vertices
+
this
.
callbackProgress
(
'
Completed Parsing: 100.00%
'
,
progressBytesPercent
);
'
\n\t
Faces:
'
+
this
.
counts
.
faces
+
'
\n\t
Multiple definitions:
'
+
this
.
counts
.
doubleIndicesCount
;
this
.
logger
.
logInfo
(
parserFinalReport
);
}
}
};
};
...
@@ -836,11 +812,11 @@ THREE.OBJLoader2 = (function () {
...
@@ -836,11 +812,11 @@ THREE.OBJLoader2 = (function () {
if
(
this
.
logger
.
isDebug
()
)
{
if
(
this
.
logger
.
isDebug
()
)
{
var
materialIndexLine
=
Validator
.
isValid
(
selectedMaterialIndex
)
?
'
\n\t\t
materialIndex:
'
+
selectedMaterialIndex
:
''
;
var
materialIndexLine
=
Validator
.
isValid
(
selectedMaterialIndex
)
?
'
\n\t\t
materialIndex:
'
+
selectedMaterialIndex
:
''
;
var
createdReport
=
'
Output Object no.:
'
+
this
.
outputObjectCount
+
var
createdReport
=
'
Output Object no.:
'
+
this
.
outputObjectCount
+
'
\n\t\t
objectName:
'
+
rawObjectDescription
.
objectName
+
'
\n\t\t
groupName:
'
+
rawObjectDescription
.
groupName
+
'
\n\t\t
groupName:
'
+
rawObjectDescription
.
groupName
+
'
\n\t\t
materialName:
'
+
rawObjectDescription
.
materialName
+
materialIndexLine
+
materialIndexLine
+
'
\n\t\t
materialName:
'
+
rawObjectDescription
.
materialName
+
'
\n\t\t
smoothingGroup:
'
+
rawObjectDescription
.
smoothingGroup
+
'
\n\t\t
smoothingGroup:
'
+
rawObjectDescription
.
smoothingGroup
+
'
\n\t\t
objectName:
'
+
rawObjectDescription
.
objectName
+
'
\n\t\t
#vertices:
'
+
rawObjectDescription
.
vertices
.
length
/
3
+
'
\n\t\t
#vertices:
'
+
rawObjectDescription
.
vertices
.
length
/
3
+
'
\n\t\t
#indices:
'
+
rawObjectDescription
.
indices
.
length
+
'
\n\t\t
#indices:
'
+
rawObjectDescription
.
indices
.
length
+
'
\n\t\t
#colors:
'
+
rawObjectDescription
.
colors
.
length
/
3
+
'
\n\t\t
#colors:
'
+
rawObjectDescription
.
colors
.
length
/
3
+
...
@@ -892,82 +868,51 @@ THREE.OBJLoader2 = (function () {
...
@@ -892,82 +868,51 @@ THREE.OBJLoader2 = (function () {
*/
*/
var
RawMesh
=
(
function
()
{
var
RawMesh
=
(
function
()
{
function
RawMesh
(
materialPerSmoothingGroup
,
useIndices
,
disregardNormals
,
activeMtlName
)
{
function
RawMesh
(
materialPerSmoothingGroup
,
useIndices
,
disregardNormals
)
{
this
.
globalVertexOffset
=
1
;
this
.
globalUvOffset
=
1
;
this
.
globalNormalOffset
=
1
;
this
.
vertices
=
[];
this
.
vertices
=
[];
this
.
colors
=
[];
this
.
colors
=
[];
this
.
normals
=
[];
this
.
normals
=
[];
this
.
uvs
=
[];
this
.
uvs
=
[];
// faces are stored according combined index of group, material and smoothingGroup (0 or not)
this
.
useIndices
=
useIndices
===
true
;
this
.
activeMtlName
=
Validator
.
verifyInput
(
activeMtlName
,
''
);
this
.
disregardNormals
=
disregardNormals
===
true
;
this
.
objectName
=
''
;
this
.
objectName
=
''
;
this
.
groupName
=
''
;
this
.
groupName
=
''
;
this
.
activeMtlName
=
''
;
this
.
mtllibName
=
''
;
this
.
mtllibName
=
''
;
this
.
reset
(
materialPerSmoothingGroup
);
}
RawMesh
.
prototype
.
reset
=
function
(
materialPerSmoothingGroup
)
{
// faces are stored according combined index of group, material and smoothingGroup (0 or not)
this
.
subGroups
=
[];
this
.
subGroupInUse
=
null
;
this
.
smoothingGroup
=
{
this
.
smoothingGroup
=
{
splitMaterials
:
materialPerSmoothingGroup
===
true
,
splitMaterials
:
materialPerSmoothingGroup
===
true
,
normalized
:
-
1
,
normalized
:
-
1
,
real
:
-
1
real
:
-
1
};
};
this
.
useIndices
=
useIndices
===
true
;
this
.
disregardNormals
=
disregardNormals
===
true
;
this
.
mtlCount
=
0
;
this
.
smoothingGroupCount
=
0
;
this
.
subGroups
=
[];
this
.
subGroupInUse
=
null
;
// this default index is required as it is possible to define faces without 'g' or 'usemtl'
// this default index is required as it is possible to define faces without 'g' or 'usemtl'
this
.
pushSmoothingGroup
(
1
);
this
.
pushSmoothingGroup
(
1
);
this
.
doubleIndicesCount
=
0
;
this
.
doubleIndicesCount
=
0
;
this
.
faceCount
=
0
;
this
.
faceCount
=
0
;
}
this
.
mtlCount
=
0
;
this
.
smoothingGroupCount
=
0
;
RawMesh
.
prototype
.
newInstanceResetOffsets
=
function
()
{
var
newRawObject
=
new
RawMesh
(
this
.
smoothingGroup
.
splitMaterials
,
this
.
useIndices
,
this
.
disregardNormals
,
this
.
activeMtlName
);
// move indices forward
newRawObject
.
globalVertexOffset
=
this
.
globalVertexOffset
+
this
.
vertices
.
length
/
3
;
newRawObject
.
globalUvOffset
=
this
.
globalUvOffset
+
this
.
uvs
.
length
/
2
;
newRawObject
.
globalNormalOffset
=
this
.
globalNormalOffset
+
this
.
normals
.
length
/
3
;
return
newRawObject
;
};
RawMesh
.
prototype
.
newInstanceKeepOffsets
=
function
()
{
var
newRawObject
=
new
RawMesh
(
this
.
smoothingGroup
.
splitMaterials
,
this
.
useIndices
,
this
.
disregardNormals
,
this
.
activeMtlName
);
// keep objectName
newRawObject
.
pushObject
(
this
.
objectName
);
// keep current buffers and indices forward
newRawObject
.
vertices
=
this
.
vertices
;
newRawObject
.
colors
=
this
.
colors
;
newRawObject
.
uvs
=
this
.
uvs
;
newRawObject
.
normals
=
this
.
normals
;
newRawObject
.
globalVertexOffset
=
this
.
globalVertexOffset
;
newRawObject
.
globalUvOffset
=
this
.
globalUvOffset
;
newRawObject
.
globalNormalOffset
=
this
.
globalNormalOffset
;
return
newRawObject
;
};
};
RawMesh
.
prototype
.
pushVertex
=
function
(
buffer
)
{
RawMesh
.
prototype
.
pushVertex
=
function
(
buffer
,
haveVertexColors
)
{
this
.
vertices
.
push
(
parseFloat
(
buffer
[
1
]
)
);
this
.
vertices
.
push
(
parseFloat
(
buffer
[
1
]
)
);
this
.
vertices
.
push
(
parseFloat
(
buffer
[
2
]
)
);
this
.
vertices
.
push
(
parseFloat
(
buffer
[
2
]
)
);
this
.
vertices
.
push
(
parseFloat
(
buffer
[
3
]
)
);
this
.
vertices
.
push
(
parseFloat
(
buffer
[
3
]
)
);
};
if
(
haveVertexColors
)
{
RawMesh
.
prototype
.
pushVertexAndVertextColors
=
function
(
buffer
)
{
this
.
colors
.
push
(
parseFloat
(
buffer
[
4
]
)
);
this
.
vertices
.
push
(
parseFloat
(
buffer
[
1
]
)
);
this
.
colors
.
push
(
parseFloat
(
buffer
[
5
]
)
);
this
.
vertices
.
push
(
parseFloat
(
buffer
[
2
]
)
);
this
.
colors
.
push
(
parseFloat
(
buffer
[
6
]
)
);
this
.
vertices
.
push
(
parseFloat
(
buffer
[
3
]
)
);
this
.
colors
.
push
(
parseFloat
(
buffer
[
4
]
)
);
}
this
.
colors
.
push
(
parseFloat
(
buffer
[
5
]
)
);
this
.
colors
.
push
(
parseFloat
(
buffer
[
6
]
)
);
};
};
RawMesh
.
prototype
.
pushUv
=
function
(
buffer
)
{
RawMesh
.
prototype
.
pushUv
=
function
(
buffer
)
{
...
@@ -981,6 +926,10 @@ THREE.OBJLoader2 = (function () {
...
@@ -981,6 +926,10 @@ THREE.OBJLoader2 = (function () {
this
.
normals
.
push
(
parseFloat
(
buffer
[
3
]
)
);
this
.
normals
.
push
(
parseFloat
(
buffer
[
3
]
)
);
};
};
RawMesh
.
prototype
.
pushGroup
=
function
(
groupName
)
{
this
.
groupName
=
Validator
.
verifyInput
(
groupName
,
''
);
};
RawMesh
.
prototype
.
pushObject
=
function
(
objectName
)
{
RawMesh
.
prototype
.
pushObject
=
function
(
objectName
)
{
this
.
objectName
=
Validator
.
verifyInput
(
objectName
,
''
);
this
.
objectName
=
Validator
.
verifyInput
(
objectName
,
''
);
};
};
...
@@ -989,10 +938,6 @@ THREE.OBJLoader2 = (function () {
...
@@ -989,10 +938,6 @@ THREE.OBJLoader2 = (function () {
this
.
mtllibName
=
Validator
.
verifyInput
(
mtllibName
,
''
);
this
.
mtllibName
=
Validator
.
verifyInput
(
mtllibName
,
''
);
};
};
RawMesh
.
prototype
.
pushGroup
=
function
(
groupName
)
{
this
.
groupName
=
Validator
.
verifyInput
(
groupName
,
''
);
};
RawMesh
.
prototype
.
pushUsemtl
=
function
(
mtlName
)
{
RawMesh
.
prototype
.
pushUsemtl
=
function
(
mtlName
)
{
if
(
this
.
activeMtlName
===
mtlName
||
!
Validator
.
isValid
(
mtlName
)
)
return
;
if
(
this
.
activeMtlName
===
mtlName
||
!
Validator
.
isValid
(
mtlName
)
)
return
;
this
.
activeMtlName
=
mtlName
;
this
.
activeMtlName
=
mtlName
;
...
@@ -1037,7 +982,7 @@ THREE.OBJLoader2 = (function () {
...
@@ -1037,7 +982,7 @@ THREE.OBJLoader2 = (function () {
// "f vertex ..."
// "f vertex ..."
if
(
slashesCount
===
0
)
{
if
(
slashesCount
===
0
)
{
for
(
i
=
2
,
length
=
bufferLength
-
1
;
i
<
length
;
i
++
)
{
for
(
i
=
2
,
length
=
bufferLength
;
i
<
length
;
i
++
)
{
this
.
buildFace
(
buffer
[
1
]
);
this
.
buildFace
(
buffer
[
1
]
);
this
.
buildFace
(
buffer
[
i
]
);
this
.
buildFace
(
buffer
[
i
]
);
...
@@ -1081,20 +1026,22 @@ THREE.OBJLoader2 = (function () {
...
@@ -1081,20 +1026,22 @@ THREE.OBJLoader2 = (function () {
}
}
};
};
RawMesh
.
prototype
.
buildFace
=
function
(
faceIndexV
,
faceIndexU
,
faceIndexN
)
{
RawMesh
.
prototype
.
buildFace
=
function
(
faceIndexV
,
faceIndexU
,
faceIndexN
)
{
var
sgiu
=
this
.
subGroupInUse
;
var
sgiu
=
this
.
subGroupInUse
;
if
(
this
.
disregardNormals
)
faceIndexN
=
undefined
;
if
(
this
.
disregardNormals
)
faceIndexN
=
undefined
;
var
scope
=
this
;
var
scope
=
this
;
var
updateRawObjectDescriptionInUse
=
function
()
{
var
updateRawObjectDescriptionInUse
=
function
()
{
var
indexPointerV
=
(
parseInt
(
faceIndexV
)
-
scope
.
globalVertexOffset
)
*
3
;
var
faceIndexVi
=
parseInt
(
faceIndexV
)
;
var
indexPointer
C
=
scope
.
colors
.
length
>
0
?
indexPointerV
:
null
;
var
indexPointer
V
=
3
*
(
faceIndexVi
>
0
?
faceIndexVi
-
1
:
faceIndexVi
+
scope
.
vertices
.
length
/
3
)
;
var
vertices
=
sgiu
.
vertices
;
var
vertices
=
sgiu
.
vertices
;
vertices
.
push
(
scope
.
vertices
[
indexPointerV
++
]
);
vertices
.
push
(
scope
.
vertices
[
indexPointerV
++
]
);
vertices
.
push
(
scope
.
vertices
[
indexPointerV
++
]
);
vertices
.
push
(
scope
.
vertices
[
indexPointerV
++
]
);
vertices
.
push
(
scope
.
vertices
[
indexPointerV
]
);
vertices
.
push
(
scope
.
vertices
[
indexPointerV
]
);
var
indexPointerC
=
scope
.
colors
.
length
>
0
?
indexPointerV
:
null
;
if
(
indexPointerC
!==
null
)
{
if
(
indexPointerC
!==
null
)
{
var
colors
=
sgiu
.
colors
;
var
colors
=
sgiu
.
colors
;
...
@@ -1106,7 +1053,8 @@ THREE.OBJLoader2 = (function () {
...
@@ -1106,7 +1053,8 @@ THREE.OBJLoader2 = (function () {
if
(
faceIndexU
)
{
if
(
faceIndexU
)
{
var
indexPointerU
=
(
parseInt
(
faceIndexU
)
-
scope
.
globalUvOffset
)
*
2
;
var
faceIndexUi
=
parseInt
(
faceIndexU
);
var
indexPointerU
=
2
*
(
faceIndexUi
>
0
?
faceIndexUi
-
1
:
faceIndexUi
+
scope
.
uvs
.
length
/
2
);
var
uvs
=
sgiu
.
uvs
;
var
uvs
=
sgiu
.
uvs
;
uvs
.
push
(
scope
.
uvs
[
indexPointerU
++
]
);
uvs
.
push
(
scope
.
uvs
[
indexPointerU
++
]
);
uvs
.
push
(
scope
.
uvs
[
indexPointerU
]
);
uvs
.
push
(
scope
.
uvs
[
indexPointerU
]
);
...
@@ -1114,7 +1062,8 @@ THREE.OBJLoader2 = (function () {
...
@@ -1114,7 +1062,8 @@ THREE.OBJLoader2 = (function () {
}
}
if
(
faceIndexN
)
{
if
(
faceIndexN
)
{
var
indexPointerN
=
(
parseInt
(
faceIndexN
)
-
scope
.
globalNormalOffset
)
*
3
;
var
faceIndexNi
=
parseInt
(
faceIndexN
);
var
indexPointerN
=
3
*
(
faceIndexNi
>
0
?
faceIndexNi
-
1
:
faceIndexNi
+
scope
.
normals
.
length
/
3
);
var
normals
=
sgiu
.
normals
;
var
normals
=
sgiu
.
normals
;
normals
.
push
(
scope
.
normals
[
indexPointerN
++
]
);
normals
.
push
(
scope
.
normals
[
indexPointerN
++
]
);
normals
.
push
(
scope
.
normals
[
indexPointerN
++
]
);
normals
.
push
(
scope
.
normals
[
indexPointerN
++
]
);
...
@@ -1348,12 +1297,11 @@ THREE.OBJLoader2 = (function () {
...
@@ -1348,12 +1297,11 @@ THREE.OBJLoader2 = (function () {
* @memberOf THREE.OBJLoader2
* @memberOf THREE.OBJLoader2
*
*
* @param {string} url URL to the file
* @param {string} url URL to the file
* @param {string} name The name of the object
* @param {Object} content The file content as arraybuffer or text
* @param {Object} content The file content as arraybuffer or text
* @param {function} callbackOnLoad
* @param {function} callbackOnLoad
* @param {string} [crossOrigin] CORS value
* @param {string} [crossOrigin] CORS value
*/
*/
OBJLoader2
.
prototype
.
loadMtl
=
function
(
url
,
name
,
content
,
callbackOnLoad
,
crossOrigin
)
{
OBJLoader2
.
prototype
.
loadMtl
=
function
(
url
,
content
,
callbackOnLoad
,
crossOrigin
)
{
var
resource
=
new
THREE
.
LoaderSupport
.
ResourceDescriptor
(
url
,
'
MTL
'
);
var
resource
=
new
THREE
.
LoaderSupport
.
ResourceDescriptor
(
url
,
'
MTL
'
);
resource
.
setContent
(
content
);
resource
.
setContent
(
content
);
this
.
_loadMtl
(
resource
,
callbackOnLoad
,
crossOrigin
);
this
.
_loadMtl
(
resource
,
callbackOnLoad
,
crossOrigin
);
...
...
examples/webgl_loader_obj2.html
浏览文件 @
770991cf
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"en"
>
<html
lang=
"en"
>
<head>
<head>
<title>
three.js webgl - OBJLoader2
</title>
<title>
three.js webgl - OBJLoader2
basic usage
</title>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
>
...
@@ -152,12 +152,10 @@
...
@@ -152,12 +152,10 @@
var
onLoadMtl
=
function
(
materials
)
{
var
onLoadMtl
=
function
(
materials
)
{
objLoader
.
setModelName
(
modelName
);
objLoader
.
setModelName
(
modelName
);
objLoader
.
setMaterials
(
materials
);
objLoader
.
setMaterials
(
materials
);
objLoader
.
setUseIndices
(
true
);
objLoader
.
setDisregardNormals
(
false
);
objLoader
.
getLogger
().
setDebug
(
true
);
objLoader
.
getLogger
().
setDebug
(
true
);
objLoader
.
load
(
'
obj/female02/female02.obj
'
,
callbackOnLoad
,
null
,
null
,
null
,
false
);
objLoader
.
load
(
'
obj/female02/female02.obj
'
,
callbackOnLoad
,
null
,
null
,
null
,
false
);
};
};
objLoader
.
loadMtl
(
'
obj/female02/female02.mtl
'
,
'
female02.mtl
'
,
null
,
onLoadMtl
);
objLoader
.
loadMtl
(
'
obj/female02/female02.mtl
'
,
null
,
onLoadMtl
);
};
};
OBJLoader2Example
.
prototype
.
_reportProgress
=
function
(
event
)
{
OBJLoader2Example
.
prototype
.
_reportProgress
=
function
(
event
)
{
...
...
examples/webgl_loader_obj2_options.html
浏览文件 @
770991cf
...
@@ -178,7 +178,7 @@
...
@@ -178,7 +178,7 @@
}
}
);
);
};
};
objLoader
.
loadMtl
(
'
obj/female02/female02.mtl
'
,
'
female02.mtl
'
,
null
,
onLoadMtl
);
objLoader
.
loadMtl
(
'
obj/female02/female02.mtl
'
,
null
,
onLoadMtl
);
};
};
...
@@ -231,9 +231,10 @@
...
@@ -231,9 +231,10 @@
var
onLoadMtl
=
function
(
materials
)
{
var
onLoadMtl
=
function
(
materials
)
{
objLoader
.
setModelName
(
modelName
);
objLoader
.
setModelName
(
modelName
);
objLoader
.
setMaterials
(
materials
);
objLoader
.
setMaterials
(
materials
);
objLoader
.
setUseIndices
(
true
);
objLoader
.
load
(
'
obj/male02/male02.obj
'
,
callbackOnLoad
,
null
,
null
,
null
,
false
);
objLoader
.
load
(
'
obj/male02/male02.obj
'
,
callbackOnLoad
,
null
,
null
,
null
,
false
);
};
};
objLoader
.
loadMtl
(
'
obj/male02/male02.mtl
'
,
'
female02.mtl
'
,
null
,
onLoadMtl
);
objLoader
.
loadMtl
(
'
obj/male02/male02.mtl
'
,
null
,
onLoadMtl
);
};
};
WWOBJLoader2Example
.
prototype
.
useLoadAsync
=
function
()
{
WWOBJLoader2Example
.
prototype
.
useLoadAsync
=
function
()
{
...
@@ -262,7 +263,7 @@
...
@@ -262,7 +263,7 @@
objLoader
.
terminateWorkerOnLoad
=
false
;
objLoader
.
terminateWorkerOnLoad
=
false
;
objLoader
.
load
(
'
obj/walt/WaltHead.obj
'
,
callbackOnLoad
,
null
,
null
,
null
,
true
);
objLoader
.
load
(
'
obj/walt/WaltHead.obj
'
,
callbackOnLoad
,
null
,
null
,
null
,
true
);
};
};
objLoader
.
loadMtl
(
'
obj/walt/
/WaltHead.mtl
'
,
'
WaltHead.mtl
'
,
null
,
onLoadMtl
);
objLoader
.
loadMtl
(
'
obj/walt/WaltHead.mtl
'
,
null
,
onLoadMtl
);
};
};
WWOBJLoader2Example
.
prototype
.
useRunSync
=
function
()
{
WWOBJLoader2Example
.
prototype
.
useRunSync
=
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录