/* JSModeler 0.45 - 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,G=a.specular,t=a.shininess;0===t&&(G=0,t=1);f=new THREE.MeshPhongMaterial({color:c,specular:G,shininess:t});a.singleSided||(f.side=THREE.DoubleSide);e&&(f.opacity=a.opacity,f.transparent=!0);if(b){var m=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;m.map=a;m.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,m,F,p){var n=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(n+0,n+1,n+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!==m&&(null!== F&&null!==p)&&(c=[],c.push(new THREE.Vector2(m.x,-m.y)),c.push(new THREE.Vector2(F.x,-F.y)),c.push(new THREE.Vector2(p.x,-p.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