Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fktz008
three.js
提交
2f2d6a07
T
three.js
项目概览
fktz008
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
2f2d6a07
编写于
1月 06, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added OBJExporter.
上级
d54f2e3f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
112 addition
and
7 deletion
+112
-7
editor/index.html
editor/index.html
+1
-0
editor/js/ui/Menubar.File.js
editor/js/ui/Menubar.File.js
+2
-4
editor/js/ui/Viewport.js
editor/js/ui/Viewport.js
+3
-3
examples/js/exporters/OBJExporter.js
examples/js/exporters/OBJExporter.js
+106
-0
未找到文件。
editor/index.html
浏览文件 @
2f2d6a07
...
...
@@ -81,6 +81,7 @@
<script
src=
"../examples/js/loaders/ctm/CTMLoader.js"
></script>
<script
src=
"../examples/js/exporters/GeometryExporter.js"
></script>
<script
src=
"../examples/js/exporters/SceneExporter.js"
></script>
<script
src=
"../examples/js/exporters/OBJExporter.js"
></script>
<script
src=
"js/libs/signals.min.js"
></script>
...
...
editor/js/ui/Menubar.File.js
浏览文件 @
2f2d6a07
...
...
@@ -38,7 +38,7 @@ Menubar.File = function ( signals ) {
var
option
=
new
UI
.
Panel
();
option
.
setClass
(
'
option
'
);
option
.
setTextContent
(
'
Export Geometry
'
);
option
.
onClick
(
function
()
{
signals
.
exportGeometry
.
dispatch
();
}
);
option
.
onClick
(
function
()
{
signals
.
exportGeometry
.
dispatch
(
{
exporter
:
THREE
.
GeometryExporter
}
);
}
);
options
.
add
(
option
);
// export scene
...
...
@@ -49,15 +49,13 @@ Menubar.File = function ( signals ) {
option
.
onClick
(
function
()
{
signals
.
exportScene
.
dispatch
();
}
);
options
.
add
(
option
);
/*
// export OBJ
var
option
=
new
UI
.
Panel
();
option
.
setClass
(
'
option
'
);
option
.
setTextContent
(
'
Export OBJ
'
);
option.onClick( function () {
alert( 'Export OBJ' )
} );
option
.
onClick
(
function
()
{
signals
.
exportGeometry
.
dispatch
(
{
exporter
:
THREE
.
OBJExporter
}
);
}
);
options
.
add
(
option
);
*/
//
...
...
editor/js/ui/Viewport.js
浏览文件 @
2f2d6a07
...
...
@@ -667,16 +667,16 @@ var Viewport = function ( signals ) {
}
);
signals
.
exportGeometry
.
add
(
function
()
{
signals
.
exportGeometry
.
add
(
function
(
object
)
{
if
(
!
selected
.
geometry
)
{
if
(
selected
.
geometry
===
undefined
)
{
console
.
warn
(
"
Selected object doesn't have any geometry
"
);
return
;
}
var
output
=
new
THREE
.
GeometryE
xporter
().
parse
(
selected
.
geometry
);
var
output
=
new
object
.
e
xporter
().
parse
(
selected
.
geometry
);
var
blob
=
new
Blob
(
[
output
],
{
type
:
'
text/plain
'
}
);
var
objectURL
=
URL
.
createObjectURL
(
blob
);
...
...
examples/js/exporters/OBJExporter.js
0 → 100644
浏览文件 @
2f2d6a07
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
OBJExporter
=
function
()
{};
THREE
.
OBJExporter
.
prototype
=
{
constructor
:
THREE
.
OBJExporter
,
parse
:
function
(
geometry
)
{
console
.
log
(
geometry
);
var
output
=
''
;
for
(
var
i
=
0
,
l
=
geometry
.
vertices
.
length
;
i
<
l
;
i
++
)
{
var
vertex
=
geometry
.
vertices
[
i
];
output
+=
'
v
'
+
vertex
.
x
+
'
'
+
vertex
.
y
+
'
'
+
vertex
.
z
+
'
\n
'
;
}
// uvs
for
(
var
i
=
0
,
l
=
geometry
.
faceVertexUvs
[
0
].
length
;
i
<
l
;
i
++
)
{
var
vertexUvs
=
geometry
.
faceVertexUvs
[
0
][
i
];
for
(
var
j
=
0
;
j
<
vertexUvs
.
length
;
j
++
)
{
var
uv
=
vertexUvs
[
j
];
output
+=
'
vt
'
+
uv
.
x
+
'
'
+
uv
.
y
+
'
\n
'
;
}
}
// normals
for
(
var
i
=
0
,
l
=
geometry
.
faces
.
length
;
i
<
l
;
i
++
)
{
var
normals
=
geometry
.
faces
[
i
].
vertexNormals
;
for
(
var
j
=
0
;
j
<
normals
.
length
;
j
++
)
{
var
normal
=
normals
[
j
];
output
+=
'
vn
'
+
normal
.
x
+
'
'
+
normal
.
y
+
'
'
+
normal
.
z
+
'
\n
'
;
}
}
// map
var
count
=
1
;
// OBJ values start by 1
var
map
=
[
count
];
for
(
var
i
=
0
,
l
=
geometry
.
faces
.
length
;
i
<
l
;
i
++
)
{
var
face
=
geometry
.
faces
[
i
];
if
(
face
instanceof
THREE
.
Face3
)
{
count
+=
3
;
}
else
if
(
face
instanceof
THREE
.
Face4
)
{
count
+=
4
;
}
map
.
push
(
count
);
}
// faces
for
(
var
i
=
0
,
l
=
geometry
.
faces
.
length
;
i
<
l
;
i
++
)
{
var
face
=
geometry
.
faces
[
i
];
output
+=
'
f
'
;
if
(
face
instanceof
THREE
.
Face3
)
{
output
+=
(
face
.
a
+
1
)
+
'
/
'
+
(
map
[
i
]
)
+
'
/
'
+
(
map
[
i
]
)
+
'
'
;
output
+=
(
face
.
b
+
1
)
+
'
/
'
+
(
map
[
i
]
+
1
)
+
'
/
'
+
(
map
[
i
]
+
1
)
+
'
'
;
output
+=
(
face
.
c
+
1
)
+
'
/
'
+
(
map
[
i
]
+
2
)
+
'
/
'
+
(
map
[
i
]
+
2
)
+
'
\n
'
;
}
else
if
(
face
instanceof
THREE
.
Face4
)
{
output
+=
(
face
.
a
+
1
)
+
'
/
'
+
(
map
[
i
]
)
+
'
/
'
+
(
map
[
i
]
)
+
'
'
;
output
+=
(
face
.
b
+
1
)
+
'
/
'
+
(
map
[
i
]
+
1
)
+
'
/
'
+
(
map
[
i
]
+
1
)
+
'
'
;
output
+=
(
face
.
c
+
1
)
+
'
/
'
+
(
map
[
i
]
+
2
)
+
'
/
'
+
(
map
[
i
]
+
2
)
+
'
'
;
output
+=
(
face
.
d
+
1
)
+
'
/
'
+
(
map
[
i
]
+
3
)
+
'
/
'
+
(
map
[
i
]
+
3
)
+
'
\n
'
;
}
}
return
output
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录