Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
5516c6f4
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,发现更多精彩内容 >>
未验证
提交
5516c6f4
编写于
1月 11, 2020
作者:
M
Mr.doob
提交者:
GitHub
1月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18356 from kaisalmen/Issue18335
Fixes #18335 CodeSerializer works with uglified code
上级
a2a773ad
7e952c95
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
45 addition
and
74 deletion
+45
-74
examples/jsm/loaders/OBJLoader2Parallel.js
examples/jsm/loaders/OBJLoader2Parallel.js
+10
-11
examples/jsm/loaders/obj2/utils/CodeSerializer.d.ts
examples/jsm/loaders/obj2/utils/CodeSerializer.d.ts
+3
-2
examples/jsm/loaders/obj2/utils/CodeSerializer.js
examples/jsm/loaders/obj2/utils/CodeSerializer.js
+8
-49
examples/jsm/loaders/obj2/worker/parallel/WorkerRunner.d.ts
examples/jsm/loaders/obj2/worker/parallel/WorkerRunner.d.ts
+4
-2
examples/jsm/loaders/obj2/worker/parallel/WorkerRunner.js
examples/jsm/loaders/obj2/worker/parallel/WorkerRunner.js
+10
-3
examples/webgl_loader_obj2_options.html
examples/webgl_loader_obj2_options.html
+10
-7
未找到文件。
examples/jsm/loaders/OBJLoader2Parallel.js
浏览文件 @
5516c6f4
...
...
@@ -97,17 +97,16 @@ OBJLoader2Parallel.prototype = Object.assign( Object.create( OBJLoader2.prototyp
}
if
(
codeBuilderInstructions
.
isSupportsStandardWorker
()
)
{
let
codeOBJLoader2Parser
=
CodeSerializer
.
serializeClass
(
'
OBJLoader2Parser
'
,
OBJLoader2Parser
);
let
codeObjectManipulator
=
CodeSerializer
.
serializeObject
(
'
ObjectManipulator
'
,
ObjectManipulator
);
let
codeParserPayloadHandler
=
CodeSerializer
.
serializeClass
(
'
DefaultWorkerPayloadHandler
'
,
DefaultWorkerPayloadHandler
);
let
codeWorkerRunner
=
CodeSerializer
.
serializeClass
(
'
WorkerRunner
'
,
WorkerRunner
);
codeBuilderInstructions
.
addCodeFragment
(
codeOBJLoader2Parser
);
codeBuilderInstructions
.
addCodeFragment
(
codeObjectManipulator
);
codeBuilderInstructions
.
addCodeFragment
(
codeParserPayloadHandler
);
codeBuilderInstructions
.
addCodeFragment
(
codeWorkerRunner
);
codeBuilderInstructions
.
addStartCode
(
'
new WorkerRunner( new DefaultWorkerPayloadHandler( new OBJLoader2Parser() ) );
'
);
let
objectManipulator
=
new
ObjectManipulator
();
let
defaultWorkerPayloadHandler
=
new
DefaultWorkerPayloadHandler
(
this
.
parser
);
let
workerRunner
=
new
WorkerRunner
(
{}
);
codeBuilderInstructions
.
addCodeFragment
(
CodeSerializer
.
serializeClass
(
OBJLoader2Parser
,
this
.
parser
)
);
codeBuilderInstructions
.
addCodeFragment
(
CodeSerializer
.
serializeClass
(
ObjectManipulator
,
objectManipulator
)
);
codeBuilderInstructions
.
addCodeFragment
(
CodeSerializer
.
serializeClass
(
DefaultWorkerPayloadHandler
,
defaultWorkerPayloadHandler
)
);
codeBuilderInstructions
.
addCodeFragment
(
CodeSerializer
.
serializeClass
(
WorkerRunner
,
workerRunner
)
);
let
startCode
=
'
new
'
+
workerRunner
.
constructor
.
name
+
'
( new
'
+
defaultWorkerPayloadHandler
.
constructor
.
name
+
'
( new
'
+
this
.
parser
.
constructor
.
name
+
'
() ) );
'
;
codeBuilderInstructions
.
addStartCode
(
startCode
);
}
return
codeBuilderInstructions
;
...
...
examples/jsm/loaders/obj2/utils/CodeSerializer.d.ts
浏览文件 @
5516c6f4
export
namespace
CodeSerializer
{
export
function
serializeObject
(
fullName
:
string
,
serializationTarget
:
object
):
string
;
export
function
serializeClass
(
fullObjectName
:
string
,
serializationTarget
:
object
,
basePrototypeName
?:
string
,
overrideFunctions
?:
CodeSerializationInstruction
[]
):
string
;
export
function
serializeClass
(
targetPrototype
:
object
,
targetPrototypeInstance
:
object
,
basePrototypeName
?:
string
,
overrideFunctions
?:
CodeSerializationInstruction
[]
):
string
;
}
export
class
CodeSerializationInstruction
{
...
...
examples/jsm/loaders/obj2/utils/CodeSerializer.js
浏览文件 @
5516c6f4
...
...
@@ -5,61 +5,20 @@
const
CodeSerializer
=
{
/**
* Serialize an object without specific prototype definition.
*
* @param {String} fullObjectName complete object name
* @param {Object} serializationTarget The object that should be serialized
* @returns {String}
*/
serializeObject
:
function
(
fullObjectName
,
serializationTarget
)
{
let
objectString
=
fullObjectName
+
'
= {
\n\n
'
;
let
part
;
for
(
let
name
in
serializationTarget
)
{
part
=
serializationTarget
[
name
];
if
(
typeof
(
part
)
===
'
string
'
||
part
instanceof
String
)
{
part
=
part
.
replace
(
/
\n
/g
,
'
\\
n
'
);
part
=
part
.
replace
(
/
\r
/g
,
'
\\
r
'
);
objectString
+=
'
\t
'
+
name
+
'
: "
'
+
part
+
'
",
\n
'
;
}
else
if
(
part
instanceof
Array
)
{
objectString
+=
'
\t
'
+
name
+
'
: [
'
+
part
+
'
],
\n
'
;
}
else
if
(
typeof
part
===
'
object
'
)
{
console
.
log
(
'
Omitting object "
'
+
name
+
'
" and replace it with empty object.
'
);
objectString
+=
'
\t
'
+
name
+
'
: {},
\n
'
;
}
else
{
objectString
+=
'
\t
'
+
name
+
'
:
'
+
part
+
'
,
\n
'
;
}
}
objectString
+=
'
}
\n\n
'
;
return
objectString
;
},
/**
* Serialize an object with specific prototype definition.
*
* @param {
String} fullObjectName Specifies the complete object name
* @param {Object}
serializationTarget The
object that should be serialized
* @param {
Object} targetPrototype The object that should be serialized
* @param {Object}
targetPrototypeInstance An instance of the ori
object that should be serialized
* @param {String} [basePrototypeName] Name of the prototype
* @param {Object} [overrideFunctions} Array of {@Link CodeSerializationInstruction} allows to replace or remove function with provided content
*
* @returns {String}
*/
serializeClass
:
function
(
fullObjectName
,
serializationTarget
,
basePrototypeName
,
overrideFunctions
)
{
serializeClass
:
function
(
targetPrototype
,
targetPrototypeInstance
,
basePrototypeName
,
overrideFunctions
)
{
let
objectPart
,
constructorString
,
i
,
funcInstructions
,
funcTemp
;
let
fullObjectName
=
targetPrototypeInstance
.
constructor
.
name
;
let
prototypeFunctions
=
[];
let
objectProperties
=
[];
let
objectFunctions
=
[];
...
...
@@ -67,9 +26,9 @@ const CodeSerializer = {
if
(
!
Array
.
isArray
(
overrideFunctions
)
)
overrideFunctions
=
[];
for
(
let
name
in
serializationTarget
.
prototype
)
{
for
(
let
name
in
targetPrototype
.
prototype
)
{
objectPart
=
serializationTarget
.
prototype
[
name
];
objectPart
=
targetPrototype
.
prototype
[
name
];
funcInstructions
=
new
CodeSerializationInstruction
(
name
,
fullObjectName
+
'
.prototype.
'
+
name
);
funcInstructions
.
setCode
(
objectPart
.
toString
()
);
...
...
@@ -106,9 +65,9 @@ const CodeSerializer = {
}
}
for
(
let
name
in
serializationTarget
)
{
for
(
let
name
in
targetPrototype
)
{
objectPart
=
serializationTarget
[
name
];
objectPart
=
targetPrototype
[
name
];
funcInstructions
=
new
CodeSerializationInstruction
(
name
,
fullObjectName
+
'
.
'
+
name
);
if
(
typeof
objectPart
===
'
function
'
)
{
...
...
examples/jsm/loaders/obj2/worker/parallel/WorkerRunner.d.ts
浏览文件 @
5516c6f4
export
namespace
ObjectManipulator
{
export
class
ObjectManipulator
{
export
function
applyProperties
(
objToAlter
:
object
,
params
:
object
,
forceCreation
:
boolean
):
void
;
constructor
();
applyProperties
(
objToAlter
:
object
,
params
:
object
,
forceCreation
:
boolean
):
void
;
}
...
...
examples/jsm/loaders/obj2/worker/parallel/WorkerRunner.js
浏览文件 @
5516c6f4
...
...
@@ -3,13 +3,19 @@
* Development repository: https://github.com/kaisalmen/WWOBJLoader
*/
const
ObjectManipulator
=
{
const
ObjectManipulator
=
function
()
{
};
ObjectManipulator
.
prototype
=
{
constructor
:
ObjectManipulator
,
/**
* Applies values from parameter object via set functions or via direct assignment.
*
* @param {Object} objToAlter The objToAlter instance
* @param {Object} params The parameter object
* @param {boolean} forceCreation Force the creation of a property
*/
applyProperties
:
function
(
objToAlter
,
params
,
forceCreation
)
{
...
...
@@ -81,8 +87,9 @@ DefaultWorkerPayloadHandler.prototype = {
parser
.
setLogging
(
this
.
logging
.
enabled
,
this
.
logging
.
debug
);
}
ObjectManipulator
.
applyProperties
(
parser
,
payload
.
params
,
false
);
ObjectManipulator
.
applyProperties
(
parser
,
callbacks
,
false
);
let
objectManipulator
=
new
ObjectManipulator
();
objectManipulator
.
applyProperties
(
parser
,
payload
.
params
,
false
);
objectManipulator
.
applyProperties
(
parser
,
callbacks
,
false
);
let
arraybuffer
=
payload
.
data
.
input
;
let
executeFunctionName
=
'
execute
'
;
...
...
examples/webgl_loader_obj2_options.html
浏览文件 @
5516c6f4
...
...
@@ -168,9 +168,14 @@
let
modelName
=
'
female02_vertex
'
;
this
.
_reportProgress
(
{
detail
:
{
text
:
'
Loading:
'
+
modelName
}
}
);
let
local
=
new
THREE
.
Object3D
();
local
.
name
=
'
Pivot_female02_vertex
'
;
local
.
position
.
set
(
-
75
,
0
,
0
);
this
.
pivot
.
add
(
local
);
let
scope
=
this
;
function
callbackOnLoad
(
object3d
,
message
)
{
scope
.
scene
.
add
(
object3d
);
local
.
add
(
object3d
);
scope
.
_reportProgress
(
{
detail
:
{
text
:
'
Loading of
'
+
modelName
+
'
completed:
'
+
message
}
}
);
}
...
...
@@ -227,7 +232,7 @@
let
local
=
new
THREE
.
Object3D
();
local
.
name
=
'
Pivot_WaltHead
'
;
local
.
position
.
set
(
-
1
2
5
,
50
,
0
);
local
.
position
.
set
(
-
1
7
5
,
50
,
0
);
let
scale
=
0.5
;
local
.
scale
.
set
(
scale
,
scale
,
scale
);
this
.
pivot
.
add
(
local
);
...
...
@@ -272,8 +277,8 @@
useLoadParallelMeshAlter
:
function
()
{
let
local
=
new
THREE
.
Object3D
();
local
.
position
.
set
(
1
25
,
5
0
,
0
);
local
.
name
=
'
Pivot_
vive-controller
'
;
local
.
position
.
set
(
1
75
,
-
10
0
,
0
);
local
.
name
=
'
Pivot_
ninjaHead
'
;
this
.
pivot
.
add
(
local
);
let
objLoader2Parallel
=
new
OBJLoader2Parallel
()
...
...
@@ -287,8 +292,6 @@
let
override
=
new
LoadedMeshUserOverride
(
false
,
true
);
let
mesh
=
new
THREE
.
Mesh
(
event
.
detail
.
bufferGeometry
,
event
.
detail
.
material
);
let
scale
=
200.0
;
mesh
.
scale
.
set
(
scale
,
scale
,
scale
);
mesh
.
name
=
event
.
detail
.
meshName
;
let
helper
=
new
VertexNormalsHelper
(
mesh
,
2
,
0x00ff00
,
1
);
helper
.
name
=
'
VertexNormalsHelper
'
;
...
...
@@ -305,7 +308,7 @@
scope
.
_reportProgress
(
{
detail
:
{
text
:
'
Loading of
'
+
objLoader2Parallel
.
modelName
+
'
completed:
'
+
message
}
}
);
}
objLoader2Parallel
.
load
(
'
models/obj/
vive-controller/vr_controller_vive_1_5
.obj
'
,
callbackOnLoad
);
objLoader2Parallel
.
load
(
'
models/obj/
ninja/ninjaHead_Low
.obj
'
,
callbackOnLoad
);
},
finalize
:
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录