提交 6fb5b91c 编写于 作者: A alteredq

Updated scene format to use singular "material" property instead of "materials" array for meshes.

Bumped scene format version to 3.2

Modified correspondingly SceneLoader, SceneExporter, Blender scene exporter and example scene files.

See #2628
上级 d4256de8
......@@ -710,12 +710,6 @@ THREE.Vector2.prototype = {
},
isZero: function ( v ) {
return this.lengthSq() < ( v !== undefined ? v : 0.0001 );
},
clone: function () {
return new THREE.Vector2( this.x, this.y );
......@@ -1201,12 +1195,6 @@ THREE.Vector3.prototype = {
},
isZero: function ( v ) {
return this.lengthSq() < ( v !== undefined ? v : 0.0001 );
},
clone: function () {
return new THREE.Vector3( this.x, this.y, this.z );
......@@ -5125,11 +5113,7 @@ THREE.Geometry.prototype = {
ab.sub( vA, vB );
cb.crossSelf( ab );
if ( !cb.isZero() ) {
cb.normalize();
}
cb.normalize();
face.normal.copy( cb );
......@@ -9360,6 +9344,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
if ( o.type && ( o.type in scope.hierarchyHandlerMap ) && o.loading === undefined ) {
var loaderParameters = {};
for ( var parType in g ) {
if ( parType !== "type" && parType !== "url" ) {
......@@ -9370,7 +9355,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
}
material = result.materials[ o.materials[ 0 ] ];
material = result.materials[ o.material ];
o.loading = true;
......@@ -9411,10 +9396,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
var hasNormals = false;
// not anymore support for multiple materials
// shouldn't really be array
material = result.materials[ o.materials[ 0 ] ];
material = result.materials[ o.material ];
hasNormals = material instanceof THREE.ShaderMaterial;
if ( hasNormals ) {
......@@ -9433,16 +9415,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
q = 0;
if ( o.materials.length === 0 ) {
material = new THREE.MeshFaceMaterial();
}
// dirty hack to handle meshes with multiple materials
// just use face materials defined in model
if ( o.materials.length > 1 ) {
if ( ! o.material ) {
material = new THREE.MeshFaceMaterial();
......@@ -32427,11 +32400,7 @@ THREE.ConvexGeometry = function( vertices ) {
ab.sub( va, vb );
cb.crossSelf( ab );
if ( !cb.isZero() ) {
cb.normalize();
}
cb.normalize();
return cb;
......
此差异已折叠。
......@@ -350,8 +350,8 @@ THREE.SceneExporter.prototype = {
var output = [
'\t\t' + LabelString( getObjectName( o ) ) + ' : {',
' "geometry" : ' + LabelString( getGeometryName( o.geometry ) ) + ',',
' "materials": [ ' + LabelString( getMaterialName( o.material ) ) + ' ],',
' "geometry" : ' + LabelString( getGeometryName( o.geometry ) ) + ',',
' "material" : ' + LabelString( getMaterialName( o.material ) ) + ',',
' "position" : ' + Vector3String( o.position ) + ',',
' "rotation" : ' + Vector3String( o.rotation ) + ',',
' "scale" : ' + Vector3String( o.scale ) + ',',
......@@ -692,7 +692,7 @@ THREE.SceneExporter.prototype = {
var output = [
'{',
' "metadata": {',
' "formatVersion" : 3.1,',
' "formatVersion" : 3.2,',
' "type" : "scene",',
' "generatedBy" : "SceneExporter",',
' "objects" : ' + nobjects + ',',
......
......@@ -2,7 +2,7 @@
"metadata" :
{
"formatVersion" : 3.1,
"formatVersion" : 3.2,
"type" : "scene",
"sourceFile" : "scene.blend",
"generatedBy" : "Blender 2.64 Exporter",
......@@ -20,7 +20,7 @@
"Cube.006" : {
"geometry" : "geo_Cube",
"groups" : [ ],
"materials" : [ "Material" ],
"material" : "Material",
"position" : [ 10.6237, 0.321692, 3.37078 ],
"rotation" : [ 0.00526525, 0.0563064, 1.566 ],
"quaternion": [ 0.708568, -0.0179916, 0.0218086, 0.705076 ],
......@@ -34,7 +34,7 @@
"Monkey.018" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ 1.70266, -5.86042, 0.680278 ],
"rotation" : [ 1.41352, -0.0813772, -3.079 ],
"quaternion": [ 0.0501767, -0.0106173, -0.649485, -0.758643 ],
......@@ -48,7 +48,7 @@
"Monkey.017" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ 0.0812951, -5.80878, 0.639505 ],
"rotation" : [ 1.41352, -0.0813772, -3.079 ],
"quaternion": [ 0.0501767, -0.0106173, -0.649485, -0.758643 ],
......@@ -62,7 +62,7 @@
"Monkey.016" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -1.56903, -5.74724, 0.619385 ],
"rotation" : [ 1.41352, -0.0813772, -3.079 ],
"quaternion": [ 0.0501767, -0.0106173, -0.649485, -0.758643 ],
......@@ -76,7 +76,7 @@
"Monkey.015" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -3.12912, -5.70927, 0.552267 ],
"rotation" : [ 1.41352, -0.0813772, -3.079 ],
"quaternion": [ 0.0501767, -0.0106173, -0.649485, -0.758643 ],
......@@ -90,7 +90,7 @@
"Monkey.014" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -6.38633, -3.0044, 0.382167 ],
"rotation" : [ 1.64624, 0.0584253, 1.67059 ],
"quaternion": [ 0.471896, 0.477057, 0.55681, 0.489585 ],
......@@ -104,7 +104,7 @@
"Monkey.013" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -6.49933, -1.59307, 0.47164 ],
"rotation" : [ 1.64624, 0.0584253, 1.67059 ],
"quaternion": [ 0.471896, 0.477057, 0.55681, 0.489585 ],
......@@ -118,7 +118,7 @@
"Monkey.012" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -6.62979, -0.234131, 0.53384 ],
"rotation" : [ 1.64624, 0.0584253, 1.67059 ],
"quaternion": [ 0.471896, 0.477057, 0.55681, 0.489585 ],
......@@ -132,7 +132,7 @@
"Monkey.011" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -6.71367, 1.00815, 0.629835 ],
"rotation" : [ 1.64624, 0.0584253, 1.67059 ],
"quaternion": [ 0.471896, 0.477057, 0.55681, 0.489585 ],
......@@ -146,7 +146,7 @@
"Monkey.010" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -2.01044, -24.3436, 1.38733 ],
"rotation" : [ -1.62112, -2.94987, -0.136972 ],
"quaternion": [ 0.0164388, -0.11614, -0.679574, -0.724169 ],
......@@ -160,7 +160,7 @@
"Monkey.009" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -4.29219, 7.9754, 1.82628 ],
"rotation" : [ 1.59482, -0.0807133, 0.213986 ],
"quaternion": [ 0.69092, 0.713888, 0.0483276, 0.103242 ],
......@@ -174,7 +174,7 @@
"Monkey.008" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ 2.15176, 8.06532, 1.89188 ],
"rotation" : [ 1.59482, -0.0807133, 0.213986 ],
"quaternion": [ 0.69092, 0.713888, 0.0483276, 0.103242 ],
......@@ -188,7 +188,7 @@
"Monkey.007" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -0.712512, 8.09784, 2.115 ],
"rotation" : [ 1.59482, -0.0807133, 0.213986 ],
"quaternion": [ 0.69092, 0.713888, 0.0483276, 0.103242 ],
......@@ -202,7 +202,7 @@
"Cube.005" : {
"geometry" : "geo_Cube",
"groups" : [ ],
"materials" : [ "Material" ],
"material" : "Material",
"position" : [ -1.00097, 8.75555, 1.31948 ],
"rotation" : [ 0, -0, 0 ],
"quaternion": [ 1, 0, 0, 0 ],
......@@ -216,7 +216,7 @@
"Cube.004" : {
"geometry" : "geo_Cube",
"groups" : [ ],
"materials" : [ "Material" ],
"material" : "Material",
"position" : [ 2.48452, -7.48693, 2.72485 ],
"rotation" : [ 0.220417, 0.0752244, -0.181029 ],
"quaternion": [ 0.988791, 0.112836, 0.0272876, -0.093898 ],
......@@ -230,7 +230,7 @@
"Monkey.006" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ 7.72494, 7.1231, 1.69488 ],
"rotation" : [ 1.83559, -0.0831609, 2.04891 ],
"quaternion": [ 0.287189, 0.433893, 0.664936, 0.535835 ],
......@@ -244,7 +244,7 @@
"Monkey.005" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -6.33464, 6.63615, 0.566791 ],
"rotation" : [ 1.32714, 0.0325614, -2.14729 ],
"quaternion": [ 0.366859, 0.304988, -0.535181, -0.697122 ],
......@@ -258,7 +258,7 @@
"Monkey.004" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -5.38404, -6.19409, 0.444915 ],
"rotation" : [ 0.991213, -0.18143, -1.03711 ],
"quaternion": [ 0.782246, 0.371851, -0.303947, -0.39678 ],
......@@ -272,7 +272,7 @@
"Monkey.003" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ 3.14775, -4.23088, 1.01484 ],
"rotation" : [ -1.42228, 2.83455, 0.213809 ],
"quaternion": [ 0.0463686, -0.179128, 0.733783, 0.653701 ],
......@@ -286,7 +286,7 @@
"Monkey.002" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -2.66804, -2.15339, 3.00888 ],
"rotation" : [ 1.88197, -0.45787, 2.21705 ],
"quaternion": [ 0.0916755, 0.470648, 0.644833, 0.595211 ],
......@@ -300,7 +300,7 @@
"Cube.003" : {
"geometry" : "geo_Cube",
"groups" : [ ],
"materials" : [ "Material" ],
"material" : "Material",
"position" : [ -3.03125, -1.94366, 0.702044 ],
"rotation" : [ 1.84085, 1.81125, -0.141131 ],
"quaternion": [ 0.328619, 0.523567, 0.440581, -0.650981 ],
......@@ -314,7 +314,7 @@
"Monkey.001" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ 1.24531, 0.137285, 0.620196 ],
"rotation" : [ 2.33987, 0.286025, 1.39476 ],
"quaternion": [ 0.38033, 0.662839, 0.627894, 0.147451 ],
......@@ -328,7 +328,7 @@
"Monkey" : {
"geometry" : "geo_Monkey",
"groups" : [ ],
"materials" : [ "Material.002" ],
"material" : "Material.002",
"position" : [ -0.2825, 4.27293, 1.81361 ],
"rotation" : [ 0.646062, 0.219349, 0.0105691 ],
"quaternion": [ 0.942751, 0.314982, 0.10546, -0.0297641 ],
......@@ -342,7 +342,7 @@
"Cube.002" : {
"geometry" : "geo_Cube",
"groups" : [ ],
"materials" : [ "Material" ],
"material" : "Material",
"position" : [ 0.0422118, 0.199037, 5.53683 ],
"rotation" : [ 0, -0, 0 ],
"quaternion": [ 1, 0, 0, 0 ],
......@@ -356,7 +356,7 @@
"Cube.001" : {
"geometry" : "geo_Cube",
"groups" : [ ],
"materials" : [ "Material" ],
"material" : "Material",
"position" : [ -0.395497, 3.94453, 1.0097 ],
"rotation" : [ 0, -0, 0 ],
"quaternion": [ 1, 0, 0, 0 ],
......@@ -370,7 +370,7 @@
"Plane" : {
"geometry" : "geo_Plane",
"groups" : [ ],
"materials" : [ "Material.001" ],
"material" : "Material.001",
"position" : [ 0, -0.11826, 0 ],
"rotation" : [ 0, -0, 0 ],
"quaternion": [ 1, 0, 0, 0 ],
......@@ -384,7 +384,7 @@
"Cube" : {
"geometry" : "geo_Cube",
"groups" : [ ],
"materials" : [ "Material" ],
"material" : "Material",
"position" : [ 3.65198, -1.49012e-08, 1.07114 ],
"rotation" : [ 0.220417, 0.0752244, -0.181029 ],
"quaternion": [ 0.988791, 0.112836, 0.0272876, -0.093898 ],
......
{
"metadata": {
"formatVersion": 3.1,
"formatVersion": 3.2,
"type" : "scene"
},
......@@ -11,7 +11,7 @@
"cube1" : {
"geometry" : "cubeNormals",
"materials": [ "phong_red" ],
"material" : "phong_red",
"position" : [ 0, 0, 0 ],
"rotation" : [ 0, -0.3, 0 ],
"scale" : [ 1, 1, 1 ],
......@@ -25,7 +25,7 @@
"cube2" : {
"geometry" : "cubeWire",
"materials": [ "basic_white" ],
"material" : "basic_white",
"position" : [ 0, 0, 0 ],
"rotation" : [ 0, -0.3, 0 ],
"scale" : [ 2, 2, 2 ],
......@@ -34,7 +34,7 @@
"cube3" : {
"geometry" : "cube",
"materials": [ "minecraft" ],
"material" : "minecraft",
"position" : [ -30, -5, 25 ],
"rotation" : [ 0, 0.8, 0 ],
"scale" : [ 1, 1, 1 ],
......@@ -43,7 +43,7 @@
"sphere_lambert" : {
"geometry" : "sphere",
"materials": [ "lambert_green" ],
"material" : "lambert_green",
"position" : [ -20, -5, 15 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 1, 1, 1 ],
......@@ -52,7 +52,7 @@
"sphere_refraction" : {
"geometry" : "sphere",
"materials": [ "basic_refraction" ],
"material" : "basic_refraction",
"position" : [ 50, 45, -50 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 1, 1, 1 ],
......@@ -61,7 +61,7 @@
"sphere_cube" : {
"geometry" : "sphere_uvs",
"materials": [ "phong_compressed_cube" ],
"material" : "phong_compressed_cube",
"position" : [ -30, -2, -15 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 1.5, 1.5, 1.5 ],
......@@ -70,7 +70,7 @@
"icosahedron" : {
"geometry" : "icosahedron",
"materials": [ "faceted_white" ],
"material" : "faceted_white",
"position" : [ 20, 10, -60 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 1, 1, 1 ],
......@@ -79,7 +79,7 @@
"torus" : {
"geometry" : "torus",
"materials": [ "phong_orange" ],
"material" : "phong_orange",
"position" : [ -20, 5, -50 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 2, 2, 2 ],
......@@ -88,7 +88,7 @@
"cone" : {
"geometry" : "cone",
"materials": [ "lambert_blue" ],
"material" : "lambert_blue",
"position" : [ -50, 15, -50 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 1, 1, 1 ],
......@@ -97,7 +97,7 @@
"cylinder" : {
"geometry" : "cylinder",
"materials": [ "lambert_blue" ],
"material" : "lambert_blue",
"position" : [ 50, 15, -50 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 1, 1, 1 ],
......@@ -106,7 +106,7 @@
"colorcube1" : {
"geometry" : "colorcube",
"materials": [],
"material" : "face",
"position" : [ -10, -5, 30 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 5, 5, 5 ],
......@@ -114,7 +114,7 @@
"children" : {
"colorcube2" : {
"geometry" : "colorcube",
"materials": [],
"material" : "face",
"position" : [ 0, 2, 0 ],
"rotation" : [ 0.1, 0.1, 0.1 ],
"scale" : [ 0.5, 0.5, 0.5 ],
......@@ -122,7 +122,7 @@
"children" : {
"colorcube3" : {
"geometry" : "colorcube",
"materials": [],
"material" : "face",
"position" : [ 0, 2, 0 ],
"rotation" : [ 0.1, 0.1, 0.1 ],
"scale" : [ 0.5, 0.5, 0.5 ],
......@@ -130,7 +130,7 @@
"children" : {
"colorcube4" : {
"geometry" : "colorcube",
"materials": [],
"material" : "face",
"position" : [ 0, 2, 0 ],
"rotation" : [ 0.1, 0.1, 0.1 ],
"scale" : [ 0.5, 0.5, 0.5 ],
......@@ -145,7 +145,7 @@
"veyron" : {
"geometry" : "veyron",
"materials": [ "face" ],
"material" : "face",
"position" : [ 40, -1, 0 ],
"rotation" : [ 0, 0.3, 0 ],
"scale" : [ 0.25, 0.25, 0.25 ],
......@@ -154,7 +154,7 @@
"walt" : {
"geometry" : "WaltHead",
"materials": [ "lambert_cube" ],
"material" : "lambert_cube",
"position" : [ -75, 10, -30 ],
"rotation" : [ 0, 0.5, 0 ],
"scale" : [ 0.5, 0.5, 0.5 ],
......@@ -163,7 +163,7 @@
"ben" : {
"geometry" : "ben",
"materials": [ "phong_ben" ],
"material" : "phong_ben",
"position" : [ -45, -10, 0 ],
"rotation" : [ 0, 0.5, 0 ],
"scale" : [ 55, 55, 55 ],
......@@ -172,7 +172,7 @@
"ninja" : {
"geometry" : "NinjaLo",
"materials": [ "phong_normal" ],
"material" : "phong_normal",
"position" : [ 75, 10, -30 ],
"rotation" : [ 0, -0.5, 0 ],
"scale" : [ 1.25, 1.25, 1.25 ],
......@@ -181,7 +181,7 @@
"sittingBox" : {
"geometry" : "sittingBox",
"materials": [ "phong_morph" ],
"material" : "phong_morph",
"position" : [ -60, -10, 10 ],
"rotation" : [ 0, 0.5, 0 ],
"scale" : [ 23, 23, 23 ],
......@@ -193,7 +193,7 @@
"knight" : {
"geometry" : "knight",
"materials": [ "phong_skin" ],
"material" : "phong_skin",
"position" : [ 70, -10, 10 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 2.5, 2.5, 2.5 ],
......@@ -204,7 +204,7 @@
"man" : {
"type": "obj",
"url" : "obj/male02/male02.obj",
"materials": [ "phong_man" ],
"material" : "phong_man",
"position" : [ -10, -10, -25 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 0.2, 0.2, 0.2 ],
......@@ -214,7 +214,6 @@
"monster" : {
"type": "dae",
"url" : "models/collada/monster/monster.dae",
"materials": [ ],
"position" : [ -43, -10, 27 ],
"rotation" : [ -1.57, 0, 0 ],
"scale" : [ 0.01, 0.01, 0.01 ],
......@@ -224,7 +223,7 @@
"hand" : {
"type" : "utf8",
"url" : "models/utf8/hand.js",
"materials": [ "phong_hand" ],
"material" : "phong_hand",
"position" : [ -28, -1, 29 ],
"rotation" : [ 0, 0.5, 0 ],
"scale" : [ 12, 12, 12 ],
......@@ -236,8 +235,8 @@
},
"bunny" : {
"geometry": "bunny",
"materials": [ "phong_bunny" ],
"geometry" : "bunny",
"material" : "phong_bunny",
"position" : [ -25, -14, 0 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 100, 100, 100 ],
......@@ -245,8 +244,8 @@
},
"disk" : {
"geometry": "disk",
"materials": [ "phong_disk" ],
"geometry" : "disk",
"material" : "phong_disk",
"position" : [ 7, -10, 30 ],
"rotation" : [ 1.57, 0, 0 ],
"scale" : [ 10, 10, 10 ],
......@@ -255,7 +254,7 @@
"quad_bg" : {
"geometry" : "quad",
"materials": [ "textured_bg" ],
"material" : "textured_bg",
"position" : [ 0, 15, -90 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 20, 20, 20 ],
......@@ -264,7 +263,7 @@
"quad_texture1" : {
"geometry" : "quad",
"materials": [ "textured_compressed_dxt3" ],
"material" : "textured_compressed_dxt3",
"position" : [ 15, -5, 20 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 1, 1, 1 ],
......@@ -273,7 +272,7 @@
"quad_texture2" : {
"geometry" : "quad",
"materials": [ "textured_compressed_dxt5" ],
"material" : "textured_compressed_dxt5",
"position" : [ 15, -5, 25 ],
"rotation" : [ 0, 0, 0 ],
"scale" : [ 1, 1, 1 ],
......@@ -282,7 +281,7 @@
"ground" : {
"geometry" : "plane",
"materials": [ "basic_gray" ],
"material" : "basic_gray",
"position" : [ 0, -10, 0 ],
"rotation" : [ -1.57, 0, 0 ],
"scale" : [ 100, 100, 100 ],
......
......@@ -183,6 +183,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
if ( o.type && ( o.type in scope.hierarchyHandlerMap ) && o.loading === undefined ) {
var loaderParameters = {};
for ( var parType in g ) {
if ( parType !== "type" && parType !== "url" ) {
......@@ -193,7 +194,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
}
material = result.materials[ o.materials[ 0 ] ];
material = result.materials[ o.material ];
o.loading = true;
......@@ -234,10 +235,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
var hasNormals = false;
// not anymore support for multiple materials
// shouldn't really be array
material = result.materials[ o.materials[ 0 ] ];
material = result.materials[ o.material ];
hasNormals = material instanceof THREE.ShaderMaterial;
if ( hasNormals ) {
......@@ -256,16 +254,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
q = 0;
if ( o.materials.length === 0 ) {
material = new THREE.MeshFaceMaterial();
}
// dirty hack to handle meshes with multiple materials
// just use face materials defined in model
if ( o.materials.length > 1 ) {
if ( ! o.material ) {
material = new THREE.MeshFaceMaterial();
......
......@@ -85,7 +85,7 @@ TEMPLATE_SCENE_ASCII = """\
"metadata" :
{
"formatVersion" : 3.1,
"formatVersion" : 3.2,
"type" : "scene",
"sourceFile" : "%(fname)s",
"generatedBy" : "Blender 2.64 Exporter",
......@@ -127,7 +127,7 @@ TEMPLATE_OBJECT = """\
%(object_id)s : {
"geometry" : %(geometry_id)s,
"groups" : [ %(group_id)s ],
"materials" : [ %(material_id)s ],
"material" : %(material_id)s,
"position" : %(position)s,
"rotation" : %(rotation)s,
"quaternion": %(quaternion)s,
......@@ -1637,8 +1637,11 @@ def generate_objects(data):
position, quaternion, scale = obj.matrix_world.decompose()
rotation = quaternion.to_euler("XYZ")
# use empty material string for multi-material objects
# this will trigger use of MeshFaceMaterial in SceneLoader
material_string = ""
if len(material_ids) > 0:
if len(material_ids) == 1:
material_string = generate_string_list(material_ids)
group_string = ""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册