Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
cfc306e2
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,发现更多精彩内容 >>
提交
cfc306e2
编写于
10月 07, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5413 from HMUDesign/dev
cleanup generated JSON
上级
9c28444c
89d02510
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
172 addition
and
184 deletion
+172
-184
utils/exporters/blender/2.65/scripts/addons/io_mesh_threejs/export_threejs.py
...der/2.65/scripts/addons/io_mesh_threejs/export_threejs.py
+172
-184
未找到文件。
utils/exporters/blender/2.65/scripts/addons/io_mesh_threejs/export_threejs.py
浏览文件 @
cfc306e2
...
...
@@ -85,172 +85,166 @@ MAX_INFLUENCES = 2
TEMPLATE_SCENE_ASCII
=
"""
\
{
"metadata" :
{
"formatVersion" : 3.2,
"type" : "scene",
"sourceFile" : "%(fname)s",
"generatedBy" : "Blender 2.7 Exporter",
"objects" : %(nobjects)s,
"geometries" : %(ngeometries)s,
"materials" : %(nmaterials)s,
"textures" : %(ntextures)s
},
"urlBaseType" : %(basetype)s,
"urlBaseType": %(basetype)s,
"metadata": {
"formatVersion" : 3.2,
"type" : "scene",
"sourceFile" : "%(fname)s",
"generatedBy" : "Blender 2.7 Exporter",
"objects" : %(nobjects)s,
"geometries" : %(ngeometries)s,
"materials" : %(nmaterials)s,
"textures" : %(ntextures)s
},
%(sections)s
"transform": {
"position" : %(position)s,
"rotation" : %(rotation)s,
"scale" : %(scale)s
},
"transform" :
{
"position" : %(position)s,
"rotation" : %(rotation)s,
"scale" : %(scale)s
},
"defaults" :
{
"bgcolor" : %(bgcolor)s,
"bgalpha" : %(bgalpha)f,
"camera" : %(defcamera)s
}
"defaults": {
"bgcolor" : %(bgcolor)s,
"bgalpha" : %(bgalpha)f,
"camera" : %(defcamera)s
}
}
"""
TEMPLATE_SECTION
=
"""
"%s" :
{
"%s": {
%s
},
},
"""
TEMPLATE_OBJECT
=
"""
\
%(object_id)s
: {
"geometry"
: %(geometry_id)s,
"groups"
: [ %(group_id)s ],
"material"
: %(material_id)s,
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"quaternion"
: %(quaternion)s,
"scale"
: %(scale)s,
"visible" : %(visible)s,
"castShadow" : %(castShadow)s,
"receiveShadow" : %(receiveShadow)s,
"doubleSided" : %(doubleSided)s
}"""
%(object_id)s
: {
"geometry"
: %(geometry_id)s,
"groups"
: [ %(group_id)s ],
"material"
: %(material_id)s,
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"quaternion"
: %(quaternion)s,
"scale"
: %(scale)s,
"visible" : %(visible)s,
"castShadow" : %(castShadow)s,
"receiveShadow" : %(receiveShadow)s,
"doubleSided" : %(doubleSided)s
}"""
TEMPLATE_EMPTY
=
"""
\
%(object_id)s
: {
"groups"
: [ %(group_id)s ],
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"quaternion"
: %(quaternion)s,
"scale"
: %(scale)s
}"""
%(object_id)s
: {
"groups"
: [ %(group_id)s ],
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"quaternion"
: %(quaternion)s,
"scale"
: %(scale)s
}"""
TEMPLATE_GEOMETRY_LINK
=
"""
\
%(geometry_id)s
: {
"type" : "ascii",
"url" : %(model_file)s
}"""
%(geometry_id)s
: {
"type" : "ascii",
"url" : %(model_file)s
}"""
TEMPLATE_GEOMETRY_EMBED
=
"""
\
%(geometry_id)s
: {
"type" : "embedded",
"id"
: %(embed_id)s
}"""
%(geometry_id)s
: {
"type" : "embedded",
"id"
: %(embed_id)s
}"""
TEMPLATE_TEXTURE
=
"""
\
%(texture_id)s
: {
"url"
: %(texture_file)s%(extras)s
}"""
%(texture_id)s
: {
"url"
: %(texture_file)s%(extras)s
}"""
TEMPLATE_MATERIAL_SCENE
=
"""
\
%(material_id)s
: {
"type"
: %(type)s,
"parameters"
: { %(parameters)s }
}"""
%(material_id)s
: {
"type"
: %(type)s,
"parameters"
: { %(parameters)s }
}"""
TEMPLATE_CAMERA_PERSPECTIVE
=
"""
\
%(camera_id)s
: {
"type"
: "PerspectiveCamera",
"fov"
: %(fov)f,
"aspect"
: %(aspect)f,
"near"
: %(near)f,
"far"
: %(far)f,
"position"
: %(position)s,
"target"
: %(target)s
}"""
%(camera_id)s
: {
"type"
: "PerspectiveCamera",
"fov"
: %(fov)f,
"aspect"
: %(aspect)f,
"near"
: %(near)f,
"far"
: %(far)f,
"position"
: %(position)s,
"target"
: %(target)s
}"""
TEMPLATE_CAMERA_ORTHO
=
"""
\
%(camera_id)s
: {
"type"
: "OrthographicCamera",
"left"
: %(left)f,
"right"
: %(right)f,
"top"
: %(top)f,
"bottom"
: %(bottom)f,
"near"
: %(near)f,
"far"
: %(far)f,
"position"
: %(position)s,
"target"
: %(target)s
}"""
%(camera_id)s
: {
"type"
: "OrthographicCamera",
"left"
: %(left)f,
"right"
: %(right)f,
"top"
: %(top)f,
"bottom"
: %(bottom)f,
"near"
: %(near)f,
"far"
: %(far)f,
"position"
: %(position)s,
"target"
: %(target)s
}"""
TEMPLATE_LIGHT_POINT
=
"""
\
%(light_id)s
: {
"type"
: "PointLight",
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"color"
: %(color)d,
"distance"
: %(distance).3f,
"intensity"
: %(intensity).3f
}"""
%(light_id)s
: {
"type"
: "PointLight",
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"color"
: %(color)d,
"distance"
: %(distance).3f,
"intensity"
: %(intensity).3f
}"""
TEMPLATE_LIGHT_SUN
=
"""
\
%(light_id)s
: {
"type"
: "AmbientLight",
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"color"
: %(color)d,
"distance"
: %(distance).3f,
"intensity"
: %(intensity).3f
}"""
%(light_id)s
: {
"type"
: "AmbientLight",
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"color"
: %(color)d,
"distance"
: %(distance).3f,
"intensity"
: %(intensity).3f
}"""
TEMPLATE_LIGHT_SPOT
=
"""
\
%(light_id)s
: {
"type" : "SpotLight",
"position" : %(position)s,
"rotation" : %(rotation)s,
"color" : %(color)d,
"distance" : %(distance).3f,
"intensity" : %(intensity).3f,
"use_shadow" : %(use_shadow)d,
"angle" : %(angle).3f
}"""
%(light_id)s
: {
"type" : "SpotLight",
"position" : %(position)s,
"rotation" : %(rotation)s,
"color" : %(color)d,
"distance" : %(distance).3f,
"intensity" : %(intensity).3f,
"use_shadow" : %(use_shadow)d,
"angle" : %(angle).3f
}"""
TEMPLATE_LIGHT_HEMI
=
"""
\
%(light_id)s
: {
"type"
: "HemisphereLight",
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"color"
: %(color)d,
"distance"
: %(distance).3f,
"intensity"
: %(intensity).3f
}"""
%(light_id)s
: {
"type"
: "HemisphereLight",
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"color"
: %(color)d,
"distance"
: %(distance).3f,
"intensity"
: %(intensity).3f
}"""
TEMPLATE_LIGHT_AREA
=
"""
\
%(light_id)s
: {
"type"
: "AreaLight",
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"color"
: %(color)d,
"distance"
: %(distance).3f,
"intensity"
: %(intensity).3f,
"gamma"
: %(gamma).3f,
"shape"
: "%(shape)s",
"size"
: %(size).3f,
"size_y"
: %(size_y).3f
}"""
%(light_id)s
: {
"type"
: "AreaLight",
"position"
: %(position)s,
"rotation"
: %(rotation)s,
"color"
: %(color)d,
"distance"
: %(distance).3f,
"intensity"
: %(intensity).3f,
"gamma"
: %(gamma).3f,
"shape"
: "%(shape)s",
"size"
: %(size).3f,
"size_y"
: %(size_y).3f
}"""
TEMPLATE_VEC4
=
'[ %g, %g, %g, %g ]'
...
...
@@ -264,51 +258,45 @@ TEMPLATE_HEX = "0x%06x"
# #####################################################
TEMPLATE_FILE_ASCII
=
"""
\
{
"metadata" :
{
"formatVersion" : 3.1,
"generatedBy" : "Blender 2.7 Exporter",
"vertices" : %(nvertex)d,
"faces" : %(nface)d,
"normals" : %(nnormal)d,
"colors" : %(ncolor)d,
"uvs" : [%(nuvs)s],
"materials" : %(nmaterial)d,
"morphTargets" : %(nmorphTarget)d,
"bones" : %(nbone)d
},
"metadata": {
"formatVersion" : 3.1,
"generatedBy" : "Blender 2.7 Exporter",
"vertices" : %(nvertex)d,
"faces" : %(nface)d,
"normals" : %(nnormal)d,
"colors" : %(ncolor)d,
"uvs" : [%(nuvs)s],
"materials" : %(nmaterial)d,
"morphTargets" : %(nmorphTarget)d,
"bones" : %(nbone)d
},
%(model)s
}
}
"""
TEMPLATE_MODEL_ASCII
=
"""
\
"scale" : %(scale)f,
"materials" : [%(materials)s],
"vertices" : [%(vertices)s],
"morphTargets" : [%(morphTargets)s],
"normals" : [%(normals)s],
"colors" : [%(colors)s],
"uvs" : [%(uvs)s],
"faces" : [%(faces)s],
"bones" : [%(bones)s],
"skinIndices" : [%(indices)s],
"skinWeights" : [%(weights)s],
"animations" : [%(animations)s]
"scale" : %(scale)f,
"vertices" : [%(vertices)s],
"faces" : [%(faces)s],
"uvs" : [%(uvs)s],
"normals" : [%(normals)s],
"skinIndices" : [%(indices)s],
"skinWeights" : [%(weights)s],
"morphTargets" : [%(morphTargets)s],
"bones" : [%(bones)s],
"animations" : [%(animations)s],
"colors" : [%(colors)s],
"materials" : [
%(materials)s
]
"""
TEMPLATE_VERTEX
=
"%g,%g,%g"
...
...
@@ -1318,11 +1306,11 @@ def generate_materials(mtl, materials, draw_type):
mtl
[
m
][
'wireframe'
]
=
True
mtl
[
m
][
'DbgColor'
]
=
0xff0000
mtl_raw
=
",
\n
"
.
join
([
'
\t\t
"%s"
: %s'
%
(
n
,
value2string
(
v
))
for
n
,
v
in
sorted
(
mtl
[
m
].
items
())])
mtl_string
=
"
\t
{
\n
%s
\n
\t
}"
%
mtl_raw
mtl_raw
=
",
\n
"
.
join
([
'
\t\t
\t\t\t
"%s"
: %s'
%
(
n
,
value2string
(
v
))
for
n
,
v
in
sorted
(
mtl
[
m
].
items
())])
mtl_string
=
"
\t
\t\t\t
{
\n
%s
\n\t\t\t
\t
}"
%
mtl_raw
mtl_array
.
append
([
index
,
mtl_string
])
return
",
\n
\n
"
.
join
([
m
for
i
,
m
in
sorted
(
mtl_array
)]),
len
(
mtl_array
)
return
",
\n
"
.
join
([
m
for
i
,
m
in
sorted
(
mtl_array
)]),
len
(
mtl_array
)
def
extract_materials
(
mesh
,
scene
,
option_colors
,
option_copy_textures
,
filepath
):
world
=
scene
.
world
...
...
@@ -1554,7 +1542,7 @@ def generate_ascii_model(meshes, morphs,
bones_string
,
nbone
=
generate_bones
(
meshes
,
option_bones
,
flipyz
)
indices_string
,
weights_string
=
generate_indices_and_weights
(
meshes
,
option_skinning
)
materials_string
=
",
\n
\n
"
.
join
(
materials
)
materials_string
=
",
\n
"
.
join
(
materials
)
model_string
=
TEMPLATE_MODEL_ASCII
%
{
"scale"
:
option_scale
,
...
...
@@ -1933,7 +1921,7 @@ def generate_objects(data):
}
chunks
.
append
(
object_string
)
return
",
\n
\n
"
.
join
(
chunks
),
len
(
chunks
)
return
",
\n
"
.
join
(
chunks
),
len
(
chunks
)
# #####################################################
# Scene exporter - geometries
...
...
@@ -1978,7 +1966,7 @@ def generate_geometries(data):
geo_set
.
add
(
name
)
return
",
\n
\n
"
.
join
(
chunks
),
len
(
chunks
)
return
",
\n
"
.
join
(
chunks
),
len
(
chunks
)
# #####################################################
# Scene exporter - textures
...
...
@@ -2015,7 +2003,7 @@ def generate_textures_scene(data):
if
texture
.
use_mirror_y
:
wrap_y
=
"mirror"
extras
+=
',
\n
"wrap": ["%s", "%s"]'
%
(
wrap_x
,
wrap_y
)
extras
+=
',
\n
\t\t\t
"wrap": ["%s", "%s"]'
%
(
wrap_x
,
wrap_y
)
texture_string
=
TEMPLATE_TEXTURE
%
{
"texture_id"
:
generate_string
(
texture_id
),
...
...
@@ -2024,7 +2012,7 @@ def generate_textures_scene(data):
}
chunks
.
append
(
texture_string
)
return
",
\n
\n
"
.
join
(
chunks
),
len
(
chunks
)
return
",
\n
"
.
join
(
chunks
),
len
(
chunks
)
def
extract_texture_filename
(
image
):
fn
=
bpy
.
path
.
abspath
(
image
.
filepath
)
...
...
@@ -2257,7 +2245,7 @@ def generate_materials_scene(data):
material_string
=
generate_material_string
(
material
)
chunks
.
append
(
material_string
)
return
",
\n
\n
"
.
join
(
chunks
),
len
(
chunks
)
return
",
\n
"
.
join
(
chunks
),
len
(
chunks
)
# #####################################################
# Scene exporter - cameras
...
...
@@ -2335,7 +2323,7 @@ def generate_cameras(data):
chunks
.
append
(
camera_string
)
return
",
\n
\n
"
.
join
(
chunks
),
len
(
chunks
)
return
",
\n
"
.
join
(
chunks
),
len
(
chunks
)
# #####################################################
# Scene exporter - lights
...
...
@@ -2409,7 +2397,7 @@ def generate_lights(data):
if
not
lamps
:
lamps
.
append
(
DEFAULTS
[
"light"
])
return
",
\n
\n
"
.
join
(
chunks
),
len
(
chunks
)
return
",
\n
"
.
join
(
chunks
),
len
(
chunks
)
# #####################################################
# Scene exporter - embedded meshes
...
...
@@ -2423,10 +2411,10 @@ def generate_embeds(data):
for
e
in
data
[
"embeds"
]:
embed
=
'
"emb_%s": {%s
}'
%
(
e
,
data
[
"embeds"
][
e
])
embed
=
'
\t\t
"emb_%s": {
\n
%s
\t\t
}'
%
(
e
,
data
[
"embeds"
][
e
])
chunks
.
append
(
embed
)
return
",
\n
\n
"
.
join
(
chunks
)
return
",
\n
"
.
join
(
chunks
)
return
""
...
...
@@ -2447,14 +2435,14 @@ def generate_ascii_scene(data):
if
nlights
>
0
:
if
nobjects
>
0
:
objects
=
objects
+
",
\n
\n
"
+
lights
objects
=
objects
+
",
\n
"
+
lights
else
:
objects
=
lights
nobjects
+=
nlights
if
ncameras
>
0
:
if
nobjects
>
0
:
objects
=
objects
+
",
\n
\n
"
+
cameras
objects
=
objects
+
",
\n
"
+
cameras
else
:
objects
=
cameras
nobjects
+=
ncameras
...
...
@@ -2479,7 +2467,7 @@ def generate_ascii_scene(data):
if
content
:
chunks
.
append
(
generate_section
(
label
,
content
))
sections_string
=
"
\n
"
.
join
(
chunks
)
sections_string
=
""
.
join
(
chunks
)
default_camera
=
""
if
data
[
"use_cameras"
]:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录