Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
fktz008
three.js
提交
e6fd2d05
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,发现更多精彩内容 >>
提交
e6fd2d05
编写于
4月 03, 2011
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Blender Exporter: Added option for truncating vertex values. Added scale parameter.
上级
09e976f2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
13 deletion
+24
-13
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
...rters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
+7
-2
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
...blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
+17
-11
未找到文件。
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
浏览文件 @
e6fd2d05
...
...
@@ -129,6 +129,8 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
use_colors
=
BoolProperty
(
name
=
"Colors"
,
description
=
"Export vertex colors"
,
default
=
True
)
use_uv_coords
=
BoolProperty
(
name
=
"UVs"
,
description
=
"Export texture coordinates"
,
default
=
True
)
option_export_scene
=
BoolProperty
(
name
=
"Scene"
,
description
=
"Export scene"
,
default
=
False
)
option_truncate
=
BoolProperty
(
name
=
"Truncate"
,
description
=
"Truncate decimals"
,
default
=
False
)
option_scale
=
FloatProperty
(
name
=
"Scale"
,
description
=
"Scale data"
,
min
=
0.01
,
max
=
1000.0
,
soft_min
=
0.01
,
soft_max
=
1000.0
,
default
=
1.0
)
align_types
=
[(
"None"
,
"None"
,
"None"
),
(
"Center"
,
"Center"
,
"Center"
),
(
"Bottom"
,
"Bottom"
,
"Bottom"
),
(
"Top"
,
"Top"
,
"Top"
)]
align_model
=
EnumProperty
(
name
=
"Align model"
,
description
=
"Align model"
,
items
=
align_types
,
default
=
"None"
)
...
...
@@ -164,12 +166,15 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"use_normals"
)
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"use_colors"
)
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"use_uv_coords"
)
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"use_materials"
)
layout
.
separator
()
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"option_truncate"
)
row
.
prop
(
self
.
properties
,
"option_scale"
)
# ################################################################
...
...
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
浏览文件 @
e6fd2d05
...
...
@@ -228,6 +228,7 @@ postMessage( model );
"""
TEMPLATE_VERTEX
=
"%f,%f,%f"
TEMPLATE_VERTEX_TRUNCATE
=
"%d,%d,%d"
TEMPLATE_N
=
"%f,%f,%f"
TEMPLATE_UV
=
"%f,%f"
...
...
@@ -391,8 +392,11 @@ def bottom(vertices):
def
hexcolor
(
c
):
return
(
int
(
c
[
0
]
*
255
)
<<
16
)
+
(
int
(
c
[
1
]
*
255
)
<<
8
)
+
int
(
c
[
2
]
*
255
)
def
generate_vertex
(
v
):
return
TEMPLATE_VERTEX
%
(
v
.
co
.
x
,
v
.
co
.
y
,
v
.
co
.
z
)
def
generate_vertex
(
v
,
truncate
):
if
truncate
:
return
TEMPLATE_VERTEX_TRUNCATE
%
(
v
.
co
.
x
,
v
.
co
.
y
,
v
.
co
.
z
)
else
:
return
TEMPLATE_VERTEX
%
(
v
.
co
.
x
,
v
.
co
.
y
,
v
.
co
.
z
)
def
generate_normal
(
n
):
return
TEMPLATE_N
%
(
n
[
0
],
n
[
1
],
n
[
2
])
...
...
@@ -737,7 +741,7 @@ def generate_materials_string(mesh, scene, use_colors, draw_type):
# ASCII model generator
# #####################################################
def
generate_ascii_model
(
mesh
,
scene
,
use_normals
,
use_colors
,
use_uv_coords
,
use_materials
,
align_model
,
flipyz
,
draw_type
):
def
generate_ascii_model
(
mesh
,
scene
,
use_normals
,
use_colors
,
use_uv_coords
,
use_materials
,
align_model
,
flipyz
,
option_truncate
,
draw_type
):
vertices
=
mesh
.
vertices
[:]
...
...
@@ -772,7 +776,7 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, us
"materials"
:
mstring
,
"vertices"
:
","
.
join
(
generate_vertex
(
v
)
for
v
in
vertices
),
"vertices"
:
","
.
join
(
generate_vertex
(
v
,
option_truncate
)
for
v
in
vertices
),
"faces"
:
","
.
join
(
generate_face
(
f
,
i
,
normals
,
uvs
,
colors
,
mesh
,
use_normals
,
use_colors
,
use_uv_coords
,
use_materials
,
flipyz
)
for
i
,
f
in
enumerate
(
mesh
.
faces
))
...
...
@@ -785,13 +789,13 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, us
# Model exporter - export single mesh
# #####################################################
def
export_mesh
(
obj
,
scene
,
filepath
,
use_normals
,
use_colors
,
use_uv_coords
,
use_materials
,
align_model
,
flipyz
,
export_single_model
):
def
export_mesh
(
obj
,
scene
,
filepath
,
use_normals
,
use_colors
,
use_uv_coords
,
use_materials
,
align_model
,
flipyz
,
option_truncate
,
option_scale
,
export_single_model
):
"""Export single mesh"""
# collapse modifiers into mesh
mesh
=
obj
.
create_mesh
(
scene
,
True
,
'RENDER'
)
mesh
=
obj
.
create_mesh
(
scene
,
True
,
'RENDER'
)
if
not
mesh
:
raise
Exception
(
"Error, could not get mesh data from object [%s]"
%
obj
.
name
)
...
...
@@ -806,6 +810,8 @@ def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, us
else
:
mesh
.
transform
(
X_ROT
)
mesh
.
transform
(
mathutils
.
Matrix
.
Scale
(
option_scale
,
4
))
mesh
.
calc_normals
()
faceUV
=
(
len
(
mesh
.
uv_textures
)
>
0
)
...
...
@@ -828,7 +834,7 @@ def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, us
if
not
active_col_layer
:
use_colors
=
False
text
=
generate_ascii_model
(
mesh
,
scene
,
use_normals
,
use_colors
,
use_uv_coords
,
use_materials
,
align_model
,
flipyz
,
o
bj
.
draw_type
)
text
=
generate_ascii_model
(
mesh
,
scene
,
use_normals
,
use_colors
,
use_uv_coords
,
use_materials
,
align_model
,
flipyz
,
o
ption_truncate
,
obj
.
draw_type
)
write_file
(
filepath
,
text
)
# remove temp mesh
...
...
@@ -929,7 +935,7 @@ def generate_objects(data):
group_string
=
generate_string_list
(
group_ids
)
castsShadow
=
generate_bool_property
(
obj
.
THREE_castsShadow
)
meshCollider
=
generate_bool_property
(
obj
.
THREE_meshCollider
)
meshCollider
=
generate_bool_property
(
obj
.
THREE_meshCollider
)
object_string
=
TEMPLATE_OBJECT
%
{
"object_id"
:
generate_string
(
object_id
),
...
...
@@ -1255,7 +1261,7 @@ def export_scene(scene, filepath, flipyz):
# Main
# #####################################################
def
save
(
operator
,
context
,
filepath
=
""
,
option_flip_yz
=
True
,
use_normals
=
True
,
use_colors
=
True
,
use_uv_coords
=
True
,
use_materials
=
True
,
align_model
=
0
,
option_export_scene
=
True
):
def
save
(
operator
,
context
,
filepath
=
""
,
option_flip_yz
=
True
,
use_normals
=
True
,
use_colors
=
True
,
use_uv_coords
=
True
,
use_materials
=
True
,
align_model
=
0
,
option_export_scene
=
False
,
option_truncate
=
False
,
option_scale
=
1.0
):
filepath
=
ensure_extension
(
filepath
,
'.js'
)
...
...
@@ -1286,7 +1292,7 @@ def save(operator, context, filepath = "", option_flip_yz = True, use_normals =
if
name
not
in
geo_set
:
fname
=
generate_mesh_filename
(
name
,
filepath
)
export_mesh
(
obj
,
scene
,
fname
,
use_normals
,
use_colors
,
use_uv_coords
,
use_materials
,
0
,
option_flip_yz
,
False
)
export_mesh
(
obj
,
scene
,
fname
,
use_normals
,
use_colors
,
use_uv_coords
,
use_materials
,
0
,
option_flip_yz
,
option_truncate
,
option_scale
,
False
)
geo_set
.
add
(
name
)
...
...
@@ -1296,7 +1302,7 @@ def save(operator, context, filepath = "", option_flip_yz = True, use_normals =
if
not
obj
:
raise
Exception
(
"Error, Select 1 active object or select 'export scene'"
)
export_mesh
(
obj
,
scene
,
filepath
,
use_normals
,
use_colors
,
use_uv_coords
,
use_materials
,
align_model
,
option_flip_yz
,
True
)
export_mesh
(
obj
,
scene
,
filepath
,
use_normals
,
use_colors
,
use_uv_coords
,
use_materials
,
align_model
,
option_flip_yz
,
option_truncate
,
option_scale
,
True
)
return
{
'FINISHED'
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录