/* JSModeler 0.41 - http://www.github.com/kovacsv/JSModeler */ 'use strict';JSM.ConvertBodyToThreeMeshes=function(a,b,e){var c={textureLoadedCallback:null,hasConvexPolygons:!1};void 0!==e&&null!==e&&(c.textureLoadedCallback=JSM.ValueOrDefault(e.textureLoadedCallback,c.textureLoadedCallback),c.hasConvexPolygons=JSM.ValueOrDefault(e.hasConvexPolygons,c.hasConvexPolygons));var f=[],d=null,g=null;JSM.ExplodeBody(a,b,{hasConvexPolygons:c.hasConvexPolygons,onPointGeometryStart:function(a){g=new THREE.PointsMaterial({color:a.diffuse,size:a.pointSize});d=new THREE.Geometry}, onPointGeometryEnd:function(){var a=new THREE.Points(d,g);f.push(a)},onPoint:function(a){d.vertices.push(new THREE.Vector3(a.x,a.y,a.z))},onLineGeometryStart:function(a){d=new THREE.Geometry;g=new THREE.LineBasicMaterial({color:a.diffuse})},onLineGeometryEnd:function(){var a=new THREE.LineSegments(d,g);f.push(a)},onLine:function(a,b){d.vertices.push(new THREE.Vector3(a.x,a.y,a.z));d.vertices.push(new THREE.Vector3(b.x,b.y,b.z))},onGeometryStart:function(a){var b=null!==a.texture,e=1!==a.opacity,f= a.diffuse,F=a.specular,u=a.shininess;0===u&&(F=0,u=1);g=new THREE.MeshPhongMaterial({color:f,specular:F,shininess:u});a.singleSided||(g.side=THREE.DoubleSide);e&&(g.opacity=a.opacity,g.transparent=!0);if(b){var n=g;a=a.texture;(new THREE.TextureLoader).load(a,function(a){a.image=JSM.ResizeImageToPowerOfTwoSides(a.image);a.wrapS=THREE.RepeatWrapping;a.wrapT=THREE.RepeatWrapping;n.map=a;n.needsUpdate=!0;null!==c.textureLoadedCallback&&c.textureLoadedCallback()})}d=new THREE.Geometry},onGeometryEnd:function(){d.computeFaceNormals(); var a=new THREE.Mesh(d,g);f.push(a)},onTriangle:function(a,b,c,e,g,f,n,E,l){var p=d.vertices.length;d.vertices.push(new THREE.Vector3(a.x,a.y,a.z));d.vertices.push(new THREE.Vector3(b.x,b.y,b.z));d.vertices.push(new THREE.Vector3(c.x,c.y,c.z));a=new THREE.Face3(p+0,p+1,p+2);d.faces.push(a);null!==e&&(null!==g&&null!==f)&&(a=[],a.push(new THREE.Vector3(e.x,e.y,e.z)),a.push(new THREE.Vector3(g.x,g.y,g.z)),a.push(new THREE.Vector3(f.x,f.y,f.z)),d.faces[d.faces.length-1].vertexNormals=a);null!==n&&(null!== E&&null!==l)&&(e=[],e.push(new THREE.Vector2(n.x,-n.y)),e.push(new THREE.Vector2(E.x,-E.y)),e.push(new THREE.Vector2(l.x,-l.y)),d.faceVertexUvs[0].push(e))}});return f};JSM.ConvertModelToThreeMeshes=function(a,b,e){var c=[],f,d,g;for(f=0;f