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