From 0bedc4af5f8270fc1e4fccee5e95967e19549a88 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Tue, 4 Nov 2014 21:55:32 +0100 Subject: [PATCH] Update JSModeler. --- jsmodeler/jsmodeler.js | 61 ++++++++++++++++++---------------- website/include/importerapp.js | 2 +- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/jsmodeler/jsmodeler.js b/jsmodeler/jsmodeler.js index f025262..fb62da4 100644 --- a/jsmodeler/jsmodeler.js +++ b/jsmodeler/jsmodeler.js @@ -1,4 +1,4 @@ -/* JSModeler 0.33.232 - http://www.github.com/kovacsv/JSModeler */ 'use strict';var JSM={mainVersion:0,subVersion:33,Eps:1E-8,Inf:9999999999,RadDeg:57.29577951308232,DegRad:0.017453292519943,IsZero:function(a){return Math.abs(a)JSM.Eps},IsNegative:function(a){return a<-JSM.Eps},IsLower:function(a,b){return b-a>JSM.Eps},IsGreater:function(a,b){return a-b>JSM.Eps},IsEqual:function(a,b){return Math.abs(b-a)JSM.Eps},IsNegative:function(a){return a<-JSM.Eps},IsLower:function(a,b){return b-a>JSM.Eps},IsGreater:function(a,b){return a-b>JSM.Eps},IsEqual:function(a,b){return Math.abs(b-a)b.length)){for(var c=a.GetVertex(b[0]),d=a.GetVertex(b[1]),d=JSM.CoordSub(d,c),f=JSM.GetPlaneFromCoordAndDirection(c,d),g,d=[],c=0;cb.center.x,d=a.y>b.center.y,e=a.z>b.center.z;return!c&&!d&&!e?this.FindNode(a,b.children[0]):c&&!d&&!e?this.FindNode(a,b.children[1]):c&&d&&!e?this.FindNode(a,b.children[2]):!c&&d&&!e?this.FindNode(a,b.children[3]):!c&&!d&&e?this.FindNode(a,b.children[4]):c&&!d&&e?this.FindNode(a,b.children[5]):c&&d&&e?this.FindNode(a,b.children[6]):!c&&d&&e?this.FindNode(a,b.children[7]):null}; +JSM.Octree.prototype.SplitNode=function(a){function b(a,b){var e=a.center.Clone(),f=JSM.VectorMultiply(a.size,0.5);e.x+=0.5*b.x*f.x;e.y+=0.5*b.y*f.y;e.z+=0.5*b.z*f.z;return{center:e,size:f,coord:-1,children:null}}a.children=[b(a,new JSM.Coord(-1,-1,-1)),b(a,new JSM.Coord(1,-1,-1)),b(a,new JSM.Coord(1,1,-1)),b(a,new JSM.Coord(-1,1,-1)),b(a,new JSM.Coord(-1,-1,1)),b(a,new JSM.Coord(1,-1,1)),b(a,new JSM.Coord(1,1,1)),b(a,new JSM.Coord(-1,1,1))];this.FindNode(this.coords[a.coord],a).coord=a.coord;a.coord= +-1};JSM.BSPTree=function(){this.root=null};JSM.BSPTree.prototype.AddPolygon=function(a,b){null===this.root&&(this.root=this.GetNewNode());return this.AddPolygonToNode(this.root,a,b)};JSM.BSPTree.prototype.Traverse=function(a){this.TraverseNode(this.root,a)};JSM.BSPTree.prototype.TraverseNode=function(a,b){null!==a&&(b(a),this.TraverseNode(a.inside,b),this.TraverseNode(a.outside,b))};JSM.BSPTree.prototype.GetNodes=function(){var a=[];this.Traverse(function(b){a.push(b)});return a}; JSM.BSPTree.prototype.NodeCount=function(){var a=0;this.Traverse(function(){a+=1});return a}; JSM.BSPTree.prototype.AddPolygonToNode=function(a,b,c){if(3>b.VertexCount())return!1;var d;if(null===a.polygon){d=JSM.CalculateNormal(b.vertices);var e=JSM.GetPlaneFromCoordAndDirection(b.GetVertex(0),d);a.polygon=b;void 0!==c&&(a.userData=c);a.plane=e}else{d=[];var f=[],e=[];JSM.CutPolygonWithPlane(b,a.plane,f,d,e)&&(0b.length;)b="0"+b;a=parseInt(b.substr(0,2),16);var c=parseInt(b.substr(2,2),16),b=parseInt(b.substr(4,2),16);return[a,c,b]};JSM.HexColorToNormalizedRGBComponents=function(a){a=JSM.HexColorToRGBComponents(a);return[a[0]/255,a[1]/255,a[2]/255]};JSM.HexColorToRGBColor=function(a){return parseInt("0x"+a,16)}; JSM.RGBComponentsToHexColor=function(a,b,c){function d(a){for(a=parseInt(a,10).toString(16);2>a.length;)a="0"+a;return a}a=d(a);b=d(b);c=d(c);return parseInt("0x"+a+b+c,16)};JSM.Light=function(a){var b={ambient:8355711,diffuse:8355711,specular:0,direction:new JSM.Vector(1,0,0)};JSM.CopyObjectProperties(a,this,!0);JSM.CopyObjectProperties(b,this,!1)}; JSM.Material=function(a){JSM.CopyObjectProperties(a,this,!0);JSM.CopyObjectProperties({ambient:52224,diffuse:52224,specular:0,shininess:0,opacity:1,texture:null,textureWidth:1,textureHeight:1},this,!1)};JSM.Materials=function(){this.materials=[];this.defaultMaterial=new JSM.Material};JSM.Materials.prototype.GetMaterial=function(a){return 0>a||a>=this.materials.length?this.defaultMaterial:this.materials[a]};JSM.Materials.prototype.AddMaterial=function(a){this.materials.push(a)}; -JSM.Materials.prototype.GetDefaultMaterial=function(){return this.defaultMaterial};JSM.Materials.prototype.Count=function(){return this.materials.length};JSM.AddVertexToBody=function(a,b,c,d){a.AddVertex(new JSM.BodyVertex(new JSM.Coord(b,c,d)))};JSM.AddPolygonToBody=function(a,b){a.AddPolygon(new JSM.BodyPolygon(b))};JSM.CalculateBodyVertexToPolygon=function(a){var b=[],c,d;for(c=0;cl;l++)0===l?m=e:1===l?m=f:2===l&&(m=g),n=Math.abs(JSM.VectorDot(b,m)),JSM.IsGreater(n,k)&&(h=l,k=n);if(-1===h)return d;b=null;0===h?b=new JSM.CoordSystem(c.origo,f,g,new JSM.Coord(0,0,0)):1===h?b=new JSM.CoordSystem(c.origo,e,g,new JSM.Coord(0,0,0)):2===h&&(b=new JSM.CoordSystem(c.origo,e,f,new JSM.Coord(0,0,0)));return null=== b?d:JSM.CalculatePlanarTextureCoord(a,b)};JSM.CalculateCylindricalTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=JSM.VectorNormalize(c.e3);if(JSM.VectorsAreCollinear(e,b))return d=JSM.CalculateCubicTextureCoord(a,b,c),[d,0];b=new JSM.Line(c.origo,e);var f=JSM.ProjectCoordToLine(a,b);b=JSM.CoordSignedDistance(c.origo,f,e);var g=JSM.VectorNormalize(c.e1);a=JSM.CoordSub(a,f);e=JSM.GetVectorsFullAngle(a,g,e);c=JSM.VectorLength(c.e1);d.x=e*c;d.y=b;return[d,e]}; @@ -478,27 +485,26 @@ JSM.Navigation.prototype.OnTouchStart=function(a){a.preventDefault();this.touch. JSM.Navigation.prototype.OnResize=function(a){a.preventDefault();this.ResizeCallback()};JSM.SoftwareViewer=function(){this.navigation=this.drawMode=this.drawer=this.bodies=this.camera=this.canvas=null};JSM.SoftwareViewer.prototype.Start=function(a,b){return!this.InitCanvas(a)||!this.InitCamera(b)?!1:!0}; JSM.SoftwareViewer.prototype.InitCanvas=function(a){this.bodies=[];this.canvas=a;if(!this.canvas)return!1;this.canvas instanceof HTMLCanvasElement?this.drawer=new JSM.CanvasDrawer(this.canvas):this.canvas instanceof SVGSVGElement&&(this.drawer=new JSM.SVGDrawer(this.canvas));if(!this.drawer)return!1;this.drawMode="Wireframe";return!0}; JSM.SoftwareViewer.prototype.InitCamera=function(a){this.camera=JSM.ValueOrDefault(a,new JSM.Camera);if(!this.camera)return!1;this.navigation=new JSM.Navigation;return!this.navigation.Init(this.canvas,this.camera,this.Draw.bind(this),this.Resize.bind(this))?!1:!0};JSM.SoftwareViewer.prototype.AddBody=function(a,b){this.bodies.push([a,b])};JSM.SoftwareViewer.prototype.RemoveBodies=function(){this.bodies=[]}; -JSM.SoftwareViewer.prototype.FitInWindow=function(){var a=this.GetCenter(),b=this.GetBoundingSphereRadius(a);this.navigation.FitInWindow(a,b);this.Draw()};JSM.SoftwareViewer.prototype.GetCenter=function(){var a=this.GetBoundingBox();return JSM.MidCoord(a[0],a[1])}; -JSM.SoftwareViewer.prototype.GetBoundingBox=function(){var a=new JSM.Coord(JSM.Inf,JSM.Inf,JSM.Inf),b=new JSM.Coord(-JSM.Inf,-JSM.Inf,-JSM.Inf),c,d,e,f;for(c=0;cb.position.z?-1:a.position.zv 0.2', function () { myThis.WelcomeDialog (); }); + importerButtons.AddLogo ('Online 3D Viewer v 0.3', function () { myThis.WelcomeDialog (); }); importerButtons.AddButton ('images/openfile.png', 'Open File', function () { myThis.OpenFile (); }); importerButtons.AddButton ('images/fitinwindow.png', 'Fit In Window', function () { myThis.FitInWindow (); }); importerButtons.AddButton ('images/fixup.png', 'Enable/Disable Fixed Up Vector', function () { myThis.SetFixUp (); });