Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
6c1b9c58
T
three.js
项目概览
Ablesons
/
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,发现更多精彩内容 >>
提交
6c1b9c58
编写于
3月 26, 2011
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge remote branch 'alteredq/master'
上级
59443e57
812c6dff
变更
23
展开全部
隐藏空白更改
内联
并排
Showing
23 changed file
with
556 addition
and
294 deletion
+556
-294
examples/obj/blenderscene/scene.Cube.js
examples/obj/blenderscene/scene.Cube.js
+10
-12
examples/obj/blenderscene/scene.Monkey.js
examples/obj/blenderscene/scene.Monkey.js
+10
-12
examples/obj/blenderscene/scene.Plane.js
examples/obj/blenderscene/scene.Plane.js
+10
-12
examples/obj/blenderscene/scene.js
examples/obj/blenderscene/scene.js
+112
-31
examples/obj/cubecolors/cube_fvc.blend
examples/obj/cubecolors/cube_fvc.blend
+0
-0
examples/obj/cubecolors/cube_fvc.js
examples/obj/cubecolors/cube_fvc.js
+13
-15
examples/obj/cubecolors/cubecolors.js
examples/obj/cubecolors/cubecolors.js
+11
-11
examples/obj/female02/Female02_bin.js
examples/obj/female02/Female02_bin.js
+9
-11
examples/obj/female02/Female02_slim.js
examples/obj/female02/Female02_slim.js
+14
-16
examples/obj/lucy/Lucy100k_bin.js
examples/obj/lucy/Lucy100k_bin.js
+4
-6
examples/obj/lucy/Lucy100k_slim.js
examples/obj/lucy/Lucy100k_slim.js
+9
-11
examples/obj/male02/Male02_bin.js
examples/obj/male02/Male02_bin.js
+8
-10
examples/obj/male02/Male02_slim.js
examples/obj/male02/Male02_slim.js
+13
-15
examples/obj/ninja/NinjaLo_bin.js
examples/obj/ninja/NinjaLo_bin.js
+4
-6
examples/obj/torus/Torus_bin.js
examples/obj/torus/Torus_bin.js
+4
-6
examples/obj/torus/Torus_slim.js
examples/obj/torus/Torus_slim.js
+9
-11
examples/obj/walt/WaltHead_bin.js
examples/obj/walt/WaltHead_bin.js
+4
-6
examples/obj/walt/WaltHead_slim.js
examples/obj/walt/WaltHead_slim.js
+9
-11
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
...rters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
+49
-9
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
...blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
+97
-46
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py
...blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py
+120
-0
utils/exporters/convert_obj_three.py
utils/exporters/convert_obj_three.py
+16
-18
utils/exporters/max/ThreeJSExporter.ms
utils/exporters/max/ThreeJSExporter.ms
+21
-19
未找到文件。
examples/obj/blenderscene/scene.Cube.js
浏览文件 @
6c1b9c58
...
...
@@ -13,10 +13,10 @@
var
model
=
{
'
version
'
:
2
,
"
version
"
:
2
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
materials
"
:
[
{
"
DbgColor
"
:
15658734
,
"
DbgIndex
"
:
0
,
"
DbgName
"
:
"
Material
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -28,20 +28,18 @@ var model = {
"
vertexColors
"
:
false
}],
'
vertices
'
:
[
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
1.000000
,
-
1.000000
,
0.999999
,
1.000000
,
1.000001
,
-
1.000000
,
1.000000
,
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
],
"
vertices
"
:
[
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
1.000000
,
-
1.000000
,
0.999999
,
1.000000
,
1.000001
,
-
1.000000
,
1.000000
,
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
],
'
morphTargets
'
:
[],
"
morphTargets
"
:
[],
'
normals
'
:
[],
"
normals
"
:
[],
'
colors
'
:
[],
"
colors
"
:
[],
'
uvs
'
:
[[]],
"
uvs
"
:
[[]],
'
faces
'
:
[
3
,
0
,
1
,
2
,
3
,
0
,
3
,
4
,
7
,
6
,
5
,
0
,
3
,
0
,
4
,
5
,
1
,
0
,
3
,
1
,
5
,
6
,
2
,
0
,
3
,
2
,
6
,
7
,
3
,
0
,
3
,
4
,
0
,
3
,
7
,
0
],
"
faces
"
:
[
3
,
0
,
1
,
2
,
3
,
0
,
3
,
4
,
7
,
6
,
5
,
0
,
3
,
0
,
4
,
5
,
1
,
0
,
3
,
1
,
5
,
6
,
2
,
0
,
3
,
2
,
6
,
7
,
3
,
0
,
3
,
4
,
0
,
3
,
7
,
0
]
'
end
'
:
(
new
Date
).
getTime
()
}
};
postMessage
(
model
);
examples/obj/blenderscene/scene.Monkey.js
浏览文件 @
6c1b9c58
此差异已折叠。
点击以展开。
examples/obj/blenderscene/scene.Plane.js
浏览文件 @
6c1b9c58
...
...
@@ -13,10 +13,10 @@
var
model
=
{
'
version
'
:
2
,
"
version
"
:
2
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
materials
"
:
[
{
"
DbgColor
"
:
15658734
,
"
DbgIndex
"
:
0
,
"
DbgName
"
:
"
Material.001
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -28,20 +28,18 @@ var model = {
"
vertexColors
"
:
false
}],
'
vertices
'
:
[
1.000000
,
-
0.000000
,
-
1.000000
,
1.000000
,
0.000000
,
1.000000
,
-
1.000000
,
0.000000
,
1.000000
,
-
1.000000
,
-
0.000000
,
-
1.000000
],
"
vertices
"
:
[
1.000000
,
-
0.000000
,
-
1.000000
,
1.000000
,
0.000000
,
1.000000
,
-
1.000000
,
0.000000
,
1.000000
,
-
1.000000
,
-
0.000000
,
-
1.000000
],
'
morphTargets
'
:
[],
"
morphTargets
"
:
[],
'
normals
'
:
[],
"
normals
"
:
[],
'
colors
'
:
[],
"
colors
"
:
[],
'
uvs
'
:
[[]],
"
uvs
"
:
[[]],
'
faces
'
:
[
3
,
0
,
3
,
2
,
1
,
0
],
"
faces
"
:
[
3
,
0
,
3
,
2
,
1
,
0
]
'
end
'
:
(
new
Date
).
getTime
()
}
};
postMessage
(
model
);
examples/obj/blenderscene/scene.js
浏览文件 @
6c1b9c58
...
...
@@ -13,272 +13,353 @@ var scene = {
{
"
Cube.006
"
:
{
"
geometry
"
:
"
geo_Cube
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material
"
],
"
position
"
:
[
10.623673
,
3.370784
,
-
0.321692
],
"
rotation
"
:
[
0.005265
,
-
0.056306
,
4.717181
],
"
quaternion
"
:
[
1.000000
,
0.000000
,
0.000000
,
0.000000
],
"
scale
"
:
[
8.310000
,
4.930000
,
0.120000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.018
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
1.702659
,
0.680278
,
5.860421
],
"
rotation
"
:
[
1.413516
,
0.081378
,
-
3.204182
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
0.435837
,
0.435837
,
0.435837
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.017
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
0.081295
,
0.639505
,
5.808783
],
"
rotation
"
:
[
1.413516
,
0.081378
,
-
3.204182
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
0.435837
,
0.435837
,
0.435837
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.016
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
1.569030
,
0.619385
,
5.747240
],
"
rotation
"
:
[
1.413516
,
0.081378
,
-
3.204182
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
0.435837
,
0.435837
,
0.435837
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.015
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
3.129120
,
0.552267
,
5.709269
],
"
rotation
"
:
[
1.413516
,
0.081378
,
-
3.204182
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
0.435837
,
0.435837
,
0.435837
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.014
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
6.386331
,
0.382167
,
3.004400
],
"
rotation
"
:
[
1.646237
,
-
0.058425
,
-
1.670593
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
0.435837
,
0.435837
,
0.435837
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.013
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
6.499331
,
0.471640
,
1.593073
],
"
rotation
"
:
[
1.646237
,
-
0.058425
,
-
1.670593
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
0.435837
,
0.435837
,
0.435837
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.012
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
6.629794
,
0.533840
,
0.234131
],
"
rotation
"
:
[
1.646237
,
-
0.058425
,
-
1.670593
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
0.435837
,
0.435837
,
0.435837
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.011
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
6.713673
,
0.629835
,
-
1.008146
],
"
rotation
"
:
[
1.646237
,
-
0.058425
,
-
1.670593
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
0.435837
,
0.435837
,
0.435837
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.010
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
2.010442
,
1.387332
,
24.343616
],
"
rotation
"
:
[
1.520470
,
0.191726
,
-
3.004622
],
"
quaternion
"
:
[
-
0.587711
,
0.550951
,
0.566613
,
0.173203
],
"
scale
"
:
[
9.160007
,
9.160007
,
9.160008
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.009
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
4.292194
,
1.826282
,
-
7.975398
],
"
rotation
"
:
[
1.594819
,
0.080713
,
-
0.213986
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.008
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
2.151757
,
1.891882
,
-
8.065320
],
"
rotation
"
:
[
1.594819
,
0.080713
,
-
0.213986
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.007
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
0.712512
,
2.115002
,
-
8.097841
],
"
rotation
"
:
[
1.594819
,
0.080713
,
-
0.213986
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Cube.005
"
:
{
"
geometry
"
:
"
geo_Cube
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material
"
],
"
position
"
:
[
-
1.000975
,
1.319482
,
-
8.755547
],
"
rotation
"
:
[
0.000000
,
0.000000
,
-
0.000000
],
"
quaternion
"
:
[
1.000000
,
0.000000
,
0.000000
,
0.000000
],
"
scale
"
:
[
6.130000
,
1.690000
,
0.070000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Cube.004
"
:
{
"
geometry
"
:
"
geo_Cube
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material
"
],
"
position
"
:
[
2.484517
,
2.724846
,
7.486932
],
"
rotation
"
:
[
0.220417
,
-
0.075224
,
0.181029
],
"
quaternion
"
:
[
0.988791
,
0.112836
,
0.027288
,
-
0.093898
],
"
scale
"
:
[
0.350000
,
3.310000
,
0.890000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.006
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
7.724935
,
1.694883
,
-
7.123103
],
"
rotation
"
:
[
1.835590
,
0.083161
,
-
2.048913
],
"
quaternion
"
:
[
-
0.587711
,
0.550951
,
0.566613
,
0.173203
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.005
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
6.334642
,
0.566791
,
-
6.636147
],
"
rotation
"
:
[
1.327136
,
-
0.032561
,
-
4.135900
],
"
quaternion
"
:
[
-
0.587711
,
0.550951
,
0.566613
,
0.173203
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.004
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
5.384042
,
0.444915
,
6.194087
],
"
rotation
"
:
[
0.991213
,
0.181430
,
-
5.246078
],
"
quaternion
"
:
[
-
0.587711
,
0.550951
,
0.566613
,
0.173203
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.003
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
3.147747
,
1.014840
,
4.230884
],
"
rotation
"
:
[
1.719311
,
-
0.307044
,
-
3.355401
],
"
quaternion
"
:
[
-
0.587711
,
0.550951
,
0.566613
,
0.173203
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.002
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
2.668043
,
3.008879
,
2.153389
],
"
rotation
"
:
[
1.881970
,
0.457870
,
4.066133
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Cube.003
"
:
{
"
geometry
"
:
"
geo_Cube
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material
"
],
"
position
"
:
[
-
3.031251
,
0.702044
,
1.943665
],
"
rotation
"
:
[
-
1.300741
,
-
1.330343
,
3.282723
],
"
quaternion
"
:
[
1.000000
,
0.000000
,
0.000000
,
0.000000
],
"
scale
"
:
[
1.781142
,
0.231142
,
0.361142
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey.001
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
1.245307
,
0.620196
,
-
0.137285
],
"
rotation
"
:
[
2.339869
,
-
0.286025
,
-
1.394760
],
"
quaternion
"
:
[
-
0.587711
,
0.550951
,
0.566613
,
0.173203
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Monkey
"
:
{
"
geometry
"
:
"
geo_Monkey
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.002
"
],
"
position
"
:
[
-
0.282500
,
1.813606
,
-
4.272932
],
"
rotation
"
:
[
0.646062
,
-
0.219349
,
-
0.010569
],
"
quaternion
"
:
[
0.942751
,
0.314982
,
0.105460
,
-
0.029764
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Cube.002
"
:
{
"
geometry
"
:
"
geo_Cube
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material
"
],
"
position
"
:
[
0.042212
,
5.536832
,
-
0.199037
],
"
rotation
"
:
[
0.000000
,
0.000000
,
-
0.000000
],
"
quaternion
"
:
[
1.000000
,
0.000000
,
0.000000
,
0.000000
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Cube.001
"
:
{
"
geometry
"
:
"
geo_Cube
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material
"
],
"
position
"
:
[
-
0.395497
,
1.009696
,
-
3.944532
],
"
rotation
"
:
[
0.000000
,
0.000000
,
-
0.000000
],
"
quaternion
"
:
[
1.000000
,
0.000000
,
0.000000
,
0.000000
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Plane
"
:
{
"
geometry
"
:
"
geo_Plane
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material.001
"
],
"
position
"
:
[
0.000000
,
0.000000
,
0.118260
],
"
rotation
"
:
[
0.000000
,
0.000000
,
-
0.000000
],
"
quaternion
"
:
[
1.000000
,
0.000000
,
0.000000
,
0.000000
],
"
scale
"
:
[
7.922787
,
7.922787
,
7.922787
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
},
"
Cube
"
:
{
"
geometry
"
:
"
geo_Cube
"
,
"
groups
"
:
[
],
"
materials
"
:
[
"
Material
"
],
"
position
"
:
[
3.651978
,
1.071144
,
0.000000
],
"
rotation
"
:
[
0.220417
,
-
0.075224
,
0.181029
],
"
quaternion
"
:
[
0.988791
,
0.112836
,
0.027288
,
-
0.093898
],
"
scale
"
:
[
1.000000
,
1.000000
,
1.000000
],
"
visible
"
:
true
"
visible
"
:
true
,
"
castsShadow
"
:
false
,
"
meshCollider
"
:
false
}
},
...
...
@@ -306,17 +387,17 @@ var scene = {
{
"
Material
"
:
{
"
type
"
:
"
MeshPhongMaterial
"
,
"
parameters
"
:
{
color
:
0xa31920
,
opacity
:
1.00
,
ambient
:
0x000000
,
specular
:
0x7f7f7f
,
shininess
:
50.0
}
"
parameters
"
:
{
color
:
10688800
,
opacity
:
1.00
,
ambient
:
0
,
specular
:
8355711
,
shininess
:
50.0
}
},
"
Material.001
"
:
{
"
type
"
:
"
MeshPhongMaterial
"
,
"
parameters
"
:
{
color
:
0x24a33e
,
opacity
:
1.00
,
ambient
:
0x000000
,
specular
:
0x7f7f7f
,
shininess
:
50.0
}
"
parameters
"
:
{
color
:
2401086
,
opacity
:
1.00
,
ambient
:
0
,
specular
:
8355711
,
shininess
:
50.0
}
},
"
Material.002
"
:
{
"
type
"
:
"
MeshPhongMaterial
"
,
"
parameters
"
:
{
color
:
0xa37024
,
opacity
:
1.00
,
ambient
:
0x000000
,
specular
:
0x7f7f7f
,
shininess
:
50.0
}
"
parameters
"
:
{
color
:
10711076
,
opacity
:
1.00
,
ambient
:
0
,
specular
:
8355711
,
shininess
:
50.0
}
}
},
...
...
@@ -340,7 +421,7 @@ var scene = {
"
default_light
"
:
{
"
type
"
:
"
directional
"
,
"
direction
"
:
[
0.000000
,
1.000000
,
1.000000
],
"
color
"
:
0xffffff
,
"
color
"
:
16777215
,
"
intensity
"
:
0.80
}
},
...
...
examples/obj/cubecolors/cube_fvc.blend
浏览文件 @
6c1b9c58
无法预览此类型文件
examples/obj/cubecolors/cube_fvc.js
浏览文件 @
6c1b9c58
...
...
@@ -4,7 +4,7 @@
*
* vertices: 8
* faces: 6
* normals:
8
* normals:
0
* uvs: 0
* colors: 22
* materials: 1
...
...
@@ -13,35 +13,33 @@
var
model
=
{
'
version
'
:
2
,
"
version
"
:
2
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
materials
"
:
[
{
"
DbgColor
"
:
15658734
,
"
DbgIndex
"
:
0
,
"
DbgName
"
:
"
Material
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
"
colorDiffuse
"
:
[
1
,
1
,
1
],
"
colorDiffuse
"
:
[
0.800000011920929
,
0.800000011920929
,
0.800000011920929
],
"
colorSpecular
"
:
[
0.5
,
0.5
,
0.5
],
"
shading
"
:
"
Basic
"
,
"
shading
"
:
"
Phong
"
,
"
specularCoef
"
:
50
,
"
transparency
"
:
1.0
,
"
vertexColors
"
:
true
}],
'
vertices
'
:
[
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
1.000000
,
-
1.000000
,
0.999999
,
1.000000
,
1.000000
,
-
1.000000
,
1.000000
,
0.999999
,
-
1.000000
,
1.000000
,
-
1.000000
],
"
vertices
"
:
[
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
-
1.000000
,
-
1.000000
,
-
1.000000
,
1.000000
,
1.000000
,
-
1.000000
,
0.999999
,
1.000000
,
1.000000
,
-
1.000000
,
1.000000
,
0.999999
,
-
1.000000
,
1.000000
,
-
1.000000
],
'
morphTargets
'
:
[],
"
morphTargets
"
:
[],
'
normals
'
:
[
0.577349
,
-
0.577349
,
-
0.577349
,
0.577349
,
-
0.577349
,
0.577349
,
-
0.577349
,
-
0.577349
,
0.577349
,
-
0.577349
,
-
0.577349
,
-
0.577349
,
0.577349
,
0.577349
,
-
0.577349
,
-
0.577349
,
0.577349
,
-
0.577349
,
-
0.577349
,
0.577349
,
0.577349
,
0.577349
,
0.577349
,
0.577349
],
"
normals
"
:
[
],
'
colors
'
:
[
0xffffff
,
0xffe18d
,
0xffe190
,
0x80fff7
,
0xe7df1b
,
0x6f62ff
,
0xfd17db
,
0xff0007
,
0x101d0e
,
0x5c00a3
,
0xd1ffb4
,
0x8a0079
,
0x797eed
,
0x6758ff
,
0xfff5de
,
0x3f3cff
,
0xb6b4ff
,
0x1dffef
,
0x101e1d
,
0x8a9190
,
0xd0ffaf
,
0x4c5555
],
"
colors
"
:
[
16777215
,
16769421
,
16769424
,
8454135
,
15195931
,
7299839
,
16586715
,
16711687
,
1056014
,
6029475
,
13762484
,
9044089
,
7962349
,
6772991
,
16774622
,
4144383
,
11973887
,
1966063
,
1056285
,
9081232
,
13696943
,
5002581
],
'
uvs
'
:
[[]],
"
uvs
"
:
[[]],
'
faces
'
:
[
163
,
0
,
1
,
2
,
3
,
0
,
0
,
1
,
2
,
3
,
0
,
1
,
2
,
3
,
163
,
4
,
7
,
6
,
5
,
0
,
4
,
5
,
6
,
7
,
4
,
5
,
6
,
7
,
163
,
0
,
4
,
5
,
1
,
0
,
0
,
4
,
7
,
1
,
0
,
8
,
9
,
10
,
163
,
1
,
5
,
6
,
2
,
0
,
1
,
7
,
6
,
2
,
0
,
11
,
12
,
13
,
163
,
2
,
6
,
7
,
3
,
0
,
2
,
6
,
5
,
3
,
14
,
15
,
16
,
17
,
163
,
4
,
0
,
3
,
7
,
0
,
4
,
0
,
3
,
5
,
18
,
19
,
20
,
21
],
"
faces
"
:
[
131
,
0
,
1
,
2
,
3
,
0
,
0
,
1
,
2
,
3
,
131
,
4
,
7
,
6
,
5
,
0
,
4
,
5
,
6
,
7
,
131
,
0
,
4
,
5
,
1
,
0
,
0
,
8
,
9
,
10
,
131
,
1
,
5
,
6
,
2
,
0
,
0
,
11
,
12
,
13
,
131
,
2
,
6
,
7
,
3
,
0
,
14
,
15
,
16
,
17
,
131
,
4
,
0
,
3
,
7
,
0
,
18
,
19
,
20
,
21
]
'
end
'
:
(
new
Date
).
getTime
()
}
};
postMessage
(
model
);
examples/obj/cubecolors/cubecolors.js
浏览文件 @
6c1b9c58
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
examples/obj/female02/Female02_bin.js
浏览文件 @
6c1b9c58
...
...
@@ -9,10 +9,10 @@
var
model
=
{
'
version
'
:
1
,
"
version
"
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
materials
"
:
[
{
"
DbgColor
"
:
15658734
,
"
DbgIndex
"
:
0
,
"
DbgName
"
:
"
_03_-_Default1noCulli__03_-_Default1noCulli
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -26,7 +26,7 @@ var model = {
},
{
"
DbgColor
"
:
0xee0000
,
"
DbgColor
"
:
15597568
,
"
DbgIndex
"
:
1
,
"
DbgName
"
:
"
_02_-_Default1noCulli__02_-_Default1noCulli
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -40,7 +40,7 @@ var model = {
},
{
"
DbgColor
"
:
0x00ee00
,
"
DbgColor
"
:
60928
,
"
DbgIndex
"
:
2
,
"
DbgName
"
:
"
FrontColorNoCullingID__02_-_Default1noCulli
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -54,7 +54,7 @@ var model = {
},
{
"
DbgColor
"
:
0x0000ee
,
"
DbgColor
"
:
238
,
"
DbgIndex
"
:
3
,
"
DbgName
"
:
"
FrontColorNoCullingID__03_-_Default1noCulli
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -68,7 +68,7 @@ var model = {
},
{
"
DbgColor
"
:
0xeeee00
,
"
DbgColor
"
:
15658496
,
"
DbgIndex
"
:
4
,
"
DbgName
"
:
"
_01_-_Default1noCulli__01_-_Default1noCulli
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -82,7 +82,7 @@ var model = {
},
{
"
DbgColor
"
:
0x00eeee
,
"
DbgColor
"
:
61166
,
"
DbgIndex
"
:
5
,
"
DbgName
"
:
"
FrontColorNoCullingID__01_-_Default1noCulli
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -95,10 +95,8 @@ var model = {
"
transparency
"
:
1.0
}],
'
buffers
'
:
'
Female02_bin.bin
'
,
"
buffers
"
:
"
Female02_bin.bin
"
'
end
'
:
(
new
Date
).
getTime
()
};
postMessage
(
model
);
examples/obj/female02/Female02_slim.js
浏览文件 @
6c1b9c58
此差异已折叠。
点击以展开。
examples/obj/lucy/Lucy100k_bin.js
浏览文件 @
6c1b9c58
...
...
@@ -9,18 +9,16 @@
var
model
=
{
'
version
'
:
1
,
"
version
"
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
materials
"
:
[
{
"
DbgColor
"
:
15658734
,
"
DbgIndex
"
:
0
,
"
DbgName
"
:
"
default
"
}],
'
buffers
'
:
'
Lucy100k_bin.bin
'
,
"
buffers
"
:
"
Lucy100k_bin.bin
"
'
end
'
:
(
new
Date
).
getTime
()
};
postMessage
(
model
);
examples/obj/lucy/Lucy100k_slim.js
浏览文件 @
6c1b9c58
此差异已折叠。
点击以展开。
examples/obj/male02/Male02_bin.js
浏览文件 @
6c1b9c58
...
...
@@ -9,10 +9,10 @@
var
model
=
{
'
version
'
:
1
,
"
version
"
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
materials
"
:
[
{
"
DbgColor
"
:
15658734
,
"
DbgIndex
"
:
0
,
"
DbgName
"
:
"
male-02-1noCullingID_male-02-1noCulling.JP
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -26,7 +26,7 @@ var model = {
},
{
"
DbgColor
"
:
0xee0000
,
"
DbgColor
"
:
15597568
,
"
DbgIndex
"
:
1
,
"
DbgName
"
:
"
orig_02_-_Defaul1noCu_orig_02_-_Defaul1noCu
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -40,7 +40,7 @@ var model = {
},
{
"
DbgColor
"
:
0x00ee00
,
"
DbgColor
"
:
60928
,
"
DbgIndex
"
:
2
,
"
DbgName
"
:
"
FrontColorNoCullingID_orig_02_-_Defaul1noCu
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -54,7 +54,7 @@ var model = {
},
{
"
DbgColor
"
:
0x0000ee
,
"
DbgColor
"
:
238
,
"
DbgIndex
"
:
3
,
"
DbgName
"
:
"
_01_-_Default1noCulli__01_-_Default1noCulli
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -68,7 +68,7 @@ var model = {
},
{
"
DbgColor
"
:
0xeeee00
,
"
DbgColor
"
:
15658496
,
"
DbgIndex
"
:
4
,
"
DbgName
"
:
"
FrontColorNoCullingID_male-02-1noCulling.JP
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -81,10 +81,8 @@ var model = {
"
transparency
"
:
1.0
}],
'
buffers
'
:
'
Male02_bin.bin
'
,
"
buffers
"
:
"
Male02_bin.bin
"
'
end
'
:
(
new
Date
).
getTime
()
};
postMessage
(
model
);
examples/obj/male02/Male02_slim.js
浏览文件 @
6c1b9c58
此差异已折叠。
点击以展开。
examples/obj/ninja/NinjaLo_bin.js
浏览文件 @
6c1b9c58
...
...
@@ -9,18 +9,16 @@
var
model
=
{
'
version
'
:
1
,
"
version
"
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
materials
"
:
[
{
"
DbgColor
"
:
15658734
,
"
DbgIndex
"
:
0
,
"
DbgName
"
:
"
default
"
}],
'
buffers
'
:
'
NinjaLo_bin.bin
'
,
"
buffers
"
:
"
NinjaLo_bin.bin
"
'
end
'
:
(
new
Date
).
getTime
()
};
postMessage
(
model
);
examples/obj/torus/Torus_bin.js
浏览文件 @
6c1b9c58
...
...
@@ -9,18 +9,16 @@
var
model
=
{
'
version
'
:
1
,
"
version
"
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
materials
"
:
[
{
"
DbgColor
"
:
15658734
,
"
DbgIndex
"
:
0
,
"
DbgName
"
:
"
(null)
"
}],
'
buffers
'
:
'
Torus_bin.bin
'
,
"
buffers
"
:
"
Torus_bin.bin
"
'
end
'
:
(
new
Date
).
getTime
()
};
postMessage
(
model
);
examples/obj/torus/Torus_slim.js
浏览文件 @
6c1b9c58
此差异已折叠。
点击以展开。
examples/obj/walt/WaltHead_bin.js
浏览文件 @
6c1b9c58
...
...
@@ -9,10 +9,10 @@
var
model
=
{
'
version
'
:
1
,
"
version
"
:
1
,
'
materials
'
:
[
{
"
DbgColor
"
:
0xeeeeee
,
"
materials
"
:
[
{
"
DbgColor
"
:
15658734
,
"
DbgIndex
"
:
0
,
"
DbgName
"
:
"
lambert2SG.001
"
,
"
colorAmbient
"
:
[
0.0
,
0.0
,
0.0
],
...
...
@@ -24,10 +24,8 @@ var model = {
"
transparency
"
:
1.0
}],
'
buffers
'
:
'
WaltHead_bin.bin
'
,
"
buffers
"
:
"
WaltHead_bin.bin
"
'
end
'
:
(
new
Date
).
getTime
()
};
postMessage
(
model
);
examples/obj/walt/WaltHead_slim.js
浏览文件 @
6c1b9c58
此差异已折叠。
点击以展开。
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
浏览文件 @
6c1b9c58
...
...
@@ -16,21 +16,32 @@
#
# ##### END GPL LICENSE BLOCK #####
# To support reload properly, try to access a package var, if it's there, reload everything
# ################################################################
# Init
# ################################################################
# To support reload properly, try to access a package var,
# if it's there, reload everything
if
"bpy"
in
locals
():
import
imp
if
"export_threejs"
in
locals
():
imp
.
reload
(
export_threejs
)
if
"import_threejs"
in
locals
():
imp
.
reload
(
import_threejs
)
import
bpy
from
bpy.props
import
*
from
io_utils
import
ExportHelper
from
io_utils
import
ExportHelper
,
ImportHelper
# ################################################################
# Custom properties
# ################################################################
bpy
.
types
.
Object
.
THREE_castsShadow
=
bpy
.
props
.
BoolProperty
()
bpy
.
types
.
Object
.
THREE_meshCollider
=
bpy
.
props
.
BoolProperty
()
class
OBJECT_PT_hello
(
bpy
.
types
.
Panel
):
bl_label
=
"THREE"
...
...
@@ -50,10 +61,33 @@ class OBJECT_PT_hello( bpy.types.Panel ):
row
=
layout
.
row
()
row
.
prop
(
obj
,
"THREE_meshCollider"
,
text
=
"Mesh collider"
)
# ################################################################
# Importer
# ################################################################
class
ImportTHREEJS
(
bpy
.
types
.
Operator
,
ImportHelper
):
'''Load a Three.js ASCII JSON model'''
bl_idname
=
"import.threejs"
bl_label
=
"Import Three.js"
filename_ext
=
".js"
filter_glob
=
StringProperty
(
default
=
"*.js"
,
options
=
{
'HIDDEN'
})
def
execute
(
self
,
context
):
# print("Selected: " + context.active_object.name)
from
.
import
import_threejs
return
import_threejs
.
load
(
self
,
context
,
**
self
.
as_keywords
(
ignore
=
(
"filter_glob"
,)))
# ################################################################
# Exporter
# ################################################################
class
ExportTHREEJS
(
bpy
.
types
.
Operator
,
ExportHelper
):
'''Export selected object for Three.js (ASCII JSON format).'''
'''Export selected object
/ scene
for Three.js (ASCII JSON format).'''
bl_idname
=
"export.threejs"
bl_label
=
"Export Three.js"
...
...
@@ -103,20 +137,26 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
row
.
prop
(
self
.
properties
,
"use_colors"
)
row
=
layout
.
row
()
row
.
prop
(
self
.
properties
,
"use_uv_coords"
)
def
menu_func
(
self
,
context
):
# ################################################################
# Common
# ################################################################
def
menu_func_export
(
self
,
context
):
default_path
=
bpy
.
data
.
filepath
.
replace
(
".blend"
,
".js"
)
self
.
layout
.
operator
(
ExportTHREEJS
.
bl_idname
,
text
=
"Three.js (.js)"
).
filepath
=
default_path
def
menu_func_import
(
self
,
context
):
self
.
layout
.
operator
(
ImportTHREEJS
.
bl_idname
,
text
=
"Three.js (.js)"
)
def
register
():
bpy
.
types
.
INFO_MT_file_export
.
append
(
menu_func
)
bpy
.
types
.
INFO_MT_file_export
.
append
(
menu_func
_export
)
bpy
.
types
.
INFO_MT_file_import
.
append
(
menu_func_import
)
def
unregister
():
bpy
.
types
.
INFO_MT_file_export
.
remove
(
menu_func
)
bpy
.
types
.
INFO_MT_file_export
.
remove
(
menu_func_export
)
bpy
.
types
.
INFO_MT_file_import
.
remove
(
menu_func_import
)
if
__name__
==
"__main__"
:
register
()
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
浏览文件 @
6c1b9c58
...
...
@@ -75,6 +75,7 @@ COLORS = [0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee]
# #####################################################
# Templates - scene
# #####################################################
TEMPLATE_SCENE_ASCII
=
"""
\
// Converted from: %(fname)s
// File generated with Blender 2.56 Exporter
...
...
@@ -167,7 +168,7 @@ TEMPLATE_LIGHT_DIRECTIONAL = """\
%(light_id)s: {
"type" : "directional",
"direction" : %(direction)s,
"color" : %(color)
s
,
"color" : %(color)
d
,
"intensity" : %(intensity).2f
}"""
...
...
@@ -175,7 +176,7 @@ TEMPLATE_LIGHT_POINT = """\
%(light_id)s: {
"type" : "point",
"position" : %(position)s,
"color" : %(color)
s
"color" : %(color)
d,
"intensity" : %(intensity).3f
}"""
...
...
@@ -188,6 +189,7 @@ TEMPLATE_HEX = "0x%06x"
# #####################################################
# Templates - model
# #####################################################
TEMPLATE_FILE_ASCII
=
"""
\
/*
* File generated with Blender 2.56 Exporter
...
...
@@ -204,25 +206,23 @@ TEMPLATE_FILE_ASCII = """\
var model = {
'version'
: 2,
"version"
: 2,
'materials'
: [%(materials)s],
"materials"
: [%(materials)s],
'vertices'
: [%(vertices)s],
"vertices"
: [%(vertices)s],
'morphTargets'
: [],
"morphTargets"
: [],
'normals'
: [%(normals)s],
"normals"
: [%(normals)s],
'colors'
: [%(colors)s],
"colors"
: [%(colors)s],
'uvs'
: [[%(uvs)s]],
"uvs"
: [[%(uvs)s]],
'faces': [%(faces)s],
"faces": [%(faces)s]
'end': (new Date).getTime()
}
};
postMessage( model );
"""
...
...
@@ -231,11 +231,13 @@ TEMPLATE_VERTEX = "%f,%f,%f"
TEMPLATE_N
=
"%f,%f,%f"
TEMPLATE_UV
=
"%f,%f"
TEMPLATE_C
=
"0x%06x"
#TEMPLATE_C = "0x%06x"
TEMPLATE_C
=
"%d"
# #####################################################
# Utils
# #####################################################
def
veckey3
(
x
,
y
,
z
):
return
round
(
x
,
6
),
round
(
y
,
6
),
round
(
z
,
6
)
...
...
@@ -280,6 +282,7 @@ def rgb2int(rgb):
# #####################################################
# Utils - files
# #####################################################
def
write_file
(
fname
,
content
):
out
=
open
(
fname
,
"w"
)
out
.
write
(
content
)
...
...
@@ -291,9 +294,21 @@ def ensure_folder_exist(foldername):
if
not
os
.
access
(
foldername
,
os
.
R_OK
|
os
.
W_OK
|
os
.
X_OK
):
os
.
makedirs
(
foldername
)
def
ensure_extension
(
filepath
,
extension
):
if
not
filepath
.
lower
().
endswith
(
extension
):
filepath
+=
extension
return
filepath
def
generate_mesh_filename
(
meshname
,
filepath
):
normpath
=
os
.
path
.
normpath
(
filepath
)
path
,
ext
=
os
.
path
.
splitext
(
normpath
)
return
"%s.%s%s"
%
(
path
,
meshname
,
ext
)
# #####################################################
#
A
lignment
#
Utils - a
lignment
# #####################################################
def
bbox
(
vertices
):
"""Compute bounding box of vertex array.
"""
...
...
@@ -370,8 +385,9 @@ def bottom(vertices):
translate
(
vertices
,
[
-
cx
,
-
cy
,
-
cz
])
# #####################################################
# Elements
# Elements
rendering
# #####################################################
def
hexcolor
(
c
):
return
(
int
(
c
[
0
]
*
255
)
<<
16
)
+
(
int
(
c
[
1
]
*
255
)
<<
8
)
+
int
(
c
[
2
]
*
255
)
...
...
@@ -387,6 +403,10 @@ def generate_vertex_color(c):
def
generate_uv
(
uv
):
return
TEMPLATE_UV
%
(
uv
[
0
],
1.0
-
uv
[
1
])
# #####################################################
# Model exporter - faces
# #####################################################
def
setBit
(
value
,
position
,
on
):
if
on
:
mask
=
1
<<
position
...
...
@@ -468,8 +488,9 @@ def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_col
# #####################################################
#
N
ormals
#
Model exporter - n
ormals
# #####################################################
def
extract_vertex_normals
(
mesh
,
use_normals
):
if
not
use_normals
:
return
{},
0
...
...
@@ -500,8 +521,9 @@ def generate_normals(normals, use_normals):
return
","
.
join
(
generate_normal
(
n
)
for
n
in
chunks
)
# #####################################################
#
V
ertex colors
#
Model exporter - v
ertex colors
# #####################################################
def
extract_vertex_colors
(
mesh
,
use_colors
):
if
not
use_colors
:
...
...
@@ -536,8 +558,9 @@ def generate_vertex_colors(colors, use_colors):
return
","
.
join
(
generate_vertex_color
(
c
)
for
c
in
chunks
)
# #####################################################
# UVs
#
Model exporter -
UVs
# #####################################################
def
extract_uvs
(
mesh
,
use_uv_coords
):
if
not
use_uv_coords
:
...
...
@@ -570,8 +593,9 @@ def generate_uvs(uvs, use_uv_coords):
return
","
.
join
(
generate_uv
(
n
)
for
n
in
chunks
)
# #####################################################
# Materials
# M
odel exporter - m
aterials
# #####################################################
def
generate_color
(
i
):
"""Generate hex color corresponding to integer.
...
...
@@ -582,9 +606,11 @@ def generate_color(i):
"""
if
i
<
len
(
COLORS
):
return
"0x%06x"
%
COLORS
[
i
]
#return "0x%06x" % COLORS[i]
return
COLORS
[
i
]
else
:
return
"0x%06x"
%
int
(
0xffffff
*
random
.
random
())
#return "0x%06x" % int(0xffffff * random.random())
return
int
(
0xffffff
*
random
.
random
())
def
generate_mtl
(
materials
):
"""Generate dummy materials.
...
...
@@ -594,10 +620,10 @@ def generate_mtl(materials):
for
m
in
materials
:
index
=
materials
[
m
]
mtl
[
m
]
=
{
'DbgName'
:
m
,
'DbgIndex'
:
index
,
'DbgColor'
:
generate_color
(
index
),
'vertexColors'
:
False
"DbgName"
:
m
,
"DbgIndex"
:
index
,
"DbgColor"
:
generate_color
(
index
),
"vertexColors"
:
False
}
return
mtl
...
...
@@ -703,8 +729,9 @@ def generate_materials_string(mesh, scene, use_colors, draw_type):
return
generate_materials
(
mtl
,
materials
,
use_colors
,
draw_type
)
# #####################################################
# ASCII
exporte
r
# ASCII
model generato
r
# #####################################################
def
generate_ascii_model
(
mesh
,
scene
,
use_normals
,
use_colors
,
use_uv_coords
,
align_model
,
flipyz
,
draw_type
):
vertices
=
mesh
.
vertices
[:]
...
...
@@ -744,22 +771,11 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
return
text
# #####################################################
# Utils
# #####################################################
def
ensure_extension
(
filepath
,
extension
):
if
not
filepath
.
lower
().
endswith
(
extension
):
filepath
+=
extension
return
filepath
def
generate_mesh_filename
(
meshname
,
filepath
):
normpath
=
os
.
path
.
normpath
(
filepath
)
path
,
ext
=
os
.
path
.
splitext
(
normpath
)
return
"%s.%s%s"
%
(
path
,
meshname
,
ext
)
# #####################################################
#
E
xport single mesh
#
Model exporter - e
xport single mesh
# #####################################################
def
export_mesh
(
obj
,
scene
,
filepath
,
use_normals
,
use_colors
,
use_uv_coords
,
align_model
,
flipyz
,
export_single_model
):
"""Export single mesh"""
...
...
@@ -814,8 +830,9 @@ def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, al
# #####################################################
#
Export scene
#
Scene exporter - render elements
# #####################################################
def
generate_vec4
(
vec
):
return
TEMPLATE_VEC4
%
(
vec
[
0
],
vec
[
1
],
vec
[
2
],
vec
[
3
])
...
...
@@ -863,6 +880,10 @@ def generate_bool_property(property):
return
"true"
return
"false"
# #####################################################
# Scene exporter - objects
# #####################################################
def
generate_objects
(
data
):
chunks
=
[]
...
...
@@ -917,6 +938,10 @@ def generate_objects(data):
return
",
\n\n
"
.
join
(
chunks
)
# #####################################################
# Scene exporter - geometries
# #####################################################
def
generate_geometries
(
data
):
chunks
=
[]
...
...
@@ -945,6 +970,10 @@ def generate_geometries(data):
return
",
\n\n
"
.
join
(
chunks
)
# #####################################################
# Scene exporter - textures
# #####################################################
def
generate_textures_scene
(
data
):
chunks
=
[]
...
...
@@ -969,6 +998,10 @@ def extract_texture_filename(image):
fn_strip
=
os
.
path
.
basename
(
fn
)
return
fn_strip
# #####################################################
# Scene exporter - materials
# #####################################################
def
extract_material_data
(
m
):
world
=
bpy
.
context
.
scene
.
world
...
...
@@ -1035,12 +1068,15 @@ def generate_material_string(material):
shading
=
material
[
"shading"
]
material_type
=
type_map
.
get
(
shading
,
"MeshBasicMaterial"
)
parameters
=
"color: %s"
%
generate_hex
(
rgb2int
(
material
[
"colorDiffuse"
]))
#parameters = "color: %s" % generate_hex(rgb2int(material["colorDiffuse"]))
parameters
=
"color: %d"
%
rgb2int
(
material
[
"colorDiffuse"
])
parameters
+=
", opacity: %.2f"
%
material
[
"transparency"
]
if
shading
==
"Phong"
:
parameters
+=
", ambient: %s"
%
generate_hex
(
rgb2int
(
material
[
"colorAmbient"
]))
parameters
+=
", specular: %s"
%
generate_hex
(
rgb2int
(
material
[
"colorSpecular"
]))
#parameters += ", ambient: %s" % generate_hex(rgb2int(material["colorAmbient"]))
#parameters += ", specular: %s" % generate_hex(rgb2int(material["colorSpecular"]))
parameters
+=
", ambient: %d"
%
rgb2int
(
material
[
"colorAmbient"
])
parameters
+=
", specular: %d"
%
rgb2int
(
material
[
"colorSpecular"
])
parameters
+=
", shininess: %.1f"
%
material
[
"specularCoef"
]
colorMap
=
material
[
'mapDiffuse'
]
...
...
@@ -1074,6 +1110,10 @@ def generate_materials_scene(data):
return
",
\n\n
"
.
join
(
chunks
)
# #####################################################
# Scene exporter - cameras
# #####################################################
def
generate_cameras
(
data
):
cameras
=
data
.
get
(
"cameras"
,
[])
if
not
cameras
:
...
...
@@ -1110,6 +1150,10 @@ def generate_cameras(data):
return
",
\n\n
"
.
join
(
chunks
)
# #####################################################
# Scene exporter - lights
# #####################################################
def
generate_lights
(
data
):
lights
=
data
.
get
(
"lights"
,
[])
if
not
lights
:
...
...
@@ -1122,7 +1166,8 @@ def generate_lights(data):
light_string
=
TEMPLATE_LIGHT_DIRECTIONAL
%
{
"light_id"
:
generate_string
(
light
[
"name"
]),
"direction"
:
generate_vec3
(
light
[
"direction"
]),
"color"
:
generate_hex
(
rgb2int
(
light
[
"color"
])),
#"color" : generate_hex(rgb2int(light["color"])),
"color"
:
rgb2int
(
light
[
"color"
]),
"intensity"
:
light
[
"intensity"
]
}
...
...
@@ -1130,7 +1175,8 @@ def generate_lights(data):
light_string
=
TEMPLATE_LIGHT_POINT
%
{
"light_id"
:
generate_string
(
light
[
"name"
]),
"position"
:
generate_vec3
(
light
[
"position"
]),
"color"
:
generate_hex
(
rgb2int
(
light
[
"color"
])),
#"color" : generate_hex(rgb2int(light["color"])),
"color"
:
rgb2int
(
light
[
"color"
]),
"intensity"
:
light
[
"intensity"
]
}
...
...
@@ -1138,6 +1184,10 @@ def generate_lights(data):
return
",
\n\n
"
.
join
(
chunks
)
# #####################################################
# Scene exporter - generate ASCII scene
# #####################################################
def
generate_ascii_scene
(
data
):
objects
=
generate_objects
(
data
)
geometries
=
generate_geometries
(
data
)
...
...
@@ -1195,6 +1245,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
,
align_model
=
0
,
option_export_scene
=
True
):
filepath
=
ensure_extension
(
filepath
,
'.js'
)
...
...
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py
0 → 100644
浏览文件 @
6c1b9c58
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# Based on import_obj.py
# Contributors: alteredq
"""
Blender importer for Three.js (ASCII JSON format).
"""
import
os
import
time
import
json
import
bpy
import
mathutils
from
mathutils.geometry
import
tesselate_polygon
from
io_utils
import
load_image
,
unpack_list
,
unpack_face_list
# #####################################################
# Utils
# #####################################################
def
splitArray
(
data
,
chunkSize
):
result
=
[]
chunk
=
[]
for
i
in
range
(
len
(
data
)):
if
i
>
0
and
i
%
chunkSize
==
0
:
result
.
append
(
chunk
)
chunk
=
[]
chunk
.
append
(
data
[
i
])
result
.
append
(
chunk
)
return
result
def
extract_json_string
(
text
):
marker_begin
=
"var model ="
marker_end
=
"postMessage"
start
=
text
.
find
(
marker_begin
)
+
len
(
marker_begin
)
end
=
text
.
find
(
marker_end
)
end
=
text
.
rfind
(
"}"
,
start
,
end
)
return
text
[
start
:
end
+
1
].
strip
()
# #####################################################
# Parser
# #####################################################
def
load
(
operator
,
context
,
filepath
):
print
(
'
\n
importing %r'
%
filepath
)
time_main
=
time
.
time
()
verts_loc
=
[]
verts_tex
=
[]
faces
=
[]
materials
=
[]
print
(
"
\t
parsing JSON file..."
)
time_sub
=
time
.
time
()
file
=
open
(
filepath
,
'rU'
)
rawcontent
=
file
.
read
()
file
.
close
()
json_string
=
extract_json_string
(
rawcontent
)
data
=
json
.
loads
(
json_string
)
time_new
=
time
.
time
()
print
(
'parsing %.4f sec'
%
(
time_new
-
time_sub
))
time_sub
=
time_new
verts_loc
=
splitArray
(
data
[
"vertices"
],
3
)
verts_loc
[:]
=
[(
v
[
0
],
v
[
2
],
-
v
[
1
])
for
v
in
verts_loc
]
# deselect all
bpy
.
ops
.
object
.
select_all
(
action
=
'DESELECT'
)
scene
=
context
.
scene
new_objects
=
[]
print
(
'
\t
building geometry...
\n\t
verts:%i faces:%i materials: %i ...'
%
(
len
(
verts_loc
),
len
(
faces
),
len
(
materials
)
))
# Create new obj
for
obj
in
new_objects
:
base
=
scene
.
objects
.
link
(
obj
)
base
.
select
=
True
scene
.
update
()
time_new
=
time
.
time
()
print
(
'finished importing: %r in %.4f sec.'
%
(
filepath
,
(
time_new
-
time_main
)))
return
{
'FINISHED'
}
if
__name__
==
"__main__"
:
register
()
utils/exporters/convert_obj_three.py
浏览文件 @
6c1b9c58
...
...
@@ -158,24 +158,22 @@ TEMPLATE_FILE_ASCII = u"""\
var model = {
'version'
: 2,
"version"
: 2,
'materials'
: [%(materials)s],
"materials"
: [%(materials)s],
'vertices'
: [%(vertices)s],
"vertices"
: [%(vertices)s],
'morphTargets'
: [%(morphTargets)s],
"morphTargets"
: [%(morphTargets)s],
'normals'
: [%(normals)s],
"normals"
: [%(normals)s],
'uvs'
: [[%(uvs)s]],
"uvs"
: [[%(uvs)s]],
'faces': [%(faces)s],
"faces": [%(faces)s]
'end': (new Date).getTime()
};
postMessage( model );
"""
...
...
@@ -191,14 +189,12 @@ TEMPLATE_FILE_BIN = u"""\
var model = {
'version'
: 1,
"version"
: 1,
'materials'
: [%(materials)s],
"materials"
: [%(materials)s],
'buffers': '%(buffers)s',
"buffers": "%(buffers)s"
'end': (new Date).getTime()
};
postMessage( model );
...
...
@@ -209,7 +205,7 @@ TEMPLATE_VERTEX = "%f,%f,%f"
TEMPLATE_N
=
"%f,%f,%f"
TEMPLATE_UV
=
"%f,%f"
TEMPLATE_MORPH
=
"
\t
{ 'name': '%s', 'vertices': [%s] }"
TEMPLATE_MORPH
=
'
\t
{ "name": "%s", "vertices": [%s] }'
# #####################################################
# Utils
...
...
@@ -670,9 +666,11 @@ def generate_color(i):
"""
if
i
<
len
(
COLORS
):
return
"0x%06x"
%
COLORS
[
i
]
#return "0x%06x" % COLORS[i]
return
COLORS
[
i
]
else
:
return
"0x%06x"
%
int
(
0xffffff
*
random
.
random
())
#return "0x%06x" % int(0xffffff * random.random())
return
int
(
0xffffff
*
random
.
random
())
def
value2string
(
v
):
if
type
(
v
)
==
str
and
v
[
0
:
2
]
!=
"0x"
:
...
...
utils/exporters/max/ThreeJSExporter.ms
浏览文件 @
6c1b9c58
...
...
@@ -40,7 +40,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
-- User interface
group "ThreeJSExporter v0.
5
"
group "ThreeJSExporter v0.
6
"
(
label msg "Exports selected meshes in Three.js ascii JSON format" align:#left
...
...
@@ -73,7 +73,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
function DumpVertices src =
(
Format "
'vertices'
: [" to:ostream
Format "
\"vertices\"
: [" to:ostream
num = src.count
...
...
@@ -121,7 +121,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
function DumpColors src useColors =
(
Format "
'colors'
: [" to:ostream
Format "
\"colors\"
: [" to:ostream
num = src.count
...
...
@@ -139,9 +139,11 @@ rollout ThreeJSExporter "ThreeJSExporter"
hexNum = ( bit.shift r 16 ) + ( bit.shift g 8 ) + b
hexColor = formattedPrint hexNum format:"#x"
Format "%" hexColor to:ostream
-- hexColor = formattedPrint hexNum format:"#x"
-- Format "%" hexColor to:ostream
decColor = formattedPrint hexNum format:"#d"
Format "%" decColor to:ostream
if i < num then Format "," to:ostream
...
...
@@ -159,7 +161,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
function DumpNormals src =
(
Format "
'normals'
: [" to:ostream
Format "
\"normals\"
: [" to:ostream
num = src.count
...
...
@@ -209,7 +211,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
function DumpUvs src =
(
Format "
'uvs'
: [[" to:ostream
Format "
\"uvs\"
: [[" to:ostream
num = src.count
...
...
@@ -250,7 +252,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
function DumpFaces src useColors =
(
Format "
'faces'
: [" to:ostream
Format "
\"faces\"
: [" to:ostream
num = src.count
...
...
@@ -422,7 +424,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
fg = formattedPrint g format:".4f"
fb = formattedPrint b format:".4f"
Format "
'%'
: [%, %, %],\n" label fr fg fb to:ostream
Format "
\"%\"
: [%, %, %],\n" label fr fg fb to:ostream
)
...
...
@@ -440,7 +442,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
(
fname = filenameFromPath bm.filename
Format "
'%' : '%'
,\n" label fname to:ostream
Format "
\"%\" : \"%\"
,\n" label fname to:ostream
)
...
...
@@ -454,7 +456,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
function ExportMaterials zmaterials zcolors =
(
Format "
'materials'
: [\n" to:ostream
Format "
\"materials\"
: [\n" to:ostream
totalMaterials = zmaterials.count
...
...
@@ -466,14 +468,14 @@ rollout ThreeJSExporter "ThreeJSExporter"
-- debug
Format "
'DbgIndex'
: %,\n" (i-1) to:ostream
Format "
\"DbgIndex\"
: %,\n" (i-1) to:ostream
if classof mat != BooleanClass then
(
useVertexColors = zcolors[i]
Format "
'DbgName' : '%'
,\n" mat.name to:ostream
Format "
\"DbgName\" : \"%\"
,\n" mat.name to:ostream
-- colors
...
...
@@ -484,8 +486,8 @@ rollout ThreeJSExporter "ThreeJSExporter"
t = mat.opacity / 100
s = mat.glossiness
Format "
'transparency'
: %,\n" t to:ostream
Format "
'specularCoef'
: %,\n" s to:ostream
Format "
\"transparency\"
: %,\n" t to:ostream
Format "
\"specularCoef\"
: %,\n" s to:ostream
-- maps
...
...
@@ -499,13 +501,13 @@ rollout ThreeJSExporter "ThreeJSExporter"
else
(
Format "
'DbgName' : '%'
,\n" "dummy" to:ostream
Format "
\"DbgName\" : \"%\"
,\n" "dummy" to:ostream
DumpColor red "colorDiffuse"
)
Format "
'vertexColors'
: %\n" useVertexColors to:ostream
Format "
\"vertexColors\"
: %\n" useVertexColors to:ostream
Format "}" to:ostream
if ( i < totalMaterials ) then Format "," to:ostream
...
...
@@ -1001,7 +1003,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
-- Dump model
Format "\n\nvar model = {\n\n" to:ostream
Format "
'version'
:2,\n\n" to:ostream
Format "
\"version\"
:2,\n\n" to:ostream
-- Dump all materials in the scene
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录