Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
4e77cbe2
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,发现更多精彩内容 >>
提交
4e77cbe2
编写于
7月 10, 2019
作者:
K
Kai Salmen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CodeSerializer: Clean, update doc and typescript definitions
General: Align js docs and ts signature files
上级
8d04711f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
100 addition
and
42 deletion
+100
-42
examples/jsm/loaders/OBJLoader2.d.ts
examples/jsm/loaders/OBJLoader2.d.ts
+2
-1
examples/jsm/loaders/obj2/bridge/MtlObjBridge.d.ts
examples/jsm/loaders/obj2/bridge/MtlObjBridge.d.ts
+5
-1
examples/jsm/loaders/obj2/utils/CodeSerializer.js
examples/jsm/loaders/obj2/utils/CodeSerializer.js
+93
-40
未找到文件。
examples/jsm/loaders/OBJLoader2.d.ts
浏览文件 @
4e77cbe2
import
{
LoadingManager
,
Group
Group
,
Object3D
}
from
'
../../../src/Three
'
;
import
{
MaterialHandler
}
from
'
./obj2/shared/MaterialHandler
'
;
...
...
examples/jsm/loaders/obj2/bridge/MtlObjBridge.d.ts
浏览文件 @
4e77cbe2
import
{
MaterialCreator
}
from
'
../../MTLLoader
'
;
export
namespace
MtlObjBridge
{
export
function
link
(
processResult
:
object
,
assetLoader
:
object
):
void
;
export
function
addMaterialsFromMtlLoader
(
materialCreator
:
object
):
void
;
export
function
addMaterialsFromMtlLoader
(
materialCreator
:
MaterialCreator
):
void
;
}
examples/jsm/loaders/obj2/utils/CodeSerializer.js
浏览文件 @
4e77cbe2
...
...
@@ -6,10 +6,11 @@
const
CodeSerializer
=
{
/**
* Serialize an object without specific prototype definition.
*
* @param
fullN
ame
* @param
object
* @returns {
s
tring}
* @param
{String} fullName complete object n
ame
* @param
{Object} object The object that should be serialized
* @returns {
S
tring}
*/
serializeObject
:
function
(
fullName
,
object
)
{
...
...
@@ -47,23 +48,23 @@ const CodeSerializer = {
},
/**
* Serialize an object with specific prototype definition.
*
* @param fullName
* @param object
* @param basePrototypeName
* @param ignoreFunctions
* @returns {string}
* @param {String} fullName complete object name
* @param {Object} object The object that should be serialized
* @param {String} constructorName
* @param {String} basePrototypeName
* @param {Object} overrideFunctions Object of {@Link OverrideFunctionDescription}
* @returns {String}
*/
serializeClass
:
function
(
fullName
,
object
,
constructorName
,
basePrototypeName
,
ignoreFunctions
,
includeFunctions
,
overrideFunctions
)
{
serializeClass
:
function
(
fullName
,
object
,
constructorName
,
basePrototypeName
,
overrideFunctions
)
{
let
valueString
,
objectPart
,
constructorString
,
i
,
funcOverride
;
let
valueString
,
objectPart
,
constructorString
,
i
,
funcOverride
,
currentName
;
let
prototypeFunctions
=
[];
let
objectProperties
=
[];
let
objectFunctions
=
[];
let
isExtended
=
(
basePrototypeName
!==
null
&&
basePrototypeName
!==
undefined
);
if
(
!
Array
.
isArray
(
ignoreFunctions
)
)
ignoreFunctions
=
[];
if
(
!
Array
.
isArray
(
includeFunctions
)
)
includeFunctions
=
null
;
if
(
!
Array
.
isArray
(
overrideFunctions
)
)
overrideFunctions
=
[];
for
(
let
name
in
object
.
prototype
)
{
...
...
@@ -76,23 +77,20 @@ const CodeSerializer = {
}
else
if
(
typeof
objectPart
===
'
function
'
)
{
if
(
ignoreFunctions
.
indexOf
(
name
)
<
0
&&
(
includeFunctions
===
null
||
includeFunctions
.
indexOf
(
name
)
>=
0
)
)
{
currentName
=
fullName
+
'
.prototype.
'
+
name
;
funcOverride
=
overrideFunctions
[
name
];
if
(
funcOverride
instanceof
OverrideFunctionInstruction
&&
funcOverride
.
getFullName
()
===
currentName
)
{
funcOverride
=
overrideFunctions
[
name
];
if
(
funcOverride
&&
funcOverride
.
fullName
===
fullName
+
'
.prototype.
'
+
name
)
{
valueString
=
funcOverride
.
code
;
valueString
=
funcOverride
.
code
;
}
if
(
isExtended
)
{
prototypeFunctions
.
push
(
fullName
+
'
.prototype.
'
+
name
+
'
=
'
+
valueString
+
'
;
\n\n
'
);
}
if
(
isExtended
)
{
}
else
{
prototypeFunctions
.
push
(
currentName
+
'
=
'
+
valueString
+
'
;
\n\n
'
);
prototypeFunctions
.
push
(
'
\t
'
+
name
+
'
:
'
+
valueString
+
'
,
\n\n
'
);
}
else
{
}
prototypeFunctions
.
push
(
'
\t
'
+
name
+
'
:
'
+
valueString
+
'
,
\n\n
'
);
}
...
...
@@ -102,24 +100,21 @@ const CodeSerializer = {
for
(
let
name
in
object
)
{
objectPart
=
object
[
name
];
currentName
=
fullName
+
'
.
'
+
name
;
if
(
typeof
objectPart
===
'
function
'
)
{
if
(
ignoreFunctions
.
indexOf
(
name
)
<
0
&&
(
includeFunctions
===
null
||
includeFunctions
.
indexOf
(
name
)
>=
0
)
)
{
funcOverride
=
overrideFunctions
[
name
];
if
(
funcOverride
&&
funcOverride
.
fullName
===
fullName
+
'
.
'
+
name
)
{
valueString
=
funcOverride
.
code
;
funcOverride
=
overrideFunctions
[
name
];
if
(
funcOverride
instanceof
OverrideFunctionInstruction
&&
funcOverride
.
getFullName
()
===
currentName
)
{
}
else
{
valueString
=
funcOverride
.
getFunctionCode
();
valueString
=
objectPart
.
toString
();
}
else
{
}
objectFunctions
.
push
(
fullName
+
'
.
'
+
name
+
'
=
'
+
valueString
+
'
;
\n\n
'
);
valueString
=
objectPart
.
toString
();
}
objectFunctions
.
push
(
currentName
+
'
=
'
+
valueString
+
'
;
\n\n
'
);
}
else
{
...
...
@@ -137,7 +132,7 @@ const CodeSerializer = {
valueString
=
objectPart
;
}
objectProperties
.
push
(
fullName
+
'
.
'
+
n
ame
+
'
=
'
+
valueString
+
'
;
\n
'
);
objectProperties
.
push
(
currentN
ame
+
'
=
'
+
valueString
+
'
;
\n
'
);
}
...
...
@@ -156,20 +151,36 @@ const CodeSerializer = {
objectString
+=
fullName
+
'
.prototype.constructor =
'
+
fullName
+
'
;
\n
'
;
objectString
+=
'
\n\n
'
;
for
(
i
=
0
;
i
<
objectProperties
.
length
;
i
++
)
objectString
+=
objectProperties
[
i
];
for
(
i
=
0
;
i
<
objectProperties
.
length
;
i
++
)
{
objectString
+=
objectProperties
[
i
];
}
objectString
+=
'
\n\n
'
;
for
(
i
=
0
;
i
<
objectFunctions
.
length
;
i
++
)
objectString
+=
objectFunctions
[
i
];
for
(
i
=
0
;
i
<
objectFunctions
.
length
;
i
++
)
{
objectString
+=
objectFunctions
[
i
];
}
objectString
+=
'
\n\n
'
;
if
(
isExtended
)
{
for
(
i
=
0
;
i
<
prototypeFunctions
.
length
;
i
++
)
objectString
+=
prototypeFunctions
[
i
];
for
(
i
=
0
;
i
<
prototypeFunctions
.
length
;
i
++
)
{
objectString
+=
prototypeFunctions
[
i
];
}
}
else
{
objectString
+=
fullName
+
'
.prototype = {
\n\n
'
;
for
(
i
=
0
;
i
<
prototypeFunctions
.
length
;
i
++
)
objectString
+=
prototypeFunctions
[
i
];
for
(
i
=
0
;
i
<
prototypeFunctions
.
length
;
i
++
)
{
objectString
+=
prototypeFunctions
[
i
];
}
objectString
+=
'
\n
};
'
;
}
...
...
@@ -180,4 +191,46 @@ const CodeSerializer = {
},
};
export
{
CodeSerializer
};
/**
*
* @param {String} fullName
* @param {String} functionCode
* @constructor
*/
const
OverrideFunctionInstruction
=
function
(
fullName
,
functionCode
)
{
this
.
fullName
=
fullName
;
this
.
functionCode
=
functionCode
;
};
OverrideFunctionInstruction
.
prototype
=
{
constructor
:
OverrideFunctionInstruction
,
/**
* Returns the full name of the function
* @return {String}
*/
getFullName
:
function
()
{
return
this
.
fullName
;
},
/**
* Returns the serialized function code
* @return {String}
*/
getFunctionCode
:
function
()
{
return
this
.
functionCode
;
}
};
export
{
CodeSerializer
,
OverrideFunctionInstruction
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录