Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
3492312d
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,发现更多精彩内容 >>
提交
3492312d
编写于
4月 08, 2011
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge remote branch 'alteredq/master' into experimental
上级
9c68545b
5fcc6190
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
111 addition
and
18 deletion
+111
-18
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
...rters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
+97
-12
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
...blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
+14
-6
未找到文件。
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
浏览文件 @
3492312d
...
@@ -34,7 +34,6 @@ import bpy
...
@@ -34,7 +34,6 @@ import bpy
from
bpy.props
import
*
from
bpy.props
import
*
from
io_utils
import
ExportHelper
,
ImportHelper
from
io_utils
import
ExportHelper
,
ImportHelper
# ################################################################
# ################################################################
# Custom properties
# Custom properties
# ################################################################
# ################################################################
...
@@ -88,6 +87,7 @@ class MATERIAL_PT_hello( bpy.types.Panel ):
...
@@ -88,6 +87,7 @@ class MATERIAL_PT_hello( bpy.types.Panel ):
class
ImportTHREEJS
(
bpy
.
types
.
Operator
,
ImportHelper
):
class
ImportTHREEJS
(
bpy
.
types
.
Operator
,
ImportHelper
):
'''Load a Three.js ASCII JSON model'''
'''Load a Three.js ASCII JSON model'''
bl_idname
=
"import.threejs"
bl_idname
=
"import.threejs"
bl_label
=
"Import Three.js"
bl_label
=
"Import Three.js"
...
@@ -112,30 +112,113 @@ class ImportTHREEJS(bpy.types.Operator, ImportHelper):
...
@@ -112,30 +112,113 @@ class ImportTHREEJS(bpy.types.Operator, ImportHelper):
row
.
prop
(
self
.
properties
,
"recalculate_normals"
)
row
.
prop
(
self
.
properties
,
"recalculate_normals"
)
# ################################################################
# Exporter - settings
# ################################################################
SETTINGS_FILE_EXPORT
=
"threejs_settings_export.js"
import
os
import
json
def
file_exists
(
filename
):
"""Return true if file exists and accessible for reading.
Should be safer than just testing for existence due to links and
permissions magic on Unix filesystems.
@rtype: boolean
"""
try
:
f
=
open
(
filename
,
'r'
)
f
.
close
()
return
True
except
IOError
:
return
False
def
get_settings_fullpath
():
return
os
.
path
.
join
(
bpy
.
app
.
tempdir
,
SETTINGS_FILE_EXPORT
)
def
save_settings_export
(
properties
):
settings
=
{
"option_export_scene"
:
properties
.
option_export_scene
,
"option_flip_yz"
:
properties
.
option_flip_yz
,
"use_materials"
:
properties
.
use_materials
,
"use_normals"
:
properties
.
use_normals
,
"use_colors"
:
properties
.
use_colors
,
"use_uv_coords"
:
properties
.
use_uv_coords
,
"use_edges"
:
properties
.
use_edges
,
"option_truncate"
:
properties
.
option_truncate
,
"option_scale"
:
properties
.
option_scale
,
"align_model"
:
properties
.
align_model
}
fname
=
get_settings_fullpath
()
f
=
open
(
fname
,
"w"
)
json
.
dump
(
settings
,
f
)
def
restore_settings_export
(
properties
):
settings
=
{}
fname
=
get_settings_fullpath
()
if
file_exists
(
fname
):
f
=
open
(
fname
,
"r"
)
settings
=
json
.
load
(
f
)
properties
.
option_export_scene
=
settings
.
get
(
"option_export_scene"
,
False
)
properties
.
option_flip_yz
=
settings
.
get
(
"option_flip_yz"
,
True
)
properties
.
use_materials
=
settings
.
get
(
"use_materials"
,
True
)
properties
.
use_normals
=
settings
.
get
(
"use_normals"
,
True
)
properties
.
use_colors
=
settings
.
get
(
"use_colors"
,
True
)
properties
.
use_uv_coords
=
settings
.
get
(
"use_uv_coords"
,
True
)
properties
.
use_edges
=
settings
.
get
(
"use_edges"
,
False
)
properties
.
option_truncate
=
settings
.
get
(
"option_truncate"
,
False
)
properties
.
option_scale
=
settings
.
get
(
"option_scale"
,
1.0
)
properties
.
align_model
=
settings
.
get
(
"align_model"
,
"None"
)
# ################################################################
# ################################################################
# Exporter
# Exporter
# ################################################################
# ################################################################
class
ExportTHREEJS
(
bpy
.
types
.
Operator
,
ExportHelper
):
class
ExportTHREEJS
(
bpy
.
types
.
Operator
,
ExportHelper
):
'''Export selected object / scene for Three.js (ASCII JSON format).'''
'''Export selected object / scene for Three.js (ASCII JSON format).'''
bl_idname
=
"export.threejs"
bl_idname
=
"export.threejs"
bl_label
=
"Export Three.js"
bl_label
=
"Export Three.js"
filename_ext
=
".js"
filename_ext
=
".js"
option_flip_yz
=
BoolProperty
(
name
=
"Flip YZ"
,
description
=
"Flip YZ"
,
default
=
True
)
option_flip_yz
=
BoolProperty
(
name
=
"Flip YZ"
,
description
=
"Flip YZ"
,
default
=
True
)
use_materials
=
BoolProperty
(
name
=
"Materials"
,
description
=
"Export materials"
,
default
=
True
)
use_normals
=
BoolProperty
(
name
=
"Normals"
,
description
=
"Export normals"
,
default
=
True
)
use_colors
=
BoolProperty
(
name
=
"Colors"
,
description
=
"Export vertex colors"
,
default
=
True
)
use_uv_coords
=
BoolProperty
(
name
=
"UVs"
,
description
=
"Export texture coordinates"
,
default
=
True
)
use_edges
=
BoolProperty
(
name
=
"Edges"
,
description
=
"Export edges"
,
default
=
False
)
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"
)]
use_materials
=
BoolProperty
(
name
=
"Materials"
,
description
=
"Export materials"
,
default
=
True
)
align_model
=
EnumProperty
(
name
=
"Align model"
,
description
=
"Align model"
,
items
=
align_types
,
default
=
"None"
)
use_normals
=
BoolProperty
(
name
=
"Normals"
,
description
=
"Export normals"
,
default
=
True
)
use_colors
=
BoolProperty
(
name
=
"Colors"
,
description
=
"Export vertex colors"
,
default
=
True
)
use_uv_coords
=
BoolProperty
(
name
=
"UVs"
,
description
=
"Export texture coordinates"
,
default
=
True
)
use_edges
=
BoolProperty
(
name
=
"Edges"
,
description
=
"Export edges"
,
default
=
False
)
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"
)
def
invoke
(
self
,
context
,
event
):
restore_settings_export
(
self
.
properties
)
return
ExportHelper
.
invoke
(
self
,
context
,
event
)
@
classmethod
@
classmethod
def
poll
(
cls
,
context
):
def
poll
(
cls
,
context
):
return
context
.
active_object
!=
None
return
context
.
active_object
!=
None
...
@@ -146,6 +229,8 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
...
@@ -146,6 +229,8 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
if
not
self
.
properties
.
filepath
:
if
not
self
.
properties
.
filepath
:
raise
Exception
(
"filename not set"
)
raise
Exception
(
"filename not set"
)
save_settings_export
(
self
.
properties
)
filepath
=
self
.
filepath
filepath
=
self
.
filepath
import
io_mesh_threejs.export_threejs
import
io_mesh_threejs.export_threejs
return
io_mesh_threejs
.
export_threejs
.
save
(
self
,
context
,
**
self
.
properties
)
return
io_mesh_threejs
.
export_threejs
.
save
(
self
,
context
,
**
self
.
properties
)
...
...
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
浏览文件 @
3492312d
...
@@ -709,9 +709,13 @@ def extract_materials(mesh, scene, use_colors):
...
@@ -709,9 +709,13 @@ def extract_materials(mesh, scene, use_colors):
m
.
specular_intensity
*
m
.
specular_color
[
1
],
m
.
specular_intensity
*
m
.
specular_color
[
1
],
m
.
specular_intensity
*
m
.
specular_color
[
2
]]
m
.
specular_intensity
*
m
.
specular_color
[
2
]]
material
[
'colorAmbient'
]
=
[
m
.
ambient
*
world
.
ambient_color
[
0
],
world_ambient_color
=
[
0
,
0
,
0
]
m
.
ambient
*
world
.
ambient_color
[
1
],
if
world
:
m
.
ambient
*
world
.
ambient_color
[
2
]]
world_ambient_color
=
world
.
ambient_color
material
[
'colorAmbient'
]
=
[
m
.
ambient
*
world_ambient_color
[
0
],
m
.
ambient
*
world_ambient_color
[
1
],
m
.
ambient
*
world_ambient_color
[
2
]]
material
[
'transparency'
]
=
m
.
alpha
material
[
'transparency'
]
=
m
.
alpha
...
@@ -1097,9 +1101,13 @@ def extract_material_data(m):
...
@@ -1097,9 +1101,13 @@ def extract_material_data(m):
m
.
specular_intensity
*
m
.
specular_color
[
1
],
m
.
specular_intensity
*
m
.
specular_color
[
1
],
m
.
specular_intensity
*
m
.
specular_color
[
2
]]
m
.
specular_intensity
*
m
.
specular_color
[
2
]]
material
[
'colorAmbient'
]
=
[
m
.
ambient
*
world
.
ambient_color
[
0
],
world_ambient_color
=
[
0
,
0
,
0
]
m
.
ambient
*
world
.
ambient_color
[
1
],
if
world
:
m
.
ambient
*
world
.
ambient_color
[
2
]]
world_ambient_color
=
world
.
ambient_color
material
[
'colorAmbient'
]
=
[
m
.
ambient
*
world_ambient_color
[
0
],
m
.
ambient
*
world_ambient_color
[
1
],
m
.
ambient
*
world_ambient_color
[
2
]]
material
[
'transparency'
]
=
m
.
alpha
material
[
'transparency'
]
=
m
.
alpha
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录