Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
0528c143
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,发现更多精彩内容 >>
提交
0528c143
编写于
11月 29, 2010
作者:
G
George Profenza
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
blender 2.49 exporter
上级
61d7fe95
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
150 addition
and
0 deletion
+150
-0
utils/exporters/blender/.DS_Store
utils/exporters/blender/.DS_Store
+0
-0
utils/exporters/blender/2.49/threejs_export.py
utils/exporters/blender/2.49/threejs_export.py
+150
-0
未找到文件。
utils/exporters/blender/.DS_Store
0 → 100644
浏览文件 @
0528c143
文件已添加
utils/exporters/blender/2.49/threejs_export.py
0 → 100755
浏览文件 @
0528c143
#!BPY
# Based on Anthony D'Agostino (Scorpius)'s Raw Exported provided with Blender
# and on Mr.doob's and Kikko's Blender 2.5a2 exporter
# 'http://mrdoob.com', 'http://github.com/kikko'
"""
Name: 'three.js (.js)...'
Blender: 245
Group: 'Export'
Tooltip: 'Export selected mesh to three.js (.js)'
"""
__author__
=
"George Profenza"
__url__
=
(
"disturb"
,
"disturbmedia.com/blog"
,
"My blog, http://tomaterial.blogspot.com"
)
__version__
=
"First File Exporter"
__bpydoc__
=
"""
\
Export meshes to mr.doob's three.js 3D Engine.
Currently supports UVs. If the model doesn't display correctly
you might need to reverse some normals/do some cleanup.
More details on the engine here:
https://github.com/mrdoob/three.js
Have fun!
Usage:<br>
Select a mesh to be exported and go to "File->Export->three.js" .
"""
# $Id: raw_export.py 14597 2008-04-28 16:09:17Z campbellbarton $
#
# +---------------------------------------------------------+
# | Copyright (c) 2002 Anthony D'Agostino |
# | http://www.redrival.com/scorpius |
# | scorpius@netzero.com |
# | April 28, 2002 |
# | Read and write RAW Triangle File Format (*.raw) |
# +---------------------------------------------------------+
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
import
Blender
import
BPyMesh
import
re
clean
=
lambda
varStr
:
re
.
sub
(
'\W|^(?=\d)'
,
'_'
,
varStr
)
def
write
(
filename
):
start
=
Blender
.
sys
.
time
()
if
not
filename
.
lower
().
endswith
(
'.js'
):
filename
+=
'.js'
scn
=
Blender
.
Scene
.
GetCurrent
()
ob
=
scn
.
objects
.
active
if
not
ob
:
Blender
.
Draw
.
PupMenu
(
'Error%t|Select 1 active object'
)
return
file
=
open
(
filename
,
'wb'
)
mesh
=
BPyMesh
.
getMeshFromObject
(
ob
,
None
,
True
,
False
,
scn
)
if
not
mesh
:
Blender
.
Draw
.
PupMenu
(
'Error%t|Could not get mesh data from active object'
)
return
mesh
.
transform
(
ob
.
matrixWorld
)
#classname = clean(ob.name)
classname
=
filename
.
split
(
'/'
)[
-
1
].
replace
(
'.js'
,
''
)
file
=
open
(
filename
,
"wb"
)
file
.
write
(
'var %s = function () {
\n\n
'
%
classname
)
file
.
write
(
'
\t
var scope = this;
\n\n
'
)
file
.
write
(
'
\t
THREE.Geometry.call(this);
\n\n
'
)
for
v
in
mesh
.
verts
:
file
.
write
(
'
\t
v( %.6f, %.6f, %.6f );
\n
'
%
(
v
.
co
.
x
,
v
.
co
.
z
,
-
v
.
co
.
y
))
# co
file
.
write
(
'
\n
'
)
for
f
in
mesh
.
faces
:
if
len
(
f
.
verts
)
==
3
:
file
.
write
(
'
\t
f3( %d, %d, %d, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
verts
[
0
].
index
,
f
.
verts
[
1
].
index
,
f
.
verts
[
2
].
index
,
f
.
verts
[
0
].
no
.
x
,
f
.
verts
[
0
].
no
.
z
,
-
f
.
verts
[
0
].
no
.
y
))
else
:
file
.
write
(
'
\t
f4( %d, %d, %d, %d, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
verts
[
0
].
index
,
f
.
verts
[
1
].
index
,
f
.
verts
[
2
].
index
,
f
.
verts
[
3
].
index
,
f
.
verts
[
0
].
no
.
x
,
f
.
verts
[
0
].
no
.
z
,
-
f
.
verts
[
0
].
no
.
y
))
face_index_pairs
=
[
(
face
,
index
)
for
index
,
face
in
enumerate
(
mesh
.
faces
)]
file
.
write
(
'
\n
'
)
'''
for f in me.faces:
if me.faceUV:
if len(f.verts) == 3:
file.write('
\t
uv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f );
\n
' % (f.uv[0][0], 1.0-f.uv[0][1], f.uv[1][0], 1.0-f.uv[1][1], f.uv[2][0], 1.0-f.uv[2][1])
'''
for
f
in
mesh
.
faces
:
if
mesh
.
faceUV
:
if
len
(
f
.
verts
)
==
3
:
file
.
write
(
'
\t
uv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f );
\n
'
%
(
f
.
uv
[
0
].
x
,
1.0
-
f
.
uv
[
0
].
y
,
f
.
uv
[
1
].
x
,
1.0
-
f
.
uv
[
1
].
y
,
f
.
uv
[
2
].
x
,
1.0
-
f
.
uv
[
2
].
y
))
else
:
file
.
write
(
'
\t
uv( %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f);
\n
'
%
(
f
.
uv
[
0
].
x
,
1.0
-
f
.
uv
[
0
].
y
,
f
.
uv
[
1
].
x
,
1.0
-
f
.
uv
[
1
].
y
,
f
.
uv
[
2
].
x
,
1.0
-
f
.
uv
[
2
].
y
,
f
.
uv
[
3
].
x
,
1.0
-
f
.
uv
[
3
].
y
))
file
.
write
(
'
\n
'
)
file
.
write
(
'
\t
function v( x, y, z ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
\n\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'
\t
function f3( a, b, c, nx, ny, nz ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.faces.push( new THREE.Face3( a, b, c, nx && ny && nz ? new THREE.Vector3( nx, ny, nz ) : null ) );
\n\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'
\t
function f4( a, b, c, d, nx, ny, nz ) {
\n\n
'
)
file
.
write
(
'
\t\t
scope.faces.push( new THREE.Face4( a, b, c, d, nx && ny && nz ? new THREE.Vector3( nx, ny, nz ) : null ) );
\n\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'
\t
function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) {
\n\n
'
)
file
.
write
(
'
\t\t
var uv = [];
\n
'
)
file
.
write
(
'
\t\t
uv.push( new THREE.UV( u1, v1 ) );
\n
'
)
file
.
write
(
'
\t\t
uv.push( new THREE.UV( u2, v2 ) );
\n
'
)
file
.
write
(
'
\t\t
uv.push( new THREE.UV( u3, v3 ) );
\n
'
)
file
.
write
(
'
\t\t
if ( u4 && v4 ) uv.push( new THREE.UV( u4, v4 ) );
\n
'
)
file
.
write
(
'
\t\t
scope.uvs.push( uv );
\n
'
)
file
.
write
(
'
\t
}
\n\n
'
)
file
.
write
(
'}
\n\n
'
)
file
.
write
(
'%s.prototype = new THREE.Geometry();
\n
'
%
classname
)
file
.
write
(
'%s.prototype.constructor = %s;'
%
(
classname
,
classname
))
file
.
close
()
end
=
Blender
.
sys
.
time
()
def
main
():
Blender
.
Window
.
FileSelector
(
write
,
'three.js Export'
,
Blender
.
sys
.
makename
(
ext
=
'.js'
))
if
__name__
==
'__main__'
:
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录