Update JSModeler.
This commit is contained in:
parent
4397d7ec02
commit
0bedc4af5f
@ -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},IsPositive:function(a){return 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},IsEqualWithEps:function(a,b,c){return Math.abs(b-a)<c},IsLowerOrEqual:function(a,b){return JSM.IsLower(a,b)||
|
||||
/* JSModeler 0.33.241 - 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},IsPositive:function(a){return 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},IsEqualWithEps:function(a,b,c){return Math.abs(b-a)<c},IsLowerOrEqual:function(a,b){return JSM.IsLower(a,b)||
|
||||
JSM.IsEqual(a,b)},IsGreaterOrEqual:function(a,b){return JSM.IsGreater(a,b)||JSM.IsEqual(a,b)},Minimum:function(a,b){return JSM.IsLower(a,b)?a:b},Maximum:function(a,b){return JSM.IsGreater(a,b)?a:b},ArcSin:function(a){return JSM.IsGreaterOrEqual(a,1)?Math.PI/2:JSM.IsLowerOrEqual(a,-1)?-Math.PI/2:Math.asin(a)},ArcCos:function(a){return JSM.IsGreaterOrEqual(a,1)?0:JSM.IsLowerOrEqual(a,-1)?Math.PI:Math.acos(a)},RandomNumber:function(a,b){return Math.random()*(b-a)+a},RandomInt:function(a,b){return Math.floor(Math.random()*
|
||||
(b-a+1)+a)},SeededRandomInt:function(a,b,c){return Math.floor((9301*c+49297)%233280/233280*(b-a+1)+a)},ValueOrDefault:function(a,b){return void 0===a||null===a?b:a},CopyObjectProperties:function(a,b,c){if(!(void 0===a||null===a||void 0===b||null===b))for(var d in a)if(a.hasOwnProperty(d)&&(c||void 0===b[d]||null===b[d]))b[d]=a[d]},Assert:function(a,b){if(!a){var c="Assertion failed.";void 0!==b&&null!==b&&(c+=" "+b);alert(c)}},Timer:function(){this.stop=this.start=0}};
|
||||
JSM.Timer.prototype.Start=function(){this.start=(new Date).getTime()};JSM.Timer.prototype.Stop=function(){this.end=(new Date).getTime()};JSM.Timer.prototype.Result=function(){return this.end-this.start};JSM.FPSCounter=function(){this.current=this.frames=this.start=null};
|
||||
@ -49,9 +49,11 @@ JSM.CoordLinePosition2D=function(a,b){var c=b.start,d=b.direction,c=d.x*(a.y-c.y
|
||||
JSM.CoordLinePosition=function(a,b,c){var d=a.x,e=a.y,f=a.z,g=b.start;b=b.direction;var h=g.x,k=g.y,l=g.z,m=g.x+b.x,n=g.y+b.y,p=g.z+b.z,q=(m-h)*(m-h)+(n-k)*(n-k)+(p-l)*(p-l);if(JSM.IsZero(q))return void 0!==c&&c.Set(g.x,g.y,g.z),JSM.CoordIsEqual(g,a)?"CoordOnLine":"CoordOutsideOfLine";d=JSM.CoordAdd(g,JSM.VectorMultiply(b,((m-h)*(d-h)+(n-k)*(e-k)+(p-l)*(f-l))/q));void 0!==c&&c.Set(d.x,d.y,d.z);a=JSM.CoordDistance(a,d);return JSM.IsZero(a)?"CoordOnLine":"CoordOutsideOfLine"};
|
||||
JSM.ProjectCoordToLine=function(a,b){var c=new JSM.Coord(0,0,0),d=a.x,e=a.y,f=a.z,g=b.start,h=b.direction,k=g.x,l=g.y,m=g.z,n=g.x+h.x,p=g.y+h.y,q=g.z+h.z,r=(n-k)*(n-k)+(p-l)*(p-l)+(q-m)*(q-m);if(JSM.IsZero(r))return c.Set(g.x,g.y,g.z),c;d=JSM.CoordAdd(g,JSM.VectorMultiply(h,((n-k)*(d-k)+(p-l)*(e-l)+(q-m)*(f-m))/r));c.Set(d.x,d.y,d.z);return c};
|
||||
JSM.LineLineClosestPoint=function(a,b,c,d){function e(a,b,c,d,e){return(a[b].x-a[c].x)*(a[d].x-a[e].x)+(a[b].y-a[c].y)*(a[d].y-a[e].y)+(a[b].z-a[c].z)*(a[d].z-a[e].z)}var f=JSM.VectorNormalize(a.direction),g=a.start,f=JSM.CoordAdd(g,f);a=JSM.VectorNormalize(b.direction);b=b.start;var h=JSM.CoordAdd(b,a),k=[g,f,b,h],l=e(k,1,0,1,0),m=e(k,0,2,1,0),h=e(k,0,2,3,2),n=e(k,3,2,1,0),k=e(k,3,2,3,2),l=l*k-n*n;if(JSM.IsEqual(l,0))return!1;m=(h*n-m*k)/l;h=(h+m*n)/k;void 0!==c&&(f=JSM.VectorNormalize(JSM.CoordSub(f,
|
||||
g)),g=JSM.CoordAdd(g,JSM.VectorMultiply(f,m)),c.Set(g.x,g.y,g.z));void 0!==d&&(c=JSM.CoordAdd(b,JSM.VectorMultiply(a,h)),d.Set(c.x,c.y,c.z));return!0};JSM.LineLinePosition=function(a,b,c){var d=new JSM.Coord(0,0,0),e=new JSM.Coord(0,0,0);return!JSM.LineLineClosestPoint(a,b,d,e)?"LinesIntersectsCoincident":JSM.CoordIsEqual(d,e)?(void 0!==c&&c.Set(d.x,d.y,d.z),"LinesIntersectsOnePoint"):"LinesDontIntersects"};JSM.Transformation=function(){this.matrix=JSM.MatrixIdentity()};
|
||||
JSM.Transformation.prototype.GetMatrix=function(){return this.matrix};JSM.Transformation.prototype.SetMatrix=function(a){this.matrix=a};JSM.Transformation.prototype.Append=function(a){this.matrix=JSM.MatrixMultiply(this.matrix,a.matrix)};JSM.Transformation.prototype.Apply=function(a){return JSM.ApplyTransformation(this.matrix,a)};JSM.Transformation.prototype.Clone=function(){var a=new JSM.Transformation;a.matrix=JSM.MatrixClone(this.matrix);return a};
|
||||
JSM.IdentityTransformation=function(){var a=new JSM.Transformation;a.matrix=JSM.MatrixIdentity();return a};JSM.TranslationTransformation=function(a){var b=new JSM.Transformation;b.matrix=JSM.MatrixTranslation(a.x,a.y,a.z);return b};JSM.OffsetTransformation=function(a,b){var c=JSM.VectorNormalize(a),c=JSM.VectorMultiply(c,b);return JSM.TranslationTransformation(c)};JSM.RotationTransformation=function(a,b,c){var d=new JSM.Transformation;d.matrix=JSM.MatrixRotation(a,b,c);return d};
|
||||
g)),g=JSM.CoordAdd(g,JSM.VectorMultiply(f,m)),c.Set(g.x,g.y,g.z));void 0!==d&&(c=JSM.CoordAdd(b,JSM.VectorMultiply(a,h)),d.Set(c.x,c.y,c.z));return!0};JSM.LineLinePosition=function(a,b,c){var d=new JSM.Coord(0,0,0),e=new JSM.Coord(0,0,0);return!JSM.LineLineClosestPoint(a,b,d,e)?"LinesIntersectsCoincident":JSM.CoordIsEqual(d,e)?(void 0!==c&&c.Set(d.x,d.y,d.z),"LinesIntersectsOnePoint"):"LinesDontIntersects"};JSM.Box2D=function(a,b){this.min=a;this.max=b};
|
||||
JSM.Box2D.prototype.Set=function(a,b){this.min=a;this.max=b};JSM.Box2D.prototype.GetCenter=function(){return JSM.MidCoord2D(this.min,this.max)};JSM.Box2D.prototype.Clone=function(){return new JSM.Box2D(this.min.Clone(),this.max.Clone())};JSM.Box=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.Set=function(a,b){this.min=a;this.max=b};JSM.Box.prototype.GetCenter=function(){return JSM.MidCoord(this.min,this.max)};JSM.Box.prototype.Clone=function(){return new JSM.Box(this.min.Clone(),this.max.Clone())};
|
||||
JSM.BoxUnion=function(a,b){var c=new JSM.Coord(JSM.Minimum(a.min.x,b.min.x),JSM.Minimum(a.min.y,b.min.y),JSM.Minimum(a.min.z,b.min.z)),d=new JSM.Coord(JSM.Maximum(a.max.x,b.max.x),JSM.Maximum(a.max.y,b.max.y),JSM.Maximum(a.max.z,b.max.z));return new JSM.Box(c,d)};JSM.Transformation=function(){this.matrix=JSM.MatrixIdentity()};JSM.Transformation.prototype.GetMatrix=function(){return this.matrix};JSM.Transformation.prototype.SetMatrix=function(a){this.matrix=a};
|
||||
JSM.Transformation.prototype.Append=function(a){this.matrix=JSM.MatrixMultiply(this.matrix,a.matrix)};JSM.Transformation.prototype.Apply=function(a){return JSM.ApplyTransformation(this.matrix,a)};JSM.Transformation.prototype.Clone=function(){var a=new JSM.Transformation;a.matrix=JSM.MatrixClone(this.matrix);return a};JSM.IdentityTransformation=function(){var a=new JSM.Transformation;a.matrix=JSM.MatrixIdentity();return a};
|
||||
JSM.TranslationTransformation=function(a){var b=new JSM.Transformation;b.matrix=JSM.MatrixTranslation(a.x,a.y,a.z);return b};JSM.OffsetTransformation=function(a,b){var c=JSM.VectorNormalize(a),c=JSM.VectorMultiply(c,b);return JSM.TranslationTransformation(c)};JSM.RotationTransformation=function(a,b,c){var d=new JSM.Transformation;d.matrix=JSM.MatrixRotation(a,b,c);return d};
|
||||
JSM.RotationXTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationX(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationXTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c};
|
||||
JSM.RotationYTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationY(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationYTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c};
|
||||
JSM.RotationZTransformation=function(a,b){var c=new JSM.Transformation;void 0===b||null===b?c.matrix=JSM.MatrixRotationZ(a):(c.Append(JSM.TranslationTransformation(new JSM.Vector(-b.x,-b.y,-b.z))),c.Append(JSM.RotationZTransformation(a)),c.Append(JSM.TranslationTransformation(new JSM.Vector(b.x,b.y,b.z))));return c};
|
||||
@ -91,14 +93,17 @@ JSM.PolygonTriangulate=function(a){var b=new JSM.Polygon2D,c=JSM.CalculateNormal
|
||||
JSM.OffsetPolygonContour=function(a,b){var c=a.VertexCount(),d=JSM.CalculateNormal(a.vertices),e,f,g,h,k,l=new JSM.Polygon,m;for(m=0;m<c;m++)e=0===m?c-1:m-1,f=m,g=m===c-1?0:m+1,e=a.GetVertex(e),f=a.GetVertex(f),h=a.GetVertex(g),k=JSM.CoordSub(e,f),g=JSM.CoordSub(h,f),k=JSM.GetVectorsAngle(k,g)/2,"Clockwise"===JSM.CoordTurnType(e,f,h,d)&&(k=Math.PI-k),e=b/Math.sin(k),e=JSM.CoordOffset(f,g,e),e=JSM.CoordRotate(e,d,k,f),l.AddVertex(e.x,e.y,e.z);return l};
|
||||
JSM.CutPolygonWithPlane=function(a,b,c,d,e){function f(a,b,c,d,e){1==b?c.push(a):-1==b?d.push(a):e.push(a)}function g(a,b,c,d){function e(a,b){if(!(2>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;c<b.length;c++)g=a.GetVertex(b[c]),d.push(JSM.CoordPlaneSignedDistance(g,f));for(c=0;c<b.length-1;c++)for(f=0;f<b.length-c-1;f++)if(JSM.IsGreater(d[f],d[f+1])){g=d;var h=f+1,l=g[f];g[f]=g[h];g[h]=l;g=b;h=f+1;l=g[f];g[f]=
|
||||
g[h];g[h]=l}}}function f(a,b,c,d,e,g){function h(a,b){a[a[b]]=-1;a[b]=-1}var l=[];(function(a,b,c){var d;for(d=0;d<a.VertexCount();d++)c.push(-1);for(d=0;d<b.length;d+=2){a=c;var e=b,f=d;a[e[f]]=e[f+1];a[e[f+1]]=e[f]}})(a,b,l);var k=0;g&&(k=b.length-1);for(var m=b[k],n=m,p=!1,q=0,r=new JSM.Polygon,t;;){p||(q=c[n],0!==q&&(p=!0));if(0<r.VertexCount()&&n==m)if(1==q?d.push(r):-1==q&&e.push(r),r=new JSM.Polygon,0<k&&k<b.length){n=m=b[k];continue}else break;t=a.GetVertex(n);r.AddVertex(t.x,t.y,t.z);-1!=
|
||||
l[n]?(k=g?k-2:k+2,n=l[n],h(l,n)):n=n<a.VertexCount()-1?n+1:0}}var g=[];(function(a,b){var c,d,e,f;for(c=0;c<a.length;c++)if(d=a[c],0===d){d=0<c?c-1:a.length-1;e=c<a.length-1?c+1:0;f=a[d];e=a[e];if(0!==e&&0===f){for(;0===a[d];)d=0<d?d-1:a.length-1;f=a[d]}(-1==f&&1==e||1==f&&-1==e)&&b.push(c)}})(b,g);0===g.length||0!==g.length%2||(e(a,g),f(a,g,b,c,d,!1),f(a,g,b,c,d,!0))}var h=new JSM.Polygon,k=[];b=function(a,b,c,d){function e(a,c,d,f,g){function h(a,c,d,e,f,g){var k=d[d.length-1];0!==k&&(0!==g&&k!=
|
||||
g)&&(e=a.GetVertex(e),a=a.GetVertex(f),a=new JSM.Line(a,JSM.CoordSub(a,e)),f=new JSM.Coord(0,0,0),"LineIntersectsPlane"==JSM.LinePlanePosition(a,b,f)&&(c.AddVertex(f.x,f.y,f.z),d.push(0)))}function k(a,b,c,d,e){a=a.GetVertex(d);b.AddVertex(a.x,a.y,a.z);c.push(e)}var l=0===c,n=c===a.VertexCount(),p;n?(c=0,p=a.VertexCount()-1):p=c-1;f=f[c];l||h(a,d,g,p,c,f);n||k(a,d,g,c,f);return f}var f=[],g=!1,h=!1,k,s,x;for(k=0;k<a.VertexCount();k++)s=a.GetVertex(k),s=JSM.CoordPlanePosition(s,b),x=0,"CoordInFrontOfPlane"==
|
||||
s?(x=1,h=!0):"CoordAtBackOfPlane"==s&&(x=-1,g=!0),f.push(x);if(g&&h)for(k=0;k<=a.VertexCount();k++)e(a,k,c,f,d);else{if(g)return-1;if(h)return 1}return 0}(a,b,h,k);0===h.VertexCount()&&0===k.length?f(a,b,c,d,e):g(h,k,c,d);return 0===c.length+d.length+e.length?!1:!0};JSM.BSPNode=function(){this.outside=this.inside=this.parent=this.plane=this.userData=this.polygon=null};JSM.BSPNode.prototype.IsLeaf=function(){return null===this.inside&&null===this.outside};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};
|
||||
l[n]?(k=g?k-2:k+2,n=l[n],h(l,n)):n=n<a.VertexCount()-1?n+1:0}}var g=function(a){var b=[],c,d,e,f;for(c=0;c<a.length;c++)if(d=a[c],0===d){d=0<c?c-1:a.length-1;e=c<a.length-1?c+1:0;f=a[d];e=a[e];if(0!==e&&0===f){for(;0===a[d];)d=0<d?d-1:a.length-1;f=a[d]}(-1==f&&1==e||1==f&&-1==e)&&b.push(c)}return b}(b);0===g.length||0!==g.length%2||(e(a,g),f(a,g,b,c,d,!1),f(a,g,b,c,d,!0))}var h=new JSM.Polygon,k=[];b=function(a,b,c,d){function e(a,c,d,f,g){function h(a,c,d,e,f,g){var k=d[d.length-1];0!==k&&(0!==g&&
|
||||
k!=g)&&(e=a.GetVertex(e),a=a.GetVertex(f),a=new JSM.Line(a,JSM.CoordSub(a,e)),f=new JSM.Coord(0,0,0),"LineIntersectsPlane"==JSM.LinePlanePosition(a,b,f)&&(c.AddVertex(f.x,f.y,f.z),d.push(0)))}function k(a,b,c,d,e){a=a.GetVertex(d);b.AddVertex(a.x,a.y,a.z);c.push(e)}var l=0===c,n=c===a.VertexCount(),p;n?(c=0,p=a.VertexCount()-1):p=c-1;f=f[c];l||h(a,d,g,p,c,f);n||k(a,d,g,c,f);return f}var f=[],g=!1,h=!1,k,s,x;for(k=0;k<a.VertexCount();k++)s=a.GetVertex(k),s=JSM.CoordPlanePosition(s,b),x=0,"CoordInFrontOfPlane"==
|
||||
s?(x=1,h=!0):"CoordAtBackOfPlane"==s&&(x=-1,g=!0),f.push(x);if(g&&h)for(k=0;k<=a.VertexCount();k++)e(a,k,c,f,d);else{if(g)return-1;if(h)return 1}return 0}(a,b,h,k);0===h.VertexCount()&&0===k.length?f(a,b,c,d,e):g(h,k,c,d);return 0===c.length+d.length+e.length?!1:!0};JSM.Octree=function(a,b){this.coords=[];this.root={center:JSM.MidCoord(a,b),size:JSM.CoordSub(b,a),coord:-1,children:null}};JSM.Octree.prototype.AddCoord=function(a){return this.AddCoordToNode(a,this.root)};
|
||||
JSM.Octree.prototype.FindCoord=function(a){a=this.FindNode(a,this.root);return null===a?-1:a.coord};JSM.Octree.prototype.AddCoordToNode=function(a,b){var c=this.FindNode(a,b);if(null===c)return-1;if(-1==c.coord)return c.coord=this.coords.length,this.coords.push(a),c.coord;if(JSM.CoordIsEqual(a,this.coords[c.coord]))return c.coord;this.SplitNode(c);return this.AddCoordToNode(a,c)};
|
||||
JSM.Octree.prototype.FindNode=function(a,b){if(null===b.children)return b;var c=a.x>b.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)&&(0<d.length&&this.AddInsidePolygonsToNode(a,d,c),0<f.length&&this.AddOutsidePolygonsToNode(a,f,c),0<e.length&&(d=JSM.CalculateNormal(b.vertices),0<JSM.VectorDot(d,a.plane.GetNormal())?
|
||||
this.AddInsidePolygonsToNode(a,e,c):this.AddOutsidePolygonsToNode(a,e,c)))}return!0};JSM.BSPTree.prototype.AddInsidePolygonsToNode=function(a,b,c){null===a.inside&&(a.inside=this.GetNewNode(),a.inside.parent=a);var d;for(d=0;d<b.length;d++)this.AddPolygonToNode(a.inside,b[d],c)};JSM.BSPTree.prototype.AddOutsidePolygonsToNode=function(a,b,c){null===a.outside&&(a.outside=this.GetNewNode(),a.outside.parent=a);var d;for(d=0;d<b.length;d++)this.AddPolygonToNode(a.outside,b[d],c)};
|
||||
JSM.BSPTree.prototype.GetNewNode=function(){return new JSM.BSPNode};
|
||||
JSM.BSPTree.prototype.GetNewNode=function(){return{polygon:null,userData:null,plane:null,parent:null,inside:null,outside:null}};
|
||||
JSM.ClipPolygonWithBSPTree=function(a,b,c,d,e,f){function g(a,b,c){if(null!==b){var d=[],e=[],f=[];JSM.CutPolygonWithPlane(a,b.plane,e,d,f)&&(0<d.length&&k(b,d,c),0<e.length&&l(b,e,c),0<f.length&&(a=JSM.CalculateNormal(a.vertices),0<JSM.VectorDot(a,b.plane.GetNormal())?k(b,f,!0):l(b,f,!0)))}}function h(a,b){var c;for(c=0;c<a.length;c++)b.push(a[c])}function k(a,b,c){if(null!==a.inside){a=a.inside;var e;for(e=0;e<b.length;e++)g(b[e],a,c)}else h(b,c?f:d)}function l(a,b,d){if(null!==a.outside){a=a.outside;
|
||||
var f;for(f=0;f<b.length;f++)g(b[f],a,d)}else h(b,d?e:c)}g(a,b.root,!1);return!0};JSM.GetGaussianCParameter=function(a,b,c,d){return Math.sqrt(-(Math.pow(a-c,2)/(2*Math.log(d/Math.abs(b)))))};JSM.GetGaussianValue=function(a,b,c,d){return b*Math.exp(-(Math.pow(a-c,2)/(2*Math.pow(d,2))))};JSM.GenerateCirclePoints=function(a,b,c){var d=[],e=2*Math.PI,f=2*Math.PI/b,g,h;for(g=0;g<b;g++)h=JSM.CylindricalToCartesian(a,0,e),void 0!==c&&null!==c&&(h=JSM.CoordAdd(h,c)),d.push(h),e+=f;return d};
|
||||
JSM.GetRuledMesh=function(a,b,c,d,e){if(a.length===b.length){var f=a.length-1,g=[],h=[],k;for(k=0;k<=f;k++)g.push(JSM.CoordSub(b[k],a[k])),h.push(JSM.CoordDistance(a[k],b[k]));var l,m;for(k=0;k<=f;k++){l=h[k]/c;for(b=0;b<=c;b++)m=JSM.CoordOffset(a[k],g[k],l*b),d.push(m)}for(k=0;k<f;k++)for(b=0;b<c;b++)a=k*(c+1)+b,d=a+1,g=a+c+1,h=g+1,a=[a,g,h,d],e.push(a)}};JSM.BodyVertex=function(a){this.position=a};JSM.BodyVertex.prototype.GetPosition=function(){return this.position};
|
||||
@ -110,14 +115,20 @@ JSM.Body.prototype.GetPolygon=function(a){return this.polygons[a]};JSM.Body.prot
|
||||
JSM.Body.prototype.SetTextureProjectionType=function(a){this.projection=a};JSM.Body.prototype.GetTextureProjectionCoords=function(){return this.coords};JSM.Body.prototype.SetTextureProjectionCoords=function(a){this.coords=a};JSM.Body.prototype.SetPlanarTextureProjection=function(a,b,c){this.SetTextureProjectionType("Planar");this.SetTextureProjectionCoords(new JSM.CoordSystem(a,b,JSM.VectorCross(b,c),new JSM.Coord(0,0,0)))};
|
||||
JSM.Body.prototype.SetCubicTextureProjection=function(a,b,c,d){this.SetTextureProjectionType("Cubic");this.SetTextureProjectionCoords(new JSM.CoordSystem(a,b,c,d))};JSM.Body.prototype.SetCylindricalTextureProjection=function(a,b,c,d){this.SetTextureProjectionType("Cylindrical");this.SetTextureProjectionCoords(new JSM.CoordSystem(a,JSM.VectorSetLength(c,b),JSM.VectorSetLength(JSM.VectorCross(d,c),b),d))};
|
||||
JSM.Body.prototype.Transform=function(a){var b;for(b=0;b<this.vertices.length;b++)this.vertices[b].position=a.Apply(this.vertices[b].position);null!==this.coords&&(b=JSM.CoordSystemToAbsoluteCoords(this.coords),b.origo=a.Apply(b.origo),b.e1=a.Apply(b.e1),b.e2=a.Apply(b.e2),b.e3=a.Apply(b.e3),this.coords=JSM.CoordSystemToDirectionVectors(b))};
|
||||
JSM.Body.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;for(c=0;c<this.vertices.length;c++)d=this.vertices[c].position,a.x=JSM.Minimum(a.x,d.x),a.y=JSM.Minimum(a.y,d.y),a.z=JSM.Minimum(a.z,d.z),b.x=JSM.Maximum(b.x,d.x),b.y=JSM.Maximum(b.y,d.y),b.z=JSM.Maximum(b.z,d.z);return[a,b]};JSM.Body.prototype.GetCenter=function(){var a=this.GetBoundingBox();return JSM.MidCoord(a[0],a[1])};
|
||||
JSM.Body.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;for(c=0;c<this.vertices.length;c++)d=this.vertices[c].position,a.x=JSM.Minimum(a.x,d.x),a.y=JSM.Minimum(a.y,d.y),a.z=JSM.Minimum(a.z,d.z),b.x=JSM.Maximum(b.x,d.x),b.y=JSM.Maximum(b.y,d.y),b.z=JSM.Maximum(b.z,d.z);return new JSM.Box(a,b)};JSM.Body.prototype.GetCenter=function(){return this.GetBoundingBox().GetCenter()};
|
||||
JSM.Body.prototype.GetBoundingSphereRadius=function(){var a=this.GetCenter(),b=0,c,d;for(c=0;c<this.vertices.length;c++)d=JSM.CoordDistance(a,this.vertices[c].position),JSM.IsGreater(d,b)&&(b=d);return b};JSM.Body.prototype.OffsetToOrigo=function(){var a=this.GetCenter(),a=JSM.VectorMultiply(a,-1),b;for(b=0;b<this.vertices.length;b++)this.vertices[b].position=JSM.CoordAdd(this.vertices[b].position,a)};
|
||||
JSM.Body.prototype.Merge=function(a){var b=this.vertices.length,c,d;for(c=0;c<a.VertexCount();c++)this.vertices.push(a.GetVertex(c).Clone());var e;for(c=0;c<a.PolygonCount();c++){e=a.GetPolygon(c).Clone();for(d=0;d<e.VertexIndexCount();d++)e.vertices[d]+=b;this.polygons.push(e)}};JSM.Body.prototype.Clear=function(){this.vertices=[];this.polygons=[];this.coords=this.projection=null};JSM.Model=function(){this.bodies=[]};
|
||||
JSM.Model.prototype.AddBody=function(a){this.bodies.push(a);return this.bodies.length-1};JSM.Model.prototype.GetBody=function(a){return this.bodies[a]};JSM.Model.prototype.BodyCount=function(){return this.bodies.length};JSM.Model.prototype.VertexCount=function(){var a=0,b;for(b=0;b<this.bodies.length;b++)a+=this.bodies[b].VertexCount();return a};JSM.Model.prototype.PolygonCount=function(){var a=0,b;for(b=0;b<this.bodies.length;b++)a+=this.bodies[b].PolygonCount();return a};
|
||||
JSM.HexColorToRGBComponents=function(a){for(var b=a.toString(16);6>b.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;c<a.VertexCount();c++)b.push([]);var e;for(c=0;c<a.PolygonCount();c++){e=a.GetPolygon(c);for(d=0;d<e.VertexIndexCount();d++)b[e.GetVertexIndex(d)].push(c)}return b};
|
||||
JSM.Materials.prototype.GetDefaultMaterial=function(){return this.defaultMaterial};JSM.Materials.prototype.Count=function(){return this.materials.length};JSM.VertInfo=function(){this.edges=[];this.pgons=[]};JSM.EdgeInfo=function(){this.pgon2=this.pgon1=this.vert2=this.vert1=-1};JSM.PolyEdgeInfo=function(){this.index=-1;this.reverse=!1};JSM.PgonInfo=function(){this.verts=[];this.pedges=[]};JSM.AdjacencyInfo=function(){this.verts=[];this.edges=[];this.pgons=[]};
|
||||
JSM.GetPolyEdgeStartVertex=function(a,b){return a.reverse?b.edges[a.index].vert2:b.edges[a.index].vert1};JSM.GetPolyEdgeEndVertex=function(a,b){return a.reverse?b.edges[a.index].vert1:b.edges[a.index].vert2};JSM.GetAnotherPgonOfEdge=function(a,b){return-1!=a.pgon1&&a.pgon1!=b?a.pgon1:-1!=a.pgon2&&a.pgon2!=b?a.pgon2:-1};
|
||||
JSM.CalculateAdjacencyInfo=function(a){var b=new JSM.AdjacencyInfo,c,d,e;for(c=0;c<a.VertexCount();c++)d=new JSM.VertInfo,b.verts.push(d);var f,g,h,k,l;for(c=0;c<a.PolygonCount();c++){f=a.GetPolygon(c);e=new JSM.PgonInfo;g=f.VertexIndexCount();for(d=0;d<g;d++){h=f.GetVertexIndex(d);k=f.GetVertexIndex(d<g-1?d+1:0);l=h;var m=k;k=c;for(var n=new JSM.PolyEdgeInfo,p=void 0,q=void 0,p=0;p<b.edges.length;p++)q=b.edges[p],q.vert1===l&&q.vert2===m?(n.index=p,n.reverse=!1):q.vert1===m&&q.vert2===l&&(n.index=
|
||||
p,n.reverse=!0);-1===n.index?(p=new JSM.EdgeInfo,p.vert1=l,p.vert2=m,p.pgon1=k,p.pgon2=-1,b.edges.push(p),n.index=b.edges.length-1,n.reverse=!1):(l=b.edges[n.index],-1===l.pgon1?l.pgon1=k:l.pgon1!==k&&-1===l.pgon2&&(l.pgon2=k));l=n;e.verts.push(h);e.pedges.push(l);b.verts[h].edges.push(l.index);b.verts[h].pgons.push(c)}b.pgons.push(e)}return b};JSM.IsSolidBody=function(a){a=JSM.CalculateAdjacencyInfo(a);var b,c;for(b=0;b<a.edges.length;b++)if(c=a.edges[b],-1===c.pgon1||-1===c.pgon2)return!1;return!0};
|
||||
JSM.CheckSolidBody=function(a){a=JSM.CalculateAdjacencyInfo(a);var b,c,d,e,f,g,h,k;for(b=0;b<a.edges.length;b++){d=a.edges[b];if(-1===d.pgon1||-1===d.pgon2)return!1;g=a.pgons[d.pgon1];f=!1;for(c=0;c<g.pedges.length;c++)if(e=g.pedges[c],e.index==b){h=e.reverse;f=!0;break}if(!f)return!1;d=a.pgons[d.pgon2];f=!1;for(c=0;c<d.pedges.length;c++)if(e=d.pedges[c],e.index==b){k=e.reverse;f=!0;break}if(!f||h==k)return!1}return!0};
|
||||
JSM.TraversePgonsAlongEdges=function(a,b,c){var d=[],e;for(e=0;e<b.pgons.length;e++)d.push(!1);for(a=[a];0<a.length;)if(e=a.pop(),!d[e]&&(d[e]=!0,c(e)))for(var f=b,g=a,h=f.pgons[e],k=void 0,l=void 0,l=void 0,k=0;k<h.pedges.length;k++)l=f.edges[h.pedges[k].index],l=JSM.GetAnotherPgonOfEdge(l,e),-1!=l&&g.push(l)};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;c<a.VertexCount();c++)b.push([]);var e;for(c=0;c<a.PolygonCount();c++){e=a.GetPolygon(c);for(d=0;d<e.VertexIndexCount();d++)b[e.GetVertexIndex(d)].push(c)}return b};
|
||||
JSM.CalculateBodyPolygonNormal=function(a,b){var c=a.GetPolygon(b),d=c.VertexIndexCount(),e=new JSM.Vector(0,0,0);if(3<=d){var f,g,h;for(f=0;f<d;f++)g=f,h=(f+1)%d,g=a.GetVertexPosition(c.GetVertexIndex(g)),h=a.GetVertexPosition(c.GetVertexIndex(h)),e.x+=(g.y-h.y)*(g.z+h.z),e.y+=(g.z-h.z)*(g.x+h.x),e.z+=(g.x-h.x)*(g.y+h.y)}return JSM.VectorNormalize(e)};JSM.CalculateBodyPolygonNormals=function(a){var b=[],c;for(c=0;c<a.PolygonCount();c++)b.push(JSM.CalculateBodyPolygonNormal(a,c));return b};
|
||||
JSM.CalculateBodyVertexNormals=function(a){var b=[],c=JSM.CalculateBodyPolygonNormals(a),d=null,e,f,g,h,k,l,m,n;for(e=0;e<a.PolygonCount();e++)if(h=a.GetPolygon(e),b[e]=[],h.HasCurveGroup()){null===d&&(d=JSM.CalculateBodyVertexToPolygon(a));for(f=0;f<h.VertexIndexCount();f++){k=new JSM.Vector(0,0,0);l=0;m=d[h.GetVertexIndex(f)];for(g=0;g<m.length;g++)n=a.GetPolygon(m[g]),n.GetCurveGroup()===h.GetCurveGroup()&&(k=JSM.CoordAdd(k,c[m[g]]),l++);k=JSM.VectorMultiply(k,1/l);k=JSM.VectorNormalize(k);b[e].push(k)}}else{g=
|
||||
c[e];for(f=0;f<h.VertexIndexCount();f++)b[e].push(new JSM.Vector(g.x,g.y,g.z))}return b};JSM.MakeBodyInsideOut=function(a){var b,c,d,e,f;for(b=0;b<a.PolygonCount();b++){d=a.GetPolygon(b);f=d.vertices.slice(0);e=f.length;d.vertices=[];for(c=0;c<e;c++)d.vertices.push(f[e-c-1])}};
|
||||
@ -126,11 +137,7 @@ JSM.CalculatePolygonCentroid=function(a,b){var c=a.GetPolygon(b),d=c.VertexIndex
|
||||
JSM.TriangulateWithCentroids=function(a){var b=new JSM.Body,c,d;for(c=0;c<a.VertexCount();c++)d=a.GetVertex(c).position,b.AddVertex(new JSM.BodyVertex(new JSM.Coord(d.x,d.y,d.z)));var e,f,g,h,k;for(c=0;c<a.PolygonCount();c++){d=JSM.CalculatePolygonCentroid(a,c);k=b.VertexCount();b.AddVertex(new JSM.BodyVertex(new JSM.Coord(d.x,d.y,d.z)));f=a.GetPolygon(c);g=f.VertexIndexCount();for(d=0;d<g;d++)e=f.GetVertexIndex(d),h=f.GetVertexIndex(d<g-1?d+1:0),e=new JSM.BodyPolygon([e,h,k]),e.material=f.material,
|
||||
e.curved=f.curved,b.AddPolygon(e)}return b};
|
||||
JSM.TriangulatePolygons=function(a){var b=new JSM.Body,c,d,e;for(c=0;c<a.VertexCount();c++)e=a.GetVertexPosition(c),b.AddVertex(new JSM.BodyVertex(new JSM.Coord(e.x,e.y,e.z)));var f,g;for(c=0;c<a.PolygonCount();c++){f=new JSM.Polygon;g=a.GetPolygon(c);for(d=0;d<g.VertexIndexCount();d++)e=a.GetVertexPosition(g.GetVertexIndex(d)),f.AddVertex(e.x,e.y,e.z);e=JSM.PolygonTriangulate(f);for(d=0;d<e.length;d++)f=e[d],f=new JSM.BodyPolygon([g.GetVertexIndex(f[0]),g.GetVertexIndex(f[1]),g.GetVertexIndex(f[2])]),
|
||||
f.InheritAttributes(g),b.AddPolygon(f)}return b};JSM.GenerateRandomMaterials=function(a,b,c){var d,e;for(d=0;d<a.PolygonCount();d++)e=void 0!==c&&c?JSM.SeededRandomInt(0,16777215,d+1):JSM.RandomInt(0,16777215),b.AddMaterial(new JSM.Material({ambient:e,diffuse:e})),e=b.Count()-1,a.GetPolygon(d).SetMaterialIndex(e)};JSM.VertInfo=function(){this.edges=[];this.pgons=[]};JSM.EdgeInfo=function(){this.pgon2=this.pgon1=this.vert2=this.vert1=-1};JSM.PolyEdgeInfo=function(){this.index=-1;this.reverse=!1};
|
||||
JSM.PgonInfo=function(){this.verts=[];this.pedges=[]};JSM.AdjacencyInfo=function(){this.verts=[];this.edges=[];this.pgons=[]};JSM.GetPolyEdgeStartVertex=function(a,b){return a.reverse?b.edges[a.index].vert2:b.edges[a.index].vert1};JSM.GetPolyEdgeEndVertex=function(a,b){return a.reverse?b.edges[a.index].vert1:b.edges[a.index].vert2};
|
||||
JSM.CalculateAdjacencyInfo=function(a){var b=new JSM.AdjacencyInfo,c,d,e;for(c=0;c<a.VertexCount();c++)d=new JSM.VertInfo,b.verts.push(d);var f,g,h,k,l;for(c=0;c<a.PolygonCount();c++){f=a.GetPolygon(c);e=new JSM.PgonInfo;g=f.VertexIndexCount();for(d=0;d<g;d++){h=f.GetVertexIndex(d);k=f.GetVertexIndex(d<g-1?d+1:0);l=h;var m=k;k=c;for(var n=new JSM.PolyEdgeInfo,p=void 0,q=void 0,p=0;p<b.edges.length;p++)q=b.edges[p],q.vert1===l&&q.vert2===m?(n.index=p,n.reverse=!1):q.vert1===m&&q.vert2===l&&(n.index=
|
||||
p,n.reverse=!0);-1===n.index?(p=new JSM.EdgeInfo,p.vert1=l,p.vert2=m,p.pgon1=k,p.pgon2=-1,b.edges.push(p),n.index=b.edges.length-1,n.reverse=!1):(l=b.edges[n.index],-1===l.pgon1?l.pgon1=k:l.pgon1!==k&&-1===l.pgon2&&(l.pgon2=k));l=n;e.verts.push(h);e.pedges.push(l);b.verts[h].edges.push(l.index);b.verts[h].pgons.push(c)}b.pgons.push(e)}return b};JSM.IsSolidBody=function(a){a=JSM.CalculateAdjacencyInfo(a);var b,c;for(b=0;b<a.edges.length;b++)if(c=a.edges[b],-1===c.pgon1||-1===c.pgon2)return!1;return!0};
|
||||
JSM.CheckSolidBody=function(a){a=JSM.CalculateAdjacencyInfo(a);var b,c,d,e,f,g,h,k;for(b=0;b<a.edges.length;b++){d=a.edges[b];if(-1===d.pgon1||-1===d.pgon2)return!1;g=a.pgons[d.pgon1];f=!1;for(c=0;c<g.pedges.length;c++)if(e=g.pedges[c],e.index==b){h=e.reverse;f=!0;break}if(!f)return!1;d=a.pgons[d.pgon2];f=!1;for(c=0;c<d.pedges.length;c++)if(e=d.pedges[c],e.index==b){k=e.reverse;f=!0;break}if(!f||h==k)return!1}return!0};
|
||||
f.InheritAttributes(g),b.AddPolygon(f)}return b};JSM.GenerateRandomMaterials=function(a,b,c){var d,e;for(d=0;d<a.PolygonCount();d++)e=void 0!==c&&c?JSM.SeededRandomInt(0,16777215,d+1):JSM.RandomInt(0,16777215),b.AddMaterial(new JSM.Material({ambient:e,diffuse:e})),e=b.Count()-1,a.GetPolygon(d).SetMaterialIndex(e)};
|
||||
JSM.CalculatePlanarTextureCoord=function(a,b){var c=new JSM.Coord2D(0,0),d=JSM.VectorNormalize(b.e1),e=JSM.VectorNormalize(b.e2),f=JSM.VectorCross(b.e1,b.e2),f=JSM.GetPlaneFromCoordAndDirection(b.origo,f),e=JSM.GetPlaneFromCoordAndDirection(b.origo,e),d=JSM.GetPlaneFromCoordAndDirection(b.origo,d),f=JSM.ProjectCoordToPlane(a,f);c.x=JSM.CoordPlaneSignedDistance(f,d);c.y=JSM.CoordPlaneSignedDistance(f,e);return c};
|
||||
JSM.CalculateCubicTextureCoord=function(a,b,c){var d=new JSM.Coord2D(0,0),e=JSM.VectorNormalize(c.e1),f=JSM.VectorNormalize(c.e2),g=JSM.VectorNormalize(c.e3),h=-1,k=0,l,m,n;for(l=0;3>l;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;c<this.bodies.length;c++){e=this.bodies[c][0];for(d=0;d<e.VertexCount();d++)f=e.GetVertex(d),a.x=JSM.Minimum(a.x,f.position.x),a.y=JSM.Minimum(a.y,f.position.y),a.z=JSM.Minimum(a.z,f.position.z),b.x=JSM.Maximum(b.x,f.position.x),b.y=JSM.Maximum(b.y,f.position.y),b.z=JSM.Maximum(b.z,f.position.z)}return[a,b]};
|
||||
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(){return this.GetBoundingBox().GetCenter()};
|
||||
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;c<this.bodies.length;c++){e=this.bodies[c][0];for(d=0;d<e.VertexCount();d++)f=e.GetVertex(d),a.x=JSM.Minimum(a.x,f.position.x),a.y=JSM.Minimum(a.y,f.position.y),a.z=JSM.Minimum(a.z,f.position.z),b.x=JSM.Maximum(b.x,f.position.x),b.y=JSM.Maximum(b.y,f.position.y),b.z=JSM.Maximum(b.z,f.position.z)}return new JSM.Box(a,b)};
|
||||
JSM.SoftwareViewer.prototype.GetBoundingSphereRadius=function(a){if(void 0===a||null===a)a=this.GetCenter();var b=0,c,d,e,f;for(c=0;c<this.bodies.length;c++){e=this.bodies[c][0];for(d=0;d<e.VertexCount();d++)f=e.GetVertex(d),f=JSM.CoordDistance(a,f.position),JSM.IsGreater(f,b)&&(b=f)}return b};JSM.SoftwareViewer.prototype.Resize=function(){this.Draw()};
|
||||
JSM.SoftwareViewer.prototype.Draw=function(){var a,b;this.drawer.Clear();for(a=0;a<this.bodies.length;a++)b=this.bodies[a],JSM.DrawProjectedBody(b[0],b[1],this.camera,this.drawMode,!1,this.drawer);return!0};JSM.SpriteViewer=function(){this.navigation=this.projected=this.points=this.callbacks=this.camera=this.canvas=null};JSM.SpriteViewer.prototype.Start=function(a,b,c){return!this.InitCanvas(a)||!this.InitCamera(b)||!this.InitCallbacks(c)?!1:!0};
|
||||
JSM.SpriteViewer.prototype.InitCanvas=function(a){this.points=[];this.canvas=a;return!this.canvas?!1:!0};JSM.SpriteViewer.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))?!1:!0};
|
||||
JSM.SpriteViewer.prototype.InitCallbacks=function(a){this.callbacks={onPointDraw:null};void 0!==a&&(void 0!==a.onDrawStart&&(this.callbacks.onDrawStart=a.onDrawStart),void 0!==a.onPointDraw&&(this.callbacks.onPointDraw=a.onPointDraw),void 0!==a.onDrawEnd&&(this.callbacks.onDrawEnd=a.onDrawEnd));return!0};JSM.SpriteViewer.prototype.AddPoint=function(a){this.points.push(a)};JSM.SpriteViewer.prototype.RemovePoints=function(){this.points=[]};JSM.SpriteViewer.prototype.Resize=function(){this.Draw()};
|
||||
JSM.SpriteViewer.prototype.NearestPointUnderPosition=function(a,b,c){b=new JSM.Coord2D(b,c);c=-1;var d=JSM.Inf,e,f,g;for(e=0;e<this.projected.length;e++)f=this.projected[e],g=JSM.CoordDistance2D(new JSM.Coord2D(f.position.x,f.position.y),b),JSM.IsLower(g,a)&&JSM.IsLower(g,d)&&(c=f.originalIndex,d=g);return c};JSM.SpriteViewer.prototype.NearestPointUnderMouse=function(a){return this.NearestPointUnderPosition(a,this.navigation.mouse.currX,this.navigation.mouse.currY)};
|
||||
JSM.SpriteViewer.prototype.NearestPointUnderTouch=function(a){return this.NearestPointUnderPosition(a,this.navigation.touch.currX,this.navigation.touch.currY)};JSM.SpriteViewer.prototype.FitInWindow=function(){var a=this.GetCenter(),b=this.GetBoundingSphereRadius(a);this.navigation.FitInWindow(a,b);this.Draw()};JSM.SpriteViewer.prototype.GetCenter=function(){var a=this.GetBoundingBox();return JSM.MidCoord(a[0],a[1])};
|
||||
JSM.SpriteViewer.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;for(c=0;c<this.points.length;c++)d=this.points[c],a.x=JSM.Minimum(a.x,d.x),a.y=JSM.Minimum(a.y,d.y),a.z=JSM.Minimum(a.z,d.z),b.x=JSM.Maximum(b.x,d.x),b.y=JSM.Maximum(b.y,d.y),b.z=JSM.Maximum(b.z,d.z);return[a,b]};
|
||||
JSM.SpriteViewer.prototype.NearestPointUnderTouch=function(a){return this.NearestPointUnderPosition(a,this.navigation.touch.currX,this.navigation.touch.currY)};JSM.SpriteViewer.prototype.FitInWindow=function(){var a=this.GetCenter(),b=this.GetBoundingSphereRadius(a);this.navigation.FitInWindow(a,b);this.Draw()};JSM.SpriteViewer.prototype.GetCenter=function(){return this.GetBoundingBox().GetCenter()};
|
||||
JSM.SpriteViewer.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;for(c=0;c<this.points.length;c++)d=this.points[c],a.x=JSM.Minimum(a.x,d.x),a.y=JSM.Minimum(a.y,d.y),a.z=JSM.Minimum(a.z,d.z),b.x=JSM.Maximum(b.x,d.x),b.y=JSM.Maximum(b.y,d.y),b.z=JSM.Maximum(b.z,d.z);return new JSM.Box(a,b)};
|
||||
JSM.SpriteViewer.prototype.GetBoundingSphereRadius=function(a){if(void 0===a||null===a)a=this.GetCenter();var b=0,c,d;for(c=0;c<this.points.length;c++)d=this.points[c],d=JSM.CoordDistance(a,d),JSM.IsGreater(d,b)&&(b=d);return b};
|
||||
JSM.SpriteViewer.prototype.Draw=function(){if(null!==this.callbacks.onDrawStart)this.callbacks.onDrawStart(this.canvas);var a=this.canvas.width/this.canvas.height,b=[0,0,this.canvas.width,this.canvas.height];this.projected=[];var c,d;for(c=0;c<this.points.length;c++)d=this.points[c],d=JSM.Project(d,this.camera.eye,this.camera.center,this.camera.up,this.camera.fieldOfView*JSM.DegRad,a,this.camera.nearClippingPlane,this.camera.farClippingPlane,b),d.y=this.canvas.height-d.y,null!==d&&this.projected.push({position:d,
|
||||
originalIndex:c});this.projected.sort(function(a,b){return a.position.z>b.position.z?-1:a.position.z<b.position.z?1:0});for(c=0;c<this.projected.length;c++)if(null!==this.callbacks.onPointDraw)this.callbacks.onPointDraw(this.canvas,this.projected[c].originalIndex,this.projected[c].position);if(null!==this.callbacks.onDrawEnd)this.callbacks.onDrawEnd(this.canvas);return!0};JSM.Viewer=function(){this.navigation=this.renderer=null};
|
||||
JSM.Viewer.prototype.Init=function(a,b,c){return!this.InitRenderer(a,b,c)||!this.InitNavigation()?!1:!0};JSM.Viewer.prototype.InitRenderer=function(a,b,c){this.renderer=new JSM.Renderer;return!this.renderer.Init(a,b,c)?!1:!0};JSM.Viewer.prototype.InitNavigation=function(){this.navigation=new JSM.Navigation;return!this.navigation.Init(this.renderer.canvas,this.renderer.camera,this.Draw.bind(this),this.Resize.bind(this))?!1:!0};
|
||||
JSM.Viewer.prototype.SetClearColor=function(a,b,c){this.renderer.SetClearColor(a,b,c);this.Draw()};JSM.Viewer.prototype.AddGeometries=function(a){this.renderer.AddGeometries(a);this.Draw()};JSM.Viewer.prototype.RemoveGeometries=function(){this.renderer.RemoveGeometries();this.Draw()};JSM.Viewer.prototype.FitInWindow=function(){var a=this.GetCenter(),b=this.GetBoundingSphereRadius(a);this.navigation.FitInWindow(a,b);this.Draw()};
|
||||
JSM.Viewer.prototype.GetCenter=function(){var a=this.GetBoundingBox();return JSM.MidCoord(a[0],a[1])};
|
||||
JSM.Viewer.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;c<this.renderer.geometries.length;c++){e=this.renderer.geometries[c];for(d=0;d<e.VertexCount();d+=1)f=e.GetTransformedVertex(d),a.x=JSM.Minimum(a.x,f.x),a.y=JSM.Minimum(a.y,f.y),a.z=JSM.Minimum(a.z,f.z),b.x=JSM.Maximum(b.x,f.x),b.y=JSM.Maximum(b.y,f.y),b.z=JSM.Maximum(b.z,f.z)}return[a,b]};
|
||||
JSM.Viewer.prototype.SetClearColor=function(a,b,c){this.renderer.SetClearColor(a,b,c);this.Draw()};JSM.Viewer.prototype.AddGeometries=function(a){this.renderer.AddGeometries(a);this.Draw()};JSM.Viewer.prototype.RemoveGeometries=function(){this.renderer.RemoveGeometries();this.Draw()};JSM.Viewer.prototype.FitInWindow=function(){var a=this.GetCenter(),b=this.GetBoundingSphereRadius(a);this.navigation.FitInWindow(a,b);this.Draw()};JSM.Viewer.prototype.GetCenter=function(){return this.GetBoundingBox().GetCenter()};
|
||||
JSM.Viewer.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;c<this.renderer.geometries.length;c++){e=this.renderer.geometries[c];for(d=0;d<e.VertexCount();d+=1)f=e.GetTransformedVertex(d),a.x=JSM.Minimum(a.x,f.x),a.y=JSM.Minimum(a.y,f.y),a.z=JSM.Minimum(a.z,f.z),b.x=JSM.Maximum(b.x,f.x),b.y=JSM.Maximum(b.y,f.y),b.z=JSM.Maximum(b.z,f.z)}return new JSM.Box(a,b)};
|
||||
JSM.Viewer.prototype.GetBoundingSphereRadius=function(a){if(void 0===a||null===a)a=this.GetCenter();var b=0,c,d,e,f;for(c=0;c<this.renderer.geometries.length;c++){e=this.renderer.geometries[c];for(d=0;d<e.VertexCount();d+=1)f=e.GetTransformedVertex(d),f=JSM.CoordDistance(a,f),JSM.IsGreater(f,b)&&(b=f)}return b};JSM.Viewer.prototype.Resize=function(){this.renderer.Resize();this.Draw()};JSM.Viewer.prototype.Draw=function(){this.renderer.Render()};
|
||||
JSM.PointCloudViewer=function(){this.navigation=this.renderer=this.canvas=null};JSM.PointCloudViewer.prototype.Init=function(a,b){return!this.InitRenderer(a,b)||!this.InitNavigation()?!1:!0};JSM.PointCloudViewer.prototype.InitRenderer=function(a,b){this.renderer=new JSM.PointCloudRenderer;return!this.renderer.Init(a,b)?!1:!0};
|
||||
JSM.PointCloudViewer.prototype.InitNavigation=function(){this.navigation=new JSM.Navigation;return!this.navigation.Init(this.renderer.canvas,this.renderer.camera,this.Draw.bind(this),this.Resize.bind(this))?!1:!0};JSM.PointCloudViewer.prototype.SetClearColor=function(a,b,c){this.renderer.SetClearColor(a,b,c)};JSM.PointCloudViewer.prototype.SetPointSize=function(a){this.renderer.SetPointSize(a)};JSM.PointCloudViewer.prototype.AddPoints=function(a,b){this.renderer.AddPoints(a,b)};
|
||||
JSM.PointCloudViewer.prototype.RemovePoints=function(){this.renderer.RemovePoints()};JSM.PointCloudViewer.prototype.FitInWindow=function(){var a=this.GetCenter(),b=this.GetBoundingSphereRadius(a);this.navigation.FitInWindow(a,b);this.Draw()};JSM.PointCloudViewer.prototype.GetCenter=function(){var a=this.GetBoundingBox();return JSM.MidCoord(a[0],a[1])};
|
||||
JSM.PointCloudViewer.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;c<this.renderer.points.length;c++){e=this.renderer.points[c].pointArray;for(d=0;d<e.length;d+=3)f=new JSM.Coord(e[d],e[d+1],e[d+2]),a.x=JSM.Minimum(a.x,f.x),a.y=JSM.Minimum(a.y,f.y),a.z=JSM.Minimum(a.z,f.z),b.x=JSM.Maximum(b.x,f.x),b.y=JSM.Maximum(b.y,f.y),b.z=JSM.Maximum(b.z,f.z)}return[a,b]};
|
||||
JSM.PointCloudViewer.prototype.RemovePoints=function(){this.renderer.RemovePoints()};JSM.PointCloudViewer.prototype.FitInWindow=function(){var a=this.GetCenter(),b=this.GetBoundingSphereRadius(a);this.navigation.FitInWindow(a,b);this.Draw()};JSM.PointCloudViewer.prototype.GetCenter=function(){return this.GetBoundingBox().GetCenter()};
|
||||
JSM.PointCloudViewer.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;c<this.renderer.points.length;c++){e=this.renderer.points[c].pointArray;for(d=0;d<e.length;d+=3)f=new JSM.Coord(e[d],e[d+1],e[d+2]),a.x=JSM.Minimum(a.x,f.x),a.y=JSM.Minimum(a.y,f.y),a.z=JSM.Minimum(a.z,f.z),b.x=JSM.Maximum(b.x,f.x),b.y=JSM.Maximum(b.y,f.y),b.z=JSM.Maximum(b.z,f.z)}return new JSM.Box(a,b)};
|
||||
JSM.PointCloudViewer.prototype.GetBoundingSphereRadius=function(a){if(void 0===a||null===a)a=this.GetCenter();var b=0,c,d,e,f;for(c=0;c<this.renderer.points.length;c++){e=this.renderer.points[c].pointArray;for(d=0;d<e.length;d+=3)f=new JSM.Coord(e[d],e[d+1],e[d+2]),f=JSM.CoordDistance(a,f),JSM.IsGreater(f,b)&&(b=f)}return b};JSM.PointCloudViewer.prototype.Resize=function(){this.renderer.Resize();this.Draw()};JSM.PointCloudViewer.prototype.Draw=function(){this.renderer.Render()};
|
||||
JSM.IsPowerOfTwo=function(a){return a&0===a-1};JSM.NextPowerOfTwo=function(a){if(JSM.IsPowerOfTwo(a))return a;for(var b=1;b<a;)b*=2;return b};JSM.ResizeImageToPowerOfTwoSides=function(a){if(JSM.IsPowerOfTwo(a.width)&&!JSM.IsPowerOfTwo(a.height))return a;var b=JSM.NextPowerOfTwo(a.width),c=JSM.NextPowerOfTwo(a.height),d=document.createElement("canvas");d.width=b;d.height=c;d=d.getContext("2d");d.drawImage(a,0,0,b,c);return d.getImageData(0,0,b,c)};
|
||||
JSM.ConvertBodyToThreeMeshes=function(a,b,c){var d={textureLoadedCallback:null,hasConvexPolygons:!1,doubleSided:!0};void 0!==c&&null!==c&&(d.textureLoadedCallback=JSM.ValueOrDefault(c.textureLoadedCallback,d.textureLoadedCallback),d.hasConvexPolygons=JSM.ValueOrDefault(c.hasConvexPolygons,d.hasConvexPolygons),d.doubleSided=JSM.ValueOrDefault(c.doubleSided,d.doubleSided));var e=[],f=null;JSM.ExplodeBodyToTriangles(a,b,{hasConvexPolygons:d.hasConvexPolygons,onGeometryStart:function(){f=new THREE.Geometry},
|
||||
@ -523,9 +529,8 @@ JSM.ThreeViewer.prototype.AddMesh=function(a){this.scene.add(a);this.DrawIfNeede
|
||||
JSM.ThreeViewer.prototype.FaceCount=function(){var a=0;this.scene.traverse(function(b){b instanceof THREE.Mesh&&(a+=b.geometry.faces.length)});return a};JSM.ThreeViewer.prototype.GetMesh=function(a){var b=null,c=0,d;for(d=0;d<this.scene.children.length;d++)if(b=this.scene.children[d],b instanceof THREE.Mesh){if(c==a)return b;c+=1}return null};JSM.ThreeViewer.prototype.RemoveMesh=function(a){this.scene.remove(a);this.DrawIfNeeded()};
|
||||
JSM.ThreeViewer.prototype.RemoveMeshes=function(){var a,b;for(b=0;b<this.scene.children.length;b++)a=this.scene.children[b],a instanceof THREE.Mesh&&(this.scene.remove(a),b--);this.DrawIfNeeded()};JSM.ThreeViewer.prototype.RemoveLastMesh=function(){var a=null;this.scene.traverse(function(b){b instanceof THREE.Mesh&&(a=b)});null!==a&&this.scene.remove(a);this.DrawIfNeeded()};
|
||||
JSM.ThreeViewer.prototype.SetCamera=function(a,b,c){this.navigation.SetCamera(a,b,c);this.navigation.SetOrbitCenter(b.Clone());this.DrawIfNeeded()};JSM.ThreeViewer.prototype.Resize=function(){this.camera.aspect=this.canvas.width/this.canvas.height;this.camera.updateProjectionMatrix();this.renderer.setSize(this.canvas.width,this.canvas.height);this.DrawIfNeeded()};
|
||||
JSM.ThreeViewer.prototype.FitInWindow=function(){if(0!==this.MeshCount()){var a=this.GetCenter(),b=this.GetBoundingSphereRadius(a);this.navigation.FitInWindow(a,b);this.DrawIfNeeded()}};JSM.ThreeViewer.prototype.AdjustClippingPlanes=function(a){var b=this.GetCenter();this.GetBoundingSphereRadius(b)<a?(this.camera.near=0.1,this.camera.far=1E3):(this.camera.near=10,this.camera.far=1E6);this.camera.updateProjectionMatrix();this.Draw()};
|
||||
JSM.ThreeViewer.prototype.GetCenter=function(){var a=this.GetBoundingBox();return JSM.MidCoord(a[0],a[1])};
|
||||
JSM.ThreeViewer.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;this.scene.traverse(function(e){if(e instanceof THREE.Mesh){c=e.geometry;var f;for(f=0;f<c.vertices.length;f++)d=c.vertices[f].clone(),d.add(e.position),a.x=JSM.Minimum(a.x,d.x),a.y=JSM.Minimum(a.y,d.y),a.z=JSM.Minimum(a.z,d.z),b.x=JSM.Maximum(b.x,d.x),b.y=JSM.Maximum(b.y,d.y),b.z=JSM.Maximum(b.z,d.z)}});return[a,b]};
|
||||
JSM.ThreeViewer.prototype.FitInWindow=function(){if(0!==this.MeshCount()){var a=this.GetCenter(),b=this.GetBoundingSphereRadius(a);this.navigation.FitInWindow(a,b);this.DrawIfNeeded()}};JSM.ThreeViewer.prototype.AdjustClippingPlanes=function(a){var b=this.GetCenter();this.GetBoundingSphereRadius(b)<a?(this.camera.near=0.1,this.camera.far=1E3):(this.camera.near=10,this.camera.far=1E6);this.camera.updateProjectionMatrix();this.Draw()};JSM.ThreeViewer.prototype.GetCenter=function(){return this.GetBoundingBox().GetCenter()};
|
||||
JSM.ThreeViewer.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;this.scene.traverse(function(e){if(e instanceof THREE.Mesh){c=e.geometry;var f;for(f=0;f<c.vertices.length;f++)d=c.vertices[f].clone(),d.add(e.position),a.x=JSM.Minimum(a.x,d.x),a.y=JSM.Minimum(a.y,d.y),a.z=JSM.Minimum(a.z,d.z),b.x=JSM.Maximum(b.x,d.x),b.y=JSM.Maximum(b.y,d.y),b.z=JSM.Maximum(b.z,d.z)}});return new JSM.Box(a,b)};
|
||||
JSM.ThreeViewer.prototype.GetBoundingSphereRadius=function(a){if(void 0===a||null===a)a=this.GetCenter();var b=0,c,d,e;this.scene.traverse(function(f){if(f instanceof THREE.Mesh){c=f.geometry;var g;for(g=0;g<c.vertices.length;g++)d=c.vertices[g].clone(),d.add(f.position),e=JSM.CoordDistance(a,new JSM.Coord(d.x,d.y,d.z)),JSM.IsGreater(e,b)&&(b=e)}});return b};
|
||||
JSM.ThreeViewer.prototype.GetObjectsUnderPosition=function(a,b){var c=2*(a/this.canvas.width)-1,d=2*-(b/this.canvas.height)+1,e=new THREE.Projector,f=this.camera.position,c=new THREE.Vector3(c,d,0.5);e.unprojectVector(c,this.camera);c.sub(f);c.normalize();return(new THREE.Raycaster(f,c)).intersectObjects(this.scene.children)};JSM.ThreeViewer.prototype.GetObjectsUnderMouse=function(){return this.GetObjectsUnderPosition(this.navigation.mouse.currX,this.navigation.mouse.currY)};
|
||||
JSM.ThreeViewer.prototype.GetObjectsUnderTouch=function(){return this.GetObjectsUnderPosition(this.navigation.touch.currX,this.navigation.touch.currY)};JSM.ThreeViewer.prototype.ProjectVector=function(a,b,c){var d=this.canvas.width/2,e=this.canvas.height/2,f=new THREE.Projector;a=new THREE.Vector3(a,b,c);f.projectVector(a,this.camera);a.x=a.x*d+d;a.y=-(a.y*e)+e;return a};JSM.ThreeViewer.prototype.EnableDraw=function(a){this.enableDraw=a};
|
||||
|
||||
@ -29,7 +29,7 @@ ImporterApp.prototype.Init = function ()
|
||||
var myThis = this;
|
||||
var top = document.getElementById ('top');
|
||||
var importerButtons = new ImporterButtons (top);
|
||||
importerButtons.AddLogo ('Online 3D Viewer <span class="version">v 0.2</span>', function () { myThis.WelcomeDialog (); });
|
||||
importerButtons.AddLogo ('Online 3D Viewer <span class="version">v 0.3</span>', 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 (); });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user