Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
932ee2d4
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,发现更多精彩内容 >>
提交
932ee2d4
编写于
2月 24, 2015
作者:
M
mese79
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add support for texture folder
上级
43c5354f
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
40 addition
and
44 deletion
+40
-44
utils/exporters/blender/addons/io_three/__init__.py
utils/exporters/blender/addons/io_three/__init__.py
+14
-3
utils/exporters/blender/addons/io_three/constants.py
utils/exporters/blender/addons/io_three/constants.py
+7
-5
utils/exporters/blender/addons/io_three/exporter/__init__.py
utils/exporters/blender/addons/io_three/exporter/__init__.py
+5
-18
utils/exporters/blender/addons/io_three/exporter/api/__init__.py
...xporters/blender/addons/io_three/exporter/api/__init__.py
+0
-10
utils/exporters/blender/addons/io_three/exporter/api/material.py
...xporters/blender/addons/io_three/exporter/api/material.py
+1
-1
utils/exporters/blender/addons/io_three/exporter/api/texture.py
...exporters/blender/addons/io_three/exporter/api/texture.py
+6
-3
utils/exporters/blender/addons/io_three/exporter/geometry.py
utils/exporters/blender/addons/io_three/exporter/geometry.py
+2
-2
utils/exporters/blender/addons/io_three/exporter/image.py
utils/exporters/blender/addons/io_three/exporter/image.py
+2
-1
utils/exporters/blender/addons/io_three/exporter/io.py
utils/exporters/blender/addons/io_three/exporter/io.py
+1
-0
utils/exporters/blender/addons/io_three/exporter/scene.py
utils/exporters/blender/addons/io_three/exporter/scene.py
+2
-1
未找到文件。
utils/exporters/blender/addons/io_three/__init__.py
浏览文件 @
932ee2d4
...
...
@@ -26,7 +26,8 @@ from bpy.props import (
EnumProperty
,
BoolProperty
,
FloatProperty
,
IntProperty
IntProperty
,
StringProperty
)
from
.
import
constants
...
...
@@ -41,7 +42,7 @@ SETTINGS_FILE_EXPORT = 'three_settings_export.js'
bl_info
=
{
'name'
:
"Three.js Format"
,
'author'
:
"repsac, mrdoob, yomotsu, mpk, jpweeks"
,
'version'
:
(
1
,
2
,
3
),
'version'
:
(
1
,
2
,
2
),
'blender'
:
(
2
,
7
,
3
),
'location'
:
"File > Export"
,
'description'
:
"Export Three.js formatted JSON files."
,
...
...
@@ -295,6 +296,7 @@ def save_settings_export(properties):
constants
.
COMPRESSION
:
properties
.
option_compression
,
constants
.
INDENT
:
properties
.
option_indent
,
constants
.
COPY_TEXTURES
:
properties
.
option_copy_textures
,
constants
.
TEXTURE_FOLDER
:
properties
.
option_texture_folder
,
constants
.
SCENE
:
properties
.
option_export_scene
,
#constants.EMBED_GEOMETRY: properties.option_embed_geometry,
...
...
@@ -420,6 +422,10 @@ def restore_settings_export(properties):
constants
.
COPY_TEXTURES
,
constants
.
EXPORT_OPTIONS
[
constants
.
COPY_TEXTURES
])
properties
.
option_texture_folder
=
settings
.
get
(
constants
.
TEXTURE_FOLDER
,
constants
.
EXPORT_OPTIONS
[
constants
.
TEXTURE_FOLDER
])
properties
.
option_embed_animation
=
settings
.
get
(
constants
.
EMBED_ANIMATION
,
constants
.
EXPORT_OPTIONS
[
constants
.
EMBED_ANIMATION
])
...
...
@@ -617,6 +623,9 @@ class ExportThree(bpy.types.Operator, ExportHelper):
description
=
"Copy textures"
,
default
=
constants
.
EXPORT_OPTIONS
[
constants
.
COPY_TEXTURES
])
option_texture_folder
=
StringProperty
(
name
=
"Texture folder"
,
description
=
"add this folder to textures path"
,
default
=
""
)
option_lights
=
BoolProperty
(
name
=
"Lights"
,
description
=
"Export default scene lights"
,
...
...
@@ -693,7 +702,6 @@ class ExportThree(bpy.types.Operator, ExportHelper):
raise
Exception
(
"filename not set"
)
settings
=
save_settings_export
(
self
.
properties
)
settings
[
'addon_version'
]
=
bl_info
[
'version'
]
filepath
=
self
.
filepath
if
settings
[
constants
.
COMPRESSION
]
==
constants
.
MSGPACK
:
...
...
@@ -812,6 +820,9 @@ class ExportThree(bpy.types.Operator, ExportHelper):
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
'option_copy_textures'
)
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"option_texture_folder"
)
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
'option_scale'
)
...
...
utils/exporters/blender/addons/io_three/constants.py
浏览文件 @
932ee2d4
...
...
@@ -63,6 +63,7 @@ LIGHTS = 'lights'
FACE_MATERIALS
=
'faceMaterials'
SKINNING
=
'skinning'
COPY_TEXTURES
=
'copyTextures'
TEXTURE_FOLDER
=
"texture_folder"
ENABLE_PRECISION
=
'enablePrecision'
PRECISION
=
'precision'
DEFAULT_PRECISION
=
6
...
...
@@ -91,18 +92,18 @@ INFLUENCES_PER_VERTEX = 'influencesPerVertex'
EXPORT_OPTIONS
=
{
FACES
:
True
,
VERTICES
:
True
,
NORMALS
:
Fals
e
,
UVS
:
Fals
e
,
NORMALS
:
Tru
e
,
UVS
:
Tru
e
,
COLORS
:
False
,
MATERIALS
:
Fals
e
,
MATERIALS
:
Tru
e
,
FACE_MATERIALS
:
False
,
SCALE
:
1
,
FRAME_STEP
:
1
,
FRAME_INDEX_AS_TIME
:
False
,
SCENE
:
Fals
e
,
SCENE
:
Tru
e
,
MIX_COLORS
:
False
,
COMPRESSION
:
None
,
MAPS
:
Fals
e
,
MAPS
:
Tru
e
,
ANIMATION
:
OFF
,
BONES
:
False
,
SKINNING
:
False
,
...
...
@@ -110,6 +111,7 @@ EXPORT_OPTIONS = {
CAMERAS
:
False
,
LIGHTS
:
False
,
COPY_TEXTURES
:
True
,
TEXTURE_FOLDER
:
""
,
LOGGING
:
DEBUG
,
ENABLE_PRECISION
:
True
,
PRECISION
:
DEFAULT_PRECISION
,
...
...
utils/exporters/blender/addons/io_three/exporter/__init__.py
浏览文件 @
932ee2d4
import
os
import
sys
import
traceback
from
..
import
constants
,
logger
,
exceptions
,
dialogs
from
..
import
constants
,
logger
,
exceptions
from
.
import
scene
,
geometry
,
api
,
base_classes
...
...
@@ -9,10 +9,7 @@ def _error_handler(func):
def
inner
(
filepath
,
options
,
*
args
,
**
kwargs
):
level
=
options
.
get
(
constants
.
LOGGING
,
constants
.
DEBUG
)
version
=
options
.
get
(
'addon_version'
)
logger
.
init
(
'io_three.export.log'
,
level
=
level
)
if
version
is
not
None
:
logger
.
debug
(
"Addon Version %s"
,
version
)
api
.
init
()
try
:
...
...
@@ -58,26 +55,16 @@ def export_scene(filepath, options):
@
_error_handler
def
export_geometry
(
filepath
,
options
,
node
=
None
):
msg
=
""
exception
=
None
if
node
is
None
:
node
=
api
.
active_object
()
if
node
is
None
:
msg
=
"Nothing selected"
msg
=
'Nothing selected'
logger
.
error
(
msg
)
exception
=
exceptions
.
SelectionError
raise
exceptions
.
SelectionError
(
msg
)
if
node
.
type
!=
'MESH'
:
msg
=
"%s is not a valid mesh object"
%
node
.
name
logger
.
error
(
msg
)
exception
=
exceptions
.
GeometryError
msg
=
'Not a valid mesh object'
raise
exceptions
.
GeometryError
(
msg
)
if
exception
is
not
None
:
if
api
.
batch_mode
():
raise
exception
(
msg
)
else
:
dialogs
.
error
(
msg
)
return
mesh
=
api
.
object
.
mesh
(
node
,
options
)
parent
=
base_classes
.
BaseScene
(
filepath
,
options
)
geo
=
geometry
.
Geometry
(
mesh
,
parent
)
...
...
utils/exporters/blender/addons/io_three/exporter/api/__init__.py
浏览文件 @
932ee2d4
...
...
@@ -13,16 +13,6 @@ def active_object():
return
bpy
.
context
.
scene
.
objects
.
active
def
batch_mode
():
"""
:return: Whether or not the session is interactive
:rtype: bool
"""
return
bpy
.
context
.
area
is
None
def
init
():
"""Initializing the api module. Required first step before
initializing the actual export process.
...
...
utils/exporters/blender/addons/io_three/exporter/api/material.py
浏览文件 @
932ee2d4
...
...
@@ -380,7 +380,7 @@ def _valid_textures(material):
for
texture
in
material
.
texture_slots
:
if
not
texture
:
continue
if
texture
.
texture
.
type
!=
IMAGE
:
if
texture
.
texture
.
type
!=
IMAGE
or
not
texture
.
use
:
continue
logger
.
debug
(
"Valid texture found %s"
,
texture
)
yield
texture
utils/exporters/blender/addons/io_three/exporter/api/texture.py
浏览文件 @
932ee2d4
...
...
@@ -170,6 +170,9 @@ def textures():
"""
logger
.
debug
(
"texture.textures()"
)
for
texture
in
data
.
textures
:
if
texture
.
type
==
IMAGE
:
yield
texture
.
name
for
mat
in
data
.
materials
:
if
mat
.
users
==
0
:
continue
for
slot
in
mat
.
texture_slots
:
if
slot
and
slot
.
use
and
slot
.
texture
.
type
==
IMAGE
:
yield
slot
.
texture
.
name
utils/exporters/blender/addons/io_three/exporter/geometry.py
浏览文件 @
932ee2d4
...
...
@@ -135,7 +135,7 @@ class Geometry(base_classes.BaseNode):
return
data
def
copy_textures
(
self
):
def
copy_textures
(
self
,
texture_folder
=
""
):
"""Copy the textures to the destination directory."""
logger
.
debug
(
"Geometry().copy_textures()"
)
if
self
.
options
.
get
(
constants
.
COPY_TEXTURES
):
...
...
@@ -143,7 +143,7 @@ class Geometry(base_classes.BaseNode):
if
texture_registration
:
logger
.
info
(
"%s has registered textures"
,
self
.
node
)
io
.
copy_registered_textures
(
os
.
path
.
dirname
(
self
.
scene
.
filepath
),
os
.
path
.
join
(
os
.
path
.
dirname
(
self
.
scene
.
filepath
),
texture_folder
),
texture_registration
)
def
parse
(
self
):
...
...
utils/exporters/blender/addons/io_three/exporter/image.py
浏览文件 @
932ee2d4
...
...
@@ -11,7 +11,8 @@ class Image(base_classes.BaseNode):
logger
.
debug
(
"Image().__init__(%s)"
,
node
)
base_classes
.
BaseNode
.
__init__
(
self
,
node
,
parent
,
constants
.
IMAGE
)
self
[
constants
.
URL
]
=
api
.
image
.
file_name
(
self
.
node
)
texture_folder
=
self
.
scene
.
options
.
get
(
constants
.
TEXTURE_FOLDER
,
""
)
self
[
constants
.
URL
]
=
os
.
path
.
join
(
texture_folder
,
api
.
image
.
file_name
(
self
.
node
))
@
property
def
destination
(
self
):
...
...
utils/exporters/blender/addons/io_three/exporter/io.py
浏览文件 @
932ee2d4
...
...
@@ -14,6 +14,7 @@ def copy_registered_textures(dest, registration):
"""
logger
.
debug
(
"io.copy_registered_textures(%s, %s)"
,
dest
,
registration
)
os
.
makedirs
(
dest
,
exist_ok
=
True
)
for
value
in
registration
.
values
():
copy
(
value
[
'file_path'
],
dest
)
...
...
utils/exporters/blender/addons/io_three/exporter/scene.py
浏览文件 @
932ee2d4
...
...
@@ -159,9 +159,10 @@ class Scene(base_classes.BaseScene):
io
.
dump
(
self
.
filepath
,
data
,
options
=
self
.
options
)
if
self
.
options
.
get
(
constants
.
COPY_TEXTURES
):
texture_folder
=
self
.
options
.
get
(
constants
.
TEXTURE_FOLDER
)
for
geo
in
self
[
constants
.
GEOMETRIES
]:
logger
.
info
(
"Copying textures from %s"
,
geo
.
node
)
geo
.
copy_textures
()
geo
.
copy_textures
(
texture_folder
)
def
_parse_geometries
(
self
):
"""Locate all geometry nodes and parse them"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录