Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
631c60db
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,发现更多精彩内容 >>
提交
631c60db
编写于
3月 19, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Basic implementation of MaterialLoader.
上级
dff219ae
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
171 addition
and
7 deletion
+171
-7
editor/index.html
editor/index.html
+2
-1
examples/js/exporters/MaterialExporter.js
examples/js/exporters/MaterialExporter.js
+54
-0
examples/js/exporters/SceneExporter2.js
examples/js/exporters/SceneExporter2.js
+23
-4
examples/js/loaders/SceneLoader2.js
examples/js/loaders/SceneLoader2.js
+16
-1
src/loaders/MaterialLoader.js
src/loaders/MaterialLoader.js
+76
-1
未找到文件。
editor/index.html
浏览文件 @
631c60db
...
@@ -80,6 +80,7 @@
...
@@ -80,6 +80,7 @@
<script
src=
"../examples/js/loaders/ctm/ctm.js"
></script>
<script
src=
"../examples/js/loaders/ctm/ctm.js"
></script>
<script
src=
"../examples/js/loaders/ctm/CTMLoader.js"
></script>
<script
src=
"../examples/js/loaders/ctm/CTMLoader.js"
></script>
<script
src=
"../examples/js/exporters/GeometryExporter.js"
></script>
<script
src=
"../examples/js/exporters/GeometryExporter.js"
></script>
<script
src=
"../examples/js/exporters/MaterialExporter.js"
></script>
<script
src=
"../examples/js/exporters/SceneExporter.js"
></script>
<script
src=
"../examples/js/exporters/SceneExporter.js"
></script>
<script
src=
"../examples/js/exporters/OBJExporter.js"
></script>
<script
src=
"../examples/js/exporters/OBJExporter.js"
></script>
<script
src=
"../examples/js/renderers/SoftwareRenderer.js"
></script>
<script
src=
"../examples/js/renderers/SoftwareRenderer.js"
></script>
...
@@ -475,7 +476,7 @@
...
@@ -475,7 +476,7 @@
localStorage
.
threejsEditor
=
JSON
.
stringify
(
sceneExporter
.
parse
(
scene
)
);
localStorage
.
threejsEditor
=
JSON
.
stringify
(
sceneExporter
.
parse
(
scene
)
);
},
5
000
);
},
3
000
);
}
);
}
);
...
...
examples/js/exporters/MaterialExporter.js
浏览文件 @
631c60db
...
@@ -10,7 +10,61 @@ THREE.MaterialExporter.prototype = {
...
@@ -10,7 +10,61 @@ THREE.MaterialExporter.prototype = {
parse
:
function
(
material
)
{
parse
:
function
(
material
)
{
var
output
=
{
metadata
:
{
version
:
4.0
,
type
:
'
material
'
,
generator
:
'
MaterialExporter
'
}
};
if
(
material
instanceof
THREE
.
MeshBasicMaterial
)
{
output
.
type
=
'
MeshBasicMaterial
'
;
output
.
color
=
material
.
color
.
getHex
();
output
.
opacity
=
material
.
opacity
;
output
.
transparent
=
material
.
transparent
;
output
.
wireframe
=
material
.
wireframe
;
}
else
if
(
material
instanceof
THREE
.
MeshLambertMaterial
)
{
output
.
type
=
'
MeshLambertMaterial
'
;
output
.
color
=
material
.
color
.
getHex
();
output
.
ambient
=
material
.
ambient
.
getHex
();
output
.
emissive
=
material
.
emissive
.
getHex
();
output
.
opacity
=
material
.
opacity
;
output
.
transparent
=
material
.
transparent
;
output
.
wireframe
=
material
.
wireframe
;
}
else
if
(
material
instanceof
THREE
.
MeshPhongMaterial
)
{
output
.
type
=
'
MeshPhongMaterial
'
;
output
.
color
=
material
.
color
.
getHex
();
output
.
ambient
=
material
.
ambient
.
getHex
();
output
.
emissive
=
material
.
emissive
.
getHex
();
output
.
specular
=
material
.
specular
.
getHex
();
output
.
shininess
=
material
.
shininess
;
output
.
opacity
=
material
.
opacity
;
output
.
transparent
=
material
.
transparent
;
output
.
wireframe
=
material
.
wireframe
;
}
else
if
(
material
instanceof
THREE
.
MeshNormalMaterial
)
{
output
.
type
=
'
MeshNormalMaterial
'
;
output
.
opacity
=
material
.
opacity
;
output
.
transparent
=
material
.
transparent
;
output
.
wireframe
=
material
.
wireframe
;
}
else
if
(
material
instanceof
THREE
.
MeshDepthMaterial
)
{
output
.
type
=
'
MeshDepthMaterial
'
;
output
.
opacity
=
material
.
opacity
;
output
.
transparent
=
material
.
transparent
;
output
.
wireframe
=
material
.
wireframe
;
}
return
output
;
}
}
...
...
examples/js/exporters/SceneExporter2.js
浏览文件 @
631c60db
...
@@ -10,6 +10,8 @@ THREE.SceneExporter2.prototype = {
...
@@ -10,6 +10,8 @@ THREE.SceneExporter2.prototype = {
parse
:
function
(
scene
)
{
parse
:
function
(
scene
)
{
// console.log( scene );
var
output
=
{
var
output
=
{
metadata
:
{
metadata
:
{
version
:
4.0
,
version
:
4.0
,
...
@@ -18,8 +20,6 @@ THREE.SceneExporter2.prototype = {
...
@@ -18,8 +20,6 @@ THREE.SceneExporter2.prototype = {
}
}
};
};
console
.
log
(
scene
);
//
//
var
geometries
=
{};
var
geometries
=
{};
...
@@ -79,16 +79,34 @@ THREE.SceneExporter2.prototype = {
...
@@ -79,16 +79,34 @@ THREE.SceneExporter2.prototype = {
};
};
/*
//
var
materials
=
{};
var
materials
=
{};
var
materialExporter
=
new
THREE
.
MaterialExporter
();
var
materialExporter
=
new
THREE
.
MaterialExporter
();
var
parseMaterial
=
function
(
material
)
{
var
parseMaterial
=
function
(
material
)
{
if
(
materials
[
material
.
id
]
===
undefined
)
{
if
(
output
.
materials
===
undefined
)
{
output
.
materials
=
[];
}
materials
[
material
.
id
]
=
output
.
materials
.
length
;
var
data
=
{
name
:
material
.
name
,
data
:
materialExporter
.
parse
(
material
)
};
output
.
materials
.
push
(
data
);
}
return
materials
[
material
.
id
];
};
};
*/
//
var
parseObject
=
function
(
object
)
{
var
parseObject
=
function
(
object
)
{
...
@@ -154,6 +172,7 @@ THREE.SceneExporter2.prototype = {
...
@@ -154,6 +172,7 @@ THREE.SceneExporter2.prototype = {
data
.
rotation
=
object
.
rotation
.
toArray
();
data
.
rotation
=
object
.
rotation
.
toArray
();
data
.
scale
=
object
.
scale
.
toArray
();
data
.
scale
=
object
.
scale
.
toArray
();
data
.
geometry
=
parseGeometry
(
object
.
geometry
);
data
.
geometry
=
parseGeometry
(
object
.
geometry
);
data
.
material
=
parseMaterial
(
object
.
material
);
}
else
{
}
else
{
...
...
examples/js/loaders/SceneLoader2.js
浏览文件 @
631c60db
...
@@ -109,6 +109,21 @@ THREE.SceneLoader2.prototype = {
...
@@ -109,6 +109,21 @@ THREE.SceneLoader2.prototype = {
// materials
// materials
var
materials
=
[];
var
loader
=
new
THREE
.
MaterialLoader
();
for
(
var
i
=
0
,
l
=
json
.
materials
.
length
;
i
<
l
;
i
++
)
{
var
material
;
var
data
=
json
.
materials
[
i
];
material
=
loader
.
parse
(
data
.
data
);
material
.
name
=
data
.
name
;
materials
.
push
(
material
);
}
// objects
// objects
var
parseObject
=
function
(
array
,
parent
)
{
var
parseObject
=
function
(
array
,
parent
)
{
...
@@ -171,7 +186,7 @@ THREE.SceneLoader2.prototype = {
...
@@ -171,7 +186,7 @@ THREE.SceneLoader2.prototype = {
case
'
Mesh
'
:
case
'
Mesh
'
:
object
=
new
THREE
.
Mesh
(
geometries
[
data
.
geometry
]
);
// TODO: Material
object
=
new
THREE
.
Mesh
(
geometries
[
data
.
geometry
]
,
materials
[
data
.
material
]
);
object
.
position
.
fromArray
(
data
.
position
);
object
.
position
.
fromArray
(
data
.
position
);
object
.
rotation
.
fromArray
(
data
.
rotation
);
object
.
rotation
.
fromArray
(
data
.
rotation
);
object
.
scale
.
fromArray
(
data
.
scale
);
object
.
scale
.
fromArray
(
data
.
scale
);
...
...
src/loaders/MaterialLoader.js
浏览文件 @
631c60db
...
@@ -44,7 +44,82 @@ THREE.MaterialLoader.prototype = {
...
@@ -44,7 +44,82 @@ THREE.MaterialLoader.prototype = {
parse
:
function
(
json
)
{
parse
:
function
(
json
)
{
var
material
;
switch
(
json
.
type
)
{
case
'
MeshBasicMaterial
'
:
material
=
new
THREE
.
MeshBasicMaterial
(
{
color
:
json
.
color
,
opacity
:
json
.
opacity
,
transparent
:
json
.
transparent
,
wireframe
:
json
.
wireframe
}
);
break
;
case
'
MeshLambertMaterial
'
:
material
=
new
THREE
.
MeshLambertMaterial
(
{
color
:
json
.
color
,
ambient
:
json
.
ambient
,
emissive
:
json
.
emissive
,
opacity
:
json
.
opacity
,
transparent
:
json
.
transparent
,
wireframe
:
json
.
wireframe
}
);
break
;
case
'
MeshPhongMaterial
'
:
material
=
new
THREE
.
MeshPhongMaterial
(
{
color
:
json
.
color
,
ambient
:
json
.
ambient
,
emissive
:
json
.
emissive
,
specular
:
json
.
specular
,
shininess
:
json
.
shininess
,
opacity
:
json
.
opacity
,
transparent
:
json
.
transparent
,
wireframe
:
json
.
wireframe
}
);
break
;
case
'
MeshNormalMaterial
'
:
material
=
new
THREE
.
MeshNormalMaterial
(
{
opacity
:
json
.
opacity
,
transparent
:
json
.
transparent
,
wireframe
:
json
.
wireframe
}
);
break
;
case
'
MeshDepthMaterial
'
:
material
=
new
THREE
.
MeshDepthMaterial
(
{
opacity
:
json
.
opacity
,
transparent
:
json
.
transparent
,
wireframe
:
json
.
wireframe
}
);
break
;
}
return
material
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录