Skip to content

Commit 4aaacae

Browse files
committed
Extended Blender exporter to support mesh merging and export of all / selected meshes as single JSON model.
Do not use yet, work-in-progress, very little tested.
1 parent f9c24ff commit 4aaacae

File tree

3 files changed

+217
-123
lines changed

3 files changed

+217
-123
lines changed

examples/webgl_objconvert_test.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ <h1>OBJ to Three.js converter test</h1>
107107
xm.map.repeat.set( 10, 10 );
108108

109109
geometry = new THREE.PlaneGeometry( 100, 100, 15, 10 );
110-
110+
111111
mesh = new THREE.Mesh( geometry, xm );
112112
mesh.position.x = 0;
113113
mesh.position.y = FLOOR;
@@ -229,7 +229,7 @@ <h1>OBJ to Three.js converter test</h1>
229229
xc.font = "50pt arial bold";
230230
xc.fillText(i, 10, 64);
231231

232-
var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( x ) } );
232+
var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( x ), transparent: true } );
233233
xm.map.needsUpdate = true;
234234

235235
mesh = new THREE.Mesh( new THREE.PlaneGeometry( size, size ), xm );

utils/exporters/blender/2.58/scripts/addons/io_mesh_threejs/__init__.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
bl_info = {
2525
"name": "three.js format",
2626
"author": "mrdoob, kikko, alteredq, remoe, pxf",
27-
"version": (1, 0, 2),
27+
"version": (1, 1, 0),
2828
"blender": (2, 5, 7),
2929
"api": 35622,
3030
"location": "File > Import-Export",
@@ -183,6 +183,10 @@ def save_settings_export(properties):
183183
"option_lights" : properties.option_lights,
184184
"option_cameras" : properties.option_cameras,
185185

186+
"option_animation" : properties.option_animation,
187+
"option_frame_step" : properties.option_frame_step,
188+
"option_all_meshes" : properties.option_all_meshes,
189+
186190
"option_flip_yz" : properties.option_flip_yz,
187191

188192
"option_materials" : properties.option_materials,
@@ -235,6 +239,10 @@ def restore_settings_export(properties):
235239
properties.option_lights = settings.get("option_lights", False)
236240
properties.option_cameras = settings.get("option_cameras", False)
237241

242+
properties.option_animation = settings.get("option_animation", False)
243+
properties.option_frame_step = settings.get("option_frame_step", 1)
244+
properties.option_all_meshes = settings.get("option_all_meshes", True)
245+
238246
# ################################################################
239247
# Exporter
240248
# ################################################################
@@ -268,13 +276,17 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
268276
option_flip_yz = BoolProperty(name = "Flip YZ", description = "Flip YZ", default = True)
269277

270278
option_export_scene = BoolProperty(name = "Scene", description = "Export scene", default = False)
271-
option_embed_meshes = BoolProperty(name = "Embed", description = "Embed meshes", default = True)
279+
option_embed_meshes = BoolProperty(name = "Embed meshes", description = "Embed meshes", default = True)
272280
option_copy_textures = BoolProperty(name = "Copy textures", description = "Copy textures", default = False)
273281
option_url_base_html = BoolProperty(name = "HTML as url base", description = "Use HTML as url base ", default = False)
274282

275283
option_lights = BoolProperty(name = "Lights", description = "Export default scene lights", default = False)
276284
option_cameras = BoolProperty(name = "Cameras", description = "Export default scene cameras", default = False)
277285

286+
option_animation = BoolProperty(name = "Animation", description = "Export animation (morphs)", default = False)
287+
option_frame_step = IntProperty(name = "Frame step", description = "Animation frame step", min = 1, max = 1000, soft_min = 1, soft_max = 1000, default = 1)
288+
option_all_meshes = BoolProperty(name = "All meshes", description = "All meshes (merged)", default = True)
289+
278290
def invoke(self, context, event):
279291
restore_settings_export(self.properties)
280292
return ExportHelper.invoke(self, context, event)
@@ -346,17 +358,36 @@ def draw(self, context):
346358
layout.separator()
347359

348360
row = layout.row()
349-
row.label(text="Beta:")
361+
row.label(text="--------- Experimental ---------")
362+
layout.separator()
363+
364+
row = layout.row()
365+
row.label(text="Scene:")
350366

351367
row = layout.row()
352368
row.prop(self.properties, "option_export_scene")
369+
row.prop(self.properties, "option_embed_meshes")
353370

354371
row = layout.row()
355372
row.prop(self.properties, "option_lights")
356373
row.prop(self.properties, "option_cameras")
374+
layout.separator()
375+
376+
row = layout.row()
377+
row.label(text="Animation:")
378+
379+
row = layout.row()
380+
row.prop(self.properties, "option_animation")
381+
row.prop(self.properties, "option_frame_step")
382+
layout.separator()
383+
384+
row = layout.row()
385+
row.label(text="Settings:")
386+
387+
row = layout.row()
388+
row.prop(self.properties, "option_all_meshes")
357389

358390
row = layout.row()
359-
row.prop(self.properties, "option_embed_meshes")
360391
row.prop(self.properties, "option_copy_textures")
361392

362393
row = layout.row()

0 commit comments

Comments
 (0)