diff --git a/examples/obj/blenderscene/scene.Cube.js b/examples/obj/blenderscene/scene.Cube.js new file mode 100644 index 00000000..87815667 --- /dev/null +++ b/examples/obj/blenderscene/scene.Cube.js @@ -0,0 +1,47 @@ +/* + * File generated with Blender 2.56 Exporter + * https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender/ + * + * vertices: 8 + * faces: 6 + * normals: 0 + * uvs: 0 + * colors: 0 + * materials: 1 + * + */ + +var model = { + + 'version' : 2, + + 'materials': [ { + "DbgColor" : 0xeeeeee, + "DbgIndex" : 0, + "DbgName" : "Material", + "colorAmbient" : [0.0, 0.0, 0.0], + "colorDiffuse" : [0.6400000190734865, 0.10179081114814892, 0.126246120426746], + "colorSpecular" : [0.5, 0.5, 0.5], + "shading" : "Phong", + "specularCoef" : 50, + "transparency" : 1.0, + "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], + + 'morphTargets': [], + + 'normals': [], + + 'colors': [], + + '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], + + 'end': (new Date).getTime() + +} + +postMessage( model ); diff --git a/examples/obj/blenderscene/scene.Monkey.js b/examples/obj/blenderscene/scene.Monkey.js new file mode 100644 index 00000000..f6826252 --- /dev/null +++ b/examples/obj/blenderscene/scene.Monkey.js @@ -0,0 +1,47 @@ +/* + * File generated with Blender 2.56 Exporter + * https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender/ + * + * vertices: 507 + * faces: 500 + * normals: 0 + * uvs: 0 + * colors: 0 + * materials: 1 + * + */ + +var model = { + + 'version' : 2, + + 'materials': [ { + "DbgColor" : 0xeeeeee, + "DbgIndex" : 0, + "DbgName" : "Material.002", + "colorAmbient" : [0.0, 0.0, 0.0], + "colorDiffuse" : [0.6400000190734865, 0.44102483452893537, 0.14499310471107218], + "colorSpecular" : [0.5, 0.5, 0.5], + "shading" : "Phong", + "specularCoef" : 50, + "transparency" : 1.0, + "vertexColors" : false + }], + + 'vertices': [0.437500,0.765625,-0.164063,-0.437500,0.765625,-0.164063,0.500000,0.687500,-0.093750,-0.500000,0.687500,-0.093750,0.546875,0.578125,-0.054688,-0.546875,0.578125,-0.054688,0.351562,0.617188,0.023437,-0.351562,0.617188,0.023437,0.351562,0.718750,-0.031250,-0.351562,0.718750,-0.031250,0.351562,0.781250,-0.132813,-0.351562,0.781250,-0.132813,0.273438,0.796875,-0.164063,-0.273438,0.796875,-0.164063,0.203125,0.742188,-0.093750,-0.203125,0.742188,-0.093750,0.156250,0.648438,-0.054688,-0.156250,0.648438,-0.054688,0.078125,0.656250,-0.242188,-0.078125,0.656250,-0.242188,0.140625,0.742188,-0.242188,-0.140625,0.742188,-0.242188,0.242188,0.796875,-0.242188,-0.242188,0.796875,-0.242188,0.273438,0.796875,-0.328125,-0.273438,0.796875,-0.328125,0.203125,0.742188,-0.390625,-0.203125,0.742188,-0.390625,0.156250,0.648438,-0.437500,-0.156250,0.648438,-0.437500,0.351562,0.617188,-0.515625,-0.351562,0.617188,-0.515625,0.351562,0.718750,-0.453125,-0.351562,0.718750,-0.453125,0.351562,0.781250,-0.359375,-0.351562,0.781250,-0.359375,0.437500,0.765625,-0.328125,-0.437500,0.765625,-0.328125,0.500000,0.687500,-0.390625,-0.500000,0.687500,-0.390625,0.546875,0.578125,-0.437500,-0.546875,0.578125,-0.437500,0.625000,0.562500,-0.242188,-0.625000,0.562500,-0.242188,0.562500,0.671875,-0.242188,-0.562500,0.671875,-0.242188,0.468750,0.757812,-0.242188,-0.468750,0.757812,-0.242188,0.476562,0.773438,-0.242188,-0.476562,0.773438,-0.242188,0.445312,0.781250,-0.335938,-0.445312,0.781250,-0.335938,0.351562,0.804688,-0.375000,-0.351562,0.804688,-0.375000,0.265625,0.820312,-0.335938,-0.265625,0.820312,-0.335938,0.226562,0.820312,-0.242188,-0.226562,0.820312,-0.242188,0.265625,0.820312,-0.156250,-0.265625,0.820312,-0.156250,0.351562,0.828125,-0.242188,-0.351562,0.828125,-0.242188,0.351562,0.804688,-0.117188,-0.351562,0.804688,-0.117188,0.445312,0.781250,-0.156250,-0.445312,0.781250,-0.156250,0.000000,0.742188,-0.429688,0.000000,0.820312,-0.351563,0.000000,0.734375,0.679687,0.000000,0.781250,0.320312,0.000000,0.796875,0.187500,0.000000,0.718750,0.773437,0.000000,0.601562,-0.406250,0.000000,0.570312,-0.570312,0.000000,-0.546875,-0.898438,0.000000,-0.851562,-0.562500,0.000000,-0.828125,-0.070312,0.000000,-0.351562,0.382813,0.203125,0.562500,0.187500,-0.203125,0.562500,0.187500,0.312500,0.570312,0.437500,-0.312500,0.570312,0.437500,0.351562,0.570313,0.695312,-0.351562,0.570313,0.695312,0.367188,0.531250,0.890625,-0.367188,0.531250,0.890625,0.328125,0.523438,0.945312,-0.328125,0.523438,0.945312,0.179688,0.554688,0.968750,-0.179688,0.554688,0.968750,0.000000,0.578125,0.984375,0.437500,0.531250,0.140625,-0.437500,0.531250,0.140625,0.632812,0.539062,0.039062,-0.632812,0.539062,0.039062,0.828125,0.445312,-0.148438,-0.828125,0.445312,-0.148438,0.859375,0.593750,-0.429688,-0.859375,0.593750,-0.429688,0.710938,0.625000,-0.484375,-0.710938,0.625000,-0.484375,0.492188,0.687500,-0.601563,-0.492188,0.687500,-0.601563,0.320312,0.734375,-0.757813,-0.320312,0.734375,-0.757813,0.156250,0.757812,-0.718750,-0.156250,0.757812,-0.718750,0.062500,0.750000,-0.492188,-0.062500,0.750000,-0.492188,0.164062,0.773438,-0.414063,-0.164062,0.773438,-0.414063,0.125000,0.765625,-0.304688,-0.125000,0.765625,-0.304688,0.203125,0.742188,-0.093750,-0.203125,0.742188,-0.093750,0.375000,0.703125,-0.015625,-0.375000,0.703125,-0.015625,0.492188,0.671875,-0.062500,-0.492188,0.671875,-0.062500,0.625000,0.648438,-0.187500,-0.625000,0.648438,-0.187500,0.640625,0.648438,-0.296875,-0.640625,0.648438,-0.296875,0.601562,0.664062,-0.375000,-0.601562,0.664062,-0.375000,0.429688,0.718750,-0.437500,-0.429688,0.718750,-0.437500,0.250000,0.757812,-0.468750,-0.250000,0.757812,-0.468750,0.000000,0.734375,0.765625,0.109375,0.734375,0.718750,-0.109375,0.734375,0.718750,0.117188,0.710938,0.835937,-0.117188,0.710938,0.835937,0.062500,0.695313,0.882812,-0.062500,0.695313,0.882812,0.000000,0.687500,0.890625,0.000000,0.750000,0.195312,0.000000,0.742188,0.140625,0.101562,0.742188,0.148437,-0.101562,0.742188,0.148437,0.125000,0.750000,0.226562,-0.125000,0.750000,0.226562,0.085938,0.742188,0.289062,-0.085938,0.742188,0.289062,0.398438,0.671875,0.046875,-0.398438,0.671875,0.046875,0.617188,0.625000,-0.054688,-0.617188,0.625000,-0.054688,0.726562,0.601562,-0.203125,-0.726562,0.601562,-0.203125,0.742188,0.656250,-0.375000,-0.742188,0.656250,-0.375000,0.687500,0.726562,-0.414063,-0.687500,0.726562,-0.414063,0.437500,0.796875,-0.546875,-0.437500,0.796875,-0.546875,0.312500,0.835938,-0.640625,-0.312500,0.835938,-0.640625,0.203125,0.851562,-0.617188,-0.203125,0.851562,-0.617188,0.101562,0.843750,-0.429688,-0.101562,0.843750,-0.429688,0.125000,0.812500,0.101562,-0.125000,0.812500,0.101562,0.210938,0.710938,0.445312,-0.210938,0.710938,0.445312,0.250000,0.687500,0.703125,-0.250000,0.687500,0.703125,0.265625,0.664063,0.820312,-0.265625,0.664063,0.820312,0.234375,0.632813,0.914062,-0.234375,0.632813,0.914062,0.164062,0.632813,0.929688,-0.164062,0.632813,0.929688,0.000000,0.640625,0.945312,0.000000,0.726562,-0.046875,0.000000,0.765625,-0.210938,0.328125,0.742188,-0.476563,-0.328125,0.742188,-0.476563,0.164062,0.750000,-0.140625,-0.164062,0.750000,-0.140625,0.132812,0.757812,-0.210938,-0.132812,0.757812,-0.210938,0.117188,0.734375,0.687500,-0.117188,0.734375,0.687500,0.078125,0.750000,0.445312,-0.078125,0.750000,0.445312,0.000000,0.750000,0.445312,0.000000,0.742188,0.328125,0.093750,0.781250,0.273437,-0.093750,0.781250,0.273437,0.132812,0.796875,0.226562,-0.132812,0.796875,0.226562,0.109375,0.781250,0.132812,-0.109375,0.781250,0.132812,0.039062,0.781250,0.125000,-0.039062,0.781250,0.125000,0.000000,0.828125,0.203125,0.046875,0.812500,0.148437,-0.046875,0.812500,0.148437,0.093750,0.812500,0.156250,-0.093750,0.812500,0.156250,0.109375,0.828125,0.226562,-0.109375,0.828125,0.226562,0.078125,0.804688,0.250000,-0.078125,0.804688,0.250000,0.000000,0.804688,0.289062,0.257812,0.554688,0.312500,-0.257812,0.554688,0.312500,0.164062,0.710938,0.242187,-0.164062,0.710938,0.242187,0.179688,0.710938,0.312500,-0.179688,0.710938,0.312500,0.234375,0.554688,0.250000,-0.234375,0.554688,0.250000,0.000000,0.687500,0.875000,0.046875,0.687500,0.867187,-0.046875,0.687500,0.867187,0.093750,0.710938,0.820312,-0.093750,0.710938,0.820312,0.093750,0.726563,0.742187,-0.093750,0.726563,0.742187,0.000000,0.656250,0.781250,0.093750,0.664063,0.750000,-0.093750,0.664063,0.750000,0.093750,0.640625,0.812500,-0.093750,0.640625,0.812500,0.046875,0.632813,0.851562,-0.046875,0.632813,0.851562,0.000000,0.632813,0.859375,0.171875,0.781250,-0.218750,-0.171875,0.781250,-0.218750,0.187500,0.773438,-0.156250,-0.187500,0.773438,-0.156250,0.335938,0.757812,-0.429688,-0.335938,0.757812,-0.429688,0.273438,0.773438,-0.421875,-0.273438,0.773438,-0.421875,0.421875,0.773438,-0.398438,-0.421875,0.773438,-0.398438,0.562500,0.695312,-0.351563,-0.562500,0.695312,-0.351563,0.585938,0.687500,-0.289063,-0.585938,0.687500,-0.289063,0.578125,0.679688,-0.195313,-0.578125,0.679688,-0.195313,0.476562,0.718750,-0.101563,-0.476562,0.718750,-0.101563,0.375000,0.742188,-0.062500,-0.375000,0.742188,-0.062500,0.226562,0.781250,-0.109375,-0.226562,0.781250,-0.109375,0.179688,0.781250,-0.296875,-0.179688,0.781250,-0.296875,0.210938,0.781250,-0.375000,-0.210938,0.781250,-0.375000,0.234375,0.757812,-0.359375,-0.234375,0.757812,-0.359375,0.195312,0.757812,-0.296875,-0.195312,0.757812,-0.296875,0.242188,0.757812,-0.125000,-0.242188,0.757812,-0.125000,0.375000,0.726562,-0.085938,-0.375000,0.726562,-0.085938,0.460938,0.703125,-0.117188,-0.460938,0.703125,-0.117188,0.546875,0.671875,-0.210938,-0.546875,0.671875,-0.210938,0.554688,0.671875,-0.281250,-0.554688,0.671875,-0.281250,0.531250,0.679688,-0.335938,-0.531250,0.679688,-0.335938,0.414062,0.750000,-0.390625,-0.414062,0.750000,-0.390625,0.281250,0.765625,-0.398438,-0.281250,0.765625,-0.398438,0.335938,0.750000,-0.406250,-0.335938,0.750000,-0.406250,0.203125,0.750000,-0.171875,-0.203125,0.750000,-0.171875,0.195312,0.750000,-0.226563,-0.195312,0.750000,-0.226563,0.109375,0.609375,-0.460938,-0.109375,0.609375,-0.460938,0.195312,0.617188,-0.664062,-0.195312,0.617188,-0.664062,0.335938,0.593750,-0.687500,-0.335938,0.593750,-0.687500,0.484375,0.554688,-0.554688,-0.484375,0.554688,-0.554688,0.679688,0.492187,-0.453125,-0.679688,0.492187,-0.453125,0.796875,0.460937,-0.406250,-0.796875,0.460937,-0.406250,0.773438,0.375000,-0.164063,-0.773438,0.375000,-0.164063,0.601562,0.414062,-0.000000,-0.601562,0.414062,-0.000000,0.437500,0.468750,0.093750,-0.437500,0.468750,0.093750,0.000000,0.289062,-0.898438,0.000000,-0.078125,-0.984375,0.000000,-0.671875,0.195313,0.000000,0.187500,0.460938,0.000000,0.460938,0.976562,0.000000,0.343750,0.804688,0.000000,0.320313,0.570312,0.000000,0.281250,0.484375,0.851562,0.054687,-0.234375,-0.851562,0.054687,-0.234375,0.859375,-0.046875,-0.320312,-0.859375,-0.046875,-0.320312,0.773438,-0.437500,-0.265625,-0.773438,-0.437500,-0.265625,0.460938,-0.703125,-0.437500,-0.460938,-0.703125,-0.437500,0.734375,0.070312,0.046875,-0.734375,0.070312,0.046875,0.593750,-0.164062,0.125000,-0.593750,-0.164062,0.125000,0.640625,-0.429688,0.007813,-0.640625,-0.429688,0.007813,0.335938,-0.664062,-0.054687,-0.335938,-0.664062,-0.054687,0.234375,0.406250,0.351562,-0.234375,0.406250,0.351562,0.179688,0.257813,0.414062,-0.179688,0.257813,0.414062,0.289062,0.382813,0.710938,-0.289062,0.382813,0.710938,0.250000,0.390625,0.500000,-0.250000,0.390625,0.500000,0.328125,0.398438,0.914062,-0.328125,0.398438,0.914062,0.140625,0.367188,0.757812,-0.140625,0.367188,0.757812,0.125000,0.359375,0.539062,-0.125000,0.359375,0.539062,0.164062,0.437500,0.945312,-0.164062,0.437500,0.945312,0.218750,0.429688,0.281250,-0.218750,0.429688,0.281250,0.210938,0.468750,0.226562,-0.210938,0.468750,0.226562,0.203125,0.500000,0.171875,-0.203125,0.500000,0.171875,0.210938,0.164063,0.390625,-0.210938,0.164063,0.390625,0.296875,-0.265625,0.312500,-0.296875,-0.265625,0.312500,0.343750,-0.539062,0.148438,-0.343750,-0.539062,0.148438,0.453125,-0.382813,-0.867188,-0.453125,-0.382813,-0.867188,0.453125,-0.070313,-0.929688,-0.453125,-0.070313,-0.929688,0.453125,0.234375,-0.851562,-0.453125,0.234375,-0.851562,0.460938,0.429687,-0.523438,-0.460938,0.429687,-0.523438,0.726562,0.335937,-0.406250,-0.726562,0.335937,-0.406250,0.632812,0.281250,-0.453125,-0.632812,0.281250,-0.453125,0.640625,0.054687,-0.703125,-0.640625,0.054687,-0.703125,0.796875,0.125000,-0.562500,-0.796875,0.125000,-0.562500,0.796875,-0.117188,-0.617188,-0.796875,-0.117188,-0.617188,0.640625,-0.195313,-0.750000,-0.640625,-0.195313,-0.750000,0.640625,-0.445313,-0.679688,-0.640625,-0.445313,-0.679688,0.796875,-0.359375,-0.539062,-0.796875,-0.359375,-0.539062,0.617188,-0.585938,-0.328125,-0.617188,-0.585938,-0.328125,0.484375,-0.546875,-0.023437,-0.484375,-0.546875,-0.023437,0.820312,-0.203125,-0.328125,-0.820312,-0.203125,-0.328125,0.406250,0.148438,0.171875,-0.406250,0.148438,0.171875,0.429688,-0.210937,0.195313,-0.429688,-0.210937,0.195313,0.890625,-0.234375,-0.406250,-0.890625,-0.234375,-0.406250,0.773438,-0.125000,0.140625,-0.773438,-0.125000,0.140625,1.039062,-0.328125,0.101563,-1.039062,-0.328125,0.101563,1.281250,-0.429688,-0.054687,-1.281250,-0.429688,-0.054687,1.351562,-0.421875,-0.320312,-1.351562,-0.421875,-0.320312,1.234375,-0.421875,-0.507812,-1.234375,-0.421875,-0.507812,1.023438,-0.312500,-0.476562,-1.023438,-0.312500,-0.476562,1.015625,-0.289063,-0.414062,-1.015625,-0.289063,-0.414062,1.187500,-0.390625,-0.437500,-1.187500,-0.390625,-0.437500,1.265625,-0.406250,-0.289062,-1.265625,-0.406250,-0.289062,1.210938,-0.406250,-0.078125,-1.210938,-0.406250,-0.078125,1.031250,-0.304688,0.039063,-1.031250,-0.304688,0.039063,0.828125,-0.132812,0.070313,-0.828125,-0.132812,0.070313,0.921875,-0.218750,-0.359375,-0.921875,-0.218750,-0.359375,0.945312,-0.289062,-0.304688,-0.945312,-0.289062,-0.304688,0.882812,-0.210938,0.023438,-0.882812,-0.210938,0.023438,1.039062,-0.367188,0.000000,-1.039062,-0.367188,0.000000,1.187500,-0.445312,-0.093750,-1.187500,-0.445312,-0.093750,1.234375,-0.445312,-0.250000,-1.234375,-0.445312,-0.250000,1.171875,-0.437500,-0.359375,-1.171875,-0.437500,-0.359375,1.023438,-0.359375,-0.343750,-1.023438,-0.359375,-0.343750,0.843750,-0.210938,-0.289062,-0.843750,-0.210938,-0.289062,0.835938,-0.273438,-0.171875,-0.835938,-0.273438,-0.171875,0.757812,-0.273438,-0.093750,-0.757812,-0.273438,-0.093750,0.820312,-0.273438,-0.085937,-0.820312,-0.273438,-0.085937,0.843750,-0.273438,-0.015625,-0.843750,-0.273438,-0.015625,0.812500,-0.273438,0.015625,-0.812500,-0.273438,0.015625,0.726562,-0.070312,0.000000,-0.726562,-0.070312,0.000000,0.718750,-0.171875,0.023438,-0.718750,-0.171875,0.023438,0.718750,-0.187500,-0.039062,-0.718750,-0.187500,-0.039062,0.796875,-0.210938,-0.203125,-0.796875,-0.210938,-0.203125,0.890625,-0.265625,-0.242187,-0.890625,-0.265625,-0.242187,0.890625,-0.320312,-0.234375,-0.890625,-0.320312,-0.234375,0.812500,-0.320312,0.015625,-0.812500,-0.320312,0.015625,0.851562,-0.320312,-0.015625,-0.851562,-0.320312,-0.015625,0.828125,-0.320312,-0.078125,-0.828125,-0.320312,-0.078125,0.765625,-0.320312,-0.093750,-0.765625,-0.320312,-0.093750,0.843750,-0.320312,-0.171875,-0.843750,-0.320312,-0.171875,1.039062,-0.414062,-0.328125,-1.039062,-0.414062,-0.328125,1.187500,-0.484375,-0.343750,-1.187500,-0.484375,-0.343750,1.257812,-0.492188,-0.242187,-1.257812,-0.492188,-0.242187,1.210938,-0.484375,-0.085937,-1.210938,-0.484375,-0.085937,1.046875,-0.421875,0.000000,-1.046875,-0.421875,0.000000,0.882812,-0.265625,0.015625,-0.882812,-0.265625,0.015625,0.953125,-0.343750,-0.289062,-0.953125,-0.343750,-0.289062,0.890625,-0.328125,-0.109375,-0.890625,-0.328125,-0.109375,0.937500,-0.335938,-0.062500,-0.937500,-0.335938,-0.062500,1.000000,-0.367188,-0.125000,-1.000000,-0.367188,-0.125000,0.960938,-0.351562,-0.171875,-0.960938,-0.351562,-0.171875,1.015625,-0.375000,-0.234375,-1.015625,-0.375000,-0.234375,1.054688,-0.382812,-0.187500,-1.054688,-0.382812,-0.187500,1.109375,-0.390625,-0.210937,-1.109375,-0.390625,-0.210937,1.085938,-0.390625,-0.273437,-1.085938,-0.390625,-0.273437,1.023438,-0.484375,-0.437500,-1.023438,-0.484375,-0.437500,1.250000,-0.546875,-0.468750,-1.250000,-0.546875,-0.468750,1.367188,-0.500000,-0.296875,-1.367188,-0.500000,-0.296875,1.312500,-0.531250,-0.054687,-1.312500,-0.531250,-0.054687,1.039062,-0.492188,0.085938,-1.039062,-0.492188,0.085938,0.789062,-0.328125,0.125000,-0.789062,-0.328125,0.125000,0.859375,-0.382813,-0.382812,-0.859375,-0.382813,-0.382812], + + 'morphTargets': [], + + 'normals': [], + + 'colors': [], + + 'uvs': [[]], + + 'faces': [3,46,0,2,44,0,3,3,1,47,45,0,3,44,2,4,42,0,3,5,3,45,43,0,3,2,8,6,4,0,3,7,9,3,5,0,3,0,10,8,2,0,3,9,11,1,3,0,3,10,12,14,8,0,3,15,13,11,9,0,3,8,14,16,6,0,3,17,15,9,7,0,3,14,20,18,16,0,3,19,21,15,17,0,3,12,22,20,14,0,3,21,23,13,15,0,3,22,24,26,20,0,3,27,25,23,21,0,3,20,26,28,18,0,3,29,27,21,19,0,3,26,32,30,28,0,3,31,33,27,29,0,3,24,34,32,26,0,3,33,35,25,27,0,3,34,36,38,32,0,3,39,37,35,33,0,3,32,38,40,30,0,3,41,39,33,31,0,3,38,44,42,40,0,3,43,45,39,41,0,3,36,46,44,38,0,3,45,47,37,39,0,3,46,36,50,48,0,3,51,37,47,49,0,3,36,34,52,50,0,3,53,35,37,51,0,3,34,24,54,52,0,3,55,25,35,53,0,3,24,22,56,54,0,3,57,23,25,55,0,3,22,12,58,56,0,3,59,13,23,57,0,3,12,10,62,58,0,3,63,11,13,59,0,3,10,0,64,62,0,3,65,1,11,63,0,3,0,46,48,64,0,3,49,47,1,65,0,2,60,64,48,0,2,49,65,61,0,2,62,64,60,0,2,61,65,63,0,2,60,58,62,0,2,63,59,61,0,2,60,56,58,0,2,59,57,61,0,2,60,54,56,0,2,57,55,61,0,2,60,52,54,0,2,55,53,61,0,2,60,50,52,0,2,53,51,61,0,2,60,48,50,0,2,51,49,61,0,3,88,173,175,90,0,3,175,174,89,90,0,3,86,171,173,88,0,3,174,172,87,89,0,3,84,169,171,86,0,3,172,170,85,87,0,3,82,167,169,84,0,3,170,168,83,85,0,3,80,165,167,82,0,3,168,166,81,83,0,3,78,91,145,163,0,3,146,92,79,164,0,3,91,93,147,145,0,3,148,94,92,146,0,3,93,95,149,147,0,3,150,96,94,148,0,3,95,97,151,149,0,3,152,98,96,150,0,3,97,99,153,151,0,3,154,100,98,152,0,3,99,101,155,153,0,3,156,102,100,154,0,3,101,103,157,155,0,3,158,104,102,156,0,3,103,105,159,157,0,3,160,106,104,158,0,3,105,107,161,159,0,3,162,108,106,160,0,3,107,66,67,161,0,3,67,66,108,162,0,3,109,127,159,161,0,3,160,128,110,162,0,3,127,178,157,159,0,3,158,179,128,160,0,3,125,155,157,178,0,3,158,156,126,179,0,3,123,153,155,125,0,3,156,154,124,126,0,3,121,151,153,123,0,3,154,152,122,124,0,3,119,149,151,121,0,3,152,150,120,122,0,3,117,147,149,119,0,3,150,148,118,120,0,3,115,145,147,117,0,3,148,146,116,118,0,3,113,163,145,115,0,3,146,164,114,116,0,3,113,180,176,163,0,3,176,181,114,164,0,3,109,161,67,111,0,3,67,162,110,112,0,3,111,67,177,182,0,3,177,67,112,183,0,3,176,180,182,177,0,3,183,181,176,177,0,3,134,136,175,173,0,3,175,136,135,174,0,3,132,134,173,171,0,3,174,135,133,172,0,3,130,132,171,169,0,3,172,133,131,170,0,3,165,186,184,167,0,3,185,187,166,168,0,3,130,169,167,184,0,3,168,170,131,185,0,3,143,189,188,186,0,3,188,189,144,187,0,3,184,186,188,68,0,3,188,187,185,68,0,3,129,130,184,68,0,3,185,131,129,68,0,3,141,192,190,143,0,3,191,193,142,144,0,3,139,194,192,141,0,3,193,195,140,142,0,3,138,196,194,139,0,3,195,197,138,140,0,3,137,70,196,138,0,3,197,70,137,138,0,3,189,143,190,69,0,3,191,144,189,69,0,3,69,190,205,207,0,3,206,191,69,207,0,3,70,198,199,196,0,3,200,198,70,197,0,3,196,199,201,194,0,3,202,200,197,195,0,3,194,201,203,192,0,3,204,202,195,193,0,3,192,203,205,190,0,3,206,204,193,191,0,3,198,203,201,199,0,3,202,204,198,200,0,3,198,207,205,203,0,3,206,207,198,204,0,3,138,139,163,176,0,3,164,140,138,176,0,3,139,141,210,163,0,3,211,142,140,164,0,3,141,143,212,210,0,3,213,144,142,211,0,3,143,186,165,212,0,3,166,187,144,213,0,3,80,208,212,165,0,3,213,209,81,166,0,3,208,214,210,212,0,3,211,215,209,213,0,3,78,163,210,214,0,3,211,164,79,215,0,3,130,129,71,221,0,3,71,129,131,222,0,3,132,130,221,219,0,3,222,131,133,220,0,3,134,132,219,217,0,3,220,133,135,218,0,3,136,134,217,216,0,3,218,135,136,216,0,3,216,217,228,230,0,3,229,218,216,230,0,3,217,219,226,228,0,3,227,220,218,229,0,3,219,221,224,226,0,3,225,222,220,227,0,3,221,71,223,224,0,3,223,71,222,225,0,3,223,230,228,224,0,3,229,230,223,225,0,2,224,228,226,0,2,227,229,225,0,3,182,180,233,231,0,3,234,181,183,232,0,3,111,182,231,253,0,3,232,183,112,254,0,3,109,111,253,255,0,3,254,112,110,256,0,3,180,113,251,233,0,3,252,114,181,234,0,3,113,115,249,251,0,3,250,116,114,252,0,3,115,117,247,249,0,3,248,118,116,250,0,3,117,119,245,247,0,3,246,120,118,248,0,3,119,121,243,245,0,3,244,122,120,246,0,3,121,123,241,243,0,3,242,124,122,244,0,3,123,125,239,241,0,3,240,126,124,242,0,3,125,178,235,239,0,3,236,179,126,240,0,3,178,127,237,235,0,3,238,128,179,236,0,3,127,109,255,237,0,3,256,110,128,238,0,3,237,255,257,275,0,3,258,256,238,276,0,3,235,237,275,277,0,3,276,238,236,278,0,3,239,235,277,273,0,3,278,236,240,274,0,3,241,239,273,271,0,3,274,240,242,272,0,3,243,241,271,269,0,3,272,242,244,270,0,3,245,243,269,267,0,3,270,244,246,268,0,3,247,245,267,265,0,3,268,246,248,266,0,3,249,247,265,263,0,3,266,248,250,264,0,3,251,249,263,261,0,3,264,250,252,262,0,3,233,251,261,279,0,3,262,252,234,280,0,3,255,253,259,257,0,3,260,254,256,258,0,3,253,231,281,259,0,3,282,232,254,260,0,3,231,233,279,281,0,3,280,234,232,282,0,3,66,107,283,72,0,3,284,108,66,72,0,3,107,105,285,283,0,3,286,106,108,284,0,3,105,103,287,285,0,3,288,104,106,286,0,3,103,101,289,287,0,3,290,102,104,288,0,3,101,99,291,289,0,3,292,100,102,290,0,3,99,97,293,291,0,3,294,98,100,292,0,3,97,95,295,293,0,3,296,96,98,294,0,3,95,93,297,295,0,3,298,94,96,296,0,3,93,91,299,297,0,3,300,92,94,298,0,3,307,308,327,337,0,3,328,308,307,338,0,3,306,307,337,335,0,3,338,307,306,336,0,3,305,306,335,339,0,3,336,306,305,340,0,3,88,90,305,339,0,3,305,90,89,340,0,3,86,88,339,333,0,3,340,89,87,334,0,3,84,86,333,329,0,3,334,87,85,330,0,3,82,84,329,331,0,3,330,85,83,332,0,3,329,335,337,331,0,3,338,336,330,332,0,3,329,333,339,335,0,3,340,334,330,336,0,3,325,331,337,327,0,3,338,332,326,328,0,3,80,82,331,325,0,3,332,83,81,326,0,3,208,341,343,214,0,3,344,342,209,215,0,3,80,325,341,208,0,3,342,326,81,209,0,3,78,214,343,345,0,3,344,215,79,346,0,3,78,345,299,91,0,3,300,346,79,92,0,3,76,323,351,303,0,3,352,324,76,303,0,3,303,351,349,77,0,3,350,352,303,77,0,3,77,349,347,304,0,3,348,350,77,304,0,3,304,347,327,308,0,3,328,348,304,308,0,3,325,327,347,341,0,3,348,328,326,342,0,3,295,297,317,309,0,3,318,298,296,310,0,3,75,315,323,76,0,3,324,316,75,76,0,3,301,357,355,302,0,3,356,358,301,302,0,3,302,355,353,74,0,3,354,356,302,74,0,3,74,353,315,75,0,3,316,354,74,75,0,3,291,293,361,363,0,3,362,294,292,364,0,3,363,361,367,365,0,3,368,362,364,366,0,3,365,367,369,371,0,3,370,368,366,372,0,3,371,369,375,373,0,3,376,370,372,374,0,3,313,377,373,375,0,3,374,378,314,376,0,3,315,353,373,377,0,3,374,354,316,378,0,3,353,355,371,373,0,3,372,356,354,374,0,3,355,357,365,371,0,3,366,358,356,372,0,3,357,359,363,365,0,3,364,360,358,366,0,3,289,291,363,359,0,3,364,292,290,360,0,3,73,359,357,301,0,3,358,360,73,301,0,3,283,285,287,289,0,3,288,286,284,290,0,3,283,289,359,73,0,3,360,290,284,73,0,2,72,283,73,0,2,73,284,72,0,3,293,295,309,361,0,3,310,296,294,362,0,3,309,311,367,361,0,3,368,312,310,362,0,3,311,381,369,367,0,3,370,382,312,368,0,3,313,375,369,381,0,3,370,376,314,382,0,3,347,349,385,383,0,3,386,350,348,384,0,3,317,383,385,319,0,3,386,384,318,320,0,3,297,299,383,317,0,3,384,300,298,318,0,3,299,343,341,383,0,3,342,344,300,384,0,2,341,347,383,0,2,384,348,342,0,2,299,345,343,0,2,344,346,300,0,3,313,321,379,377,0,3,380,322,314,378,0,3,315,377,379,323,0,3,380,378,316,324,0,3,319,385,379,321,0,3,380,386,320,322,0,3,349,351,379,385,0,3,380,352,350,386,0,2,323,379,351,0,2,352,380,324,0,3,399,387,413,401,0,3,414,388,400,402,0,3,399,401,403,397,0,3,404,402,400,398,0,3,397,403,405,395,0,3,406,404,398,396,0,3,395,405,407,393,0,3,408,406,396,394,0,3,393,407,409,391,0,3,410,408,394,392,0,3,391,409,411,389,0,3,412,410,392,390,0,3,409,419,417,411,0,3,418,420,410,412,0,3,407,421,419,409,0,3,420,422,408,410,0,3,405,423,421,407,0,3,422,424,406,408,0,3,403,425,423,405,0,3,424,426,404,406,0,3,401,427,425,403,0,3,426,428,402,404,0,3,401,413,415,427,0,3,416,414,402,428,0,3,317,319,443,441,0,3,444,320,318,442,0,3,319,389,411,443,0,3,412,390,320,444,0,3,309,317,441,311,0,3,442,318,310,312,0,3,381,429,413,387,0,3,414,430,382,388,0,3,411,417,439,443,0,3,440,418,412,444,0,3,437,445,443,439,0,3,444,446,438,440,0,3,433,445,437,435,0,3,438,446,434,436,0,3,431,447,445,433,0,3,446,448,432,434,0,3,429,447,431,449,0,3,432,448,430,450,0,3,413,429,449,415,0,3,450,430,414,416,0,3,311,447,429,381,0,3,430,448,312,382,0,3,311,441,445,447,0,3,446,442,312,448,0,2,441,443,445,0,2,446,444,442,0,3,415,449,451,475,0,3,452,450,416,476,0,3,449,431,461,451,0,3,462,432,450,452,0,3,431,433,459,461,0,3,460,434,432,462,0,3,433,435,457,459,0,3,458,436,434,460,0,3,435,437,455,457,0,3,456,438,436,458,0,3,437,439,453,455,0,3,454,440,438,456,0,3,439,417,473,453,0,3,474,418,440,454,0,3,427,415,475,463,0,3,476,416,428,464,0,3,425,427,463,465,0,3,464,428,426,466,0,3,423,425,465,467,0,3,466,426,424,468,0,3,421,423,467,469,0,3,468,424,422,470,0,3,419,421,469,471,0,3,470,422,420,472,0,3,417,419,471,473,0,3,472,420,418,474,0,3,457,455,479,477,0,3,480,456,458,478,0,3,477,479,481,483,0,3,482,480,478,484,0,3,483,481,487,485,0,3,488,482,484,486,0,3,485,487,489,491,0,3,490,488,486,492,0,3,463,475,485,491,0,3,486,476,464,492,0,3,451,483,485,475,0,3,486,484,452,476,0,3,451,461,477,483,0,3,478,462,452,484,0,3,457,477,461,459,0,3,462,478,458,460,0,3,453,473,479,455,0,3,480,474,454,456,0,3,471,481,479,473,0,3,480,482,472,474,0,3,469,487,481,471,0,3,482,488,470,472,0,3,467,489,487,469,0,3,488,490,468,470,0,3,465,491,489,467,0,3,490,492,466,468,0,2,463,491,465,0,2,466,492,464,0,3,391,389,503,501,0,3,504,390,392,502,0,3,393,391,501,499,0,3,502,392,394,500,0,3,395,393,499,497,0,3,500,394,396,498,0,3,397,395,497,495,0,3,498,396,398,496,0,3,399,397,495,493,0,3,496,398,400,494,0,3,387,399,493,505,0,3,494,400,388,506,0,3,493,501,503,505,0,3,504,502,494,506,0,3,493,495,499,501,0,3,500,496,494,502,0,2,495,497,499,0,2,500,498,496,0,3,313,381,387,505,0,3,388,382,314,506,0,3,313,505,503,321,0,3,504,506,314,322,0,3,319,321,503,389,0,3,504,322,320,390,0], + + 'end': (new Date).getTime() + +} + +postMessage( model ); diff --git a/examples/obj/blenderscene/scene.Plane.js b/examples/obj/blenderscene/scene.Plane.js new file mode 100644 index 00000000..758b9669 --- /dev/null +++ b/examples/obj/blenderscene/scene.Plane.js @@ -0,0 +1,47 @@ +/* + * File generated with Blender 2.56 Exporter + * https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender/ + * + * vertices: 4 + * faces: 1 + * normals: 0 + * uvs: 0 + * colors: 0 + * materials: 1 + * + */ + +var model = { + + 'version' : 2, + + 'materials': [ { + "DbgColor" : 0xeeeeee, + "DbgIndex" : 0, + "DbgName" : "Material.001", + "colorAmbient" : [0.0, 0.0, 0.0], + "colorDiffuse" : [0.14462547517754842, 0.6400000190734865, 0.24541190036254967], + "colorSpecular" : [0.5, 0.5, 0.5], + "shading" : "Phong", + "specularCoef" : 50, + "transparency" : 1.0, + "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], + + 'morphTargets': [], + + 'normals': [], + + 'colors': [], + + 'uvs': [[]], + + 'faces': [3,0,3,2,1,0], + + 'end': (new Date).getTime() + +} + +postMessage( model ); diff --git a/examples/obj/blenderscene/scene.blend b/examples/obj/blenderscene/scene.blend new file mode 100644 index 00000000..ab1d5cb6 Binary files /dev/null and b/examples/obj/blenderscene/scene.blend differ diff --git a/examples/obj/blenderscene/scene.js b/examples/obj/blenderscene/scene.js new file mode 100644 index 00000000..fdab9674 --- /dev/null +++ b/examples/obj/blenderscene/scene.js @@ -0,0 +1,359 @@ +// Converted from: scene.blend +// File generated with Blender 2.56 Exporter +// https://github.com/alteredq/three.js/tree/master/utils/exporters/blender/ + + +var scene = { + +"type" : "scene", +"urlBaseType" : "relativeToScene", + + +"objects" : +{ + "Cube.006" : { + "geometry" : "geo_Cube", + "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 + }, + + "Monkey.018" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.017" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.016" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.015" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.014" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.013" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.012" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.011" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.010" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.009" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.008" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.007" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Cube.005" : { + "geometry" : "geo_Cube", + "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 + }, + + "Cube.004" : { + "geometry" : "geo_Cube", + "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 + }, + + "Monkey.006" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.005" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.004" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.003" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey.002" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Cube.003" : { + "geometry" : "geo_Cube", + "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 + }, + + "Monkey.001" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Monkey" : { + "geometry" : "geo_Monkey", + "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 + }, + + "Cube.002" : { + "geometry" : "geo_Cube", + "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 + }, + + "Cube.001" : { + "geometry" : "geo_Cube", + "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 + }, + + "Plane" : { + "geometry" : "geo_Plane", + "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 + }, + + "Cube" : { + "geometry" : "geo_Cube", + "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 + } +}, + + +"geometries" : +{ + "geo_Cube" : { + "type" : "ascii_mesh", + "url" : "scene.Cube.js" + }, + + "geo_Monkey" : { + "type" : "ascii_mesh", + "url" : "scene.Monkey.js" + }, + + "geo_Plane" : { + "type" : "ascii_mesh", + "url" : "scene.Plane.js" + } +}, + + +"materials" : +{ + "Material" : { + "type": "MeshPhongMaterial", + "parameters": { color: 0xa31920, opacity: 1.00, ambient: 0x000000, specular: 0x7f7f7f, shininess: 50.0 } + }, + + "Material.001" : { + "type": "MeshPhongMaterial", + "parameters": { color: 0x24a33e, opacity: 1.00, ambient: 0x000000, specular: 0x7f7f7f, shininess: 50.0 } + }, + + "Material.002" : { + "type": "MeshPhongMaterial", + "parameters": { color: 0xa37024, opacity: 1.00, ambient: 0x000000, specular: 0x7f7f7f, shininess: 50.0 } + } +}, + + +"cameras" : +{ + "default_camera" : { + "type" : "perspective", + "fov" : 60.000000, + "aspect": 1.333000, + "near" : 1.000000, + "far" : 10000.000000, + "position": [ 0.000000, 0.000000, 10.000000 ], + "target" : [ 0.000000, 0.000000, 0.000000 ] + } +}, + + +"lights" : +{ + "default_light": { + "type" : "directional", + "direction" : [ 0.000000, 1.000000, 1.000000 ], + "color" : 0xffffff, + "intensity" : 0.80 + } +}, + + +"defaults" : +{ + "bgcolor" : [ 0.000000, 0.000000, 0.000000 ], + "bgalpha" : 1.000000, + "camera" : "default_camera" +} + +} + +postMessage( scene ); + diff --git a/examples/webgl_scene_test_blender.html b/examples/webgl_scene_test_blender.html new file mode 100644 index 00000000..dc312b9b --- /dev/null +++ b/examples/webgl_scene_test_blender.html @@ -0,0 +1,561 @@ + + + + three.js webgl - io - scene loader [blender] + + + + + +
+ three.js - scene loader test [blender] +
+ +
+ [+] +
+
+ +
+ Loading ... + +
+
+
Start
+
+
+ +

+
+
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+
+		
+
+	
+
diff --git a/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py b/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
index 0e6cbbac..8355c5d3 100644
--- a/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
+++ b/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
@@ -35,13 +35,14 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
 
     filename_ext = ".js"
 
-    use_modifiers = BoolProperty(name="Apply Modifiers", description="Apply modifiers to the exported mesh", default=True)
+    option_flip_yz = BoolProperty(name="Flip YZ", description="Flip YZ", 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)
+    option_export_scene = BoolProperty(name="Scene", description="Export scene", default=True)
 
     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="Center")
+    align_model = EnumProperty(name="Align model", description="Align model", items=align_types, default="None")
 
     @classmethod
     def poll(cls, context):
@@ -61,15 +62,24 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
         layout = self.layout
 
         row = layout.row()
-        row.prop(self.properties, "use_modifiers")
+        row.prop(self.properties, "option_export_scene")
+        layout.separator()
+
+        row = layout.row()
+        row.prop(self.properties, "option_flip_yz")
+        layout.separator()
+
+        row = layout.row()
+        row.prop(self.properties, "align_model")
+        layout.separator()
+
         row = layout.row()
         row.prop(self.properties, "use_normals")
         row = layout.row()
         row.prop(self.properties, "use_colors")
         row = layout.row()
         row.prop(self.properties, "use_uv_coords")
-        row = layout.row()
-        row.prop(self.properties, "align_model")
+        
 
 
 def menu_func(self, context):
diff --git a/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py b/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
index b54e092c..8efea477 100644
--- a/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
+++ b/utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
@@ -23,9 +23,8 @@
 Blender exporter for Three.js (ASCII JSON format).
 
 TODO
-    - model alignment
+    - export scene
     - copy used images to folder where exported file goes
-    - export all selected meshes
     - binary format
 """
 
@@ -42,13 +41,149 @@ import random
 # Configuration
 # #####################################################
 
-# default colors for debugging (each material gets one distinct color):
+DEFAULTS = {
+"bgcolor" : [0, 0, 0],
+"bgalpha" : 1.0,
+
+"camera"  : 
+    {
+        "name" : "default_camera",
+        "type" : "perspective",
+        "near" : 1,
+        "far"  : 10000,
+        "fov"  : 60,
+        "aspect": 1.333,
+        "position" : [0, 0, 10],
+        "target"   : [0, 0, 0]
+    },
+
+"light" :
+ {
+    "name"       : "default_light",
+    "type"       : "directional",
+    "direction"	 : [0,1,1],
+    "color" 	 : [1,1,1],
+    "intensity"	 : 0.8
+ }
+}
+
+# default colors for debugging (each material gets one distinct color): 
 # white, red, green, blue, yellow, cyan, magenta
 COLORS = [0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee]
 
 
 # #####################################################
-# Templates
+# Templates - scene
+# #####################################################
+TEMPLATE_SCENE_ASCII = """\
+// Converted from: %(fname)s
+//  File generated with Blender 2.56 Exporter
+//  https://github.com/alteredq/three.js/tree/master/utils/exporters/blender/
+
+
+var scene = {
+
+"type" : "scene",
+"urlBaseType" : "relativeToScene",
+
+%(sections)s
+
+"defaults" : 
+{
+    "bgcolor" : %(bgcolor)s,
+    "bgalpha" : %(bgalpha)f,
+    "camera"  : %(defcamera)s
+}
+
+}
+
+postMessage( scene );
+
+"""
+
+TEMPLATE_SECTION = """
+"%s" : 
+{
+%s
+},
+"""
+
+TEMPLATE_OBJECT = """\
+    %(object_id)s : {
+        "geometry"  : %(geometry_id)s,
+        "materials" : [ %(material_id)s ],
+        "position"  : %(position)s,
+        "rotation"  : %(rotation)s,
+        "quaternion": %(quaternion)s,
+        "scale"	    : %(scale)s,
+        "visible"   : true
+    }"""
+
+TEMPLATE_GEOMETRY = """\
+    %(geometry_id)s : {
+        "type" : "ascii_mesh",
+        "url"  : %(model_file)s
+    }"""
+
+TEMPLATE_TEXTURE = """\
+    %(texture_id)s : {
+        "url": %(texture_file)s
+    }"""
+
+TEMPLATE_MATERIAL_SCENE = """\
+    %(material_id)s : {
+        "type": %(type)s,
+        "parameters": { %(parameters)s } 
+    }"""
+
+TEMPLATE_CAMERA_PERSPECTIVE = """\
+    %(camera_id)s : {
+        "type"  : "perspective",
+        "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"  : "ortho",
+        "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_DIRECTIONAL = """\
+	%(light_id)s: {
+		"type"		 : "directional",
+		"direction"	 : %(direction)s,
+		"color" 	 : %(color)s,
+		"intensity"	 : %(intensity).2f
+	}"""
+
+TEMPLATE_LIGHT_POINT = """\
+	%(light_id)s: {
+		"type"	     : "point",
+		"position"   : %(position)s,
+		"color"      : %(color)s
+		"intensity"	 : %(intensity).3f
+	}"""
+
+TEMPLATE_VEC4 = '[ %f, %f, %f, %f ]'
+TEMPLATE_VEC3 = '[ %f, %f, %f ]'
+TEMPLATE_VEC2 = '[ %f, %f ]'
+TEMPLATE_STRING = '"%s"'
+TEMPLATE_HEX = "0x%06x"
+
+# #####################################################
+# Templates - model
 # #####################################################
 TEMPLATE_FILE_ASCII = """\
 /*
@@ -98,8 +233,11 @@ TEMPLATE_C = "0x%06x"
 # #####################################################
 # Utils
 # #####################################################
+def veckey3(x,y,z):
+    return round(x, 6), round(y, 6), round(z, 6)
+
 def veckey3d(v):
-    return round(v.x, 6), round(v.y, 6), round(v.z, 6)
+    return veckey3(v.x, v.y, v.z)
 
 def veckey2d(v):
     return round(v[0], 6), round(v[1], 6)
@@ -107,8 +245,13 @@ def veckey2d(v):
 def get_normal_indices(v, normals, mesh):
     n = []
     mv = mesh.vertices
+
     for i in v:
-        n.append( normals[veckey3d(mv[i].normal)] )
+        normal = mv[i].normal        
+        key = veckey3d(normal)
+        
+        n.append( normals[key] )
+
     return n
 
 def get_uv_indices(face_index, uvs, mesh):
@@ -127,6 +270,24 @@ def get_color_indices(face_index, colors, mesh):
         c.append( colors[hexcolor(i)] )
     return c
 
+def rgb2int(rgb):
+    color = (int(rgb[0]*255) << 16) + (int(rgb[1]*255) << 8) + int(rgb[2]*255);
+    return color
+
+# #####################################################
+# Utils - files
+# #####################################################
+def write_file(fname, content):
+    out = open(fname, "w")
+    out.write(content)
+    out.close()
+
+def ensure_folder_exist(foldername):
+    """Create folder (with whole path) if it doesn't exist yet."""
+    
+    if not os.access(foldername, os.R_OK|os.W_OK|os.X_OK):
+        os.makedirs(foldername)
+
 # #####################################################
 # Alignment
 # #####################################################
@@ -231,7 +392,7 @@ def setBit(value, position, on):
         mask = ~(1 << position)
         return (value & mask)    
     
-def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords):
+def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, flipyz):
     isTriangle = ( len(f.vertices) == 3 )
     
     if isTriangle:
@@ -315,7 +476,10 @@ def extract_vertex_normals(mesh, use_normals):
 
     for f in mesh.faces:
         for v in f.vertices:
-            key = veckey3d(mesh.vertices[v].normal)
+            
+            normal = mesh.vertices[v].normal            
+            key = veckey3d(normal)
+                
             if key not in normals:
                 normals[key] = count
                 count += 1
@@ -327,7 +491,7 @@ def generate_normals(normals, use_normals):
         return ""
 
     chunks = []
-    for key, index in sorted(normals.items(), key=operator.itemgetter(1)):
+    for key, index in sorted(normals.items(), key = operator.itemgetter(1)):
         chunks.append(key)
 
     return ",".join(generate_normal(n) for n in chunks)
@@ -441,7 +605,7 @@ def value2string(v):
         return str(v).lower()
     return str(v)
 
-def generate_materials(mtl, materials, use_colors):
+def generate_materials(mtl, materials, use_colors, draw_type):
     """Generate JS array of materials objects
     """
 
@@ -458,6 +622,10 @@ def generate_materials(mtl, materials, use_colors):
         mtl[m]['DbgColor'] = generate_color(index)
         mtl[m]['vertexColors'] = use_colors
 
+        if draw_type in [ "BOUNDS", "WIRE" ]:
+            mtl[m]['wireframe'] = True
+            mtl[m]['DbgColor'] = 0xff0000
+            
         mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
         mtl_string = "\t{\n%s\n\t}" % mtl_raw
         mtl_array.append([index, mtl_string])
@@ -505,7 +673,7 @@ def extract_materials(mesh, scene):
 
     return materials
 
-def generate_materials_string(mesh, scene, use_colors):
+def generate_materials_string(mesh, scene, use_colors, draw_type):
 
     random.seed(42) # to get well defined color order for debug materials
 
@@ -522,19 +690,21 @@ def generate_materials_string(mesh, scene, use_colors):
         materials = { 'default':0 }
 
     # default dummy materials
+    
     mtl = generate_mtl(materials)
 
     # extract real materials from the mesh
+    
     mtl.update(extract_materials(mesh, scene))
 
-    return generate_materials(mtl, materials, use_colors)
+    return generate_materials(mtl, materials, use_colors, draw_type)
 
 # #####################################################
 # ASCII exporter
 # #####################################################
-def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model):
+def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model, flipyz, draw_type):
 
-    vertices = mesh.vertices[:]
+    vertices = mesh.vertices[:]    
 
     if align_model == 1:
         center(vertices)
@@ -547,7 +717,7 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
     colors, ncolor = extract_vertex_colors(mesh, use_colors)
     uvs, nuv = extract_uvs(mesh, use_uv_coords)
 
-    mstring, nmaterial = generate_materials_string(mesh, scene, use_colors)
+    mstring, nmaterial = generate_materials_string(mesh, scene, use_colors, draw_type)
     
     text = TEMPLATE_FILE_ASCII % {
     "nvertex"   : len(mesh.vertices),
@@ -565,46 +735,49 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
 
     "vertices"      : ",".join(generate_vertex(v) for v in vertices),
 
-    "faces"     : ",".join(generate_face(f, i, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords) for i, f in enumerate(mesh.faces))
+    "faces"     : ",".join(generate_face(f, i, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, flipyz) for i, f in enumerate(mesh.faces))
 
     }
 
     return text
 
 # #####################################################
-# Main
+# Utils
 # #####################################################
-def save(operator, context, filepath="", use_modifiers=True, use_normals=True, use_colors=True, use_uv_coords=True, align_model=1):
+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)
+    
+# #####################################################
+# Export single mesh
+# #####################################################
+def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, align_model, flipyz, export_single_model):
+    """Export single mesh"""
 
-    def rvec3d(v):
-        return round(v[0], 6), round(v[1], 6), round(v[2], 6)
 
-    def rvec2d(v):
-        return round(v[0], 6), round(v[1], 6)
-
-    scene = context.scene
-    obj = context.object
-
-    if not filepath.lower().endswith('.js'):
-        filepath += '.js'
-
-    if not obj:
-        raise Exception("Error, Select 1 active object")
-
-    if scene.objects.active:
-        bpy.ops.object.mode_set(mode='OBJECT')
-
-    if use_modifiers:
-        mesh = obj.create_mesh(scene, True, 'PREVIEW')
-    else:
-        mesh = obj.data
+    # collapse modifiers into mesh
+    
+    mesh = obj.create_mesh(scene, True, 'RENDER')        
 
     if not mesh:
-        raise Exception("Error, could not get mesh data from active object")
+        raise Exception("Error, could not get mesh data from object [%s]" % obj.name)
 
     # that's what Blender's native export_obj.py does
-    x_rot = mathutils.Matrix.Rotation(-math.pi/2, 4, 'X')
-    mesh.transform(x_rot * obj.matrix_world)
+    # to flip YZ
+
+    X_ROT = mathutils.Matrix.Rotation(-math.pi/2, 4, 'X')
+
+    if export_single_model:
+        mesh.transform(X_ROT * obj.matrix_world)
+    else:
+        mesh.transform(X_ROT)
+
     mesh.calc_normals()
 
     faceUV = (len(mesh.uv_textures) > 0)
@@ -627,14 +800,412 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
         if not active_col_layer:
             use_colors = False
 
-    text = generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model)
-    file = open(filepath, 'w')
-    file.write(text)
-    file.close()
+    text = generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model, flipyz, obj.draw_type)    
+    write_file(filepath, text)
+
+    # remove temp mesh
+
+    bpy.data.meshes.remove(mesh)
 
     print("writing", filepath, "done")
+    
+    
+# #####################################################
+# Export scene
+# #####################################################
+def generate_vec4(vec):
+    return TEMPLATE_VEC4 % (vec[0], vec[1], vec[2], vec[3])
 
-    if use_modifiers:
-        bpy.data.meshes.remove(mesh)
+def generate_vec3(vec):
+    return TEMPLATE_VEC3 % (vec[0], vec[1], vec[2])
 
+def generate_vec2(vec):
+    return TEMPLATE_VEC2 % (vec[0], vec[1])
+
+def generate_hex(number):
+    return TEMPLATE_HEX % number
+    
+def generate_string(s):
+    return TEMPLATE_STRING % s
+    
+def generate_section(label, content):
+    return TEMPLATE_SECTION % (label, content)
+    
+def get_mesh_filename(mesh):
+    object_id = mesh["data"]["name"]
+    filename = "%s.js" % sanitize(object_id)
+    return filename
+    
+def generate_material_id_list(materials):
+    chunks = []
+    for material in materials:
+        chunks.append(material.name)
+    
+    return ",".join(chunks)
+    
+def generate_objects(data):
+    chunks = []
+    
+    for obj in data["objects"]:
+        if obj.type == "MESH":
+            object_id = obj.name
+            
+            if len(obj.modifiers) > 0:
+                geo_name = obj.name
+            else:
+                geo_name = obj.data.name
+
+            geometry_id = "geo_%s" % geo_name
+            
+            material_id = generate_material_id_list(obj.material_slots)
+
+            #position = obj.location
+            #rotation = obj.rotation_euler
+            scale = obj.scale
+            quaternion = obj.rotation_quaternion
+            
+            position = [obj.location.x, obj.location.z, -obj.location.y]
+            rotation = [obj.rotation_euler.x, -obj.rotation_euler.y, -obj.rotation_euler.z]
+            #quaternion = obj.rotation_euler.to_quat()
+            scale = [obj.scale.x, obj.scale.z, obj.scale.y]
+            
+            material_string = ""
+            if material_id:
+                material_string = generate_string(material_id)
+                
+            object_string = TEMPLATE_OBJECT % {
+            "object_id"   : generate_string(object_id),
+            "geometry_id" : generate_string(geometry_id),
+            "material_id" : material_string,
+            "position"    : generate_vec3(position),
+            "rotation"    : generate_vec3(rotation),
+            "quaternion"  : generate_vec4(quaternion),
+            "scale"       : generate_vec3(scale)
+            }
+            chunks.append(object_string)
+        
+    return ",\n\n".join(chunks)
+    
+def generate_geometries(data):
+    chunks = []
+    
+    geo_set = set()
+    
+    for obj in data["objects"]:
+        if obj.type == "MESH":
+            
+            if len(obj.modifiers) > 0:
+                name = obj.name
+            else:
+                name = obj.data.name
+            
+            if name not in geo_set:
+
+                geometry_id = "geo_%s" % name
+                model_filename = os.path.basename(generate_mesh_filename(name, data["filepath"]))
+                
+                geometry_string = TEMPLATE_GEOMETRY % {
+                "geometry_id" : generate_string(geometry_id),
+                "model_file"  : generate_string(model_filename)
+                }
+                chunks.append(geometry_string)
+                
+                geo_set.add(name)
+        
+    return ",\n\n".join(chunks)
+    
+def generate_textures_scene(data):
+    chunks = []
+    
+    # TODO: extract just textures actually used by some objects in the scene
+    
+    for img in bpy.data.images:
+        
+        texture_id = img.name
+        texture_file = extract_texture_filename(img)
+    
+        texture_string = TEMPLATE_TEXTURE % {
+        "texture_id"   : generate_string(texture_id),
+        "texture_file" : generate_string(texture_file)
+        }
+        chunks.append(texture_string)
+
+    return ",\n\n".join(chunks)
+
+def extract_texture_filename(image):
+    fn = bpy.path.abspath(image.filepath)
+    fn = os.path.normpath(fn)
+    fn_strip = os.path.basename(fn)
+    return fn_strip
+    
+def extract_material_data(m):
+    world = bpy.context.scene.world
+    
+    material = { 'name': m.name }
+    
+    material['colorDiffuse'] = [m.diffuse_intensity * m.diffuse_color[0],
+                                m.diffuse_intensity * m.diffuse_color[1],
+                                m.diffuse_intensity * m.diffuse_color[2]]
+
+    material['colorSpecular'] = [m.specular_intensity * m.specular_color[0],
+                                 m.specular_intensity * m.specular_color[1],
+                                 m.specular_intensity * m.specular_color[2]]
+
+    material['colorAmbient'] = [m.ambient * world.ambient_color[0],
+                                m.ambient * world.ambient_color[1],
+                                m.ambient * world.ambient_color[2]]
+
+    material['transparency'] = m.alpha
+
+    # not sure about mapping values to Blinn-Phong shader
+    # Blender uses INT from [1,511] with default 0
+    # http://www.blender.org/documentation/blender_python_api_2_54_0/bpy.types.Material.html#bpy.types.Material.specular_hardness
+
+    material["specularCoef"] = m.specular_hardness
+
+    material['mapDiffuse'] = ""
+    material['mapLight'] = ""
+    material['mapNormal'] = ""    
+        
+    # just take first textures of each, for the moment three.js materials can't handle more
+
+    for i in range(len(m.texture_slots)):
+        ts = m.texture_slots[i]
+        if ts:
+            t = ts.texture
+            if ts.use and t.type == 'IMAGE':
+                name = t.image.name
+
+                if t.use_normal_map:
+                    material['mapNormal'] = name
+                else:
+                    if not material['mapDiffuse']:
+                        material['mapDiffuse'] = name
+                    else:
+                        material['mapLight'] = name
+                
+                if material['mapDiffuse'] and material['mapNormal'] and material['mapLight']:
+                    break
+        
+    if m.specular_intensity > 0.0 and (m.specular_color[0] > 0 or m.specular_color[1] > 0 or m.specular_color[2] > 0):
+        material['shading'] = "Phong"
+    else:
+        material['shading'] = "Lambert"
+        
+    return material
+    
+def generate_material_string(material):
+    type_map = {
+    "Lambert"   : "MeshLambertMaterial",
+    "Phong"     : "MeshPhongMaterial"
+    }
+    
+    material_id = material["name"]
+    shading = material["shading"]
+    material_type = type_map.get(shading, "MeshBasicMaterial")
+
+    parameters = "color: %s" % generate_hex(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 += ", shininess: %.1f" % material["specularCoef"]
+
+    colorMap = material['mapDiffuse']
+    lightMap = material['mapLight']
+    normalMap  = material['mapNormal']
+
+    if colorMap:
+        parameters += ", map: %s" % generate_string(colorMap)
+    if lightMap:
+        parameters += ", lightMap: %s" % generate_string(lightMap)
+    if normalMap:
+        parameters += ", normalMap: %s" % generate_string(normalMap)
+
+    material_string = TEMPLATE_MATERIAL_SCENE % {
+    "material_id" : generate_string(material_id),
+    "type"        : generate_string(material_type),
+    "parameters"  : parameters
+    }
+    
+    return material_string
+    
+def generate_materials_scene(data):
+    chunks = []
+
+    # TODO: extract just materials actually used by some objects in the scene
+    
+    for m in bpy.data.materials:
+        material = extract_material_data(m)
+        material_string = generate_material_string(material)
+        chunks.append(material_string)
+
+    return ",\n\n".join(chunks)
+
+def generate_cameras(data):
+    cameras = data.get("cameras", [])
+    if not cameras:
+        cameras.append(DEFAULTS["camera"])
+        
+    chunks = []
+    for camera in cameras:
+
+        if camera["type"] == "perspective":
+            camera_string = TEMPLATE_CAMERA_PERSPECTIVE % {
+            "camera_id" : generate_string(camera["name"]),
+            "fov"       : camera["fov"],
+            "aspect"    : camera["aspect"],
+            "near"      : camera["near"],
+            "far"       : camera["far"],
+            "position"  : generate_vec3(camera["position"]),
+            "target"    : generate_vec3(camera["target"])
+            }
+
+        elif camera["type"] == "ortho":
+            camera_string = TEMPLATE_CAMERA_ORTHO % {
+            "camera_id" : generate_string(camera["name"]),
+            "left"      : camera["left"],
+            "right"     : camera["right"],
+            "top"       : camera["top"],
+            "bottom"    : camera["bottom"],
+            "near"      : camera["near"],
+            "far"       : camera["far"],
+            "position"  : generate_vec3(camera["position"]),
+            "target"    : generate_vec3(camera["target"])
+            }
+            
+        chunks.append(camera_string)
+        
+    return ",\n\n".join(chunks)
+
+def generate_lights(data):
+    lights = data.get("lights", [])
+    if not lights:
+        lights.append(DEFAULTS["light"])
+        
+    chunks = []
+    for light in lights:
+
+        if light["type"] == "directional":
+            light_string = TEMPLATE_LIGHT_DIRECTIONAL % {
+            "light_id"      : generate_string(light["name"]),
+            "direction"     : generate_vec3(light["direction"]),
+            "color"         : generate_hex(rgb2int(light["color"])),
+            "intensity"     : light["intensity"]
+            }
+
+        elif light["type"] == "point":
+            light_string = TEMPLATE_LIGHT_POINT % {
+            "light_id"      : generate_string(light["name"]),
+            "position"      : generate_vec3(light["position"]),
+            "color"         : generate_hex(rgb2int(light["color"])),
+            "intensity"     : light["intensity"]
+            }
+            
+        chunks.append(light_string)
+            
+    return ",\n\n".join(chunks)
+
+def generate_ascii_scene(data):
+    objects = generate_objects(data)
+    geometries = generate_geometries(data)
+    textures = generate_textures_scene(data)
+    materials = generate_materials_scene(data)
+    cameras = generate_cameras(data)
+    lights = generate_lights(data)
+    
+    sections = [
+    ["objects",    objects],
+    ["geometries", geometries],
+    ["textures",   textures],
+    ["materials",  materials],
+    ["cameras",    cameras],
+    ["lights",     lights]
+    ]
+    
+    chunks = []
+    for label, content in sections:
+        if content:
+            chunks.append(generate_section(label, content))
+
+    sections_string = "\n".join(chunks)
+    
+    default_camera = "default_camera"
+    
+    parameters = {
+    "fname"     : data["source_file"],
+    "sections"  : sections_string,
+    "bgcolor"   : generate_vec3(DEFAULTS["bgcolor"]),
+    "bgalpha"   : DEFAULTS["bgalpha"],
+    "defcamera" : generate_string(default_camera)
+    }
+
+    text = TEMPLATE_SCENE_ASCII % parameters
+    
+    return text
+    
+def export_scene(scene, filepath, flipyz):
+
+    source_file = os.path.basename(bpy.data.filepath)
+
+    scene_text = ""
+    data = {
+    "scene"       : scene,
+    "objects"     : scene.objects,
+    "source_file" : source_file,
+    "filepath"    : filepath,
+    "flipyz"      : flipyz
+    }
+    scene_text += generate_ascii_scene(data)
+    
+    write_file(filepath, scene_text)
+
+# #####################################################
+# 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')
+
+    scene = context.scene
+
+    if scene.objects.active:
+        bpy.ops.object.mode_set(mode='OBJECT')
+
+    if option_export_scene:
+
+        export_scene(scene, filepath, option_flip_yz)
+
+        geo_set = set()
+        
+        for obj in scene.objects:
+            if obj.type == "MESH":
+                
+                # create extra copy of geometry with applied modifiers
+                # (if they exist)
+                
+                if len(obj.modifiers) > 0:
+                    name = obj.name
+                    
+                # otherwise can share geometry
+
+                else:
+                    name = obj.data.name
+
+                if name not in geo_set:
+                    fname = generate_mesh_filename(name, filepath)
+                    export_mesh(obj, scene, fname, use_normals, use_colors, use_uv_coords, 0, option_flip_yz, False)
+                    
+                    geo_set.add(name)
+
+    else:
+
+        obj = context.object
+        if not obj:
+            raise Exception("Error, Select 1 active object or select 'export scene'")
+
+        export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, align_model, option_flip_yz, True)
+
+    
     return {'FINISHED'}