Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
bc520665
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,发现更多精彩内容 >>
提交
bc520665
编写于
4月 11, 2011
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleaned up Blender exporter (visually, code-wise and whitespaces-wise)
上级
7361be39
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
257 addition
and
230 deletion
+257
-230
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
...rters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
+67
-40
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
...blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
+190
-190
未找到文件。
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
浏览文件 @
bc520665
...
@@ -153,7 +153,7 @@ def save_settings_export(properties):
...
@@ -153,7 +153,7 @@ def save_settings_export(properties):
"option_uv_coords"
:
properties
.
option_uv_coords
,
"option_uv_coords"
:
properties
.
option_uv_coords
,
"option_edges"
:
properties
.
option_edges
,
"option_edges"
:
properties
.
option_edges
,
"option_
truncate"
:
properties
.
option
_truncate
,
"option_
vertices_truncate"
:
properties
.
option_vertices
_truncate
,
"option_scale"
:
properties
.
option_scale
,
"option_scale"
:
properties
.
option_scale
,
"align_model"
:
properties
.
align_model
"align_model"
:
properties
.
align_model
...
@@ -172,20 +172,22 @@ def restore_settings_export(properties):
...
@@ -172,20 +172,22 @@ def restore_settings_export(properties):
f
=
open
(
fname
,
"r"
)
f
=
open
(
fname
,
"r"
)
settings
=
json
.
load
(
f
)
settings
=
json
.
load
(
f
)
properties
.
option_export_scene
=
settings
.
get
(
"option_export_scene"
,
False
)
properties
.
option_vertices
=
settings
.
get
(
"option_vertices"
,
True
)
properties
.
option_vertices_truncate
=
settings
.
get
(
"option_vertices_truncate"
,
False
)
properties
.
option_flip_yz
=
settings
.
get
(
"option_flip_yz"
,
True
)
properties
.
option_faces
=
settings
.
get
(
"option_faces"
,
True
)
properties
.
option_materials
=
settings
.
get
(
"option_materials"
,
True
)
properties
.
option_normals
=
settings
.
get
(
"option_normals"
,
True
)
properties
.
option_normals
=
settings
.
get
(
"option_normals"
,
True
)
properties
.
option_edges
=
settings
.
get
(
"option_edges"
,
False
)
properties
.
option_colors
=
settings
.
get
(
"option_colors"
,
True
)
properties
.
option_colors
=
settings
.
get
(
"option_colors"
,
True
)
properties
.
option_uv_coords
=
settings
.
get
(
"option_uv_coords"
,
True
)
properties
.
option_uv_coords
=
settings
.
get
(
"option_uv_coords"
,
True
)
properties
.
option_edges
=
settings
.
get
(
"option_edges"
,
False
)
properties
.
option_materials
=
settings
.
get
(
"option_materials"
,
True
)
properties
.
align_model
=
settings
.
get
(
"align_model"
,
"None"
)
properties
.
option_truncate
=
settings
.
get
(
"option_truncate"
,
False
)
properties
.
option_scale
=
settings
.
get
(
"option_scale"
,
1.0
)
properties
.
option_scale
=
settings
.
get
(
"option_scale"
,
1.0
)
properties
.
option_flip_yz
=
settings
.
get
(
"option_flip_yz"
,
True
)
properties
.
align_model
=
settings
.
get
(
"align_model"
,
"None"
)
properties
.
option_export_scene
=
settings
.
get
(
"option_export_scene"
,
False
)
# ################################################################
# ################################################################
# Exporter
# Exporter
...
@@ -199,10 +201,13 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
...
@@ -199,10 +201,13 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
filename_ext
=
".js"
filename_ext
=
".js"
option_flip_yz
=
BoolProperty
(
name
=
"Flip YZ"
,
description
=
"Flip YZ"
,
default
=
True
)
option_vertices
=
BoolProperty
(
name
=
"Vertices"
,
description
=
"Export vertices"
,
default
=
True
)
option_vertices
=
BoolProperty
(
name
=
"Vertices"
,
description
=
"Export vertices"
,
default
=
True
)
option_vertices_deltas
=
BoolProperty
(
name
=
"Deltas"
,
description
=
"Delta vertices"
,
default
=
False
)
option_vertices_truncate
=
BoolProperty
(
name
=
"Truncate"
,
description
=
"Truncate vertices"
,
default
=
False
)
option_faces
=
BoolProperty
(
name
=
"Faces"
,
description
=
"Export faces"
,
default
=
True
)
option_faces
=
BoolProperty
(
name
=
"Faces"
,
description
=
"Export faces"
,
default
=
True
)
option_faces_deltas
=
BoolProperty
(
name
=
"Deltas"
,
description
=
"Delta faces"
,
default
=
False
)
option_normals
=
BoolProperty
(
name
=
"Normals"
,
description
=
"Export normals"
,
default
=
True
)
option_normals
=
BoolProperty
(
name
=
"Normals"
,
description
=
"Export normals"
,
default
=
True
)
option_edges
=
BoolProperty
(
name
=
"Edges"
,
description
=
"Export edges"
,
default
=
False
)
option_edges
=
BoolProperty
(
name
=
"Edges"
,
description
=
"Export edges"
,
default
=
False
)
...
@@ -210,14 +215,14 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
...
@@ -210,14 +215,14 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
option_uv_coords
=
BoolProperty
(
name
=
"UVs"
,
description
=
"Export texture coordinates"
,
default
=
True
)
option_uv_coords
=
BoolProperty
(
name
=
"UVs"
,
description
=
"Export texture coordinates"
,
default
=
True
)
option_materials
=
BoolProperty
(
name
=
"Materials"
,
description
=
"Export materials"
,
default
=
True
)
option_materials
=
BoolProperty
(
name
=
"Materials"
,
description
=
"Export materials"
,
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_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"
)
align_model
=
EnumProperty
(
name
=
"Align model"
,
description
=
"Align model"
,
items
=
align_types
,
default
=
"None"
)
option_scale
=
FloatProperty
(
name
=
"Scale"
,
description
=
"Scale vertices"
,
min
=
0.01
,
max
=
1000.0
,
soft_min
=
0.01
,
soft_max
=
1000.0
,
default
=
1.0
)
option_flip_yz
=
BoolProperty
(
name
=
"Flip YZ"
,
description
=
"Flip YZ"
,
default
=
True
)
option_export_scene
=
BoolProperty
(
name
=
"Scene"
,
description
=
"Export scene"
,
default
=
False
)
def
invoke
(
self
,
context
,
event
):
def
invoke
(
self
,
context
,
event
):
restore_settings_export
(
self
.
properties
)
restore_settings_export
(
self
.
properties
)
return
ExportHelper
.
invoke
(
self
,
context
,
event
)
return
ExportHelper
.
invoke
(
self
,
context
,
event
)
...
@@ -242,25 +247,34 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
...
@@ -242,25 +247,34 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
layout
=
self
.
layout
layout
=
self
.
layout
row
=
layout
.
row
()
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"option_export_scene"
)
row
.
label
(
text
=
"Geometry:"
)
layout
.
separator
()
row
=
layout
.
row
()
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"option_flip_yz"
)
row
.
prop
(
self
.
properties
,
"option_vertices"
)
row
=
layout
.
row
()
row
.
enabled
=
self
.
properties
.
option_vertices
# row.prop(self.properties, "option_vertices_deltas")
row
.
prop
(
self
.
properties
,
"option_vertices_truncate"
)
layout
.
separator
()
layout
.
separator
()
row
=
layout
.
row
()
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"align_model"
)
row
.
prop
(
self
.
properties
,
"option_faces"
)
row
=
layout
.
row
()
row
.
enabled
=
self
.
properties
.
option_faces
# row.prop(self.properties, "option_faces_deltas")
layout
.
separator
()
layout
.
separator
()
row
=
layout
.
row
()
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"option_vertices"
)
row
.
prop
(
self
.
properties
,
"option_normals"
)
row
.
prop
(
self
.
properties
,
"option_normals"
)
layout
.
separator
()
row
=
layout
.
row
()
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"option_faces"
)
row
.
prop
(
self
.
properties
,
"option_edges"
)
row
.
prop
(
self
.
properties
,
"option_edges"
)
layout
.
separator
()
layout
.
separator
()
row
=
layout
.
row
()
row
.
label
(
text
=
"Materials:"
)
row
=
layout
.
row
()
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"option_uv_coords"
)
row
.
prop
(
self
.
properties
,
"option_uv_coords"
)
row
.
prop
(
self
.
properties
,
"option_colors"
)
row
.
prop
(
self
.
properties
,
"option_colors"
)
...
@@ -269,8 +283,21 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
...
@@ -269,8 +283,21 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
layout
.
separator
()
layout
.
separator
()
row
=
layout
.
row
()
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"option_truncate"
)
row
.
label
(
text
=
"Settings:"
)
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"align_model"
)
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"option_flip_yz"
)
row
.
prop
(
self
.
properties
,
"option_scale"
)
row
.
prop
(
self
.
properties
,
"option_scale"
)
layout
.
separator
()
row
=
layout
.
row
()
row
.
label
(
text
=
"Beta:"
)
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"option_export_scene"
)
layout
.
separator
()
# ################################################################
# ################################################################
...
...
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
浏览文件 @
bc520665
...
@@ -416,14 +416,14 @@ def bottom(vertices):
...
@@ -416,14 +416,14 @@ def bottom(vertices):
def
hexcolor
(
c
):
def
hexcolor
(
c
):
return
(
int
(
c
[
0
]
*
255
)
<<
16
)
+
(
int
(
c
[
1
]
*
255
)
<<
8
)
+
int
(
c
[
2
]
*
255
)
return
(
int
(
c
[
0
]
*
255
)
<<
16
)
+
(
int
(
c
[
1
]
*
255
)
<<
8
)
+
int
(
c
[
2
]
*
255
)
def
generate_vertices
(
vertices
,
option_truncate
,
option_vertices
):
def
generate_vertices
(
vertices
,
option_
vertices_
truncate
,
option_vertices
):
if
not
option_vertices
:
if
not
option_vertices
:
return
""
return
""
return
","
.
join
(
generate_vertex
(
v
,
option_truncate
)
for
v
in
vertices
)
return
","
.
join
(
generate_vertex
(
v
,
option_
vertices_
truncate
)
for
v
in
vertices
)
def
generate_vertex
(
v
,
option_truncate
):
def
generate_vertex
(
v
,
option_
vertices_
truncate
):
if
not
option_truncate
:
if
not
option_
vertices_
truncate
:
return
TEMPLATE_VERTEX
%
(
v
.
co
.
x
,
v
.
co
.
y
,
v
.
co
.
z
)
return
TEMPLATE_VERTEX
%
(
v
.
co
.
x
,
v
.
co
.
y
,
v
.
co
.
z
)
else
:
else
:
return
TEMPLATE_VERTEX_TRUNCATE
%
(
v
.
co
.
x
,
v
.
co
.
y
,
v
.
co
.
z
)
return
TEMPLATE_VERTEX_TRUNCATE
%
(
v
.
co
.
x
,
v
.
co
.
y
,
v
.
co
.
z
)
...
@@ -786,6 +786,7 @@ def generate_materials_string(mesh, scene, option_colors, draw_type):
...
@@ -786,6 +786,7 @@ def generate_materials_string(mesh, scene, option_colors, draw_type):
def
generate_ascii_model
(
mesh
,
scene
,
def
generate_ascii_model
(
mesh
,
scene
,
option_vertices
,
option_vertices
,
option_vertices_truncate
,
option_faces
,
option_faces
,
option_normals
,
option_normals
,
option_edges
,
option_edges
,
...
@@ -794,7 +795,6 @@ def generate_ascii_model(mesh, scene,
...
@@ -794,7 +795,6 @@ def generate_ascii_model(mesh, scene,
option_colors
,
option_colors
,
align_model
,
align_model
,
flipyz
,
flipyz
,
option_truncate
,
option_scale
,
option_scale
,
draw_type
):
draw_type
):
...
@@ -841,7 +841,7 @@ def generate_ascii_model(mesh, scene,
...
@@ -841,7 +841,7 @@ def generate_ascii_model(mesh, scene,
"materials"
:
materials_string
,
"materials"
:
materials_string
,
"vertices"
:
generate_vertices
(
vertices
,
option_truncate
,
option_vertices
),
"vertices"
:
generate_vertices
(
vertices
,
option_
vertices_
truncate
,
option_vertices
),
"faces"
:
generate_faces
(
normals
,
uvs
,
colors
,
mesh
,
option_normals
,
option_colors
,
option_uv_coords
,
option_materials
,
flipyz
,
option_faces
),
"faces"
:
generate_faces
(
normals
,
uvs
,
colors
,
mesh
,
option_normals
,
option_colors
,
option_uv_coords
,
option_materials
,
flipyz
,
option_faces
),
...
@@ -858,6 +858,7 @@ def generate_ascii_model(mesh, scene,
...
@@ -858,6 +858,7 @@ def generate_ascii_model(mesh, scene,
def
export_mesh
(
obj
,
scene
,
filepath
,
def
export_mesh
(
obj
,
scene
,
filepath
,
option_vertices
,
option_vertices
,
option_vertices_truncate
,
option_faces
,
option_faces
,
option_normals
,
option_normals
,
option_edges
,
option_edges
,
...
@@ -866,7 +867,6 @@ def export_mesh(obj, scene, filepath,
...
@@ -866,7 +867,6 @@ def export_mesh(obj, scene, filepath,
option_colors
,
option_colors
,
align_model
,
align_model
,
flipyz
,
flipyz
,
option_truncate
,
option_scale
,
option_scale
,
export_single_model
):
export_single_model
):
...
@@ -912,6 +912,7 @@ def export_mesh(obj, scene, filepath,
...
@@ -912,6 +912,7 @@ def export_mesh(obj, scene, filepath,
text
=
generate_ascii_model
(
mesh
,
scene
,
text
=
generate_ascii_model
(
mesh
,
scene
,
option_vertices
,
option_vertices
,
option_vertices_truncate
,
option_faces
,
option_faces
,
option_normals
,
option_normals
,
option_edges
,
option_edges
,
...
@@ -920,7 +921,6 @@ def export_mesh(obj, scene, filepath,
...
@@ -920,7 +921,6 @@ def export_mesh(obj, scene, filepath,
option_colors
,
option_colors
,
align_model
,
align_model
,
flipyz
,
flipyz
,
option_truncate
,
option_scale
,
option_scale
,
obj
.
draw_type
)
obj
.
draw_type
)
...
@@ -1370,6 +1370,7 @@ def export_scene(scene, filepath, flipyz):
...
@@ -1370,6 +1370,7 @@ def export_scene(scene, filepath, flipyz):
def
save
(
operator
,
context
,
filepath
=
""
,
def
save
(
operator
,
context
,
filepath
=
""
,
option_flip_yz
=
True
,
option_flip_yz
=
True
,
option_vertices
=
True
,
option_vertices
=
True
,
option_vertices_truncate
=
False
,
option_faces
=
True
,
option_faces
=
True
,
option_normals
=
True
,
option_normals
=
True
,
option_edges
=
False
,
option_edges
=
False
,
...
@@ -1378,7 +1379,6 @@ def save(operator, context, filepath = "",
...
@@ -1378,7 +1379,6 @@ def save(operator, context, filepath = "",
option_colors
=
True
,
option_colors
=
True
,
align_model
=
0
,
align_model
=
0
,
option_export_scene
=
False
,
option_export_scene
=
False
,
option_truncate
=
False
,
option_scale
=
1.0
):
option_scale
=
1.0
):
filepath
=
ensure_extension
(
filepath
,
'.js'
)
filepath
=
ensure_extension
(
filepath
,
'.js'
)
...
@@ -1412,6 +1412,7 @@ def save(operator, context, filepath = "",
...
@@ -1412,6 +1412,7 @@ def save(operator, context, filepath = "",
fname
=
generate_mesh_filename
(
name
,
filepath
)
fname
=
generate_mesh_filename
(
name
,
filepath
)
export_mesh
(
obj
,
scene
,
fname
,
export_mesh
(
obj
,
scene
,
fname
,
option_vertices
,
option_vertices
,
option_vertices_truncate
,
option_faces
,
option_faces
,
option_normals
,
option_normals
,
option_edges
,
option_edges
,
...
@@ -1420,7 +1421,6 @@ def save(operator, context, filepath = "",
...
@@ -1420,7 +1421,6 @@ def save(operator, context, filepath = "",
option_colors
,
option_colors
,
False
,
False
,
option_flip_yz
,
option_flip_yz
,
option_truncate
,
option_scale
,
option_scale
,
False
)
False
)
...
@@ -1434,6 +1434,7 @@ def save(operator, context, filepath = "",
...
@@ -1434,6 +1434,7 @@ def save(operator, context, filepath = "",
export_mesh
(
obj
,
scene
,
filepath
,
export_mesh
(
obj
,
scene
,
filepath
,
option_vertices
,
option_vertices
,
option_vertices_truncate
,
option_faces
,
option_faces
,
option_normals
,
option_normals
,
option_edges
,
option_edges
,
...
@@ -1442,7 +1443,6 @@ def save(operator, context, filepath = "",
...
@@ -1442,7 +1443,6 @@ def save(operator, context, filepath = "",
option_colors
,
option_colors
,
align_model
,
align_model
,
option_flip_yz
,
option_flip_yz
,
option_truncate
,
option_scale
,
option_scale
,
True
)
True
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录