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